get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 95945,
    "url": "https://patches.dpdk.org/api/patches/95945/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210716072436.19017-3-cheng1.jiang@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": "<20210716072436.19017-3-cheng1.jiang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210716072436.19017-3-cheng1.jiang@intel.com",
    "date": "2021-07-16T07:24:33",
    "name": "[v5,2/5] vhost: add unsafe API to drain pkts in async vhost",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "a70bc8f08c15d3c9a41e57c8e4158e5227160e58",
    "submitter": {
        "id": 1530,
        "url": "https://patches.dpdk.org/api/people/1530/?format=api",
        "name": "Jiang, Cheng1",
        "email": "Cheng1.jiang@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/20210716072436.19017-3-cheng1.jiang@intel.com/mbox/",
    "series": [
        {
            "id": 17853,
            "url": "https://patches.dpdk.org/api/series/17853/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=17853",
            "date": "2021-07-16T07:24:31",
            "name": "vhost: handle memory hotplug for async vhost",
            "version": 5,
            "mbox": "https://patches.dpdk.org/series/17853/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/95945/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/95945/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 79051A0C50;\n\tFri, 16 Jul 2021 09:41:28 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 468E640151;\n\tFri, 16 Jul 2021 09:41:25 +0200 (CEST)",
            "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n by mails.dpdk.org (Postfix) with ESMTP id 1EE3F40143\n for <dev@dpdk.org>; Fri, 16 Jul 2021 09:41:21 +0200 (CEST)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 16 Jul 2021 00:41:21 -0700",
            "from dpdk_jiangcheng.sh.intel.com ([10.67.119.149])\n by fmsmga002.fm.intel.com with ESMTP; 16 Jul 2021 00:41:19 -0700"
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10046\"; a=\"296335655\"",
            "E=Sophos;i=\"5.84,244,1620716400\"; d=\"scan'208\";a=\"296335655\"",
            "E=Sophos;i=\"5.84,244,1620716400\"; d=\"scan'208\";a=\"506384272\""
        ],
        "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": "Fri, 16 Jul 2021 07:24:33 +0000",
        "Message-Id": "<20210716072436.19017-3-cheng1.jiang@intel.com>",
        "X-Mailer": "git-send-email 2.29.2",
        "In-Reply-To": "<20210716072436.19017-1-cheng1.jiang@intel.com>",
        "References": "<20210602042802.31943-1-cheng1.jiang@intel.com>\n <20210716072436.19017-1-cheng1.jiang@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v5 2/5] vhost: add unsafe API to drain pkts 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 in-flight\npkts when in VM memory hot-plug case and async vhost is used. This\npatch is to provide an unsafe API to drain in-flight pkts which are\nsubmitted 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 | 24 ++++++++++\n lib/vhost/version.map       |  3 ++\n lib/vhost/virtio_net.c      | 90 +++++++++++++++++++++++++++----------\n 3 files changed, 94 insertions(+), 23 deletions(-)",
    "diff": "diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h\nindex e964d83837..c3de79d1e1 100644\n--- a/lib/vhost/rte_vhost_async.h\n+++ b/lib/vhost/rte_vhost_async.h\n@@ -193,4 +193,28 @@ __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 empty all pakcets\n+ * for a specific vhost device queue. Packets which are inflight will\n+ * be returned in an array.\n+ *\n+ * @note This function does not perform any locking\n+ *\n+ * @param vid\n+ *  id of vhost device to enqueue data\n+ * @param queue_id\n+ *  queue id to enqueue data\n+ * @param pkts\n+ *  blank array to get return packet pointer\n+ * @param count\n+ *  size of the packet array\n+ * @param times\n+ *  max number of poll attempts\n+ * @return\n+ *  num of packets returned\n+ */\n+__rte_experimental\n+uint16_t rte_vhost_try_drain_queue_thread_unsafe(int vid, uint16_t queue_id,\n+\t\tstruct rte_mbuf **pkts, uint16_t count, uint16_t times);\n+\n #endif /* _RTE_VHOST_ASYNC_H_ */\ndiff --git a/lib/vhost/version.map b/lib/vhost/version.map\nindex 9103a23cd4..b8fc8770dd 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_try_drain_queue_thread_unsafe;\n };\ndiff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c\nindex 16ae4d9e19..c3a1493e0d 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,12 +2192,74 @@ 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 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_put = 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_put = vhost_poll_enqueue_completed(dev, queue_id, pkts, count);\n+\n \trte_spinlock_unlock(&vq->access_lock);\n \n \treturn n_pkts_put;\n }\n \n+uint16_t rte_vhost_try_drain_queue_thread_unsafe(int vid, uint16_t queue_id,\n+\t\tstruct rte_mbuf **pkts, uint16_t count, uint16_t times)\n+{\n+\tstruct virtio_net *dev = get_device(vid);\n+\tstruct vhost_virtqueue *vq;\n+\tuint16_t n_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+\twhile ((n_cpl < count) && times--)\n+\t\tn_cpl += vhost_poll_enqueue_completed(dev, queue_id, pkts + n_cpl, count);\n+\n+\treturn n_cpl;\n+}\n+\n static __rte_always_inline uint32_t\n virtio_dev_rx_async_submit(struct virtio_net *dev, uint16_t queue_id,\n \tstruct rte_mbuf **pkts, uint32_t count,\n",
    "prefixes": [
        "v5",
        "2/5"
    ]
}