get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 118516,
    "url": "http://patches.dpdk.org/api/patches/118516/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1666168884-104665-7-git-send-email-andy.pei@intel.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<1666168884-104665-7-git-send-email-andy.pei@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1666168884-104665-7-git-send-email-andy.pei@intel.com",
    "date": "2022-10-19T08:41:18",
    "name": "[v9,06/12] vdpa/ifc: support dynamic enable/disable queue",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "c40ffdbec4cbd619e2de8e659b9175321b369adb",
    "submitter": {
        "id": 1185,
        "url": "http://patches.dpdk.org/api/people/1185/?format=api",
        "name": "Pei, Andy",
        "email": "andy.pei@intel.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1666168884-104665-7-git-send-email-andy.pei@intel.com/mbox/",
    "series": [
        {
            "id": 25297,
            "url": "http://patches.dpdk.org/api/series/25297/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=25297",
            "date": "2022-10-19T08:41:12",
            "name": "vdpa/ifc: add multi queue support",
            "version": 9,
            "mbox": "http://patches.dpdk.org/series/25297/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/118516/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/118516/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 0C0E4A0581;\n\tWed, 19 Oct 2022 11:32:07 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 40CE24282E;\n\tWed, 19 Oct 2022 11:31:54 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n by mails.dpdk.org (Postfix) with ESMTP id DDAC042829\n for <dev@dpdk.org>; Wed, 19 Oct 2022 11:31:52 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 19 Oct 2022 02:31:51 -0700",
            "from dpdk-dipei.sh.intel.com ([10.67.110.251])\n by fmsmga001.fm.intel.com with ESMTP; 19 Oct 2022 02:31:49 -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=1666171913; x=1697707913;\n h=from:to:cc:subject:date:message-id:in-reply-to: references;\n bh=VMY/XQgY3LiXk3abQWsaQCKGKFqsmcMrD2+Gz98WQA0=;\n b=UixBH3UJ2qalFBBA8RWfAMrYbQzk7PVJk3mHUlF42JWUs26/bfljVygt\n aVXMGTP9u8woWVtFJchWKRAU1HUpLXzf1z2oAK2Fk3F+yBa+G50ShmERT\n +nqV4zqHntxn8H+EaGRrD5/8MiAPeV44mqHdDadx799E248yl/tOMIDlI\n vohFa8oFT8yLGJYVINErsWY9tEvW6KGdsI+5Lg1r2EA2IDp9NzN6ur40b\n tGzLr8OyDizlOcnSvi3RuhLx5qllTNoSDLs5NID3Nj2o37CGkaZnxpQCi\n 5pJZ8LRHj/2N0Qeb2lFCO6Y206NyoGZt/DW6WLaAqMKKgpxm8HO3IE3+L Q==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6500,9779,10504\"; a=\"303976932\"",
            "E=Sophos;i=\"5.95,195,1661842800\"; d=\"scan'208\";a=\"303976932\"",
            "E=McAfee;i=\"6500,9779,10504\"; a=\"771690956\"",
            "E=Sophos;i=\"5.95,195,1661842800\"; d=\"scan'208\";a=\"771690956\""
        ],
        "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 v9 06/12] vdpa/ifc: support dynamic enable/disable queue",
        "Date": "Wed, 19 Oct 2022 16:41:18 +0800",
        "Message-Id": "<1666168884-104665-7-git-send-email-andy.pei@intel.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1666168884-104665-1-git-send-email-andy.pei@intel.com>",
        "References": "<1661229305-240952-2-git-send-email-andy.pei@intel.com>\n <1666168884-104665-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": [
        "v9",
        "06/12"
    ]
}