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 504E2A0C4B for ; Thu, 16 Sep 2021 20:50:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C89B410E9; Thu, 16 Sep 2021 20:50:05 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 5708C4069E; Thu, 16 Sep 2021 20:50:03 +0200 (CEST) Received: from localhost.localdomain (unknown [5.144.123.201]) (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 ESMTPSA id 7E08F7F523; Thu, 16 Sep 2021 21:50:02 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 7E08F7F523 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1631818202; bh=weEdnzMssv2SvwByixMTR6elNhpRNCe7LWnSQTlJrLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qKgpD0yPmvZh9Z0yxfY9byG5U4aIvdhQ35trsiK+L3wNCRSoMVE283P2dUlsMOx5j W09Rwv2CE/K0mWFI25Ij3D10otqs2e5S6sQLAoyIcF/L949DmkemmRtuqk1mn1tRLg sntbQ2Hp/1SAgrKa230VHkS7vB9EIomjDB3uGRL0= From: Ivan Malov To: dev@dpdk.org Cc: Maxime Coquelin , stable@dpdk.org, Andrew Rybchenko , Chenbo Xia , Yuanhan Liu , Olivier Matz Date: Thu, 16 Sep 2021 21:49:55 +0300 Message-Id: <20210916184955.2755-1-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210830142655.18373-1-ivan.malov@oktetlabs.ru> References: <20210830142655.18373-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH v2] net/virtio: handle Tx checksums correctly for tunnel packets 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 Sender: "stable" 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") Cc: stable@dpdk.org Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko --- 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