DPDK patches and discussions
 help / color / mirror / Atom feed
From: Wei li <liw@dtdream.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] vhost: tcp pkt with virtio header in one desc
Date: Thu, 28 May 2015 16:19:44 +0800	[thread overview]
Message-ID: <8975cbf4-0f4d-4da4-8e45-6b75629072e1@liw0310-PC.local> (raw)

Signed-off-by: Wei li <liw@dtdream.com>
---
 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)) {
-- 
1.9.5.msysgit.1

             reply	other threads:[~2015-05-28  8:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-28  8:19 Wei li [this message]
2015-05-28 13:32 ` Ouyang, Changchun
2015-05-28 14:50 ` Stephen Hemminger
2015-05-28 15:22   ` Ouyang, Changchun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8975cbf4-0f4d-4da4-8e45-6b75629072e1@liw0310-PC.local \
    --to=liw@dtdream.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).