Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/8385/?format=api
http://patches.dpdk.org/api/patches/8385/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1446210034-13750-8-git-send-email-jijiang.liu@intel.com/", "project": { "id": 1, "url": "http://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": "<1446210034-13750-8-git-send-email-jijiang.liu@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1446210034-13750-8-git-send-email-jijiang.liu@intel.com", "date": "2015-10-30T13:00:32", "name": "[dpdk-dev,v2,7/9] lib/librte_vhost:dequeue vhost TX offload", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "78a81addc51d679f4937f637f1f7bed55b5e9939", "submitter": { "id": 52, "url": "http://patches.dpdk.org/api/people/52/?format=api", "name": "Jijiang Liu", "email": "jijiang.liu@intel.com" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dpdk/patch/1446210034-13750-8-git-send-email-jijiang.liu@intel.com/mbox/", "series": [], "comments": "http://patches.dpdk.org/api/patches/8385/comments/", "check": "pending", "checks": "http://patches.dpdk.org/api/patches/8385/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 2B06091A0;\n\tFri, 30 Oct 2015 14:01:04 +0100 (CET)", "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id E87D18F9D\n\tfor <dev@dpdk.org>; Fri, 30 Oct 2015 14:01:00 +0100 (CET)", "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga103.fm.intel.com with ESMTP; 30 Oct 2015 06:01:00 -0700", "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby fmsmga001.fm.intel.com with ESMTP; 30 Oct 2015 06:00:59 -0700", "from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com\n\t[10.239.29.89])\n\tby shvmail01.sh.intel.com with ESMTP id t9UD0sSG023076;\n\tFri, 30 Oct 2015 21:00:54 +0800", "from shecgisg004.sh.intel.com (localhost [127.0.0.1])\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP\n\tid t9UD0pqw013834; Fri, 30 Oct 2015 21:00:53 +0800", "(from jijiangl@localhost)\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t9UD0pD8013830; \n\tFri, 30 Oct 2015 21:00:51 +0800" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.20,218,1444719600\"; d=\"scan'208\";a=\"823125086\"", "From": "Jijiang Liu <jijiang.liu@intel.com>", "To": "dev@dpdk.org", "Date": "Fri, 30 Oct 2015 21:00:32 +0800", "Message-Id": "<1446210034-13750-8-git-send-email-jijiang.liu@intel.com>", "X-Mailer": "git-send-email 1.7.12.2", "In-Reply-To": "<1446210034-13750-1-git-send-email-jijiang.liu@intel.com>", "References": "<1446210034-13750-1-git-send-email-jijiang.liu@intel.com>", "Subject": "[dpdk-dev] [PATCH v2 7/9] lib/librte_vhost:dequeue vhost TX offload", "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": "Dequeue vhost TX offload in vhost lib.\n\nSigned-off-by: Jijiang Liu <jijiang.liu@intel.com>\n---\n lib/librte_vhost/vhost_rxtx.c | 108 ++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 107 insertions(+), 1 deletions(-)", "diff": "diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c\nindex 7026bfa..a888ba9 100644\n--- a/lib/librte_vhost/vhost_rxtx.c\n+++ b/lib/librte_vhost/vhost_rxtx.c\n@@ -36,7 +36,12 @@\n \n #include <rte_mbuf.h>\n #include <rte_memcpy.h>\n+#include <rte_ether.h>\n+#include <rte_ip.h>\n #include <rte_virtio_net.h>\n+#include <rte_tcp.h>\n+#include <rte_udp.h>\n+#include <rte_sctp.h>\n \n #include \"vhost-net.h\"\n \n@@ -548,6 +553,101 @@ rte_vhost_enqueue_burst(struct virtio_net *dev, uint16_t queue_id,\n \t\treturn virtio_dev_rx(dev, queue_id, pkts, count);\n }\n \n+static void\n+parse_ethernet(struct rte_mbuf *m, uint16_t *l4_proto, void **l4_hdr)\n+{\n+\tstruct ipv4_hdr *ipv4_hdr;\n+\tstruct ipv6_hdr *ipv6_hdr;\n+\tvoid *l3_hdr = NULL;\n+\tstruct ether_hdr *eth_hdr;\n+\tuint16_t ethertype;\n+\n+\teth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);\n+\n+\tm->l2_len = sizeof(struct ether_hdr);\n+\tethertype = rte_be_to_cpu_16(eth_hdr->ether_type);\n+\n+\tif (ethertype == ETHER_TYPE_VLAN) {\n+\t\tstruct vlan_hdr *vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1);\n+\n+\t\tm->l2_len += sizeof(struct vlan_hdr);\n+\t\tethertype = rte_be_to_cpu_16(vlan_hdr->eth_proto);\n+\t}\n+\n+\tl3_hdr = (char *)eth_hdr + m->l2_len;\n+\n+\tswitch (ethertype) {\n+\tcase ETHER_TYPE_IPv4:\n+\t\tipv4_hdr = (struct ipv4_hdr *)l3_hdr;\n+\t\t*l4_proto = ipv4_hdr->next_proto_id;\n+\t\tm->l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4;\n+\t\t*l4_hdr = (char *)l3_hdr + m->l3_len;\n+\t\tm->ol_flags |= PKT_TX_IPV4;\n+\t\tbreak;\n+\tcase ETHER_TYPE_IPv6:\n+\t\tipv6_hdr = (struct ipv6_hdr *)l3_hdr;\n+\t\t*l4_proto = ipv6_hdr->proto;\n+\t\tm->ol_flags |= PKT_TX_IPV6;\n+\t\tm->l3_len = sizeof(struct ipv6_hdr);\n+\t\t*l4_hdr = (char *)l3_hdr + m->l3_len;\n+\t\tbreak;\n+\tdefault:\n+\t\tm->l3_len = 0;\n+\t\t*l4_proto = 0;\n+\t\tbreak;\n+\t}\n+}\n+\n+static inline void __attribute__((always_inline))\n+vhost_dequeue_offload(struct virtio_net_hdr *hdr, struct rte_mbuf *m)\n+{\n+\tuint16_t l4_proto = 0;\n+\tvoid *l4_hdr = NULL;\n+\tstruct tcp_hdr *tcp_hdr = NULL;\n+\n+\tparse_ethernet(m, &l4_proto, &l4_hdr);\n+\tif (hdr->flags == VIRTIO_NET_HDR_F_NEEDS_CSUM) {\n+\t\tif ((hdr->csum_start == m->l2_len) &&\n+\t\t\t(hdr->csum_offset == offsetof(struct ipv4_hdr,\n+\t\t\t\t\t\thdr_checksum)))\n+\t\t\tm->ol_flags |= PKT_TX_IP_CKSUM;\n+\t\telse if (hdr->csum_start == (m->l2_len + m->l3_len)) {\n+\t\t\tswitch (hdr->csum_offset) {\n+\t\t\tcase (offsetof(struct tcp_hdr, cksum)):\n+\t\t\t\tif (l4_proto == IPPROTO_TCP)\n+\t\t\t\t\tm->ol_flags |= PKT_TX_TCP_CKSUM;\n+\t\t\t\tbreak;\n+\t\t\tcase (offsetof(struct udp_hdr, dgram_cksum)):\n+\t\t\t\tif (l4_proto == IPPROTO_UDP)\n+\t\t\t\t\tm->ol_flags |= PKT_TX_UDP_CKSUM;\n+\t\t\t\tbreak;\n+\t\t\tcase (offsetof(struct sctp_hdr, cksum)):\n+\t\t\t\tif (l4_proto == IPPROTO_SCTP)\n+\t\t\t\t\tm->ol_flags |= PKT_TX_SCTP_CKSUM;\n+\t\t\t\tbreak;\n+\t\t\tdefault:\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\tif (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {\n+\t\tswitch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {\n+\t\tcase VIRTIO_NET_HDR_GSO_TCPV4:\n+\t\tcase VIRTIO_NET_HDR_GSO_TCPV6:\n+\t\t\ttcp_hdr = (struct tcp_hdr *)l4_hdr;\n+\t\t\tm->ol_flags |= PKT_TX_TCP_SEG;\n+\t\t\tm->tso_segsz = hdr->gso_size;\n+\t\t\tm->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tRTE_LOG(WARNING, VHOST_DATA,\n+\t\t\t\t\"unsupported gso type %u.\\n\", hdr->gso_type);\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+}\n+\n uint16_t\n rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,\n \tstruct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count)\n@@ -556,11 +656,13 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,\n \tstruct vhost_virtqueue *vq;\n \tstruct vring_desc *desc;\n \tuint64_t vb_addr = 0;\n+\tuint64_t vb_net_hdr_addr = 0;\n \tuint32_t head[MAX_PKT_BURST];\n \tuint32_t used_idx;\n \tuint32_t i;\n \tuint16_t free_entries, entry_success = 0;\n \tuint16_t avail_idx;\n+\tstruct virtio_net_hdr *hdr = NULL;\n \n \tif (unlikely(queue_id != VIRTIO_TXQ)) {\n \t\tLOG_DEBUG(VHOST_DATA, \"mq isn't supported in this version.\\n\");\n@@ -607,6 +709,9 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,\n \n \t\tdesc = &vq->desc[head[entry_success]];\n \n+\t\tvb_net_hdr_addr = gpa_to_vva(dev, desc->addr);\n+\t\thdr = (struct virtio_net_hdr *)((uintptr_t)vb_net_hdr_addr);\n+\n \t\t/* Discard first buffer as it is the virtio header */\n \t\tif (desc->flags & VRING_DESC_F_NEXT) {\n \t\t\tdesc = &vq->desc[desc->next];\n@@ -745,7 +850,8 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,\n \t\t\tbreak;\n \n \t\tm->nb_segs = seg_num;\n-\n+\t\tif ((hdr->flags != 0) || (hdr->gso_type != 0))\n+\t\t\tvhost_dequeue_offload(hdr, m);\n \t\tpkts[entry_success] = m;\n \t\tvq->last_used_idx++;\n \t\tentry_success++;\n", "prefixes": [ "dpdk-dev", "v2", "7/9" ] }{ "id": 8385, "url": "