From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id B863C377E for ; Wed, 16 Sep 2015 19:11:07 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 16 Sep 2015 10:11:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,540,1437462000"; d="scan'208";a="646096051" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga003.jf.intel.com with ESMTP; 16 Sep 2015 10:11:01 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t8GHAsXo006609; Thu, 17 Sep 2015 01:10:54 +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 t8GHAo60010641; Thu, 17 Sep 2015 01:10:52 +0800 Received: (from jijiangl@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t8GHAoq6010637; Thu, 17 Sep 2015 01:10:50 +0800 From: Jijiang Liu To: dev@dpdk.org Date: Thu, 17 Sep 2015 01:10:34 +0800 Message-Id: <1442423438-10578-5-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 4/8] driver/virtio:enqueue TSO offload 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: , X-List-Received-Date: Wed, 16 Sep 2015 17:11:08 -0000 Enqueue host TSO4/6 offload in guest side. Signed-off-by: Jijiang Liu --- 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