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 57753A0543 for ; Fri, 8 Jul 2022 04:58:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4EDB140041; Fri, 8 Jul 2022 04:58:29 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id B4E2F40041 for ; Fri, 8 Jul 2022 04:58:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657249107; x=1688785107; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=mMbyKlwOtRVKflz6EHxYIgZwEWv/p9YztLewN+MG0Ak=; b=aeSh5H+hciAszhp4TswvJis+U3sxFi61vuSgYgAHRjikj8Z9PaXRSecL UfIlT9y6I43M9mjmAsqAiYLHA9fnp1SFeUkVydNlEslYFhldd7NXCeBOH 1NMnRVV8WGQq0PNBLbKXIMYrX7562Bkq0DxCv4j3wGPjSg2QJKV9YudjU ywmDsTtMOCJ04YYRzAlVLjt1V0LYzHd9J115KoM0sxlEzBuPvZmgr15c9 yS+Xf2rnQaiphBYuyeOHOJ4VW2Y/vzGbfwvcRWSm2pW0EqItt/6UK/y0O s9Dpy/Zq4zem5zppJixUGVVV2Mdwy2xb2mOsMWuKhQ7goE1hfW7Zv7iw5 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10401"; a="370487997" X-IronPort-AV: E=Sophos;i="5.92,254,1650956400"; d="scan'208";a="370487997" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2022 19:58:26 -0700 X-IronPort-AV: E=Sophos;i="5.92,254,1650956400"; d="scan'208";a="621042188" Received: from unknown (HELO localhost.localdomain) ([10.239.252.251]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2022 19:58:24 -0700 From: Wenwu Ma To: stable@dpdk.org Cc: Wenwu Ma , Jiayu Hu , Wei Ling , Yuying Zhang Subject: [PATCH 19.11] app/testpmd: perform SW IP checksum for GRO/GSO packets Date: Fri, 8 Jul 2022 10:53:43 +0800 Message-Id: <20220708025343.344065-1-wenwux.ma@intel.com> X-Mailer: git-send-email 2.25.1 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 1945c64674b2b9ad55af0ef31f8a02ae0b747400 The GRO/GSO library doesn't re-calculate checksums for merged/fragmented packets. If users want the packets to have correct IP checksums, they should select HW IP checksum calculation for the port which the packets are transmitted to. But if the port doesn't support HW IP checksum, users may perform a SW IP checksum. Fixes: b7091f1dcfbc ("app/testpmd: enable the heavyweight mode TCP/IPv4 GRO") Fixes: 52f38a2055ed ("app/testpmd: enable TCP/IPv4 VxLAN and GRE GSO") Signed-off-by: Wenwu Ma Reviewed-by: Jiayu Hu Tested-by: Wei Ling Acked-by: Yuying Zhang --- app/test-pmd/csumonly.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 25091de881..117f14451d 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -731,6 +731,26 @@ pkt_copy_split(const struct rte_mbuf *pkt) return md[0]; } +/* + * Re-calculate IP checksum for merged/fragmented packets. + */ +static void +pkts_ip_csum_recalc(struct rte_mbuf **pkts_burst, const uint16_t nb_pkts, uint64_t tx_offloads) +{ + int i; + struct rte_ipv4_hdr *ipv4_hdr; + for (i = 0; i < nb_pkts; i++) { + if ((pkts_burst[i]->ol_flags & PKT_TX_IPV4) && + (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { + ipv4_hdr = rte_pktmbuf_mtod_offset(pkts_burst[i], + struct rte_ipv4_hdr *, + pkts_burst[i]->l2_len); + ipv4_hdr->hdr_checksum = 0; + ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); + } + } +} + /* * Receive a burst of packets, and for each packet: * - parse packet, and try to recognize a supported packet type (1) @@ -1038,6 +1058,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) fs->gro_times = 0; } } + + pkts_ip_csum_recalc(pkts_burst, nb_rx, tx_offloads); } if (gso_ports[fs->tx_port].enable == 0) @@ -1059,6 +1081,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) tx_pkts_burst = gso_segments; nb_rx = nb_segments; + + pkts_ip_csum_recalc(tx_pkts_burst, nb_rx, tx_offloads); } nb_prep = rte_eth_tx_prepare(fs->tx_port, fs->tx_queue, -- 2.25.1