From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 8E7F27D19; Mon, 23 Oct 2017 08:40:40 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2017 23:40:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,421,1503385200"; d="scan'208";a="326430455" Received: from unknown (HELO dpdk5.bj.intel.com) ([172.16.182.182]) by fmsmga004.fm.intel.com with ESMTP; 22 Oct 2017 23:40:37 -0700 From: Zhiyong Yang To: dev@dpdk.org Cc: stable@dpdk.org, yliu@fridaylinux.org, maxime.coquelin@redhat.com, Zhiyong Yang Date: Mon, 23 Oct 2017 14:40:36 +0800 Message-Id: <20171023064036.56821-1-zhiyong.yang@intel.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20171011043935.16813-1-zhiyong.yang@intel.com> References: <20171011043935.16813-1-zhiyong.yang@intel.com> Subject: [dpdk-stable] [PATCH v2] net/virtio: fix wrong TX pkt length stats X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2017 06:40:41 -0000 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 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 Reviewed-by: Maxime Coquelin --- 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; } void -- 2.13.3