From patchwork Wed Sep 16 17:10:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jijiang Liu X-Patchwork-Id: 7049 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id CABC78E65; Wed, 16 Sep 2015 19:11:44 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id D00118E65 for ; Wed, 16 Sep 2015 19:11:42 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 16 Sep 2015 10:11:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,540,1437462000"; d="scan'208";a="805828072" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 16 Sep 2015 10:11:04 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t8GHB1tH007826; Thu, 17 Sep 2015 01:11:01 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t8GHAvPw010663; Thu, 17 Sep 2015 01:10:59 +0800 Received: (from jijiangl@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t8GHAvto010659; Thu, 17 Sep 2015 01:10:57 +0800 From: Jijiang Liu To: dev@dpdk.org Date: Thu, 17 Sep 2015 01:10:37 +0800 Message-Id: <1442423438-10578-8-git-send-email-jijiang.liu@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1442423438-10578-1-git-send-email-jijiang.liu@intel.com> References: <1442423438-10578-1-git-send-email-jijiang.liu@intel.com> Subject: [dpdk-dev] [PATCH 7/8] examples/vhost:support TSO in vhost sample X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Change the vhost sample in order to support and test TSO offload. Signed-off-by: Jijiang Liu --- 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 #include #include +#include #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;