get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 96054,
    "url": "https://patches.dpdk.org/api/patches/96054/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1626706847-276163-4-git-send-email-jiayu.hu@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": "<1626706847-276163-4-git-send-email-jiayu.hu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1626706847-276163-4-git-send-email-jiayu.hu@intel.com",
    "date": "2021-07-19T15:00:47",
    "name": "[v6,3/3] vhost: add thread unsafe async registeration functions",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "606326ef5fc6ee6e478433bb0f3774b3c042ebec",
    "submitter": {
        "id": 539,
        "url": "https://patches.dpdk.org/api/people/539/?format=api",
        "name": "Hu, Jiayu",
        "email": "jiayu.hu@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/1626706847-276163-4-git-send-email-jiayu.hu@intel.com/mbox/",
    "series": [
        {
            "id": 17891,
            "url": "https://patches.dpdk.org/api/series/17891/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=17891",
            "date": "2021-07-19T15:00:44",
            "name": "provide thread unsafe async registration functions",
            "version": 6,
            "mbox": "https://patches.dpdk.org/series/17891/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/96054/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/96054/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 B4B8CA034F;\n\tMon, 19 Jul 2021 10:33:54 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id D728941195;\n\tMon, 19 Jul 2021 10:33:41 +0200 (CEST)",
            "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n by mails.dpdk.org (Postfix) with ESMTP id 633FA4119B\n for <dev@dpdk.org>; Mon, 19 Jul 2021 10:33:39 +0200 (CEST)",
            "from fmsmga008.fm.intel.com ([10.253.24.58])\n by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 19 Jul 2021 01:33:38 -0700",
            "from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.119.25])\n by fmsmga008.fm.intel.com with ESMTP; 19 Jul 2021 01:33:37 -0700"
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10049\"; a=\"296577208\"",
            "E=Sophos;i=\"5.84,251,1620716400\"; d=\"scan'208\";a=\"296577208\"",
            "E=Sophos;i=\"5.84,251,1620716400\"; d=\"scan'208\";a=\"468347532\""
        ],
        "X-ExtLoop1": "1",
        "From": "Jiayu Hu <jiayu.hu@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "maxime.coquelin@redhat.com, chenbo.xia@intel.com,\n Jiayu Hu <jiayu.hu@intel.com>",
        "Date": "Mon, 19 Jul 2021 11:00:47 -0400",
        "Message-Id": "<1626706847-276163-4-git-send-email-jiayu.hu@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1626706847-276163-1-git-send-email-jiayu.hu@intel.com>",
        "References": "<1626465089-17052-2-git-send-email-jiayu.hu@intel.com>\n <1626706847-276163-1-git-send-email-jiayu.hu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v6 3/3] vhost: add thread unsafe async\n registeration functions",
        "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": "This patch adds thread unsafe version for async register and\nunregister functions.\n\nSigned-off-by: Jiayu Hu <jiayu.hu@intel.com>\nReviewed-by: Chenbo Xia <chenbo.xia@intel.com>\n---\n doc/guides/prog_guide/vhost_lib.rst |  16 ++++\n lib/vhost/rte_vhost_async.h         |  41 ++++++++++\n lib/vhost/version.map               |   4 +\n lib/vhost/vhost.c                   | 149 +++++++++++++++++++++++++++---------\n 4 files changed, 175 insertions(+), 35 deletions(-)",
    "diff": "diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst\nindex 2a61b85..462393d 100644\n--- a/doc/guides/prog_guide/vhost_lib.rst\n+++ b/doc/guides/prog_guide/vhost_lib.rst\n@@ -256,6 +256,14 @@ The following is an overview of some key Vhost API functions:\n     vhost invokes this function to get the copy data completed by async\n     devices.\n \n+* ``rte_vhost_async_channel_register_thread_unsafe(vid, queue_id, config, ops)``\n+\n+  Register an async copy device channel for a vhost queue without\n+  performing any locking.\n+\n+  This function is only safe to call in vhost callback functions\n+  (i.e., struct vhost_device_ops).\n+\n * ``rte_vhost_async_channel_unregister(vid, queue_id)``\n \n   Unregister the async copy device channel from a vhost queue.\n@@ -268,6 +276,14 @@ The following is an overview of some key Vhost API functions:\n   devices for all vhost queues in destroy_device(), when a\n   virtio device is paused or shut down.\n \n+* ``rte_vhost_async_channel_unregister_thread_unsafe(vid, queue_id)``\n+\n+  Unregister the async copy device channel for a vhost queue without\n+  performing any locking.\n+\n+  This function is only safe to call in vhost callback functions\n+  (i.e., struct vhost_device_ops).\n+\n * ``rte_vhost_submit_enqueue_burst(vid, queue_id, pkts, count, comp_pkts, comp_count)``\n \n   Submit an enqueue request to transmit ``count`` packets from host to guest\ndiff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h\nindex ef8c1a2..dbfbbcc 100644\n--- a/lib/vhost/rte_vhost_async.h\n+++ b/lib/vhost/rte_vhost_async.h\n@@ -141,6 +141,47 @@ __rte_experimental\n int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id);\n \n /**\n+ * Register an async channel for a vhost queue without performing any\n+ * locking\n+ *\n+ * @note This function does not perform any locking, and is only safe to\n+ *       call in vhost callback functions.\n+ *\n+ * @param vid\n+ *  vhost device id async channel to be attached to\n+ * @param queue_id\n+ *  vhost queue id async channel to be attached to\n+ * @param config\n+ *  Async channel configuration\n+ * @param ops\n+ *  Async channel operation callbacks\n+ * @return\n+ *  0 on success, -1 on failures\n+ */\n+__rte_experimental\n+int rte_vhost_async_channel_register_thread_unsafe(int vid, uint16_t queue_id,\n+\tstruct rte_vhost_async_config config,\n+\tstruct rte_vhost_async_channel_ops *ops);\n+\n+/**\n+ * Unregister an async channel for a vhost queue without performing any\n+ * locking\n+ *\n+ * @note This function does not perform any locking, and is only safe to\n+ *       call in vhost callback functions.\n+ *\n+ * @param vid\n+ *  vhost device id async channel to be detached from\n+ * @param queue_id\n+ *  vhost queue id async channel to be detached from\n+ * @return\n+ *  0 on success, -1 on failures\n+ */\n+__rte_experimental\n+int rte_vhost_async_channel_unregister_thread_unsafe(int vid,\n+\t\tuint16_t queue_id);\n+\n+/**\n  * This function submits enqueue data to async engine. Successfully\n  * enqueued packets can be transfer completed or being occupied by DMA\n  * engines, when this API returns. Transfer completed packets are returned\ndiff --git a/lib/vhost/version.map b/lib/vhost/version.map\nindex 9103a23..2363db8 100644\n--- a/lib/vhost/version.map\n+++ b/lib/vhost/version.map\n@@ -79,4 +79,8 @@ 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_async_channel_register_thread_unsafe;\n+\trte_vhost_async_channel_unregister_thread_unsafe;\n };\ndiff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c\nindex 908758e..d3d0205 100644\n--- a/lib/vhost/vhost.c\n+++ b/lib/vhost/vhost.c\n@@ -1619,43 +1619,19 @@ int rte_vhost_extern_callback_register(int vid,\n \treturn 0;\n }\n \n-int\n-rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n+static __rte_always_inline int\n+async_channel_register(int vid, uint16_t queue_id,\n \t\tstruct rte_vhost_async_config config,\n \t\tstruct rte_vhost_async_channel_ops *ops)\n {\n-\tstruct vhost_virtqueue *vq;\n \tstruct virtio_net *dev = get_device(vid);\n-\n-\tif (dev == NULL || ops == NULL)\n-\t\treturn -1;\n-\n-\tif (queue_id >= VHOST_MAX_VRING)\n-\t\treturn -1;\n-\n-\tvq = dev->virtqueue[queue_id];\n-\n-\tif (unlikely(vq == NULL || !dev->async_copy))\n-\t\treturn -1;\n-\n-\tif (unlikely(!(config.features & RTE_VHOST_ASYNC_INORDER))) {\n-\t\tVHOST_LOG_CONFIG(ERR,\n-\t\t\t\"async copy is not supported on non-inorder mode \"\n-\t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n-\t\treturn -1;\n-\t}\n-\n-\tif (unlikely(ops->check_completed_copies == NULL ||\n-\t\tops->transfer_data == NULL))\n-\t\treturn -1;\n-\n-\trte_spinlock_lock(&vq->access_lock);\n+\tstruct vhost_virtqueue *vq = dev->virtqueue[queue_id];\n \n \tif (unlikely(vq->async_registered)) {\n \t\tVHOST_LOG_CONFIG(ERR,\n \t\t\t\"async register failed: channel already registered \"\n \t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n-\t\tgoto reg_out;\n+\t\treturn -1;\n \t}\n \n \tvq->async_pkts_info = rte_malloc_socket(NULL,\n@@ -1666,7 +1642,7 @@ rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n \t\tVHOST_LOG_CONFIG(ERR,\n \t\t\t\"async register failed: cannot allocate memory for async_pkts_info \"\n \t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n-\t\tgoto reg_out;\n+\t\treturn -1;\n \t}\n \n \tvq->it_pool = rte_malloc_socket(NULL,\n@@ -1677,7 +1653,7 @@ rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n \t\tVHOST_LOG_CONFIG(ERR,\n \t\t\t\"async register failed: cannot allocate memory for it_pool \"\n \t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n-\t\tgoto reg_out;\n+\t\treturn -1;\n \t}\n \n \tvq->vec_pool = rte_malloc_socket(NULL,\n@@ -1688,7 +1664,7 @@ rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n \t\tVHOST_LOG_CONFIG(ERR,\n \t\t\t\"async register failed: cannot allocate memory for vec_pool \"\n \t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n-\t\tgoto reg_out;\n+\t\treturn -1;\n \t}\n \n \tif (vq_is_packed(dev)) {\n@@ -1700,7 +1676,7 @@ rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n \t\t\tVHOST_LOG_CONFIG(ERR,\n \t\t\t\t\"async register failed: cannot allocate memory for async buffers \"\n \t\t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n-\t\t\tgoto reg_out;\n+\t\t\treturn -1;\n \t\t}\n \t} else {\n \t\tvq->async_descs_split = rte_malloc_socket(NULL,\n@@ -1711,7 +1687,7 @@ rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n \t\t\tVHOST_LOG_CONFIG(ERR,\n \t\t\t\t\"async register failed: cannot allocate memory for async descs \"\n \t\t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n-\t\t\tgoto reg_out;\n+\t\t\treturn -1;\n \t\t}\n \t}\n \n@@ -1721,10 +1697,78 @@ rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n \n \tvq->async_registered = true;\n \n-reg_out:\n+\treturn 0;\n+}\n+\n+int\n+rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n+\t\tstruct rte_vhost_async_config config,\n+\t\tstruct rte_vhost_async_channel_ops *ops)\n+{\n+\tstruct vhost_virtqueue *vq;\n+\tstruct virtio_net *dev = get_device(vid);\n+\tint ret;\n+\n+\tif (dev == NULL || ops == NULL)\n+\t\treturn -1;\n+\n+\tif (queue_id >= VHOST_MAX_VRING)\n+\t\treturn -1;\n+\n+\tvq = dev->virtqueue[queue_id];\n+\n+\tif (unlikely(vq == NULL || !dev->async_copy))\n+\t\treturn -1;\n+\n+\tif (unlikely(!(config.features & RTE_VHOST_ASYNC_INORDER))) {\n+\t\tVHOST_LOG_CONFIG(ERR,\n+\t\t\t\"async copy is not supported on non-inorder mode \"\n+\t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n+\t\treturn -1;\n+\t}\n+\n+\tif (unlikely(ops->check_completed_copies == NULL ||\n+\t\tops->transfer_data == NULL))\n+\t\treturn -1;\n+\n+\trte_spinlock_lock(&vq->access_lock);\n+\tret = async_channel_register(vid, queue_id, config, ops);\n \trte_spinlock_unlock(&vq->access_lock);\n \n-\treturn 0;\n+\treturn ret;\n+}\n+\n+int\n+rte_vhost_async_channel_register_thread_unsafe(int vid, uint16_t queue_id,\n+\t\tstruct rte_vhost_async_config config,\n+\t\tstruct rte_vhost_async_channel_ops *ops)\n+{\n+\tstruct vhost_virtqueue *vq;\n+\tstruct virtio_net *dev = get_device(vid);\n+\n+\tif (dev == NULL || ops == NULL)\n+\t\treturn -1;\n+\n+\tif (queue_id >= VHOST_MAX_VRING)\n+\t\treturn -1;\n+\n+\tvq = dev->virtqueue[queue_id];\n+\n+\tif (unlikely(vq == NULL || !dev->async_copy))\n+\t\treturn -1;\n+\n+\tif (unlikely(!(config.features & RTE_VHOST_ASYNC_INORDER))) {\n+\t\tVHOST_LOG_CONFIG(ERR,\n+\t\t\t\"async copy is not supported on non-inorder mode \"\n+\t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n+\t\treturn -1;\n+\t}\n+\n+\tif (unlikely(ops->check_completed_copies == NULL ||\n+\t\tops->transfer_data == NULL))\n+\t\treturn -1;\n+\n+\treturn async_channel_register(vid, queue_id, config, ops);\n }\n \n int\n@@ -1775,5 +1819,40 @@ rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)\n \treturn ret;\n }\n \n+int\n+rte_vhost_async_channel_unregister_thread_unsafe(int vid, uint16_t queue_id)\n+{\n+\tstruct vhost_virtqueue *vq;\n+\tstruct virtio_net *dev = get_device(vid);\n+\n+\tif (dev == NULL)\n+\t\treturn -1;\n+\n+\tif (queue_id >= VHOST_MAX_VRING)\n+\t\treturn -1;\n+\n+\tvq = dev->virtqueue[queue_id];\n+\n+\tif (vq == NULL)\n+\t\treturn -1;\n+\n+\tif (!vq->async_registered)\n+\t\treturn 0;\n+\n+\tif (vq->async_pkts_inflight_n) {\n+\t\tVHOST_LOG_CONFIG(ERR, \"Failed to unregister async channel. \"\n+\t\t\t\"async inflight packets must be completed before unregistration.\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tvhost_free_async_mem(vq);\n+\n+\tvq->async_ops.transfer_data = NULL;\n+\tvq->async_ops.check_completed_copies = NULL;\n+\tvq->async_registered = false;\n+\n+\treturn 0;\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",
        "3/3"
    ]
}