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 07045454E9 for ; Tue, 25 Jun 2024 02:01:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F35B041141; Tue, 25 Jun 2024 02:01:15 +0200 (CEST) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by mails.dpdk.org (Postfix) with ESMTP id 5967540EDD for ; Tue, 25 Jun 2024 02:01:14 +0200 (CEST) Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-42198492353so41512735e9.1 for ; Mon, 24 Jun 2024 17:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719273674; x=1719878474; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nPPw+x+ZAu7zp03MTvl0QsQzWsyEdJwHlQghq4A7H1w=; b=YloM3d164Oy4vvwcMqTSWOllmYg7bv7A/ls0XlsUxrAIkGilQMDw1JLoXaWZzDlhWd TxAKTiNcBSgJZIWmF6XwHXZLKk3wfZq04NvcxhNXuKnm8chAGhMdSjp+bE7AFSpUKbin dpRaL80zt7KLXYn+EvRYT2pOwQ7X5QLGquCygKFhhXKSb2O56qEuw+cUnsa7TNkRNISq 3H3yIxrKYlhfVnKX9JAS+QzRRUAG/CAQBL0QviGNdig5HrihWtCdg9OFLlrVONJT3Vro ZstBQV6RwpK00zHn3rPOGVGTfg6d7XlQx4l4PcDtoJGuTAxn5P71s9CLeVzGRWD/pLae UsJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719273674; x=1719878474; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nPPw+x+ZAu7zp03MTvl0QsQzWsyEdJwHlQghq4A7H1w=; b=RJwocu6lWZLu2bQXbUMx8SthecrN0QpG3XDHUqsanu+hOokzx+esvU8VX5hm6kVsso 09Ws1d5tAGxmBtYP1vstZlJqkoLRo2V6qRr1hb417ePAtP+ekz7R5LnJm4ToaijaRZVh Sj6GqNr8hKSDv6pIz0PFsFwYARX6X83V4oWVVoRi8QHR2LW8qrYLpsZJnHPbMjlwwB2j ZiNm83+MEu7Vorm9HQoARlWVBXpUuL48wf4fBgs6MsBJbGgCDFn31XKGnGHxAmi1ztlU GLtLUf9weZmB5J7iuCusPaZdxq9g3fm61vsSxCW+5oSvlilG2KFtdpueSd+YIFsSHkQO iARA== X-Forwarded-Encrypted: i=1; AJvYcCVuRvzrWeYZQ/RNrjYoQmnGuPz2HhoyM0m0vRN6JBDi2TBQbxAdb4SxBt39w8JRLnKqB7k2zTwSL9/fEhxDgDo= X-Gm-Message-State: AOJu0YxshYAP23XmLl990PLTfSUmQDEKwtwmuAYHL28aPet8blJxIgK9 zTPTtG3mDoyQd/u17aiL4HrWhY0Wffrdv/HpybGTbHjjDNPDym6n X-Google-Smtp-Source: AGHT+IHpisyhe/kWuP3BGUu4ZQZFTULLpi2Huj+SeGQX57aBDJIqLHpEtSYoMNF9i+WYFgaMc68wMA== X-Received: by 2002:a05:6000:1a8d:b0:366:f010:8820 with SMTP id ffacd0b85a97d-366f0108934mr3627884f8f.10.1719273673878; Mon, 24 Jun 2024 17:01:13 -0700 (PDT) Received: from localhost ([137.220.120.171]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3663a2f8268sm11294609f8f.79.2024.06.24.17.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 17:01:13 -0700 (PDT) From: luca.boccassi@gmail.com To: David Marchand Cc: Ali Alnubani , dpdk stable Subject: patch 'net: fix outer UDP checksum in Intel prepare helper' has been queued to stable release 22.11.6 Date: Tue, 25 Jun 2024 00:58:23 +0100 Message-Id: <20240624235907.885628-37-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624235907.885628-1-luca.boccassi@gmail.com> References: <20240624235907.885628-1-luca.boccassi@gmail.com> 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 Hi, FYI, your patch has been queued to stable release 22.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/27/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/b5fc38d53c9b4f682e0dd433063db14faaa6ae63 Thanks. Luca Boccassi --- >From b5fc38d53c9b4f682e0dd433063db14faaa6ae63 Mon Sep 17 00:00:00 2001 From: David Marchand Date: Thu, 18 Apr 2024 10:20:18 +0200 Subject: [PATCH] net: fix outer UDP checksum in Intel prepare helper [ upstream commit f876dbef080932dbeb1de075d7ca3cbe2ed6d7eb ] Setting a pseudo header checksum in the outer UDP checksum is a Intel (and some other vendors) requirement. Applications (like OVS) requesting outer UDP checksum without doing this extra setup have broken outer UDP checksums. Move this specific setup from testpmd to the "common" helper rte_net_intel_cksum_flags_prepare(). net/hns3 can then be adjusted. Bugzilla ID: 1406 Fixes: d8e5e69f3a9b ("app/testpmd: add GTP parsing and Tx checksum offload") Signed-off-by: David Marchand Tested-by: Ali Alnubani --- app/test-pmd/csumonly.c | 11 +---- drivers/net/hns3/hns3_rxtx.c | 93 ++++++++++-------------------------- lib/net/rte_net.h | 17 ++++++- 3 files changed, 43 insertions(+), 78 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index bfe1fc3ddc..161bbd4e14 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -568,8 +568,6 @@ static uint64_t process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, uint64_t tx_offloads, int tso_enabled, struct rte_mbuf *m) { - struct rte_ipv4_hdr *ipv4_hdr = outer_l3_hdr; - struct rte_ipv6_hdr *ipv6_hdr = outer_l3_hdr; struct rte_udp_hdr *udp_hdr; uint64_t ol_flags = 0; @@ -579,6 +577,8 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, if (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) { ol_flags |= RTE_MBUF_F_TX_OUTER_IP_CKSUM; } else { + struct rte_ipv4_hdr *ipv4_hdr = outer_l3_hdr; + ipv4_hdr->hdr_checksum = 0; ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); } @@ -597,13 +597,6 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, /* Skip SW outer UDP checksum generation if HW supports it */ if (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) { - if (info->outer_ethertype == _htons(RTE_ETHER_TYPE_IPV4)) - udp_hdr->dgram_cksum - = rte_ipv4_phdr_cksum(ipv4_hdr, ol_flags); - else - udp_hdr->dgram_cksum - = rte_ipv6_phdr_cksum(ipv6_hdr, ol_flags); - ol_flags |= RTE_MBUF_F_TX_OUTER_UDP_CKSUM; return ol_flags; } diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index c0479a44dc..4343a3e4df 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -3627,58 +3627,6 @@ hns3_pkt_need_linearized(struct rte_mbuf *tx_pkts, uint32_t bd_num, return false; } -static bool -hns3_outer_ipv4_cksum_prepared(struct rte_mbuf *m, uint64_t ol_flags, - uint32_t *l4_proto) -{ - struct rte_ipv4_hdr *ipv4_hdr; - ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, - m->outer_l2_len); - if (ol_flags & RTE_MBUF_F_TX_OUTER_IP_CKSUM) - ipv4_hdr->hdr_checksum = 0; - if (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM) { - struct rte_udp_hdr *udp_hdr; - /* - * If OUTER_UDP_CKSUM is support, HW can calculate the pseudo - * header for TSO packets - */ - if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) - return true; - udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, - m->outer_l2_len + m->outer_l3_len); - udp_hdr->dgram_cksum = rte_ipv4_phdr_cksum(ipv4_hdr, ol_flags); - - return true; - } - *l4_proto = ipv4_hdr->next_proto_id; - return false; -} - -static bool -hns3_outer_ipv6_cksum_prepared(struct rte_mbuf *m, uint64_t ol_flags, - uint32_t *l4_proto) -{ - struct rte_ipv6_hdr *ipv6_hdr; - ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, - m->outer_l2_len); - if (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM) { - struct rte_udp_hdr *udp_hdr; - /* - * If OUTER_UDP_CKSUM is support, HW can calculate the pseudo - * header for TSO packets - */ - if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) - return true; - udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, - m->outer_l2_len + m->outer_l3_len); - udp_hdr->dgram_cksum = rte_ipv6_phdr_cksum(ipv6_hdr, ol_flags); - - return true; - } - *l4_proto = ipv6_hdr->proto; - return false; -} - static void hns3_outer_header_cksum_prepare(struct rte_mbuf *m) { @@ -3686,29 +3634,38 @@ hns3_outer_header_cksum_prepare(struct rte_mbuf *m) uint32_t paylen, hdr_len, l4_proto; struct rte_udp_hdr *udp_hdr; - if (!(ol_flags & (RTE_MBUF_F_TX_OUTER_IPV4 | RTE_MBUF_F_TX_OUTER_IPV6))) + if (!(ol_flags & (RTE_MBUF_F_TX_OUTER_IPV4 | RTE_MBUF_F_TX_OUTER_IPV6)) && + ((ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM) || + !(ol_flags & RTE_MBUF_F_TX_TCP_SEG))) return; if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV4) { - if (hns3_outer_ipv4_cksum_prepared(m, ol_flags, &l4_proto)) - return; + struct rte_ipv4_hdr *ipv4_hdr; + + ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, + m->outer_l2_len); + l4_proto = ipv4_hdr->next_proto_id; } else { - if (hns3_outer_ipv6_cksum_prepared(m, ol_flags, &l4_proto)) - return; + struct rte_ipv6_hdr *ipv6_hdr; + + ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, + m->outer_l2_len); + l4_proto = ipv6_hdr->proto; } + if (l4_proto != IPPROTO_UDP) + return; + /* driver should ensure the outer udp cksum is 0 for TUNNEL TSO */ - if (l4_proto == IPPROTO_UDP && (ol_flags & RTE_MBUF_F_TX_TCP_SEG)) { - hdr_len = m->l2_len + m->l3_len + m->l4_len; - hdr_len += m->outer_l2_len + m->outer_l3_len; - paylen = m->pkt_len - hdr_len; - if (paylen <= m->tso_segsz) - return; - udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, - m->outer_l2_len + - m->outer_l3_len); - udp_hdr->dgram_cksum = 0; - } + hdr_len = m->l2_len + m->l3_len + m->l4_len; + hdr_len += m->outer_l2_len + m->outer_l3_len; + paylen = m->pkt_len - hdr_len; + if (paylen <= m->tso_segsz) + return; + udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, + m->outer_l2_len + + m->outer_l3_len); + udp_hdr->dgram_cksum = 0; } static int diff --git a/lib/net/rte_net.h b/lib/net/rte_net.h index 56611fc8f9..a94f6af717 100644 --- a/lib/net/rte_net.h +++ b/lib/net/rte_net.h @@ -121,7 +121,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) * no offloads are requested. */ if (!(ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_L4_MASK | RTE_MBUF_F_TX_TCP_SEG | - RTE_MBUF_F_TX_OUTER_IP_CKSUM))) + RTE_MBUF_F_TX_OUTER_IP_CKSUM | RTE_MBUF_F_TX_OUTER_UDP_CKSUM))) return 0; if (ol_flags & (RTE_MBUF_F_TX_OUTER_IPV4 | RTE_MBUF_F_TX_OUTER_IPV6)) { @@ -135,6 +135,21 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) struct rte_ipv4_hdr *, m->outer_l2_len); ipv4_hdr->hdr_checksum = 0; } + if (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM) { + if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV4) { + ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, + m->outer_l2_len); + udp_hdr = (struct rte_udp_hdr *)((char *)ipv4_hdr + + m->outer_l3_len); + udp_hdr->dgram_cksum = rte_ipv4_phdr_cksum(ipv4_hdr, m->ol_flags); + } else { + ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, + m->outer_l2_len); + udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, + m->outer_l2_len + m->outer_l3_len); + udp_hdr->dgram_cksum = rte_ipv6_phdr_cksum(ipv6_hdr, m->ol_flags); + } + } } /* -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-06-25 00:22:15.829676123 +0100 +++ 0037-net-fix-outer-UDP-checksum-in-Intel-prepare-helper.patch 2024-06-25 00:22:13.137184670 +0100 @@ -1 +1 @@ -From f876dbef080932dbeb1de075d7ca3cbe2ed6d7eb Mon Sep 17 00:00:00 2001 +From b5fc38d53c9b4f682e0dd433063db14faaa6ae63 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit f876dbef080932dbeb1de075d7ca3cbe2ed6d7eb ] + @@ -18 +19,0 @@ -Cc: stable@dpdk.org @@ -25,2 +26,2 @@ - lib/net/rte_net.h | 18 ++++++- - 3 files changed, 44 insertions(+), 78 deletions(-) + lib/net/rte_net.h | 17 ++++++- + 3 files changed, 43 insertions(+), 78 deletions(-) @@ -29 +30 @@ -index f5125c2788..71add6ca47 100644 +index bfe1fc3ddc..161bbd4e14 100644 @@ -32 +33 @@ -@@ -577,8 +577,6 @@ static uint64_t +@@ -568,8 +568,6 @@ static uint64_t @@ -41 +42 @@ -@@ -588,6 +586,8 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, +@@ -579,6 +577,8 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, @@ -50 +51 @@ -@@ -608,13 +608,6 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, +@@ -597,13 +597,6 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, @@ -65 +66 @@ -index bf10da1928..59a95aba7c 100644 +index c0479a44dc..4343a3e4df 100644 @@ -68 +69 @@ -@@ -3629,58 +3629,6 @@ hns3_pkt_need_linearized(struct rte_mbuf *tx_pkts, uint32_t bd_num, +@@ -3627,58 +3627,6 @@ hns3_pkt_need_linearized(struct rte_mbuf *tx_pkts, uint32_t bd_num, @@ -127 +128 @@ -@@ -3688,29 +3636,38 @@ hns3_outer_header_cksum_prepare(struct rte_mbuf *m) +@@ -3686,29 +3634,38 @@ hns3_outer_header_cksum_prepare(struct rte_mbuf *m) @@ -183 +184 @@ -index ef3ff4c6fd..efd9d5f5ee 100644 +index 56611fc8f9..a94f6af717 100644 @@ -186 +187 @@ -@@ -121,7 +121,8 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) +@@ -121,7 +121,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) @@ -190,3 +191,2 @@ -- RTE_MBUF_F_TX_UDP_SEG | RTE_MBUF_F_TX_OUTER_IP_CKSUM))) -+ RTE_MBUF_F_TX_UDP_SEG | RTE_MBUF_F_TX_OUTER_IP_CKSUM | -+ RTE_MBUF_F_TX_OUTER_UDP_CKSUM))) +- RTE_MBUF_F_TX_OUTER_IP_CKSUM))) ++ RTE_MBUF_F_TX_OUTER_IP_CKSUM | RTE_MBUF_F_TX_OUTER_UDP_CKSUM))) @@ -196 +196 @@ -@@ -135,6 +136,21 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) +@@ -135,6 +135,21 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags)