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 F3AA7A0093 for ; Thu, 12 May 2022 03:11:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB2A6427F2; Thu, 12 May 2022 03:11:04 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 8353F40E64; Thu, 12 May 2022 03:11:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652317863; x=1683853863; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ef82Gr1uoHvTC5628T9epGEleAO08R/pe6zV7er4J8k=; b=SvIzptY9oc0FDKTV1ermOcmTVc8VWcGj2UUWGTIAftlYqcplX6HFD43w KHm0yq0qFUPDFEW+BfqR6iJ9Ts1jeV+tSZahEjH9pxgY6uCvlHiuAserc iJ6DhRCN1aEGlvODlF6sXiRpXoBj5s2+C3r6j+lXQ9fKFvvQYLCLc2HWI pDAlkxpTSyn+V6vj4RzRkrPybjo+1TtlIn9CgLE7gt2nvl57BIoOtB+lO GLpga1cUO6QjMk0OOqZQKo0uhT7R/Td2ddab45JwfoP+dPmuH/lOa7nEZ GZ9lFGJbfTd+24dEVwg120+fj2MeAQyHDyj45BmZs5dBcX0o44hBqEklo A==; X-IronPort-AV: E=McAfee;i="6400,9594,10344"; a="249750324" X-IronPort-AV: E=Sophos;i="5.91,218,1647327600"; d="scan'208";a="249750324" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2022 18:11:01 -0700 X-IronPort-AV: E=Sophos;i="5.91,218,1647327600"; d="scan'208";a="658392564" Received: from unknown (HELO localhost.localdomain) ([10.239.251.251]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2022 18:10:58 -0700 From: Wenwu Ma To: xiaoyun.li@intel.com, aman.deep.singh@intel.com, yuying.zhang@intel.com, dev@dpdk.org Cc: jiayu.hu@intel.com, yinan.wang@intel.com, xingguang.he@intel.com, Wenwu Ma , stable@dpdk.org Subject: [PATCH v3] app/testpmd: perform SW IP checksum for GRO/GSO packets Date: Thu, 12 May 2022 01:07:56 +0000 Message-Id: <20220512010756.29553-1-wenwux.ma@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220511013705.24602-1-wenwux.ma@intel.com> References: <20220511013705.24602-1-wenwux.ma@intel.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 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. This patch add the code about it. Fixes: b7091f1dcfbc ("app/testpmd: enable the heavyweight mode TCP/IPv4 GRO") Fixes: 52f38a2055ed ("app/testpmd: enable TCP/IPv4 VxLAN and GRE GSO") Cc: stable@dpdk.org Signed-off-by: Wenwu Ma --- app/test-pmd/csumonly.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 8b6665d6f3..2498ee88a2 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -778,6 +778,28 @@ pkt_copy_split(const struct rte_mbuf *pkt) return md[0]; } +#if defined(RTE_LIB_GRO) || defined(RTE_LIB_GSO) +/* + * 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 & RTE_MBUF_F_TX_IPV4) && + (tx_offloads & RTE_ETH_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); + } + } +} +#endif + /* * Receive a burst of packets, and for each packet: * - parse packet, and try to recognize a supported packet type (1) @@ -1098,6 +1120,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) fs->gro_times = 0; } } + + pkts_ip_csum_recalc(pkts_burst, nb_rx, tx_offloads); } #endif @@ -1131,6 +1155,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); } else #endif tx_pkts_burst = pkts_burst; -- 2.25.1