From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 2BB4F1B723; Tue, 24 Oct 2017 05:06:19 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP; 23 Oct 2017 20:06:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,424,1503385200"; d="scan'208";a="141498038" Received: from unknown (HELO dpdk5.bj.intel.com) ([172.16.182.182]) by orsmga004.jf.intel.com with ESMTP; 23 Oct 2017 20:06:16 -0700 From: Zhiyong Yang To: dev@dpdk.org Cc: stable@dpdk.org, yliu@fridaylinux.org, maxime.coquelin@redhat.com, Zhiyong Yang Date: Tue, 24 Oct 2017 11:06:14 +0800 Message-Id: <20171024030614.37690-1-zhiyong.yang@intel.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20171023064036.56821-1-zhiyong.yang@intel.com> References: <20171023064036.56821-1-zhiyong.yang@intel.com> Subject: [dpdk-dev] [PATCH v3] 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: Tue, 24 Oct 2017 03:06:20 -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. 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 Reviewed-by: Maxime Coquelin --- 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(+) 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); -- 2.13.3