summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOuyang Changchun <changchun.ouyang@intel.com>2014-12-10 20:11:47 +0800
committerThomas Monjalon <thomas.monjalon@6wind.com>2014-12-11 01:42:03 +0100
commitc2ab5162dbd8837bf381be4627e3ba8efccf4562 (patch)
treed4c3a3aa32854069cb14ee9d8a996001185e892c
parent8bd6c395a568ef7a70c64fbef0968c456bed6d29 (diff)
downloaddpdk-c2ab5162dbd8837bf381be4627e3ba8efccf4562.zip
dpdk-c2ab5162dbd8837bf381be4627e3ba8efccf4562.tar.gz
dpdk-c2ab5162dbd8837bf381be4627e3ba8efccf4562.tar.xz
examples/vhost: fix hard forward of jumbo frames
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>
-rw-r--r--examples/vhost/main.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index d2c1852..9331910 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -1119,9 +1119,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;
}
@@ -1135,8 +1134,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;