get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 100732,
    "url": "https://patches.dpdk.org/api/patches/100732/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20211007220013.355530-2-maxime.coquelin@redhat.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": "<20211007220013.355530-2-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20211007220013.355530-2-maxime.coquelin@redhat.com",
    "date": "2021-10-07T22:00:00",
    "name": "[RFC,01/14] vhost: move async data in a dedicated structure",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "355959bb142dcd7b68c83482171c00b43421525b",
    "submitter": {
        "id": 512,
        "url": "https://patches.dpdk.org/api/people/512/?format=api",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.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/20211007220013.355530-2-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 19439,
            "url": "https://patches.dpdk.org/api/series/19439/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=19439",
            "date": "2021-10-07T22:00:01",
            "name": "vhost: clean-up and simplify async implementation",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/19439/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/100732/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/100732/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 D9204A0C43;\n\tFri,  8 Oct 2021 00:14:08 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 5F34841467;\n\tFri,  8 Oct 2021 00:14:04 +0200 (CEST)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [216.205.24.124])\n by mails.dpdk.org (Postfix) with ESMTP id BEA7A4146E\n for <dev@dpdk.org>; Fri,  8 Oct 2021 00:14:02 +0200 (CEST)",
            "from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id\n us-mta-507-lb3fbOzWPfqZYTvQnK1wUA-1; Thu, 07 Oct 2021 18:13:55 -0400",
            "from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com\n [10.5.11.16])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BB6261A767D7;\n Thu,  7 Oct 2021 22:00:20 +0000 (UTC)",
            "from max-t490s.redhat.com (unknown [10.39.208.18])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 9BC875C1A3;\n Thu,  7 Oct 2021 22:00:18 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1633644842;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=bnhd04TnRn+fsADLu8CGpKvdricoZVrFumCMVqCpAWg=;\n b=O9Srn7S8FOwPHX6WfqS+V8jHZm9PW5hf5VRmLzNXZKHG40W4fGb6+dI69u09piH76i64mW\n 3qXxYmJC9yNuCORgc7u9FVYz23vOkrAlgoIgp60jEixisk0+srfj9+46CojV8OO6QGTPo7\n 5d2SXpkvM8jFLjK63Hi4CJPCdftE3bM=",
        "X-MC-Unique": "lb3fbOzWPfqZYTvQnK1wUA-1",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org, chenbo.xia@intel.com, jiayu.hu@intel.com,\n yuanx.wang@intel.com, wenwux.ma@intel.com, bruce.richardson@intel.com,\n john.mcnamara@intel.com",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Fri,  8 Oct 2021 00:00:00 +0200",
        "Message-Id": "<20211007220013.355530-2-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20211007220013.355530-1-maxime.coquelin@redhat.com>",
        "References": "<20211007220013.355530-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.16",
        "Authentication-Results": "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"",
        "Subject": "[dpdk-dev] [RFC 01/14] vhost: move async data in a dedicated\n structure",
        "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 moves async-related metadata from vhost_virtqueue\nto a dedicated struct. It makes it clear which fields are\nasync related, and also saves some memory when async feature\nis not in use.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n lib/vhost/vhost.c      | 129 ++++++++++++++++-------------------------\n lib/vhost/vhost.h      |  53 ++++++++---------\n lib/vhost/vhost_user.c |   4 +-\n lib/vhost/virtio_net.c | 114 +++++++++++++++++++-----------------\n 4 files changed, 140 insertions(+), 160 deletions(-)",
    "diff": "diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c\nindex 9540522dac..58f72b633c 100644\n--- a/lib/vhost/vhost.c\n+++ b/lib/vhost/vhost.c\n@@ -340,19 +340,15 @@ cleanup_device(struct virtio_net *dev, int destroy)\n static void\n vhost_free_async_mem(struct vhost_virtqueue *vq)\n {\n-\trte_free(vq->async_pkts_info);\n+\trte_free(vq->async->pkts_info);\n \n-\trte_free(vq->async_buffers_packed);\n-\tvq->async_buffers_packed = NULL;\n-\trte_free(vq->async_descs_split);\n-\tvq->async_descs_split = NULL;\n+\trte_free(vq->async->buffers_packed);\n+\tvq->async->buffers_packed = NULL;\n+\trte_free(vq->async->descs_split);\n+\tvq->async->descs_split = NULL;\n \n-\trte_free(vq->it_pool);\n-\trte_free(vq->vec_pool);\n-\n-\tvq->async_pkts_info = NULL;\n-\tvq->it_pool = NULL;\n-\tvq->vec_pool = NULL;\n+\trte_free(vq->async);\n+\tvq->async = NULL;\n }\n \n void\n@@ -1629,77 +1625,63 @@ async_channel_register(int vid, uint16_t queue_id,\n {\n \tstruct virtio_net *dev = get_device(vid);\n \tstruct vhost_virtqueue *vq = dev->virtqueue[queue_id];\n+\tstruct vhost_async *async;\n+\tint node = vq->numa_node;\n \n-\tif (unlikely(vq->async_registered)) {\n+\tif (unlikely(vq->async)) {\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\t\t\t\"async register failed: already registered (vid %d, qid: %d)\\n\",\n+\t\t\t\tvid, queue_id);\n \t\treturn -1;\n \t}\n \n-\tvq->async_pkts_info = rte_malloc_socket(NULL,\n-\t\t\tvq->size * sizeof(struct async_inflight_info),\n-\t\t\tRTE_CACHE_LINE_SIZE, vq->numa_node);\n-\tif (!vq->async_pkts_info) {\n-\t\tvhost_free_async_mem(vq);\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+\tasync = rte_zmalloc_socket(NULL, sizeof(struct vhost_async), 0, node);\n+\tif (!async) {\n+\t\tVHOST_LOG_CONFIG(ERR, \"failed to allocate async metadata (vid %d, qid: %d)\\n\",\n+\t\t\t\tvid, queue_id);\n \t\treturn -1;\n \t}\n \n-\tvq->it_pool = rte_malloc_socket(NULL,\n-\t\t\tVHOST_MAX_ASYNC_IT * sizeof(struct rte_vhost_iov_iter),\n-\t\t\tRTE_CACHE_LINE_SIZE, vq->numa_node);\n-\tif (!vq->it_pool) {\n-\t\tvhost_free_async_mem(vq);\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\treturn -1;\n-\t}\n-\n-\tvq->vec_pool = rte_malloc_socket(NULL,\n-\t\t\tVHOST_MAX_ASYNC_VEC * sizeof(struct iovec),\n-\t\t\tRTE_CACHE_LINE_SIZE, vq->numa_node);\n-\tif (!vq->vec_pool) {\n-\t\tvhost_free_async_mem(vq);\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\treturn -1;\n+\tasync->pkts_info = rte_malloc_socket(NULL, vq->size * sizeof(struct async_inflight_info),\n+\t\t\tRTE_CACHE_LINE_SIZE, node);\n+\tif (async->pkts_info) {\n+\t\tVHOST_LOG_CONFIG(ERR, \"failed to allocate async_pkts_info (vid %d, qid: %d)\\n\",\n+\t\t\t\tvid, queue_id);\n+\t\tgoto out_free_async;\n \t}\n \n \tif (vq_is_packed(dev)) {\n-\t\tvq->async_buffers_packed = rte_malloc_socket(NULL,\n-\t\t\tvq->size * sizeof(struct vring_used_elem_packed),\n-\t\t\tRTE_CACHE_LINE_SIZE, vq->numa_node);\n-\t\tif (!vq->async_buffers_packed) {\n-\t\t\tvhost_free_async_mem(vq);\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\treturn -1;\n+\t\tasync->buffers_packed = rte_malloc_socket(NULL,\n+\t\t\t\tvq->size * sizeof(struct vring_used_elem_packed),\n+\t\t\t\tRTE_CACHE_LINE_SIZE, node);\n+\t\tif (!async->buffers_packed) {\n+\t\t\tVHOST_LOG_CONFIG(ERR, \"failed to allocate async buffers (vid %d, qid: %d)\\n\",\n+\t\t\t\t\tvid, queue_id);\n+\t\t\tgoto out_free_inflight;\n \t\t}\n \t} else {\n-\t\tvq->async_descs_split = rte_malloc_socket(NULL,\n-\t\t\tvq->size * sizeof(struct vring_used_elem),\n-\t\t\tRTE_CACHE_LINE_SIZE, vq->numa_node);\n-\t\tif (!vq->async_descs_split) {\n-\t\t\tvhost_free_async_mem(vq);\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\treturn -1;\n+\t\tasync->descs_split = rte_malloc_socket(NULL,\n+\t\t\t\tvq->size * sizeof(struct vring_used_elem),\n+\t\t\t\tRTE_CACHE_LINE_SIZE, node);\n+\t\tif (!async->descs_split) {\n+\t\t\tVHOST_LOG_CONFIG(ERR, \"failed to allocate async descs (vid %d, qid: %d)\\n\",\n+\t\t\t\t\tvid, queue_id);\n+\t\t\tgoto out_free_inflight;\n \t\t}\n \t}\n \n-\tvq->async_ops.check_completed_copies = ops->check_completed_copies;\n-\tvq->async_ops.transfer_data = ops->transfer_data;\n+\tasync->ops.check_completed_copies = ops->check_completed_copies;\n+\tasync->ops.transfer_data = ops->transfer_data;\n \n-\tvq->async_registered = true;\n+\tvq->async = async;\n \n \treturn 0;\n+out_free_inflight:\n+\trte_free(async->pkts_info);\n+out_free_async:\n+\trte_free(async);\n+\n+\treturn -1;\n }\n \n int\n@@ -1793,7 +1775,7 @@ rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)\n \n \tret = 0;\n \n-\tif (!vq->async_registered)\n+\tif (!vq->async)\n \t\treturn ret;\n \n \tif (!rte_spinlock_trylock(&vq->access_lock)) {\n@@ -1802,7 +1784,7 @@ rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)\n \t\treturn -1;\n \t}\n \n-\tif (vq->async_pkts_inflight_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\tret = -1;\n@@ -1810,11 +1792,6 @@ rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)\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 out:\n \trte_spinlock_unlock(&vq->access_lock);\n \n@@ -1838,10 +1815,10 @@ rte_vhost_async_channel_unregister_thread_unsafe(int vid, uint16_t queue_id)\n \tif (vq == NULL)\n \t\treturn -1;\n \n-\tif (!vq->async_registered)\n+\tif (!vq->async)\n \t\treturn 0;\n \n-\tif (vq->async_pkts_inflight_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@@ -1849,10 +1826,6 @@ rte_vhost_async_channel_unregister_thread_unsafe(int vid, uint16_t queue_id)\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@@ -1874,7 +1847,7 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)\n \tif (vq == NULL)\n \t\treturn ret;\n \n-\tif (!vq->async_registered)\n+\tif (!vq->async)\n \t\treturn ret;\n \n \tif (!rte_spinlock_trylock(&vq->access_lock)) {\n@@ -1883,7 +1856,7 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)\n \t\treturn ret;\n \t}\n \n-\tret = vq->async_pkts_inflight_n;\n+\tret = vq->async->pkts_inflight_n;\n \trte_spinlock_unlock(&vq->access_lock);\n \n \treturn ret;\ndiff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h\nindex 1e56311725..ba33c6a69d 100644\n--- a/lib/vhost/vhost.h\n+++ b/lib/vhost/vhost.h\n@@ -119,6 +119,32 @@ struct vring_used_elem_packed {\n \tuint32_t count;\n };\n \n+struct vhost_async {\n+\t/* operation callbacks for DMA */\n+\tstruct rte_vhost_async_channel_ops ops;\n+\n+\tstruct rte_vhost_iov_iter it_pool[VHOST_MAX_ASYNC_IT];\n+\tstruct iovec vec_pool[VHOST_MAX_ASYNC_VEC];\n+\n+\t/* data transfer status */\n+\tstruct async_inflight_info *pkts_info;\n+\tuint16_t pkts_idx;\n+\tuint16_t pkts_inflight_n;\n+\tuint16_t last_pkts_n;\n+\tunion {\n+\t\tstruct vring_used_elem  *descs_split;\n+\t\tstruct vring_used_elem_packed *buffers_packed;\n+\t};\n+\tunion {\n+\t\tuint16_t desc_idx_split;\n+\t\tuint16_t buffer_idx_packed;\n+\t};\n+\tunion {\n+\t\tuint16_t last_desc_idx_split;\n+\t\tuint16_t last_buffer_idx_packed;\n+\t};\n+};\n+\n /**\n  * Structure contains variables relevant to RX/TX virtqueues.\n  */\n@@ -193,32 +219,7 @@ struct vhost_virtqueue {\n \tstruct rte_vhost_resubmit_info *resubmit_inflight;\n \tuint64_t\t\tglobal_counter;\n \n-\t/* operation callbacks for async dma */\n-\tstruct rte_vhost_async_channel_ops\tasync_ops;\n-\n-\tstruct rte_vhost_iov_iter *it_pool;\n-\tstruct iovec *vec_pool;\n-\n-\t/* async data transfer status */\n-\tstruct async_inflight_info *async_pkts_info;\n-\tuint16_t\tasync_pkts_idx;\n-\tuint16_t\tasync_pkts_inflight_n;\n-\tuint16_t\tasync_last_pkts_n;\n-\tunion {\n-\t\tstruct vring_used_elem  *async_descs_split;\n-\t\tstruct vring_used_elem_packed *async_buffers_packed;\n-\t};\n-\tunion {\n-\t\tuint16_t async_desc_idx_split;\n-\t\tuint16_t async_buffer_idx_packed;\n-\t};\n-\tunion {\n-\t\tuint16_t last_async_desc_idx_split;\n-\t\tuint16_t last_async_buffer_idx_packed;\n-\t};\n-\n-\t/* vq async features */\n-\tbool\t\tasync_registered;\n+\tstruct vhost_async\t*async;\n \n \tint\t\t\tnotif_enable;\n #define VIRTIO_UNINITIALIZED_NOTIF\t(-1)\ndiff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c\nindex 5a894ca0cc..dad4463d45 100644\n--- a/lib/vhost/vhost_user.c\n+++ b/lib/vhost/vhost_user.c\n@@ -2140,8 +2140,8 @@ vhost_user_set_vring_enable(struct virtio_net **pdev,\n \t\t\"set queue enable: %d to qp idx: %d\\n\",\n \t\tenable, index);\n \n-\tif (enable && dev->virtqueue[index]->async_registered) {\n-\t\tif (dev->virtqueue[index]->async_pkts_inflight_n) {\n+\tif (enable && dev->virtqueue[index]->async) {\n+\t\tif (dev->virtqueue[index]->async->pkts_inflight_n) {\n \t\t\tVHOST_LOG_CONFIG(ERR, \"failed to enable vring. \"\n \t\t\t\"async inflight packets must be completed first\\n\");\n \t\t\treturn RTE_VHOST_MSG_RESULT_ERR;\ndiff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c\nindex e481906113..a109c2a316 100644\n--- a/lib/vhost/virtio_net.c\n+++ b/lib/vhost/virtio_net.c\n@@ -1510,12 +1510,13 @@ virtio_dev_rx_async_submit_split(struct virtio_net *dev,\n \tuint16_t num_buffers;\n \tuint16_t avail_head;\n \n-\tstruct rte_vhost_iov_iter *it_pool = vq->it_pool;\n-\tstruct iovec *vec_pool = vq->vec_pool;\n+\tstruct vhost_async *async = vq->async;\n+\tstruct rte_vhost_iov_iter *it_pool = async->it_pool;\n+\tstruct iovec *vec_pool = async->vec_pool;\n \tstruct rte_vhost_async_desc tdes[MAX_PKT_BURST];\n \tstruct iovec *src_iovec = vec_pool;\n \tstruct iovec *dst_iovec = vec_pool + (VHOST_MAX_ASYNC_VEC >> 1);\n-\tstruct async_inflight_info *pkts_info = vq->async_pkts_info;\n+\tstruct async_inflight_info *pkts_info = async->pkts_info;\n \tuint32_t n_pkts = 0, pkt_err = 0;\n \tint32_t n_xfer;\n \tuint16_t segs_await = 0;\n@@ -1556,7 +1557,7 @@ virtio_dev_rx_async_submit_split(struct virtio_net *dev,\n \t\tasync_fill_desc(&tdes[pkt_burst_idx++], &it_pool[it_idx],\n \t\t\t\t&it_pool[it_idx + 1]);\n \n-\t\tslot_idx = (vq->async_pkts_idx + pkt_idx) & (vq->size - 1);\n+\t\tslot_idx = (async->pkts_idx + pkt_idx) & (vq->size - 1);\n \t\tpkts_info[slot_idx].descs = num_buffers;\n \t\tpkts_info[slot_idx].mbuf = pkts[pkt_idx];\n \n@@ -1574,7 +1575,7 @@ virtio_dev_rx_async_submit_split(struct virtio_net *dev,\n \t\tif (unlikely(pkt_burst_idx >= VHOST_ASYNC_BATCH_THRESHOLD ||\n \t\t\t((VHOST_MAX_ASYNC_VEC >> 1) - segs_await <\n \t\t\tBUF_VECTOR_MAX))) {\n-\t\t\tn_xfer = vq->async_ops.transfer_data(dev->vid,\n+\t\t\tn_xfer = async->ops.transfer_data(dev->vid,\n \t\t\t\t\tqueue_id, tdes, 0, pkt_burst_idx);\n \t\t\tif (likely(n_xfer >= 0)) {\n \t\t\t\tn_pkts = n_xfer;\n@@ -1606,7 +1607,7 @@ virtio_dev_rx_async_submit_split(struct virtio_net *dev,\n \t}\n \n \tif (pkt_burst_idx) {\n-\t\tn_xfer = vq->async_ops.transfer_data(dev->vid, queue_id, tdes, 0, pkt_burst_idx);\n+\t\tn_xfer = async->ops.transfer_data(dev->vid, queue_id, tdes, 0, pkt_burst_idx);\n \t\tif (likely(n_xfer >= 0)) {\n \t\t\tn_pkts = n_xfer;\n \t\t} else {\n@@ -1638,15 +1639,15 @@ virtio_dev_rx_async_submit_split(struct virtio_net *dev,\n \n \t/* keep used descriptors */\n \tif (likely(vq->shadow_used_idx)) {\n-\t\tuint16_t to = vq->async_desc_idx_split & (vq->size - 1);\n+\t\tuint16_t to = async->desc_idx_split & (vq->size - 1);\n \n \t\tstore_dma_desc_info_split(vq->shadow_used_split,\n-\t\t\t\tvq->async_descs_split, vq->size, 0, to,\n+\t\t\t\tasync->descs_split, vq->size, 0, to,\n \t\t\t\tvq->shadow_used_idx);\n \n-\t\tvq->async_desc_idx_split += vq->shadow_used_idx;\n-\t\tvq->async_pkts_idx += pkt_idx;\n-\t\tvq->async_pkts_inflight_n += pkt_idx;\n+\t\tasync->desc_idx_split += vq->shadow_used_idx;\n+\t\tasync->pkts_idx += pkt_idx;\n+\t\tasync->pkts_inflight_n += pkt_idx;\n \t\tvq->shadow_used_idx = 0;\n \t}\n \n@@ -1798,7 +1799,7 @@ dma_error_handler_packed(struct vhost_virtqueue *vq, uint16_t slot_idx,\n {\n \tuint16_t descs_err = 0;\n \tuint16_t buffers_err = 0;\n-\tstruct async_inflight_info *pkts_info = vq->async_pkts_info;\n+\tstruct async_inflight_info *pkts_info = vq->async->pkts_info;\n \n \t*pkt_idx -= nr_err;\n \t/* calculate the sum of buffers and descs of DMA-error packets. */\n@@ -1829,12 +1830,13 @@ virtio_dev_rx_async_submit_packed(struct virtio_net *dev,\n \tuint16_t num_buffers;\n \tuint16_t num_descs;\n \n-\tstruct rte_vhost_iov_iter *it_pool = vq->it_pool;\n-\tstruct iovec *vec_pool = vq->vec_pool;\n+\tstruct vhost_async *async = vq->async;\n+\tstruct rte_vhost_iov_iter *it_pool = async->it_pool;\n+\tstruct iovec *vec_pool = async->vec_pool;\n \tstruct rte_vhost_async_desc tdes[MAX_PKT_BURST];\n \tstruct iovec *src_iovec = vec_pool;\n \tstruct iovec *dst_iovec = vec_pool + (VHOST_MAX_ASYNC_VEC >> 1);\n-\tstruct async_inflight_info *pkts_info = vq->async_pkts_info;\n+\tstruct async_inflight_info *pkts_info = async->pkts_info;\n \tuint32_t n_pkts = 0, pkt_err = 0;\n \tuint16_t slot_idx = 0;\n \tuint16_t segs_await = 0;\n@@ -1851,7 +1853,7 @@ virtio_dev_rx_async_submit_packed(struct virtio_net *dev,\n \t\t\t\t\t\t&it_pool[it_idx], &it_pool[it_idx + 1]) < 0))\n \t\t\tbreak;\n \n-\t\tslot_idx = (vq->async_pkts_idx + pkt_idx) % vq->size;\n+\t\tslot_idx = (async->pkts_idx + pkt_idx) % vq->size;\n \n \t\tasync_fill_desc(&tdes[pkt_burst_idx++], &it_pool[it_idx],\n \t\t\t\t&it_pool[it_idx + 1]);\n@@ -1873,7 +1875,7 @@ virtio_dev_rx_async_submit_packed(struct virtio_net *dev,\n \t\t */\n \t\tif (unlikely(pkt_burst_idx >= VHOST_ASYNC_BATCH_THRESHOLD ||\n \t\t\t((VHOST_MAX_ASYNC_VEC >> 1) - segs_await < BUF_VECTOR_MAX))) {\n-\t\t\tn_xfer = vq->async_ops.transfer_data(dev->vid,\n+\t\t\tn_xfer = async->ops.transfer_data(dev->vid,\n \t\t\t\t\tqueue_id, tdes, 0, pkt_burst_idx);\n \t\t\tif (likely(n_xfer >= 0)) {\n \t\t\t\tn_pkts = n_xfer;\n@@ -1904,7 +1906,7 @@ virtio_dev_rx_async_submit_packed(struct virtio_net *dev,\n \t} while (pkt_idx < count);\n \n \tif (pkt_burst_idx) {\n-\t\tn_xfer = vq->async_ops.transfer_data(dev->vid, queue_id, tdes, 0, pkt_burst_idx);\n+\t\tn_xfer = async->ops.transfer_data(dev->vid, queue_id, tdes, 0, pkt_burst_idx);\n \t\tif (likely(n_xfer >= 0)) {\n \t\t\tn_pkts = n_xfer;\n \t\t} else {\n@@ -1922,20 +1924,20 @@ virtio_dev_rx_async_submit_packed(struct virtio_net *dev,\n \n \tif (likely(vq->shadow_used_idx)) {\n \t\t/* keep used descriptors. */\n-\t\tstore_dma_desc_info_packed(vq->shadow_used_packed, vq->async_buffers_packed,\n-\t\t\t\t\tvq->size, 0, vq->async_buffer_idx_packed,\n+\t\tstore_dma_desc_info_packed(vq->shadow_used_packed, async->buffers_packed,\n+\t\t\t\t\tvq->size, 0, async->buffer_idx_packed,\n \t\t\t\t\tvq->shadow_used_idx);\n \n-\t\tvq->async_buffer_idx_packed += vq->shadow_used_idx;\n-\t\tif (vq->async_buffer_idx_packed >= vq->size)\n-\t\t\tvq->async_buffer_idx_packed -= vq->size;\n+\t\tasync->buffer_idx_packed += vq->shadow_used_idx;\n+\t\tif (async->buffer_idx_packed >= vq->size)\n+\t\t\tasync->buffer_idx_packed -= vq->size;\n \n-\t\tvq->async_pkts_idx += pkt_idx;\n-\t\tif (vq->async_pkts_idx >= vq->size)\n-\t\t\tvq->async_pkts_idx -= vq->size;\n+\t\tasync->pkts_idx += pkt_idx;\n+\t\tif (async->pkts_idx >= vq->size)\n+\t\t\tasync->pkts_idx -= vq->size;\n \n \t\tvq->shadow_used_idx = 0;\n-\t\tvq->async_pkts_inflight_n += pkt_idx;\n+\t\tasync->pkts_inflight_n += pkt_idx;\n \t}\n \n \treturn pkt_idx;\n@@ -1944,28 +1946,29 @@ virtio_dev_rx_async_submit_packed(struct virtio_net *dev,\n static __rte_always_inline void\n write_back_completed_descs_split(struct vhost_virtqueue *vq, uint16_t n_descs)\n {\n+\tstruct vhost_async *async = vq->async;\n \tuint16_t nr_left = n_descs;\n \tuint16_t nr_copy;\n \tuint16_t to, from;\n \n \tdo {\n-\t\tfrom = vq->last_async_desc_idx_split & (vq->size - 1);\n+\t\tfrom = async->last_desc_idx_split & (vq->size - 1);\n \t\tnr_copy = nr_left + from <= vq->size ? nr_left : vq->size - from;\n \t\tto = vq->last_used_idx & (vq->size - 1);\n \n \t\tif (to + nr_copy <= vq->size) {\n-\t\t\trte_memcpy(&vq->used->ring[to], &vq->async_descs_split[from],\n+\t\t\trte_memcpy(&vq->used->ring[to], &async->descs_split[from],\n \t\t\t\t\tnr_copy * sizeof(struct vring_used_elem));\n \t\t} else {\n \t\t\tuint16_t size = vq->size - to;\n \n-\t\t\trte_memcpy(&vq->used->ring[to], &vq->async_descs_split[from],\n+\t\t\trte_memcpy(&vq->used->ring[to], &async->descs_split[from],\n \t\t\t\t\tsize * sizeof(struct vring_used_elem));\n-\t\t\trte_memcpy(&vq->used->ring[0], &vq->async_descs_split[from + size],\n+\t\t\trte_memcpy(&vq->used->ring[0], &async->descs_split[from + size],\n \t\t\t\t\t(nr_copy - size) * sizeof(struct vring_used_elem));\n \t\t}\n \n-\t\tvq->last_async_desc_idx_split += nr_copy;\n+\t\tasync->last_desc_idx_split += nr_copy;\n \t\tvq->last_used_idx += nr_copy;\n \t\tnr_left -= nr_copy;\n \t} while (nr_left > 0);\n@@ -1975,20 +1978,21 @@ static __rte_always_inline void\n write_back_completed_descs_packed(struct vhost_virtqueue *vq,\n \t\t\t\tuint16_t n_buffers)\n {\n+\tstruct vhost_async *async = vq->async;\n \tuint16_t nr_left = n_buffers;\n \tuint16_t from, to;\n \n \tdo {\n-\t\tfrom = vq->last_async_buffer_idx_packed;\n+\t\tfrom = async->last_buffer_idx_packed;\n \t\tto = (from + nr_left) % vq->size;\n \t\tif (to > from) {\n-\t\t\tvhost_update_used_packed(vq, vq->async_buffers_packed + from, to - from);\n-\t\t\tvq->last_async_buffer_idx_packed += nr_left;\n+\t\t\tvhost_update_used_packed(vq, async->buffers_packed + from, to - from);\n+\t\t\tasync->last_buffer_idx_packed += nr_left;\n \t\t\tnr_left = 0;\n \t\t} else {\n-\t\t\tvhost_update_used_packed(vq, vq->async_buffers_packed + from,\n+\t\t\tvhost_update_used_packed(vq, async->buffers_packed + from,\n \t\t\t\tvq->size - from);\n-\t\t\tvq->last_async_buffer_idx_packed = 0;\n+\t\t\tasync->last_buffer_idx_packed = 0;\n \t\t\tnr_left -= vq->size - from;\n \t\t}\n \t} while (nr_left > 0);\n@@ -1999,6 +2003,7 @@ vhost_poll_enqueue_completed(struct virtio_net *dev, uint16_t queue_id,\n \t\tstruct rte_mbuf **pkts, uint16_t count)\n {\n \tstruct vhost_virtqueue *vq;\n+\tstruct vhost_async *async;\n \tstruct async_inflight_info *pkts_info;\n \tint32_t n_cpl;\n \tuint16_t n_pkts_cpl = 0, n_pkts_put = 0, n_descs = 0, n_buffers = 0;\n@@ -2006,15 +2011,16 @@ vhost_poll_enqueue_completed(struct virtio_net *dev, uint16_t queue_id,\n \tuint16_t from, i;\n \n \tvq = dev->virtqueue[queue_id];\n-\tpkts_idx = vq->async_pkts_idx % vq->size;\n-\tpkts_info = vq->async_pkts_info;\n+\tasync = vq->async;\n+\tpkts_idx = async->pkts_idx % vq->size;\n+\tpkts_info = async->pkts_info;\n \tvq_size = vq->size;\n \tstart_idx = virtio_dev_rx_async_get_info_idx(pkts_idx,\n-\t\tvq_size, vq->async_pkts_inflight_n);\n+\t\tvq_size, async->pkts_inflight_n);\n \n-\tif (count > vq->async_last_pkts_n) {\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+\tif (count > async->last_pkts_n) {\n+\t\tn_cpl = async->ops.check_completed_copies(dev->vid,\n+\t\t\tqueue_id, 0, count - async->last_pkts_n);\n \t\tif (likely(n_cpl >= 0)) {\n \t\t\tn_pkts_cpl = n_cpl;\n \t\t} else {\n@@ -2025,10 +2031,10 @@ vhost_poll_enqueue_completed(struct virtio_net *dev, uint16_t queue_id,\n \t\t}\n \t}\n \n-\tn_pkts_cpl += vq->async_last_pkts_n;\n+\tn_pkts_cpl += async->last_pkts_n;\n \tn_pkts_put = RTE_MIN(n_pkts_cpl, count);\n \tif (unlikely(n_pkts_put == 0)) {\n-\t\tvq->async_last_pkts_n = n_pkts_cpl;\n+\t\tasync->last_pkts_n = n_pkts_cpl;\n \t\treturn 0;\n \t}\n \n@@ -2045,8 +2051,8 @@ vhost_poll_enqueue_completed(struct virtio_net *dev, uint16_t queue_id,\n \t\t\tpkts[i] = pkts_info[from].mbuf;\n \t\t}\n \t}\n-\tvq->async_last_pkts_n = n_pkts_cpl - n_pkts_put;\n-\tvq->async_pkts_inflight_n -= n_pkts_put;\n+\tasync->last_pkts_n = n_pkts_cpl - n_pkts_put;\n+\tasync->pkts_inflight_n -= n_pkts_put;\n \n \tif (likely(vq->enabled && vq->access_ok)) {\n \t\tif (vq_is_packed(dev)) {\n@@ -2062,11 +2068,11 @@ vhost_poll_enqueue_completed(struct virtio_net *dev, uint16_t queue_id,\n \t\t}\n \t} else {\n \t\tif (vq_is_packed(dev)) {\n-\t\t\tvq->last_async_buffer_idx_packed += n_buffers;\n-\t\t\tif (vq->last_async_buffer_idx_packed >= vq->size)\n-\t\t\t\tvq->last_async_buffer_idx_packed -= vq->size;\n+\t\t\tasync->last_buffer_idx_packed += n_buffers;\n+\t\t\tif (async->last_buffer_idx_packed >= vq->size)\n+\t\t\t\tasync->last_buffer_idx_packed -= vq->size;\n \t\t} else {\n-\t\t\tvq->last_async_desc_idx_split += n_descs;\n+\t\t\tasync->last_desc_idx_split += n_descs;\n \t\t}\n \t}\n \n@@ -2093,7 +2099,7 @@ rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,\n \n \tvq = dev->virtqueue[queue_id];\n \n-\tif (unlikely(!vq->async_registered)) {\n+\tif (unlikely(!vq->async)) {\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@@ -2128,7 +2134,7 @@ rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,\n \n \tvq = dev->virtqueue[queue_id];\n \n-\tif (unlikely(!vq->async_registered)) {\n+\tif (unlikely(!vq->async)) {\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@@ -2157,7 +2163,7 @@ virtio_dev_rx_async_submit(struct virtio_net *dev, uint16_t queue_id,\n \n \trte_spinlock_lock(&vq->access_lock);\n \n-\tif (unlikely(!vq->enabled || !vq->async_registered))\n+\tif (unlikely(!vq->enabled || !vq->async))\n \t\tgoto out_access_unlock;\n \n \tif (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))\n",
    "prefixes": [
        "RFC",
        "01/14"
    ]
}