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
  0 siblings, 0 replies; only message 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] only message in thread

only message in thread, other threads:[~2021-11-16 16:34 UTC | newest]

Thread overview: (only message) (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

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git