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 272F644165; Wed, 5 Jun 2024 20:36:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B02CC410E3; Wed, 5 Jun 2024 20:36:12 +0200 (CEST) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2085.outbound.protection.outlook.com [40.107.102.85]) by mails.dpdk.org (Postfix) with ESMTP id 0315C410F1 for ; Wed, 5 Jun 2024 20:36:12 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q+oQBZr+gEjMebr5G7kCnf3njbZ/l0UAE2ydlnbs1+EmcMU+Il/LDlUyEycGWSBO7UVj+5zcojBdPecdjeQuRAC/Z60m1+ono/sr0P6LDwH9nEEM0o79tg28/mnveydqpsOohfalYo/i3L8hqoMGbGhg9HqY3S+42r6fV0zB/89Rf3ZSHkLk6hCzGn40oMkMZchcLBj1iQt/l0kQHQ2eCXKKV90Y6rQ4cwOrGB1VatXB1PbJmkAKj/HI9VPbTtN1VeV9QXo5zoyfnVfb0hpDl0RKA+MURM6OLOxAc6rYB3PFVc0yu7NA/mBjGN9UUYKYnMrQQD1pN5dY0krl5TAo6Q== 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=iTejDMZ7+GG7PQFXy5LnEKvcxXYGm5+O2acWiIpv8kc=; b=i36fCtN3zkG9OUHwRYfARVpv5MMZEKNMSw2X1I5+nheBlrmJbkSvHp9l4EKigZG95xjgNVZuvYBAyYmy92iJoRaVdDeRZdkH1np8koOFAm13PjHwvExsILSJN+K/+bgrzAq4woFx9BggNPmBgHjWbfx0crKkpDv7Oekm5X0hpesoGg8M97bGLlXhAalFBhdzy1y/gcb+h3r/0yeiUGcLYnx5R7jmSyLJ+QbSQgkb+3mZwDgzhJlP05IEjZmWc90fxDOlId2O6CQieh811XdNhLaproSWFnLjcQZ6saYRofEDs7uRsqR23e9YD+cqc1rtx67HLRgrDbWHY7NTcZDWkQ== 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=iTejDMZ7+GG7PQFXy5LnEKvcxXYGm5+O2acWiIpv8kc=; b=GcA4jHZup08vB8zunw4HowmDN7zRLYfufcTk9JASwUkeTz3Uvy9RpKLDe8Qhr79pGv3TTGTORffLx4M7/Yy52Vg/pNaRvEHv68PED1jnw5ENVKvYiKCCv7ZzHHksci2BYlj+ye8dgz297scfChptq5IXsTezQzVFiTNBEjPzUIGo03/4NHoXNm7/zDpIT1CB9FQLLjzBEvq8jQkRPmvvTdlWvVzhIiHvWlGJL18v+/+0S55IUxvnao2NfURc50Z2hyHerrC3nGvRMhIZ0YiFiqNQHG604AaD/kfx18aCY5E+6DUdGL5ZwE0tfN4Y/YWgJ3IWpGbpqUTseLCBOD7czQ== Received: from BL0PR0102CA0068.prod.exchangelabs.com (2603:10b6:208:25::45) by CH3PR12MB8660.namprd12.prod.outlook.com (2603:10b6:610:177::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.27; Wed, 5 Jun 2024 18:35:42 +0000 Received: from BL02EPF00021F6B.namprd02.prod.outlook.com (2603:10b6:208:25:cafe::12) by BL0PR0102CA0068.outlook.office365.com (2603:10b6:208:25::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.18 via Frontend Transport; Wed, 5 Jun 2024 18:35:42 +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 BL02EPF00021F6B.mail.protection.outlook.com (10.167.249.7) 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:41 +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, 5 Jun 2024 11:34:49 -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:47 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH 3/9] net/mlx5: extract queue index validation Date: Wed, 5 Jun 2024 20:34:13 +0200 Message-ID: <20240605183419.489323-4-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: BL02EPF00021F6B:EE_|CH3PR12MB8660:EE_ X-MS-Office365-Filtering-Correlation-Id: b3deb76d-1561-4e3f-73a5-08dc858e4ded X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|376005|36860700004|82310400017|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?d8V/lBllMPgKO2wW8+SCOSYwPOAgJVm9DpkVGjCXZgohE4KENVVIGSDFg8iM?= =?us-ascii?Q?kuatq+3nRn+Nu2/xw1aUN2+4yDp2NxMZnlf32L7EGqXbQERxljxPA7WaU4nW?= =?us-ascii?Q?IPKMY5GZ3/5MfVVQEunQp5UBRgyxFA6XGnyv0ewdlm9CnJfoNgJHPgpoFB8v?= =?us-ascii?Q?UlZz1eSog8eNf3tF+n8VSLCsnvRlhrVeDEfSR6H35lHWrtXd+UuS81IVWcK5?= =?us-ascii?Q?20fqketYuZysyRNHKpAb2CFLlniMonnlgX2ZQfchAO7Heb7XXC4xrZZdfmEd?= =?us-ascii?Q?8eg9W6fNEL88Gutm4LIOF50jHfPpEFB1pAly2qQvtH5LFVcnqgATubzAzs1Z?= =?us-ascii?Q?NX5sSt5o9LRiRmTeAzsiZX+msSVam2+ZhbkX6mDyiu813ns2/g6R7TkPJaOa?= =?us-ascii?Q?YW/+RWJ/tBHeNGad8eQRLmzcxOrIVGUE088I4IHB0Bw3mUQpzS0hONpZ0Oxr?= =?us-ascii?Q?zs/D7ogeS34G+Rf0p7SW0+WZ03zT5H+Lb9Qy3SyOTtIpdqwDHw/baEx4sAln?= =?us-ascii?Q?wiyC4zKM9XhnfoEICnuEQ5/QwUWc02GHxq9jEysIEY/P5TUNEvej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US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(376005)(36860700004)(82310400017)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 18:35:41.6837 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3deb76d-1561-4e3f-73a5-08dc858e4ded 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: BL02EPF00021F6B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8660 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 18c8890e4a..9643fa424f 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 5f51f7257e..7be95a7d18 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -2948,6 +2948,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