patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 20.11] net/virtio: fix Tx checksum for tunnel packets
@ 2021-11-16 16:34 Ivan Malov
  2021-11-27 14:41 ` Xueming(Steven) Li
  0 siblings, 1 reply; 2+ messages in thread
From: Ivan Malov @ 2021-11-16 16:34 UTC (permalink / raw)
  To: stable
  Cc: Xueming Li, Andrew Rybchenko, Chenbo Xia, Olivier Matz,
	Maxime Coquelin, Yuanhan Liu

[ upstream commit 6474b59448700d6ed8c7a0b673ebd1dbb6063ca8 ]

Tx prepare method calls rte_net_intel_cksum_prepare(), which
handles tunnel packets correctly, but Tx burst path does not
take tunnel presence into account when computing the offsets.

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

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/virtio/virtqueue.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
index b812c2882..9a66395b0 100644
--- a/drivers/net/virtio/virtqueue.h
+++ b/drivers/net/virtio/virtqueue.h
@@ -642,19 +642,25 @@ virtqueue_xmit_offload(struct virtio_net_hdr *hdr,
 			bool offload)
 {
 	if (offload) {
+		uint16_t o_l23_len =
+			(cookie->ol_flags & PKT_TX_TUNNEL_MASK) ?
+			cookie->outer_l2_len + cookie->outer_l3_len : 0;
+
 		if (cookie->ol_flags & PKT_TX_TCP_SEG)
 			cookie->ol_flags |= PKT_TX_TCP_CKSUM;
 
 		switch (cookie->ol_flags & PKT_TX_L4_MASK) {
 		case PKT_TX_UDP_CKSUM:
-			hdr->csum_start = cookie->l2_len + cookie->l3_len;
+			hdr->csum_start = o_l23_len +
+					  cookie->l2_len + cookie->l3_len;
 			hdr->csum_offset = offsetof(struct rte_udp_hdr,
 				dgram_cksum);
 			hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
 			break;
 
 		case PKT_TX_TCP_CKSUM:
-			hdr->csum_start = cookie->l2_len + cookie->l3_len;
+			hdr->csum_start = o_l23_len +
+					  cookie->l2_len + cookie->l3_len;
 			hdr->csum_offset = offsetof(struct rte_tcp_hdr, cksum);
 			hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
 			break;
@@ -673,6 +679,7 @@ virtqueue_xmit_offload(struct virtio_net_hdr *hdr,
 				VIRTIO_NET_HDR_GSO_TCPV4;
 			hdr->gso_size = cookie->tso_segsz;
 			hdr->hdr_len =
+				o_l23_len +
 				cookie->l2_len +
 				cookie->l3_len +
 				cookie->l4_len;
-- 
2.30.2


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

* Re: [PATCH 20.11] net/virtio: fix Tx checksum for tunnel packets
  2021-11-16 16:34 [PATCH 20.11] net/virtio: fix Tx checksum for tunnel packets Ivan Malov
@ 2021-11-27 14:41 ` Xueming(Steven) Li
  0 siblings, 0 replies; 2+ messages in thread
From: Xueming(Steven) Li @ 2021-11-27 14:41 UTC (permalink / raw)
  To: ivan.malov, stable
  Cc: chenbo.xia, olivier.matz, andrew.rybchenko, maxime.coquelin, yuanhan.liu

On Tue, 2021-11-16 at 19:34 +0300, Ivan Malov wrote:
> [ upstream commit 6474b59448700d6ed8c7a0b673ebd1dbb6063ca8 ]
> 
> Tx prepare method calls rte_net_intel_cksum_prepare(), which
> handles tunnel packets correctly, but Tx burst path does not
> take tunnel presence into account when computing the offsets.
> 
> Fixes: 58169a9c8153 ("net/virtio: support Tx checksum offload")
> 
> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
> Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
> ---

Applied to 20.11.4 list, thanks!

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

end of thread, other threads:[~2021-11-27 14:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 16:34 [PATCH 20.11] net/virtio: fix Tx checksum for tunnel packets Ivan Malov
2021-11-27 14:41 ` Xueming(Steven) Li

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).