[dpdk-dev,v4,1/3] vhost: Fix packet length issue
Commit Message
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 | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
Comments
> -----Original Message-----
> From: Ouyang, Changchun
> Sent: Wednesday, November 05, 2014 12:11 AM
> To: dev@dpdk.org
> Cc: Xie, Huawei; Ananyev, Konstantin; Cao, Waterman; Ouyang, Changchun
> Subject: [PATCH v4 1/3] vhost: Fix packet length issue
>
> 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 | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/examples/vhost/main.c b/examples/vhost/main.c
> index 57ef464..5ca8dce 100644
> --- a/examples/vhost/main.c
> +++ b/examples/vhost/main.c
> @@ -1078,7 +1078,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];
> @@ -1102,8 +1108,10 @@ 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;
> + m->pkt_len += offset;
> +
> m->vlan_tci = vlan_tag;
>
> tx_q->m_table[len] = m;
> --
> 1.8.4.2
Only one thing, I feel "by minus/plus" has grammar problem. :).
Acked-by: Huawei Xie <huawei.xie@intel.com>.
@@ -1078,7 +1078,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];
@@ -1102,8 +1108,10 @@ 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;
+ m->pkt_len += offset;
+
m->vlan_tci = vlan_tag;
tx_q->m_table[len] = m;