* [dpdk-dev] [PATCH] net/virtio: fix broken Tx checksum offloads
@ 2019-10-24 17:46 Andrew Rybchenko
2019-10-25 6:37 ` Tiwei Bie
2019-10-25 8:30 ` Maxime Coquelin
0 siblings, 2 replies; 6+ messages in thread
From: Andrew Rybchenko @ 2019-10-24 17:46 UTC (permalink / raw)
To: Maxime Coquelin, Tiwei Bie, Zhihong Wang; +Cc: dev, stable
Missing parenthesis around expression before type cast to struct
virtio_net_hdr pointer makes the arithmetic to be in
sizeof(struct virtio_net_hdr) units.
Use rte_pktmbuf_mtod_offset() to fix the problem.
Type of head_size is changed to signed since some compilers bark
on unary minus applied to unsigned.
Fixes: 1ae55ad38e5e ("net/virtio: fix mbuf data and packet length mismatch")
Cc: stable@dpdk.org
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
drivers/net/virtio/virtio_rxtx.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index b5fc4ecbe1..274b778d84 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -635,7 +635,7 @@ virtqueue_enqueue_xmit_inorder(struct virtnet_tx *txvq,
struct vring_desc *start_dp;
struct virtio_net_hdr *hdr;
uint16_t idx;
- uint16_t head_size = vq->hw->vtnet_hdr_size;
+ int16_t head_size = vq->hw->vtnet_hdr_size;
uint16_t i = 0;
idx = vq->vq_desc_head_idx;
@@ -648,8 +648,8 @@ virtqueue_enqueue_xmit_inorder(struct virtnet_tx *txvq,
dxp->ndescs = 1;
virtio_update_packet_stats(&txvq->stats, cookies[i]);
- hdr = (struct virtio_net_hdr *)(char *)cookies[i]->buf_addr +
- cookies[i]->data_off - head_size;
+ hdr = rte_pktmbuf_mtod_offset(cookies[i],
+ struct virtio_net_hdr *, -head_size);
/* if offload disabled, hdr is not zeroed yet, do it now */
if (!vq->hw->has_tx_offload)
@@ -682,7 +682,7 @@ virtqueue_enqueue_xmit_packed_fast(struct virtnet_tx *txvq,
struct vring_packed_desc *dp;
struct vq_desc_extra *dxp;
uint16_t idx, id, flags;
- uint16_t head_size = vq->hw->vtnet_hdr_size;
+ int16_t head_size = vq->hw->vtnet_hdr_size;
struct virtio_net_hdr *hdr;
id = in_order ? vq->vq_avail_idx : vq->vq_desc_head_idx;
@@ -696,8 +696,8 @@ virtqueue_enqueue_xmit_packed_fast(struct virtnet_tx *txvq,
flags = vq->vq_packed.cached_flags;
/* prepend cannot fail, checked by caller */
- hdr = (struct virtio_net_hdr *)(char *)cookie->buf_addr +
- cookie->data_off - head_size;
+ hdr = rte_pktmbuf_mtod_offset(cookie, struct virtio_net_hdr *,
+ -head_size);
/* if offload disabled, hdr is not zeroed yet, do it now */
if (!vq->hw->has_tx_offload)
@@ -734,7 +734,7 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie,
struct virtqueue *vq = txvq->vq;
struct vring_packed_desc *start_dp, *head_dp;
uint16_t idx, id, head_idx, head_flags;
- uint16_t head_size = vq->hw->vtnet_hdr_size;
+ int16_t head_size = vq->hw->vtnet_hdr_size;
struct virtio_net_hdr *hdr;
uint16_t prev;
bool prepend_header = false;
@@ -756,8 +756,8 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie,
if (can_push) {
/* prepend cannot fail, checked by caller */
- hdr = (struct virtio_net_hdr *)(char *)cookie->buf_addr +
- cookie->data_off - head_size;
+ hdr = rte_pktmbuf_mtod_offset(cookie, struct virtio_net_hdr *,
+ -head_size);
prepend_header = true;
/* if offload disabled, it is not zeroed below, do it now */
@@ -832,7 +832,7 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie,
struct vring_desc *start_dp;
uint16_t seg_num = cookie->nb_segs;
uint16_t head_idx, idx;
- uint16_t head_size = vq->hw->vtnet_hdr_size;
+ int16_t head_size = vq->hw->vtnet_hdr_size;
bool prepend_header = false;
struct virtio_net_hdr *hdr;
@@ -849,8 +849,8 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie,
if (can_push) {
/* prepend cannot fail, checked by caller */
- hdr = (struct virtio_net_hdr *)(char *)cookie->buf_addr +
- cookie->data_off - head_size;
+ hdr = rte_pktmbuf_mtod_offset(cookie, struct virtio_net_hdr *,
+ -head_size);
prepend_header = true;
/* if offload disabled, it is not zeroed below, do it now */
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] net/virtio: fix broken Tx checksum offloads
2019-10-24 17:46 [dpdk-dev] [PATCH] net/virtio: fix broken Tx checksum offloads Andrew Rybchenko
@ 2019-10-25 6:37 ` Tiwei Bie
2019-10-25 8:30 ` Maxime Coquelin
1 sibling, 0 replies; 6+ messages in thread
From: Tiwei Bie @ 2019-10-25 6:37 UTC (permalink / raw)
To: Andrew Rybchenko; +Cc: Maxime Coquelin, Zhihong Wang, dev, stable
On Thu, Oct 24, 2019 at 06:46:09PM +0100, Andrew Rybchenko wrote:
> Missing parenthesis around expression before type cast to struct
> virtio_net_hdr pointer makes the arithmetic to be in
> sizeof(struct virtio_net_hdr) units.
>
> Use rte_pktmbuf_mtod_offset() to fix the problem.
>
> Type of head_size is changed to signed since some compilers bark
> on unary minus applied to unsigned.
>
> Fixes: 1ae55ad38e5e ("net/virtio: fix mbuf data and packet length mismatch")
> Cc: stable@dpdk.org
>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
> drivers/net/virtio/virtio_rxtx.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
Thanks,
Tiwei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] net/virtio: fix broken Tx checksum offloads
2019-10-24 17:46 [dpdk-dev] [PATCH] net/virtio: fix broken Tx checksum offloads Andrew Rybchenko
2019-10-25 6:37 ` Tiwei Bie
@ 2019-10-25 8:30 ` Maxime Coquelin
2019-10-25 8:48 ` Maxime Coquelin
` (2 more replies)
1 sibling, 3 replies; 6+ messages in thread
From: Maxime Coquelin @ 2019-10-25 8:30 UTC (permalink / raw)
To: Andrew Rybchenko, Tiwei Bie, Zhihong Wang; +Cc: dev, stable
On 10/24/19 7:46 PM, Andrew Rybchenko wrote:
> Missing parenthesis around expression before type cast to struct
> virtio_net_hdr pointer makes the arithmetic to be in
> sizeof(struct virtio_net_hdr) units.
>
> Use rte_pktmbuf_mtod_offset() to fix the problem.
>
> Type of head_size is changed to signed since some compilers bark
> on unary minus applied to unsigned.
>
> Fixes: 1ae55ad38e5e ("net/virtio: fix mbuf data and packet length mismatch")
> Cc: stable@dpdk.org
>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
> drivers/net/virtio/virtio_rxtx.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
Thanks Andrew!
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Ferruh, do you want to apply it directly for -rc1?
Maxime
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] net/virtio: fix broken Tx checksum offloads
2019-10-25 8:30 ` Maxime Coquelin
@ 2019-10-25 8:48 ` Maxime Coquelin
2019-10-25 10:22 ` Ferruh Yigit
2019-10-25 14:41 ` Ferruh Yigit
2 siblings, 0 replies; 6+ messages in thread
From: Maxime Coquelin @ 2019-10-25 8:48 UTC (permalink / raw)
To: Andrew Rybchenko, Tiwei Bie, Zhihong Wang, Ferruh Yigit; +Cc: dev, stable
Missed to add Ferruh.
On 10/25/19 10:30 AM, Maxime Coquelin wrote:
>
>
> On 10/24/19 7:46 PM, Andrew Rybchenko wrote:
>> Missing parenthesis around expression before type cast to struct
>> virtio_net_hdr pointer makes the arithmetic to be in
>> sizeof(struct virtio_net_hdr) units.
>>
>> Use rte_pktmbuf_mtod_offset() to fix the problem.
>>
>> Type of head_size is changed to signed since some compilers bark
>> on unary minus applied to unsigned.
>>
>> Fixes: 1ae55ad38e5e ("net/virtio: fix mbuf data and packet length mismatch")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
>> ---
>> drivers/net/virtio/virtio_rxtx.c | 24 ++++++++++++------------
>> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> Thanks Andrew!
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>
> Ferruh, do you want to apply it directly for -rc1?
>
> Maxime
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] net/virtio: fix broken Tx checksum offloads
2019-10-25 8:30 ` Maxime Coquelin
2019-10-25 8:48 ` Maxime Coquelin
@ 2019-10-25 10:22 ` Ferruh Yigit
2019-10-25 14:41 ` Ferruh Yigit
2 siblings, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2019-10-25 10:22 UTC (permalink / raw)
To: Maxime Coquelin, Andrew Rybchenko, Tiwei Bie, Zhihong Wang; +Cc: dev, stable
On 10/25/2019 9:30 AM, Maxime Coquelin wrote:
>
>
> On 10/24/19 7:46 PM, Andrew Rybchenko wrote:
>> Missing parenthesis around expression before type cast to struct
>> virtio_net_hdr pointer makes the arithmetic to be in
>> sizeof(struct virtio_net_hdr) units.
>>
>> Use rte_pktmbuf_mtod_offset() to fix the problem.
>>
>> Type of head_size is changed to signed since some compilers bark
>> on unary minus applied to unsigned.
>>
>> Fixes: 1ae55ad38e5e ("net/virtio: fix mbuf data and packet length mismatch")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
>> ---
>> drivers/net/virtio/virtio_rxtx.c | 24 ++++++++++++------------
>> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> Thanks Andrew!
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>
> Ferruh, do you want to apply it directly for -rc1?
>
Yep, I will get directly to next-net.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] net/virtio: fix broken Tx checksum offloads
2019-10-25 8:30 ` Maxime Coquelin
2019-10-25 8:48 ` Maxime Coquelin
2019-10-25 10:22 ` Ferruh Yigit
@ 2019-10-25 14:41 ` Ferruh Yigit
2 siblings, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2019-10-25 14:41 UTC (permalink / raw)
To: Maxime Coquelin, Andrew Rybchenko, Tiwei Bie, Zhihong Wang; +Cc: dev, stable
On 10/25/2019 9:30 AM, Maxime Coquelin wrote:
>
>
> On 10/24/19 7:46 PM, Andrew Rybchenko wrote:
>> Missing parenthesis around expression before type cast to struct
>> virtio_net_hdr pointer makes the arithmetic to be in
>> sizeof(struct virtio_net_hdr) units.
>>
>> Use rte_pktmbuf_mtod_offset() to fix the problem.
>>
>> Type of head_size is changed to signed since some compilers bark
>> on unary minus applied to unsigned.
>>
>> Fixes: 1ae55ad38e5e ("net/virtio: fix mbuf data and packet length mismatch")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
>> ---
>> drivers/net/virtio/virtio_rxtx.c | 24 ++++++++++++------------
>> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> Thanks Andrew!
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>
Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-10-25 14:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-24 17:46 [dpdk-dev] [PATCH] net/virtio: fix broken Tx checksum offloads Andrew Rybchenko
2019-10-25 6:37 ` Tiwei Bie
2019-10-25 8:30 ` Maxime Coquelin
2019-10-25 8:48 ` Maxime Coquelin
2019-10-25 10:22 ` Ferruh Yigit
2019-10-25 14:41 ` Ferruh Yigit
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).