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 C7E3A455E3; Tue, 9 Jul 2024 14:33:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0577642E6A; Tue, 9 Jul 2024 14:32:28 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2056.outbound.protection.outlook.com [40.107.94.56]) by mails.dpdk.org (Postfix) with ESMTP id F16A942E66; Tue, 9 Jul 2024 14:32:25 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RUUkhJQoztDS1ibseMcuY6GZGyLlAB4dQkwkK22QFeYApmgggYnv6n0nDVbZrCoHSExYgAXuDZIzzEdqg1iAFK/3Zq6zils4W+xVOGBbd8RlZNQSpAr/va422oLUWgek2IIJXIgskHLl/vll26STbSIbfG9DHwCujZTV45LdcUO+k9D6HGnQMO6UgBcK7S0R/PY7VoD6GOdKZar7bcNcYcViFbCdxH+We/xS2q0eYJeDu3TzXYAPM/AlXfObY9MEEVwQexcxqXBwa5hh3/kgG19fyPjKNNE3PoFaWzTMl0FYTyHxlmbTjYGQndu/jpSZVZV7aXBgkjUp8ITs25J4iA== 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=dBvx85oFSvQOsRlpZPODzAkhqzo3t2GmwV/usxdttL4ILrBSvwDxwXaSlRTFS47QlTV/tv9HzMXZEfOCP8A5GsIfyurtZp8kMNJ436sX+qDnn8Mr55a41fNgUh4zfgChtlY3cwC3tXwvFjvdUNMh2OfltojPDukMuLWREv9ZUKKpdNSaULTMsDz5KyP6BJVjgwv01r18f1YTsTnjTfvODx9SuePRwVQYepO4O3hmf1PtuCTE+Gz7L8O9BwQAx1OsAaQIGOaywH7D1BsbpGiEZNWDE3D198UzxYuLDlp64rkCrZVXuVtiSnlPv26riMyPU8yycHNWOiwM9AGY5vQQng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=DQvwAYY5o/NjV6yjc5QREy3RYFuW4ubK2PScR10tqHeNRrB5YY7YoPBGul3251jU9ettiKbnZ52zZbV4SJ6S/Jrnjiz7MbQ5EQ7YXo46+W1mjXqB1Or8JOaVZI5FwC0PPtasUTubdc8Y8p36H5QLk81RYEyZ0uWhEL7eGcPUNQgtmGA+ZLHGw/uNlxtsP755qm8x38h9gjE/Tr8w3h19KnV5bgty46d1mQKu3B60pvI6Mc4O7PdJGTqz1OTG1EeCas9xyz540czzPkLzRnFg2nQDCC0nNL6H5wcP9iT28D5dmDY8cf3NlirbMAj42f5zbGBzYkLzP6UNO2DNXqTWzw== Received: from MN2PR06CA0017.namprd06.prod.outlook.com (2603:10b6:208:23d::22) by MN2PR12MB4285.namprd12.prod.outlook.com (2603:10b6:208:1d7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.20; Tue, 9 Jul 2024 12:32:22 +0000 Received: from BL6PEPF0001AB54.namprd02.prod.outlook.com (2603:10b6:208:23d:cafe::4) by MN2PR06CA0017.outlook.office365.com (2603:10b6:208:23d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.36 via Frontend Transport; Tue, 9 Jul 2024 12:32:20 +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 BL6PEPF0001AB54.mail.protection.outlook.com (10.167.241.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.17 via Frontend Transport; Tue, 9 Jul 2024 12:32:20 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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.1544.4; Tue, 9 Jul 2024 05:31:49 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 9 Jul 2024 05:31:49 -0700 Received: from nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4 via Frontend Transport; Tue, 9 Jul 2024 05:31:45 -0700 From: Itamar Gozlan To: , , , , , , , , Dariusz Sosnowski , Bing Zhao , Ori Kam , Matan Azrad CC: , Subject: [PATCH 8/8] net/mlx5/hws: fix NA64 copy TOS field instead of TTL Date: Tue, 9 Jul 2024 15:31:03 +0300 Message-ID: <20240709123103.2101902-9-igozlan@nvidia.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240709123103.2101902-1-igozlan@nvidia.com> References: <20240707102532.2045942-10-igozlan@nvidia.com> <20240709123103.2101902-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: BL6PEPF0001AB54:EE_|MN2PR12MB4285:EE_ X-MS-Office365-Filtering-Correlation-Id: 0869725f-6b27-45b6-c53b-08dca0132d59 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|376014|36860700013|1800799024|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wirMBVZ9ZGrz7Zvfz2k96O/q2MNiDjRha+f3eXb2toikBVMLpcwic2Z34fI6?= =?us-ascii?Q?p6mzLRq3LOsxA6SRISRACmkYu1O9x1WQ96or3dbUyb9ePZm9Wpaa2zxMz5IW?= =?us-ascii?Q?Ya2L8/AuKm/TqjrhikNnAglLpsmldBZgFu+PPsjsNlDvsmoIyjbI+WbNSEsZ?= =?us-ascii?Q?3nkumC+4FzuLF6ETsHiDIL2aprHPx7ayNlWIg5jH23NgNinzwEhOJtkxpfa7?= =?us-ascii?Q?VBA5ZSmf6+dVzy0mzs8Vq9/HaXYmvDjNB8VuUTkSVYJ2D75d3UQGthZCfeFa?= =?us-ascii?Q?Zu7NxjaFXjwgb7HzPl4LeexQRh0Dmzdb4RDhGYEYJlGAGoEurR5Wc4jQH5+W?= =?us-ascii?Q?oBn+I54C8A7lGlxOgzZFvxgtB7uox7lHD5ko6nZwCB2Q5FsOmBkTETpsh8te?= =?us-ascii?Q?nw/BFDT4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H70dJ?= =?us-ascii?Q?OJA+TCXhh+GGrVTGYcsJZaEcOLCs0HSF+c5nqnbFfrxKuFdS8bZJM0PZCurs?= =?us-ascii?Q?QSnNsiuIl9/5em+kkC+YGJZ9xNHg06ro2IgWZ0U8/B/qCxjJylYe0OyevgKk?= =?us-ascii?Q?RDHjQj7hX7cyAT4X4NAl7Cv4MwNe5BifZYBQTvDo9TgVIkeiA9RuSw=3D=3D?= 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:(13230040)(376014)(36860700013)(1800799024)(82310400026)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 12:32:20.3260 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0869725f-6b27-45b6-c53b-08dca0132d59 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: BL6PEPF0001AB54.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4285 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: 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