From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <maxime.coquelin@redhat.com>
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28])
 by dpdk.org (Postfix) with ESMTP id 723381B663
 for <dev@dpdk.org>; Fri, 13 Oct 2017 12:06:16 +0200 (CEST)
Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com
 [10.5.11.13])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mx1.redhat.com (Postfix) with ESMTPS id 9FC5AA78B;
 Fri, 13 Oct 2017 10:06:15 +0000 (UTC)
DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9FC5AA78B
Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com;
 dmarc=none (p=none dis=none) header.from=redhat.com
Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com;
 spf=fail smtp.mailfrom=maxime.coquelin@redhat.com
Received: from [10.36.112.24] (ovpn-112-24.ams2.redhat.com [10.36.112.24])
 by smtp.corp.redhat.com (Postfix) with ESMTPS id ED22A60841;
 Fri, 13 Oct 2017 10:06:13 +0000 (UTC)
To: Zhiyong Yang <zhiyong.yang@intel.com>, dev@dpdk.org
Cc: yliu@fridaylinux.org, jianfeng.tan@intel.com
References: <20171011043935.16813-1-zhiyong.yang@intel.com>
From: Maxime Coquelin <maxime.coquelin@redhat.com>
Message-ID: <c268770f-625b-dafb-807d-c4d2b515ea95@redhat.com>
Date: Fri, 13 Oct 2017 12:06:11 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.3.0
MIME-Version: 1.0
In-Reply-To: <20171011043935.16813-1-zhiyong.yang@intel.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
 (mx1.redhat.com [10.5.110.29]); Fri, 13 Oct 2017 10:06:15 +0000 (UTC)
Subject: Re: [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 <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Fri, 13 Oct 2017 10:06:16 -0000

Hi Zhiyong,

On 10/11/2017 06:39 AM, Zhiyong Yang wrote:
> 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 <zhiyong.yang@intel.com>
> ---
>   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;

I acknowledge the problem, but I don't like modifying pkt_len.
This is not the case currently, but in case we want to do something
with the mbuf later in virtio_xmit_cleanup(), it could be good to have
the real length there.

What about:

if (can_push == 1)
     txvq->stats.bytes += txm->pkt_len - txvq->vq->hw->vtnet_hdr_size;
else
     txvq->stats.bytes += txm->pkt_len;

Thanks,
Maxime

>   		virtio_update_packet_stats(&txvq->stats, txm);
>   	}
>