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 1619743B54; Tue, 20 Feb 2024 15:11:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5AEFB40A7A; Tue, 20 Feb 2024 15:11:16 +0100 (CET) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2057.outbound.protection.outlook.com [40.107.100.57]) by mails.dpdk.org (Postfix) with ESMTP id 133844067C for ; Tue, 20 Feb 2024 15:11:14 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=etXjDXYp+QRoBp8CY+dme7uknf0p2q9Yn07rFnnk1qOnQ514zsMo9wmEhLGj+ijXyP5bEHEpSksKfRMv29hiRuuAy0g2Zgbxznqcs1KFo4Wtyz7nJyYnUyERNsTcdS3/XucBtmOOurK+R4khONJQFUFFjdXwKn34Q+FOYb6ZlbBFcRT/9tqjMIA0BYCU+5jVxwO6yKw/xf1PtmlQ/U/qfMdolDfievZTXcs2GI3Zw0omlf7PEoz3dMS+7bprLxqoV+KbikhGLeFzlFCOjdhm7aSowW5nJZV0MHtjh1MTlVhyW1cYBnkj86SMaZUxW7hvmU5Njkj+hon9lFothaG7YQ== 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=0k/meV3YkF6HznAwGNGa+QBPAQ6vEHmJ3i0EwJFcljw=; b=Iy88MoGt20PGm/lkvHuTEUcooy+qjTZV8Xo3/ksDdvzGOsUv6GBsxlZstWIC0YPDxgcuojgecLE4qid4R162zLzDIbuogU4xMTnXS7sx6ZPmqV+weylBwSF4/NabNob9RHg168Jn+67Wr49A8J2Zh8323553CkwiKcheHzhK5rHbUMaoBEMo2Bj+Lo11yB7Yj5qpHLROq+CkK0zjiLgOjCqSc4tKdoUFyHxbxiH7KVuXHutnRG4aUKAPu0z9XpL5emHceRLYflV1XzL3vqHwTQ0YDvDLmCL0AWxwA+TPRFX1Xrwmu/arGzUz3ZvgT5Bxs2kZtyif5QRSwMIkwClkAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=intel.com 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=0k/meV3YkF6HznAwGNGa+QBPAQ6vEHmJ3i0EwJFcljw=; b=qhB8/AFXguWBjFpWMY3JSeUC178YMJg2BoR3YIEOQdCaV0npzulGpyCCTbpYQ7jXw6zLpZtndWdCS7RZISDew2ZF65ip+pdz8IQTkBZMQAiySwYKHyr+Y72UyRhnwfrVbgfEOn+jj7U/jBzMBJ0LM1EMtqS1ArQ73RpOjHl8EEUZPKJJs/Ln1Xi0bvrGAQP+6obD2sNpn2a9Q7ZYD9I2aVSnGyrre+PHYvTOPktc+lWqfuvCmOx70hTIOafa1rTSEhX6FYl8a7zUJi7Bk28JRHuls4V6YX+hlTGr9BuKFi1mXYHewO0TOdTF4Fly/YBPGvO76WO2gcpZZitc2HRDoQ== Received: from MW4PR04CA0365.namprd04.prod.outlook.com (2603:10b6:303:81::10) by SA0PR12MB4368.namprd12.prod.outlook.com (2603:10b6:806:9f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.21; Tue, 20 Feb 2024 14:11:11 +0000 Received: from CO1PEPF000042AD.namprd03.prod.outlook.com (2603:10b6:303:81:cafe::f6) by MW4PR04CA0365.outlook.office365.com (2603:10b6:303:81::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.40 via Frontend Transport; Tue, 20 Feb 2024 14:11:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1PEPF000042AD.mail.protection.outlook.com (10.167.243.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Tue, 20 Feb 2024 14:11:11 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 20 Feb 2024 06:10:53 -0800 Received: from nvidia.com (10.126.231.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.1258.12; Tue, 20 Feb 2024 06:10:49 -0800 From: Bing Zhao To: , , , , , , , , , , Subject: [PATCH v2 4/5] net/mlx5: add NAT64 action support in rule creation Date: Tue, 20 Feb 2024 16:10:07 +0200 Message-ID: <20240220141008.292641-5-bingz@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240220141008.292641-1-bingz@nvidia.com> References: <20231227090731.2569427-1-bingz@nvidia.com> <20240220141008.292641-1-bingz@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AD:EE_|SA0PR12MB4368:EE_ X-MS-Office365-Filtering-Correlation-Id: 85d4fb8c-1cd1-46ad-bcb7-08dc321dca8f 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; X-Microsoft-Antispam-Message-Info: BiRPXnC/M5bzArNKT/30oNg8USv05cyv18FNIabQKeTYrP9Cew+OuzIdutd6A/75R5IqII4sGx8KdP5nEl9xIHWCc+vIYo51tvVpMn/yzJ3bf8KNQoUo2bkOdEDOfTfFKaRDBq5OJv4EFObModqfn1AQHv+BVp5rk1CsOVW9iU8zP1eJ/nC9VmC+Bh1CdffJq4N7xLakN2wvZvGkZ3icl/kiUejDFysFPQUuZWUf6T/B2+xCLF90mCkP6z3/NqwrQplhtG+GgeFOZ28xFo4LAtkq1/fi9WJt3q7VDvTF+2AAYQuv1nP4nzHp2cqTx74zzt3sBb4HfWjOqCJnLwHJp/KP4QbyEn6aafE6W4XSc1Ly9nNplsVB/AVvqJ/V57vF5vRtFS5u4ik4RMOG/03A98OImTZHhooN1DLhI6/uSYrHvnEDigaYNf9Y8iQTjbwL82pus4HJEzG522kUjtJxHIPEIxi1/7mkOBLe/5KxhYlT39ySofKtI8xoYAlvzM2qxbAyYR6aYfA6LDXqPTJMQM+IE9PQA/cN3jztlQ9nvcBDKWcO/RD3H2M/MRdAOy0U2kBJiuUJX0JEkY7pB7h4RdQS8qNG84t72kzzavia59VgATNyHaBdcWNQjsJ09ZofJN2Hvd48GfDWwOWP4oY1GFFHwEiQdM1rz4HL0lLd5m8= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(36860700004)(40470700004)(46966006)(921011); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2024 14:11:11.2531 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 85d4fb8c-1cd1-46ad-bcb7-08dc321dca8f 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4368 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 The action will handle the IPv4 and IPv6 headers translation. It will add / remove IPv6 address prefix by default. To use the user specific address, another rule to modify the addresses of the IP header is needed. Signed-off-by: Bing Zhao --- drivers/net/mlx5/mlx5_flow_hw.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index f53df40041..abe7159ad1 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -2492,6 +2492,19 @@ __flow_hw_actions_translate(struct rte_eth_dev *dev, } acts->rule_acts[dr_pos].action = priv->hw_def_miss; break; + case RTE_FLOW_ACTION_TYPE_NAT64: + if (masks->conf && + ((const struct rte_flow_action_nat64 *)masks->conf)->type) { + const struct rte_flow_action_nat64 *nat64_c = + (const struct rte_flow_action_nat64 *)actions->conf; + + acts->rule_acts[dr_pos].action = + priv->action_nat64[type][nat64_c->type]; + } else if (__flow_hw_act_data_general_append(priv, acts, + actions->type, + src_pos, dr_pos)) + goto err; + break; case RTE_FLOW_ACTION_TYPE_END: actions_end = true; break; @@ -2934,6 +2947,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, const struct rte_flow_action_ethdev *port_action = NULL; const struct rte_flow_action_meter *meter = NULL; const struct rte_flow_action_age *age = NULL; + const struct rte_flow_action_nat64 *nat64_c = NULL; uint8_t *buf = job->encap_data; uint8_t *push_buf = job->push_data; struct rte_flow_attr attr = { @@ -3201,6 +3215,11 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, if (ret != 0) return ret; break; + case RTE_FLOW_ACTION_TYPE_NAT64: + nat64_c = action->conf; + rule_acts[act_data->action_dst].action = + priv->action_nat64[table->type][nat64_c->type]; + break; default: break; } @@ -5959,6 +5978,7 @@ static enum mlx5dr_action_type mlx5_hw_dr_action_types[] = { [RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL] = MLX5DR_ACTION_TYP_DEST_ROOT, [RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH] = MLX5DR_ACTION_TYP_PUSH_IPV6_ROUTE_EXT, [RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE] = MLX5DR_ACTION_TYP_POP_IPV6_ROUTE_EXT, + [RTE_FLOW_ACTION_TYPE_NAT64] = MLX5DR_ACTION_TYP_NAT64, }; static inline void -- 2.34.1