get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 94252,
    "url": "https://patches.dpdk.org/api/patches/94252/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210615141513.16163-2-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": "<20210615141513.16163-2-cheng1.jiang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210615141513.16163-2-cheng1.jiang@intel.com",
    "date": "2021-06-15T14:15:11",
    "name": "[v2,1/3] vhost: add unsafe API to drain pkts in async vhost",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "2397336b1aa82bae07e29759a3f2d0a7d7ea1b4b",
    "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/20210615141513.16163-2-cheng1.jiang@intel.com/mbox/",
    "series": [
        {
            "id": 17339,
            "url": "https://patches.dpdk.org/api/series/17339/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=17339",
            "date": "2021-06-15T14:15:10",
            "name": "vhost: handle memory hotplug for async vhost",
            "version": 2,
            "mbox": "https://patches.dpdk.org/series/17339/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/94252/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/94252/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 B61FAA0C44;\n\tTue, 15 Jun 2021 16:31:36 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 8857641165;\n\tTue, 15 Jun 2021 16:31:33 +0200 (CEST)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n by mails.dpdk.org (Postfix) with ESMTP id 7FE6141164\n for <dev@dpdk.org>; Tue, 15 Jun 2021 16:31:30 +0200 (CEST)",
            "from orsmga001.jf.intel.com ([10.7.209.18])\n by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 15 Jun 2021 07:31:30 -0700",
            "from dpdk_jiangcheng.sh.intel.com ([10.67.119.149])\n by orsmga001.jf.intel.com with ESMTP; 15 Jun 2021 07:31:28 -0700"
        ],
        "IronPort-SDR": [
            "\n H0RImr4gaFpcp1s9IX5LUxnt/Euy3rmSPBOAJgmcOhU7Cu51t/CB7y0qIvs69c/QHlRTbsZNtm\n nYjIHAaGIn7A==",
            "\n S3rXea8j6jVsno5cSpkybbkCQxIXz9ZiE8pS3IsLr/yw8UEypbTnu4ONqnVWySVveCFHDp5GAz\n n1LGy9ZFISjA=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10015\"; a=\"227472946\"",
            "E=Sophos;i=\"5.83,275,1616482800\"; d=\"scan'208\";a=\"227472946\"",
            "E=Sophos;i=\"5.83,275,1616482800\"; d=\"scan'208\";a=\"484488295\""
        ],
        "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": "Tue, 15 Jun 2021 14:15:11 +0000",
        "Message-Id": "<20210615141513.16163-2-cheng1.jiang@intel.com>",
        "X-Mailer": "git-send-email 2.29.2",
        "In-Reply-To": "<20210615141513.16163-1-cheng1.jiang@intel.com>",
        "References": "<20210602042802.31943-1-cheng1.jiang@intel.com>\n <20210615141513.16163-1-cheng1.jiang@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v2 1/3] 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 | 22 +++++++++\n lib/vhost/version.map       |  3 ++\n lib/vhost/virtio_net.c      | 90 +++++++++++++++++++++++++++----------\n 3 files changed, 92 insertions(+), 23 deletions(-)",
    "diff": "diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h\nindex 6faa31f5ad..041f40cf04 100644\n--- a/lib/vhost/rte_vhost_async.h\n+++ b/lib/vhost/rte_vhost_async.h\n@@ -193,4 +193,26 @@ __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+ * @return\n+ *  num of packets returned\n+ */\n+__rte_experimental\n+uint16_t rte_vhost_drain_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 9103a23cd4..f480f188af 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_drain_queue_thread_unsafe;\n };\ndiff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c\nindex 8da8a86a10..793510974a 100644\n--- a/lib/vhost/virtio_net.c\n+++ b/lib/vhost/virtio_net.c\n@@ -2082,36 +2082,18 @@ 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 \tstruct async_inflight_info *pkts_info;\n \tuint16_t from, i;\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@@ -2119,14 +2101,14 @@ 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_pkts_cpl = vq->async_ops.check_completed_copies(vid,\n+\t\tn_pkts_cpl = vq->async_ops.check_completed_copies(dev->vid,\n \t\t\tqueue_id, 0, count - vq->async_last_pkts_n);\n \tn_pkts_cpl += vq->async_last_pkts_n;\n \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@@ -2165,12 +2147,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_drain_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 = count;\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 (count)\n+\t\tcount -= vhost_poll_enqueue_completed(dev, queue_id, pkts, count);\n+\n+\treturn n_pkts;\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": [
        "v2",
        "1/3"
    ]
}