DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] vhost: Fix packet length issue
@ 2014-10-30  9:00 Ouyang Changchun
  2014-10-30 14:59 ` [dpdk-dev] [PATCH v2] " Ouyang Changchun
  0 siblings, 1 reply; 16+ messages in thread
From: Ouyang Changchun @ 2014-10-30  9:00 UTC (permalink / raw)
  To: dev

As HW vlan strip will reduce the packet length by minus length of vlan tag,
so it need restore the packet length by plus it.

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

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 0566124..dc32fa9 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -1067,6 +1067,7 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)
 {
 	struct mbuf_table *tx_q;
 	struct rte_mbuf **m_table;
+	struct rte_mbuf *last_seg = m;
 	unsigned len, ret, offset = 0;
 	const uint16_t lcore_id = rte_lcore_id();
 	struct virtio_net_data_ll *dev_ll = ll_root_used;
@@ -1097,7 +1098,13 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)
 					rte_pktmbuf_free(m);
 					return;
 				}
-				offset = 4;
+
+				/*
+				 * HW vlan strip will reduce the packet length
+				 * by minus length of vlan tag, so need restore
+				 * the packet length by plus it.
+				 */
+				offset = VLAN_HLEN;
 				vlan_tag =
 				(uint16_t)
 				vlan_tags[(uint16_t)dev_ll->vdev->dev->device_fh];
@@ -1121,8 +1128,12 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)
 	len = tx_q->len;
 
 	m->ol_flags = PKT_TX_VLAN_PKT;
-	/*FIXME: offset*/
-	m->data_len += offset;
+
+	while (last_seg->next)
+		last_seg = last_seg->next;
+	last_seg->data_len += offset;
+	m->pkt_len += offset;
+
 	m->vlan_tci = vlan_tag;
 
 	tx_q->m_table[len] = m;
-- 
1.8.4.2

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-11-06  0:37 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-30  9:00 [dpdk-dev] [PATCH] vhost: Fix packet length issue Ouyang Changchun
2014-10-30 14:59 ` [dpdk-dev] [PATCH v2] " Ouyang Changchun
2014-11-04  7:05   ` [dpdk-dev] [PATCH v3 0/2] " Ouyang Changchun
2014-11-04  7:05     ` [dpdk-dev] [PATCH v3 1/2] vhost: " Ouyang Changchun
2014-11-04  7:05     ` [dpdk-dev] [PATCH v3 2/2] vhost: Remove duplicated codes Ouyang Changchun
2014-11-05  7:10     ` [dpdk-dev] [PATCH v4 0/3] Fix packet length issue Ouyang Changchun
2014-11-05  7:10       ` [dpdk-dev] [PATCH v4 1/3] vhost: " Ouyang Changchun
2014-11-05 16:46         ` Xie, Huawei
2014-11-05  7:10       ` [dpdk-dev] [PATCH v4 2/3] vhost: Remove duplicated codes Ouyang Changchun
2014-11-05  7:10       ` [dpdk-dev] [PATCH v4 3/3] vhost: Check offset value Ouyang Changchun
2014-11-05 16:52         ` Xie, Huawei
2014-11-05 17:00           ` Thomas Monjalon
2014-11-05 17:05             ` Xie, Huawei
2014-11-06  0:44             ` Ouyang, Changchun
2014-11-05  9:28       ` [dpdk-dev] [PATCH v4 0/3] Fix packet length issue Ananyev, Konstantin
2014-11-05 22:07         ` Thomas Monjalon

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).