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 94B01A034F; Mon, 19 Jul 2021 10:33:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B4A44069D; Mon, 19 Jul 2021 10:33:31 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2067.outbound.protection.outlook.com [40.107.93.67]) by mails.dpdk.org (Postfix) with ESMTP id CC5834068B; Mon, 19 Jul 2021 10:33:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LDCO+tnc6U4/PPt0TSshvo0o/NZeTf3zf3Gb9hfzvV8fD/kE0SJMLYr9y11Wr96QV2jjd++y4JCMw9lPZ6+Avljq/bstLZ/kDuhGcJjLf69BUoY6ZgIFiSEhRHl6sZj3poGdrU5EieyIm5FQr1411X3xKLgq/bHppDRwutMEbRN9G3AIgNJVvugFUGC5sOI6iFetjK5ZhHiGI5eMYseu5hazW4yYX5K+LZ6RDQtGi47qIBCZeeLw+imfjA4hQz4BOc9XnNf7hXwN6jW2AhoQtFu7gAO/9RqHOoE3Fw04a/g2o5MrcERcxScDncVWu9Ur2wq5j4KI6zpCc4czmaPXUg== 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=g4BS0hHibtkT+CU1jSQlYo7//TzRf3yQFu+RiIufMj4=; b=nMJ/ecCLg2R28Z02qfhEz8ccOBXEpymUwsP8v+sBpwn6lPAaT+LjxgQbsABdtarp9jvlhvjolzqRkxOgUjncRijiIpLj64jVGRvWblfvsGPrMha3vRErjtNhEJkrYFhS6oOM9Mi+oVCDqGmQtQMzWRNauZTcbRol0aSuXgUQRLuKGniLfrpSqQfyvFgwMHRrYm6wTYDM/S7SfGNIdveUVDOOrxGJ6mG2BnnBAUt8xz4b99B+MLdK2rrnqF7FNaMRaby/yBgxRrlSTIh1o2A7Mx+5zvUYsKXmfiOSkysZvxswpQMm/UMMcRfkIg4gyS2g8ke+ixzPysL3Kz5LcIEBTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com 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=g4BS0hHibtkT+CU1jSQlYo7//TzRf3yQFu+RiIufMj4=; b=hFi3HXtVstjsV2bR/ctPmPTKsOgzpvJ4lLdkJ3U9xBHUR9RhVptqZb6ffZe6cm9MHuf/gLgep1/FK0ZdVjPuD3G2t8MmlWt2MN5VisiW3AHa0jHc49Np2DovO2kvsMG9aM0+Nzyr+5ajHYqRseF8pTs5DxH9+N5cycwrAtdfx4ByQ+qH3mOBRJBmVd9CASnkmmsanolJEtlEhY0g/nAGljJ1e10oMFMU/n9KQn9JObIT2FFHAnmEYSIoiUHewE8M3HsUwY/XY1PsaKIKJBnNAHsrfVHctDKeFwJF21x0u3UWUkONT9R/F+mKpBmooH7CDUBpKRq3aOyJleAhB9uXqA== Received: from MWHPR18CA0041.namprd18.prod.outlook.com (2603:10b6:320:31::27) by SN6PR12MB4735.namprd12.prod.outlook.com (2603:10b6:805:e5::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.29; Mon, 19 Jul 2021 08:33:27 +0000 Received: from CO1NAM11FT041.eop-nam11.prod.protection.outlook.com (2603:10b6:320:31:cafe::49) by MWHPR18CA0041.outlook.office365.com (2603:10b6:320:31::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Mon, 19 Jul 2021 08:33:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; 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 CO1NAM11FT041.mail.protection.outlook.com (10.13.174.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4331.21 via Frontend Transport; Mon, 19 Jul 2021 08:33:27 +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; Mon, 19 Jul 2021 08:33:25 +0000 From: Gregory Etelson To: CC: , , Dmitry Kozlyuk , Xiaoyun Li , Olivier Matz Date: Mon, 19 Jul 2021 11:33:09 +0300 Message-ID: <20210719083309.15428-1-getelson@nvidia.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ace94154-6917-45e7-8c9e-08d94a8fe196 X-MS-TrafficTypeDiagnostic: SN6PR12MB4735: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WbJoYZHySv0Pm+u6teO55CCZtb0E11Xi3YWf2XHg562VEB+BXZHDwhGSSbXsPqmL+QK1lz4jRM8q8c/MHPbe4dFrII9rW/JqZlRKwLh2wQM7qHn2yNgc4a+xglDmcnEuqlSGgyUpwfzPystlA+jGU0nF9lsnqgpNczU4mzcWLYDMZj1SpQZhvA6EtGtlBKL9jdrr7gXR7DWtTpYDRzHlem9m9HeqtYzv9pgz4LnAPL5y5Httj21vMWR2mNEK0EgJ8QMB24EVvEhgzPiGI5ddu84JNNyos9saWhB9pUfRfm+DSgzsuR4c5eR0/JzwV4ty3W4tQkMbl196BP6IOS+IcUzRKnC1MuREb4HI7VU8FCSh1k1hYyG+vdZFP5jmhYGJ2fsNuISLmiZ0JkS0/TL52xgS1oWZbbEdqerfyMb1cG3m/R9gTUXwQlylWXP52qAYD/9+wPt2GYinhsQXRweHgBdeFwXF46kj73gGOSBwFDnysAoDS7PQYmSEoSMmsWQzKNewPzjVmbCxxYMb43GQLIFzA4CZTymHuD5oTse8LGkKaEVGJ1wBB+38yYD9zr5hHWinXKqMqpKx4yyhEN5SZnyum0CexSBXsJ7ooJd6gYBmZZ6lMAS8v5Ncic+5sn/HZn6lf9QWBfRC80Nb5XLJtUHWBshHWXIKpMNqRp8nyKXaBmKMNP0zLzf3pgodVbj7OF8dF8GqFBGa1eDnXRs5bDir/RCMU4a790Mvl1VsUog= 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)(39860400002)(346002)(136003)(376002)(396003)(46966006)(36840700001)(1076003)(2906002)(82310400003)(36756003)(4326008)(54906003)(55016002)(6286002)(478600001)(6916009)(36906005)(86362001)(426003)(2616005)(336012)(70206006)(8676002)(6666004)(356005)(82740400003)(7696005)(8936002)(16526019)(186003)(83380400001)(7636003)(70586007)(47076005)(26005)(36860700001)(316002)(5660300002)(21314003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2021 08:33:27.4135 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ace94154-6917-45e7-8c9e-08d94a8fe196 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: CO1NAM11FT041.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4735 Subject: [dpdk-dev] [PATCH] 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 Reviewed-by: Dmitry Kozlyuk --- 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 089936587b..a658cd5389 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) { + 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 if (udp_hdr->dgram_cksum) { + 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) { + 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) { + sctp_hdr->cksum = 0; /* XXX implement CRC32c, example available in * RFC3309 */ } -- 2.31.1