DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jijiang Liu <jijiang.liu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 7/8] examples/vhost:support TSO in vhost sample
Date: Thu, 17 Sep 2015 01:10:37 +0800	[thread overview]
Message-ID: <1442423438-10578-8-git-send-email-jijiang.liu@intel.com> (raw)
In-Reply-To: <1442423438-10578-1-git-send-email-jijiang.liu@intel.com>

Change the vhost sample in order to support and test TSO offload.

Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
---
 examples/vhost/main.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 1b137b9..482f7af 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -50,6 +50,7 @@
 #include <rte_string_fns.h>
 #include <rte_malloc.h>
 #include <rte_virtio_net.h>
+#include <rte_tcp.h>
 
 #include "main.h"
 
@@ -441,6 +442,9 @@ port_init(uint8_t port)
 
 	if (port >= rte_eth_dev_count()) return -1;
 
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO)
+		rte_vhost_feature_enable(1ULL << VIRTIO_NET_F_HOST_TSO4);
+
 	rx_rings = (uint16_t)dev_info.max_rx_queues;
 	/* Configure ethernet device. */
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
@@ -1148,6 +1152,13 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)
 	len = tx_q->len;
 
 	nh = rte_pktmbuf_mtod(m, struct ether_hdr *);
+	m->l2_len = sizeof(struct ether_hdr);
+	m->l3_len = sizeof(struct ipv4_hdr);
+	if (m->tso_segsz) {
+		m->l4_len = sizeof(struct tcp_hdr);
+		m->ol_flags |= PKT_TX_IP_CKSUM;
+	}
+
 	if (unlikely(nh->ether_type == rte_cpu_to_be_16(ETHER_TYPE_VLAN))) {
 		/* Guest has inserted the vlan tag. */
 		struct vlan_hdr *vh = (struct vlan_hdr *) (nh + 1);
@@ -1155,8 +1166,9 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)
 		if ((vm2vm_mode == VM2VM_HARDWARE) &&
 			(vh->vlan_tci != vlan_tag_be))
 			vh->vlan_tci = vlan_tag_be;
+		m->l2_len += sizeof(struct vlan_hdr);
 	} else {
-		m->ol_flags = PKT_TX_VLAN_PKT;
+		m->ol_flags |= PKT_TX_VLAN_PKT;
 
 		/*
 		 * Find the right seg to adjust the data len when offset is
@@ -1841,10 +1853,14 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,
 		mbuf->buf_physaddr = m->buf_physaddr;
 		mbuf->buf_addr = m->buf_addr;
 	}
-	mbuf->ol_flags = PKT_TX_VLAN_PKT;
+	mbuf->ol_flags |= PKT_TX_VLAN_PKT;
 	mbuf->vlan_tci = vlan_tag;
 	mbuf->l2_len = sizeof(struct ether_hdr);
 	mbuf->l3_len = sizeof(struct ipv4_hdr);
+	if (mbuf->tso_segsz) {
+		mbuf->l4_len = sizeof(struct tcp_hdr);
+		mbuf->ol_flags |= PKT_TX_IP_CKSUM;
+	}
 	MBUF_HEADROOM_UINT32(mbuf) = (uint32_t)desc_idx;
 
 	tx_q->m_table[len] = mbuf;
-- 
1.7.7.6

  parent reply	other threads:[~2015-09-16 17:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16 17:10 [dpdk-dev] [PATCH 0/8] add vhost TSO capability Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 1/8] driver/virtio:add vhost TSO support capability Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 2/8] driver/virtio:add virtual addr for virtio net header Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 3/8] driver/virtio: record virtual address of " Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 4/8] driver/virtio:enqueue TSO offload Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 5/8] lib/librte_vhost:dequeue vhost " Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 6/8] lib/librte_vhost:extend supported vhost features Jijiang Liu
2015-09-16 17:10 ` Jijiang Liu [this message]
2015-09-16 17:10 ` [dpdk-dev] [PATCH 8/8] app/testpmd: modify the mac of csum forwarding Jijiang Liu
2015-10-26  7:09 ` [dpdk-dev] [PATCH 0/8] add vhost TSO capability Tan, Jianfeng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1442423438-10578-8-git-send-email-jijiang.liu@intel.com \
    --to=jijiang.liu@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).