From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id BBFAE1B1B9 for ; Wed, 11 Oct 2017 06:39:40 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP; 10 Oct 2017 21:39:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,359,1503385200"; d="scan'208";a="321854191" Received: from unknown (HELO dpdk5.bj.intel.com) ([172.16.182.182]) by fmsmga004.fm.intel.com with ESMTP; 10 Oct 2017 21:39:37 -0700 From: Zhiyong Yang To: dev@dpdk.org Cc: yliu@fridaylinux.org, maxime.coquelin@redhat.com, jianfeng.tan@intel.com, Zhiyong Yang Date: Wed, 11 Oct 2017 12:39:35 +0800 Message-Id: <20171011043935.16813-1-zhiyong.yang@intel.com> X-Mailer: git-send-email 2.13.3 Subject: [dpdk-dev] [PATCH] net/virtio: fix wrong TX pkt length stats X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Oct 2017 04:39:41 -0000 In the function virtqueue_enqueue_xmit(), when can_push == 1 is true, vtnet_hdr_size is added to pkt_len by calling rte_pktmbuf_prepend. So, virtio header len should be subtracted before calling stats function. Fixes: 58169a9c8153 ("net/virtio: support Tx checksum offload") Signed-off-by: Zhiyong Yang --- drivers/net/virtio/virtio_rxtx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 609b4138a..bf14f9a99 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -1079,6 +1079,12 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) /* Enqueue Packet buffers */ virtqueue_enqueue_xmit(txvq, txm, slots, use_indirect, can_push); + /* In function virtqueue_enqueue_xmit(), when can_push == 1 + * is true, vtnet_hdr_size is added to pkt_len of mbuf. So, it + * should be subtracted before calling stats function. + */ + if (can_push == 1) + txm->pkt_len -= txvq->vq->hw->vtnet_hdr_size; txvq->stats.bytes += txm->pkt_len; virtio_update_packet_stats(&txvq->stats, txm); } -- 2.13.3