From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A0AFEA0032 for ; Tue, 16 Nov 2021 17:34:23 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F9F6411AB; Tue, 16 Nov 2021 17:34:23 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 2378B411AB for ; Tue, 16 Nov 2021 17:34:22 +0100 (CET) Received: from bree.oktetlabs.ru (bree.oktetlabs.ru [192.168.34.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPS id A7F6B7F50B; Tue, 16 Nov 2021 19:34:21 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru A7F6B7F50B Authentication-Results: shelob.oktetlabs.ru/A7F6B7F50B; dkim=none; dkim-atps=neutral From: Ivan Malov To: stable@dpdk.org Cc: Xueming Li , Andrew Rybchenko , Chenbo Xia , Olivier Matz , Maxime Coquelin , Yuanhan Liu Subject: [PATCH 20.11] net/virtio: fix Tx checksum for tunnel packets Date: Tue, 16 Nov 2021 19:34:19 +0300 Message-Id: <20211116163419.17940-1-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ 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 Reviewed-by: Andrew Rybchenko Reviewed-by: Chenbo Xia Reviewed-by: Olivier Matz --- 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