[dpdk-dev,v3] net/virtio: fix wrong TX pkt length stats

Message ID 20171024030614.37690-1-zhiyong.yang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Yuanhan Liu
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Yang, Zhiyong Oct. 24, 2017, 3:06 a.m. UTC
  In the function virtqueue_enqueue_xmit(), when can_push is true,
vtnet_hdr_size is added to pkt_len by calling rte_pktmbuf_prepend.
which is wrong for pkt stats, virtio header length should be subtracted
before calling stats function.

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

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

Changes in V3:
Move code inside "if (can_push)" clause and simplify comments.

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

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

Comments

Yuanhan Liu Oct. 24, 2017, 8:46 a.m. UTC | #1
On Tue, Oct 24, 2017 at 11:06:14AM +0800, Zhiyong Yang wrote:
> In the function virtqueue_enqueue_xmit(), when can_push is true,
> vtnet_hdr_size is added to pkt_len by calling rte_pktmbuf_prepend.
> which is wrong for pkt stats, virtio header length should be subtracted
> before calling stats function.
> 
> Fixes: 58169a9c8153 ("net/virtio: support Tx checksum offload")
> 
> Cc: stable@dpdk.org
> Cc: yliu@fridaylinux.org
> Cc: maxime.coquelin@redhat.com
> Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Applied to dpdk-next-virtio.

Thanks.

	--yliu
  

Patch

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 2cf82fef4..ac4055d45 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -299,6 +299,10 @@  virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie,
 		/* prepend cannot fail, checked by caller */
 		hdr = (struct virtio_net_hdr *)
 			rte_pktmbuf_prepend(cookie, head_size);
+		/* rte_pktmbuf_prepend() counts the hdr size to the pkt length,
+		 * which is wrong. Below subtract restores correct pkt size.
+		 */
+		cookie->pkt_len -= head_size;
 		/* if offload disabled, it is not zeroed below, do it now */
 		if (offload == 0) {
 			ASSIGN_UNLESS_EQUAL(hdr->csum_start, 0);