DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ouyang Changchun <changchun.ouyang@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] examples/vhost: Fix data len issue
Date: Wed, 10 Dec 2014 20:11:47 +0800	[thread overview]
Message-ID: <1418213507-1911-1-git-send-email-changchun.ouyang@intel.com> (raw)

Search the right segment to increase its data length, rather than
wrongly early return and exit the tx function, which leads to drop all jumbo frame packets
when vm2vm is in hard forward mode.

Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
---
 examples/vhost/main.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 1f1edbe..12fa4ce 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -1127,9 +1127,8 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)
 		return;
 	}
 
-	if (vm2vm_mode == VM2VM_HARDWARE) {
-		if (find_local_dest(dev, m, &offset, &vlan_tag) != 0 ||
-			offset > rte_pktmbuf_tailroom(m)) {
+	if (unlikely(vm2vm_mode == VM2VM_HARDWARE)) {
+		if (unlikely(find_local_dest(dev, m, &offset, &vlan_tag) != 0)) {
 			rte_pktmbuf_free(m);
 			return;
 		}
@@ -1143,8 +1142,24 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)
 
 	m->ol_flags = PKT_TX_VLAN_PKT;
 
-	m->data_len += offset;
-	m->pkt_len += offset;
+	/*
+	 * Find the right seg to adjust the data len when offset is
+	 * bigger than tail room size.
+	 */
+	if (unlikely(vm2vm_mode == VM2VM_HARDWARE)) {
+		if (likely(offset <= rte_pktmbuf_tailroom(m)))
+			m->data_len += offset;
+		else {
+			struct rte_mbuf *seg = m;
+
+			while ((seg->next != NULL) &&
+				(offset > rte_pktmbuf_tailroom(seg)))
+				seg = seg->next;
+
+			seg->data_len += offset;
+		}
+		m->pkt_len += offset;
+	}
 
 	m->vlan_tci = vlan_tag;
 
-- 
1.8.4.2

             reply	other threads:[~2014-12-10 12:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-10 12:11 Ouyang Changchun [this message]
2014-12-11  1:07 ` Thomas Monjalon

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=1418213507-1911-1-git-send-email-changchun.ouyang@intel.com \
    --to=changchun.ouyang@intel.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).