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 9F09C432C0; Tue, 7 Nov 2023 05:11:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 267BD40698; Tue, 7 Nov 2023 05:11:07 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id F2176402A1 for ; Tue, 7 Nov 2023 05:11:03 +0100 (CET) Received: from kwepemm000004.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SPZWz1VL4zvQBm; Tue, 7 Nov 2023 12:10:55 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by kwepemm000004.china.huawei.com (7.193.23.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 7 Nov 2023 12:11:02 +0800 From: Huisong Li To: , Aman Singh , Yuying Zhang , Zhichao Zeng CC: , , Subject: [PATCH v3 2/2] app/testpmd: fix UDP cksum error for UFO enable Date: Tue, 7 Nov 2023 12:11:17 +0800 Message-ID: <20231107041117.23285-3-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20231107041117.23285-1-lihuisong@huawei.com> References: <20230728021310.15970-1-lihuisong@huawei.com> <20231107041117.23285-1-lihuisong@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm000004.china.huawei.com (7.193.23.18) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The command "tso set " is used to enable UFO, please see commit ce8e6e742807 ("app/testpmd: support UFO in checksum engine") The above patch sets the RTE_MBUF_F_TX_UDP_SEG in mbuf ol_flags, only by checking if 'tso_segsz' is set, but missing check if UFO offload (RTE_ETH_TX_OFFLOAD_UDP_TSO) supported by device. The RTE_MBUF_F_TX_UDP_SEG flag causes driver that supports TSO to compute pseudo header checksum. As a result, if device only supports TSO, but not UFO, UDP packet checksum will be wrong. So enabling UFO also depends on if driver has RTE_ETH_TX_OFFLOAD_UDP_TSO capability. Similarly, TSO also need to do like this. Note: all offloads about tunnel TSO are added in process_inner_cksums() in case of the impact on tunnel TSO. In addition, this patch also fixes cmd_tso_set_parsed() for UFO to make it better to support TSO and UFO. Fixes: ce8e6e742807 ("app/testpmd: support UFO in checksum engine") Cc: stable@dpdk.org Signed-off-by: Huisong Li Acked-by: Chengwen Feng --- app/test-pmd/cmdline.c | 31 +++++++++++++++++++++---------- app/test-pmd/csumonly.c | 11 +++++++++-- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 1c57e07d41..05078f8377 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -4933,6 +4933,7 @@ cmd_tso_set_parsed(void *parsed_result, { struct cmd_tso_set_result *res = parsed_result; struct rte_eth_dev_info dev_info; + uint64_t offloads; int ret; if (port_id_is_invalid(res->port_id, ENABLED_WARN)) @@ -4949,21 +4950,31 @@ cmd_tso_set_parsed(void *parsed_result, if (ret != 0) return; - if ((ports[res->port_id].tso_segsz != 0) && - (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) { - fprintf(stderr, "Error: TSO is not supported by port %d\n", - res->port_id); - return; + if (ports[res->port_id].tso_segsz != 0) { + if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO | + RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) { + fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n", + res->port_id); + return; + } + /* display warnings if configuration is not supported by the NIC */ + if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) + printf("Warning: port %d doesn't support TSO\n", res->port_id); + if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0) + printf("Warning: port %d doesn't support UFO\n", res->port_id); } if (ports[res->port_id].tso_segsz == 0) { ports[res->port_id].dev_conf.txmode.offloads &= - ~RTE_ETH_TX_OFFLOAD_TCP_TSO; - printf("TSO for non-tunneled packets is disabled\n"); + ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO); + printf("TSO and UFO for non-tunneled packets is disabled\n"); } else { - ports[res->port_id].dev_conf.txmode.offloads |= - RTE_ETH_TX_OFFLOAD_TCP_TSO; - printf("TSO segment size for non-tunneled packets is %d\n", + offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ? + RTE_ETH_TX_OFFLOAD_TCP_TSO : 0; + offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ? + RTE_ETH_TX_OFFLOAD_UDP_TSO : 0; + ports[res->port_id].dev_conf.txmode.offloads |= offloads; + printf("segment size for non-tunneled packets is %d\n", ports[res->port_id].tso_segsz); } cmd_config_queue_tx_offloads(&ports[res->port_id]); diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index c103e54111..21210aff43 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -466,6 +466,12 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, uint64_t ol_flags = 0; uint32_t max_pkt_len, tso_segsz = 0; uint16_t l4_off; + uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO | + RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO | + RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO | + RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO | + RTE_ETH_TX_OFFLOAD_IP_TNL_TSO | + RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO; /* ensure packet is large enough to require tso */ if (!info->is_tunnel) { @@ -505,7 +511,7 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, udp_hdr = (struct rte_udp_hdr *)((char *)l3_hdr + info->l3_len); /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { - if (tso_segsz) + if (tso_segsz && (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_TSO)) ol_flags |= RTE_MBUF_F_TX_UDP_SEG; else if (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) { ol_flags |= RTE_MBUF_F_TX_UDP_CKSUM; @@ -528,7 +534,8 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, #endif } else if (info->l4_proto == IPPROTO_TCP) { tcp_hdr = (struct rte_tcp_hdr *)((char *)l3_hdr + info->l3_len); - if (tso_segsz) + if (tso_segsz && + (tx_offloads & (RTE_ETH_TX_OFFLOAD_TCP_TSO | all_tunnel_tso))) ol_flags |= RTE_MBUF_F_TX_TCP_SEG; else if (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) { ol_flags |= RTE_MBUF_F_TX_TCP_CKSUM; -- 2.33.0