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 6256943319; Mon, 13 Nov 2023 08:30:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E07FA402BA; Mon, 13 Nov 2023 08:30:15 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by mails.dpdk.org (Postfix) with ESMTP id 0B4C340279; Mon, 13 Nov 2023 08:30:15 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kEo95H7mYAVzCUUQLK2KmC+wlPYTYqwcRhASaDq2xxgzd1F5Dq+rDfWi8Q5p/mujNTSAJbRF9SGlO8f2iA6TyYpQkuF5yo4uEaMpgO62wew5HBSMbvYqhtby0UupOtuLsP5MwACVpN3QxuozwvDMwU5YjN1r0OSgj4sP2qKvpVj478OAx+ZjC4B/VM4d8a4mELfk50isKCr6QZXqaPw7Og5jyr5y0JhEM40RxTqLF/3IBYcG1oOS2SLd/l4cZuoc15S/ZdzoHXrFY2dYtTqIYO0OLrQckHpkOvVKpQyGLbQWKyYMK7buyrHCsq25fDZ1UyhyzdKvjo0cpDKnevCmLg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8+w5YQdAWNPPHRqJmh4K9n/kS+UtZ3TxDh4gBhN10qk=; b=Dt7MabreFxtS5vmQXZ3OVQ/iFS38rjDoZVEa/gTvYon4jqdJMP/r+lelHN4mFH9FifcWTEGq0cUoYYCI02GJD6J5iBE4ZXFozoHKKD+l572YiqAdZQYjTiSEbGDoS1j1rNYY1pL+Ties6qTvua9nlJYX+lZSiQWxp1/Tlo31Qu38Gyx+hAgWdKE3GODQ21fXkze5szUiC0gPWgQJHSe/gj3EUzp64AGrJs9b2w9dpTpEArW15bmqfHW4qNBpHKfa16MkEPwV+eQUfdFB/LcZ2y2tfecdEe1DxfeJAcyUXiPmzmNXFWr7wLrpsCwShvuGeLi+lwl8y5tmjHjXAp01iw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=8+w5YQdAWNPPHRqJmh4K9n/kS+UtZ3TxDh4gBhN10qk=; b=bqFo8OhkrkjmxD2mgAus4S5QoiSJ1TEzcmTPJQgtUXOnC0X28lsrGUjZ1RoIrf9aBe0JO4TGQQRjS7p1sq379HJhCqaF9KkITm3Lbz5hWVS3iKDjFlTlvCsBtZowwjpUVDrJuzy5lTObug82A8tg56D3w1rqKOW9clYRxO1OfOHNizQAudRGn9Hy9zkL3A8bvdvXFSFdkUXewMW0q4u9CZxVKhZrUEK0FQb9Oh5NUTRgFd702f6ugyAb9RViqH+iblYjLdx6nmxZyh4QXWjyuSGsToXt6ZG///40MUOenuvf7x4ABej4sYG/LXwJlOCFD1N9LbQEcth05TZSl5Zy+A== Received: from CH2PR03CA0006.namprd03.prod.outlook.com (2603:10b6:610:59::16) by DM6PR12MB4074.namprd12.prod.outlook.com (2603:10b6:5:218::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.29; Mon, 13 Nov 2023 07:30:12 +0000 Received: from DS1PEPF00017098.namprd05.prod.outlook.com (2603:10b6:610:59:cafe::86) by CH2PR03CA0006.outlook.office365.com (2603:10b6:610:59::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.29 via Frontend Transport; Mon, 13 Nov 2023 07:30:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF00017098.mail.protection.outlook.com (10.167.18.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.13 via Frontend Transport; Mon, 13 Nov 2023 07:30:12 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Sun, 12 Nov 2023 23:29:58 -0800 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Sun, 12 Nov 2023 23:29:55 -0800 From: Bing Zhao To: , , , , CC: , Eli Britstein , Subject: [PATCH] net/mlx5: zero encap UDP csum for IPv4 too Date: Mon, 13 Nov 2023 09:29:41 +0200 Message-ID: <20231113072941.6914-1-bingz@nvidia.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017098:EE_|DM6PR12MB4074:EE_ X-MS-Office365-Filtering-Correlation-Id: 91862d2b-ced0-41a6-c974-08dbe41a5f4f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3sD38QkOI01X0eCl+VlA7QlWWdCNAs5ajpAPbCGavjcARY4GvsixMEZM/YwB1KIG8pHkejK0Mc13e2ZYj0Ho6k2VpT94DFymlqxNQYC84I4z9J5m097v6PsUYaSNPq2kzRIKpED2H02qiyIfcig5GF1Op1XdfmC7GFmBGoho6M/w0D6hIY18CnndlfDV1mTNR6VEetIkLk2EUPEyvPZSEx6sepDlsNlBcaQRwZhY1Q/IUy1Zs7gGSdn/UeA0NPkibQrfyl1q7mxlhDB2k+QtiUF0V4UVh+kdZB/XKL42KGFr+MvtvCHK1obE9fMrdat/X8jYick2PxnC2UMV7aAHg5SlmZDU5eTBs9kCVU3rmT+tetVjk9qiYp6YnfEVTGn5G7WUeWHycp0uA+L+oWu2xdrV3niIigyHJKhVskq5qUGgqdeTeuS8OMa4lONZr3isqK776YYnc1eja6lVmu17mpJeBmE2bJsBkd34/fLbWKv7AczPhJuu0O1dlY/t0gkB4yUL0qM8bczOW4QcDDMDjbNyGREktiScrSDy+7IaXc8RSrAeb4w6wfo4ZVkYE+CWj7YYz/oiAqNtIypUKYhm89LMzPNrsNQ4OXXOctM+PixjNPkqNS0e29D6YHIvHSP+NCPlcvXLAn9lKhCiGkcZIEJ8B7UgfoA+VP9PhYu0AmOXBXfSIeHs8DFf+3EuGejg0rIlTRWFlyeJDeiA8x7gJdvhVNxwjMMQkQyVyeEAANg= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(396003)(136003)(346002)(39860400002)(376002)(230922051799003)(64100799003)(82310400011)(1800799009)(186009)(451199024)(46966006)(36840700001)(40470700004)(2906002)(40460700003)(6666004)(7696005)(478600001)(86362001)(1076003)(26005)(6286002)(16526019)(2616005)(54906003)(316002)(70586007)(70206006)(450100002)(6636002)(36860700001)(47076005)(426003)(336012)(7636003)(82740400003)(356005)(83380400001)(5660300002)(8936002)(36756003)(8676002)(4326008)(110136005)(41300700001)(55016003)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2023 07:30:12.0841 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91862d2b-ced0-41a6-c974-08dbe41a5f4f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017098.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4074 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 From: Eli Britstein A zero UDP csum indicates it should not be validated by the receiver. The HW may not calculate UDP csum after encap. The cited commit made sure the UDP csum is zero for UDP over IPv6, mistakenly not handling UDP over IPv4. Fix it. Fixes: bf1d7d9a033a ("net/mlx5: zero out UDP checksum in encapsulation") Cc: stable@dpdk.org Signed-off-by: Eli Britstein --- drivers/net/mlx5/mlx5_flow_dv.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 9753af2cb1..115d730317 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -4713,6 +4713,7 @@ flow_dv_zero_encap_udp_csum(void *data, struct rte_flow_error *error) { struct rte_ether_hdr *eth = NULL; struct rte_vlan_hdr *vlan = NULL; + struct rte_ipv4_hdr *ipv4 = NULL; struct rte_ipv6_hdr *ipv6 = NULL; struct rte_udp_hdr *udp = NULL; char *next_hdr; @@ -4729,24 +4730,27 @@ flow_dv_zero_encap_udp_csum(void *data, struct rte_flow_error *error) next_hdr += sizeof(struct rte_vlan_hdr); } - /* HW calculates IPv4 csum. no need to proceed */ - if (proto == RTE_ETHER_TYPE_IPV4) - return 0; - /* non IPv4/IPv6 header. not supported */ - if (proto != RTE_ETHER_TYPE_IPV6) { + if (proto != RTE_ETHER_TYPE_IPV4 && proto != RTE_ETHER_TYPE_IPV6) { return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "Cannot offload non IPv4/IPv6"); } - ipv6 = (struct rte_ipv6_hdr *)next_hdr; - - /* ignore non UDP */ - if (ipv6->proto != IPPROTO_UDP) - return 0; + if (proto == RTE_ETHER_TYPE_IPV4) { + ipv4 = (struct rte_ipv4_hdr *)next_hdr; + /* ignore non UDP */ + if (ipv4->next_proto_id != IPPROTO_UDP) + return 0; + udp = (struct rte_udp_hdr *)(ipv4 + 1); + } else { + ipv6 = (struct rte_ipv6_hdr *)next_hdr; + /* ignore non UDP */ + if (ipv6->proto != IPPROTO_UDP) + return 0; + udp = (struct rte_udp_hdr *)(ipv6 + 1); + } - udp = (struct rte_udp_hdr *)(ipv6 + 1); udp->dgram_cksum = 0; return 0; -- 2.34.1