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 0C7EE44060; Wed, 12 Jun 2024 18:25:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3472440E41; Wed, 12 Jun 2024 18:25:13 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2068.outbound.protection.outlook.com [40.107.220.68]) by mails.dpdk.org (Postfix) with ESMTP id 5D4E540EE1 for ; Wed, 12 Jun 2024 18:25:11 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dR/K85fXJv1Vb/mboFDqmsZCUOiGBOCbbCrWd0mYMgslDHbAKHvvlBUvXpZXBBGi7NHkgJ2JErrbKX+MxffnGWgwkKT/G9BvXqjRnJ5hpIu0HMVG22H2LpDvk614uHvUDWmVHB0LHj1cBe5yhI1tKH8LrP0t4bnA2PQm6lJHdJeleoXkEad06wq9z0az2gVEnXoGrL0Zck7BL/ru9Lb+x16wZnhdRoBraYoVNbf/kOZW+k46OJu6SXjijL77Q66It98PzkckjDtwSujL5AhtbSc5vvAUnOAD1nvYttFIj3NDayHnMkTDfnxGc+G7buU/igg2HNrFqDabZrBTt8S+QA== 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=utcM9eUtkA6OF765+AcnmPsNTJ7Y/F39zkzLZA3zpx8=; b=LJuFRsjovhKFbxiaF1qwDu3MhvRpkHPbnSIAg0DMtHu0jDIHa6KDmi3Bv9C787cqRLc+mGpwmsKXCpVevpNyl9qz4wM/DHWWlT35r1Mg8OU16y5ui4bYwMcbk9Ltu2OwZMTn6xZuUCQCrjrMinSezImFJL8R1kV6BH2UP3xsXtYh5AuycqdMdXp3q5kNOzrB7LiPr/E811dmGHi3hAoLLeQ7zrtYk4y9TrndyigFIog1daaMkett5CCVTptq6MhRUtsV6qAKPR+DRnuU21RFUqjKPsxX36EKOWaL0TyTfe8vSOtU71KnVJqubjgD4YGf/qkdh3S2yZPLiGjsdW+4OQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=utcM9eUtkA6OF765+AcnmPsNTJ7Y/F39zkzLZA3zpx8=; b=AclGLWFVNkgea0P3SRI3pRoqoJ+JQyTitlA78io4AoITGUfoYevS+7VIrffAjnF69QddnbwxP5BuNAW1+Sfo60AWa1/6mp1GdWdWPD44mNY6WOajDFzDBlMuFCSoEPXrYHscivORkyKvtXfyQvYzr7ILXExo0Eg2Ro2akyLz0u3EqDWPHZGxy4QMb+K+yq7f+T0VLA9PA1GdMeQt5uk89YP/GUPVqdSTL48ia8Jbco23PHkvJSP+jgV4enC5MD5FpSDQLbQtBtYx5INB2JUDmXDL/b7dGMaBVF0j54ZH5hu21WVZioz9XaJAPkLvUPURFBVHWJiuA4sp6+B/4CB2DA== Received: from MW4PR04CA0239.namprd04.prod.outlook.com (2603:10b6:303:87::34) by SJ2PR12MB8830.namprd12.prod.outlook.com (2603:10b6:a03:4d0::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.36; Wed, 12 Jun 2024 16:25:06 +0000 Received: from SJ5PEPF000001D5.namprd05.prod.outlook.com (2603:10b6:303:87:cafe::50) by MW4PR04CA0239.outlook.office365.com (2603:10b6:303:87::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.19 via Frontend Transport; Wed, 12 Jun 2024 16:25:06 +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 SJ5PEPF000001D5.mail.protection.outlook.com (10.167.242.57) 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, 12 Jun 2024 16:25:06 +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.1544.4; Wed, 12 Jun 2024 09:24: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, 12 Jun 2024 09:24:48 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v2 1/8] net/mlx5: extract target port validation Date: Wed, 12 Jun 2024 18:24:19 +0200 Message-ID: <20240612162426.978117-2-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240612162426.978117-1-dsosnowski@nvidia.com> References: <20240605183419.489323-1-dsosnowski@nvidia.com> <20240612162426.978117-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: SJ5PEPF000001D5:EE_|SJ2PR12MB8830:EE_ X-MS-Office365-Filtering-Correlation-Id: ad773a1a-33e1-4c0d-2d86-08dc8afc3868 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230034|36860700007|376008|1800799018|82310400020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?RFTapAO39of31NLbxSVeTrJQZMETYQC5bJOGu7aDql37FtlI5gXhfM5xVQe/?= =?us-ascii?Q?P/29RK7tPOtDQZTWcdKCLblbu2n5AMlREhoeV2cT09nmp2YnOf3M8oeCycNl?= =?us-ascii?Q?iZcc2CHVSJs+Wd58u09Q/zNyrK6oFz+sLl5YND3YY4BWIHHJvpli212MnxgI?= =?us-ascii?Q?3hVs/sHSq3F8XOsOz2ZWbW43Nvh/WyHYCceQ0ovZl7L5/KvaH1Hazqs/9gV3?= =?us-ascii?Q?ZBxCjl+WXtS+P+/jfdOTTnh0jauqbX35UhJ1ygMK6CypKwL03Ic1MXPUJ1PE?= =?us-ascii?Q?EhdTQpLEmZMg2ac4YKtlZcLzI5FKWU4R+o2N53zL0STB7wxCv0LjfBZnPLLD?= =?us-ascii?Q?QZmCN1yFiDJeZsUYqvpxxB6IctnHHstEPSsk1vIGEBiC8ypUdLjKm5WZSMTW?= =?us-ascii?Q?XvIir7CiAuJswqquepM3NPxSgAbQRo0h0zG+K/zsYfRR14PZSJjsETaMpwgl?= =?us-ascii?Q?QcopnbVU1bSJV+3KOA0dVp2nxhYb8uDjKOEk6DJCoOiGH5q3L/c3w0jrsR7h?= =?us-ascii?Q?quBAanFfB5LP/qQZqXlI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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:(13230034)(36860700007)(376008)(1800799018)(82310400020); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2024 16:25:06.1885 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad773a1a-33e1-4c0d-2d86-08dc8afc3868 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: SJ5PEPF000001D5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8830 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 eb89dcf454..aee0201cbc 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -6046,6 +6046,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, @@ -6062,32 +6098,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