get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 118121,
    "url": "https://patches.dpdk.org/api/patches/118121/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20221013092708.4922-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": "<20221013092708.4922-2-xuan.ding@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20221013092708.4922-2-xuan.ding@intel.com",
    "date": "2022-10-13T09:27:07",
    "name": "[v5,1/2] vhost: introduce DMA vchannel unconfiguration",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "bf404f8c6e8af559a49e82f85a601ee74adbfe89",
    "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/20221013092708.4922-2-xuan.ding@intel.com/mbox/",
    "series": [
        {
            "id": 25203,
            "url": "https://patches.dpdk.org/api/series/25203/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=25203",
            "date": "2022-10-13T09:27:06",
            "name": "vhost: introduce DMA vchannel unconfiguration",
            "version": 5,
            "mbox": "https://patches.dpdk.org/series/25203/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/118121/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/118121/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 B4F78A00C2;\n\tThu, 13 Oct 2022 11:29:28 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 7476042E0D;\n\tThu, 13 Oct 2022 11:29:27 +0200 (CEST)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n by mails.dpdk.org (Postfix) with ESMTP id F236D42E0D\n for <dev@dpdk.org>; Thu, 13 Oct 2022 11:29:25 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 13 Oct 2022 02:29:25 -0700",
            "from npg-dpdk-xuan-cbdma.sh.intel.com ([10.67.111.102])\n by fmsmga001.fm.intel.com with ESMTP; 13 Oct 2022 02:29:23 -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=1665653366; x=1697189366;\n h=from:to:cc:subject:date:message-id:in-reply-to: references;\n bh=PVE5VRAc/CO1gSkC1EfCQG6qgewFzEk4UjeXaa5JILw=;\n b=gLu0fUVAagfapAa56W7Lkco//swoZ21k12h9OvMOL9tO5lL6WEKXwuiB\n iWymyFbhylCDJ9NddcrsMav+lNmqzjt22Lcn0wSftquFbeusEwms4hpFT\n acMNRp/J93ELQt1cRjnqhLRwXpeq4y+MWt0b5RXwYneuZkuplkRKxui/f\n v4k4aBeffig3a0qBpAyP9XrFGNRtn7wWKllU0ykvpoP4HE6E0efkJNg9h\n 35eTmxFUE5x5RR8KwPbb0zgFkV+INVAfuAMALAWFwUhd7xscCFnZpzt2u\n QCnw+2dl/wRRb+2msovPP+J+jMfr4WHJ4+8gayQ4vkT4Wa2NJqc1mev/O Q==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6500,9779,10498\"; a=\"305022266\"",
            "E=Sophos;i=\"5.95,180,1661842800\"; d=\"scan'208\";a=\"305022266\"",
            "E=McAfee;i=\"6500,9779,10498\"; a=\"769547382\"",
            "E=Sophos;i=\"5.95,180,1661842800\"; d=\"scan'208\";a=\"769547382\""
        ],
        "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 v5 1/2] vhost: introduce DMA vchannel unconfiguration",
        "Date": "Thu, 13 Oct 2022 09:27:07 +0000",
        "Message-Id": "<20221013092708.4922-2-xuan.ding@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20221013092708.4922-1-xuan.ding@intel.com>",
        "References": "<20220814140442.82525-1-xuan.ding@intel.com>\n <20221013092708.4922-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    |  6 +++\n doc/guides/rel_notes/release_22_11.rst |  4 ++\n lib/vhost/rte_vhost_async.h            | 18 +++++++\n lib/vhost/version.map                  |  3 ++\n lib/vhost/vhost.c                      | 69 ++++++++++++++++++++++++--\n 5 files changed, 95 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst\nindex bad4d819e1..d3cef978d0 100644\n--- a/doc/guides/prog_guide/vhost_lib.rst\n+++ b/doc/guides/prog_guide/vhost_lib.rst\n@@ -323,6 +323,12 @@ 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\n+  be called after the deregistration of async DMA vchannel\n+  has been finished.\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..3be150122c 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,10 @@ 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+\n \n Removed Items\n -------------\ndiff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h\nindex 1db2a10124..6ee4f7258d 100644\n--- a/lib/vhost/rte_vhost_async.h\n+++ b/lib/vhost/rte_vhost_async.h\n@@ -266,6 +266,24 @@ 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 asynchronous data path.\n+ * This function should be called after the DMA vChannel has been unregistered.\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": [
        "v5",
        "1/2"
    ]
}