All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Malov <ivan.malov@oktetlabs.ru>
To: dev@dpdk.org
Cc: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	Maxime Coquelin <maxime.coquelin@redhat.com>,
	Chenbo Xia <chenbo.xia@intel.com>
Subject: [dpdk-dev] [PATCH] net/virtio: handle Tx checksums correctly for tunnel packets
Date: Mon, 30 Aug 2021 17:26:55 +0300	[thread overview]
Message-ID: <20210830142655.18373-1-ivan.malov@oktetlabs.ru> (raw)

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.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/net/virtio/virtqueue.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
index 03957b2bd0..b83ff32efb 100644
--- a/drivers/net/virtio/virtqueue.h
+++ b/drivers/net/virtio/virtqueue.h
@@ -620,19 +620,21 @@ static inline void
 virtqueue_xmit_offload(struct virtio_net_hdr *hdr, struct rte_mbuf *cookie)
 {
 	uint64_t csum_l4 = cookie->ol_flags & PKT_TX_L4_MASK;
+	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)
 		csum_l4 |= PKT_TX_TCP_CKSUM;
 
 	switch (csum_l4) {
 	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;
@@ -650,7 +652,8 @@ virtqueue_xmit_offload(struct virtio_net_hdr *hdr, struct rte_mbuf *cookie)
 			VIRTIO_NET_HDR_GSO_TCPV6 :
 			VIRTIO_NET_HDR_GSO_TCPV4;
 		hdr->gso_size = cookie->tso_segsz;
-		hdr->hdr_len = cookie->l2_len + cookie->l3_len + cookie->l4_len;
+		hdr->hdr_len = o_l23_len + cookie->l2_len + cookie->l3_len +
+			       cookie->l4_len;
 	} else {
 		ASSIGN_UNLESS_EQUAL(hdr->gso_type, 0);
 		ASSIGN_UNLESS_EQUAL(hdr->gso_size, 0);
-- 
2.20.1


             reply	other threads:[~2021-08-30 14:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30 14:26 Ivan Malov [this message]
2021-09-13 20:06 ` [dpdk-dev] [PATCH] net/virtio: handle Tx checksums correctly for tunnel packets Maxime Coquelin
2021-09-16 18:49 ` [dpdk-dev] [PATCH v2] " Ivan Malov
2021-10-14  6:45   ` Andrew Rybchenko
2021-10-14  7:12   ` Xia, Chenbo
2021-10-15  8:32     ` Olivier Matz
2021-10-18  7:04       ` Andrew Rybchenko
2021-10-18  7:54         ` Olivier Matz
2021-10-18  8:20           ` Andrew Rybchenko
2021-10-21 12:28   ` Maxime Coquelin

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=20210830142655.18373-1-ivan.malov@oktetlabs.ru \
    --to=ivan.malov@oktetlabs.ru \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.