* [dpdk-dev] [PATCH 1/8] driver/virtio:add vhost TSO support capability
2015-09-16 17:10 [dpdk-dev] [PATCH 0/8] add vhost TSO capability Jijiang Liu
@ 2015-09-16 17:10 ` Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 2/8] driver/virtio:add virtual addr for virtio net header Jijiang Liu
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jijiang Liu @ 2015-09-16 17:10 UTC (permalink / raw)
To: dev
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] 10+ messages in thread
* [dpdk-dev] [PATCH 2/8] driver/virtio:add virtual addr for virtio net header
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 ` Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 3/8] driver/virtio: record virtual address of " Jijiang Liu
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jijiang Liu @ 2015-09-16 17:10 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] 10+ messages in thread
* [dpdk-dev] [PATCH 3/8] driver/virtio: record virtual address of virtio net header
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 ` Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 4/8] driver/virtio:enqueue TSO offload Jijiang Liu
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jijiang Liu @ 2015-09-16 17:10 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] 10+ messages in thread
* [dpdk-dev] [PATCH 4/8] driver/virtio:enqueue TSO offload
2015-09-16 17:10 [dpdk-dev] [PATCH 0/8] add vhost TSO capability Jijiang Liu
` (2 preceding siblings ...)
2015-09-16 17:10 ` [dpdk-dev] [PATCH 3/8] driver/virtio: record virtual address of " Jijiang Liu
@ 2015-09-16 17:10 ` Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 5/8] lib/librte_vhost:dequeue vhost " Jijiang Liu
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jijiang Liu @ 2015-09-16 17:10 UTC (permalink / raw)
To: dev
Enqueue host TSO4/6 offload in guest side.
Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
---
drivers/net/virtio/virtio_rxtx.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index c5b53bb..68b293e 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -198,6 +198,31 @@ virtqueue_enqueue_recv_refill(struct virtqueue *vq, struct rte_mbuf *cookie)
return 0;
}
+static int
+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 -1;
+ 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 -1;
+ 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;
+ }
+ return 0;
+}
+
static int
virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie)
{
@@ -221,6 +246,9 @@ virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie)
dxp->cookie = (void *)cookie;
dxp->ndescs = needed;
+ if (virtqueue_enqueue_offload(txvq, cookie, idx, head_size) < 0)
+ return -EPERM;
+
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] 10+ messages in thread
* [dpdk-dev] [PATCH 5/8] lib/librte_vhost:dequeue vhost TSO offload
2015-09-16 17:10 [dpdk-dev] [PATCH 0/8] add vhost TSO capability Jijiang Liu
` (3 preceding siblings ...)
2015-09-16 17:10 ` [dpdk-dev] [PATCH 4/8] driver/virtio:enqueue TSO offload Jijiang Liu
@ 2015-09-16 17:10 ` Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 6/8] lib/librte_vhost:extend supported vhost features Jijiang Liu
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jijiang Liu @ 2015-09-16 17:10 UTC (permalink / raw)
To: dev
Dequeue host TSO4/6 offload in host side.
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..b84ec64 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(WARNING, VHOST_DATA,
+ "unsupported 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] 10+ messages in thread
* [dpdk-dev] [PATCH 6/8] lib/librte_vhost:extend supported vhost features
2015-09-16 17:10 [dpdk-dev] [PATCH 0/8] add vhost TSO capability Jijiang Liu
` (4 preceding siblings ...)
2015-09-16 17:10 ` [dpdk-dev] [PATCH 5/8] lib/librte_vhost:dequeue vhost " Jijiang Liu
@ 2015-09-16 17:10 ` Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 7/8] examples/vhost:support TSO in vhost sample Jijiang Liu
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jijiang Liu @ 2015-09-16 17:10 UTC (permalink / raw)
To: dev
Add host TSO support into vhost features bits
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] 10+ messages in thread
* [dpdk-dev] [PATCH 7/8] examples/vhost:support TSO in vhost sample
2015-09-16 17:10 [dpdk-dev] [PATCH 0/8] add vhost TSO capability Jijiang Liu
` (5 preceding siblings ...)
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
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
8 siblings, 0 replies; 10+ messages in thread
From: Jijiang Liu @ 2015-09-16 17:10 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] 10+ messages in thread
* [dpdk-dev] [PATCH 8/8] app/testpmd: modify the mac of csum forwarding
2015-09-16 17:10 [dpdk-dev] [PATCH 0/8] add vhost TSO capability Jijiang Liu
` (6 preceding siblings ...)
2015-09-16 17:10 ` [dpdk-dev] [PATCH 7/8] examples/vhost:support TSO in vhost sample Jijiang Liu
@ 2015-09-16 17:10 ` Jijiang Liu
2015-10-26 7:09 ` [dpdk-dev] [PATCH 0/8] add vhost TSO capability Tan, Jianfeng
8 siblings, 0 replies; 10+ messages in thread
From: Jijiang Liu @ 2015-09-16 17:10 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],
+ ð_hdr->d_addr);
+
+ ether_addr_copy(&ports[fs->tx_port].eth_addr,
+ ð_hdr->s_addr);
/* if verbose mode is enabled, dump debug info */
if (verbose_level > 0) {
--
1.7.7.6
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH 0/8] add vhost TSO capability
2015-09-16 17:10 [dpdk-dev] [PATCH 0/8] add vhost TSO capability Jijiang Liu
` (7 preceding siblings ...)
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 ` Tan, Jianfeng
8 siblings, 0 replies; 10+ messages in thread
From: Tan, Jianfeng @ 2015-10-26 7:09 UTC (permalink / raw)
To: Liu, Jijiang, dev
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jijiang Liu
> Sent: Thursday, September 17, 2015 1:11 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 0/8] add vhost TSO capability
>
> 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.
>
> *** BLURB HERE ***
>
> 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 | 28 ++++++++++++++++++++++++++++
> 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, 91 insertions(+), 5 deletions(-)
>
> --
> 1.7.7.6
Acked-by: Jianfeng Tan <jianfeng.tan@intel.com>
Thanks,
Jianfeng
^ permalink raw reply [flat|nested] 10+ messages in thread