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 8FCE9455B6; Sun, 7 Jul 2024 12:26:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D140E40676; Sun, 7 Jul 2024 12:26:28 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2087.outbound.protection.outlook.com [40.107.236.87]) by mails.dpdk.org (Postfix) with ESMTP id 5615440664; Sun, 7 Jul 2024 12:26:27 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WyygEg+ELqryAPw0nA6A5M+QacguyCGvOeLtMi6NG82vrwNsdAliwwieLf2jmBYRS2WO5JEy9I9J7XuR6GXl+BZQF8FB5RpIDhfci5l+KidBIwcM26nDSL5fN3Ehtk7BazTQC8w4Dh83gH8dVubPaVd4bGv9NNkUpFWBp8YtYnRLrW23hkmP9S4J+A1RoiZNjR8jEy1AX+dkLSShadcT7Pv4TLlsMll/2+OwR2ey5tDWkMFRf+kwQPnWUBO5A69YafmVnvJRg/sFNxiVZzMhFAJUMR/SovutUoN4LcRVjy4yEKAMqGDFh3fu55dJVCqeYNxivGkdebo+q4LHnQqJCA== 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=Lpfcgf40tfD+BqRj0urH3tSGTzbo+PqEYNrCZLn2+b0=; b=OSGoPq57/RDbXNpQYTTemUt5gUPOBSjrojTnk5wUjOW1iz300eCI7YkihTwE4wkBxcOJqzulthYgZ1fwbIZj1NesysKOLCVxDzDCU5lbolrqojSBvBTOvqhvB6CkBD6AAqRwKbzV3r7pbPFX9UqBOkvf1gVNrdGIWXjQT57C3elScoVINP1W6rGiFnTxiPf5LdgdMZ3VnlIdHUBjLZjVbshB1tRB9owqlvSIJKMyjYr67Qi98oIvRbe/9V9KK+hq5X3FEbJBo7kwhvheY0ODtX/XtpqLWWWTScqeU/+pWbZ0mARhdpTwOTGWcF9zE3Fy77Tlk5iujf+6D4takn3dnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=Lpfcgf40tfD+BqRj0urH3tSGTzbo+PqEYNrCZLn2+b0=; b=Di/avEpKm5euK62MKZH9JF16+iRd0E/iJ63dVpvzG2L83dVGLwL7uhq9Rd8j1a74Vyj/Cz06bPPZAyPJnZ2tRmRza9YpwBsVTeznBFpCe3EHKK6ebNNEW20wRJO6imDrSx4ewYIOLdSRwF2C6jNB3Otz46SrCaS0v7GDluCteUN2kp/VybPW5XOUZm5jepoyUTko97cm5OLzwDFJDzwfh+TUtNKdeVKLbjaDSBbYFbyf1e348xwdfAoFwEPzSmHQzVDFGUFfBjV/bh8YdbILNySabVj5i4iZOm526FT9ZN+5Aap2z0tszx/MzEHxGlPMdDNxwi1/S/rABkjUwBRFAg== Received: from MN2PR15CA0042.namprd15.prod.outlook.com (2603:10b6:208:237::11) by DS0PR12MB6534.namprd12.prod.outlook.com (2603:10b6:8:c1::19) 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:24 +0000 Received: from BL6PEPF0001AB59.namprd02.prod.outlook.com (2603:10b6:208:237:cafe::e3) by MN2PR15CA0042.outlook.office365.com (2603:10b6:208:237::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.34 via Frontend Transport; Sun, 7 Jul 2024 10:26:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BL6PEPF0001AB59.mail.protection.outlook.com (10.167.241.11) 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:24 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) 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:16 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.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; Sun, 7 Jul 2024 03:26:16 -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:12 -0700 From: Itamar Gozlan To: , , , , , , , , Dariusz Sosnowski , Bing Zhao , Ori Kam , Matan Azrad CC: , Subject: [PATCH 09/10] net/mlx5/hws: fix NAT64 csum issue Date: Sun, 7 Jul 2024 13:25:30 +0300 Message-ID: <20240707102532.2045942-9-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: BL6PEPF0001AB59:EE_|DS0PR12MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c550f72-a18d-40c6-4266-08dc9e6f40a9 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?8COJjIQEgcltKhe5DkfnVo7sKYl7MvFzfxp8uGCakLW5rO7p89SNDVVcADcz?= =?us-ascii?Q?JwcZc2NQisFR4uhQVUVxlNUUDbptfP/o2Gm5YFvZ8BL56qF4X0Kb6BXlPLOu?= =?us-ascii?Q?/PRSbazjlAgimoAJkAReE4CyYKmYU0QdZ+EUPBd8K7DeudNYsrKVMMr7qZbw?= =?us-ascii?Q?7NBJrl3BouCrNdR618/xrODXpOKlazq81XdBSLnELUcgAK2NLkozEWEKDBc9?= =?us-ascii?Q?OWULI92VrSpefyRxDxIFh1dwCDRd8r4lktwXmbYP/ikPUDBQKrvGvUQBkrME?= =?us-ascii?Q?CPPPseMoG3jhjpg5Uwcnxbw7XFaMV42GylKvsNepiBPPWdZG25jVeKxpr4D1?= =?us-ascii?Q?nl9GBE47rAKt8jZy0dPadI0xJ5f1byr+D9Nz0S48xsBcdizpkLXiz/a22ycb?= =?us-ascii?Q?1RuKEpvClwGXuGTGwU/bgUVFOUeLcEpGuqvbDSdNKNgYpTU2xOp2coKIe/Yy?= =?us-ascii?Q?wy3BahDbURAlWMz196Z43B77F1qPiX3eFCcl9Z65qLSfkTV3xxzir2H+Z84F?= =?us-ascii?Q?IFenvPb3cK0rDMKoy/ekrb9pnqP4hdj+786rgfQiQn2Kawf1T13ffOrm862B?= =?us-ascii?Q?ysJZbXk1H6QKjd/o2sOWEG3tI6fa7TAF6RqQ1FSD9FidcqmynLZv78wLsuPQ?= =?us-ascii?Q?0aHl9zPq3XI2JPefKz7rLRPjFu4nDqZALOBKsG8lfvXp5bOjDAz8BSepwO/q?= =?us-ascii?Q?nkHd+oPRNjqdOncC9ZUpoaOEr5l+ic46s656owbpg7oeVGogm0UnQRDgQ0S2?= =?us-ascii?Q?OmVv+7k8B4XOLqbVK+B8Wb94LxenJI3jDMir577A53+96nW2sQKnvrpRV8j5?= =?us-ascii?Q?U3Sa5Sn1ay0/xSccpyPHPkdjUisp3LrAefPXhRQhxMHDRVNx7i02rHWYhj/4?= =?us-ascii?Q?0R5ZA+kocXn6WPIesTXbXYYa5OiTfjhWUd8E2rwUooE0Wkb4i/knC0xue/Qe?= =?us-ascii?Q?/kzlyXCgRQzeUqrJlfNRkZM1ymVLQOjBoYfhPOkqjCEQzd9EEOvSZM3Z5n3O?= =?us-ascii?Q?I5p63vmHDP8u7/6b7lQ9EUnvFWdhh68jpwHw46n8my3oJ2u9kCILFGCB9ZXo?= =?us-ascii?Q?rw73aeu/fn9I664qpvNs06Xorbs3WYkP/tSspw70WDXwM2IDAlhRAFALVf+Q?= =?us-ascii?Q?LwY8VUPgac057F9oihFqmH/moJul/h1mf25kwhEydkVh0VwLQzXxnUeS3YRG?= =?us-ascii?Q?uf3+1ibR9Vo5Qm425WuSygaXXPNpQ60lgOTgZtIMNKlIl/rRJlUslkUDWQc9?= =?us-ascii?Q?4fZMdq8XV+3wOpQPaHPyJoF8sOaRAiH+CkUlR0YWKhYq3/ciUAAS3LYvR+dW?= =?us-ascii?Q?F6BHC74Sh37+Q9zQR6igJwiqvpha604cUk0+mO9MBcL81/7ti106uJ7NLM97?= =?us-ascii?Q?uxeGscoKWh0INsjh1IVPG3ASpYB4piZj/riyVWBXXb5pizrIzZjyTUeinMsj?= =?us-ascii?Q?pHv/+L4X18E7HIaanojesU1uaZtlM/CpdOXOAU4VaLt8eURFAcoQjw=3D=3D?= X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2024 10:26:24.1285 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c550f72-a18d-40c6-4266-08dc9e6f40a9 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.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB59.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6534 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 Due to HW limitation we got two csum's that were not correct, udp and ip, both of them were not calculated correctly by the HW. By adding the next W/A we allow the HW to collect it well: Separate the protocol field and zero all the addresses before fixed the UDP csum. We saw that the IP csum by the HW didn't take the ipv4 version as part of the csum because the way it was inserted into the packet, in order to solve that we added a prefix that takes into account the real csum for the ip version and from that point the HW calculating the csum correctly. 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 | 136 ++++++++++++++++++++++----- drivers/net/mlx5/hws/mlx5dr_action.h | 15 ++- 2 files changed, 123 insertions(+), 28 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c index 0d90280a7d..8d3d0033e5 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -249,6 +249,62 @@ static void mlx5dr_action_put_shared_stc(struct mlx5dr_action *action, mlx5dr_action_put_shared_stc_nic(ctx, stc_type, MLX5DR_TABLE_TYPE_FDB); } +static void +mlx5dr_action_create_nat64_zero_all_addr(uint8_t **action_ptr, bool is_v4_to_v6) +{ + if (is_v4_to_v6) { + MLX5_SET(set_action_in, *action_ptr, action_type, MLX5_MODIFICATION_TYPE_SET); + MLX5_SET(set_action_in, *action_ptr, field, MLX5_MODI_OUT_SIPV4); + MLX5_SET(set_action_in, *action_ptr, data, 0); + *action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + + MLX5_SET(set_action_in, *action_ptr, action_type, MLX5_MODIFICATION_TYPE_SET); + MLX5_SET(set_action_in, *action_ptr, field, MLX5_MODI_OUT_DIPV4); + MLX5_SET(set_action_in, *action_ptr, data, 0); + *action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + } else { + MLX5_SET(set_action_in, *action_ptr, action_type, MLX5_MODIFICATION_TYPE_SET); + MLX5_SET(set_action_in, *action_ptr, field, MLX5_MODI_OUT_SIPV6_127_96); + MLX5_SET(set_action_in, *action_ptr, data, 0); + *action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + + MLX5_SET(set_action_in, *action_ptr, action_type, MLX5_MODIFICATION_TYPE_SET); + MLX5_SET(set_action_in, *action_ptr, field, MLX5_MODI_OUT_SIPV6_95_64); + MLX5_SET(set_action_in, *action_ptr, data, 0); + *action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + + MLX5_SET(set_action_in, *action_ptr, action_type, MLX5_MODIFICATION_TYPE_SET); + MLX5_SET(set_action_in, *action_ptr, field, MLX5_MODI_OUT_SIPV6_63_32); + MLX5_SET(set_action_in, *action_ptr, data, 0); + *action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + + MLX5_SET(set_action_in, *action_ptr, action_type, MLX5_MODIFICATION_TYPE_SET); + MLX5_SET(set_action_in, *action_ptr, field, MLX5_MODI_OUT_SIPV6_31_0); + MLX5_SET(set_action_in, *action_ptr, data, 0); + *action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + + MLX5_SET(set_action_in, *action_ptr, action_type, MLX5_MODIFICATION_TYPE_SET); + MLX5_SET(set_action_in, *action_ptr, field, MLX5_MODI_OUT_DIPV6_127_96); + MLX5_SET(set_action_in, *action_ptr, data, 0); + *action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + + MLX5_SET(set_action_in, *action_ptr, action_type, MLX5_MODIFICATION_TYPE_SET); + MLX5_SET(set_action_in, *action_ptr, field, MLX5_MODI_OUT_DIPV6_95_64); + MLX5_SET(set_action_in, *action_ptr, data, 0); + *action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + + MLX5_SET(set_action_in, *action_ptr, action_type, MLX5_MODIFICATION_TYPE_SET); + MLX5_SET(set_action_in, *action_ptr, field, MLX5_MODI_OUT_DIPV6_63_32); + MLX5_SET(set_action_in, *action_ptr, data, 0); + *action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + + MLX5_SET(set_action_in, *action_ptr, action_type, MLX5_MODIFICATION_TYPE_SET); + MLX5_SET(set_action_in, *action_ptr, field, MLX5_MODI_OUT_DIPV6_31_0); + MLX5_SET(set_action_in, *action_ptr, data, 0); + *action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; + } +} + static struct mlx5dr_action * mlx5dr_action_create_nat64_copy_state(struct mlx5dr_context *ctx, struct mlx5dr_action_nat64_attr *attr, @@ -329,17 +385,7 @@ mlx5dr_action_create_nat64_copy_state(struct mlx5dr_context *ctx, action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; /* set sip and dip to 0, in order to have new csum */ - if (is_v4_to_v6) { - MLX5_SET(set_action_in, action_ptr, action_type, MLX5_MODIFICATION_TYPE_SET); - MLX5_SET(set_action_in, action_ptr, field, MLX5_MODI_OUT_SIPV4); - MLX5_SET(set_action_in, action_ptr, data, 0); - action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; - - MLX5_SET(set_action_in, action_ptr, action_type, MLX5_MODIFICATION_TYPE_SET); - MLX5_SET(set_action_in, action_ptr, field, MLX5_MODI_OUT_DIPV4); - MLX5_SET(set_action_in, action_ptr, data, 0); - action_ptr += MLX5DR_ACTION_DOUBLE_SIZE; - } + mlx5dr_action_create_nat64_zero_all_addr(&action_ptr, is_v4_to_v6); pat[0].data = modify_action_data; pat[0].sz = (action_ptr - (uint8_t *)modify_action_data); @@ -383,9 +429,14 @@ mlx5dr_action_create_nat64_repalce_state(struct mlx5dr_context *ctx, memcpy(address_prefix, nat64_well_known_pref, MLX5DR_ACTION_NAT64_HEADER_MINUS_ONE * sizeof(uint32_t)); } else { + /* In order to fix HW csum issue, make the prefix ready */ + uint32_t ipv4_pref[] = {0x0, 0xffba0000, 0x0, 0x0, 0x0}; + header_size_in_dw = MLX5DR_ACTION_NAT64_IPV4_HEADER; ip_ver = MLX5DR_ACTION_NAT64_IPV4_VER; eth_type = RTE_ETHER_TYPE_IPV4; + memcpy(address_prefix, ipv4_pref, + MLX5DR_ACTION_NAT64_IPV4_HEADER * sizeof(uint32_t)); } memset(modify_action_data, 0, sizeof(modify_action_data)); @@ -441,6 +492,46 @@ mlx5dr_action_create_nat64_repalce_state(struct mlx5dr_context *ctx, return action; } +static struct mlx5dr_action * +mlx5dr_action_create_nat64_copy_proto_state(struct mlx5dr_context *ctx, + struct mlx5dr_action_nat64_attr *attr, + uint32_t flags) +{ + __be64 modify_action_data[MLX5DR_ACTION_NAT64_MAX_MODIFY_ACTIONS]; + struct mlx5dr_action_mh_pattern pat[2]; + struct mlx5dr_action *action; + uint8_t *action_ptr; + + memset(modify_action_data, 0, sizeof(modify_action_data)); + action_ptr = (uint8_t *)modify_action_data; + + 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, + MLX5_MODI_OUT_IP_PROTOCOL); + MLX5_SET(copy_action_in, action_ptr, src_offset, 16); + MLX5_SET(copy_action_in, action_ptr, dst_offset, 0); + MLX5_SET(copy_action_in, action_ptr, length, 8); + 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; + + pat[0].data = modify_action_data; + pat[0].sz = action_ptr - (uint8_t *)modify_action_data; + + action = mlx5dr_action_create_modify_header_reparse(ctx, 1, pat, 0, flags, + MLX5DR_ACTION_STC_REPARSE_ON); + if (!action) { + DR_LOG(ERR, "Failed to create action: action_sz: %zu, flags: 0x%x\n", + pat[0].sz, flags); + return NULL; + } + + return action; +} + static struct mlx5dr_action * mlx5dr_action_create_nat64_copy_back_state(struct mlx5dr_context *ctx, struct mlx5dr_action_nat64_attr *attr, @@ -490,16 +581,6 @@ mlx5dr_action_create_nat64_copy_back_state(struct mlx5dr_context *ctx, 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, - MLX5_MODI_OUT_IP_PROTOCOL); - MLX5_SET(copy_action_in, action_ptr, src_offset, 16); - MLX5_SET(copy_action_in, action_ptr, dst_offset, 0); - MLX5_SET(copy_action_in, action_ptr, length, 8); - 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; @@ -2051,7 +2132,7 @@ mlx5dr_action_create_modify_header_hws(struct mlx5dr_action *action, return rte_errno; } -static struct mlx5dr_action * +struct mlx5dr_action * mlx5dr_action_create_modify_header_reparse(struct mlx5dr_context *ctx, uint8_t num_of_patterns, struct mlx5dr_action_mh_pattern *patterns, @@ -2927,17 +3008,24 @@ mlx5dr_action_create_nat64(struct mlx5dr_context *ctx, DR_LOG(ERR, "Nat64 failed creating replace state"); goto free_copy; } + action->nat64.stages[MLX5DR_ACTION_NAT64_STAGE_COPY_PROTOCOL] = + mlx5dr_action_create_nat64_copy_proto_state(ctx, attr, flags); + if (!action->nat64.stages[MLX5DR_ACTION_NAT64_STAGE_COPY_PROTOCOL]) { + DR_LOG(ERR, "Nat64 failed creating copy protocol state"); + goto free_replace; + } action->nat64.stages[MLX5DR_ACTION_NAT64_STAGE_COPYBACK] = mlx5dr_action_create_nat64_copy_back_state(ctx, attr, flags); if (!action->nat64.stages[MLX5DR_ACTION_NAT64_STAGE_COPYBACK]) { DR_LOG(ERR, "Nat64 failed creating copyback state"); - goto free_replace; + goto free_copy_proto; } return action; - +free_copy_proto: + mlx5dr_action_destroy(action->nat64.stages[MLX5DR_ACTION_NAT64_STAGE_COPY_PROTOCOL]); free_replace: mlx5dr_action_destroy(action->nat64.stages[MLX5DR_ACTION_NAT64_STAGE_REPLACE]); free_copy: diff --git a/drivers/net/mlx5/hws/mlx5dr_action.h b/drivers/net/mlx5/hws/mlx5dr_action.h index 57e059a572..faea6bb1f4 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.h +++ b/drivers/net/mlx5/hws/mlx5dr_action.h @@ -11,9 +11,6 @@ /* Max number of internal subactions of ipv6_ext */ #define MLX5DR_ACTION_IPV6_EXT_MAX_SA 4 -/* Number of MH in NAT64 */ -#define MLX5DR_ACTION_NAT64_STAGES 3 - enum mlx5dr_action_stc_idx { MLX5DR_ACTION_STC_IDX_CTRL = 0, MLX5DR_ACTION_STC_IDX_HIT = 1, @@ -88,7 +85,10 @@ enum { enum mlx5dr_action_nat64_stages { MLX5DR_ACTION_NAT64_STAGE_COPY = 0, MLX5DR_ACTION_NAT64_STAGE_REPLACE = 1, - MLX5DR_ACTION_NAT64_STAGE_COPYBACK = 2, + MLX5DR_ACTION_NAT64_STAGE_COPY_PROTOCOL = 2, + MLX5DR_ACTION_NAT64_STAGE_COPYBACK = 3, + /* Number of MH in NAT64 */ + MLX5DR_ACTION_NAT64_STAGES = 4, }; /* Registers for keeping data from stage to stage */ @@ -256,6 +256,13 @@ int mlx5dr_action_alloc_single_stc(struct mlx5dr_context *ctx, void mlx5dr_action_free_single_stc(struct mlx5dr_context *ctx, uint32_t table_type, struct mlx5dr_pool_chunk *stc); +struct mlx5dr_action * +mlx5dr_action_create_modify_header_reparse(struct mlx5dr_context *ctx, + uint8_t num_of_patterns, + struct mlx5dr_action_mh_pattern *patterns, + uint32_t log_bulk_size, + uint32_t flags, uint32_t reparse); + static inline void mlx5dr_action_setter_default_single(struct mlx5dr_actions_apply_data *apply, -- 2.39.3