patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Ivan Malov <ivan.malov@oktetlabs.ru>
To: stable@dpdk.org
Cc: Xueming Li <xuemingl@nvidia.com>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	Chenbo Xia <chenbo.xia@intel.com>,
	Olivier Matz <olivier.matz@6wind.com>,
	Maxime Coquelin <maxime.coquelin@redhat.com>,
	Yuanhan Liu <yuanhan.liu@linux.intel.com>
Subject: [PATCH 20.11] net/virtio: fix Tx checksum for tunnel packets
Date: Tue, 16 Nov 2021 19:34:19 +0300	[thread overview]
Message-ID: <20211116163419.17940-1-ivan.malov@oktetlabs.ru> (raw)

[ 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


             reply	other threads:[~2021-11-16 16:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-16 16:34 Ivan Malov [this message]
2021-11-27 14:41 ` Xueming(Steven) Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211116163419.17940-1-ivan.malov@oktetlabs.ru \
    --to=ivan.malov@oktetlabs.ru \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=chenbo.xia@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=olivier.matz@6wind.com \
    --cc=stable@dpdk.org \
    --cc=xuemingl@nvidia.com \
    --cc=yuanhan.liu@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).