DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC PATCH 0/8] Add vhost TSO capability
@ 2015-08-31  9:41 Jijiang Liu
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 1/8] driver/virtio:add vhost TSO support capability Jijiang Liu
                   ` (7 more replies)
  0 siblings, 8 replies; 16+ messages in thread
From: Jijiang Liu @ 2015-08-31  9:41 UTC (permalink / raw)
  To: dev

The patch set add the negotiation between us-vhost and virtio-net for vhost TSO feature, and enqueue/dequeue vhost TSO offload, and change vhost sample and csum application to test these.


Jijiang Liu (8):
  add host TSO support in virtio_ethdev.h file
  add virtual addr for virtio net header in struct virtqueue.
  record the virtual addr for virtio net header
  enqueue TSO offload in virtio-net
  extend VHOST_SUPPORTED_FEATURES list for TSO support
  add TSO offload dequeue
  TSO support in vhost sample 
  fix an issue in csum file.

 app/test-pmd/csumonly.c            |    6 ++++++
 drivers/net/virtio/virtio_ethdev.c |    3 +++
 drivers/net/virtio/virtio_ethdev.h |    4 +++-
 drivers/net/virtio/virtio_rxtx.c   |   23 +++++++++++++++++++++++
 drivers/net/virtio/virtqueue.h     |    1 +
 examples/vhost/main.c              |   20 ++++++++++++++++++--
 lib/librte_vhost/vhost_rxtx.c      |   29 ++++++++++++++++++++++++++++-
 lib/librte_vhost/virtio-net.c      |    5 ++++-
 8 files changed, 86 insertions(+), 5 deletions(-)

-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [dpdk-dev] [RFC PATCH 1/8] driver/virtio:add vhost TSO support capability
  2015-08-31  9:41 [dpdk-dev] [RFC PATCH 0/8] Add vhost TSO capability Jijiang Liu
@ 2015-08-31  9:41 ` Jijiang Liu
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 2/8] driver/virtio: add virtual addr for virtio net header Jijiang Liu
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Jijiang Liu @ 2015-08-31  9:41 UTC (permalink / raw)
  To: dev

Extend the VIRTIO_PMD_GUEST_FEATURES for supporting vhost TSO.

Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
---
 drivers/net/virtio/virtio_ethdev.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h
index 9026d42..3a66491 100644
--- a/drivers/net/virtio/virtio_ethdev.h
+++ b/drivers/net/virtio/virtio_ethdev.h
@@ -64,7 +64,9 @@
 	 1u << VIRTIO_NET_F_CTRL_VQ	  |	\
 	 1u << VIRTIO_NET_F_CTRL_RX	  |	\
 	 1u << VIRTIO_NET_F_CTRL_VLAN	  |	\
-	 1u << VIRTIO_NET_F_MRG_RXBUF)
+	 1u << VIRTIO_NET_F_MRG_RXBUF     |     \
+	 1u << VIRTIO_NET_F_HOST_TSO4     |     \
+	 1u << VIRTIO_NET_F_HOST_TSO6)
 
 /*
  * CQ function prototype
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [dpdk-dev] [RFC PATCH 2/8] driver/virtio: add virtual addr for virtio net header
  2015-08-31  9:41 [dpdk-dev] [RFC PATCH 0/8] Add vhost TSO capability Jijiang Liu
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 1/8] driver/virtio:add vhost TSO support capability Jijiang Liu
@ 2015-08-31  9:41 ` Jijiang Liu
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 3/8] driver/virtio: record virtual address of " Jijiang Liu
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Jijiang Liu @ 2015-08-31  9:41 UTC (permalink / raw)
  To: dev

The virtual addr for virtio net header need to be recorded.

Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
---
 drivers/net/virtio/virtqueue.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
index 7789411..530f840 100644
--- a/drivers/net/virtio/virtqueue.h
+++ b/drivers/net/virtio/virtqueue.h
@@ -189,6 +189,7 @@ struct virtqueue {
 	uint16_t vq_used_cons_idx;
 	uint16_t vq_avail_idx;
 	phys_addr_t virtio_net_hdr_mem; /**< hdr for each xmit packet */
+	uint64_t virtio_net_hdr_addr; /**< virtual addr for virtio net header */
 
 	/* Statistics */
 	uint64_t	packets;
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [dpdk-dev] [RFC PATCH 3/8] driver/virtio: record virtual address of virtio net header
  2015-08-31  9:41 [dpdk-dev] [RFC PATCH 0/8] Add vhost TSO capability Jijiang Liu
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 1/8] driver/virtio:add vhost TSO support capability Jijiang Liu
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 2/8] driver/virtio: add virtual addr for virtio net header Jijiang Liu
@ 2015-08-31  9:41 ` Jijiang Liu
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload Jijiang Liu
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Jijiang Liu @ 2015-08-31  9:41 UTC (permalink / raw)
  To: dev

Record virtual address of virtio net header.

Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 465d3cd..cb5dfee 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -376,6 +376,9 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 		}
 		vq->virtio_net_hdr_mem =
 			vq->virtio_net_hdr_mz->phys_addr;
+		vq->virtio_net_hdr_addr =
+			(uint64_t)(uintptr_t)vq->virtio_net_hdr_mz->addr;
+
 		memset(vq->virtio_net_hdr_mz->addr, 0,
 			vq_size * hw->vtnet_hdr_size);
 	} else if (queue_type == VTNET_CQ) {
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload
  2015-08-31  9:41 [dpdk-dev] [RFC PATCH 0/8] Add vhost TSO capability Jijiang Liu
                   ` (2 preceding siblings ...)
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 3/8] driver/virtio: record virtual address of " Jijiang Liu
@ 2015-08-31  9:41 ` Jijiang Liu
  2015-09-01  3:28   ` Ouyang, Changchun
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 5/8] lib/librte_vhost:dequeue vhost " Jijiang Liu
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Jijiang Liu @ 2015-08-31  9:41 UTC (permalink / raw)
  To: dev

Enqueue TSO4/6 offload.

Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
---
 drivers/net/virtio/virtio_rxtx.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index c5b53bb..4c2d838 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -198,6 +198,28 @@ virtqueue_enqueue_recv_refill(struct virtqueue *vq, struct rte_mbuf *cookie)
 	return 0;
 }
 
+static void
+virtqueue_enqueue_offload(struct virtqueue *txvq, struct rte_mbuf *m,
+			uint16_t idx, uint16_t hdr_sz)
+{
+	struct virtio_net_hdr *hdr = (struct virtio_net_hdr *)(uintptr_t)
+				(txvq->virtio_net_hdr_addr + idx * hdr_sz);
+
+	if (m->tso_segsz != 0 && m->ol_flags & PKT_TX_TCP_SEG) {
+		if (m->ol_flags & PKT_TX_IPV4) {
+			if (!vtpci_with_feature(txvq->hw, VIRTIO_NET_F_HOST_TSO4))
+				return;
+			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
+		} else if (m->ol_flags & PKT_TX_IPV6) {
+			if (!vtpci_with_feature(txvq->hw, VIRTIO_NET_F_HOST_TSO6))
+				return;
+			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		}
+		hdr->gso_size = m->tso_segsz;
+		hdr->hdr_len = m->l2_len + m->l3_len + m->l4_len;
+	}
+}
+
 static int
 virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie)
 {
@@ -221,6 +243,7 @@ virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie)
 	dxp->cookie = (void *)cookie;
 	dxp->ndescs = needed;
 
+	virtqueue_enqueue_offload(txvq, cookie, idx, head_size);
 	start_dp = txvq->vq_ring.desc;
 	start_dp[idx].addr =
 		txvq->virtio_net_hdr_mem + idx * head_size;
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [dpdk-dev] [RFC PATCH 5/8] lib/librte_vhost:dequeue vhost TSO offload
  2015-08-31  9:41 [dpdk-dev] [RFC PATCH 0/8] Add vhost TSO capability Jijiang Liu
                   ` (3 preceding siblings ...)
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload Jijiang Liu
@ 2015-08-31  9:41 ` Jijiang Liu
  2015-09-01  3:40   ` Ouyang, Changchun
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 6/8] lib/librte_vhost:extend supported vhost features Jijiang Liu
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Jijiang Liu @ 2015-08-31  9:41 UTC (permalink / raw)
  To: dev

Dequeue vhost TSO offload

Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
---
 lib/librte_vhost/vhost_rxtx.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index 0d07338..9adfdb1 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -545,6 +545,30 @@ rte_vhost_enqueue_burst(struct virtio_net *dev, uint16_t queue_id,
 		return virtio_dev_rx(dev, queue_id, pkts, count);
 }
 
+static inline void __attribute__((always_inline))
+vhost_dequeue_offload(uint64_t addr, struct rte_mbuf *m)
+{
+	struct virtio_net_hdr *hdr =
+		(struct virtio_net_hdr *)((uintptr_t)addr);
+
+	if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
+		switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
+		case VIRTIO_NET_HDR_GSO_TCPV4:
+			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_TCP_SEG);
+			m->tso_segsz = hdr->gso_size;
+			break;
+		case VIRTIO_NET_HDR_GSO_TCPV6:
+			m->ol_flags |= (PKT_TX_IPV6 | PKT_TX_TCP_SEG);
+			m->tso_segsz = hdr->gso_size;
+			break;
+		default:
+			RTE_LOG(ERR, VHOST_DATA,
+				"bad gso type %u.\n", hdr->gso_type);
+			break;
+		}
+	}
+}
+
 uint16_t
 rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,
 	struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count)
@@ -553,6 +577,7 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,
 	struct vhost_virtqueue *vq;
 	struct vring_desc *desc;
 	uint64_t vb_addr = 0;
+	uint64_t vb_net_hdr_addr = 0;
 	uint32_t head[MAX_PKT_BURST];
 	uint32_t used_idx;
 	uint32_t i;
@@ -604,6 +629,8 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,
 
 		desc = &vq->desc[head[entry_success]];
 
+		vb_net_hdr_addr = gpa_to_vva(dev, desc->addr);
+
 		/* Discard first buffer as it is the virtio header */
 		if (desc->flags & VRING_DESC_F_NEXT) {
 			desc = &vq->desc[desc->next];
@@ -742,7 +769,7 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,
 			break;
 
 		m->nb_segs = seg_num;
-
+		vhost_dequeue_offload(vb_net_hdr_addr, m);
 		pkts[entry_success] = m;
 		vq->last_used_idx++;
 		entry_success++;
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [dpdk-dev] [RFC PATCH 6/8] lib/librte_vhost:extend supported vhost features
  2015-08-31  9:41 [dpdk-dev] [RFC PATCH 0/8] Add vhost TSO capability Jijiang Liu
                   ` (4 preceding siblings ...)
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 5/8] lib/librte_vhost:dequeue vhost " Jijiang Liu
@ 2015-08-31  9:41 ` Jijiang Liu
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 7/8] examples/vhost:support tso in vhost sample Jijiang Liu
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 8/8] app/testpmd: modify the mac of csum forwarding Jijiang Liu
  7 siblings, 0 replies; 16+ messages in thread
From: Jijiang Liu @ 2015-08-31  9:41 UTC (permalink / raw)
  To: dev

Add TSO into supported vhost features

Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
---
 lib/librte_vhost/virtio-net.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
index b520ec5..2f9ac25 100644
--- a/lib/librte_vhost/virtio-net.c
+++ b/lib/librte_vhost/virtio-net.c
@@ -71,7 +71,10 @@ static struct virtio_net_config_ll *ll_root;
 #define VHOST_SUPPORTED_FEATURES ((1ULL << VIRTIO_NET_F_MRG_RXBUF) | \
 				(1ULL << VIRTIO_NET_F_CTRL_VQ) | \
 				(1ULL << VIRTIO_NET_F_CTRL_RX) | \
-				(1ULL << VHOST_F_LOG_ALL))
+				(1ULL << VHOST_F_LOG_ALL)      | \
+				(1ULL << VIRTIO_NET_F_HOST_TSO4) | \
+				(1ULL << VIRTIO_NET_F_HOST_TSO6))
+
 static uint64_t VHOST_FEATURES = VHOST_SUPPORTED_FEATURES;
 
 
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [dpdk-dev] [RFC PATCH 7/8] examples/vhost:support tso in vhost sample
  2015-08-31  9:41 [dpdk-dev] [RFC PATCH 0/8] Add vhost TSO capability Jijiang Liu
                   ` (5 preceding siblings ...)
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 6/8] lib/librte_vhost:extend supported vhost features Jijiang Liu
@ 2015-08-31  9:41 ` Jijiang Liu
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 8/8] app/testpmd: modify the mac of csum forwarding Jijiang Liu
  7 siblings, 0 replies; 16+ messages in thread
From: Jijiang Liu @ 2015-08-31  9:41 UTC (permalink / raw)
  To: dev

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [dpdk-dev] [RFC PATCH 8/8] app/testpmd: modify the mac of csum forwarding
  2015-08-31  9:41 [dpdk-dev] [RFC PATCH 0/8] Add vhost TSO capability Jijiang Liu
                   ` (6 preceding siblings ...)
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 7/8] examples/vhost:support tso in vhost sample Jijiang Liu
@ 2015-08-31  9:41 ` Jijiang Liu
  7 siblings, 0 replies; 16+ messages in thread
From: Jijiang Liu @ 2015-08-31  9:41 UTC (permalink / raw)
  To: dev

The change will affect on the csum fwd performance.
But I also think the change is necessary, or we cannot use csumonly fwd mode in a VM.

Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
---
 app/test-pmd/csumonly.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 1bf3485..c4ba22e 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -636,6 +636,12 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 		}
 		m->tso_segsz = info.tso_segsz;
 		m->ol_flags = ol_flags;
+		
+		ether_addr_copy(&peer_eth_addrs[fs->peer_addr],
+				&eth_hdr->d_addr);
+
+		ether_addr_copy(&ports[fs->tx_port].eth_addr,
+				&eth_hdr->s_addr);
 
 		/* if verbose mode is enabled, dump debug info */
 		if (verbose_level > 0) {
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload Jijiang Liu
@ 2015-09-01  3:28   ` Ouyang, Changchun
  2015-09-07  6:11     ` Liu, Jijiang
  0 siblings, 1 reply; 16+ messages in thread
From: Ouyang, Changchun @ 2015-09-01  3:28 UTC (permalink / raw)
  To: Liu, Jijiang, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jijiang Liu
> Sent: Monday, August 31, 2015 5:42 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload
> 
> Enqueue TSO4/6 offload.
> 
> Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
> ---
>  drivers/net/virtio/virtio_rxtx.c |   23 +++++++++++++++++++++++
>  1 files changed, 23 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
> index c5b53bb..4c2d838 100644
> --- a/drivers/net/virtio/virtio_rxtx.c
> +++ b/drivers/net/virtio/virtio_rxtx.c
> @@ -198,6 +198,28 @@ virtqueue_enqueue_recv_refill(struct virtqueue *vq,
> struct rte_mbuf *cookie)
>  	return 0;
>  }
> 
> +static void
> +virtqueue_enqueue_offload(struct virtqueue *txvq, struct rte_mbuf *m,
> +			uint16_t idx, uint16_t hdr_sz)
> +{
> +	struct virtio_net_hdr *hdr = (struct virtio_net_hdr *)(uintptr_t)
> +				(txvq->virtio_net_hdr_addr + idx * hdr_sz);
> +
> +	if (m->tso_segsz != 0 && m->ol_flags & PKT_TX_TCP_SEG) {
> +		if (m->ol_flags & PKT_TX_IPV4) {
> +			if (!vtpci_with_feature(txvq->hw,
> VIRTIO_NET_F_HOST_TSO4))
> +				return;

Do we need return error if host can't handle tso for the packet?

> +			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
> +		} else if (m->ol_flags & PKT_TX_IPV6) {
> +			if (!vtpci_with_feature(txvq->hw,
> VIRTIO_NET_F_HOST_TSO6))
> +				return;

Same as above

> +			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
> +		}

Do we need else branch for the case of neither tcpv4 nor tcpv6?

> +		hdr->gso_size = m->tso_segsz;
> +		hdr->hdr_len = m->l2_len + m->l3_len + m->l4_len;
> +	}
> +}
> +
>  static int
>  virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie)
> { @@ -221,6 +243,7 @@ virtqueue_enqueue_xmit(struct virtqueue *txvq,
> struct rte_mbuf *cookie)
>  	dxp->cookie = (void *)cookie;
>  	dxp->ndescs = needed;
> 
> +	virtqueue_enqueue_offload(txvq, cookie, idx, head_size);

If TSO is not enabled in the feature bit, how to resolve here?

>  	start_dp = txvq->vq_ring.desc;
>  	start_dp[idx].addr =
>  		txvq->virtio_net_hdr_mem + idx * head_size;
> --
> 1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [RFC PATCH 5/8] lib/librte_vhost:dequeue vhost TSO offload
  2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 5/8] lib/librte_vhost:dequeue vhost " Jijiang Liu
@ 2015-09-01  3:40   ` Ouyang, Changchun
  2015-09-07  6:16     ` Liu, Jijiang
  0 siblings, 1 reply; 16+ messages in thread
From: Ouyang, Changchun @ 2015-09-01  3:40 UTC (permalink / raw)
  To: Liu, Jijiang, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jijiang Liu
> Sent: Monday, August 31, 2015 5:42 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [RFC PATCH 5/8] lib/librte_vhost:dequeue vhost TSO
> offload
> 
> Dequeue vhost TSO offload
> 
> Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
> ---
>  lib/librte_vhost/vhost_rxtx.c |   29 ++++++++++++++++++++++++++++-
>  1 files changed, 28 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
> index 0d07338..9adfdb1 100644
> --- a/lib/librte_vhost/vhost_rxtx.c
> +++ b/lib/librte_vhost/vhost_rxtx.c
> @@ -545,6 +545,30 @@ rte_vhost_enqueue_burst(struct virtio_net *dev,
> uint16_t queue_id,
>  		return virtio_dev_rx(dev, queue_id, pkts, count);  }
> 
> +static inline void __attribute__((always_inline))
> +vhost_dequeue_offload(uint64_t addr, struct rte_mbuf *m) {
> +	struct virtio_net_hdr *hdr =
> +		(struct virtio_net_hdr *)((uintptr_t)addr);
> +
> +	if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
> +		switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
> +		case VIRTIO_NET_HDR_GSO_TCPV4:
> +			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_TCP_SEG);
> +			m->tso_segsz = hdr->gso_size;
> +			break;
> +		case VIRTIO_NET_HDR_GSO_TCPV6:
> +			m->ol_flags |= (PKT_TX_IPV6 | PKT_TX_TCP_SEG);
> +			m->tso_segsz = hdr->gso_size;
> +			break;
> +		default:
> +			RTE_LOG(ERR, VHOST_DATA,
> +				"bad gso type %u.\n", hdr->gso_type);
> +			break;

Do we need special handling for the bad gso type? 

> +		}
> +	}
> +}
> +
>  uint16_t
>  rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,
>  	struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t
> count) @@ -553,6 +577,7 @@ rte_vhost_dequeue_burst(struct virtio_net
> *dev, uint16_t queue_id,
>  	struct vhost_virtqueue *vq;
>  	struct vring_desc *desc;
>  	uint64_t vb_addr = 0;
> +	uint64_t vb_net_hdr_addr = 0;
>  	uint32_t head[MAX_PKT_BURST];
>  	uint32_t used_idx;
>  	uint32_t i;
> @@ -604,6 +629,8 @@ rte_vhost_dequeue_burst(struct virtio_net *dev,
> uint16_t queue_id,
> 
>  		desc = &vq->desc[head[entry_success]];
> 
> +		vb_net_hdr_addr = gpa_to_vva(dev, desc->addr);
> +
>  		/* Discard first buffer as it is the virtio header */
>  		if (desc->flags & VRING_DESC_F_NEXT) {
>  			desc = &vq->desc[desc->next];
> @@ -742,7 +769,7 @@ rte_vhost_dequeue_burst(struct virtio_net *dev,
> uint16_t queue_id,
>  			break;
> 
>  		m->nb_segs = seg_num;
> -
> +		vhost_dequeue_offload(vb_net_hdr_addr, m);
>  		pkts[entry_success] = m;
>  		vq->last_used_idx++;
>  		entry_success++;
> --
> 1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload
  2015-09-01  3:28   ` Ouyang, Changchun
@ 2015-09-07  6:11     ` Liu, Jijiang
  2015-09-09  1:17       ` Ouyang, Changchun
  0 siblings, 1 reply; 16+ messages in thread
From: Liu, Jijiang @ 2015-09-07  6:11 UTC (permalink / raw)
  To: Ouyang, Changchun, dev



> -----Original Message-----
> From: Ouyang, Changchun
> Sent: Monday, August 31, 2015 8:29 PM
> To: Liu, Jijiang; dev@dpdk.org
> Cc: Ouyang, Changchun
> Subject: RE: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload
> 
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jijiang Liu
> > Sent: Monday, August 31, 2015 5:42 PM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload
> >
> > Enqueue TSO4/6 offload.
> >
> > Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
> > ---
> >  drivers/net/virtio/virtio_rxtx.c |   23 +++++++++++++++++++++++
> >  1 files changed, 23 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/net/virtio/virtio_rxtx.c
> > b/drivers/net/virtio/virtio_rxtx.c
> > index c5b53bb..4c2d838 100644
> > --- a/drivers/net/virtio/virtio_rxtx.c
> > +++ b/drivers/net/virtio/virtio_rxtx.c
> > @@ -198,6 +198,28 @@ virtqueue_enqueue_recv_refill(struct virtqueue
> > *vq, struct rte_mbuf *cookie)
> >  	return 0;
> >  }
> >
> > +static void
> > +virtqueue_enqueue_offload(struct virtqueue *txvq, struct rte_mbuf *m,
> > +			uint16_t idx, uint16_t hdr_sz)
> > +{
> > +	struct virtio_net_hdr *hdr = (struct virtio_net_hdr *)(uintptr_t)
> > +				(txvq->virtio_net_hdr_addr + idx * hdr_sz);
> > +
> > +	if (m->tso_segsz != 0 && m->ol_flags & PKT_TX_TCP_SEG) {
> > +		if (m->ol_flags & PKT_TX_IPV4) {
> > +			if (!vtpci_with_feature(txvq->hw,
> > VIRTIO_NET_F_HOST_TSO4))
> > +				return;
> 
> Do we need return error if host can't handle tso for the packet?
> 
> > +			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
> > +		} else if (m->ol_flags & PKT_TX_IPV6) {
> > +			if (!vtpci_with_feature(txvq->hw,
> > VIRTIO_NET_F_HOST_TSO6))
> > +				return;
> 
> Same as above
> 
> > +			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
> > +		}
> 
> Do we need else branch for the case of neither tcpv4 nor tcpv6?
> 
> > +		hdr->gso_size = m->tso_segsz;
> > +		hdr->hdr_len = m->l2_len + m->l3_len + m->l4_len;
> > +	}
> > +}
> > +
> >  static int
> >  virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf
> > *cookie) { @@ -221,6 +243,7 @@ virtqueue_enqueue_xmit(struct virtqueue
> > *txvq, struct rte_mbuf *cookie)
> >  	dxp->cookie = (void *)cookie;
> >  	dxp->ndescs = needed;
> >
> > +	virtqueue_enqueue_offload(txvq, cookie, idx, head_size);
> 
> If TSO is not enabled in the feature bit, how to resolve here?

The TSO enablement  check is in the function.

If TSO is not enabled, and don't need to fill virtio_net_hdr now.

> >  	start_dp = txvq->vq_ring.desc;
> >  	start_dp[idx].addr =
> >  		txvq->virtio_net_hdr_mem + idx * head_size;
> > --
> > 1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [RFC PATCH 5/8] lib/librte_vhost:dequeue vhost TSO offload
  2015-09-01  3:40   ` Ouyang, Changchun
@ 2015-09-07  6:16     ` Liu, Jijiang
  0 siblings, 0 replies; 16+ messages in thread
From: Liu, Jijiang @ 2015-09-07  6:16 UTC (permalink / raw)
  To: Ouyang, Changchun, dev



> -----Original Message-----
> From: Ouyang, Changchun
> Sent: Monday, August 31, 2015 8:40 PM
> To: Liu, Jijiang; dev@dpdk.org
> Cc: Ouyang, Changchun
> Subject: RE: [dpdk-dev] [RFC PATCH 5/8] lib/librte_vhost:dequeue vhost TSO
> offload
> 
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jijiang Liu
> > Sent: Monday, August 31, 2015 5:42 PM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] [RFC PATCH 5/8] lib/librte_vhost:dequeue vhost TSO
> > offload
> >
> > Dequeue vhost TSO offload
> >
> > Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
> > ---
> >  lib/librte_vhost/vhost_rxtx.c |   29 ++++++++++++++++++++++++++++-
> >  1 files changed, 28 insertions(+), 1 deletions(-)
> >
> > diff --git a/lib/librte_vhost/vhost_rxtx.c
> > b/lib/librte_vhost/vhost_rxtx.c index 0d07338..9adfdb1 100644
> > --- a/lib/librte_vhost/vhost_rxtx.c
> > +++ b/lib/librte_vhost/vhost_rxtx.c
> > @@ -545,6 +545,30 @@ rte_vhost_enqueue_burst(struct virtio_net *dev,
> > uint16_t queue_id,
> >  		return virtio_dev_rx(dev, queue_id, pkts, count);  }
> >
> > +static inline void __attribute__((always_inline))
> > +vhost_dequeue_offload(uint64_t addr, struct rte_mbuf *m) {
> > +	struct virtio_net_hdr *hdr =
> > +		(struct virtio_net_hdr *)((uintptr_t)addr);
> > +
> > +	if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
> > +		switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
> > +		case VIRTIO_NET_HDR_GSO_TCPV4:
> > +			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_TCP_SEG);
> > +			m->tso_segsz = hdr->gso_size;
> > +			break;
> > +		case VIRTIO_NET_HDR_GSO_TCPV6:
> > +			m->ol_flags |= (PKT_TX_IPV6 | PKT_TX_TCP_SEG);
> > +			m->tso_segsz = hdr->gso_size;
> > +			break;
> > +		default:
> > +			RTE_LOG(ERR, VHOST_DATA,
> > +				"bad gso type %u.\n", hdr->gso_type);
> > +			break;
> 
> Do we need special handling for the bad gso type?
Yes, we need return error, and log it and break this operation.

I will change it in next version.

> 
> > +		}
> > +	}
> > +}
> > +
> >  uint16_t
> >  rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,
> >  	struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t
> > count) @@ -553,6 +577,7 @@ rte_vhost_dequeue_burst(struct virtio_net
> > *dev, uint16_t queue_id,
> >  	struct vhost_virtqueue *vq;
> >  	struct vring_desc *desc;
> >  	uint64_t vb_addr = 0;
> > +	uint64_t vb_net_hdr_addr = 0;
> >  	uint32_t head[MAX_PKT_BURST];
> >  	uint32_t used_idx;
> >  	uint32_t i;
> > @@ -604,6 +629,8 @@ rte_vhost_dequeue_burst(struct virtio_net *dev,
> > uint16_t queue_id,
> >
> >  		desc = &vq->desc[head[entry_success]];
> >
> > +		vb_net_hdr_addr = gpa_to_vva(dev, desc->addr);
> > +
> >  		/* Discard first buffer as it is the virtio header */
> >  		if (desc->flags & VRING_DESC_F_NEXT) {
> >  			desc = &vq->desc[desc->next];
> > @@ -742,7 +769,7 @@ rte_vhost_dequeue_burst(struct virtio_net *dev,
> > uint16_t queue_id,
> >  			break;
> >
> >  		m->nb_segs = seg_num;
> > -
> > +		vhost_dequeue_offload(vb_net_hdr_addr, m);
> >  		pkts[entry_success] = m;
> >  		vq->last_used_idx++;
> >  		entry_success++;
> > --
> > 1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload
  2015-09-07  6:11     ` Liu, Jijiang
@ 2015-09-09  1:17       ` Ouyang, Changchun
  2015-09-09 17:21         ` Liu, Jijiang
  0 siblings, 1 reply; 16+ messages in thread
From: Ouyang, Changchun @ 2015-09-09  1:17 UTC (permalink / raw)
  To: Liu, Jijiang, dev



> -----Original Message-----
> From: Liu, Jijiang
> Sent: Monday, September 7, 2015 2:11 PM
> To: Ouyang, Changchun; dev@dpdk.org
> Subject: RE: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload
> 
> 
> 
> > -----Original Message-----
> > From: Ouyang, Changchun
> > Sent: Monday, August 31, 2015 8:29 PM
> > To: Liu, Jijiang; dev@dpdk.org
> > Cc: Ouyang, Changchun
> > Subject: RE: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO
> > offload
> >
> >
> >
> > > -----Original Message-----
> > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jijiang Liu
> > > Sent: Monday, August 31, 2015 5:42 PM
> > > To: dev@dpdk.org
> > > Subject: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO
> > > offload
> > >
> > > Enqueue TSO4/6 offload.
> > >
> > > Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
> > > ---
> > >  drivers/net/virtio/virtio_rxtx.c |   23 +++++++++++++++++++++++
> > >  1 files changed, 23 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/drivers/net/virtio/virtio_rxtx.c
> > > b/drivers/net/virtio/virtio_rxtx.c
> > > index c5b53bb..4c2d838 100644
> > > --- a/drivers/net/virtio/virtio_rxtx.c
> > > +++ b/drivers/net/virtio/virtio_rxtx.c
> > > @@ -198,6 +198,28 @@ virtqueue_enqueue_recv_refill(struct virtqueue
> > > *vq, struct rte_mbuf *cookie)
> > >  	return 0;
> > >  }
> > >
> > > +static void
> > > +virtqueue_enqueue_offload(struct virtqueue *txvq, struct rte_mbuf
> *m,
> > > +			uint16_t idx, uint16_t hdr_sz)
> > > +{
> > > +	struct virtio_net_hdr *hdr = (struct virtio_net_hdr *)(uintptr_t)
> > > +				(txvq->virtio_net_hdr_addr + idx * hdr_sz);
> > > +
> > > +	if (m->tso_segsz != 0 && m->ol_flags & PKT_TX_TCP_SEG) {
> > > +		if (m->ol_flags & PKT_TX_IPV4) {
> > > +			if (!vtpci_with_feature(txvq->hw,
> > > VIRTIO_NET_F_HOST_TSO4))
> > > +				return;
> >
> > Do we need return error if host can't handle tso for the packet?
> >
> > > +			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
> > > +		} else if (m->ol_flags & PKT_TX_IPV6) {
> > > +			if (!vtpci_with_feature(txvq->hw,
> > > VIRTIO_NET_F_HOST_TSO6))
> > > +				return;
> >
> > Same as above
> >
> > > +			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
> > > +		}
> >
> > Do we need else branch for the case of neither tcpv4 nor tcpv6?
> >
> > > +		hdr->gso_size = m->tso_segsz;
> > > +		hdr->hdr_len = m->l2_len + m->l3_len + m->l4_len;
> > > +	}
> > > +}
> > > +
> > >  static int
> > >  virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf
> > > *cookie) { @@ -221,6 +243,7 @@ virtqueue_enqueue_xmit(struct
> > > virtqueue *txvq, struct rte_mbuf *cookie)
> > >  	dxp->cookie = (void *)cookie;
> > >  	dxp->ndescs = needed;
> > >
> > > +	virtqueue_enqueue_offload(txvq, cookie, idx, head_size);
> >
> > If TSO is not enabled in the feature bit, how to resolve here?
> 
> The TSO enablement  check is in the function.
> 
> If TSO is not enabled, and don't need to fill virtio_net_hdr now.

Here I mean if (m->ol_flags & PKT_TX_TCP_SEG) is true, that is to say, the virtio-pmd user expect do tso in vhost or virtio,
but the host feature bit doesn't support it, then it should handle this case,
either handle it in virtio pmd, or return error to caller. 
Otherwise the packet with flag tso maybe can't be send out normally.  
Am I right?

> 
> > >  	start_dp = txvq->vq_ring.desc;
> > >  	start_dp[idx].addr =
> > >  		txvq->virtio_net_hdr_mem + idx * head_size;
> > > --
> > > 1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload
  2015-09-09  1:17       ` Ouyang, Changchun
@ 2015-09-09 17:21         ` Liu, Jijiang
  2015-09-09 23:03           ` Ouyang, Changchun
  0 siblings, 1 reply; 16+ messages in thread
From: Liu, Jijiang @ 2015-09-09 17:21 UTC (permalink / raw)
  To: Ouyang, Changchun, dev



> -----Original Message-----
> From: Ouyang, Changchun
> Sent: Tuesday, September 8, 2015 6:18 PM
> To: Liu, Jijiang; dev@dpdk.org
> Cc: Ouyang, Changchun
> Subject: RE: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload
> 
> 
> 
> > -----Original Message-----
> > From: Liu, Jijiang
> > Sent: Monday, September 7, 2015 2:11 PM
> > To: Ouyang, Changchun; dev@dpdk.org
> > Subject: RE: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO
> > offload
> >
> >
> >
> > > -----Original Message-----
> > > From: Ouyang, Changchun
> > > Sent: Monday, August 31, 2015 8:29 PM
> > > To: Liu, Jijiang; dev@dpdk.org
> > > Cc: Ouyang, Changchun
> > > Subject: RE: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO
> > > offload
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jijiang Liu
> > > > Sent: Monday, August 31, 2015 5:42 PM
> > > > To: dev@dpdk.org
> > > > Subject: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO
> > > > offload
> > > >
> > > > Enqueue TSO4/6 offload.
> > > >
> > > > Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
> > > > ---
> > > >  drivers/net/virtio/virtio_rxtx.c |   23 +++++++++++++++++++++++
> > > >  1 files changed, 23 insertions(+), 0 deletions(-)
> > > >
> > > > diff --git a/drivers/net/virtio/virtio_rxtx.c
> > > > b/drivers/net/virtio/virtio_rxtx.c
> > > > index c5b53bb..4c2d838 100644
> > > > --- a/drivers/net/virtio/virtio_rxtx.c
> > > > +++ b/drivers/net/virtio/virtio_rxtx.c
> > > > @@ -198,6 +198,28 @@ virtqueue_enqueue_recv_refill(struct
> > > > virtqueue *vq, struct rte_mbuf *cookie)
> > > >  	return 0;
> > > >  }
> > > >
> > > > +static void
> > > > +virtqueue_enqueue_offload(struct virtqueue *txvq, struct rte_mbuf
> > *m,
> > > > +			uint16_t idx, uint16_t hdr_sz) {
> > > > +	struct virtio_net_hdr *hdr = (struct virtio_net_hdr *)(uintptr_t)
> > > > +				(txvq->virtio_net_hdr_addr + idx * hdr_sz);
> > > > +
> > > > +	if (m->tso_segsz != 0 && m->ol_flags & PKT_TX_TCP_SEG) {
> > > > +		if (m->ol_flags & PKT_TX_IPV4) {
> > > > +			if (!vtpci_with_feature(txvq->hw,
> > > > VIRTIO_NET_F_HOST_TSO4))
> > > > +				return;
> > >
> > > Do we need return error if host can't handle tso for the packet?
> > >
> > > > +			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
> > > > +		} else if (m->ol_flags & PKT_TX_IPV6) {
> > > > +			if (!vtpci_with_feature(txvq->hw,
> > > > VIRTIO_NET_F_HOST_TSO6))
> > > > +				return;
> > >
> > > Same as above
> > >
> > > > +			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
> > > > +		}
> > >
> > > Do we need else branch for the case of neither tcpv4 nor tcpv6?
> > >
> > > > +		hdr->gso_size = m->tso_segsz;
> > > > +		hdr->hdr_len = m->l2_len + m->l3_len + m->l4_len;
> > > > +	}
> > > > +}
> > > > +
> > > >  static int
> > > >  virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf
> > > > *cookie) { @@ -221,6 +243,7 @@ virtqueue_enqueue_xmit(struct
> > > > virtqueue *txvq, struct rte_mbuf *cookie)
> > > >  	dxp->cookie = (void *)cookie;
> > > >  	dxp->ndescs = needed;
> > > >
> > > > +	virtqueue_enqueue_offload(txvq, cookie, idx, head_size);
> > >
> > > If TSO is not enabled in the feature bit, how to resolve here?
> >
> > The TSO enablement  check is in the function.
> >
> > If TSO is not enabled, and don't need to fill virtio_net_hdr now.
> 
> Here I mean if (m->ol_flags & PKT_TX_TCP_SEG) is true, that is to say, the virtio-
> pmd user expect do tso in vhost or virtio, but the host feature bit doesn't
> support it, then it should handle this case, either handle it in virtio pmd, or return
> error to caller.
> Otherwise the packet with flag tso maybe can't be send out normally.
> Am I right?
Not exactly, if host feature bit doesn't support TSO, and the TSO flag cannot been set in this function,
and then continue processing the packet in host. 
Now I think it had better return an error, and don't continue processing this packet.

> >
> > > >  	start_dp = txvq->vq_ring.desc;
> > > >  	start_dp[idx].addr =
> > > >  		txvq->virtio_net_hdr_mem + idx * head_size;
> > > > --
> > > > 1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload
  2015-09-09 17:21         ` Liu, Jijiang
@ 2015-09-09 23:03           ` Ouyang, Changchun
  0 siblings, 0 replies; 16+ messages in thread
From: Ouyang, Changchun @ 2015-09-09 23:03 UTC (permalink / raw)
  To: Liu, Jijiang, dev



> -----Original Message-----
> From: Liu, Jijiang
> Sent: Thursday, September 10, 2015 1:21 AM
> To: Ouyang, Changchun; dev@dpdk.org
> Subject: RE: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload
> 
> 
> 
> > -----Original Message-----
> > From: Ouyang, Changchun
> > Sent: Tuesday, September 8, 2015 6:18 PM
> > To: Liu, Jijiang; dev@dpdk.org
> > Cc: Ouyang, Changchun
> > Subject: RE: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO
> > offload
> >
> >
> >
> > > -----Original Message-----
> > > From: Liu, Jijiang
> > > Sent: Monday, September 7, 2015 2:11 PM
> > > To: Ouyang, Changchun; dev@dpdk.org
> > > Subject: RE: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO
> > > offload
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Ouyang, Changchun
> > > > Sent: Monday, August 31, 2015 8:29 PM
> > > > To: Liu, Jijiang; dev@dpdk.org
> > > > Cc: Ouyang, Changchun
> > > > Subject: RE: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO
> > > > offload
> > > >
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jijiang Liu
> > > > > Sent: Monday, August 31, 2015 5:42 PM
> > > > > To: dev@dpdk.org
> > > > > Subject: [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO
> > > > > offload
> > > > >
> > > > > Enqueue TSO4/6 offload.
> > > > >
> > > > > Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
> > > > > ---
> > > > >  drivers/net/virtio/virtio_rxtx.c |   23 +++++++++++++++++++++++
> > > > >  1 files changed, 23 insertions(+), 0 deletions(-)
> > > > >
> > > > > diff --git a/drivers/net/virtio/virtio_rxtx.c
> > > > > b/drivers/net/virtio/virtio_rxtx.c
> > > > > index c5b53bb..4c2d838 100644
> > > > > --- a/drivers/net/virtio/virtio_rxtx.c
> > > > > +++ b/drivers/net/virtio/virtio_rxtx.c
> > > > > @@ -198,6 +198,28 @@ virtqueue_enqueue_recv_refill(struct
> > > > > virtqueue *vq, struct rte_mbuf *cookie)
> > > > >  	return 0;
> > > > >  }
> > > > >
> > > > > +static void
> > > > > +virtqueue_enqueue_offload(struct virtqueue *txvq, struct
> > > > > +rte_mbuf
> > > *m,
> > > > > +			uint16_t idx, uint16_t hdr_sz) {
> > > > > +	struct virtio_net_hdr *hdr = (struct virtio_net_hdr
> *)(uintptr_t)
> > > > > +				(txvq->virtio_net_hdr_addr + idx *
> hdr_sz);
> > > > > +
> > > > > +	if (m->tso_segsz != 0 && m->ol_flags & PKT_TX_TCP_SEG) {
> > > > > +		if (m->ol_flags & PKT_TX_IPV4) {
> > > > > +			if (!vtpci_with_feature(txvq->hw,
> > > > > VIRTIO_NET_F_HOST_TSO4))
> > > > > +				return;
> > > >
> > > > Do we need return error if host can't handle tso for the packet?
> > > >
> > > > > +			hdr->gso_type =
> VIRTIO_NET_HDR_GSO_TCPV4;
> > > > > +		} else if (m->ol_flags & PKT_TX_IPV6) {
> > > > > +			if (!vtpci_with_feature(txvq->hw,
> > > > > VIRTIO_NET_F_HOST_TSO6))
> > > > > +				return;
> > > >
> > > > Same as above
> > > >
> > > > > +			hdr->gso_type =
> VIRTIO_NET_HDR_GSO_TCPV6;
> > > > > +		}
> > > >
> > > > Do we need else branch for the case of neither tcpv4 nor tcpv6?
> > > >
> > > > > +		hdr->gso_size = m->tso_segsz;
> > > > > +		hdr->hdr_len = m->l2_len + m->l3_len + m->l4_len;
> > > > > +	}
> > > > > +}
> > > > > +
> > > > >  static int
> > > > >  virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf
> > > > > *cookie) { @@ -221,6 +243,7 @@ virtqueue_enqueue_xmit(struct
> > > > > virtqueue *txvq, struct rte_mbuf *cookie)
> > > > >  	dxp->cookie = (void *)cookie;
> > > > >  	dxp->ndescs = needed;
> > > > >
> > > > > +	virtqueue_enqueue_offload(txvq, cookie, idx, head_size);
> > > >
> > > > If TSO is not enabled in the feature bit, how to resolve here?
> > >
> > > The TSO enablement  check is in the function.
> > >
> > > If TSO is not enabled, and don't need to fill virtio_net_hdr now.
> >
> > Here I mean if (m->ol_flags & PKT_TX_TCP_SEG) is true, that is to say,
> > the virtio- pmd user expect do tso in vhost or virtio, but the host
> > feature bit doesn't support it, then it should handle this case,
> > either handle it in virtio pmd, or return error to caller.
> > Otherwise the packet with flag tso maybe can't be send out normally.
> > Am I right?
> Not exactly, if host feature bit doesn't support TSO, and the TSO flag cannot
> been set in this function, and then continue processing the packet in host.

TSO flag is set by upper level, so it could be set even if host feature bit doesn't support TSO,
You know the other path is also supporting TSO in guest feature bit.
Currently the virtio driver can't support TSO, at least we should return error for this possible case.

> Now I think it had better return an error, and don't continue processing this
> packet.
> 
> > >
> > > > >  	start_dp = txvq->vq_ring.desc;
> > > > >  	start_dp[idx].addr =
> > > > >  		txvq->virtio_net_hdr_mem + idx * head_size;
> > > > > --
> > > > > 1.7.7.6

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-09-09 23:03 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-31  9:41 [dpdk-dev] [RFC PATCH 0/8] Add vhost TSO capability Jijiang Liu
2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 1/8] driver/virtio:add vhost TSO support capability Jijiang Liu
2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 2/8] driver/virtio: add virtual addr for virtio net header Jijiang Liu
2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 3/8] driver/virtio: record virtual address of " Jijiang Liu
2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 4/8] driver/virtio:enqueue TSO offload Jijiang Liu
2015-09-01  3:28   ` Ouyang, Changchun
2015-09-07  6:11     ` Liu, Jijiang
2015-09-09  1:17       ` Ouyang, Changchun
2015-09-09 17:21         ` Liu, Jijiang
2015-09-09 23:03           ` Ouyang, Changchun
2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 5/8] lib/librte_vhost:dequeue vhost " Jijiang Liu
2015-09-01  3:40   ` Ouyang, Changchun
2015-09-07  6:16     ` Liu, Jijiang
2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 6/8] lib/librte_vhost:extend supported vhost features Jijiang Liu
2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 7/8] examples/vhost:support tso in vhost sample Jijiang Liu
2015-08-31  9:41 ` [dpdk-dev] [RFC PATCH 8/8] app/testpmd: modify the mac of csum forwarding Jijiang Liu

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).