From patchwork Thu May 28 08:19:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei li X-Patchwork-Id: 4929 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 1D1385A52; Thu, 28 May 2015 10:19:53 +0200 (CEST) Received: from smtp2203-239.mail.aliyun.com (smtp2203-239.mail.aliyun.com [121.197.203.239]) by dpdk.org (Postfix) with ESMTP id 899E437AA for ; Thu, 28 May 2015 10:19:50 +0200 (CEST) X-Alimail-AntiSpam: AC=CONTINUE; BC=0.4820169|-1; FP=0|0|0|0|0|-1|-1|-1; HT=r46d02009; MF=liw@dtdream.com; PH=DS; RN=1; RT=1; SR=0; Received: from liw0310-PC.local(mailfrom:liw@dtdream.com ip:111.198.29.132) by smtp.aliyun-inc.com(10.194.100.111); Thu, 28 May 2015 16:19:45 +0800 Date: Thu, 28 May 2015 16:19:44 +0800 From: Wei li To: dev@dpdk.org Message-ID: <8975cbf4-0f4d-4da4-8e45-6b75629072e1@liw0310-PC.local> X-Mailer: TortoiseGit MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] vhost: tcp pkt with virtio header in one desc 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" Signed-off-by: Wei li --- lib/librte_vhost/vhost_rxtx.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c index 4809d32..2d3ea92 100644 --- a/lib/librte_vhost/vhost_rxtx.c +++ b/lib/librte_vhost/vhost_rxtx.c @@ -588,8 +588,19 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, desc = &vq->desc[head[entry_success]]; - /* Discard first buffer as it is the virtio header */ - desc = &vq->desc[desc->next]; + if (desc->flags & VRING_DESC_F_NEXT) + { + /* Discard first buffer as it is the virtio header */ + desc = &vq->desc[desc->next]; + vb_offset = 0; + vb_avail = desc->len; + } + else /* virtio header in one desc with real pkt */ + { + /* strip the virtio header */ + vb_offset = vq->vhost_hlen; + vb_avail = desc->len - vq->vhost_hlen; + } /* Buffer address translation. */ vb_addr = gpa_to_vva(dev, desc->addr); @@ -608,8 +619,6 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, vq->used->ring[used_idx].id = head[entry_success]; vq->used->ring[used_idx].len = 0; - vb_offset = 0; - vb_avail = desc->len; /* Allocate an mbuf and populate the structure. */ m = rte_pktmbuf_alloc(mbuf_pool); if (unlikely(m == NULL)) {