[dpdk-stable] [PATCH v2] net/virtio: fix wrong TX pkt length stats

Zhiyong Yang zhiyong.yang at intel.com
Mon Oct 23 08:40:36 CEST 2017

In the function virtqueue_enqueue_xmit(), when can_push is true,
vtnet_hdr_size is added to pkt_len by calling rte_pktmbuf_prepend.
So, virtio header length should be subtracted before calling stats

Fixes: 58169a9c8153 ("net/virtio: support Tx checksum offload")

Cc: stable at dpdk.org
Cc: yliu at fridaylinux.org
Cc: maxime.coquelin at redhat.com
Signed-off-by: Zhiyong Yang <zhiyong.yang at intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>

Changes in V2:
Put code in the function virtqueue_enqueue_xmit() according to
yuanhan's comments.

 drivers/net/virtio/virtio_rxtx.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 2cf82fef4..f28751e07 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -396,6 +396,13 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie,
 		vq->vq_desc_tail_idx = idx;
 	vq->vq_free_cnt = (uint16_t)(vq->vq_free_cnt - needed);
 	vq_update_avail_ring(vq, head_idx);
+	/* when can_push is true, vtnet_hdr_size is added to pkt_len
+	 * of mbuf. It should be subtracted in order to make stats function
+	 * work in the right way.
+	 */
+	if (can_push)
+		cookie->pkt_len -= head_size;

More information about the stable mailing list