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 E3D72A0C40; Wed, 28 Jul 2021 05:45:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 66C0740E64; Wed, 28 Jul 2021 05:45:53 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2066.outbound.protection.outlook.com [40.107.244.66]) by mails.dpdk.org (Postfix) with ESMTP id 5F81A40142; Wed, 28 Jul 2021 05:45:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gW3xk7PTUDDzcSkqBzzrdSuPq39NcbVaQr1WmdPW7rcRVqxMYVy3E5haQoiESLkc3E3rFB4PwhlpxXwDuGhtlv24ZWFbCXQUFPMQ/X7oriT8CENTAMO0lhzJIytiZTO9+TGoEn6a5NNnkIzGRxsM5MpIWgpOUCY5z9T8PC/2V8BLHTVDiFT4WIMMMw34QelKIlTo72wC1dhvF4v6MqGlwVKYZkYoUk5OVbtg/SBq6yrOsIKNHF9DobPL98qQA3gxhxCnXab1QRl9d37k9Q3ClqFrJiut9srDLQrLsSzog64FrtT0B3ldeZ6zQNS4jzjab50vcRbblveNtTTpQNn5jA== 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=pCAVxsGXGnZ9SSgI0nEQieoETlr+eIi5+jMnErImQ9s=; b=SCtX0TlijH05+BB62Y8+Px4JazCKOB0+1L8LsFCFRsJkWwzUnIih9fJACOpWKpf99EB0VcaAbhg9lnIvLfFgNFWFY2tXpAOF/tcYX5AgWhHAidYVn1LMd0/s+WTd+B7maRIxW6JDoYDjRtB92wmfZCTPenVmdupMsVHxfAI8ZVZgg9ftkALiKX6V5iX7RLmPgc4vE3pXq7R3Y8bp8Wb4TxblIEtIClZDgnrygrMvPe9WzCz/gTnlRLthm4Gj68NkJAj9hiSohN1GDkf6kLBV+h/U4fRYhoTy6nvAb08dneKr2exaa2rv/KvO9baw+pTpkzc+shfP0l8PhYxLqhoHOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=pCAVxsGXGnZ9SSgI0nEQieoETlr+eIi5+jMnErImQ9s=; b=r6LEp64M4uhyCR5F/fX3lPhqssBJIG/5PCND9mJwLs3nZw2dP+rxh170yWGaKf88Falkaj5vyHEgfUudLZUC6ML9iwE8PpM+cqtTBEfhjvV+o5AmvXv8M6GCKeewR5icnfY9AT0sfk9aIW65oROfDnbtx67UB/Qi1ihn8jNuDM28xZb8HJokwkwSFjx9H7WX5HkeszxtkMg6xdJ2b8K3qBEhdz/vvaUqRIXvX6Ry+47TwKpZ0+my7hazLOzleYClPa8Js81UwRV0TseEucxPz2IjFELNLFRZISEyKSfU7WHl8lR6fRQoybWrmdc8bV928+mCOL6DYzhClJdZ1tXn+w== Received: from BY5PR12MB4834.namprd12.prod.outlook.com (2603:10b6:a03:1b2::17) by BYAPR12MB2872.namprd12.prod.outlook.com (2603:10b6:a03:12e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.28; Wed, 28 Jul 2021 03:45:49 +0000 Received: from BY5PR12MB4834.namprd12.prod.outlook.com ([fe80::3814:b909:389e:4030]) by BY5PR12MB4834.namprd12.prod.outlook.com ([fe80::3814:b909:389e:4030%5]) with mapi id 15.20.4373.019; Wed, 28 Jul 2021 03:45:43 +0000 From: Gregory Etelson To: "Li, Xiaoyun" , "dev@dpdk.org" CC: Ajit Khaparde , Olivier Matz , Andrew Rybchenko , "Yigit, Ferruh" , NBU-Contact-Thomas Monjalon , "stable@dpdk.org" Thread-Topic: [PATCH v2] app/testpmd: fix TX checksum calculation for tunnel Thread-Index: AQHXguh4syGJazA4nE2s7L8tXYr5f6tXmrMAgAAjvXA= Date: Wed, 28 Jul 2021 03:45:39 +0000 Message-ID: References: <20210719083309.15428-1-getelson@nvidia.com> <20210727130757.30724-1-getelson@nvidia.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 367771b6-a175-42ec-46fe-08d9517a2db4 x-ms-traffictypediagnostic: BYAPR12MB2872: x-ld-processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: v7204tacbJzs0V0Zb+rk4hQeI34HpOnLd1L9tyyRiMv9Dli9ik+tlyP7cQNfOTSRCumSeMfi/E6ld8GXJxK0EVrX3wrZvCvXpdGq3wxnTegoY+023WF4XGHB87VVVe55ZDSooeDvTurnwZjqgmc6TKUYlARk5ZT2re6NG+d3+XPjcn8/+E9rETHgx0XHBSitFxGAh0xoTene5ytAnPR/dtDAghYq/5gUW/V/a8RAvAXw9xJpP73+ECYrSlm0bZTyajWWzSTBZDFaLjI6vcsC43oX9bMzcmfxYw876gAmkgpdZEBFVd+wg7aHEsOSDh8Z6E2Ql16tAzOQtKtQ1EokiC6Kl3Lz0JPzQ+1ty7jbOZknmhdcsz5lrRm8JDDp8cCWqGWqJByDtLLhkrbfath07iqs2Z3B3z/LlrkbsJpBtnexI7B8PUe9NhAzcMMFOManeGqjUHxTjHlpfx91rV/6b+7UK7+bLQtr4rZiXybSnBI1FwDpez1kYIbxEpauRCu50a1CT2PVEXJvMMjIr9hDjj6CKurxD9cmLVrJ2t3ajwy5DGg3jtB2JTKnwD+y8xJCh8fZV2E6oyGgVoXUrMnyiVZxDz+5ma6dZdqh4WOxfELJWNzuYRZ7o4Q2eyvMsoL6LGrx23VGbef3VvgpZVS/1fgWirT6VrVN004CTZBthooTU7mO5kpXXx18CkA4H3eLnQkeN1s5w4b8wR7bqv2gqTd5JRe2plWLA+T9oBIRGeM= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR12MB4834.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(376002)(136003)(39860400002)(346002)(66946007)(66476007)(66446008)(66556008)(64756008)(55016002)(54906003)(478600001)(9686003)(186003)(6506007)(71200400001)(26005)(110136005)(122000001)(33656002)(38100700002)(2906002)(5660300002)(76116006)(8676002)(6666004)(52536014)(4326008)(7696005)(316002)(83380400001)(86362001)(38070700005)(8936002)(21314003); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?g4vLjAdazeqIqx9Jmpb+zGY5M8k35DVeIqE85A7RhTKJdtgM5vnZBf0ixn7G?= =?us-ascii?Q?hH7FFpi4bEggEWAYoc+byJf58ifTlOqea4QoPCIhDXjLFDC5QnR1ATRMfbvg?= =?us-ascii?Q?P9CTWhpB6NryUyWvGDQx3aBhizL/XJ+scEC6aojutRulOMFXRkjGYfLe9nTY?= =?us-ascii?Q?c0hwO88WS86O6cQIkKG6LhiNNZAkQOmb2wxXedzc7bHoaibq2FhtQx+I6NZh?= =?us-ascii?Q?755fvlAcZJxbAF37mACdtLjtAEw3JDURFknZ6kT0HmKEbchpoiMh1uq/GGVz?= =?us-ascii?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?= =?us-ascii?Q?T5FdjWREQRwI8gj2IeEmuDPHqICkZwOwPAaaoDNsaYimf3jH0Ghk3H4kbrve?= =?us-ascii?Q?jE/ernqzuaExsHAhOYsSxdMWxUTOq77QTkBpkNLv9VczpqVINRzOZURMhVgx?= =?us-ascii?Q?VWfdUS2MQtlnCRaM3hf/EIOP?= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4834.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 367771b6-a175-42ec-46fe-08d9517a2db4 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jul 2021 03:45:40.0040 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: OwkJLBJFW+lsI2/+kLSe3YkXNKRfykb80cR3pgfaSmBLPR+ibxWLKmMRvpfydZ4dgqEJF5OQ9w6ndkbSWjUiAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2872 Subject: Re: [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" Hello, Please see below. Regards, Gregory > > Subject: [PATCH v2] app/testpmd: fix TX checksum calculation for > > tunnel > > > > 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 zero= ed > 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 =3D=3D _htons(RTE_ETHER_TYPE_IPV4)) { > > ipv4_hdr =3D l3_hdr; > > - ipv4_hdr->hdr_checksum =3D 0; > > > > ol_flags |=3D PKT_TX_IPV4; > > if (info->l4_proto =3D=3D IPPROTO_TCP && tso_segsz) { > > ol_flags |=3D PKT_TX_IP_CKSUM; > > } else { > > - if (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) > > + if (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) { > > ol_flags |=3D PKT_TX_IP_CKSUM; > > - else > > + } else if (ipv4_hdr->hdr_checksum !=3D 0) { > > + ipv4_hdr->hdr_checksum =3D 0; > > ipv4_hdr->hdr_checksum =3D > > rte_ipv4_cksum(ipv4_hdr); > > + } > > } > > } else if (info->ethertype =3D=3D _htons(RTE_ETHER_TYPE_IPV6)) > > ol_flags |=3D PKT_TX_IPV6; @@ -501,10 +502,10 @@ > > process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info > > *info, > > udp_hdr =3D (struct rte_udp_hdr *)((char *)l3_hdr + info-= >l3_len); > > /* do not recalculate udp cksum if it was 0 */ > > if (udp_hdr->dgram_cksum !=3D 0) { > > - udp_hdr->dgram_cksum =3D 0; > > - if (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) > > + if (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) { > > ol_flags |=3D PKT_TX_UDP_CKSUM; > > - else { > > + } else { >=20 > else if (udp_hdr->dgram_cksum !=3D 0) { ? > process_inner_cksums() function verifies udp_hdr->dgram_cksum !=3D 0 before checking for hardware / software offload capabilities in enclosing=20 if() statement. No need to repeat that verification =20 > > + udp_hdr->dgram_cksum =3D 0; > > udp_hdr->dgram_cksum =3D > > get_udptcp_checksum(l3_hdr, udp_h= dr, > > info->ethertype); @@ > > -514,12 +515,12 @@ process_inner_cksums(void *l3_hdr, const struct > > testpmd_offload_info *info, > > ol_flags |=3D PKT_TX_UDP_SEG; > > } else if (info->l4_proto =3D=3D IPPROTO_TCP) { > > tcp_hdr =3D (struct rte_tcp_hdr *)((char *)l3_hdr + info-= >l3_len); > > - tcp_hdr->cksum =3D 0; > > if (tso_segsz) > > ol_flags |=3D PKT_TX_TCP_SEG; > > - else if (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) > > + else if (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) { > > ol_flags |=3D PKT_TX_TCP_CKSUM; > > - else { > > + } else if (tcp_hdr->cksum !=3D 0) { > > + tcp_hdr->cksum =3D 0; > > tcp_hdr->cksum =3D > > 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 =3D=3D IPPROTO_SCTP) { > > sctp_hdr =3D (struct rte_sctp_hdr *) > > ((char *)l3_hdr + info->l3_len); > > - sctp_hdr->cksum =3D 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) =3D=3D 0)) { > > ol_flags |=3D PKT_TX_SCTP_CKSUM; > > - } else { > > + } else if (sctp_hdr->cksum !=3D 0) { > > + sctp_hdr->cksum =3D 0; > > /* XXX implement CRC32c, example available in > > * RFC3309 */ > > } > > -- > > 2.32.0