Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/96185/?format=api
http://patchwork.dpdk.org/api/patches/96185/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20210722040907.20468-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": "<20210722040907.20468-3-cheng1.jiang@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20210722040907.20468-3-cheng1.jiang@intel.com", "date": "2021-07-22T04:09:04", "name": "[v7,2/5] vhost: add unsafe API to clear packets in async vhost", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "2481161d5b7828cac736f6b49c05be68a1fd2307", "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/20210722040907.20468-3-cheng1.jiang@intel.com/mbox/", "series": [ { "id": 17945, "url": "http://patchwork.dpdk.org/api/series/17945/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=17945", "date": "2021-07-22T04:09:02", "name": "vhost: handle memory hotplug for async vhost", "version": 7, "mbox": "http://patchwork.dpdk.org/series/17945/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/96185/comments/", "check": "success", "checks": "http://patchwork.dpdk.org/api/patches/96185/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 07630A0C45;\n\tThu, 22 Jul 2021 06:26:38 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id D8C00410EC;\n\tThu, 22 Jul 2021 06:26:29 +0200 (CEST)", "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n by mails.dpdk.org (Postfix) with ESMTP id 20DAA410EC\n for <dev@dpdk.org>; Thu, 22 Jul 2021 06:26:27 +0200 (CEST)", "from fmsmga006.fm.intel.com ([10.253.24.20])\n by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 21 Jul 2021 21:26:27 -0700", "from dpdk_jiangcheng.sh.intel.com ([10.67.119.149])\n by fmsmga006.fm.intel.com with ESMTP; 21 Jul 2021 21:26:26 -0700" ], "X-IronPort-AV": [ "E=McAfee;i=\"6200,9189,10052\"; a=\"209664605\"", "E=Sophos;i=\"5.84,259,1620716400\"; d=\"scan'208\";a=\"209664605\"", "E=Sophos;i=\"5.84,259,1620716400\"; d=\"scan'208\";a=\"658668666\"" ], "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": "Thu, 22 Jul 2021 04:09:04 +0000", "Message-Id": "<20210722040907.20468-3-cheng1.jiang@intel.com>", "X-Mailer": "git-send-email 2.29.2", "In-Reply-To": "<20210722040907.20468-1-cheng1.jiang@intel.com>", "References": "<20210602042802.31943-1-cheng1.jiang@intel.com>\n <20210722040907.20468-1-cheng1.jiang@intel.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH v7 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>\nReviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n lib/vhost/rte_vhost_async.h | 22 +++++++++\n lib/vhost/version.map | 1 +\n lib/vhost/virtio_net.c | 93 +++++++++++++++++++++++++++----------\n 3 files changed, 92 insertions(+), 24 deletions(-)", "diff": "diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h\nindex 02d012ae23..b25ff446f7 100644\n--- a/lib/vhost/rte_vhost_async.h\n+++ b/lib/vhost/rte_vhost_async.h\n@@ -246,4 +246,26 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,\n __rte_experimental\n int rte_vhost_async_get_inflight(int vid, uint16_t queue_id);\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 e0c89646e8..e2504ba657 100644\n--- a/lib/vhost/version.map\n+++ b/lib/vhost/version.map\n@@ -84,4 +84,5 @@ EXPERIMENTAL {\n \trte_vhost_async_get_inflight;\n \trte_vhost_async_channel_register_thread_unsafe;\n \trte_vhost_async_channel_unregister_thread_unsafe;\n+\trte_vhost_clear_queue_thread_unsafe;\n };\ndiff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c\nindex 3ab5229f76..8549afbbe1 100644\n--- a/lib/vhost/virtio_net.c\n+++ b/lib/vhost/virtio_net.c\n@@ -2214,10 +2214,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@@ -2225,26 +2225,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@@ -2252,7 +2234,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@@ -2268,7 +2250,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@@ -2310,10 +2292,73 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,\n \t\t}\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": [ "v7", "2/5" ] }{ "id": 96185, "url": "