Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/118433/?format=api
https://patches.dpdk.org/api/patches/118433/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20221018152221.86341-2-xuan.ding@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": "<20221018152221.86341-2-xuan.ding@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20221018152221.86341-2-xuan.ding@intel.com", "date": "2022-10-18T15:22:20", "name": "[v6,1/2] vhost: introduce DMA vchannel unconfiguration", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "d9ff69d249399eef6a5f371f6a742868ecd4b723", "submitter": { "id": 1401, "url": "https://patches.dpdk.org/api/people/1401/?format=api", "name": "Ding, Xuan", "email": "xuan.ding@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/20221018152221.86341-2-xuan.ding@intel.com/mbox/", "series": [ { "id": 25286, "url": "https://patches.dpdk.org/api/series/25286/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=25286", "date": "2022-10-18T15:22:19", "name": "vhost: introduce DMA vchannel unconfiguration", "version": 6, "mbox": "https://patches.dpdk.org/series/25286/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/118433/comments/", "check": "success", "checks": "https://patches.dpdk.org/api/patches/118433/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 10AE0A0560;\n\tTue, 18 Oct 2022 17:25:22 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 25656410E8;\n\tTue, 18 Oct 2022 17:25:19 +0200 (CEST)", "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n by mails.dpdk.org (Postfix) with ESMTP id 03387410E8\n for <dev@dpdk.org>; Tue, 18 Oct 2022 17:25:17 +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 18 Oct 2022 08:25:17 -0700", "from npg-dpdk-xuan-cbdma.sh.intel.com ([10.67.111.102])\n by fmsmga002.fm.intel.com with ESMTP; 18 Oct 2022 08:25:14 -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=1666106718; x=1697642718;\n h=from:to:cc:subject:date:message-id:in-reply-to: references;\n bh=/gsgxhvk+MeG5owN2S3Vjybus2O4mjLBrkoPXAcOZKE=;\n b=JVEiVVEYuaoRnew17p7/jgjtQTneiD034W8DTwZzAiRqa08eUIWPjFPj\n NfLhPkZ9Sk2LGPX8M9bDgJmbjz0DQujdvKUxmZ69OO22y5fRKnzUQTkMD\n UyvAu8tPIe2A60M+q4iV//d2ypD5uSb+4w1xXwFAecJq2pPp7cyO/tnAG\n Qq/q5B04sG3yg+Xz/VrEqSq6f7hizm3Eets6YAZ2C3I9FMofYcTC+gGbw\n UwaodowNlGw2LV1UlnksuZVSHjSRtU4n7CF9aNI8IhdAzJ3WqmenzVv31\n c7nB1UoisPRcL+aeoz8Ko9GRqyic++q0O5TVMzYszXLUvj/gZPwJp6LMd w==;", "X-IronPort-AV": [ "E=McAfee;i=\"6500,9779,10504\"; a=\"392444803\"", "E=Sophos;i=\"5.95,193,1661842800\"; d=\"scan'208\";a=\"392444803\"", "E=McAfee;i=\"6500,9779,10504\"; a=\"733686041\"", "E=Sophos;i=\"5.95,193,1661842800\"; d=\"scan'208\";a=\"733686041\"" ], "X-ExtLoop1": "1", "From": "xuan.ding@intel.com", "To": "maxime.coquelin@redhat.com,\n\tchenbo.xia@intel.com", "Cc": "dev@dpdk.org, jiayu.hu@intel.com, xingguang.he@intel.com,\n yvonnex.yang@intel.com, cheng1.jiang@intel.com, yuanx.wang@intel.com,\n wenwux.ma@intel.com, Xuan Ding <xuan.ding@intel.com>", "Subject": "[PATCH v6 1/2] vhost: introduce DMA vchannel unconfiguration", "Date": "Tue, 18 Oct 2022 15:22:20 +0000", "Message-Id": "<20221018152221.86341-2-xuan.ding@intel.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20221018152221.86341-1-xuan.ding@intel.com>", "References": "<20220814140442.82525-1-xuan.ding@intel.com>\n <20221018152221.86341-1-xuan.ding@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: Xuan Ding <xuan.ding@intel.com>\n\nAdd a new API rte_vhost_async_dma_unconfigure() to unconfigure DMA\nvchannels in vhost async data path. Lock protection are also added\nto protect DMA vchannels configuration and unconfiguration\nfrom concurrent calls.\n\nSigned-off-by: Xuan Ding <xuan.ding@intel.com>\n---\n doc/guides/prog_guide/vhost_lib.rst | 7 +++\n doc/guides/rel_notes/release_22_11.rst | 5 ++\n lib/vhost/rte_vhost_async.h | 20 ++++++++\n lib/vhost/version.map | 3 ++\n lib/vhost/vhost.c | 69 ++++++++++++++++++++++++--\n 5 files changed, 99 insertions(+), 5 deletions(-)", "diff": "diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst\nindex bad4d819e1..fbe841321f 100644\n--- a/doc/guides/prog_guide/vhost_lib.rst\n+++ b/doc/guides/prog_guide/vhost_lib.rst\n@@ -323,6 +323,13 @@ The following is an overview of some key Vhost API functions:\n Get device type of vDPA device, such as VDPA_DEVICE_TYPE_NET,\n VDPA_DEVICE_TYPE_BLK.\n \n+* ``rte_vhost_async_dma_unconfigure(dma_id, vchan_id)``\n+\n+ Clean DMA vChannels finished to use. This function needs to be called\n+ after the deregistration of async DMA vchannel has been finished.\n+ After this function is called, the specified DMA device should no\n+ longer be used by the Vhost library.\n+\n Vhost-user Implementations\n --------------------------\n \ndiff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst\nindex 2da8bc9661..a1c5cdea7c 100644\n--- a/doc/guides/rel_notes/release_22_11.rst\n+++ b/doc/guides/rel_notes/release_22_11.rst\n@@ -236,6 +236,11 @@ New Features\n \n strings $dpdk_binary_or_driver | sed -n 's/^PMD_INFO_STRING= //p'\n \n+* **Added DMA vChannel unconfiguration for async vhost.**\n+\n+ * Added support to unconfigure DMA vChannels that have been unregistered\n+ and no longer used by Vhost library.\n+\n \n Removed Items\n -------------\ndiff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h\nindex 1db2a10124..eac7eb568e 100644\n--- a/lib/vhost/rte_vhost_async.h\n+++ b/lib/vhost/rte_vhost_async.h\n@@ -266,6 +266,26 @@ rte_vhost_async_try_dequeue_burst(int vid, uint16_t queue_id,\n \tstruct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count,\n \tint *nr_inflight, int16_t dma_id, uint16_t vchan_id);\n \n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.\n+ *\n+ * Unconfigure DMA vChannels in Vhost asynchronous data path.\n+ * This function should be called after the DMA vChannel has been unregistered.\n+ * After this function is called, the specified DMA device should no longer\n+ * be used by the Vhost library.\n+ *\n+ * @param dma_id\n+ * the identifier of DMA device\n+ * @param vchan_id\n+ * the identifier of virtual DMA channel\n+ * @return\n+ * 0 on success, and -1 on failure\n+ */\n+__rte_experimental\n+int\n+rte_vhost_async_dma_unconfigure(int16_t dma_id, uint16_t vchan_id);\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/vhost/version.map b/lib/vhost/version.map\nindex 7a00b65740..0b61870870 100644\n--- a/lib/vhost/version.map\n+++ b/lib/vhost/version.map\n@@ -94,6 +94,9 @@ EXPERIMENTAL {\n \trte_vhost_async_try_dequeue_burst;\n \trte_vhost_driver_get_vdpa_dev_type;\n \trte_vhost_clear_queue;\n+\n+\t# added in 22.11\n+\trte_vhost_async_dma_unconfigure;\n };\n \n INTERNAL {\ndiff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c\nindex 8740aa2788..975c0d3297 100644\n--- a/lib/vhost/vhost.c\n+++ b/lib/vhost/vhost.c\n@@ -23,6 +23,7 @@\n \n struct virtio_net *vhost_devices[RTE_MAX_VHOST_DEVICE];\n pthread_mutex_t vhost_dev_lock = PTHREAD_MUTEX_INITIALIZER;\n+pthread_mutex_t vhost_dma_lock = PTHREAD_MUTEX_INITIALIZER;\n \n struct vhost_vq_stats_name_off {\n \tchar name[RTE_VHOST_STATS_NAME_SIZE];\n@@ -1844,19 +1845,20 @@ rte_vhost_async_dma_configure(int16_t dma_id, uint16_t vchan_id)\n \tvoid *pkts_cmpl_flag_addr;\n \tuint16_t max_desc;\n \n+\tpthread_mutex_lock(&vhost_dma_lock);\n \tif (!rte_dma_is_valid(dma_id)) {\n \t\tVHOST_LOG_CONFIG(\"dma\", ERR, \"DMA %d is not found.\\n\", dma_id);\n-\t\treturn -1;\n+\t\tgoto error;\n \t}\n \n \tif (rte_dma_info_get(dma_id, &info) != 0) {\n \t\tVHOST_LOG_CONFIG(\"dma\", ERR, \"Fail to get DMA %d information.\\n\", dma_id);\n-\t\treturn -1;\n+\t\tgoto error;\n \t}\n \n \tif (vchan_id >= info.max_vchans) {\n \t\tVHOST_LOG_CONFIG(\"dma\", ERR, \"Invalid DMA %d vChannel %u.\\n\", dma_id, vchan_id);\n-\t\treturn -1;\n+\t\tgoto error;\n \t}\n \n \tif (!dma_copy_track[dma_id].vchans) {\n@@ -1868,7 +1870,7 @@ rte_vhost_async_dma_configure(int16_t dma_id, uint16_t vchan_id)\n \t\t\tVHOST_LOG_CONFIG(\"dma\", ERR,\n \t\t\t\t\"Failed to allocate vchans for DMA %d vChannel %u.\\n\",\n \t\t\t\tdma_id, vchan_id);\n-\t\t\treturn -1;\n+\t\t\tgoto error;\n \t\t}\n \n \t\tdma_copy_track[dma_id].vchans = vchans;\n@@ -1877,6 +1879,7 @@ rte_vhost_async_dma_configure(int16_t dma_id, uint16_t vchan_id)\n \tif (dma_copy_track[dma_id].vchans[vchan_id].pkts_cmpl_flag_addr) {\n \t\tVHOST_LOG_CONFIG(\"dma\", INFO, \"DMA %d vChannel %u already registered.\\n\",\n \t\t\tdma_id, vchan_id);\n+\t\tpthread_mutex_unlock(&vhost_dma_lock);\n \t\treturn 0;\n \t}\n \n@@ -1894,7 +1897,7 @@ rte_vhost_async_dma_configure(int16_t dma_id, uint16_t vchan_id)\n \t\t\trte_free(dma_copy_track[dma_id].vchans);\n \t\t\tdma_copy_track[dma_id].vchans = NULL;\n \t\t}\n-\t\treturn -1;\n+\t\tgoto error;\n \t}\n \n \tdma_copy_track[dma_id].vchans[vchan_id].pkts_cmpl_flag_addr = pkts_cmpl_flag_addr;\n@@ -1902,7 +1905,12 @@ rte_vhost_async_dma_configure(int16_t dma_id, uint16_t vchan_id)\n \tdma_copy_track[dma_id].vchans[vchan_id].ring_mask = max_desc - 1;\n \tdma_copy_track[dma_id].nr_vchans++;\n \n+\tpthread_mutex_unlock(&vhost_dma_lock);\n \treturn 0;\n+\n+error:\n+\tpthread_mutex_unlock(&vhost_dma_lock);\n+\treturn -1;\n }\n \n int\n@@ -2091,5 +2099,56 @@ int rte_vhost_vring_stats_reset(int vid, uint16_t queue_id)\n \treturn 0;\n }\n \n+int\n+rte_vhost_async_dma_unconfigure(int16_t dma_id, uint16_t vchan_id)\n+{\n+\tstruct rte_dma_info info;\n+\tuint16_t max_desc;\n+\tint i;\n+\n+\tpthread_mutex_lock(&vhost_dma_lock);\n+\tif (!rte_dma_is_valid(dma_id)) {\n+\t\tVHOST_LOG_CONFIG(\"dma\", ERR, \"DMA %d is not found.\\n\", dma_id);\n+\t\tgoto error;\n+\t}\n+\n+\tif (rte_dma_info_get(dma_id, &info) != 0) {\n+\t\tVHOST_LOG_CONFIG(\"dma\", ERR, \"Fail to get DMA %d information.\\n\", dma_id);\n+\t\tgoto error;\n+\t}\n+\n+\tif (vchan_id >= info.max_vchans) {\n+\t\tVHOST_LOG_CONFIG(\"dma\", ERR, \"Invalid DMA %d vChannel %u.\\n\", dma_id, vchan_id);\n+\t\tgoto error;\n+\t}\n+\n+\tmax_desc = info.max_desc;\n+\tfor (i = 0; i < max_desc; i++) {\n+\t\tif (dma_copy_track[dma_id].vchans[vchan_id].pkts_cmpl_flag_addr[i] != NULL) {\n+\t\t\trte_free(dma_copy_track[dma_id].vchans[vchan_id].pkts_cmpl_flag_addr[i]);\n+\t\t\tdma_copy_track[dma_id].vchans[vchan_id].pkts_cmpl_flag_addr[i] = NULL;\n+\t\t}\n+\t}\n+\n+\tif (dma_copy_track[dma_id].vchans[vchan_id].pkts_cmpl_flag_addr != NULL) {\n+\t\trte_free(dma_copy_track[dma_id].vchans[vchan_id].pkts_cmpl_flag_addr);\n+\t\tdma_copy_track[dma_id].vchans[vchan_id].pkts_cmpl_flag_addr = NULL;\n+\t}\n+\n+\tif (dma_copy_track[dma_id].vchans != NULL) {\n+\t\trte_free(dma_copy_track[dma_id].vchans);\n+\t\tdma_copy_track[dma_id].vchans = NULL;\n+\t}\n+\n+\tdma_copy_track[dma_id].nr_vchans--;\n+\n+\tpthread_mutex_unlock(&vhost_dma_lock);\n+\treturn 0;\n+\n+error:\n+\tpthread_mutex_unlock(&vhost_dma_lock);\n+\treturn -1;\n+}\n+\n RTE_LOG_REGISTER_SUFFIX(vhost_config_log_level, config, INFO);\n RTE_LOG_REGISTER_SUFFIX(vhost_data_log_level, data, WARNING);\n", "prefixes": [ "v6", "1/2" ] }{ "id": 118433, "url": "