From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 0794F8D9E for ; Wed, 16 Sep 2015 19:11:36 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 16 Sep 2015 10:10:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,540,1437462000"; d="scan'208";a="770381816" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 16 Sep 2015 10:10:59 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t8GHAuge007663; Thu, 17 Sep 2015 01:10:56 +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 t8GHAr4L010649; Thu, 17 Sep 2015 01:10:55 +0800 Received: (from jijiangl@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t8GHAqPp010645; Thu, 17 Sep 2015 01:10:52 +0800 From: Jijiang Liu To: dev@dpdk.org Date: Thu, 17 Sep 2015 01:10:35 +0800 Message-Id: <1442423438-10578-6-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 5/8] lib/librte_vhost:dequeue vhost 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:37 -0000 Dequeue host TSO4/6 offload in host side. Signed-off-by: Jijiang Liu --- 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