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 A4A83455B6 for ; Sun, 7 Jul 2024 12:26:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8FB214161A; Sun, 7 Jul 2024 12:26:38 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2047.outbound.protection.outlook.com [40.107.92.47]) by mails.dpdk.org (Postfix) with ESMTP id F32A940654; Sun, 7 Jul 2024 12:26:36 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FgOO4JCGId97GrEYF/hVWl6rHeQEtiC6Pe4s239+ydPDqZOUbPLxrA5+50HF9uYnOruSJMy39acgTKo0BAyqTAkqaaP95gwrqjYCwHBmktF83OiOevI4LrBgbR8UIwx7qRXEKgtwxm4yEyryh3heAaS5dfdIT3OG3pt9xWkLORvW7TVrwR7ebq4tSLdP+POP5CC6vII41sJBx9Da6HD6wqXcPScynoj/+d89vKU+rJHD+4XZbHh0goJ5UmXnsQP6YRui+Gpp3vNuftaSKjQo+AB8pC8P0ayqdT65DQ55AsvrvYUpvVQ9fJZyhFXH7pBJT+PMTbJF0CrIxW4zqW3pxQ== 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=/JcZuVh+ROhGrYOwKcnnZuXzkxZiLTx8biBj+A0s2E8=; b=UUJDEhdk+K9S+V4KscQjBA345r1p3BQFa71YNmwOrfR6IUX9nujYaOCgEXraDFhLGHoL2cNXEGJ4nKCtcjhrshlbU3yqLLdckboxM4EZacW/AlxyptbVlsBnB2Q9olARMTS7IQY2eGnfW+LjdjWBZM7sU71Z69Hd0wmsCp9QrJJKYzTw1DXDUsXRYIyoiNwkLA+sOpGBLQ94u8jwxipyTRVEN/2kSiEODcsULSEiUgOLeUzta+3U08FRwCeQTcRcNb9oOj6m4oTcGdA49Bs8ooauRdMC3Om5b+ZYJfPrJzTcmGLEDfkA9wKA4H0ojaOJJygJ5qtY6KcYAme+azTuBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=monjalon.net 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=/JcZuVh+ROhGrYOwKcnnZuXzkxZiLTx8biBj+A0s2E8=; b=FGRQ2l5klPwbkSz4f1DC2ahe3KlzI5s7A0oSbtzPN/9wT/sN+whot1rIfegnaItYxGlQhuHjp/pclfiPm2FHwvZgvmkaBIqWviChmylb8mP2j0dfdooLSZWKCOOaCrcTPIzwRz7fc6udGhtq8UqaYjljQ4bYtFluxPwKZ8tnmaXmPDTDQ7Z/b2zsICpihXMxOjXNpe07nsg1D29lo3BV6Dhu0LJRxST7ZYOC8XIyslS8/CCcWyzK+LK3+rCW5FUp18W7KyBgBNwtB/hW0EPcu5uv4ej+8N9xsEiOZ+fvV97xZu+1Pnbcl+KT4/vNYP8EM9K5z6bG9gMYeIjjyGBnxQ== Received: from SA0PR11CA0210.namprd11.prod.outlook.com (2603:10b6:806:1bc::35) by MN2PR12MB4093.namprd12.prod.outlook.com (2603:10b6:208:198::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.34; Sun, 7 Jul 2024 10:26:33 +0000 Received: from SN1PEPF0002BA52.namprd03.prod.outlook.com (2603:10b6:806:1bc:cafe::41) by SA0PR11CA0210.outlook.office365.com (2603:10b6:806:1bc::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35 via Frontend Transport; Sun, 7 Jul 2024 10:26:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by SN1PEPF0002BA52.mail.protection.outlook.com (10.167.242.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.17 via Frontend Transport; Sun, 7 Jul 2024 10:26:28 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sun, 7 Jul 2024 03:26:20 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sun, 7 Jul 2024 03:26:20 -0700 Received: from nvidia.com (10.127.8.12) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4 via Frontend Transport; Sun, 7 Jul 2024 03:26:16 -0700 From: Itamar Gozlan To: , , , , , , , , Dariusz Sosnowski , Bing Zhao , Ori Kam , Matan Azrad CC: , Subject: [PATCH 10/10] net/mlx5/hws: fix NA64 copy TOS field instead of TTL Date: Sun, 7 Jul 2024 13:25:31 +0300 Message-ID: <20240707102532.2045942-10-igozlan@nvidia.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240707102532.2045942-1-igozlan@nvidia.com> References: <20240707102532.2045942-1-igozlan@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA52:EE_|MN2PR12MB4093:EE_ X-MS-Office365-Filtering-Correlation-Id: f832d92d-86fc-4c7d-5311-08dc9e6f430a X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|376014|36860700013|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lsYxT199jHssh+KzuAmnpsUoA146eAy7xZrj4mglAM1wQLeQMqB28d6QKsDP?= =?us-ascii?Q?23cNGoaGAvHC7HZ2oZWkZvbfYxk/k5ktRSWU4nbEpO35Hn/zhTDycpR9+xQu?= =?us-ascii?Q?U/dgAAdUf+1t+ItFRDPjaOUiYW1WyYtUPMcRvxJJIK3bZlUcMb7L64vvlBSi?= =?us-ascii?Q?yeh1m0P0e8enN8GICxs351ncOz00GeFN+zyYrqGYhU+AhV5tPBeQ2gU24WJU?= =?us-ascii?Q?sP8xI7/8QdNbvBWrBrsqc5yv6nDPwdrPZDp4cGcd9qYHpONTT5Rp2Ry6M0tP?= =?us-ascii?Q?7IrSmLwAvDtisn9h1otRYfLsAaimE9vNv2lVfDn/0SlIa3Tv8GP9gdesUZna?= =?us-ascii?Q?LqgvD8QzX+zV4dSJFr625Q/Gf4enpqYhgZLKf/Ik/sdmlkQPt6b3h27oahW+?= =?us-ascii?Q?1imPqlbZAr3KITxrubbUI1eQ+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q?U/FTo3OrPtGUJGodrCd97opZjqwd3O7W+Ra0dxPvAUUDh+KC5gOuwCgk2KAa?= =?us-ascii?Q?qrSeeljOgxnWqRsPta1HnXmx6fw/W5S5WUwJrs0GM6Hk+THypYfAaKfFowHh?= =?us-ascii?Q?yoE6VJHfeW3aYl739UaLAJ5o8QM4usGxtqnE0U/S6dv6U9hy1uONBQ=3D=3D?= X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230040)(82310400026)(1800799024)(376014)(36860700013)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2024 10:26:28.1826 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f832d92d-86fc-4c7d-5311-08dc9e6f430a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002BA52.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4093 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 From: Erez Shitrit We don't have enough registers to copy TTL and TOS, so we will set TTL to be the default value (64) and will copy TOS. Fixes: 06d969a8c5b8 ("net/mlx5/hws: support NAT64 flow action") Cc: erezsh@nvidia.com Cc: stable@dpdk.org Signed-off-by: Erez Shitrit Acked-by: Matan Azrad --- drivers/net/mlx5/hws/mlx5dr_action.c | 66 +++++++++++++++++++++++----- drivers/net/mlx5/hws/mlx5dr_action.h | 2 + 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c index 8d3d0033e5..8f6be37818 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -315,21 +315,27 @@ mlx5dr_action_create_nat64_copy_state(struct mlx5dr_context *ctx, struct mlx5dr_action *action; uint32_t packet_len_field; uint8_t *action_ptr; - uint32_t ttl_field; + uint32_t tos_field; + uint32_t tos_size; uint32_t src_addr; uint32_t dst_addr; bool is_v4_to_v6; + uint32_t ecn; is_v4_to_v6 = attr->flags & MLX5DR_ACTION_NAT64_V4_TO_V6; if (is_v4_to_v6) { packet_len_field = MLX5_MODI_OUT_IPV4_TOTAL_LEN; - ttl_field = MLX5_MODI_OUT_IPV4_TTL; + tos_field = MLX5_MODI_OUT_IP_DSCP; + tos_size = 6; + ecn = MLX5_MODI_OUT_IP_ECN; src_addr = MLX5_MODI_OUT_SIPV4; dst_addr = MLX5_MODI_OUT_DIPV4; } else { packet_len_field = MLX5_MODI_OUT_IPV6_PAYLOAD_LEN; - ttl_field = MLX5_MODI_OUT_IPV6_HOPLIMIT; + tos_field = MLX5_MODI_OUT_IPV6_TRAFFIC_CLASS; + tos_size = 8; + ecn = 0; src_addr = MLX5_MODI_OUT_SIPV6_31_0; dst_addr = MLX5_MODI_OUT_DIPV6_31_0; } @@ -352,7 +358,7 @@ mlx5dr_action_create_nat64_copy_state(struct mlx5dr_context *ctx, } /* | 8 bit - 8 bit - 16 bit | - * | ttl - protocol - packet-len | + * | TOS - protocol - packet-len | */ MLX5_SET(copy_action_in, action_ptr, action_type, MLX5_MODIFICATION_TYPE_COPY); MLX5_SET(copy_action_in, action_ptr, src_field, packet_len_field); @@ -377,12 +383,25 @@ mlx5dr_action_create_nat64_copy_state(struct mlx5dr_context *ctx, action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; MLX5_SET(copy_action_in, action_ptr, action_type, MLX5_MODIFICATION_TYPE_COPY); - MLX5_SET(copy_action_in, action_ptr, src_field, ttl_field); + MLX5_SET(copy_action_in, action_ptr, src_field, tos_field); MLX5_SET(copy_action_in, action_ptr, dst_field, attr->registers[MLX5DR_ACTION_NAT64_REG_CONTROL]); MLX5_SET(copy_action_in, action_ptr, dst_offset, 24); - MLX5_SET(copy_action_in, action_ptr, length, 8); + MLX5_SET(copy_action_in, action_ptr, length, tos_size); action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + /* in ipv4 TOS = {dscp (6bits) - ecn (2bits) }*/ + if (ecn) { + MLX5_SET(copy_action_in, action_ptr, action_type, MLX5_MODIFICATION_TYPE_NOP); + action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + + MLX5_SET(copy_action_in, action_ptr, action_type, MLX5_MODIFICATION_TYPE_COPY); + MLX5_SET(copy_action_in, action_ptr, src_field, ecn); + MLX5_SET(copy_action_in, action_ptr, dst_field, + attr->registers[MLX5DR_ACTION_NAT64_REG_CONTROL]); + MLX5_SET(copy_action_in, action_ptr, dst_offset, 24 + tos_size); + MLX5_SET(copy_action_in, action_ptr, length, MLX5DR_ACTION_NAT64_ECN_SIZE); + action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + } /* set sip and dip to 0, in order to have new csum */ mlx5dr_action_create_nat64_zero_all_addr(&action_ptr, is_v4_to_v6); @@ -543,10 +562,13 @@ mlx5dr_action_create_nat64_copy_back_state(struct mlx5dr_context *ctx, uint32_t packet_len_field; uint32_t packet_len_add; uint8_t *action_ptr; + uint32_t tos_field; uint32_t ttl_field; + uint32_t tos_size; uint32_t src_addr; uint32_t dst_addr; bool is_v4_to_v6; + uint32_t ecn; is_v4_to_v6 = attr->flags & MLX5DR_ACTION_NAT64_V4_TO_V6; @@ -557,6 +579,9 @@ mlx5dr_action_create_nat64_copy_back_state(struct mlx5dr_context *ctx, ttl_field = MLX5_MODI_OUT_IPV6_HOPLIMIT; src_addr = MLX5_MODI_OUT_SIPV6_31_0; dst_addr = MLX5_MODI_OUT_DIPV6_31_0; + tos_field = MLX5_MODI_OUT_IPV6_TRAFFIC_CLASS; + tos_size = 8; + ecn = 0; } else { packet_len_field = MLX5_MODI_OUT_IPV4_TOTAL_LEN; /* ipv4 len is including 20 bytes of the header, so add 20 over ipv6 len */ @@ -564,6 +589,9 @@ mlx5dr_action_create_nat64_copy_back_state(struct mlx5dr_context *ctx, ttl_field = MLX5_MODI_OUT_IPV4_TTL; src_addr = MLX5_MODI_OUT_SIPV4; dst_addr = MLX5_MODI_OUT_DIPV4; + tos_field = MLX5_MODI_OUT_IP_DSCP; + tos_size = 6; + ecn = MLX5_MODI_OUT_IP_ECN; } memset(modify_action_data, 0, sizeof(modify_action_data)); @@ -578,20 +606,34 @@ mlx5dr_action_create_nat64_copy_back_state(struct mlx5dr_context *ctx, MLX5_SET(copy_action_in, action_ptr, length, 16); action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; - MLX5_SET(copy_action_in, action_ptr, action_type, MLX5_MODIFICATION_TYPE_NOP); - action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; - - MLX5_SET(copy_action_in, action_ptr, action_type, MLX5_MODIFICATION_TYPE_NOP); + MLX5_SET(set_action_in, action_ptr, action_type, MLX5_MODIFICATION_TYPE_SET); + MLX5_SET(set_action_in, action_ptr, field, ttl_field); + MLX5_SET(set_action_in, action_ptr, length, 8); + MLX5_SET(set_action_in, action_ptr, data, MLX5DR_ACTION_NAT64_TTL_DEFAULT_VAL); action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + /* copy TOS */ MLX5_SET(copy_action_in, action_ptr, action_type, MLX5_MODIFICATION_TYPE_COPY); MLX5_SET(copy_action_in, action_ptr, src_field, attr->registers[MLX5DR_ACTION_NAT64_REG_CONTROL]); - MLX5_SET(copy_action_in, action_ptr, dst_field, ttl_field); + MLX5_SET(copy_action_in, action_ptr, dst_field, tos_field); MLX5_SET(copy_action_in, action_ptr, src_offset, 24); - MLX5_SET(copy_action_in, action_ptr, length, 8); + MLX5_SET(copy_action_in, action_ptr, length, tos_size); action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + if (ecn) { + MLX5_SET(copy_action_in, action_ptr, action_type, MLX5_MODIFICATION_TYPE_NOP); + action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + + MLX5_SET(copy_action_in, action_ptr, action_type, MLX5_MODIFICATION_TYPE_COPY); + MLX5_SET(copy_action_in, action_ptr, src_field, + attr->registers[MLX5DR_ACTION_NAT64_REG_CONTROL]); + MLX5_SET(copy_action_in, action_ptr, dst_field, ecn); + MLX5_SET(copy_action_in, action_ptr, src_offset, 24 + tos_size); + MLX5_SET(copy_action_in, action_ptr, length, MLX5DR_ACTION_NAT64_ECN_SIZE); + action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + } + MLX5_SET(copy_action_in, action_ptr, action_type, MLX5_MODIFICATION_TYPE_NOP); action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; diff --git a/drivers/net/mlx5/hws/mlx5dr_action.h b/drivers/net/mlx5/hws/mlx5dr_action.h index faea6bb1f4..ba4ce55228 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.h +++ b/drivers/net/mlx5/hws/mlx5dr_action.h @@ -79,6 +79,8 @@ enum { MLX5DR_ACTION_NAT64_IPV4_HEADER = 5, MLX5DR_ACTION_NAT64_IPV6_VER = 0x60000000, MLX5DR_ACTION_NAT64_IPV4_VER = 0x45000000, + MLX5DR_ACTION_NAT64_TTL_DEFAULT_VAL = 64, + MLX5DR_ACTION_NAT64_ECN_SIZE = 2, }; /* 3 stages for the nat64 action */ -- 2.39.3