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 AFF24454E5; Wed, 26 Jun 2024 20:15:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 09A0640648; Wed, 26 Jun 2024 20:15:17 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2055.outbound.protection.outlook.com [40.107.93.55]) by mails.dpdk.org (Postfix) with ESMTP id 9503840615 for ; Wed, 26 Jun 2024 20:15:14 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fAJ4ti3jwC/Zps2fPSO3DkB9hTkCy6RO1Coc8OE4+/nX0slnmmKZyeoNhTBU40IdFNGcaYNqQGYucWUFKv2KIiq3ioczEWglr4fIOV1KyLbnWZ/WQzFzul3p/ovkNzUNo8TOGsq53UkdbPh/d3U9LudE1PmsdTjypvNdQUh9F1mdMemOK0M3ZeG3uuBJeaTEKg0+E+beIR4mjeSkWPAxhpjSa8aF+7zkQuIMZjMdtHIyLDRdgX5YTagEvil5UZu9otSt1lz/QiD7ez1mPf8Mw7ctfADVMd3O8GbChpaJ2rz8ux+S7Nw75iMdwwu21U69OW57k2dhq/0ZExs4yjUNnw== 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=oV5JH3nfTc13WHvCaElgsyKoD+mAG3lqyVU/Oty3rLk=; b=UXwSYRq+f5cHDXNPtXyLfm7mYGZL89GzdBJRowxVZ3BuWm/r2nm0PLurpRriW+nH5e4J9oLtgQYqB7fQyn7Ml6OUwLjrIf/YDeT5HlUw/G8zpKAsCuUw8Ky2WkiFa5l1R8JupovZjbcPQm7ngwulb13vk6jdrVO8gCiHuTHvmDTrO1L/8+TP38/FzXC6MLpBfpcHaxa1uA/+ITk1FkazQJ18563X2MnWdowj5MaoAsvuelmxHji73BcYwOeJuAvCjXwU1IPu/3tzdf3xK2frgnATwKRtuQa9WEl8kLgnhhUxeykQ/R5MZ7NX1lZ5BM22ctNYKizAo46EpCmPWkbUxA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org 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=oV5JH3nfTc13WHvCaElgsyKoD+mAG3lqyVU/Oty3rLk=; b=aNQYSK+yI87DGTrqMn/9QKJw4U1HWNl/DcShBRPCyEs/OuwQC/rXwSKXKrraS1zKZMo44GKbMhfB1VY3MruGV0qw4KEZugbY18hj12NsOBVLBq2gviunI/PgEAjNG1Fy50w0vBa0zJjwjzwFWoxYhX3m9c67sSdw8g1UvNtBuf9L6VSwen5ZarPH2NTVLBp1aXsv8W8Txb7izuiWfE0cAc7iEpmg0aLTXcrVl39JF/IaFOME0FHnkXqB90zbDwlnAXY/j5k2QG9eoVgP9d4HlPSRZyBPi77uidUlDleXDdKU5csE1gc+AWxlcQlTm0rOyycOUlYKJqvcvz2dhWyY+w== Received: from SJ0PR13CA0095.namprd13.prod.outlook.com (2603:10b6:a03:2c5::10) by CY5PR12MB6106.namprd12.prod.outlook.com (2603:10b6:930:29::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Wed, 26 Jun 2024 18:15:10 +0000 Received: from SJ5PEPF000001CB.namprd05.prod.outlook.com (2603:10b6:a03:2c5:cafe::1f) by SJ0PR13CA0095.outlook.office365.com (2603:10b6:a03:2c5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.20 via Frontend Transport; Wed, 26 Jun 2024 18:15:09 +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 SJ5PEPF000001CB.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Wed, 26 Jun 2024 18:15:09 +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.1544.4; Wed, 26 Jun 2024 11:14:50 -0700 Received: from nvidia.com (10.126.230.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.1544.4; Wed, 26 Jun 2024 11:14:48 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v3 1/8] net/mlx5: extract target port validation Date: Wed, 26 Jun 2024 20:14:21 +0200 Message-ID: <20240626181428.1678402-2-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626181428.1678402-1-dsosnowski@nvidia.com> References: <20240612162426.978117-1-dsosnowski@nvidia.com> <20240626181428.1678402-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.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: SJ5PEPF000001CB:EE_|CY5PR12MB6106:EE_ X-MS-Office365-Filtering-Correlation-Id: 231c43a4-0ab7-4234-5772-08dc960bea27 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230038|1800799022|82310400024|36860700011|376012; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ldt1hFEN3LtutPxIP5WUFo8v6vNm8ClGvZC2bmNhpQCvqXkQ0ZMFicfLZFa5?= =?us-ascii?Q?5AQY9O2u5yNB25WMWJF25l4ITmcT3x4vI/crw09fr3tTDHNxWnJl/zfAWJZU?= =?us-ascii?Q?M3tLVr9I2TmJuzWY5YrciLN1JIWNu9CJMz8AR2h1k9+5DnnYWjj1UOiAm1/u?= =?us-ascii?Q?Y0+z54rzZ2Jg7PaA1UHIZS6XDsrn2xIRSU6PK4ldUWU7pPiRl2fSERnF6aeE?= =?us-ascii?Q?ib6f8IFa30r7zNnoqnWRxFzKk0+h9U+X7ETZUh/4d+GBC5PyMouwBPO/YSdc?= =?us-ascii?Q?x9da4ues8CwzdRnWfeKhhGPHAE2rOmc3CkgbRLG86IFBUhZY5BpwwZLfMLum?= =?us-ascii?Q?wmQD6CyyQaomBfo4eB7ucixqPDvnOLfE2nhX69rmsIMcqAn4BgLR7YhCZmCl?= =?us-ascii?Q?nxzjdUe5QmPJBdQQ954ZAN6mA7WzGiJZtXHGOzB5v6RIYH6eyxkjUPHbCz/c?= =?us-ascii?Q?6v6cbGCgK0tG541Up4QLq4frK1Imx37ukEmcnmFTuVuPOKjQkZtvivxoWVHA?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5zMKAB+nCLCvs6hi1UCE+Lxycg?= =?us-ascii?Q?NF4z6wP0hKUhhFmFjlP7PSrghGXo1r+e?= 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:(13230038)(1800799022)(82310400024)(36860700011)(376012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 18:15:09.6865 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 231c43a4-0ab7-4234-5772-08dc960bea27 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: SJ5PEPF000001CB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6106 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 Extract code responsible for validation if port specified in configuration of RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT action is correct. Allow for reuse of this logic for both RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT actions and RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT items. Signed-off-by: Dariusz Sosnowski Acked-by: Ori Kam --- drivers/net/mlx5/mlx5_flow_hw.c | 63 +++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index b8d71b145d..c0d763198d 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -6051,6 +6051,42 @@ flow_hw_validate_action_port_representor(struct rte_eth_dev *dev __rte_unused, return 0; } +static int +flow_hw_validate_target_port_id(struct rte_eth_dev *dev, + uint16_t target_port_id) +{ + struct mlx5_priv *port_priv; + struct mlx5_priv *dev_priv; + + if (target_port_id == MLX5_REPRESENTED_PORT_ESW_MGR) + return 0; + + port_priv = mlx5_port_to_eswitch_info(target_port_id, false); + if (!port_priv) { + rte_errno = EINVAL; + DRV_LOG(ERR, "Port %u Failed to obtain E-Switch info for port %u", + dev->data->port_id, target_port_id); + return -rte_errno; + } + + dev_priv = mlx5_dev_to_eswitch_info(dev); + if (!dev_priv) { + rte_errno = EINVAL; + DRV_LOG(ERR, "Port %u Failed to obtain E-Switch info for transfer proxy", + dev->data->port_id); + return -rte_errno; + } + + if (port_priv->domain_id != dev_priv->domain_id) { + rte_errno = EINVAL; + DRV_LOG(ERR, "Port %u Failed to obtain E-Switch info for transfer proxy", + dev->data->port_id); + return -rte_errno; + } + + return 0; +} + static int flow_hw_validate_action_represented_port(struct rte_eth_dev *dev, const struct rte_flow_action *action, @@ -6067,32 +6103,13 @@ flow_hw_validate_action_represented_port(struct rte_eth_dev *dev, "cannot use represented_port actions" " without an E-Switch"); if (mask_conf && mask_conf->port_id) { - struct mlx5_priv *port_priv; - struct mlx5_priv *dev_priv; - if (!action_conf) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action, "port index was not provided"); - port_priv = mlx5_port_to_eswitch_info(action_conf->port_id, false); - if (!port_priv) - return rte_flow_error_set(error, rte_errno, - RTE_FLOW_ERROR_TYPE_ACTION, - action, - "failed to obtain E-Switch" - " info for port"); - dev_priv = mlx5_dev_to_eswitch_info(dev); - if (!dev_priv) - return rte_flow_error_set(error, rte_errno, - RTE_FLOW_ERROR_TYPE_ACTION, - action, - "failed to obtain E-Switch" - " info for transfer proxy"); - if (port_priv->domain_id != dev_priv->domain_id) - return rte_flow_error_set(error, rte_errno, - RTE_FLOW_ERROR_TYPE_ACTION, - action, - "cannot forward to port from" - " a different E-Switch"); + + if (flow_hw_validate_target_port_id(dev, action_conf->port_id)) + return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_ACTION, + action, "port index is invalid"); } return 0; } -- 2.39.2