get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 123288,
    "url": "https://patches.dpdk.org/api/patches/123288/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20230207151747.245808-4-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": "<20230207151747.245808-4-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230207151747.245808-4-maxime.coquelin@redhat.com",
    "date": "2023-02-07T15:17:29",
    "name": "[v2,03/21] net/virtio: virtqueue headers alloc refactoring",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "a5cd9aa196691d3ef2fd48893a531741f81d977c",
    "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/20230207151747.245808-4-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 26854,
            "url": "https://patches.dpdk.org/api/series/26854/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=26854",
            "date": "2023-02-07T15:17:33",
            "name": "Add control queue & MQ support to Virtio-user vDPA",
            "version": 2,
            "mbox": "https://patches.dpdk.org/series/26854/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/123288/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/123288/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 7984E41C30;\n\tTue,  7 Feb 2023 16:20:01 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 0085242DB8;\n\tTue,  7 Feb 2023 16:18:55 +0100 (CET)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by mails.dpdk.org (Postfix) with ESMTP id 978FF42D70\n for <dev@dpdk.org>; Tue,  7 Feb 2023 16:18:48 +0100 (CET)",
            "from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-212-6SNzxXnOPveab3dL61V_TA-1; Tue, 07 Feb 2023 10:18:40 -0500",
            "from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com\n [10.11.54.7])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0F52D1029DFC;\n Tue,  7 Feb 2023 15:17:59 +0000 (UTC)",
            "from max-t490s.redhat.com (unknown [10.39.208.26])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 98F02140EBF4;\n Tue,  7 Feb 2023 15:17:57 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1675783128;\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=T1tQt6rYDWUz94OaZJZfsF15RP+csY2XB3thR2dHVPs=;\n b=OvwgxY/5GUfgnGRlA6LWVR8uIZpHW7sE+OvmpQlutV+IhYU977lA35/H2jjlCdhKkRRm7W\n H9vA4M/5GLO+R7rfWdoa8p4zOztEg6RqnY8FWUWP/WiXov0pK42E79VbZEqup4IQ6TSIHP\n 9h/z0OytgyL1iJ9fG8+5IokKvR9voQM=",
        "X-MC-Unique": "6SNzxXnOPveab3dL61V_TA-1",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org, chenbo.xia@intel.com, david.marchand@redhat.com,\n eperezma@redhat.com, stephen@networkplumber.org",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Subject": "[PATCH v2 03/21] net/virtio: virtqueue headers alloc refactoring",
        "Date": "Tue,  7 Feb 2023 16:17:29 +0100",
        "Message-Id": "<20230207151747.245808-4-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20230207151747.245808-1-maxime.coquelin@redhat.com>",
        "References": "<20230207151747.245808-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.1 on 10.11.54.7",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "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": "This patch refactors virtqueue initialization by moving\nits headers allocation and deallocation in dedicated\nfunction.\n\nWhile at it, it renames the memzone metadata and address\npointers in the virtnet_tx and virtnet_ctl structures to\nremove redundant virtio_net_ prefix.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\nReviewed-by: Chenbo Xia <chenbo.xia@intel.com>\n---\n drivers/net/virtio/virtio_cvq.c    |  19 ++--\n drivers/net/virtio/virtio_cvq.h    |   9 +-\n drivers/net/virtio/virtio_ethdev.c | 149 ++++++++++++++++++-----------\n drivers/net/virtio/virtio_rxtx.c   |  12 +--\n drivers/net/virtio/virtio_rxtx.h   |  12 +--\n drivers/net/virtio/virtqueue.c     |   8 +-\n drivers/net/virtio/virtqueue.h     |  13 +--\n 7 files changed, 126 insertions(+), 96 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_cvq.c b/drivers/net/virtio/virtio_cvq.c\nindex cd25614df8..5e457f5fd0 100644\n--- a/drivers/net/virtio/virtio_cvq.c\n+++ b/drivers/net/virtio/virtio_cvq.c\n@@ -34,7 +34,7 @@ virtio_send_command_packed(struct virtnet_ctl *cvq,\n \t */\n \thead = vq->vq_avail_idx;\n \tflags = vq->vq_packed.cached_flags;\n-\tdesc[head].addr = cvq->virtio_net_hdr_mem;\n+\tdesc[head].addr = cvq->hdr_mem;\n \tdesc[head].len = sizeof(struct virtio_net_ctrl_hdr);\n \tvq->vq_free_cnt--;\n \tnb_descs++;\n@@ -44,7 +44,7 @@ virtio_send_command_packed(struct virtnet_ctl *cvq,\n \t}\n \n \tfor (k = 0; k < pkt_num; k++) {\n-\t\tdesc[vq->vq_avail_idx].addr = cvq->virtio_net_hdr_mem\n+\t\tdesc[vq->vq_avail_idx].addr = cvq->hdr_mem\n \t\t\t+ sizeof(struct virtio_net_ctrl_hdr)\n \t\t\t+ sizeof(ctrl->status) + sizeof(uint8_t) * sum;\n \t\tdesc[vq->vq_avail_idx].len = dlen[k];\n@@ -60,7 +60,7 @@ virtio_send_command_packed(struct virtnet_ctl *cvq,\n \t\t}\n \t}\n \n-\tdesc[vq->vq_avail_idx].addr = cvq->virtio_net_hdr_mem\n+\tdesc[vq->vq_avail_idx].addr = cvq->hdr_mem\n \t\t+ sizeof(struct virtio_net_ctrl_hdr);\n \tdesc[vq->vq_avail_idx].len = sizeof(ctrl->status);\n \tdesc[vq->vq_avail_idx].flags = VRING_DESC_F_WRITE |\n@@ -103,7 +103,7 @@ virtio_send_command_packed(struct virtnet_ctl *cvq,\n \t\t\tvq->vq_packed.cached_flags,\n \t\t\tvq->vq_packed.used_wrap_counter);\n \n-\tresult = cvq->virtio_net_hdr_mz->addr;\n+\tresult = cvq->hdr_mz->addr;\n \treturn result;\n }\n \n@@ -126,14 +126,14 @@ virtio_send_command_split(struct virtnet_ctl *cvq,\n \t * One RX packet for ACK.\n \t */\n \tvq->vq_split.ring.desc[head].flags = VRING_DESC_F_NEXT;\n-\tvq->vq_split.ring.desc[head].addr = cvq->virtio_net_hdr_mem;\n+\tvq->vq_split.ring.desc[head].addr = cvq->hdr_mem;\n \tvq->vq_split.ring.desc[head].len = sizeof(struct virtio_net_ctrl_hdr);\n \tvq->vq_free_cnt--;\n \ti = vq->vq_split.ring.desc[head].next;\n \n \tfor (k = 0; k < pkt_num; k++) {\n \t\tvq->vq_split.ring.desc[i].flags = VRING_DESC_F_NEXT;\n-\t\tvq->vq_split.ring.desc[i].addr = cvq->virtio_net_hdr_mem\n+\t\tvq->vq_split.ring.desc[i].addr = cvq->hdr_mem\n \t\t\t+ sizeof(struct virtio_net_ctrl_hdr)\n \t\t\t+ sizeof(ctrl->status) + sizeof(uint8_t) * sum;\n \t\tvq->vq_split.ring.desc[i].len = dlen[k];\n@@ -143,7 +143,7 @@ virtio_send_command_split(struct virtnet_ctl *cvq,\n \t}\n \n \tvq->vq_split.ring.desc[i].flags = VRING_DESC_F_WRITE;\n-\tvq->vq_split.ring.desc[i].addr = cvq->virtio_net_hdr_mem\n+\tvq->vq_split.ring.desc[i].addr = cvq->hdr_mem\n \t\t\t+ sizeof(struct virtio_net_ctrl_hdr);\n \tvq->vq_split.ring.desc[i].len = sizeof(ctrl->status);\n \tvq->vq_free_cnt--;\n@@ -186,7 +186,7 @@ virtio_send_command_split(struct virtnet_ctl *cvq,\n \tPMD_INIT_LOG(DEBUG, \"vq->vq_free_cnt=%d\\nvq->vq_desc_head_idx=%d\",\n \t\t\tvq->vq_free_cnt, vq->vq_desc_head_idx);\n \n-\tresult = cvq->virtio_net_hdr_mz->addr;\n+\tresult = cvq->hdr_mz->addr;\n \treturn result;\n }\n \n@@ -216,8 +216,7 @@ virtio_send_command(struct virtnet_ctl *cvq, struct virtio_pmd_ctrl *ctrl, int *\n \t\treturn -1;\n \t}\n \n-\tmemcpy(cvq->virtio_net_hdr_mz->addr, ctrl,\n-\t\tsizeof(struct virtio_pmd_ctrl));\n+\tmemcpy(cvq->hdr_mz->addr, ctrl, sizeof(struct virtio_pmd_ctrl));\n \n \tif (virtio_with_packed_queue(vq->hw))\n \t\tresult = virtio_send_command_packed(cvq, ctrl, dlen, pkt_num);\ndiff --git a/drivers/net/virtio/virtio_cvq.h b/drivers/net/virtio/virtio_cvq.h\nindex 224dc81422..226561e6b8 100644\n--- a/drivers/net/virtio/virtio_cvq.h\n+++ b/drivers/net/virtio/virtio_cvq.h\n@@ -106,11 +106,10 @@ struct virtio_net_ctrl_hdr {\n typedef uint8_t virtio_net_ctrl_ack;\n \n struct virtnet_ctl {\n-\t/**< memzone to populate hdr. */\n-\tconst struct rte_memzone *virtio_net_hdr_mz;\n-\trte_iova_t virtio_net_hdr_mem;  /**< hdr for each xmit packet */\n-\tuint16_t port_id;               /**< Device port identifier. */\n-\tconst struct rte_memzone *mz;   /**< mem zone to populate CTL ring. */\n+\tconst struct rte_memzone *hdr_mz; /**< memzone to populate hdr. */\n+\trte_iova_t hdr_mem;               /**< hdr for each xmit packet */\n+\tuint16_t port_id;                 /**< Device port identifier. */\n+\tconst struct rte_memzone *mz;     /**< mem zone to populate CTL ring. */\n \trte_spinlock_t lock;              /**< spinlock for control queue. */\n \tvoid (*notify_queue)(struct virtqueue *vq, void *cookie); /**< notify ops. */\n \tvoid *notify_cookie;              /**< cookie for notify ops */\ndiff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c\nindex 422c597c2b..057388cfaf 100644\n--- a/drivers/net/virtio/virtio_ethdev.c\n+++ b/drivers/net/virtio/virtio_ethdev.c\n@@ -259,19 +259,97 @@ virtio_control_queue_notify(struct virtqueue *vq, __rte_unused void *cookie)\n \tvirtqueue_notify(vq);\n }\n \n+static int\n+virtio_alloc_queue_headers(struct virtqueue *vq, int numa_node, const char *name)\n+{\n+\tchar hdr_name[VIRTQUEUE_MAX_NAME_SZ];\n+\tconst struct rte_memzone **hdr_mz;\n+\trte_iova_t *hdr_mem;\n+\tssize_t size;\n+\tint queue_type;\n+\n+\tqueue_type = virtio_get_queue_type(vq->hw, vq->vq_queue_index);\n+\tswitch (queue_type) {\n+\tcase VTNET_TQ:\n+\t\t/*\n+\t\t * For each xmit packet, allocate a virtio_net_hdr\n+\t\t * and indirect ring elements\n+\t\t */\n+\t\tsize = vq->vq_nentries * sizeof(struct virtio_tx_region);\n+\t\thdr_mz = &vq->txq.hdr_mz;\n+\t\thdr_mem = &vq->txq.hdr_mem;\n+\t\tbreak;\n+\tcase VTNET_CQ:\n+\t\t/* Allocate a page for control vq command, data and status */\n+\t\tsize = rte_mem_page_size();\n+\t\thdr_mz = &vq->cq.hdr_mz;\n+\t\thdr_mem = &vq->cq.hdr_mem;\n+\t\tbreak;\n+\tcase VTNET_RQ:\n+\t\t/* fallthrough */\n+\tdefault:\n+\t\treturn 0;\n+\t}\n+\n+\tsnprintf(hdr_name, sizeof(hdr_name), \"%s_hdr\", name);\n+\t*hdr_mz = rte_memzone_reserve_aligned(hdr_name, size, numa_node,\n+\t\t\tRTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);\n+\tif (*hdr_mz == NULL) {\n+\t\tif (rte_errno == EEXIST)\n+\t\t\t*hdr_mz = rte_memzone_lookup(hdr_name);\n+\t\tif (*hdr_mz == NULL)\n+\t\t\treturn -ENOMEM;\n+\t}\n+\n+\tmemset((*hdr_mz)->addr, 0, size);\n+\n+\tif (vq->hw->use_va)\n+\t\t*hdr_mem = (uintptr_t)(*hdr_mz)->addr;\n+\telse\n+\t\t*hdr_mem = (uintptr_t)(*hdr_mz)->iova;\n+\n+\treturn 0;\n+}\n+\n+static void\n+virtio_free_queue_headers(struct virtqueue *vq)\n+{\n+\tconst struct rte_memzone **hdr_mz;\n+\trte_iova_t *hdr_mem;\n+\tint queue_type;\n+\n+\tqueue_type = virtio_get_queue_type(vq->hw, vq->vq_queue_index);\n+\tswitch (queue_type) {\n+\tcase VTNET_TQ:\n+\t\thdr_mz = &vq->txq.hdr_mz;\n+\t\thdr_mem = &vq->txq.hdr_mem;\n+\t\tbreak;\n+\tcase VTNET_CQ:\n+\t\thdr_mz = &vq->cq.hdr_mz;\n+\t\thdr_mem = &vq->cq.hdr_mem;\n+\t\tbreak;\n+\tcase VTNET_RQ:\n+\t\t/* fallthrough */\n+\tdefault:\n+\t\treturn;\n+\t}\n+\n+\trte_memzone_free(*hdr_mz);\n+\t*hdr_mz = NULL;\n+\t*hdr_mem = 0;\n+}\n+\n static int\n virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)\n {\n \tchar vq_name[VIRTQUEUE_MAX_NAME_SZ];\n-\tchar vq_hdr_name[VIRTQUEUE_MAX_NAME_SZ];\n-\tconst struct rte_memzone *mz = NULL, *hdr_mz = NULL;\n+\tconst struct rte_memzone *mz = NULL;\n \tunsigned int vq_size, size;\n \tstruct virtio_hw *hw = dev->data->dev_private;\n \tstruct virtnet_rx *rxvq = NULL;\n \tstruct virtnet_tx *txvq = NULL;\n \tstruct virtnet_ctl *cvq = NULL;\n \tstruct virtqueue *vq;\n-\tsize_t sz_hdr_mz = 0;\n \tvoid *sw_ring = NULL;\n \tint queue_type = virtio_get_queue_type(hw, queue_idx);\n \tint ret;\n@@ -297,22 +375,12 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)\n \t\treturn -EINVAL;\n \t}\n \n-\tsnprintf(vq_name, sizeof(vq_name), \"port%d_vq%d\",\n-\t\t dev->data->port_id, queue_idx);\n+\tsnprintf(vq_name, sizeof(vq_name), \"port%d_vq%d\", dev->data->port_id, queue_idx);\n \n \tsize = RTE_ALIGN_CEIL(sizeof(*vq) +\n \t\t\t\tvq_size * sizeof(struct vq_desc_extra),\n \t\t\t\tRTE_CACHE_LINE_SIZE);\n-\tif (queue_type == VTNET_TQ) {\n-\t\t/*\n-\t\t * For each xmit packet, allocate a virtio_net_hdr\n-\t\t * and indirect ring elements\n-\t\t */\n-\t\tsz_hdr_mz = vq_size * sizeof(struct virtio_tx_region);\n-\t} else if (queue_type == VTNET_CQ) {\n-\t\t/* Allocate a page for control vq command, data and status */\n-\t\tsz_hdr_mz = rte_mem_page_size();\n-\t}\n+\n \n \tvq = rte_zmalloc_socket(vq_name, size, RTE_CACHE_LINE_SIZE,\n \t\t\t\tnuma_node);\n@@ -366,20 +434,10 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)\n \n \tvirtio_init_vring(vq);\n \n-\tif (sz_hdr_mz) {\n-\t\tsnprintf(vq_hdr_name, sizeof(vq_hdr_name), \"port%d_vq%d_hdr\",\n-\t\t\t dev->data->port_id, queue_idx);\n-\t\thdr_mz = rte_memzone_reserve_aligned(vq_hdr_name, sz_hdr_mz,\n-\t\t\t\tnuma_node, RTE_MEMZONE_IOVA_CONTIG,\n-\t\t\t\tRTE_CACHE_LINE_SIZE);\n-\t\tif (hdr_mz == NULL) {\n-\t\t\tif (rte_errno == EEXIST)\n-\t\t\t\thdr_mz = rte_memzone_lookup(vq_hdr_name);\n-\t\t\tif (hdr_mz == NULL) {\n-\t\t\t\tret = -ENOMEM;\n-\t\t\t\tgoto free_mz;\n-\t\t\t}\n-\t\t}\n+\tret = virtio_alloc_queue_headers(vq, numa_node, vq_name);\n+\tif (ret) {\n+\t\tPMD_INIT_LOG(ERR, \"Failed to alloc queue headers\");\n+\t\tgoto free_mz;\n \t}\n \n \tif (queue_type == VTNET_RQ) {\n@@ -411,21 +469,9 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)\n \t\ttxvq = &vq->txq;\n \t\ttxvq->port_id = dev->data->port_id;\n \t\ttxvq->mz = mz;\n-\t\ttxvq->virtio_net_hdr_mz = hdr_mz;\n-\t\tif (hw->use_va)\n-\t\t\ttxvq->virtio_net_hdr_mem = (uintptr_t)hdr_mz->addr;\n-\t\telse\n-\t\t\ttxvq->virtio_net_hdr_mem = hdr_mz->iova;\n \t} else if (queue_type == VTNET_CQ) {\n \t\tcvq = &vq->cq;\n \t\tcvq->mz = mz;\n-\t\tcvq->virtio_net_hdr_mz = hdr_mz;\n-\t\tif (hw->use_va)\n-\t\t\tcvq->virtio_net_hdr_mem = (uintptr_t)hdr_mz->addr;\n-\t\telse\n-\t\t\tcvq->virtio_net_hdr_mem = hdr_mz->iova;\n-\t\tmemset(cvq->virtio_net_hdr_mz->addr, 0, rte_mem_page_size());\n-\n \t\thw->cvq = cvq;\n \t\tvq->cq.notify_queue = &virtio_control_queue_notify;\n \t}\n@@ -439,18 +485,15 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)\n \t\tstruct virtio_tx_region *txr;\n \t\tunsigned int i;\n \n-\t\ttxr = hdr_mz->addr;\n-\t\tmemset(txr, 0, vq_size * sizeof(*txr));\n+\t\ttxr = txvq->hdr_mz->addr;\n \t\tfor (i = 0; i < vq_size; i++) {\n \t\t\t/* first indirect descriptor is always the tx header */\n \t\t\tif (!virtio_with_packed_queue(hw)) {\n \t\t\t\tstruct vring_desc *start_dp = txr[i].tx_indir;\n \t\t\t\tvring_desc_init_split(start_dp,\n \t\t\t\t\t\t      RTE_DIM(txr[i].tx_indir));\n-\t\t\t\tstart_dp->addr = txvq->virtio_net_hdr_mem\n-\t\t\t\t\t+ i * sizeof(*txr)\n-\t\t\t\t\t+ offsetof(struct virtio_tx_region,\n-\t\t\t\t\t\t   tx_hdr);\n+\t\t\t\tstart_dp->addr = txvq->hdr_mem + i * sizeof(*txr)\n+\t\t\t\t\t+ offsetof(struct virtio_tx_region, tx_hdr);\n \t\t\t\tstart_dp->len = hw->vtnet_hdr_size;\n \t\t\t\tstart_dp->flags = VRING_DESC_F_NEXT;\n \t\t\t} else {\n@@ -458,10 +501,8 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)\n \t\t\t\t\ttxr[i].tx_packed_indir;\n \t\t\t\tvring_desc_init_indirect_packed(start_dp,\n \t\t\t\t      RTE_DIM(txr[i].tx_packed_indir));\n-\t\t\t\tstart_dp->addr = txvq->virtio_net_hdr_mem\n-\t\t\t\t\t+ i * sizeof(*txr)\n-\t\t\t\t\t+ offsetof(struct virtio_tx_region,\n-\t\t\t\t\t\t   tx_hdr);\n+\t\t\t\tstart_dp->addr = txvq->hdr_mem + i * sizeof(*txr)\n+\t\t\t\t\t+ offsetof(struct virtio_tx_region, tx_hdr);\n \t\t\t\tstart_dp->len = hw->vtnet_hdr_size;\n \t\t\t}\n \t\t}\n@@ -481,7 +522,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)\n free_sw_ring:\n \trte_free(sw_ring);\n free_hdr_mz:\n-\trte_memzone_free(hdr_mz);\n+\tvirtio_free_queue_headers(vq);\n free_mz:\n \trte_memzone_free(mz);\n free_vq:\n@@ -514,12 +555,12 @@ virtio_free_queues(struct virtio_hw *hw)\n \t\t\trte_memzone_free(vq->rxq.mz);\n \t\t} else if (queue_type == VTNET_TQ) {\n \t\t\trte_memzone_free(vq->txq.mz);\n-\t\t\trte_memzone_free(vq->txq.virtio_net_hdr_mz);\n \t\t} else {\n \t\t\trte_memzone_free(vq->cq.mz);\n-\t\t\trte_memzone_free(vq->cq.virtio_net_hdr_mz);\n \t\t}\n \n+\t\tvirtio_free_queue_headers(vq);\n+\n \t\trte_free(vq);\n \t\thw->vqs[i] = NULL;\n \t}\ndiff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c\nindex d9d40832e0..bd95e8ceb5 100644\n--- a/drivers/net/virtio/virtio_rxtx.c\n+++ b/drivers/net/virtio/virtio_rxtx.c\n@@ -542,7 +542,7 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie,\n \t\t\tuint16_t needed, int use_indirect, int can_push,\n \t\t\tint in_order)\n {\n-\tstruct virtio_tx_region *txr = txvq->virtio_net_hdr_mz->addr;\n+\tstruct virtio_tx_region *txr = txvq->hdr_mz->addr;\n \tstruct vq_desc_extra *dxp;\n \tstruct virtqueue *vq = virtnet_txq_to_vq(txvq);\n \tstruct vring_desc *start_dp;\n@@ -579,9 +579,8 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie,\n \t\t * the first slot in indirect ring is already preset\n \t\t * to point to the header in reserved region\n \t\t */\n-\t\tstart_dp[idx].addr  = txvq->virtio_net_hdr_mem +\n-\t\t\tRTE_PTR_DIFF(&txr[idx].tx_indir, txr);\n-\t\tstart_dp[idx].len   = (seg_num + 1) * sizeof(struct vring_desc);\n+\t\tstart_dp[idx].addr = txvq->hdr_mem + RTE_PTR_DIFF(&txr[idx].tx_indir, txr);\n+\t\tstart_dp[idx].len = (seg_num + 1) * sizeof(struct vring_desc);\n \t\tstart_dp[idx].flags = VRING_DESC_F_INDIRECT;\n \t\thdr = (struct virtio_net_hdr *)&txr[idx].tx_hdr;\n \n@@ -592,9 +591,8 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie,\n \t\t/* setup first tx ring slot to point to header\n \t\t * stored in reserved region.\n \t\t */\n-\t\tstart_dp[idx].addr  = txvq->virtio_net_hdr_mem +\n-\t\t\tRTE_PTR_DIFF(&txr[idx].tx_hdr, txr);\n-\t\tstart_dp[idx].len   = vq->hw->vtnet_hdr_size;\n+\t\tstart_dp[idx].addr = txvq->hdr_mem + RTE_PTR_DIFF(&txr[idx].tx_hdr, txr);\n+\t\tstart_dp[idx].len = vq->hw->vtnet_hdr_size;\n \t\tstart_dp[idx].flags = VRING_DESC_F_NEXT;\n \t\thdr = (struct virtio_net_hdr *)&txr[idx].tx_hdr;\n \ndiff --git a/drivers/net/virtio/virtio_rxtx.h b/drivers/net/virtio/virtio_rxtx.h\nindex 6ee3a13100..226c722d64 100644\n--- a/drivers/net/virtio/virtio_rxtx.h\n+++ b/drivers/net/virtio/virtio_rxtx.h\n@@ -33,15 +33,13 @@ struct virtnet_rx {\n };\n \n struct virtnet_tx {\n-\t/**< memzone to populate hdr. */\n-\tconst struct rte_memzone *virtio_net_hdr_mz;\n-\trte_iova_t virtio_net_hdr_mem;   /**< hdr for each xmit packet */\n+\tconst struct rte_memzone *hdr_mz; /**< memzone to populate hdr. */\n+\trte_iova_t hdr_mem;               /**< hdr for each xmit packet */\n \n-\tuint16_t    queue_id;            /**< DPDK queue index. */\n-\tuint16_t    port_id;             /**< Device port identifier. */\n+\tuint16_t    queue_id;             /**< DPDK queue index. */\n+\tuint16_t    port_id;              /**< Device port identifier. */\n \n-\t/* Statistics */\n-\tstruct virtnet_stats stats;\n+\tstruct virtnet_stats stats;       /* Statistics */\n \n \tconst struct rte_memzone *mz;    /**< mem zone to populate TX ring. */\n };\ndiff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c\nindex c98d696e62..3b174a5923 100644\n--- a/drivers/net/virtio/virtqueue.c\n+++ b/drivers/net/virtio/virtqueue.c\n@@ -200,10 +200,9 @@ virtqueue_txvq_reset_packed(struct virtqueue *vq)\n \tvq->vq_packed.event_flags_shadow = 0;\n \n \ttxvq = &vq->txq;\n-\ttxr = txvq->virtio_net_hdr_mz->addr;\n+\ttxr = txvq->hdr_mz->addr;\n \tmemset(txvq->mz->addr, 0, txvq->mz->len);\n-\tmemset(txvq->virtio_net_hdr_mz->addr, 0,\n-\t\ttxvq->virtio_net_hdr_mz->len);\n+\tmemset(txvq->hdr_mz->addr, 0, txvq->hdr_mz->len);\n \n \tfor (desc_idx = 0; desc_idx < vq->vq_nentries; desc_idx++) {\n \t\tdxp = &vq->vq_descx[desc_idx];\n@@ -217,8 +216,7 @@ virtqueue_txvq_reset_packed(struct virtqueue *vq)\n \t\t\tstart_dp = txr[desc_idx].tx_packed_indir;\n \t\t\tvring_desc_init_indirect_packed(start_dp,\n \t\t\t\t\t\t\tRTE_DIM(txr[desc_idx].tx_packed_indir));\n-\t\t\tstart_dp->addr = txvq->virtio_net_hdr_mem\n-\t\t\t\t\t + desc_idx * sizeof(*txr)\n+\t\t\tstart_dp->addr = txvq->hdr_mem + desc_idx * sizeof(*txr)\n \t\t\t\t\t + offsetof(struct virtio_tx_region, tx_hdr);\n \t\t\tstart_dp->len = vq->hw->vtnet_hdr_size;\n \t\t}\ndiff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h\nindex 62f472850e..f5058f362c 100644\n--- a/drivers/net/virtio/virtqueue.h\n+++ b/drivers/net/virtio/virtqueue.h\n@@ -604,7 +604,7 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie,\n \t\t\t      uint16_t needed, int use_indirect, int can_push,\n \t\t\t      int in_order)\n {\n-\tstruct virtio_tx_region *txr = txvq->virtio_net_hdr_mz->addr;\n+\tstruct virtio_tx_region *txr = txvq->hdr_mz->addr;\n \tstruct vq_desc_extra *dxp;\n \tstruct virtqueue *vq = virtnet_txq_to_vq(txvq);\n \tstruct vring_packed_desc *start_dp, *head_dp;\n@@ -646,10 +646,8 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie,\n \t\t * the first slot in indirect ring is already preset\n \t\t * to point to the header in reserved region\n \t\t */\n-\t\tstart_dp[idx].addr  = txvq->virtio_net_hdr_mem +\n-\t\t\tRTE_PTR_DIFF(&txr[idx].tx_packed_indir, txr);\n-\t\tstart_dp[idx].len   = (seg_num + 1) *\n-\t\t\tsizeof(struct vring_packed_desc);\n+\t\tstart_dp[idx].addr = txvq->hdr_mem + RTE_PTR_DIFF(&txr[idx].tx_packed_indir, txr);\n+\t\tstart_dp[idx].len = (seg_num + 1) * sizeof(struct vring_packed_desc);\n \t\t/* Packed descriptor id needs to be restored when inorder. */\n \t\tif (in_order)\n \t\t\tstart_dp[idx].id = idx;\n@@ -665,9 +663,8 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie,\n \t\t/* setup first tx ring slot to point to header\n \t\t * stored in reserved region.\n \t\t */\n-\t\tstart_dp[idx].addr  = txvq->virtio_net_hdr_mem +\n-\t\t\tRTE_PTR_DIFF(&txr[idx].tx_hdr, txr);\n-\t\tstart_dp[idx].len   = vq->hw->vtnet_hdr_size;\n+\t\tstart_dp[idx].addr = txvq->hdr_mem + RTE_PTR_DIFF(&txr[idx].tx_hdr, txr);\n+\t\tstart_dp[idx].len = vq->hw->vtnet_hdr_size;\n \t\thdr = (struct virtio_net_hdr *)&txr[idx].tx_hdr;\n \t\tidx++;\n \t\tif (idx >= vq->vq_nentries) {\n",
    "prefixes": [
        "v2",
        "03/21"
    ]
}