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 07B5D44165; Wed, 5 Jun 2024 20:35:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A6B3E402E1; Wed, 5 Jun 2024 20:35:17 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2048.outbound.protection.outlook.com [40.107.236.48]) by mails.dpdk.org (Postfix) with ESMTP id D461E402D7 for ; Wed, 5 Jun 2024 20:35:15 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LEG/KloRbcfXDJ0XljVxvYerx1Xat67IkNPXQfJXD7qerxEAw+he6e7k8PuVN68WsF4LKkfTSa6xqwLzySj3oQZXWx/YnPFQ72j5bqIu0kLT8FIgIIu3leHrxAV4Myu6hvQ4T9dzTfYCcaW/ZFtUHdbJF9f631Eteh+SUZHrbSO/cZNtX8yT3R/zi+vhtEUx0EtGVSXHHyWYPpvDSr/PsHHx93mSw+p5TccvZzYHKnG3xF5CaOZspxi0VpGlNycqd4p9hM1qapa28jomiClmlTWvXKElt9CAoOHMapgawFKT3kfnFOWHvkvFuwJuWhj629aHboSzy7LCuPy884eKdQ== 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=SqiukarYeSv5DwisHBIt3L7OjGpcP01WuH9Yecubb/M=; b=NIsDdOd5MjGCA7GpfViKYDoE2RoFLqkE78Nsa1cQPOgr45alCJtHf0q7AL05IdEjmJZqfd5euOWdz2c+ZF/BVwzRKg1A9Eslz84k5w5GgNkCTulVm2+5LKmx99PsWYC+NbAUkFPIpSLFwRHBmX2qlvMRW+EtlRZvkffZzX2i6LyE5lpQH68aLfGv9oBhmppjJSHdGh1RHOTPSTCeEIf0jLPdC5gmXwT4GuhbllwmbUBlWRN48axNM4NBZa1bHUog+HMaLxA4IIoTceyRtGmanEFYX0A87jsJKefVaWDUyMilF+cNsYJvRyg0oOM8OrjTZvJaC8nDKq5TIj48mh88wg== 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=SqiukarYeSv5DwisHBIt3L7OjGpcP01WuH9Yecubb/M=; b=ZACA2QfYon71gyCWTIOygZbM7NxZYu4bsgBZttcyA33M4cuR/xYqIsF2L/xK66o4UKcPblr/ztjaUy30k7UxZLdJikXa22PZyFCCe8Yq7lfw9MVZ5lIKX5JOdaHtEE8n4thXMXljeDInwMEDQxB2Xc4VTHFQ+YTSQdXlMxTH/eq55CX4agfVFd9PIJqBIp5a91OktlZt9nvSKkQfBHbPxSwe+JNr46RCQAGNMlIQVgnQOmcbFthON1O/RSdG1E+lz8Zenyli2n3rDloeh7ijjWB72G4r4RHTU5Q3HSURogg3DNxHaSUcaEbc21rmgTh0RY6SyqdIlUiGGNc+CxFplg== Received: from MN2PR12CA0018.namprd12.prod.outlook.com (2603:10b6:208:a8::31) by PH7PR12MB6956.namprd12.prod.outlook.com (2603:10b6:510:1b9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.31; Wed, 5 Jun 2024 18:35:12 +0000 Received: from BN3PEPF0000B071.namprd04.prod.outlook.com (2603:10b6:208:a8:cafe::d6) by MN2PR12CA0018.outlook.office365.com (2603:10b6:208:a8::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.31 via Frontend Transport; Wed, 5 Jun 2024 18:35:12 +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 BN3PEPF0000B071.mail.protection.outlook.com (10.167.243.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 5 Jun 2024 18:35: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.1544.4; Wed, 5 Jun 2024 11:34:46 -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, 5 Jun 2024 11:34:44 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH 2/9] net/mlx5: extract target port validation Date: Wed, 5 Jun 2024 20:34:12 +0200 Message-ID: <20240605183419.489323-3-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240605183419.489323-1-dsosnowski@nvidia.com> References: <20240605183419.489323-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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B071:EE_|PH7PR12MB6956:EE_ X-MS-Office365-Filtering-Correlation-Id: 27eba3d1-75fa-43e8-6366-08dc858e3c26 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|82310400017|1800799015|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?tCJ7UgBXq43HxqhANoPkQOn28wBnlTc/7wd+jt4eeqLsvHFjS8aoHA8QVO9A?= =?us-ascii?Q?jlP54B+dfwPoUUyk9mV3V1U6Z4mEBZxeY8WEly7mc2Dy0smGmhxAEgIG/XuU?= =?us-ascii?Q?24hFSwtV1nD5eaZLdpTruT2ZG8cJtqb3SjbA0FlNKj/JXQiwgEcbkA2n2k4T?= =?us-ascii?Q?yVp4t5CRrEPrt3McHJ7lRXmiyqHdUTt6DSy2N2xqMH+2UpbGny3jDwfmwHPt?= =?us-ascii?Q?zZyt1HRqqsJTtMidTFjCZJ7Qi2mCNX2zpGQXIUDpdHioXkHdTjVkx/yKp6kZ?= =?us-ascii?Q?HqCtfTDLWbXXbHS3ueh6gOi7zCccOKimHy2N8eEQUZ/tfprI/ZNKXQNlK7VN?= =?us-ascii?Q?V0moX0pwNC1dNAE+9wjVpq0c6lyxxYLHh7445OUa8g3fxwRwbvo4ntjwVBz3?= =?us-ascii?Q?rnic43QiCuhS8FvwOsZHTpP+3CwHJxeaLk5NtryW8WDFhAt3UIBCVORKVj4W?= =?us-ascii?Q?opdpnGhrpXlDbLrwSbC22MjV1irJlJ8Hs18RzIM1eSokBrPMI1sdKjyAw/Gd?= =?us-ascii?Q?cWAtqIejoypjMNqWELD3QHeLcdP28BBSENezVljr6p0GDpOMp/3z4AwP1hZe?= =?us-ascii?Q?8AbQJqbpk0MQ5BJS0+2DQiWnGlIcj0A8xW55Pz79ZA+qkzC2b7ovNagffI9s?= =?us-ascii?Q?K/TYnXVgooHipJQ2x8EG7vumGiiSA7V/aVaB4GdpxBn4WdL6xfjJVLm2v7pg?= =?us-ascii?Q?Z0creoSBC5UhpnE9RASBzfJNmoc7q2sBfBjDoBZk9ZmbLtkfcb93aS3E/egF?= =?us-ascii?Q?UH7D1uCRc5M23SQ/FDIy3qILzt2zaHQfe4jW2yq1dveLKVvxoJvb+FPRb0be?= =?us-ascii?Q?LMn00z9OTVHXHykj9Zpw36tSKAYvCynE3pzkajgRXHsh0XqIjb1jKK2cAohB?= =?us-ascii?Q?wSeVcU4EpS5sdxIgrqfmJAId+fHF8sRGP4LfNQzbjXwKKZQq8XVZ1KM1vNW2?= =?us-ascii?Q?8NehjiNBiGWyguee4SZhSyJ7C7nz+WdRIb3Y0i4bmfs5XGqIYTcIXfL6uguI?= =?us-ascii?Q?kXG3g687AYCchK1h6M+02S8Rg7f4djoEMvTGizn1D0vn3KTxaXT/QZZA+WWE?= =?us-ascii?Q?nhL1ktjKUF3WOko1Cq7H8rJk0k1+2AHVhTg6kpXKFxpycQVXXi9kC1uJHzSF?= =?us-ascii?Q?L8htymbSesClR4Riv7zgCrjtXwHNzu0w4fqLkx8NXrXTUfpYvpTr5m0kHU8q?= =?us-ascii?Q?y3BxpsXWG3gY38rTFufgTyOodo1+ouhZRjDpU0sA54FCY4fDqEGrOMZrMtrn?= =?us-ascii?Q?/7MjGP0Z+7lBLURyx9YfmKE47k++uIOkunxY4mQwefsCdsn2z2W4fAbRcO7+?= =?us-ascii?Q?tLDNRQHkDCGnnf4EFhXpfiW/hn/gOPOOmOGTYnCdOKTLhUEx1q30+TeOGEcz?= =?us-ascii?Q?sF3HfGjxwpLRWqYaQsHwSERFfq/3?= 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)(82310400017)(1800799015)(36860700004)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 18:35:11.8735 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 27eba3d1-75fa-43e8-6366-08dc858e3c26 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: BN3PEPF0000B071.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6956 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 e8562660dd..24b86535b1 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -5716,6 +5716,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, @@ -5732,32 +5768,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