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 7CCAD454E5; Wed, 26 Jun 2024 20:15:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 40B2940651; Wed, 26 Jun 2024 20:15:18 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2084.outbound.protection.outlook.com [40.107.220.84]) by mails.dpdk.org (Postfix) with ESMTP id D423B40647 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=gqvzqAeymkqy4Q0Nqohkla9xCoj8tUaP8JjRAPgvdX4D6r875WXBQvLBjnkVJhgpRylrUvXnDOKNgThHxGef5z0mGz2RUEMGaM2zLoXhSXmRMbri7VBc7rY7SAFk9APRT5DRKALOfueCb4HQYqqov5hn1hwpbQVsrBG9JDk0YJeR3oCGMAmzRBFWha4GL8ZDxb74o4z+in3Mr6IzHsvfffjKfsU0zPOeo1uixxGsla9wN2cXy7a1AxSYUBtbITsN4dDTDYmKt+kGFi5og517lcfImJNaj67Mq5ngioCHS1ALfV9i8V1Ieb5tLS5SdfStJ9l6jjAGHe95m6SLocaJAQ== 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=XkIaMR3btf2/SplYoetA4lBff+06ul2+xcaIm6gTAJQ=; b=iX1kE+LFeX1b81oPpKl9tA4ZYx8Rto3yPlauz7zEQ+PMKt9ZxzGOEmHXCV/cV8AOfWgG3o26hoRRYol0Wc7h5eSD5JtNOKAxQPGCnIMeXbm/OEhG2POFnJ1po27AUQ6eA/iWxIAvCpz/iNiUQciUh1ednuiRkTTtqmFNTNEriqZ44+AVCUmT4HEpsayXdyyI93meiOKJX0EMsPeyFsWMHPxKxNnWlOOzjc+JLfVUZvR0HpSnNi9ACFT02s1Vy7GXGSzepHsU+STYRVCTsWG1TSeUJ1vupCavLg2O3oKO5qKu2M9Muma8QhYt8P8BGJORVuJCsMLh6xR1gNs8OuDeTQ== 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=XkIaMR3btf2/SplYoetA4lBff+06ul2+xcaIm6gTAJQ=; b=e5n7ttqWD230qgUGreL9zk+D5+s6+TTQs9YjWgaOOPYD8+C/NgNYCxQ74n4EljIG0FGw4tP/6mIyWMeAGw3HhV7q9RLNBpIiPHf4Pyx7bpfgB+sxe4EtHzzR5fhCPWZzrzExY5X0JfEmDPUDOOUrgZlv5EatSpjDth3FF6K/DNOd9i2rqup6q6hOWkn6y3bjoKF3eymHs/j2E5krHTuksi9lWalgQYttbROWaklLzafbtAsVQusoEsF2O6GEn95aJRx1aGKAilHP+JJIJoIIlLh5x3QljpkPHZN1sFwIJsx/56UHGQZQwTrLvYgSGCaiYU/rB7XIgrk8+BMya/4dNA== Received: from MW4PR04CA0170.namprd04.prod.outlook.com (2603:10b6:303:85::25) by PH7PR12MB7986.namprd12.prod.outlook.com (2603:10b6:510:27d::17) 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:11 +0000 Received: from SJ5PEPF000001CD.namprd05.prod.outlook.com (2603:10b6:303:85:cafe::92) by MW4PR04CA0170.outlook.office365.com (2603:10b6:303:85::25) 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:10 +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 SJ5PEPF000001CD.mail.protection.outlook.com (10.167.242.42) 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:10 +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:52 -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:50 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v3 2/8] net/mlx5: extract queue index validation Date: Wed, 26 Jun 2024 20:14:22 +0200 Message-ID: <20240626181428.1678402-3-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: SJ5PEPF000001CD:EE_|PH7PR12MB7986:EE_ X-MS-Office365-Filtering-Correlation-Id: 400bbb1a-a74a-47c7-9dab-08dc960bea89 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?ewa2K/cYdu7ennKFlEO8buyIxi1WsIbM8mrEJ0tkTJ2jhNIaM0ErQnhcfgcx?= =?us-ascii?Q?dKjMnKOdtaeM1CyNTuARR3KcpuDpJmENZteMPn+ukw+4d1CUpO2emLMy88dj?= =?us-ascii?Q?Nw59fd6GDcSC1YmLn7uQe3TwjvsFlRBCvcvXHd1hCrn6ViNtFYMsO6U5sm14?= =?us-ascii?Q?7gbVK2AGM40k0Q7fDqOCEvUA3p5eYzTSo8J3i37CtbrTe4n5dcf19cRYP9Me?= =?us-ascii?Q?ERlOFEyKxQvvFmY4oe7cVrVgifKKNPkoyUxSzROkBkWSMRdhkYq+kl48QXtO?= =?us-ascii?Q?nuihc5Oio3kaUb1kPeegUQcT07tgG/FQDL1dV8RC/s33FJVYzKBm2A23arkA?= =?us-ascii?Q?kzNDM6ylb/u8sqQJ82POfJo6JwmlPdEU55bThr/gw2LgbFppn3nemOT6Lcjc?= =?us-ascii?Q?2cB3g7EZjWpbnslHS3uiT5YN21rSL7jOJp28kWGwamp76DeCAmUWy3zYK8sb?= =?us-ascii?Q?7FcpH55Xj5x1QvKRdh6bbqWzkkB0dglniAmwjTiExvFWAE9G+BOSmTgo4Vqr?= =?us-ascii?Q?XsievY6uyvSzW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-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:10.3149 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 400bbb1a-a74a-47c7-9dab-08dc960bea89 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: SJ5PEPF000001CD.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7986 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 validation of queue index out of validation of RTE_FLOW_ACTION_TYPE_QUEUE action to allow reuse in template API flow rule creation implementation. Signed-off-by: Dariusz Sosnowski Acked-by: Ori Kam --- drivers/net/mlx5/mlx5_flow.c | 59 +++++++++++++++++++++++++----------- drivers/net/mlx5/mlx5_flow.h | 3 ++ 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 3a59fb525a..daf0e41c6f 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2020,6 +2020,46 @@ mlx5_flow_validate_action_drop(struct rte_eth_dev *dev, return 0; } +/* + * Check if a queue specified in the queue action is valid. + * + * @param[in] dev + * Pointer to the Ethernet device structure. + * @param[in] action + * Pointer to the queue action. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_flow_validate_target_queue(struct rte_eth_dev *dev, + const struct rte_flow_action *action, + struct rte_flow_error *error) +{ + const struct rte_flow_action_queue *queue = action->conf; + struct mlx5_priv *priv = dev->data->dev_private; + + if (mlx5_is_external_rxq(dev, queue->index)) + return 0; + if (!priv->rxqs_n) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + NULL, "No Rx queues configured"); + if (queue->index >= priv->rxqs_n) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + &queue->index, + "queue index out of range"); + if (mlx5_rxq_get(dev, queue->index) == NULL) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + &queue->index, + "queue is not configured"); + return 0; +} + /* * Validate the queue action. * @@ -2044,7 +2084,6 @@ mlx5_flow_validate_action_queue(const struct rte_flow_action *action, const struct rte_flow_attr *attr, struct rte_flow_error *error) { - struct mlx5_priv *priv = dev->data->dev_private; const struct rte_flow_action_queue *queue = action->conf; if (!queue) @@ -2060,23 +2099,7 @@ mlx5_flow_validate_action_queue(const struct rte_flow_action *action, return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL, "queue action not supported for egress."); - if (mlx5_is_external_rxq(dev, queue->index)) - return 0; - if (!priv->rxqs_n) - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_CONF, - NULL, "No Rx queues configured"); - if (queue->index >= priv->rxqs_n) - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_CONF, - &queue->index, - "queue index out of range"); - if (mlx5_rxq_get(dev, queue->index) == NULL) - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_CONF, - &queue->index, - "queue is not configured"); - return 0; + return mlx5_flow_validate_target_queue(dev, action, error); } /** diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 92e2ecedb3..da7d06d033 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -3018,6 +3018,9 @@ int mlx5_flow_validate_action_mark(struct rte_eth_dev *dev, uint64_t action_flags, const struct rte_flow_attr *attr, struct rte_flow_error *error); +int mlx5_flow_validate_target_queue(struct rte_eth_dev *dev, + const struct rte_flow_action *action, + struct rte_flow_error *error); int mlx5_flow_validate_action_queue(const struct rte_flow_action *action, uint64_t action_flags, struct rte_eth_dev *dev, -- 2.39.2