get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/118267/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 118267,
    "url": "https://patches.dpdk.org/api/patches/118267/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1666006905-74029-7-git-send-email-andy.pei@intel.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1666006905-74029-7-git-send-email-andy.pei@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1666006905-74029-7-git-send-email-andy.pei@intel.com",
    "date": "2022-10-17T11:41:43",
    "name": "[v6,6/8] vdpa/ifc: support dynamic enable/disable queue",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "c40ffdbec4cbd619e2de8e659b9175321b369adb",
    "submitter": {
        "id": 1185,
        "url": "https://patches.dpdk.org/api/people/1185/?format=api",
        "name": "Pei, Andy",
        "email": "andy.pei@intel.com"
    },
    "delegate": {
        "id": 2642,
        "url": "https://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1666006905-74029-7-git-send-email-andy.pei@intel.com/mbox/",
    "series": [
        {
            "id": 25258,
            "url": "https://patches.dpdk.org/api/series/25258/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=25258",
            "date": "2022-10-17T11:41:37",
            "name": "vdpa/ifc: add multi queue support",
            "version": 6,
            "mbox": "https://patches.dpdk.org/series/25258/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/118267/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/118267/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 86939A055F;\n\tMon, 17 Oct 2022 13:46:15 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 580CD41614;\n\tMon, 17 Oct 2022 13:45:54 +0200 (CEST)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n by mails.dpdk.org (Postfix) with ESMTP id 6911D4114E\n for <dev@dpdk.org>; Mon, 17 Oct 2022 13:45:50 +0200 (CEST)",
            "from orsmga007.jf.intel.com ([10.7.209.58])\n by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 17 Oct 2022 04:45:49 -0700",
            "from dpdk-dipei.sh.intel.com ([10.67.110.251])\n by orsmga007.jf.intel.com with ESMTP; 17 Oct 2022 04:45:47 -0700"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1666007150; x=1697543150;\n h=from:to:cc:subject:date:message-id:in-reply-to: references;\n bh=VMY/XQgY3LiXk3abQWsaQCKGKFqsmcMrD2+Gz98WQA0=;\n b=WsadmO5nM736+DggVNy72kNqcKtYTQRKiqed0vAmlGEd31lyraMnvLvF\n CY8Kv7MBX3CVX0DIBPiIB4GDM3DSAZdU2K2Ts8ucdm1fAXtMEv5hqrnCr\n 7Mu6R9ya1LtWsOc4iL8mDTrF5PSk+5OU3CI+icaYY+fnpRAxw+yGc7/MJ\n qvFB1E/cofxJiNncREC6Y1XDkd/4USqlh14R4pqIA2mrU5RD1flCUAHbI\n 5IXGxLwHIqcn7kyciIPb2p08F7aDAyEdcCpjtTz1YnWCwO0w7rA/B/N0K\n yrxWRmQ9KNS5C9II5mfZ6WrhS/W+kJtjqi8sDbfPvxEdHAf5NCXESkiKm w==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6500,9779,10502\"; a=\"305763847\"",
            "E=Sophos;i=\"5.95,191,1661842800\"; d=\"scan'208\";a=\"305763847\"",
            "E=McAfee;i=\"6500,9779,10502\"; a=\"623199960\"",
            "E=Sophos;i=\"5.95,191,1661842800\"; d=\"scan'208\";a=\"623199960\""
        ],
        "X-ExtLoop1": "1",
        "From": "Andy Pei <andy.pei@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "chenbo.xia@intel.com, rosen.xu@intel.com, wei.huang@intel.com,\n gang.cao@intel.com, maxime.coquelin@redhat.com",
        "Subject": "[PATCH v6 6/8] vdpa/ifc: support dynamic enable/disable queue",
        "Date": "Mon, 17 Oct 2022 19:41:43 +0800",
        "Message-Id": "<1666006905-74029-7-git-send-email-andy.pei@intel.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1666006905-74029-1-git-send-email-andy.pei@intel.com>",
        "References": "<1661229305-240952-2-git-send-email-andy.pei@intel.com>\n <1666006905-74029-1-git-send-email-andy.pei@intel.com>",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "From: Huang Wei <wei.huang@intel.com>\n\nSupport dynamic enable or disable queue.\nFor front end, like QEMU, user can use ethtool to configure queue.\nFor example, \"ethtool -L eth0 combined 3\" to enable 3 queues pairs.\n\nSigned-off-by: Huang Wei <wei.huang@intel.com>\nSigned-off-by: Andy Pei <andy.pei@intel.com>\nReviewed-by: Chenbo Xia <chenbo.xia@intel.com>\n---\n drivers/vdpa/ifc/base/ifcvf.c | 100 ++++++++++++++++++++++++++++++++++++++++++\n drivers/vdpa/ifc/base/ifcvf.h |   6 +++\n drivers/vdpa/ifc/ifcvf_vdpa.c |  93 ++++++++++++++++++++++++++++++++-------\n 3 files changed, 184 insertions(+), 15 deletions(-)",
    "diff": "diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c\nindex 30bb8cb..869ddd6 100644\n--- a/drivers/vdpa/ifc/base/ifcvf.c\n+++ b/drivers/vdpa/ifc/base/ifcvf.c\n@@ -233,6 +233,106 @@\n \t}\n }\n \n+int\n+ifcvf_enable_vring_hw(struct ifcvf_hw *hw, int i)\n+{\n+\tstruct ifcvf_pci_common_cfg *cfg;\n+\tu8 *lm_cfg;\n+\tu16 notify_off;\n+\tint msix_vector;\n+\n+\tif (i >= (int)hw->nr_vring)\n+\t\treturn -1;\n+\n+\tcfg = hw->common_cfg;\n+\tif (!cfg) {\n+\t\tRTE_LOG(ERR, PMD, \"common_cfg in HW is NULL.\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tifcvf_enable_mq(hw);\n+\n+\tIFCVF_WRITE_REG16(i, &cfg->queue_select);\n+\tmsix_vector = IFCVF_READ_REG16(&cfg->queue_msix_vector);\n+\tif (msix_vector != (i + 1)) {\n+\t\tIFCVF_WRITE_REG16(i + 1, &cfg->queue_msix_vector);\n+\t\tmsix_vector = IFCVF_READ_REG16(&cfg->queue_msix_vector);\n+\t\tif (msix_vector == IFCVF_MSI_NO_VECTOR) {\n+\t\t\tRTE_LOG(ERR, PMD, \"queue %d, msix vec alloc failed\\n\",\n+\t\t\t\ti);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\tio_write64_twopart(hw->vring[i].desc, &cfg->queue_desc_lo,\n+\t\t\t&cfg->queue_desc_hi);\n+\tio_write64_twopart(hw->vring[i].avail, &cfg->queue_avail_lo,\n+\t\t\t&cfg->queue_avail_hi);\n+\tio_write64_twopart(hw->vring[i].used, &cfg->queue_used_lo,\n+\t\t\t&cfg->queue_used_hi);\n+\tIFCVF_WRITE_REG16(hw->vring[i].size, &cfg->queue_size);\n+\n+\tlm_cfg = hw->lm_cfg;\n+\tif (lm_cfg) {\n+\t\tif (hw->device_type == IFCVF_BLK)\n+\t\t\t*(u32 *)(lm_cfg + IFCVF_LM_RING_STATE_OFFSET +\n+\t\t\t\ti * IFCVF_LM_CFG_SIZE) =\n+\t\t\t\t(u32)hw->vring[i].last_avail_idx |\n+\t\t\t\t((u32)hw->vring[i].last_used_idx << 16);\n+\t\telse\n+\t\t\t*(u32 *)(lm_cfg + IFCVF_LM_RING_STATE_OFFSET +\n+\t\t\t\t(i / 2) * IFCVF_LM_CFG_SIZE +\n+\t\t\t\t(i % 2) * 4) =\n+\t\t\t\t(u32)hw->vring[i].last_avail_idx |\n+\t\t\t\t((u32)hw->vring[i].last_used_idx << 16);\n+\t}\n+\n+\tnotify_off = IFCVF_READ_REG16(&cfg->queue_notify_off);\n+\thw->notify_addr[i] = (void *)((u8 *)hw->notify_base +\n+\t\t\tnotify_off * hw->notify_off_multiplier);\n+\tIFCVF_WRITE_REG16(1, &cfg->queue_enable);\n+\n+\treturn 0;\n+}\n+\n+void\n+ifcvf_disable_vring_hw(struct ifcvf_hw *hw, int i)\n+{\n+\tstruct ifcvf_pci_common_cfg *cfg;\n+\tu32 ring_state;\n+\tu8 *lm_cfg;\n+\n+\tif (i >= (int)hw->nr_vring)\n+\t\treturn;\n+\n+\tcfg = hw->common_cfg;\n+\tif (!cfg) {\n+\t\tRTE_LOG(ERR, PMD, \"common_cfg in HW is NULL.\\n\");\n+\t\treturn;\n+\t}\n+\n+\tIFCVF_WRITE_REG16(i, &cfg->queue_select);\n+\tIFCVF_WRITE_REG16(0, &cfg->queue_enable);\n+\n+\tlm_cfg = hw->lm_cfg;\n+\tif (lm_cfg) {\n+\t\tif (hw->device_type == IFCVF_BLK) {\n+\t\t\tring_state = *(u32 *)(lm_cfg +\n+\t\t\t\t\tIFCVF_LM_RING_STATE_OFFSET +\n+\t\t\t\t\ti * IFCVF_LM_CFG_SIZE);\n+\t\t\thw->vring[i].last_avail_idx =\n+\t\t\t\t(u16)(ring_state & IFCVF_16_BIT_MASK);\n+\t\t} else {\n+\t\t\tring_state = *(u32 *)(lm_cfg +\n+\t\t\t\t\tIFCVF_LM_RING_STATE_OFFSET +\n+\t\t\t\t\t(i / 2) * IFCVF_LM_CFG_SIZE +\n+\t\t\t\t\t(i % 2) * 4);\n+\t\t\thw->vring[i].last_avail_idx = (u16)(ring_state >> 16);\n+\t\t}\n+\t\thw->vring[i].last_used_idx = (u16)(ring_state >> 16);\n+\t}\n+}\n+\n STATIC int\n ifcvf_hw_enable(struct ifcvf_hw *hw)\n {\ndiff --git a/drivers/vdpa/ifc/base/ifcvf.h b/drivers/vdpa/ifc/base/ifcvf.h\nindex 1e133c0..3726da7 100644\n--- a/drivers/vdpa/ifc/base/ifcvf.h\n+++ b/drivers/vdpa/ifc/base/ifcvf.h\n@@ -164,6 +164,12 @@ struct ifcvf_hw {\n ifcvf_get_features(struct ifcvf_hw *hw);\n \n int\n+ifcvf_enable_vring_hw(struct ifcvf_hw *hw, int i);\n+\n+void\n+ifcvf_disable_vring_hw(struct ifcvf_hw *hw, int i);\n+\n+int\n ifcvf_start_hw(struct ifcvf_hw *hw);\n \n void\ndiff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c\nindex 0c3407a..9c49f9c 100644\n--- a/drivers/vdpa/ifc/ifcvf_vdpa.c\n+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c\n@@ -1282,13 +1282,59 @@ struct rte_vdpa_dev_info {\n }\n \n static int\n+ifcvf_config_vring(struct ifcvf_internal *internal, int vring)\n+{\n+\tstruct ifcvf_hw *hw = &internal->hw;\n+\tint vid = internal->vid;\n+\tstruct rte_vhost_vring vq;\n+\tuint64_t gpa;\n+\n+\tif (hw->vring[vring].enable) {\n+\t\trte_vhost_get_vhost_vring(vid, vring, &vq);\n+\t\tgpa = hva_to_gpa(vid, (uint64_t)(uintptr_t)vq.desc);\n+\t\tif (gpa == 0) {\n+\t\t\tDRV_LOG(ERR, \"Fail to get GPA for descriptor ring.\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\thw->vring[vring].desc = gpa;\n+\n+\t\tgpa = hva_to_gpa(vid, (uint64_t)(uintptr_t)vq.avail);\n+\t\tif (gpa == 0) {\n+\t\t\tDRV_LOG(ERR, \"Fail to get GPA for available ring.\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\thw->vring[vring].avail = gpa;\n+\n+\t\tgpa = hva_to_gpa(vid, (uint64_t)(uintptr_t)vq.used);\n+\t\tif (gpa == 0) {\n+\t\t\tDRV_LOG(ERR, \"Fail to get GPA for used ring.\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\thw->vring[vring].used = gpa;\n+\n+\t\thw->vring[vring].size = vq.size;\n+\t\trte_vhost_get_vring_base(vid, vring,\n+\t\t\t\t&hw->vring[vring].last_avail_idx,\n+\t\t\t\t&hw->vring[vring].last_used_idx);\n+\t\tifcvf_enable_vring_hw(&internal->hw, vring);\n+\t} else {\n+\t\tifcvf_disable_vring_hw(&internal->hw, vring);\n+\t\trte_vhost_set_vring_base(vid, vring,\n+\t\t\t\thw->vring[vring].last_avail_idx,\n+\t\t\t\thw->vring[vring].last_used_idx);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n ifcvf_set_vring_state(int vid, int vring, int state)\n {\n \tstruct rte_vdpa_device *vdev;\n \tstruct internal_list *list;\n \tstruct ifcvf_internal *internal;\n \tstruct ifcvf_hw *hw;\n-\tstruct ifcvf_pci_common_cfg *cfg;\n+\tbool enable = !!state;\n \tint ret = 0;\n \n \tvdev = rte_vhost_get_vdpa_device(vid);\n@@ -1298,6 +1344,9 @@ struct rte_vdpa_dev_info {\n \t\treturn -1;\n \t}\n \n+\tDRV_LOG(INFO, \"%s queue %d of vDPA device %s\",\n+\t\tenable ? \"enable\" : \"disable\", vring, vdev->device->name);\n+\n \tinternal = list->internal;\n \tif (vring < 0 || vring >= internal->max_queues * 2) {\n \t\tDRV_LOG(ERR, \"Vring index %d not correct\", vring);\n@@ -1305,27 +1354,41 @@ struct rte_vdpa_dev_info {\n \t}\n \n \thw = &internal->hw;\n+\thw->vring[vring].enable = enable;\n+\n \tif (!internal->configured)\n-\t\tgoto exit;\n+\t\treturn 0;\n \n-\tcfg = hw->common_cfg;\n-\tIFCVF_WRITE_REG16(vring, &cfg->queue_select);\n-\tIFCVF_WRITE_REG16(!!state, &cfg->queue_enable);\n+\tunset_notify_relay(internal);\n \n-\tif (!state && hw->vring[vring].enable) {\n-\t\tret = vdpa_disable_vfio_intr(internal);\n-\t\tif (ret)\n-\t\t\treturn ret;\n+\tret = vdpa_enable_vfio_intr(internal, false);\n+\tif (ret) {\n+\t\tDRV_LOG(ERR, \"failed to set vfio interrupt of vDPA device %s\",\n+\t\t\tvdev->device->name);\n+\t\treturn ret;\n \t}\n \n-\tif (state && !hw->vring[vring].enable) {\n-\t\tret = vdpa_enable_vfio_intr(internal, false);\n-\t\tif (ret)\n-\t\t\treturn ret;\n+\tret = ifcvf_config_vring(internal, vring);\n+\tif (ret) {\n+\t\tDRV_LOG(ERR, \"failed to configure queue %d of vDPA device %s\",\n+\t\t\tvring, vdev->device->name);\n+\t\treturn ret;\n+\t}\n+\n+\tret = setup_notify_relay(internal);\n+\tif (ret) {\n+\t\tDRV_LOG(ERR, \"failed to setup notify relay of vDPA device %s\",\n+\t\t\tvdev->device->name);\n+\t\treturn ret;\n+\t}\n+\n+\tret = rte_vhost_host_notifier_ctrl(vid, vring, enable);\n+\tif (ret) {\n+\t\tDRV_LOG(ERR, \"vDPA device %s queue %d host notifier ctrl fail\",\n+\t\t\tvdev->device->name, vring);\n+\t\treturn ret;\n \t}\n \n-exit:\n-\thw->vring[vring].enable = !!state;\n \treturn 0;\n }\n \n",
    "prefixes": [
        "v6",
        "6/8"
    ]
}