Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/16945/?format=api
http://patchwork.dpdk.org/api/patches/16945/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1478338865-26126-4-git-send-email-yuanhan.liu@linux.intel.com/", "project": { "id": 1, "url": "http://patchwork.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": "<1478338865-26126-4-git-send-email-yuanhan.liu@linux.intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1478338865-26126-4-git-send-email-yuanhan.liu@linux.intel.com", "date": "2016-11-05T09:40:58", "name": "[dpdk-dev,v2,03/10] net/virtio: simplify queue allocation", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "920f04c5e9159e55a3402272cd524fd8f31a960a", "submitter": { "id": 307, "url": "http://patchwork.dpdk.org/api/people/307/?format=api", "name": "Yuanhan Liu", "email": "yuanhan.liu@linux.intel.com" }, "delegate": null, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1478338865-26126-4-git-send-email-yuanhan.liu@linux.intel.com/mbox/", "series": [], "comments": "http://patchwork.dpdk.org/api/patches/16945/comments/", "check": "success", "checks": "http://patchwork.dpdk.org/api/patches/16945/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 5522E376D;\n\tSat, 5 Nov 2016 10:41:04 +0100 (CET)", "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby dpdk.org (Postfix) with ESMTP id A9AEC137C\n\tfor <dev@dpdk.org>; Sat, 5 Nov 2016 10:40:20 +0100 (CET)", "from fmsmga004.fm.intel.com ([10.253.24.48])\n\tby orsmga102.jf.intel.com with ESMTP; 05 Nov 2016 02:40:20 -0700", "from yliu-dev.sh.intel.com ([10.239.67.162])\n\tby fmsmga004.fm.intel.com with ESMTP; 05 Nov 2016 02:40:18 -0700" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.31,448,1473145200\"; d=\"scan'208\";a=\"187945090\"", "From": "Yuanhan Liu <yuanhan.liu@linux.intel.com>", "To": "dev@dpdk.org", "Cc": "Thomas Monjalon <thomas.monjalon@6wind.com>,\n\tTan Jianfeng <jianfeng.tan@intel.com>,\n\tKevin Traynor <ktraynor@redhat.com>, \n\tIlya Maximets <i.maximets@samsung.com>,\n\tKyle Larose <klarose@sandvine.com>, \n\tMaxime Coquelin <maxime.coquelin@redhat.com>,\n\tYuanhan Liu <yuanhan.liu@linux.intel.com>", "Date": "Sat, 5 Nov 2016 17:40:58 +0800", "Message-Id": "<1478338865-26126-4-git-send-email-yuanhan.liu@linux.intel.com>", "X-Mailer": "git-send-email 1.9.0", "In-Reply-To": "<1478338865-26126-1-git-send-email-yuanhan.liu@linux.intel.com>", "References": "<1478189400-14606-1-git-send-email-yuanhan.liu@linux.intel.com>\n\t<1478338865-26126-1-git-send-email-yuanhan.liu@linux.intel.com>", "Subject": "[dpdk-dev] [PATCH v2 03/10] net/virtio: simplify queue allocation", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Let rxq/txq/cq be the union field of the virtqueue struct. This would\nsimplifies the vq allocation a bit: we don't need calculate the vq_size\nany more based on the queue type.\n\nSigned-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>\nReviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n drivers/net/virtio/virtio_ethdev.c | 18 +++++++-----------\n drivers/net/virtio/virtqueue.h | 7 +++++++\n 2 files changed, 14 insertions(+), 11 deletions(-)", "diff": "diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c\nindex d082df5..5a2c14b 100644\n--- a/drivers/net/virtio/virtio_ethdev.c\n+++ b/drivers/net/virtio/virtio_ethdev.c\n@@ -312,7 +312,7 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,\n \tstruct virtnet_tx *txvq = NULL;\n \tstruct virtnet_ctl *cvq = NULL;\n \tstruct virtqueue *vq;\n-\tsize_t sz_vq, sz_q = 0, sz_hdr_mz = 0;\n+\tsize_t sz_hdr_mz = 0;\n \tvoid *sw_ring = NULL;\n \tint ret;\n \n@@ -337,25 +337,21 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,\n \tsnprintf(vq_name, sizeof(vq_name), \"port%d_vq%d\",\n \t\t dev->data->port_id, vtpci_queue_idx);\n \n-\tsz_vq = RTE_ALIGN_CEIL(sizeof(*vq) +\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_RQ) {\n-\t\tsz_q = sz_vq + sizeof(*rxvq);\n-\t} else if (queue_type == VTNET_TQ) {\n-\t\tsz_q = sz_vq + sizeof(*txvq);\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\tsz_q = sz_vq + sizeof(*cvq);\n \t\t/* Allocate a page for control vq command, data and status */\n \t\tsz_hdr_mz = PAGE_SIZE;\n \t}\n \n-\tvq = rte_zmalloc_socket(vq_name, sz_q, RTE_CACHE_LINE_SIZE, socket_id);\n+\tvq = rte_zmalloc_socket(vq_name, size, RTE_CACHE_LINE_SIZE, socket_id);\n \tif (vq == NULL) {\n \t\tPMD_INIT_LOG(ERR, \"can not allocate vq\");\n \t\treturn -ENOMEM;\n@@ -425,14 +421,14 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,\n \t\t}\n \n \t\tvq->sw_ring = sw_ring;\n-\t\trxvq = (struct virtnet_rx *)RTE_PTR_ADD(vq, sz_vq);\n+\t\trxvq = &vq->rxq;\n \t\trxvq->vq = vq;\n \t\trxvq->port_id = dev->data->port_id;\n \t\trxvq->queue_id = queue_idx;\n \t\trxvq->mz = mz;\n \t\t*pvq = rxvq;\n \t} else if (queue_type == VTNET_TQ) {\n-\t\ttxvq = (struct virtnet_tx *)RTE_PTR_ADD(vq, sz_vq);\n+\t\ttxvq = &vq->txq;\n \t\ttxvq->vq = vq;\n \t\ttxvq->port_id = dev->data->port_id;\n \t\ttxvq->queue_id = queue_idx;\n@@ -442,7 +438,7 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,\n \n \t\t*pvq = txvq;\n \t} else if (queue_type == VTNET_CQ) {\n-\t\tcvq = (struct virtnet_ctl *)RTE_PTR_ADD(vq, sz_vq);\n+\t\tcvq = &vq->cq;\n \t\tcvq->vq = vq;\n \t\tcvq->mz = mz;\n \t\tcvq->virtio_net_hdr_mz = hdr_mz;\ndiff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h\nindex ef0027b..bbeb2f2 100644\n--- a/drivers/net/virtio/virtqueue.h\n+++ b/drivers/net/virtio/virtqueue.h\n@@ -44,6 +44,7 @@\n #include \"virtio_pci.h\"\n #include \"virtio_ring.h\"\n #include \"virtio_logs.h\"\n+#include \"virtio_rxtx.h\"\n \n struct rte_mbuf;\n \n@@ -191,6 +192,12 @@ struct virtqueue {\n \tvoid *vq_ring_virt_mem; /**< linear address of vring*/\n \tunsigned int vq_ring_size;\n \n+\tunion {\n+\t\tstruct virtnet_rx rxq;\n+\t\tstruct virtnet_tx txq;\n+\t\tstruct virtnet_ctl cq;\n+\t};\n+\n \tphys_addr_t vq_ring_mem; /**< physical address of vring,\n \t\t\t\t * or virtual address for virtio_user. */\n \n", "prefixes": [ "dpdk-dev", "v2", "03/10" ] }{ "id": 16945, "url": "