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 764AA43B54; Tue, 20 Feb 2024 15:38:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7637440A70; Tue, 20 Feb 2024 15:38:31 +0100 (CET) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2073.outbound.protection.outlook.com [40.107.96.73]) by mails.dpdk.org (Postfix) with ESMTP id F120940A70 for ; Tue, 20 Feb 2024 15:38:29 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EBKt3jLsiul2ycYgKIrTQ8pQ0XkuSO9AadBtWIRJEZSLfKgF8OY8tw4NhwypstX3WtKEKH8NSoVGRn1C8iMafV6W/Yj8SHA87f9E+g5ncxpwzUeyOSyqw+nBhmBE9gf8jSiWgUX/csl1ni4RsTxq9cI8muKAEI8Dy8SP2RjBuzHCiI8S8h3FygOPnmw9+NqMR/iUXBJL05sTs+WfXgMwbzu2lzDcmVIsf+4Kg93DLxBzqmzfzTAMRA0j2DMMEojD5NU1onzP4QTxyGTk4/BAkT+ht0MuVMulkzmTsks8r8Jph9d9s28eKWYV44WXxVrx3rlUoOeMCMvpOlngUr57Zg== 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=JXb8G4M+NkuCowlw5BxFISpkA67FrG8t0dQha6FhubU=; b=JVQxfOzZL6C0IXDZlhb7WP5UmzMkHszlP4jweq6KlX9+v2bh/V3NMwz6sr5i+peRAz/xuXprPvBBjOHBLzI4vxB/jvT0My/qHj8XBrI34osV3isbvQocvUCqfeHIpPtPlWuzE+QjWXt884tZpebihOdoyXHqHTOlBJ2K7PIjzkja3C9CVmj7c2XalXEO6vpiqtJmze/ZnPsisQmaac8tMQL1mKjz1UkfPsRTnsQ0UA1ePumeVdQxiuOUrG2xvevnoElrvakyOSKfy8kUCMkIPQ4tVqUUSIDRsPL17dmYHc9oakw2BwAHXy/MHgGn7W/mBSPhEaZzBD0+bLDk1Qc+aw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=JXb8G4M+NkuCowlw5BxFISpkA67FrG8t0dQha6FhubU=; b=NrvxnP57xGJF0TROEGaBKlW8VPzrPN1SSdADNglQSJtohEds2i6Qznjr6bSKlotyoPUfvALewyD/H5or7bn7RDdhENhCgtpMFNOKUDazcwd3mTDLDWMPD87TYHnslnJuD0vToLEOOs64KJUs5nx0SwGwUcZL+og2h2x/axa2yAJzol0pq5VmOXX6kPwZmRt8oeVo7cVbssoyq5revo5MuadLpMy+cBl7xLNZmZCg0jfWcfxU1mJscM0fPwUrMZX7aisD/73bsQsWFjdDEgPw+ijDbe2lBOnpUvsagTTIA6d4zGTuux08BkIQRsfFc6wH7VTxjPOtYx/kTa99nYzXdg== Received: from DS7PR06CA0015.namprd06.prod.outlook.com (2603:10b6:8:2a::26) by CH3PR12MB8546.namprd12.prod.outlook.com (2603:10b6:610:15f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.19; Tue, 20 Feb 2024 14:38:24 +0000 Received: from DS2PEPF0000343C.namprd02.prod.outlook.com (2603:10b6:8:2a:cafe::50) by DS7PR06CA0015.outlook.office365.com (2603:10b6:8:2a::26) 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:38:24 +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 DS2PEPF0000343C.mail.protection.outlook.com (10.167.18.39) 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:38:24 +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; Tue, 20 Feb 2024 06:38:10 -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:38:07 -0800 From: Bing Zhao To: , , , , , , , , , , Subject: [PATCH v3 5/5] net/mlx5: validate the actions combination with NAT64 Date: Tue, 20 Feb 2024 16:37:31 +0200 Message-ID: <20240220143731.295140-6-bingz@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240220143731.295140-1-bingz@nvidia.com> References: <20231227090731.2569427-1-bingz@nvidia.com> <20240220143731.295140-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: DS2PEPF0000343C:EE_|CH3PR12MB8546:EE_ X-MS-Office365-Filtering-Correlation-Id: dbf9075c-c717-4319-3bde-08dc3221982f 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: +Bioh0wpYKuOdpf/PPDDxD4qH9xG7M9nePPmJPuguaqTlrUdNl4OJY4MQY1zTgRrM8/2nnuR3S94EaHdt0fgX6VTbfClnqxjjyTB0+0gt4E7I9rBuKLnlaJeiu1cxg9Q6zAQiUEVm6dwE6FTmD/ywHRlKDbyjravro5hwArM+/tn72YArIrLM/iB8NWwHWToCDX+ImRdP8IQgUhzfHl3lgLGz0QXYR2ShCNmOn0WDx8+Pblze6LomZyruLgOiD2tZcG58h9N5NhLkU/2NARhEIKvYklv+6j8zgI7FRgmuZXGdT0Li2kj11LLHFncpAF0A49e8MqXO2BILqR8Epc9GsvSAGydSkvQtQUp4W3ath/jtx1YXBgjWdNRb6ryKxfPMAcEQoiIxRZzdNmO8MOWqx3gypoiZD0tWrXOJhE+TB7UbG04ltCUZYrloYap6BNbzGx9y3TP9NvsREhkE2nBEc55S/DnLs4RJL5DcLsqMEMRrRdjHqJpJnfetaSJ4p5zFVrwfaaHks14/3izQBj6d0uL1wnmDTNnS1XvjIHOdasUTPp+JmtnKYu8oQjm4xgrTpgImFLEdHqF6ezmHA3DAzizFtfSmEkmUApvk+I85kRWeZIUyz2hP3uthDejGgbT0TJvZduuws/vuzZBwPXUM44Z1MbMn4WrQl5of8dJ7wc= 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)(36860700004)(46966006)(40470700004)(921011); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2024 14:38:24.6278 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dbf9075c-c717-4319-3bde-08dc3221982f 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: DS2PEPF0000343C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8546 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 NAT64 is treated as a modify header action. The action order and limitation should be the same as that of modify header in each domain. Since the last 2 TAG registers will be used implicitly in the address backup mode, the values in these registers are no longer valid after the NAT64 action. The application should not try to match these TAGs after the rule that contains NAT64 action. Signed-off-by: Bing Zhao --- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_hw.c | 51 +++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index af41fd2112..52994fa3ee 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -382,6 +382,7 @@ enum mlx5_feature_name { #define MLX5_FLOW_ACTION_PORT_REPRESENTOR (1ull << 47) #define MLX5_FLOW_ACTION_IPV6_ROUTING_REMOVE (1ull << 48) #define MLX5_FLOW_ACTION_IPV6_ROUTING_PUSH (1ull << 49) +#define MLX5_FLOW_ACTION_NAT64 (1ull << 50) #define MLX5_FLOW_DROP_INCLUSIVE_ACTIONS \ (MLX5_FLOW_ACTION_COUNT | MLX5_FLOW_ACTION_SAMPLE | MLX5_FLOW_ACTION_AGE) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index a2e2c6769a..2057528c84 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -5725,6 +5725,50 @@ flow_hw_validate_action_default_miss(struct rte_eth_dev *dev, return 0; } +static int +flow_hw_validate_action_nat64(struct rte_eth_dev *dev, + const struct rte_flow_actions_template_attr *attr, + const struct rte_flow_action *action, + const struct rte_flow_action *mask, + uint64_t action_flags, + struct rte_flow_error *error) +{ + struct mlx5_priv *priv = dev->data->dev_private; + const struct rte_flow_action_nat64 *nat64_c; + enum rte_flow_nat64_type cov_type; + + RTE_SET_USED(action_flags); + if (mask->conf && ((const struct rte_flow_action_nat64 *)mask->conf)->type) { + nat64_c = (const struct rte_flow_action_nat64 *)action->conf; + cov_type = nat64_c->type; + if ((attr->ingress && !priv->action_nat64[MLX5DR_TABLE_TYPE_NIC_RX][cov_type]) || + (attr->egress && !priv->action_nat64[MLX5DR_TABLE_TYPE_NIC_TX][cov_type]) || + (attr->transfer && !priv->action_nat64[MLX5DR_TABLE_TYPE_FDB][cov_type])) + goto err_out; + } else { + /* + * Usually, the actions will be used on both directions. For non-masked actions, + * both directions' actions will be checked. + */ + if (attr->ingress) + if (!priv->action_nat64[MLX5DR_TABLE_TYPE_NIC_RX][RTE_FLOW_NAT64_6TO4] || + !priv->action_nat64[MLX5DR_TABLE_TYPE_NIC_RX][RTE_FLOW_NAT64_4TO6]) + goto err_out; + if (attr->egress) + if (!priv->action_nat64[MLX5DR_TABLE_TYPE_NIC_TX][RTE_FLOW_NAT64_6TO4] || + !priv->action_nat64[MLX5DR_TABLE_TYPE_NIC_TX][RTE_FLOW_NAT64_4TO6]) + goto err_out; + if (attr->transfer) + if (!priv->action_nat64[MLX5DR_TABLE_TYPE_FDB][RTE_FLOW_NAT64_6TO4] || + !priv->action_nat64[MLX5DR_TABLE_TYPE_FDB][RTE_FLOW_NAT64_4TO6]) + goto err_out; + } + return 0; +err_out: + return rte_flow_error_set(error, EOPNOTSUPP, RTE_FLOW_ERROR_TYPE_ACTION, + NULL, "NAT64 action is not supported."); +} + static int mlx5_flow_hw_actions_validate(struct rte_eth_dev *dev, const struct rte_flow_actions_template_attr *attr, @@ -5926,6 +5970,13 @@ mlx5_flow_hw_actions_validate(struct rte_eth_dev *dev, MLX5_HW_VLAN_PUSH_VID_IDX; action_flags |= MLX5_FLOW_ACTION_OF_PUSH_VLAN; break; + case RTE_FLOW_ACTION_TYPE_NAT64: + ret = flow_hw_validate_action_nat64(dev, attr, action, mask, + action_flags, error); + if (ret != 0) + return ret; + action_flags |= MLX5_FLOW_ACTION_NAT64; + break; case RTE_FLOW_ACTION_TYPE_END: actions_end = true; break; -- 2.34.1