From patchwork Mon Aug 31 09:41:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jijiang Liu X-Patchwork-Id: 6834 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 BBDCB91C0; Mon, 31 Aug 2015 11:42:16 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 92C4C91BF for ; Mon, 31 Aug 2015 11:42:15 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 31 Aug 2015 02:42:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,439,1437462000"; d="scan'208";a="759004671" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 31 Aug 2015 02:42:14 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t7V9gCKs007100; Mon, 31 Aug 2015 17:42:12 +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 t7V9gAbx003217; Mon, 31 Aug 2015 17:42:12 +0800 Received: (from jijiangl@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t7V9gAKr003213; Mon, 31 Aug 2015 17:42:10 +0800 From: Jijiang Liu To: dev@dpdk.org Date: Mon, 31 Aug 2015 17:41:47 +0800 Message-Id: <1441014108-3125-8-git-send-email-jijiang.liu@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1441014108-3125-1-git-send-email-jijiang.liu@intel.com> References: <1441014108-3125-1-git-send-email-jijiang.liu@intel.com> Subject: [dpdk-dev] [RFC 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;