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 A8215A0032; Wed, 11 May 2022 03:40:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4CAAE406B4; Wed, 11 May 2022 03:40:11 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 5EF5B4067E for ; Wed, 11 May 2022 03:40:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652233209; x=1683769209; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=/kGeUeCiL0a2He5tciLr9y7LOt1OBu6wGWaazP3wzOQ=; b=A4YlJX9Ypl4obIzNfeZPM1221tup1hrm9jMZM4O8ZlX/6vFnC/UO6UdT HmUNgmt4MWXrYavXIUL4+28M7upnofwJg+U1j3RmOi61UUqYQ2vHksqMB FL56OgTRPnv9G/lDtMbOLroHzDuhAitIsJrhoJibqJflm287CxU8nqSrF JPErsaeg3vt9MAvvmK4MQuafBf2XmWmCudBF0xJKhIIaVCjCXheayzVRH lV7Ea7GfNPuFZbWAKZIsJlM63eMnQFTdC96Sby2koQpxT0TXwk9Gqa6wT gXxxfeTSdXeq4D1eTajEu0zBq9jaJ33xNAj15Wg8todIT9jtfJUBECmKB Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10343"; a="250084297" X-IronPort-AV: E=Sophos;i="5.91,215,1647327600"; d="scan'208";a="250084297" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2022 18:40:08 -0700 X-IronPort-AV: E=Sophos;i="5.91,215,1647327600"; d="scan'208";a="593850888" Received: from unknown (HELO localhost.localdomain) ([10.239.251.251]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2022 18:40:05 -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 Subject: [PATCH] app/testpmd: perform SW IP checksum for GRO packets Date: Wed, 11 May 2022 01:37:05 +0000 Message-Id: <20220511013705.24602-1-wenwux.ma@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 GRO library doesn't re-calculate checksums for merged packets. If users want the merged packets to have correct IP checksums, they should select HW IP checksum calculation for the port which the merged 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. Signed-off-by: Wenwu Ma --- app/test-pmd/csumonly.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 8b6665d6f3..76ce58f6d0 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -824,6 +824,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) void **gro_ctx; uint16_t gro_pkts_num; uint8_t gro_enable; + struct rte_ipv4_hdr *ipv4_hdr; #endif uint16_t nb_rx; uint16_t nb_tx; @@ -1098,6 +1099,17 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) fs->gro_times = 0; } } + + for (i = 0; i < nb_rx; 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 -- 2.25.1