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 A32B3A0C43 for ; Thu, 29 Jul 2021 11:40:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8A5FD410DE; Thu, 29 Jul 2021 11:40:13 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2043.outbound.protection.outlook.com [40.107.223.43]) by mails.dpdk.org (Postfix) with ESMTP id 23D9F40041; Thu, 29 Jul 2021 11:40:11 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RrRYutNnIG48bZNyUjIfyrcoF7Oik0/D/sO5JU2ITwUyXhBk+ZgJSBJNptfUTSA9PGAGQ85EBgF7qGvzRc27ZkbUyAqU6R85q2YE2vqTP0HdA2vpf1otd6hnQIee9OmmYsQtw6n1EIrobdrqwapkAImYnLON1xwlLnVX5HPm/Tfu2kwhi1JotCtdR9U+moFSBjzkaDMViqdhNewi8dC1zU1XEe1sQl9fx068c+EgL/17N1wUGLO8sV3WYB8H3BkLV0xqCWLJxEyHv4uK3XFaDejzW4J9Bnyl/XdUrBj9pcUr35hDXnyAWV81eGkZoC8I8z8sp5M4ZSO3GXyFPypWKQ== 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=9qfAgdT909fMoggFG2LbEIIB7llQpJtRE3l0zxIA5pw=; b=nbt5vJEd98qE9+jiCzDMBPBJLvxyW5k8QpP+3ohoGvi++nMcPV5Njp2aLQhR7Pcp6sS4uGySuIYDPsnCggUsoeE4Z7axSazUVH9zsYAtE8JH5k9dQL3y1PfWyaQ4vX0d8x36ajumhPxxflgoPfCUg8Cz44mAEuqJ5kL6NhUN/taFttDGq14LdCjt0CeyjBru/tV0G0RsM1AtYOgUMNY8Shm8IeTGO7FXaGMB0MnyMU41mQI8u0DtOyAtfRaCGkoLOXmt2r3a3H5awKB1CchPzgk2ccMw0WeWwzUtJ6CxwQxIzsNoC0i2sTtmd6d7ye6hYLHPsNvfMa3rLJXSNYAVmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net 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=9qfAgdT909fMoggFG2LbEIIB7llQpJtRE3l0zxIA5pw=; b=G7qjOmYPiIS+m9+K7QNv0Lf1czi29u9hSwtpp1q11zyU+Pm2gzCjj/TwchunAJA8ceWyoVHhBc87PW53apEqJN/L/sMWuHGO2a87tW5nuYItiNLUCcH1abANmk/XqfCS4t/WVBX4k8oW0KLnxl1YAYBgKUEo1tYTGtAHBqrg2FKs0ngBHntulAqt5uS/dbbvLTO/3gIH2dAqdnmhFXkSPpQYJ1FfS2WIhV9yKxFFnNLk1HEcOJphbG4JCpeoI4TmV91kUX1UAwawhQ2Mlku1uINuKPtLmaU+Amw57vRefvELm9HQ/KcJ4LBYxlZv73lVvW4PjSw4wXgUtlBJk1T+3Q== Received: from BN0PR04CA0124.namprd04.prod.outlook.com (2603:10b6:408:ed::9) by CY4PR1201MB0007.namprd12.prod.outlook.com (2603:10b6:903:d4::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Thu, 29 Jul 2021 09:40:06 +0000 Received: from BN8NAM11FT053.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ed:cafe::d3) by BN0PR04CA0124.outlook.office365.com (2603:10b6:408:ed::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21 via Frontend Transport; Thu, 29 Jul 2021 09:40:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; 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 BN8NAM11FT053.mail.protection.outlook.com (10.13.177.209) 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 09:40: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 09:40:02 +0000 From: Gregory Etelson To: CC: , Ajit Khaparde , "Olivier Matz" , Andrew Rybchenko , Ferruh Yigit , Thomas Monjalon , , Xiaoyun Li Date: Thu, 29 Jul 2021 12:39:48 +0300 Message-ID: <20210729093948.25847-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: bce6d03f-8b14-4c31-c966-08d95274d90e X-MS-TrafficTypeDiagnostic: CY4PR1201MB0007: 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: Zltoa75AfNICh9S8wZ1bxf8VHAFw8pIEyIiPmK9cFviLiDsPHkWJTJQ970665rAzIHlweRYpOa3ay3JQq/tQA2OMLuxQoGnvVMaPwP5xcSN1YJnvIH3AJKEVgShtxgmOLoniB/Mp8gZVs3yywOOf7cE2Yxmk4JwDwaxc6uWQZjCVvfRQwDV0BF6XCN/puvZqV53lkBh4hdyM1xGugOK5MHIYbdm3AIBCIp1PgnJjrWlaTBm48Z3+pq7d8RxXo1g1lio67gyn7CcuxMH8u38bvZZYV7QxCBy5ZSxFNp7UAOX4rSkHlFeVVI9AwLdpE8AdFmkUeVRSs7h11qylsEkVbQbOchtM9oMW9D45kfjlvwvtPfhfWWLMnrFB3QWp+tqlqYC6juZg/Pierff/7NzkiYyPTwH350VYax9uFdtATvXHRYlqFgr0VdxxX6/u9YrevTm285payPGCKqxPKPJrorpBJrDsQZx+4VrHS6JGEJ1fudJ6HQVLzQjK3j4PHPFkyxi6GdktMTC88y3ZYzQlrNUUWfe7ysxFrhZKvPO+nnPedxG7/Lm+qUardEJR/AKVa0Pj7P7DoF7Ev5SVtLRTdMCYiP+HJxHm6WZSmIcoefq/+LLGNXvFPsBFw9T8vY/Dlf3bgTwUU667sBOZ0Nq0ZwWFDyqklM69sZQED0mxM8BPg9UNeffoLP2zTBuxa52RWNNuPo8go+Fq91OUgb2TJVTHsrXqNyRCbRE2ziUQhu8= 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)(346002)(136003)(39860400002)(396003)(376002)(46966006)(36840700001)(5660300002)(55016002)(86362001)(1076003)(426003)(2906002)(6286002)(36756003)(356005)(7636003)(82740400003)(47076005)(478600001)(336012)(36860700001)(83380400001)(26005)(70206006)(82310400003)(36906005)(8936002)(6666004)(16526019)(6916009)(316002)(7696005)(186003)(8676002)(2616005)(70586007)(54906003)(4326008)(21314003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jul 2021 09:40:05.9295 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bce6d03f-8b14-4c31-c966-08d95274d90e 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: BN8NAM11FT053.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0007 Subject: [dpdk-stable] [PATCH v3] app/testpmd: fix TX checksum calculation for tunnel 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 Sender: "stable" 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: 51f694dd40f5 ("app/testpmd: rework checksum forward 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 --- 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