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 9C6A341F45; Wed, 12 Jun 2024 18:25:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 82ABD41611; Wed, 12 Jun 2024 18:25:21 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2066.outbound.protection.outlook.com [40.107.237.66]) by mails.dpdk.org (Postfix) with ESMTP id 6568040151 for ; Wed, 12 Jun 2024 18:25:18 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JCiks8hXnFe5LORCHnUh4tTraNKZKYQscO2fhhFStOCz0tXQYbtt5MlGe4wjo4BZBMF99sqmR7wSDU41YJVLY9nV5t9QYZi0FWaQ/JNrEdrbcFIuTO8zIpnwlCszk5W2WEOe3rPfDfqVt7epLYMBzIqFx5luUwu6jSbbqosGNXtqj9EplbcVC6j+heV8AxKwu2KL4A5PJu1OZdocXQmLopa+FcZnrE8VN02GgPxTFP+VyMRAelXaMPXcXt8OBlg6RQcepDP7s76aNPLUG3COxO5t28YLOaCyh8mdLQZzXtZIz+ww5WpcKvL3JJt1M8fZvtvdXXJxI/bxEtBdY3jeRw== 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=6XAWyjGLz7T/vIonjogcg8Xl+ImeQl1+UN5W0+ZSiRY=; b=XcAKLyqvXa1XM8gYnq8qLRHYCtjTKHIXZV/UidbITxnDri9WcxG7EUJZLYH17vLMoer1ThbpqU0+LEbZKyreHaRQUCns8GXQYlkUmIiJEKorc3ZuJ3LX8j2AxypYya97nbk8qRloldu7rKkXVVeV9k9u7VMsqTrIvz68HeHhVhdnsX0nPdK1ND5KHehDciyzAVl0DTarw40xv0eOFAt5f5NS1ltXCmDt+McZRtaDRtukNFYGX2pjhejzP6Nd/wVGdQBXNzpszS4Lslsr55FVDweMQ4LC23g5Hb98paYr7gDSduzkeCQ0HmPLU5j5KIky6YS44S1xtDdEfcWflmtFxA== 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=6XAWyjGLz7T/vIonjogcg8Xl+ImeQl1+UN5W0+ZSiRY=; b=utJyols9Z/V5mAw+YCU8IJIzzi2DWzHH82QJcIHT/UgGPmLZnP7xHqmTQiDFdRHle2VZZrq+QkIldlbRstwotGynuTl81ZJaMui+dv8s8vTjVYQRHDlkizk+F8lvBW+n3OvGTzto+Fk37+kXcBAMH58NyaVMK0RLHWd+nKAr9Azg0Y9BBvshBjBBELuIXIekUrLNV4fmcQ0d27P0rN5kb14tB22TOxQH3r1qHodXV2pWWaBaf3/uq0TpNf14Te2FjI3Zr5SxcPZmh7T6qItROjZ3XeHaDBjdv9QhVGNpZZcLaop/nA4yzhGS4Yke1a5xzFrXvrrb+AdaKowoRn3FPw== Received: from MN2PR11CA0018.namprd11.prod.outlook.com (2603:10b6:208:23b::23) by DS0PR12MB8767.namprd12.prod.outlook.com (2603:10b6:8:14f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.20; Wed, 12 Jun 2024 16:25:15 +0000 Received: from BN2PEPF000044A7.namprd04.prod.outlook.com (2603:10b6:208:23b:cafe::28) by MN2PR11CA0018.outlook.office365.com (2603:10b6:208:23b::23) 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:15 +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 BN2PEPF000044A7.mail.protection.outlook.com (10.167.243.101) 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:15 +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, 12 Jun 2024 09:24: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, 12 Jun 2024 09:24:50 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v2 2/8] net/mlx5: extract queue index validation Date: Wed, 12 Jun 2024 18:24:20 +0200 Message-ID: <20240612162426.978117-3-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: BN2PEPF000044A7:EE_|DS0PR12MB8767:EE_ X-MS-Office365-Filtering-Correlation-Id: 2cc32a65-1a22-41ff-5233-08dc8afc3dec 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?348vrehWGUEqC0O1WRJ4Aw/NfvMtugysglsJ2Ie16PBDzAR631SAuuS4RAY9?= =?us-ascii?Q?zzD/NwWXLGpDS2Gtz3C9CetjRv8ydh3ogPeAOr9pScxAS2hrs2rgSRxj1zLx?= =?us-ascii?Q?BO2DhDV0RSEuYamAIRiRZ5KqlKAIWF9zFp4FWNS6HMN2R9FcsR/j7BqXk6KT?= =?us-ascii?Q?Z1n296l1SWZpPkJrCEzHDD285RW4JP+cX8NcQtJZPrFDOXGBrAi1+6K5gpnX?= =?us-ascii?Q?HmEIt35pp+rxWL/m2vJX2Ho4RrfOu8fCHdbj5CDIBO7OqSkX8rOwiiVwN0K9?= =?us-ascii?Q?8643eJwrfuTOvqYyNiq7W0PYTvZ3VTfCtU7iz6kf78s6pzyOebn5dxrKg0aN?= =?us-ascii?Q?aSZCmGA74R/WLkCmjHA9y5Ribyah+KAttBsRKAYavEkKH/BZov+rO43W3SeF?= =?us-ascii?Q?auh48GXqjrSlUeaXrMsaagQH+dB5PTh8PuJH18oB5jpV0Cjt8C/NVHwXuq4Q?= =?us-ascii?Q?SIf7xdlKX8EPwkJ2c3nYwvTD3jP8W6DZSuyZpeGZE3g/PQNpfmkZEgYFWL/V?= =?us-ascii?Q?0uvoD6I2bsFSfYM2JPsxyIRoGrubNRVsXeBbs/H9ro3kqzb2+4uRZco9G7vi?= =?us-ascii?Q?cMX3xwQmID2qrnLb8i4haY6lBoDrFWQI7meIU54SsldMGOZKYNFPYhXc0fg3?= =?us-ascii?Q?aqiDPhY+T7b4AH9bmTXu2yqdaZUn12AJJWfpKdIEwcDW0avugFXsd+etEPKT?= =?us-ascii?Q?bDWUl0foi7e/HcXxhmGRJbGuU37nyJXb7VYCxPv6HNCX7zKAEjWCw3SU5Eha?= =?us-ascii?Q?ty007AtF9eYEXErDp46IRPwCsh9xgYViAYB3PZLUhCYaE5f5dTRarbT3HSVe?= =?us-ascii?Q?dIe4WehkGDOLpOqdrcvwSaouH3YCfFZvxivoicdEBmbr6bsG1PFIL80DNb/Q?= =?us-ascii?Q?ov3c14dQjVU38HiDyO+Lr4eWtgTveqpQ+sIdKiEOR+Vdon7B9qvnuHaNov7v?= =?us-ascii?Q?FyPEDsgrDOcR0hehtXOHqPwyzU9MyINbtGoqStcrFAY3MXOmxeNgT0MhK6Kk?= =?us-ascii?Q?fzHyWANPGLlzV9/ea/9bJHrLz/gmZKyU72niMm3pXHp3srJoevi7HyL6ESqD?= =?us-ascii?Q?HRm32uY9X08HVlwC6JCZ+OWA+P2601esWXV+w5tk4zrbCEewBLOMVumLwtWA?= =?us-ascii?Q?iFe0xvcI6Y8ABiC8DmAckBzDZLe9pJeRLOZupfPOBtNvpaHdk9gN4msZHUFP?= =?us-ascii?Q?8RyRze+RG/qKaKWH2iDug9nzSGQ3KNNc47LUktA41mjgtMb+E6mVkeR6OeOK?= =?us-ascii?Q?fEB0v7t4QjQvxIzgHPDub+IT3fNwJ7eeXZv257mCqe5GCmzxvCKfesEDH3+d?= =?us-ascii?Q?uQQYZSAop3pzjvsdQLXYC6GSSJQcIyke2drFwC+wc1J3RsKt13uQoOxnPsqB?= =?us-ascii?Q?Ku8P7a/E2fXE+JaEbWbtoXwqlBHp6lawB22bz7jlrwPRbAE+dw=3D=3D?= 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:(13230034)(36860700007)(376008)(1800799018)(82310400020); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2024 16:25:15.3025 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2cc32a65-1a22-41ff-5233-08dc8afc3dec 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: BN2PEPF000044A7.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8767 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 7bcbbc74b5..5374c95954 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