get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 96046,
    "url": "http://patchwork.dpdk.org/api/patches/96046/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20210719081022.12949-3-cheng1.jiang@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<20210719081022.12949-3-cheng1.jiang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210719081022.12949-3-cheng1.jiang@intel.com",
    "date": "2021-07-19T08:10:19",
    "name": "[v6,2/5] vhost: add unsafe API to clear packets in async vhost",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "9eebee809f68cc4a0cfd2ddd3980d362b6ae9f77",
    "submitter": {
        "id": 1530,
        "url": "http://patchwork.dpdk.org/api/people/1530/?format=api",
        "name": "Jiang, Cheng1",
        "email": "Cheng1.jiang@intel.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patchwork.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20210719081022.12949-3-cheng1.jiang@intel.com/mbox/",
    "series": [
        {
            "id": 17889,
            "url": "http://patchwork.dpdk.org/api/series/17889/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=17889",
            "date": "2021-07-19T08:10:17",
            "name": "vhost: handle memory hotplug for async vhost",
            "version": 6,
            "mbox": "http://patchwork.dpdk.org/series/17889/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/96046/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/96046/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 A36F2A034F;\n\tMon, 19 Jul 2021 10:27:31 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 0C9214117E;\n\tMon, 19 Jul 2021 10:27:23 +0200 (CEST)",
            "from mga07.intel.com (mga07.intel.com [134.134.136.100])\n by mails.dpdk.org (Postfix) with ESMTP id 9AD3F4111E\n for <dev@dpdk.org>; Mon, 19 Jul 2021 10:27:21 +0200 (CEST)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 19 Jul 2021 01:27:21 -0700",
            "from dpdk_jiangcheng.sh.intel.com ([10.67.119.149])\n by fmsmga002.fm.intel.com with ESMTP; 19 Jul 2021 01:27:19 -0700"
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10049\"; a=\"274841382\"",
            "E=Sophos;i=\"5.84,251,1620716400\"; d=\"scan'208\";a=\"274841382\"",
            "E=Sophos;i=\"5.84,251,1620716400\"; d=\"scan'208\";a=\"509279735\""
        ],
        "X-ExtLoop1": "1",
        "From": "Cheng Jiang <cheng1.jiang@intel.com>",
        "To": "maxime.coquelin@redhat.com,\n\tChenbo.Xia@intel.com",
        "Cc": "dev@dpdk.org, jiayu.hu@intel.com, yvonnex.yang@intel.com,\n Cheng Jiang <cheng1.jiang@intel.com>",
        "Date": "Mon, 19 Jul 2021 08:10:19 +0000",
        "Message-Id": "<20210719081022.12949-3-cheng1.jiang@intel.com>",
        "X-Mailer": "git-send-email 2.29.2",
        "In-Reply-To": "<20210719081022.12949-1-cheng1.jiang@intel.com>",
        "References": "<20210602042802.31943-1-cheng1.jiang@intel.com>\n <20210719081022.12949-1-cheng1.jiang@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v6 2/5] vhost: add unsafe API to clear packets in\n async vhost",
        "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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Applications need to stop DMA transfers and finish all the inflight\npackets when in VM memory hot-plug case and async vhost is used. This\npatch is to provide an unsafe API to clear inflight packets which\nare submitted to DMA engine in vhost async data path.\n\nSigned-off-by: Cheng Jiang <cheng1.jiang@intel.com>\n---\n lib/vhost/rte_vhost_async.h | 22 +++++++++\n lib/vhost/version.map       |  3 ++\n lib/vhost/virtio_net.c      | 93 +++++++++++++++++++++++++++----------\n 3 files changed, 94 insertions(+), 24 deletions(-)",
    "diff": "diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h\nindex e964d83837..9961e4970e 100644\n--- a/lib/vhost/rte_vhost_async.h\n+++ b/lib/vhost/rte_vhost_async.h\n@@ -193,4 +193,26 @@ __rte_experimental\n uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,\n \t\tstruct rte_mbuf **pkts, uint16_t count);\n \n+/**\n+ * This function checks async completion status and clear packets for\n+ * a specific vhost device queue. Packets which are inflight will be\n+ * returned in an array.\n+ *\n+ * @note This function does not perform any locking\n+ *\n+ * @param vid\n+ *  ID of vhost device to clear data\n+ * @param queue_id\n+ *  Queue id to clear data\n+ * @param pkts\n+ *  Blank array to get return packet pointer\n+ * @param count\n+ *  Size of the packet array\n+ * @return\n+ *  Number of packets returned\n+ */\n+__rte_experimental\n+uint16_t rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,\n+\t\tstruct rte_mbuf **pkts, uint16_t count);\n+\n #endif /* _RTE_VHOST_ASYNC_H_ */\ndiff --git a/lib/vhost/version.map b/lib/vhost/version.map\nindex 9103a23cd4..8dcf9e802a 100644\n--- a/lib/vhost/version.map\n+++ b/lib/vhost/version.map\n@@ -79,4 +79,7 @@ EXPERIMENTAL {\n \n \t# added in 21.05\n \trte_vhost_get_negotiated_protocol_features;\n+\n+\t# added in 21.08\n+\trte_vhost_clear_queue_thread_unsafe;\n };\ndiff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c\nindex 16ae4d9e19..29f91f9ad4 100644\n--- a/lib/vhost/virtio_net.c\n+++ b/lib/vhost/virtio_net.c\n@@ -2117,10 +2117,10 @@ write_back_completed_descs_packed(struct vhost_virtqueue *vq,\n \t} while (nr_left > 0);\n }\n \n-uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,\n+static __rte_always_inline uint16_t\n+vhost_poll_enqueue_completed(struct virtio_net *dev, uint16_t queue_id,\n \t\tstruct rte_mbuf **pkts, uint16_t count)\n {\n-\tstruct virtio_net *dev = get_device(vid);\n \tstruct vhost_virtqueue *vq;\n \tuint16_t n_pkts_cpl = 0, n_pkts_put = 0, n_descs = 0, n_buffers = 0;\n \tuint16_t start_idx, pkts_idx, vq_size;\n@@ -2128,26 +2128,8 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,\n \tuint16_t from, i;\n \tint32_t n_cpl;\n \n-\tif (!dev)\n-\t\treturn 0;\n-\n-\tVHOST_LOG_DATA(DEBUG, \"(%d) %s\\n\", dev->vid, __func__);\n-\tif (unlikely(!is_valid_virt_queue_idx(queue_id, 0, dev->nr_vring))) {\n-\t\tVHOST_LOG_DATA(ERR, \"(%d) %s: invalid virtqueue idx %d.\\n\",\n-\t\t\tdev->vid, __func__, queue_id);\n-\t\treturn 0;\n-\t}\n-\n \tvq = dev->virtqueue[queue_id];\n \n-\tif (unlikely(!vq->async_registered)) {\n-\t\tVHOST_LOG_DATA(ERR, \"(%d) %s: async not registered for queue id %d.\\n\",\n-\t\t\tdev->vid, __func__, queue_id);\n-\t\treturn 0;\n-\t}\n-\n-\trte_spinlock_lock(&vq->access_lock);\n-\n \tpkts_idx = vq->async_pkts_idx % vq->size;\n \tpkts_info = vq->async_pkts_info;\n \tvq_size = vq->size;\n@@ -2155,7 +2137,7 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,\n \t\tvq_size, vq->async_pkts_inflight_n);\n \n \tif (count > vq->async_last_pkts_n) {\n-\t\tn_cpl = vq->async_ops.check_completed_copies(vid,\n+\t\tn_cpl = vq->async_ops.check_completed_copies(dev->vid,\n \t\t\tqueue_id, 0, count - vq->async_last_pkts_n);\n \t\tif (n_cpl >= 0) {\n \t\t\tn_pkts_cpl = n_cpl;\n@@ -2171,7 +2153,7 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,\n \tn_pkts_put = RTE_MIN(count, n_pkts_cpl);\n \tif (unlikely(n_pkts_put == 0)) {\n \t\tvq->async_last_pkts_n = n_pkts_cpl;\n-\t\tgoto done;\n+\t\treturn 0;\n \t}\n \n \tif (vq_is_packed(dev)) {\n@@ -2210,10 +2192,73 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,\n \t\t\tvq->last_async_desc_idx_split += n_descs;\n \t}\n \n-done:\n+\treturn n_pkts_put;\n+}\n+\n+uint16_t\n+rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,\n+\t\tstruct rte_mbuf **pkts, uint16_t count)\n+{\n+\tstruct virtio_net *dev = get_device(vid);\n+\tstruct vhost_virtqueue *vq;\n+\tuint16_t n_pkts_cpl = 0;\n+\n+\tif (!dev)\n+\t\treturn 0;\n+\n+\tVHOST_LOG_DATA(DEBUG, \"(%d) %s\\n\", dev->vid, __func__);\n+\tif (unlikely(!is_valid_virt_queue_idx(queue_id, 0, dev->nr_vring))) {\n+\t\tVHOST_LOG_DATA(ERR, \"(%d) %s: invalid virtqueue idx %d.\\n\",\n+\t\t\tdev->vid, __func__, queue_id);\n+\t\treturn 0;\n+\t}\n+\n+\tvq = dev->virtqueue[queue_id];\n+\n+\tif (unlikely(!vq->async_registered)) {\n+\t\tVHOST_LOG_DATA(ERR, \"(%d) %s: async not registered for queue id %d.\\n\",\n+\t\t\tdev->vid, __func__, queue_id);\n+\t\treturn 0;\n+\t}\n+\n+\trte_spinlock_lock(&vq->access_lock);\n+\n+\tn_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id, pkts, count);\n+\n \trte_spinlock_unlock(&vq->access_lock);\n \n-\treturn n_pkts_put;\n+\treturn n_pkts_cpl;\n+}\n+\n+uint16_t\n+rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,\n+\t\tstruct rte_mbuf **pkts, uint16_t count)\n+{\n+\tstruct virtio_net *dev = get_device(vid);\n+\tstruct vhost_virtqueue *vq;\n+\tuint16_t n_pkts_cpl = 0;\n+\n+\tif (!dev)\n+\t\treturn 0;\n+\n+\tVHOST_LOG_DATA(DEBUG, \"(%d) %s\\n\", dev->vid, __func__);\n+\tif (unlikely(!is_valid_virt_queue_idx(queue_id, 0, dev->nr_vring))) {\n+\t\tVHOST_LOG_DATA(ERR, \"(%d) %s: invalid virtqueue idx %d.\\n\",\n+\t\t\tdev->vid, __func__, queue_id);\n+\t\treturn 0;\n+\t}\n+\n+\tvq = dev->virtqueue[queue_id];\n+\n+\tif (unlikely(!vq->async_registered)) {\n+\t\tVHOST_LOG_DATA(ERR, \"(%d) %s: async not registered for queue id %d.\\n\",\n+\t\t\tdev->vid, __func__, queue_id);\n+\t\treturn 0;\n+\t}\n+\n+\tn_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id, pkts, count);\n+\n+\treturn n_pkts_cpl;\n }\n \n static __rte_always_inline uint32_t\n",
    "prefixes": [
        "v6",
        "2/5"
    ]
}