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 C8942A0A0C; Thu, 29 Jul 2021 19:02:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0924040E46; Thu, 29 Jul 2021 19:02:09 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2058.outbound.protection.outlook.com [40.107.212.58]) by mails.dpdk.org (Postfix) with ESMTP id 5245E4067A; Thu, 29 Jul 2021 19:02:07 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h7QLhvT4ZwtxzBGB7GAa/HrhOviDeJoO74SZUbfMCa5w3CTQvkTS43mfhfH33W1QgLQlx651sc1xI2TVwwxe5nMEVIcEXzF10zK/SQTq3//2sw8oTNKEQZSLHoH/iz1QOTa84Pemrf9r6a46WGN6IsBF/fq+BFWuSpWFbE6Pc3aQG1HjfQ1p3T8Qbgen4Z/P0ALfU0OJ9A16hp8n5fPty3DTl+PRzpB8bj2/mDewclxjUb88Id+/dxhI5a8nWs5CNMeu2uNUcUohKvAGD5whIiPpgvAssNjQ82DU78WHgnZWMjlL6c9MBZB+vPjqmkvOs4D1BXxnJ+TB28i3+CfnbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xkn+q3taBAVqMoETvJNgIGsJp6LuYBNt2yKYYyHGxo8=; b=nZRsHg833xn1SpIVO4ryJdW3Jb81AJSHwqUMMzUmwhWLB7jqRlY8DxW1itY45ocFCpKWDaPpkAR1qHepaKjmdLNQqw+1hcIDGnOpetB/TtbYcxqhT+3k6wkWDMux02G7y1GDy0+4Q60glMomKIo9GY2Mp+Wx9o7otddgajKC2DYS95/Xzr97y93m7uxsYULPJ7/F8zY3wkP+BmTjeYGPyyhlZtY6rBoyLWSRuEjinsrJ3kiq9rWtCgCnRaJPLQUcCoPXAFB9r0t8nQUvKKQWdFkbN14/KFn1robd3NGrbrcvk4DoLWYQ2ROOblXtHV61vSPYduMGez3EAEbFmwEG+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xkn+q3taBAVqMoETvJNgIGsJp6LuYBNt2yKYYyHGxo8=; b=JzSQuPHRt8YvItw8eHWCef+7EXO4iR2sgSPwu+AnPAFMeryIboVs8g7kyuD7KAg5BL7ns/5a1rxVPHydsYrQHxz8jd3C73WSGeieKiaO+QGQTx7R4GUNPEih4V2l4x7ONsimCnbbzv3k3HyP/uvZGQq6iQHCF3C2/c0Tb+YHpE2KVvm+Kh4M38txnc+Sbr0r7wsTL5crkbvxVM0blQOsB+ALmhQAIPl6roCwRjV62nfzXRqb0QtT99VBqohOuulsgK46bGlFfX3JINHkqkxoUSTe5l3LCGTsy1wu5fyljBDEcJaO+4pd2llKbzLc86BgfA+sxJCji8ZgAujgVOTo7Q== Received: from BN9PR03CA0463.namprd03.prod.outlook.com (2603:10b6:408:139::18) by DM4PR12MB5296.namprd12.prod.outlook.com (2603:10b6:5:39d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.19; Thu, 29 Jul 2021 17:02:06 +0000 Received: from BN8NAM11FT055.eop-nam11.prod.protection.outlook.com (2603:10b6:408:139:cafe::89) by BN9PR03CA0463.outlook.office365.com (2603:10b6:408:139::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.20 via Frontend Transport; Thu, 29 Jul 2021 17:02:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT055.mail.protection.outlook.com (10.13.177.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4373.18 via Frontend Transport; Thu, 29 Jul 2021 17:02:05 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 29 Jul 2021 17:02:02 +0000 From: Gregory Etelson To: CC: , Ajit Khaparde , "Olivier Matz" , Andrew Rybchenko , Ferruh Yigit , Thomas Monjalon , , Xiaoyun Li , Tomasz Kulasek , Konstantin Ananyev Date: Thu, 29 Jul 2021 20:01:41 +0300 Message-ID: <20210729170141.26563-1-getelson@nvidia.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719083309.15428-1-getelson@nvidia.com> References: <20210719083309.15428-1-getelson@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 080c2024-01c3-40b9-6b15-08d952b2982e X-MS-TrafficTypeDiagnostic: DM4PR12MB5296: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kHQ/yECi4OYn/fp3/WdpG7rPbO4/dGHRvnJkFu5L8SY4AFiaiUZu43KwX8JaoQDrM/zPfCh6CaXofYNb3S4B6WZYMHshSC/vPa3SLSEmm/4AtKIO8+lx5cDmjW7B/SHOX+r9uX+b/uabVMoT3j909O5rZ5Wso1uNc6ZI8JXJxJzE3I/y4UlDrQqpKGeso75T2na7pAASiUjmrNqUfeCXtb2x1+nKYvE8bX6t8wbtYw+oEWOxzH+f3969oalKpxZbD8p7NhKfU2mrZ0mF7PR9lcVII33u4rtNHp0erk3s2hgQ7zKbaRESQ8tSAyikWoyZpFHNggvcv4VEntOAspomk4GQ0pun24WptPSBWj+vVOk5HVjgM2I8naymZqgPLwXCo3+TtYyc71j4xlT0sc2NU8X1N7WUlLB8aZDHAX4VM0CD59pX6bywfFmg3dImmuEvygLVWMGJ/oWMAl+2iFqbuNk6HaswCaul29lg9yoQ7Ldd1mIhD6j5gACa93DtBBl+mLgRZcgi9kfTPsYFW/e5CSNj02t0QRm1yJYjkEhXma/QmdEGI1KUg1M6XJVlfXumM3Iirp7RmZEFd6oMCqXDTKFgNTgKD9Aild0cW3VVgy+daiVDXELH8v4B4NpnoaIijnbZaJs9WzElqTiIVckzNH2q+Eqyw8/g1ll/izPimRARd3eUm54krP3alnEKDIJW+as+uV4ZX26bB3bk8NoIvwLM6PC6T75NwgI1o/O7r9o= X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(376002)(136003)(396003)(346002)(39860400002)(36840700001)(46966006)(55016002)(5660300002)(47076005)(478600001)(356005)(36756003)(86362001)(6916009)(82740400003)(1076003)(83380400001)(7636003)(336012)(7696005)(36860700001)(316002)(36906005)(8676002)(26005)(8936002)(4326008)(6666004)(6286002)(82310400003)(70206006)(426003)(2906002)(70586007)(7416002)(16526019)(186003)(2616005)(54906003)(21314003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jul 2021 17:02:05.5663 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 080c2024-01c3-40b9-6b15-08d952b2982e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT055.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5296 Subject: [dpdk-dev] [PATCH v4] app/testpmd: fix TX checksum calculation for tunnel 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 Sender: "dev" csumonly engine calculates TX checksum of a tunnelled packet for outer headers only or separately for outer and inner headers. The calculation method is determined by checksum configuration options. If TX checksum calculation is separated, the inner headers are processed before outer headers. Inner headers processing sets checksum values to 0 unconditionally. If TX configuration offloads inner checksums only, outer checksum calculation in software will read 0 instead of real values and produce wrong result. The patch zeroes inner checksums only before software calculation. Fixes: 6b520d54ebfe ("app/testpmd: use Tx preparation in checksum engine") Cc: stable@dpdk.org Signed-off-by: Gregory Etelson --- v2: remove blank line between Fixes and Cc explicitly compare with 0 value in `if ()` v3: update the patch comment v4: update Fixes hash --- app/test-pmd/csumonly.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 0161f72175..bd5ad64a57 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -480,17 +480,18 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, if (info->ethertype == _htons(RTE_ETHER_TYPE_IPV4)) { ipv4_hdr = l3_hdr; - ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_IPV4; if (info->l4_proto == IPPROTO_TCP && tso_segsz) { ol_flags |= PKT_TX_IP_CKSUM; } else { - if (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) + if (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) { ol_flags |= PKT_TX_IP_CKSUM; - else + } else if (ipv4_hdr->hdr_checksum != 0) { + ipv4_hdr->hdr_checksum = 0; ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); + } } } else if (info->ethertype == _htons(RTE_ETHER_TYPE_IPV6)) ol_flags |= PKT_TX_IPV6; @@ -501,10 +502,10 @@ 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) { - udp_hdr->dgram_cksum = 0; - if (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) + if (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) { ol_flags |= PKT_TX_UDP_CKSUM; - else { + } else { + udp_hdr->dgram_cksum = 0; udp_hdr->dgram_cksum = get_udptcp_checksum(l3_hdr, udp_hdr, info->ethertype); @@ -514,12 +515,12 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, ol_flags |= PKT_TX_UDP_SEG; } else if (info->l4_proto == IPPROTO_TCP) { tcp_hdr = (struct rte_tcp_hdr *)((char *)l3_hdr + info->l3_len); - tcp_hdr->cksum = 0; if (tso_segsz) ol_flags |= PKT_TX_TCP_SEG; - else if (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) + else if (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) { ol_flags |= PKT_TX_TCP_CKSUM; - else { + } else if (tcp_hdr->cksum != 0) { + tcp_hdr->cksum = 0; tcp_hdr->cksum = get_udptcp_checksum(l3_hdr, tcp_hdr, info->ethertype); @@ -529,13 +530,13 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, } else if (info->l4_proto == IPPROTO_SCTP) { sctp_hdr = (struct rte_sctp_hdr *) ((char *)l3_hdr + info->l3_len); - sctp_hdr->cksum = 0; /* sctp payload must be a multiple of 4 to be * offloaded */ if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && ((ipv4_hdr->total_length & 0x3) == 0)) { ol_flags |= PKT_TX_SCTP_CKSUM; - } else { + } else if (sctp_hdr->cksum != 0) { + sctp_hdr->cksum = 0; /* XXX implement CRC32c, example available in * RFC3309 */ } -- 2.32.0