DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/virtio: fix wrong TX pkt length stats
@ 2017-10-11  4:39 Zhiyong Yang
  2017-10-13 10:06 ` Maxime Coquelin
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Zhiyong Yang @ 2017-10-11  4:39 UTC (permalink / raw)
  To: dev; +Cc: yliu, maxime.coquelin, jianfeng.tan, Zhiyong Yang

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;
 		virtio_update_packet_stats(&txvq->stats, txm);
 	}
-- 
2.13.3

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH] net/virtio: fix wrong TX pkt length stats
  2017-10-11  4:39 [dpdk-dev] [PATCH] net/virtio: fix wrong TX pkt length stats Zhiyong Yang
@ 2017-10-13 10:06 ` Maxime Coquelin
  2017-10-13 12:44   ` Yang, Zhiyong
  2017-10-17 13:21 ` Yuanhan Liu
  2017-10-23  6:40 ` [dpdk-dev] [PATCH v2] " Zhiyong Yang
  2 siblings, 1 reply; 10+ messages in thread
From: Maxime Coquelin @ 2017-10-13 10:06 UTC (permalink / raw)
  To: Zhiyong Yang, dev; +Cc: yliu, jianfeng.tan

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);
>   	}
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH] net/virtio: fix wrong TX pkt length stats
  2017-10-13 10:06 ` Maxime Coquelin
@ 2017-10-13 12:44   ` Yang, Zhiyong
  2017-10-13 12:47     ` Maxime Coquelin
  0 siblings, 1 reply; 10+ messages in thread
From: Yang, Zhiyong @ 2017-10-13 12:44 UTC (permalink / raw)
  To: Maxime Coquelin, dev; +Cc: yliu, Tan, Jianfeng

Hi Maxime,

> -----Original Message-----
> From: Maxime Coquelin [mailto:maxime.coquelin@redhat.com]
> Sent: Friday, October 13, 2017 6:06 PM
> To: Yang, Zhiyong <zhiyong.yang@intel.com>; dev@dpdk.org
> Cc: yliu@fridaylinux.org; Tan, Jianfeng <jianfeng.tan@intel.com>
> Subject: Re: [PATCH] net/virtio: fix wrong TX pkt length stats
> 
> 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;

I don't like modifying pkt_len, too.
But We need to consider that some stats are updated in virtio_update_packet_stats()
In this function,  pkt_len will be used further.  

Thanks
Zhiyong 

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH] net/virtio: fix wrong TX pkt length stats
  2017-10-13 12:44   ` Yang, Zhiyong
@ 2017-10-13 12:47     ` Maxime Coquelin
  0 siblings, 0 replies; 10+ messages in thread
From: Maxime Coquelin @ 2017-10-13 12:47 UTC (permalink / raw)
  To: Yang, Zhiyong, dev; +Cc: yliu, Tan, Jianfeng



On 10/13/2017 02:44 PM, Yang, Zhiyong wrote:
> Hi Maxime,
> 
>> -----Original Message-----
>> From: Maxime Coquelin [mailto:maxime.coquelin@redhat.com]
>> Sent: Friday, October 13, 2017 6:06 PM
>> To: Yang, Zhiyong <zhiyong.yang@intel.com>; dev@dpdk.org
>> Cc: yliu@fridaylinux.org; Tan, Jianfeng <jianfeng.tan@intel.com>
>> Subject: Re: [PATCH] net/virtio: fix wrong TX pkt length stats
>>
>> 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;
> 
> I don't like modifying pkt_len, too.
> But We need to consider that some stats are updated in virtio_update_packet_stats()
> In this function,  pkt_len will be used further.


Ha, good point!
I think we have no better way then:
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH] net/virtio: fix wrong TX pkt length stats
  2017-10-11  4:39 [dpdk-dev] [PATCH] net/virtio: fix wrong TX pkt length stats Zhiyong Yang
  2017-10-13 10:06 ` Maxime Coquelin
@ 2017-10-17 13:21 ` Yuanhan Liu
  2017-10-23  6:40 ` [dpdk-dev] [PATCH v2] " Zhiyong Yang
  2 siblings, 0 replies; 10+ messages in thread
From: Yuanhan Liu @ 2017-10-17 13:21 UTC (permalink / raw)
  To: Zhiyong Yang; +Cc: dev, maxime.coquelin, jianfeng.tan

On Wed, Oct 11, 2017 at 12:39:35PM +0800, 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.

Nice catch!

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

It should also Cc stable.

> 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

Hmm..., why not modifying it directly in virtqueue_enqueue_xmit()?

	--yliu

> +		 * 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-dev] [PATCH v2] net/virtio: fix wrong TX pkt length stats
  2017-10-11  4:39 [dpdk-dev] [PATCH] net/virtio: fix wrong TX pkt length stats Zhiyong Yang
  2017-10-13 10:06 ` Maxime Coquelin
  2017-10-17 13:21 ` Yuanhan Liu
@ 2017-10-23  6:40 ` Zhiyong Yang
  2017-10-23 13:21   ` Yuanhan Liu
  2017-10-24  3:06   ` [dpdk-dev] [PATCH v3] " Zhiyong Yang
  2 siblings, 2 replies; 10+ messages in thread
From: Zhiyong Yang @ 2017-10-23  6:40 UTC (permalink / raw)
  To: dev; +Cc: stable, yliu, maxime.coquelin, Zhiyong Yang

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 <zhiyong.yang@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/virtio: fix wrong TX pkt length stats
  2017-10-23  6:40 ` [dpdk-dev] [PATCH v2] " Zhiyong Yang
@ 2017-10-23 13:21   ` Yuanhan Liu
  2017-10-24  2:05     ` Yang, Zhiyong
  2017-10-24  3:06   ` [dpdk-dev] [PATCH v3] " Zhiyong Yang
  1 sibling, 1 reply; 10+ messages in thread
From: Yuanhan Liu @ 2017-10-23 13:21 UTC (permalink / raw)
  To: Zhiyong Yang; +Cc: dev, stable, maxime.coquelin

On Mon, Oct 23, 2017 at 02:40:36PM +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.
> 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 <zhiyong.yang@intel.com>
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
> 
> 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;

I actually meant to put it inside the "if (can_push)" clause, so that you
don't have to add yet another if. The another reason I wanted you to do
the move is, rte_pktmbuf_prepend (which did the magic) is exactly invoked
inside this if. Such move puts logical related code tight together. At least,
you could make the comment simpler: you don't have to say "when can_push
is true ...". Instead, it could be:

    /*
     * rte_pktmbuf_prepend() counts the hdr size to the pkt length,
     * which is wrong. Below subtract restores the correct pkt size.
     */

	--yliu

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/virtio: fix wrong TX pkt length stats
  2017-10-23 13:21   ` Yuanhan Liu
@ 2017-10-24  2:05     ` Yang, Zhiyong
  0 siblings, 0 replies; 10+ messages in thread
From: Yang, Zhiyong @ 2017-10-24  2:05 UTC (permalink / raw)
  To: Yuanhan Liu; +Cc: dev, stable, maxime.coquelin

Yuanhan,

> -----Original Message-----
> From: Yuanhan Liu [mailto:yliu@fridaylinux.org]
> Sent: Monday, October 23, 2017 9:22 PM
> To: Yang, Zhiyong <zhiyong.yang@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org; maxime.coquelin@redhat.com
> Subject: Re: [PATCH v2] net/virtio: fix wrong TX pkt length stats
> 
> On Mon, Oct 23, 2017 at 02:40:36PM +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.
> > 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 <zhiyong.yang@intel.com>
> > Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> > ---
> >
> > 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;
> 
> I actually meant to put it inside the "if (can_push)" clause, so that you don't have
> to add yet another if. The another reason I wanted you to do the move is,
> rte_pktmbuf_prepend (which did the magic) is exactly invoked inside this if. Such
> move puts logical related code tight together. At least, you could make the
> comment simpler: you don't have to say "when can_push is true ...". Instead, it
> could be:
> 
>     /*
>      * rte_pktmbuf_prepend() counts the hdr size to the pkt length,
>      * which is wrong. Below subtract restores the correct pkt size.
>      */
> 
> 	--yliu

You are right.  I mistakenly think that cookie->pkt_len will be used to transmit pkts .
Actually cookie->data_len will is used when filling the descriptors.
No problem. V3 will be sent soon.

Zhiyong

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-dev] [PATCH v3] net/virtio: fix wrong TX pkt length stats
  2017-10-23  6:40 ` [dpdk-dev] [PATCH v2] " Zhiyong Yang
  2017-10-23 13:21   ` Yuanhan Liu
@ 2017-10-24  3:06   ` Zhiyong Yang
  2017-10-24  8:46     ` Yuanhan Liu
  1 sibling, 1 reply; 10+ messages in thread
From: Zhiyong Yang @ 2017-10-24  3:06 UTC (permalink / raw)
  To: dev; +Cc: stable, yliu, maxime.coquelin, Zhiyong Yang

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(+)

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH v3] net/virtio: fix wrong TX pkt length stats
  2017-10-24  3:06   ` [dpdk-dev] [PATCH v3] " Zhiyong Yang
@ 2017-10-24  8:46     ` Yuanhan Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Yuanhan Liu @ 2017-10-24  8:46 UTC (permalink / raw)
  To: Zhiyong Yang; +Cc: dev, stable, maxime.coquelin

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-10-24  8:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-11  4:39 [dpdk-dev] [PATCH] net/virtio: fix wrong TX pkt length stats Zhiyong Yang
2017-10-13 10:06 ` Maxime Coquelin
2017-10-13 12:44   ` Yang, Zhiyong
2017-10-13 12:47     ` Maxime Coquelin
2017-10-17 13:21 ` Yuanhan Liu
2017-10-23  6:40 ` [dpdk-dev] [PATCH v2] " Zhiyong Yang
2017-10-23 13:21   ` Yuanhan Liu
2017-10-24  2:05     ` Yang, Zhiyong
2017-10-24  3:06   ` [dpdk-dev] [PATCH v3] " Zhiyong Yang
2017-10-24  8:46     ` Yuanhan Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).