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 C9911A0C4B; Tue, 27 Jul 2021 15:08:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4CEFE410F0; Tue, 27 Jul 2021 15:08:21 +0200 (CEST) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2052.outbound.protection.outlook.com [40.107.95.52]) by mails.dpdk.org (Postfix) with ESMTP id DCF41410ED; Tue, 27 Jul 2021 15:08:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ww3QKBatmF1N/98iscbfodTqWFrGkhLsLXoey90xeMAg/Wu9iVCJ/M5/nIQDfx6pBfP/IBXwt/Gt+ux0Uv0v5b2Oxy587Vd+cdGLJgmoXekTCVu1RkTVZcvU/WAeAD/2h1uUFKoD31UlKrhxQqLjZF6oq+egYVjCu+iOV39R90ifeItCn8vYuPB4dr14RrVtd+lerEutVSt42x6f2Yhq+mBMOsh2Z2LucDwbTWwXFt8dhzpzNCrEj/TEwSN1PeognXrNFcWNZsmVrb0AhWbJNdLIfIHoopsv3x1BffSwMcmrDrf+xeDDpNoxMPNEIVklaMpl2AQnYlyeyp1MjmxSFg== 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=JBPTpBNHA3FtkuKyi/Uyv17k2y1zP+XRvsIlfsQ8xzU=; b=Qaqg9I0AIKM7LI2iG09+sUD2RhyC/bnQzzow1TKjbUvLCmZ2PcTzg0CESVXqL2ENay2HC/3FeMvXdFBwGne7g7xjHPsR1CcoyCeUj0uhYl1UontzHtPN9wfpuF8viix6ui3aeY1XOt4Qm1o7yFY4s7es8Z0xqQDd/DDO5trUtqUa3OEqkCr5JbhpeUPnUdZRFKjwSPHNFWVCLrVrqfekTwmUKAWlG6REWje4aEey+ZdyHTJRfbEJ8ySghkjcXct/ORkS5TBBOxuj1YsyxhKctXaVtN8QnrVy6jVAGwacQd72PQSF8VT3EzHR83plH820HMIe5NNDPNqj7WbzNNc4qA== 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=JBPTpBNHA3FtkuKyi/Uyv17k2y1zP+XRvsIlfsQ8xzU=; b=Q3TWthtJtbx5ZDY7Dq3CfLclHGFRPfW8K1lU3UaqCMl5v+NL6Sakwbw11NGsH9NlqmVH/BOa4zDnqgNulACZyLQBw9jFPBXe38Ce+a3ZIEZ32QygnuzHWJ0wRFkxw9aHs+Ohyc0nhmwP/0iGhCjoMwZZFaDxttFekkQthcRr4oa2dG/j6EAOKmE5ZOnOYRLXz12xFRYaIhSpdBz6ijnO3uGSDqkuACEYi5KEG0m+IDgsxosTHp9a+nSC9zC5+s7E1qmQoe9Rz1m4WfquccnPaV6IhNzyLD0NRYT73OnFQ9cOsEf2m4/eXMoYgXMGcd9zA+oTnNAl9K14XbF8GFVmnA== Received: from DM5PR07CA0025.namprd07.prod.outlook.com (2603:10b6:3:16::11) by MN2PR12MB3533.namprd12.prod.outlook.com (2603:10b6:208:107::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.29; Tue, 27 Jul 2021 13:08:18 +0000 Received: from DM6NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:3:16:cafe::2) by DM5PR07CA0025.outlook.office365.com (2603:10b6:3:16::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17 via Frontend Transport; Tue, 27 Jul 2021 13:08:18 +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 DM6NAM11FT004.mail.protection.outlook.com (10.13.172.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4352.24 via Frontend Transport; Tue, 27 Jul 2021 13:08:17 +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; Tue, 27 Jul 2021 13:08:15 +0000 From: Gregory Etelson To: CC: , Ajit Khaparde , "Olivier Matz" , Andrew Rybchenko , Ferruh Yigit , Thomas Monjalon , , Xiaoyun Li Date: Tue, 27 Jul 2021 16:07:57 +0300 Message-ID: <20210727130757.30724-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: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ba46f4e4-32ec-40ff-378c-08d950ff9a0a X-MS-TrafficTypeDiagnostic: MN2PR12MB3533: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HmePhChf1htHptPne71B3ySLYNZrVQaU2EULGhEaSI0Qo6i/WAII36qOEWnXS1JpHUsA3zdszbVZKmdXfMtIi5BdNJOFXkX5kBGliLKGXonkBZi8nkLvnGeIoka2sWMVQBfSPLhzaGlIAoRovOJBgXVcQlatKJVPZNH9m+TcKVVmHK7Y7Drkiimffpv+4hbnAouc4egTnLdAui6ITWTWm+JO4ABVJaH0GpFi+JUiiuGqC7pG98I76VpHWdicDb0WVQ77HaE2Dh0nwDyzriRAjKYWiozTGssdGs/uhBC8Yhz7zHa3dCLVgt8zvLXBbDYKSAPmSemJEG7YTh89pgYxmsXwOS0Q03g6430U7bk+bWbDY4pYq3vDnCl0xWR+tXTQf0mojabCRCcGfX7JwQqEJPY9/hPuZGTf6DMhjLy+S3INOt5ShW3UgDMikJIpAuzaAkl40NHWGuRPFfRLfPm/1NtTZLjEbuKkcwVUkrXcwCAxoYy9TNlHk33epL5ZomlPhzXYVoYB2uA3v4z+865b5CzGDELJEnsb3jcH71eKKzWiOloUnLRlYBaEJUJGS8W6CyJs86uDRN6rqxOHOVqs+vgcWql6AePPWQZpa0mYtZ0ubiXAbBiMpPZAhWjfNME1n9hGhOR5vX+QJoKqS92tamEEoFPzumRqIJXfdG9kgVEY7ZmMNY/KBllb3oiypOwydnfu+MF98EQdrWKfhc1B5kd93XyY/VbuRJxp2AC4ft0= 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)(36840700001)(46966006)(426003)(6666004)(7696005)(336012)(86362001)(316002)(82310400003)(8936002)(8676002)(7636003)(26005)(47076005)(83380400001)(356005)(54906003)(36906005)(6916009)(4326008)(36756003)(1076003)(508600001)(6286002)(55016002)(2616005)(36860700001)(2906002)(70206006)(5660300002)(70586007)(16526019)(186003)(21314003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2021 13:08:17.9410 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ba46f4e4-32ec-40ff-378c-08d950ff9a0a 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: DM6NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3533 Subject: [dpdk-dev] [PATCH v2] 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" TX checksum of a tunnelled packet can be calculated for outer headers only or for both outer and inner parts. The calculation method is determined by application. If TX checksum calculation can be offloaded, hardware ignores existing checksum value and replaces it with an updated result. If TX checksum is calculated by a software, existing value must be zeroed first. The testpmd checksum forwarding engine always zeroed inner checksums. If inner checksum calculation was offloaded, that header was left with 0 checksum value. Following outer software checksum calculation produced wrong value. The patch zeroes inner IPv4 checksum 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 ()` --- 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