From patchwork Wed Jun 26 18:14:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Sosnowski X-Patchwork-Id: 141883 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AFF24454E5; Wed, 26 Jun 2024 20:15:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 09A0640648; Wed, 26 Jun 2024 20:15:17 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2055.outbound.protection.outlook.com [40.107.93.55]) by mails.dpdk.org (Postfix) with ESMTP id 9503840615 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=fAJ4ti3jwC/Zps2fPSO3DkB9hTkCy6RO1Coc8OE4+/nX0slnmmKZyeoNhTBU40IdFNGcaYNqQGYucWUFKv2KIiq3ioczEWglr4fIOV1KyLbnWZ/WQzFzul3p/ovkNzUNo8TOGsq53UkdbPh/d3U9LudE1PmsdTjypvNdQUh9F1mdMemOK0M3ZeG3uuBJeaTEKg0+E+beIR4mjeSkWPAxhpjSa8aF+7zkQuIMZjMdtHIyLDRdgX5YTagEvil5UZu9otSt1lz/QiD7ez1mPf8Mw7ctfADVMd3O8GbChpaJ2rz8ux+S7Nw75iMdwwu21U69OW57k2dhq/0ZExs4yjUNnw== 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=oV5JH3nfTc13WHvCaElgsyKoD+mAG3lqyVU/Oty3rLk=; b=UXwSYRq+f5cHDXNPtXyLfm7mYGZL89GzdBJRowxVZ3BuWm/r2nm0PLurpRriW+nH5e4J9oLtgQYqB7fQyn7Ml6OUwLjrIf/YDeT5HlUw/G8zpKAsCuUw8Ky2WkiFa5l1R8JupovZjbcPQm7ngwulb13vk6jdrVO8gCiHuTHvmDTrO1L/8+TP38/FzXC6MLpBfpcHaxa1uA/+ITk1FkazQJ18563X2MnWdowj5MaoAsvuelmxHji73BcYwOeJuAvCjXwU1IPu/3tzdf3xK2frgnATwKRtuQa9WEl8kLgnhhUxeykQ/R5MZ7NX1lZ5BM22ctNYKizAo46EpCmPWkbUxA== 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=oV5JH3nfTc13WHvCaElgsyKoD+mAG3lqyVU/Oty3rLk=; b=aNQYSK+yI87DGTrqMn/9QKJw4U1HWNl/DcShBRPCyEs/OuwQC/rXwSKXKrraS1zKZMo44GKbMhfB1VY3MruGV0qw4KEZugbY18hj12NsOBVLBq2gviunI/PgEAjNG1Fy50w0vBa0zJjwjzwFWoxYhX3m9c67sSdw8g1UvNtBuf9L6VSwen5ZarPH2NTVLBp1aXsv8W8Txb7izuiWfE0cAc7iEpmg0aLTXcrVl39JF/IaFOME0FHnkXqB90zbDwlnAXY/j5k2QG9eoVgP9d4HlPSRZyBPi77uidUlDleXDdKU5csE1gc+AWxlcQlTm0rOyycOUlYKJqvcvz2dhWyY+w== Received: from SJ0PR13CA0095.namprd13.prod.outlook.com (2603:10b6:a03:2c5::10) by CY5PR12MB6106.namprd12.prod.outlook.com (2603:10b6:930:29::7) 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:10 +0000 Received: from SJ5PEPF000001CB.namprd05.prod.outlook.com (2603:10b6:a03:2c5:cafe::1f) by SJ0PR13CA0095.outlook.office365.com (2603:10b6:a03:2c5::10) 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:09 +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 SJ5PEPF000001CB.mail.protection.outlook.com (10.167.242.40) 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:09 +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: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, 26 Jun 2024 11:14:48 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v3 1/8] net/mlx5: extract target port validation Date: Wed, 26 Jun 2024 20:14:21 +0200 Message-ID: <20240626181428.1678402-2-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 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: SJ5PEPF000001CB:EE_|CY5PR12MB6106:EE_ X-MS-Office365-Filtering-Correlation-Id: 231c43a4-0ab7-4234-5772-08dc960bea27 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: ldt1hFEN3LtutPxIP5WUFo8v6vNm8ClGvZC2bmNhpQCvqXkQ0ZMFicfLZFa55AQY9O2u5yNB25WMWJF25l4ITmcT3x4vI/crw09fr3tTDHNxWnJl/zfAWJZUM3tLVr9I2TmJuzWY5YrciLN1JIWNu9CJMz8AR2h1k9+5DnnYWjj1UOiAm1/uY0+z54rzZ2Jg7PaA1UHIZS6XDsrn2xIRSU6PK4ldUWU7pPiRl2fSERnF6aeEib6f8IFa30r7zNnoqnWRxFzKk0+h9U+X7ETZUh/4d+GBC5PyMouwBPO/YSdcx9da4ues8CwzdRnWfeKhhGPHAE2rOmc3CkgbRLG86IFBUhZY5BpwwZLfMLumwmQD6CyyQaomBfo4eB7ucixqPDvnOLfE2nhX69rmsIMcqAn4BgLR7YhCZmClnxzjdUe5QmPJBdQQ954ZAN6mA7WzGiJZtXHGOzB5v6RIYH6eyxkjUPHbCz/c6v6cbGCgK0tG541Up4QLq4frK1Imx37ukEmcnmFTuVuPOKjQkZtvivxoWVHABaN8Bj5he2pQnhsW/Si9iVnGBljytxD/70AVV7eFSFvqnogMnqTcwZge+ruZxpJzMrI/wBCMB0A2xpw1ioS3vlZvrkD2TbnqfJczONJVbmDC+osyuxsE9now5ei6KwXRrbl5ilE2ZCArt9eF2Ur3MGeWK6J1eZCKVSzObmioBXS9UGFcNI/ip6HtY5vdvYktOJgs+gqQ40nmLFZgbF7htbOi8ZkUdLnez6FyD2GvmgQ8P0mmkHlENl7BQ66QpCih6iQkGQ/pj2B7z/eMBFTY8fHPaXKADkHYbYtIgtkdPAWEDhNFB8mDP+JKPwaKEKMWU4dTjOxUrRigwA2Q9QrcQSv21Q4MOIHGlmDPDqd1+BkSnSMFlT3SL9/t8kXQRZ5wB/G/529k9+9mUtSaf0mPEyhJ1mE0duwroOajFMqyyMz5gzRy2BHBoBMa+b5T48gxsrQvM03kcuYXW+pbhRt54YmnP8NosUK9q3kGCKSNh5CejSUxs7UXj5sGi2cC/BZIwPL31XrSoldDpkVlqAGUDRHXt7hfu2UGxY2ZkDucv1YbFfNKk82IzbvSwRdIdeiiO7SMoEM1PUXTelZTqoyWJn4t76OokDKvZuSvHoitHohR/4OoXiqC0njDHr3+IVLw8YrWg3Ch620fU0LLhNxbLPUC1DE1SE2nWG1zmFz5amyYxvNyXbmRWqQPVhqF9wlovKUZCoT16YjoTERM4fZkJmtBBoR6DS2xmFrb7TSukow6F9UeM2Iews4MQssovxrKTQmkRYGNOPaGc170Hx9m581JNgk53Ad4qoWL6Si2bckChYCkJrpSb3tpN77l4tcb/gkjJU4h/l8Vo3W6/e8+ZTvEBKxipiWqLvYTlhFd5a5zMKAB+nCLCvs6hi1UCE+LxycgNF4z6wP0hKUhhFmFjlP7PSrghGXo1r+e 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:(13230038)(1800799022)(82310400024)(36860700011)(376012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 18:15:09.6865 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 231c43a4-0ab7-4234-5772-08dc960bea27 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: SJ5PEPF000001CB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6106 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 b8d71b145d..c0d763198d 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -6051,6 +6051,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, @@ -6067,32 +6103,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; } From patchwork Wed Jun 26 18:14:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Sosnowski X-Patchwork-Id: 141884 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org 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 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: ewa2K/cYdu7ennKFlEO8buyIxi1WsIbM8mrEJ0tkTJ2jhNIaM0ErQnhcfgcxdKjMnKOdtaeM1CyNTuARR3KcpuDpJmENZteMPn+ukw+4d1CUpO2emLMy88djNw59fd6GDcSC1YmLn7uQe3TwjvsFlRBCvcvXHd1hCrn6ViNtFYMsO6U5sm147gbVK2AGM40k0Q7fDqOCEvUA3p5eYzTSo8J3i37CtbrTe4n5dcf19cRYP9MeERlOFEyKxQvvFmY4oe7cVrVgifKKNPkoyUxSzROkBkWSMRdhkYq+kl48QXtOnuihc5Oio3kaUb1kPeegUQcT07tgG/FQDL1dV8RC/s33FJVYzKBm2A23arkAkzNDM6ylb/u8sqQJ82POfJo6JwmlPdEU55bThr/gw2LgbFppn3nemOT6Lcjc2cB3g7EZjWpbnslHS3uiT5YN21rSL7jOJp28kWGwamp76DeCAmUWy3zYK8sb7FcpH55Xj5x1QvKRdh6bbqWzkkB0dglniAmwjTiExvFWAE9G+BOSmTgo4VqrXsievY6uyvSzW2NbRQMI7ymXeZLXYa+pq2GsCzCsNYKLVwyy7um8vV8HBKC41g/0Zb4sIHqoN+I4D41sAJXH/NJTLrngsFJ+5aFrgZMFJKpO+78eKfNT6HW6T7N6G4N5NXzE9qE0nIz5ivplTjFhzT76wkyjnKAEAXHSwH74ZFiG80V5aPRRixd+t1N7cPZZDZZ4wEXUm1zcWs9Of4jbESiQSl295DsHNpQCDqhjA2eMr3rBHPVAaMpzUu6q2YQVasGL2isIR4gv4R+mcfbMZULQH573sxROVTWFpC+tn57a0nlLSFRQchUzWqvnpZP17JXojkcI/yrY9b3lx8wicWQBDq+pk1bH8R43uIJvNYdgNAbPz9E9VFummghz0UReTzTkIYVAJeIiMcbPR7LIM+bb1YiQMxRYv7I0woDqH4U7C2xXyd2wjaUCQNsPjQnG7NBa621UiYJB8c0bz9bFz9y4S2IQiloVPFxNH/E8P7K+my4Y9qGvLAQnAP7sQ2HlUY4JqYqtj35uIFCavxZemgMsCdtqoTLaV++stfBrqSACsRd8KEr3plTL+RmamoH1XPZrHOkTtRaWBqX96PBp22wQPdQqt1eT/UCsXuiwkZCDWdpsf5L2jgVx+vhn2+uUyKCfRbzo52wweC4XWMbJu8LaRSmmCNsgagmcUKycWioQKCfn5HPCejjk5ngrldJ5cEBLJDmoRpOnX/KQdEPznmNEY9UFY0EqpNnnF0N6wegD6k7/xVw+ysevdKscIkSVZROorFt1A51XsqguvzzfB0ejUoJ2LEX3g1HPHnSci5uppnyglFnPzrH3mAKW79xAnzqdiroG2Gqkx4GF6jA7zxJjJxVUZB+HvQuYdBhuhMj5FZCbHjWYfvM8GQ== 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:(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, From patchwork Wed Jun 26 18:14:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Sosnowski X-Patchwork-Id: 141885 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2AE98454E5; Wed, 26 Jun 2024 20:15:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8131D40659; Wed, 26 Jun 2024 20:15:19 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2056.outbound.protection.outlook.com [40.107.236.56]) by mails.dpdk.org (Postfix) with ESMTP id DCDF040615 for ; Wed, 26 Jun 2024 20:15:15 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ajAP1al5XTWNcQjRbGWiFmMznSbiiN8rD7te5ciVfPKBoj6bF7oP0jSbZDhxXIuCZ1bXWQ+0sH0N+TMQ+d5UeafTxZs2dntZxYWOJYT5XznRBFcytUjSEmuX0LMRUQ5hXxxIuzoCO0w4AG5bKdERtcXcKMxmYAyCytGGhlEHcwX2XBDaCpBPWdqQqu5VuFrKvl2d0I+CgBd3kvQvn9wlrOTRnEV+qKBX63P4K0F2vQRr4K6KyKtSf6d9aanlResc+JKjo7y1gctKl2bdCVCuL9+lt6bZU51mVfVAf9O4jyKCRXh+OT/sip/7G8jthmAXiqlbU9JA055G5J2ZSbFO8w== 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=78RbpBCRjKVfcSqrT88teXGjkjrZqWR7P3beGG3wDiQ=; b=WlbNlsjJR6NIQB4z9eWsFXeU9FaGYynPFngkLx0NbEzqgtnvzS3v/z1JUJokfU5K1Qt5BbZyr4K91H5vun84lglvKJEJy8jq33JX8eMi/YNq/+FNqJfvgkp0MopGEDr8BQiFqAh+nqc91NomDOPopuSYkedOogGKgX4DBUOsHXfxNaf6qXWrvqZxB8ARXyvFCN6a7fqoNwHYd5fxThyz8Vf7VSzkfRzrRNlYN8/gzljgek34c1Zp/hMEJ1lMwhsjxJGSOW7+hGScisa05hkUGOD0auBNcKEN1+VS9K+abi34l+7yJIBiAxcVxeC5o2+CF8bTgjHiAHQUABDSNoFFDg== 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=78RbpBCRjKVfcSqrT88teXGjkjrZqWR7P3beGG3wDiQ=; b=k3+R3491mVrVaY763II22FiVUKQu0WZGv/U3RSg/L7uXHFItsoBCZZySiXyj4uuYe+5T2L0T0siBySYMhet3oCMCUt06jjvJuStMAyOaLTOAZnEksVnvCxgR/BAdDBvTdPqPgO5VW4vvUCHJELbrxFmV7b44ibNKPVUXadiIuYJRZ0WjNQcv5jsBu3wxM6NZWn67QWmQ6bKVHxB/uN9eMBfsrGdZJzodzkQUlwSW7cwIhSsOR9Qa+4K/lEJurymbjxVASSgjKTG8aEkfhAKVARrhXEwO7SZ4DApS/uwDnb2hHcLedrDRgr9QMPO29Hbxi0sr4uE5doj0x9R/kGF2Fw== Received: from MW4PR03CA0235.namprd03.prod.outlook.com (2603:10b6:303:b9::30) by BL1PR12MB5705.namprd12.prod.outlook.com (2603:10b6:208:384::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.28; Wed, 26 Jun 2024 18:15:11 +0000 Received: from SJ5PEPF000001C8.namprd05.prod.outlook.com (2603:10b6:303:b9:cafe::41) by MW4PR03CA0235.outlook.office365.com (2603:10b6:303:b9::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.23 via Frontend Transport; Wed, 26 Jun 2024 18:15:11 +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 SJ5PEPF000001C8.mail.protection.outlook.com (10.167.242.36) 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:54 -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:52 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v3 3/8] net/mlx5: store pattern template items Date: Wed, 26 Jun 2024 20:14:23 +0200 Message-ID: <20240626181428.1678402-4-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 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: SJ5PEPF000001C8:EE_|BL1PR12MB5705:EE_ X-MS-Office365-Filtering-Correlation-Id: a373b196-0836-4ddd-c57b-08dc960beaf1 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: qBbqykKUrNB3BPNmHctHzMVImqg+YLbZJ3jtnXm1f/3TpT9G1d60aBpdNmVoZyroq2EcM0UBpJ/KBupmc3e9faXu4Un7k23ta6zpxpZ8GfONXVetpmk4s7crUGsG9FDdIUM+EKKzHXrBH32d+o6UvCwDaajYCHVlxolwj4sMV47Nnh+TWISVKVqhSkWJwDXx7ay9jNP6VhUlkb2Ug+CCvnl92GV8RpWDpZGlTXqKXL7k1nMieOdseuG7cfJAgntGNfbEl2VZhX3Y9n97LbF809boHBo1koa3KP2UTv3rA9YsAoIK4Yh0oztcurDOWGOSXJVQZn9WsRyiEcH0NLwr9RtKzSrI/J2fXs69m2L+omUpE8/MIbSEwGte9b0t5Lh0oVhIi81qpP2BTzDoAHUi1rl63hMTGEBaCBr0rjUhYRzltfHnoEfMi19M/+MZRy+jBfjTgWTfdkWTqcXg5V7mlozt3k9tS5kbA6Dt+ZuEjmvbN+etmz8VqWebiokbZsr9jB0LliTUOG06gCOCB8IdJ7udCGtrCDo+gSI0PVu7Iswh0F/WSY2pM3OlPBLw38jEbemiK5XjXnmlCxLST6g/8khzrzs9hDxCjb5iX5HAn+fw9AUvnRr/zGE8BUK1NXkF/rC59behCJ9BGYk+pzYxmBwZPVmO9XVoLwvF4WS46dmtBAKKvBFXjZLKG8Xgshn2kKKcDsBgGBkq6L7sxqIYPmNsXe4rymerCDnReEhwEc9e2shXD5vvDjD3lP4usqsqasrAMUzU0/hZzUQne8B1koE+nsalL4Cbne/NuNQEYeWmo0WA0NK1a2jYxyBpUjsNmAFXwdRZeOeUmCPcJsGmdMB+aIsXJZUcIEhOD+y0cklFzeW9M1MCwBPbjbe+6w1g8gr+YtRRNRFGj//cw02YywASesw8C9BXRWTtg2KfPCWQ+E6fNkAqbJgCALa9I6vGHRw1TtjhhSz94Li1/YJhTywvgoBIVU0AA8Nmphc2BsDuIsDc2q38z6DxWO0r/y3BeYBzGCXgCjQBdu63wfMqv1CjGMeIx7vTaMhkLzkkmUQ70nYa/ZFiTcDaatXhbQaT/cTrBonEaUBM/L1FuyoykKaEOFUFRLUpxF925xz2NQL9x2Sb6Ti3Y0VGQXUCTqTwK8X4vYjwYPnay8+6o5LDXyk7zW5uhW1RQLDaQ9UPzjseehjr//JM1FoXZm2tn/rp7pfMd7Q/iJefcRMj5jIuUX937ftSr2OgpZYLsT7+NQH6vfz+v2Qs9B6HeIbM9Qt83rliGXCHbbKUTZ0UoUS2FPmywMqN2ES0AMh0pevg552T6aD/yky4SogGWlp+jmnWe97xPlgCOeqMNw8tMx4vXMTXjyJjwB5kQSXyj20gVDoJhHjZzHRM09+Dw4BlXX6JE87euCG0glKl9FiDNUxwVA== 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:(13230038)(1800799022)(82310400024)(36860700011)(376012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 18:15:10.9975 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a373b196-0836-4ddd-c57b-08dc960beaf1 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: SJ5PEPF000001C8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5705 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 Store items which define the pattern template on creation. This allows validation of items, provided by the user during flow rule creation, against pattern template. Signed-off-by: Dariusz Sosnowski Acked-by: Ori Kam --- drivers/net/mlx5/mlx5_flow.h | 2 ++ drivers/net/mlx5/mlx5_flow_hw.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index da7d06d033..5c2cc2b7c1 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1522,6 +1522,8 @@ struct rte_flow_pattern_template { /* Manages all GENEVE TLV options used by this pattern template. */ struct mlx5_geneve_tlv_options_mng geneve_opt_mng; uint8_t flex_item; /* flex item index. */ + /* Items on which this pattern template is based on. */ + struct rte_flow_item *items; }; /* Flow action template struct. */ diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index c0d763198d..1ad261d529 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -8772,6 +8772,7 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev, .mask = &tag_m, .last = NULL }; + int it_items_size; unsigned int i = 0; int rc; @@ -8815,6 +8816,31 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev, it->attr = *attr; it->item_flags = item_flags; it->orig_item_nb = orig_item_nb; + it_items_size = rte_flow_conv(RTE_FLOW_CONV_OP_PATTERN, NULL, 0, tmpl_items, error); + if (it_items_size <= 0) { + rte_flow_error_set(error, ENOMEM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Failed to determine buffer size for pattern"); + goto error; + } + it_items_size = RTE_ALIGN(it_items_size, 16); + it->items = mlx5_malloc(MLX5_MEM_ZERO, it_items_size, 0, rte_dev_numa_node(dev->device)); + if (it->items == NULL) { + rte_flow_error_set(error, ENOMEM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Cannot allocate memory for pattern"); + goto error; + } + rc = rte_flow_conv(RTE_FLOW_CONV_OP_PATTERN, it->items, it_items_size, tmpl_items, error); + if (rc <= 0) { + rte_flow_error_set(error, ENOMEM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Failed to store pattern"); + goto error; + } it->mt = mlx5dr_match_template_create(tmpl_items, attr->relaxed_matching); if (!it->mt) { rte_flow_error_set(error, rte_errno, @@ -8829,6 +8855,7 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev, else if (attr->egress) it->implicit_tag = true; mlx5_free(copied_items); + copied_items = NULL; } /* Either inner or outer, can't both. */ if (it->item_flags & (MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT | @@ -8889,6 +8916,7 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev, mlx5_geneve_tlv_options_unregister(priv, &it->geneve_opt_mng); if (it->mt) claim_zero(mlx5dr_match_template_destroy(it->mt)); + mlx5_free(it->items); mlx5_free(it); } if (copied_items) @@ -8931,6 +8959,7 @@ flow_hw_pattern_template_destroy(struct rte_eth_dev *dev, flow_hw_flex_item_release(dev, &template->flex_item); mlx5_geneve_tlv_options_unregister(priv, &template->geneve_opt_mng); claim_zero(mlx5dr_match_template_destroy(template->mt)); + mlx5_free(template->items); mlx5_free(template); return 0; } From patchwork Wed Jun 26 18:14:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Sosnowski X-Patchwork-Id: 141887 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6CE88454E5; Wed, 26 Jun 2024 20:15:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DB9DD4066D; Wed, 26 Jun 2024 20:15:29 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2081.outbound.protection.outlook.com [40.107.93.81]) by mails.dpdk.org (Postfix) with ESMTP id D352A40656 for ; Wed, 26 Jun 2024 20:15:18 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N0Dgpo3y/L2Qyb4xssgsD1BW7TO2kc0k1WJz9/2rxrNoGg5nr7APyb9RCFSL/0Y7S2J+E2awuqrjUnFngcEJPBrT4XWrwAHBYNn7GVbl5dc8RSQQHLbcmOV71e5PfHsqtph+kK/HIcb8AC89HHBIIKXvA5WuSiEtA+q+9j8eB+Fe4DFYKv1GlmgeaBkXxT6mwkMA6Mp+mpXYo+36DgNoW98k1i+ctu3J6kNM2X8k+g6U5ghj3F4sHVC855EI/GbH59z3GGhgDYRe1rrPX6S65od5x7TP8oNAarKdGolU7VZRwvpJPiZQ7a4peP2ubhjivHqYzskCTCQqpKoYuG0vUQ== 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=4mYeLSUW22UBtEcm9RdTCxzRYnNplfZDxnPywHMdTvM=; b=KRFeeg8UGY+NhvVMNQkz9SfVC7aIG9jxWDpo1QAIAxiq41wl9FbFKrNoqmoHQFKcXDdgAfiRmRLgZf5tnDk4GMlZWd9/YeaPsnkR+0+mPB0uDYy318Jt0tFPMTAGJbTV3d2QhrMIJN+Z+h1hpxTBUXTk+As3BAgVEDg02qoYQLM07FjOkGQevP5Mn2C9OKOkBmNQ5dJydT9qH4dgm1cxdP2Xomk6F5533EotY3VG9thH/FSGgfv+iQxWK/dTSXBNXQ6NFAInnY8l7lzESIm9UoY8We8JteH5JGYgBNhpRbozfrOYsmbdiRntQEuqDYCDzEH3qB7kY7i7h9SgDq6BbQ== 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=4mYeLSUW22UBtEcm9RdTCxzRYnNplfZDxnPywHMdTvM=; b=L+HfLPN2sP8fWatgbkIz5JTMLRE2C+v2c/nXjmlMMvoMlpou0hEe/G0LCslIvy8+99ya8agIZsF0Kw9LhUW61kHH29QWlRRx3Wiv9Org2BueyYRXsEnjVFlYqqaXAR69A96/sC/IHfh+uTVjWd+D8JivND1gcKuMUtB7L7ZAJoBy+ytnptoNUgNJq06pL2k5TVn/aZfIg/18OLOnnJxUoHGS55mFNDwL3w/IQjWAulXtP42q7FgR4W2hOuC+34NPUocrh8MNe07JidfsPpGnHGx8oTKVSKzTT0Z6QMziNq4+6PvsLELuo7IwuC7YTgw9EBiArX6Olk/iQuMlCdAX9g== Received: from SJ0PR13CA0092.namprd13.prod.outlook.com (2603:10b6:a03:2c5::7) by PH7PR12MB7211.namprd12.prod.outlook.com (2603:10b6:510:206::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.28; Wed, 26 Jun 2024 18:15:11 +0000 Received: from SJ5PEPF000001CB.namprd05.prod.outlook.com (2603:10b6:a03:2c5:cafe::e8) by SJ0PR13CA0092.outlook.office365.com (2603:10b6:a03:2c5::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.16 via Frontend Transport; Wed, 26 Jun 2024 18:15:11 +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 SJ5PEPF000001CB.mail.protection.outlook.com (10.167.242.40) 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: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, 26 Jun 2024 11:14:55 -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:54 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v3 4/8] net/mlx5: store original actions in template Date: Wed, 26 Jun 2024 20:14:24 +0200 Message-ID: <20240626181428.1678402-5-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 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: SJ5PEPF000001CB:EE_|PH7PR12MB7211:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a5c1797-3312-4e16-f986-08dc960beb6d 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: Dvqxa9GzQtIecgMbbMO2oh71+vDqatEnom0E8hgPJb9f35Ox21TZRfVQyCPuQFgYh/zFL8vWS/WOATB5DV7o0GMKRqDXxm+9d0Wb5Ogyj/9i3x2cOUtK2YuP5sI1gsTD1TMligqxlGzSrpKy6hlG8SYfll+MhVBCWYBgjrx7fOJ6BWAif2+yr/12q0Kc0lpzOIFhq/xBKes+Yy7JS3viv2O1tMdDtWIylzIYcEffvpzGu2g0AEgpWO67v6jlhP946aWK+s2YahN/HUzpfPFt8a5HrqUvziNT7bOUh4LGny4YZ9vJA2dcWe9Vd+Anj0W4hO65CIiP8VsXcItekvbp8FLuea2c5/bHzWqhm65FKtrB6aQZabU80j9HD/goDGF9NfAhfIqlsnzjW0eojlvlZnp7TDjpUGFKhgQxjVsi9QM7tpotiUyvnVm0o8fOnVCzNQXXhGRh+YWHxMRZQGsmrHf7le0x53JjRXgZnLzfXKUijNFA72n6ibDripID5DKkpRC0qv1jt85s0sMVpTbZJ6U4PHTJR3yhEhSH3vXKF9bMRqh8gqXAHTzvhXqdjEucESxHbTAp1sxZ4QT9p7KJYJbr00lq+Ot9urDT681V5ZSvXliiEASHibFGTARuAWwvgffd8YQJdtqAWoyosxUUW0ma/UOvpnLvn1WqcoleRi70iEZ1252kLG0NwTN8wQMVyXAJfKf57TV8Wvl/gZFGQ274Dy5hP/QtCX9B7+i21/qRYatErfkoGKarHfXdY6xkbTV/aq5rJzcB1ufJegVizHYDlztD6Ob8vPJON4bo35zVsmj5DZGyN1r2u6ZIBDp6cITPpUSYp+42sK/oPqJexxMqyX4dcATlml3oVPRSDcdZm3BpQWV2/hteABXWUFFFeVLM3f+8ZVZJA8BoDUCH0NSLoyO3onez//4sTUwiHaQSaEsPzncfPlG0iy/CWDitSFkltgZHsiCXfUSiUYaMeGvaTdFDDnboRle0WqjJ1b+i7F27GJcVnt7FiLq6OVwaQwJ01Bwj1O89911NRRA3Svkt7Q8d/xpk3pS8kNeFM1ATEZidT4h+5QQ+Uq/KWE/j/bqsp+k6Q/163Fbuew5pcH15cVz51BeMLx4cYPUnWVsx1YXEKXPg3NtT/aI8LgBkSJbdFUVAcCnmboKWxKogVr7KLuUHfWCo+kt99vN2W+kG+S7Ap43vZu+o6MpGXnRPiD8uDZKGmymPrv5zkXYR6Pe0b9uuxRpFE8gEJnqJpxfxHW6z88D06rQu+n1vHaj8QhlkrlDboyWIIv+1ejr7glIwaN9/rthqWzEDw3qPXM6dUa6bvB872kW5Z5B7kCiEBgrHT//QD+IyHGQp5p7ySluO2xSYn7HkLrmghAlfSqBeQQHA6D7Ju9b3HaD3NuQa7VSwIsZB/H97fOY7KynhAlqxq0x7SAQ3IjsOrg4y26irH22XQxPGnuTFoqZOym86 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:(13230038)(1800799022)(82310400024)(36860700011)(376012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 18:15:11.8115 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a5c1797-3312-4e16-f986-08dc960beb6d 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: SJ5PEPF000001CB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7211 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 When actions template is created in mlx5 PMD, some actions will be replaced with another or some actions will be added to implement required template semantics on NVIDIA NICs. For example: - RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID actions is replaced with modify field action. - Modify field action is added for preserving metadata between FDB and NIC domains. - Modify field action is added when quota action is used to amend ASO syndrome. Types of actions and their order in flow rules based on some actions template must match the original, not modified one. This patch adds preserving of the original actions for actions template to allow for easier validation of ordering and types on fast path. Signed-off-by: Dariusz Sosnowski Acked-by: Ori Kam --- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_hw.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 5c2cc2b7c1..8e99e76e5d 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1532,6 +1532,7 @@ struct rte_flow_actions_template { /* Template attributes. */ struct rte_flow_actions_template_attr attr; struct rte_flow_action *actions; /* Cached flow actions. */ + struct rte_flow_action *orig_actions; /* Original flow actions. */ struct rte_flow_action *masks; /* Cached action masks.*/ struct mlx5dr_action_template *tmpl; /* mlx5dr action template. */ uint64_t action_flags; /* Bit-map of all valid action in template. */ diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 1ad261d529..1ccaf844b8 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -7750,6 +7750,7 @@ __flow_hw_actions_template_create(struct rte_eth_dev *dev, { struct mlx5_priv *priv = dev->data->dev_private; int len, act_len, mask_len; + int orig_act_len; unsigned int act_num; unsigned int i; struct rte_flow_actions_template *at = NULL; @@ -7867,6 +7868,10 @@ __flow_hw_actions_template_create(struct rte_eth_dev *dev, len += RTE_ALIGN(mask_len, 16); len += RTE_ALIGN(act_num * sizeof(*at->dr_off), 16); len += RTE_ALIGN(act_num * sizeof(*at->src_off), 16); + orig_act_len = rte_flow_conv(RTE_FLOW_CONV_OP_ACTIONS, NULL, 0, actions, error); + if (orig_act_len <= 0) + return NULL; + len += RTE_ALIGN(orig_act_len, 16); at = mlx5_malloc(MLX5_MEM_ZERO, len + sizeof(*at), RTE_CACHE_LINE_SIZE, rte_socket_id()); if (!at) { @@ -7894,6 +7899,12 @@ __flow_hw_actions_template_create(struct rte_eth_dev *dev, at->src_off = RTE_PTR_ADD(at->dr_off, RTE_ALIGN(act_num * sizeof(*at->dr_off), 16)); memcpy(at->src_off, src_off, act_num * sizeof(at->src_off[0])); + at->orig_actions = RTE_PTR_ADD(at->src_off, + RTE_ALIGN(act_num * sizeof(*at->src_off), 16)); + orig_act_len = rte_flow_conv(RTE_FLOW_CONV_OP_ACTIONS, at->orig_actions, orig_act_len, + actions, error); + if (orig_act_len <= 0) + goto error; at->actions_num = act_num; for (i = 0; i < at->actions_num; ++i) at->dr_off[i] = UINT16_MAX; From patchwork Wed Jun 26 18:14:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Sosnowski X-Patchwork-Id: 141886 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 30CDF454E5; Wed, 26 Jun 2024 20:15:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F362A4065D; Wed, 26 Jun 2024 20:15:20 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2050.outbound.protection.outlook.com [40.107.237.50]) by mails.dpdk.org (Postfix) with ESMTP id 305A740647 for ; Wed, 26 Jun 2024 20:15:16 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lieLy/twN4CgdgTUrnNkZNpF7jrBaGUMeU3+E4ge0+yge31DWS7koxJzNZXLtBnhH5m/yMsqQxFl8zGZRdzcGdYlI4c3fnFTyDHwHDV/4LoCedRwDbqRFm3uYzh2SM2ablL54bJ7KrYVTve9lftDrx6kO3W1fSnmK5EmBkagz0RERw4AGc+KhapHTAgjDptt6ERzoZ4Vgcx3t6r8EM7HbPt0kI1YZrEmgExFLvJvdVGqcfJ+naAQbbTkqR22wbU4i5Zvht1MXU3nhG28NdBQ26UbSNhISrBim2n61iML0YZHbtKuZPpWPb/4QeuPTM7CmsWfPF2ILh0DHMPT0pBVJQ== 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=uF43DKZW5LP/IyPwaVtEyTlAbJFAurp9TAyR08u2Lj0=; b=ClZBPNgQ14JJmQYmPtuVJf/cq3KeWgJfDcnl0zHKj+tJudZ9tbn0gRgfy3gQAY+0oRIGzD41EPOgCsAinqNBPZA8KNdxP0RnYlJMHFVgvYdvE72uD5a90lX9Wyx8dgmJgCd73qyDGFC6Z9EGM7nU/YGIzMlR0SiPS9y+dzrX1Y/iWyYVdFN9MNc7zltwxMEFy2uODV4tuL/ejg1DxTGjwyIp81ud7gi7C1sTiu1fEuIWwrQ5xNH2JMI66aIK8kB9OCiza3r0XellSt88ajMiqDKyyif1YAs7e7eLJtRrNR8XRsZ7KxwvOvvRKT8tk1WSF6KXBS+n3xLSGZ3dtePuYA== 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=uF43DKZW5LP/IyPwaVtEyTlAbJFAurp9TAyR08u2Lj0=; b=fx3cl7CukQ8ovt0jkXdnAVqJjzJWBgqsanW3SHNa+1SrsDeVe7wb0Q7X/p36d3jJLa6nYy96ne81cGF0ZsmOg6BV8PUaiHM+m3ZOP2yvXNOAAixErJhbx6TYTiFMjPfH+ZTU3zLsjq3beYf1jJHGe5PgkQlEdgU+AddCmo6wVIwwTCCtnj0nbMjgVDLo3Drkz4Ta5kC6J/4Om567syYrobxiNLhlPHSKEBxWRNzQd/P9FIp55mamgUR+WeP6sxrPmgCzIkjm28OCK6qW1DMi/LBgjYab97EbZiEanoEf8e7/kU0GYXrcruhagXodB3wuyDX/+0ewbKjaqTf58zLaMw== Received: from SA1P222CA0196.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c4::23) by LV8PR12MB9334.namprd12.prod.outlook.com (2603:10b6:408:20b::8) 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:12 +0000 Received: from SA2PEPF00003F62.namprd04.prod.outlook.com (2603:10b6:806:3c4:cafe::a4) by SA1P222CA0196.outlook.office365.com (2603:10b6:806:3c4::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.24 via Frontend Transport; Wed, 26 Jun 2024 18:15:12 +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 SA2PEPF00003F62.mail.protection.outlook.com (10.167.248.37) 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:12 +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, 26 Jun 2024 11:14:57 -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:56 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v3 5/8] net/mlx5: store expected type on indirect action Date: Wed, 26 Jun 2024 20:14:25 +0200 Message-ID: <20240626181428.1678402-6-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 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: SA2PEPF00003F62:EE_|LV8PR12MB9334:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b253d1e-1bb8-49a5-de41-08dc960bebd1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230038|36860700011|82310400024|1800799022|376012; X-Microsoft-Antispam-Message-Info: umqVptsAgzmzTpfqAthuTbJL0uZ2SN5TymJnR7sVvaL3fkdeA7qM9G2aX4Slve/AFhnjWjno1SAq8oyuRIYFGg5iCCdjsp48rGUedoB9Z5bnjQo+3xzcOv3aP+7MxxFHVi8KQUJ1UORr/RkiGBD4do2zeuseQ18IRG0uVrIAkCMQTKEPs9iEDuocJEwvNgPw0C5RWOLe4/1xLOxh+R04rYrIRlZLRtTMhoHEMYOVNf1r2TW783QpAUXhqwOAut+fSYoVNnDZB2LLxlP5idi7aH6dMc6wFKCj3rkmmILbIgirGR5Osv7/jaqI5cksSzGvziohZtDo/jbXZQOXNHHZKhYw/J1aL2Abh082R1qgTIOwdNbehzgEjfiZo0KjgUT83oiPKoWRRGM8cg8ELjkReN4u6xfw5l5s3YKbKQcyb1UcmLKrW+pOysFOfUvESKznNfOdMTj3hoUTGfbv/5nOdwF1zZbp6k6O8an7TQpqTPH2vwKsQaCbn9egJe1Ow4OMOFpicv7AP2IF8rmlVl0iumO6TX3qGNfVxNhOPyeYob/5fcTau4UHGTnfUtUDl2ZNNu5AdLbWHmw7Gg23FwXbxCwB6THVXCHRKZJ7WM/g2ROW5/SZsZhvmlhztF4MdPsBXNsO8wibI8NDSuSZ2y2txovqoL4cjsfeeUpdkAxVpJjvWqvq3+KavwxKQ5TjoRwtXr2FIHAuzruTxS0w5jXIF89CCdjnt8J26oV+2GnHh10AfRTGguhrVaY9tbhG0aKIvPcs4xVsKKQLq0ezmIURJB213A0eLEgmlMkVsbi5j2FzsqhZQCDo0eddR5L7qYDfR0DTb6o8XLnjxGhmt+Ft74jw056ni+0jK0KPviSAF44c7beArjvWQaTwuzE7jr2/wFZ+AjRfPdB4vnK9Vw8DjtKjl24Yf89Mz0OKhO8Qb7FlrmvBINQQTahm2MkjNxJ7yE+m/uL7seI2NlrSBqvhvohVBFB+YSt1RpDhSr+DFhBmJZCKyorIQbNgOdrwjj0FVnyjsW4zR0BljOiRpSgYC8Cbj4eHzJ8Ji0EqVTo8OTFQbOUShPbcWuXglQw7/7yxYE20VbdYjQ5ufBPqeyPwlo0jMLLtOPfAQa7x8uKfUULKO4VWaeoIBzDYnlesIlLsy9/earXzQ1J5q7XFn4SFT/t3C7dq+vQU/6YwIQTf6wPJpeMPsNgmhur+7jkLw56ueMCslOm5cHu2CKTRL8Oe6iypeqaFOoPySfKiqEOtjNMRg1DB7R9g4ad63TODdyALHlwbSIpFMGoofovVxLgS/lXNTY05qKP+FFf3I8sNvYtrlUTqaN+23mzjDvB9Rw3uQZkeEhqOQ8+d2G1mnFtM/rrrbuszVrYFiIFv4VjqKZMeKv8SM7Opg4A8A8C/kF4RJKzKiOWKDnO3VDH0g0Z6Qg== X-Forefront-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:(13230038)(36860700011)(82310400024)(1800799022)(376012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 18:15:12.3411 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b253d1e-1bb8-49a5-de41-08dc960bebd1 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: SA2PEPF00003F62.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9334 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 When template table is created, list of unmasked actions is recorded for future flow rule insertions. This patch expands entries for RTE_FLOW_ACTION_TYPE_INDIRECT actions in this list with information about expected indirect action type. This will be used in follow up commits which add flow rule operation validation. Specifically, this will be used to verify if indirect action provided by the user references an action of a correct type. Signed-off-by: Dariusz Sosnowski Acked-by: Ori Kam --- drivers/net/mlx5/mlx5_flow.h | 4 ++++ drivers/net/mlx5/mlx5_flow_hw.c | 22 ++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 8e99e76e5d..33847e2272 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1442,6 +1442,10 @@ struct mlx5_action_construct_data { uint16_t action_dst; /* mlx5dr_rule_action dst offset. */ indirect_list_callback_t indirect_list_cb; union { + struct { + /* Expected type of indirection action. */ + enum rte_flow_action_type expected_type; + } indirect; struct { /* encap data len. */ uint16_t len; diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 1ccaf844b8..f337f76450 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -997,6 +997,24 @@ __flow_hw_act_data_general_append(struct mlx5_priv *priv, return 0; } +static __rte_always_inline int +__flow_hw_act_data_indirect_append(struct mlx5_priv *priv, + struct mlx5_hw_actions *acts, + enum rte_flow_action_type type, + enum rte_flow_action_type mask_type, + uint16_t action_src, + uint16_t action_dst) +{ + struct mlx5_action_construct_data *act_data; + + act_data = __flow_hw_act_data_alloc(priv, type, action_src, action_dst); + if (!act_data) + return -1; + act_data->indirect.expected_type = mask_type; + LIST_INSERT_HEAD(&acts->act_list, act_data, next); + return 0; +} + static __rte_always_inline int flow_hw_act_data_indirect_list_append(struct mlx5_priv *priv, struct mlx5_hw_actions *acts, @@ -2486,9 +2504,9 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev, if (flow_hw_shared_action_translate (dev, actions, acts, src_pos, dr_pos)) goto err; - } else if (__flow_hw_act_data_general_append + } else if (__flow_hw_act_data_indirect_append (priv, acts, RTE_FLOW_ACTION_TYPE_INDIRECT, - src_pos, dr_pos)){ + masks->type, src_pos, dr_pos)){ goto err; } break; From patchwork Wed Jun 26 18:14:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Sosnowski X-Patchwork-Id: 141889 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5C21B454E5; Wed, 26 Jun 2024 20:16:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 382A940678; Wed, 26 Jun 2024 20:15:32 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2051.outbound.protection.outlook.com [40.107.93.51]) by mails.dpdk.org (Postfix) with ESMTP id 74B934065B for ; Wed, 26 Jun 2024 20:15:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CbPMsyxdhdpLQ2kduE9QT3jobMwB2KMaQbZrB/oLB561dl9zTE/RqVposKdrR9voceDF+vSwex5YYDW6nMlAIeSUczqBv3MujxcPUi7M3T97tLGIcX1iqxus4B7uXwIgHzuXIeA3BOtd+iK4IN2G9URmELRbl74ZHtxh7rMF2sVXFwt2BxfIgEhwaZd5mVfHy2zlQcZ3vbyIswf3DcrNXUnQ0ikfXLcy7ttJh9eErOqUG/A9BjL+A+bjZTID26y8nr8f3ZusyGeCKavYhP/tCXQa4U1UVOFzdd0KGnPjCJUvMtpINQHKPX/dJ3NPl4ZwLwnks99bOePiVO/Qk85DpQ== 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=x5E77PT74jTVocdfgvPIetpBw1tusuhpZ6U59q8VUUM=; b=NR8tytiCrkNpp+Q1k1nd9jLGYsu+RoeZMsJEfer/lXbpssU8k26PKwcCN1kRoESfD77MEML8Lp4q3Q9fLU5RoX6nj2tHFelY0RHTcpHE6BbMkIczksIb+G+RXTZ+m2kyu/eYq9TrS//VRa8z588jQpdsSnbcygxsVpE/d1OifyrmT1bAjByrZP0SBltjN1QFPG+uIcrPmpw7Zmd8P2ZgebsLe2tWk77/u8aBK7mIkokDFytvCW77ez4wXhEE15S47vxCVyszEstecDTYEdZoEmo+/OEechTN1ZC0wnPmoGQ4h/EdUUhNKRvn2xUwWHYRC8ozgx+MZTHVF+20tO1yng== 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=x5E77PT74jTVocdfgvPIetpBw1tusuhpZ6U59q8VUUM=; b=H6hIG9kln8jN7/u5/9xVgu9KLuxSWoccQSH4nAH/IGZJaMq0qrzS8tZhk12uWPhYHoOckzd2rzq41HHUwmP8bl+sTu8OUG2ahGl7XEI5CBNWdTneCCmh355E8+WllKjt65ZIeg2I7E7InRvYwhNGi2FznNnudqqKP7qNe6Ff2l7WwP+2Tv/QCdLAi6zFJIHWsrVwPqo+XSpBMh1M4ZWA/xK3xQX4dBMAtMlFjljjrBN635jA8rWNqQT7N9o9ZdG5oNXECVKc+f55Pxx5e3Fs2Nx39x7DE2UEv1XQoeUY2kM4czGpDXoFrCLxyh4WqJ/jyqfeK4SPEIYNA+YzAY3PLA== Received: from SA1P222CA0178.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c4::26) by SN7PR12MB7954.namprd12.prod.outlook.com (2603:10b6:806:344::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.26; Wed, 26 Jun 2024 18:15:13 +0000 Received: from SA2PEPF00003F62.namprd04.prod.outlook.com (2603:10b6:806:3c4:cafe::98) by SA1P222CA0178.outlook.office365.com (2603:10b6:806:3c4::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.38 via Frontend Transport; Wed, 26 Jun 2024 18:15:13 +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 SA2PEPF00003F62.mail.protection.outlook.com (10.167.248.37) 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:13 +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, 26 Jun 2024 11:14:59 -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:57 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v3 6/8] net/mlx5: store modify field action Date: Wed, 26 Jun 2024 20:14:26 +0200 Message-ID: <20240626181428.1678402-7-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 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: SA2PEPF00003F62:EE_|SN7PR12MB7954:EE_ X-MS-Office365-Filtering-Correlation-Id: 43977988-68d1-4954-387b-08dc960bec8e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230038|1800799022|82310400024|376012|36860700011; X-Microsoft-Antispam-Message-Info: vkjfYcU0d+YifoYeotsDy3Q9oKChqUlK5Q82HOPz394J3NCzqOTC2cNA0XukrXNLRYVljtBHOQ6JTdfXaPeAz78LJp44G9soiWgUEZtDhPqRmWIK24ssAopeJMy/S/PNr0CfEwGSaHtBaHAXQQ3md9XrY9R8a2Svpc4T3EelJQVZ0ok2ymls4ES0X4Y0ej4B1FhHiBy33o7GgrC/29ufwGC4W5gGpsp00d8AijG9NwDvg65Xd/IzPZtShn0pyatd4CACqnoiKpy1HIW+pX+bIXFP5/bBBPTVHEqcy6ynCudQvgzNdNcTJ8HDiIYA7DAdz81FhwdA0mZcJjpujSwLTyYfMeR8JlrN08VhzEi8XPdyobsQmBBKdWGrRYph7cgyIoAgeh2iKl3lrzQx3dWp2TNu+GFA5o9wMKTlTDFO91WHIp533ZfcXcYiJ5eW/tpGzD/Fa7daLqBbsE8oWkPGUE6teuwmqKYvmBilS36aK4PXfR097JXnbclTHDVR2qCHJCy8YrcNj66f+rmYuHkAY/nw+IaJizkS86NPMiBFxNGz7IMor7I/JPld9jMcr6tYFKON36zBso1eVkn99bIIha5EqpvUdhakQJGcqdrjLkOvj2JgwAr9CPz1ochMYWgh/MQptfGLKy+UJEWTHXSRq3/iBO9EV1NpOE3pcJCr/LOO87exEP9WsiKYbNRjc7NQ0n7EUpyprJ4oefC+4GDuuq4Kp7aDXmD103Wlm1Qlb3mZLLgJFs3qwgnH5yEjz7yFxeta6CPa6scl/cwmGcinSQZa+eXp62g7RvCfwaus7pcK5Jkkt9RN5VvJGRNwkIkF2CGSVfyBfObd4L62JYbJagsnPYF+x+muc/9WYOd6g9cb4kLqlOr+jPTi/pK6LIRJ9NuwmmZicuGD0WzprnV4ajm2zQnkleFm2tE8J+8ZmCHxBWZYt5D2JE7+dyiKwJhHtIJ0llSiXpn+TpqEVkwSBxZUHPfjfhX5WhtJaNsA64BouVgkLkcUYuDovDK8MojrfPLIsW/D2JxhyN3xltYaBohtMqx9ch8U19DVq5KAaAHlEyQ7BdyhYrCLKqu0bm9oSqwLGT87S2FZQRG09OvW6WwtGaQFPQylw/4TlSUXacYulndFHDo1wJB/B7XTly1gLh5o6fw4bKsDKuVpEwsjb6B9TNz9VdqG3jEAg4ipBrOr3Om+nsmbKazHrmIooXGFKCV6LSajs1QZATICweT9Sbq4FO5+tCzM6g3ZFSD8tTxtiLzEb1MJ3HvckBTMddFk5svz3Zn3LofGPrGtfC26T+HNoxk+zDg1c0947TUJlifC4X1I5+MVDJSzqGtXDJz81sLo5HAxvqzk/utf6EFzIuTb9efNWHZj+0EHscPTY+VnUdh5a3u85ERS6nJOJzl1xYzUhY1KfGIa1Q08CzyWMQ== X-Forefront-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:(13230038)(1800799022)(82310400024)(376012)(36860700011); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 18:15:13.5911 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 43977988-68d1-4954-387b-08dc960bec8e 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: SA2PEPF00003F62.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7954 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 When template table is created, list of unmasked actions is recorded for future flow rule insertions. This patch expands entries for RTE_FLOW_ACTION_TYPE_MODIFY_FIELD actions in this list with a copy of the action from the template. This will be used in follow up commits which add flow rule operation validation. Specifically, to validate that RTE_FLOW_ACTION_TYPE_MODIFY_FIELD action passed by the user is correctly configured. Signed-off-by: Dariusz Sosnowski Acked-by: Ori Kam --- drivers/net/mlx5/mlx5_flow.h | 2 ++ drivers/net/mlx5/mlx5_flow_hw.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 33847e2272..6974d4e075 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1472,6 +1472,8 @@ struct mlx5_action_construct_data { * PRM actions. */ uint32_t mask[MLX5_ACT_MAX_MOD_FIELDS]; + /* Copy of action passed to the action template. */ + struct rte_flow_action_modify_field action; } modify_header; struct { bool symmetric_hash_function; /* Symmetric RSS hash */ diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index f337f76450..bc084af87e 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -1112,6 +1112,7 @@ __flow_hw_act_data_hdr_modify_append(struct mlx5_priv *priv, enum rte_flow_action_type type, uint16_t action_src, uint16_t action_dst, + const struct rte_flow_action_modify_field *mf, uint16_t mhdr_cmds_off, uint16_t mhdr_cmds_end, bool shared, @@ -1124,6 +1125,7 @@ __flow_hw_act_data_hdr_modify_append(struct mlx5_priv *priv, act_data = __flow_hw_act_data_alloc(priv, type, action_src, action_dst); if (!act_data) return -1; + act_data->modify_header.action = *mf; act_data->modify_header.mhdr_cmds_off = mhdr_cmds_off; act_data->modify_header.mhdr_cmds_end = mhdr_cmds_end; act_data->modify_header.shared = shared; @@ -1605,7 +1607,7 @@ flow_hw_modify_field_compile(struct rte_eth_dev *dev, if (shared) return 0; ret = __flow_hw_act_data_hdr_modify_append(priv, acts, RTE_FLOW_ACTION_TYPE_MODIFY_FIELD, - src_pos, mhdr->pos, + src_pos, mhdr->pos, conf, cmds_start, cmds_end, shared, field, dcopy, mask); if (ret) From patchwork Wed Jun 26 18:14:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Sosnowski X-Patchwork-Id: 141888 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 920A3454E5; Wed, 26 Jun 2024 20:15:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0943840650; Wed, 26 Jun 2024 20:15:31 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2044.outbound.protection.outlook.com [40.107.243.44]) by mails.dpdk.org (Postfix) with ESMTP id 32EEE40657 for ; Wed, 26 Jun 2024 20:15:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kwcAdCCni5w8IZPvJaMi1x7FgWdN4/Pfbwc2CUYju6KRlZucgmGeUDSU3xDNOUIIysUEXZOz3bbKHgoevK+9jjlOuFgFLqVbtrI1FesYriGDV32nS7pe5jtjBTraVUbi34u2YSeQYdXWU9H+EINEUfV1oTUh/O4+XEv6gJKrZj99XRlYFnCEsRivfiLk7Wj5T9JJ9W1YCKDqZTtLTa0xyC/VgC7pZ0YSrpzJZHX89t4WoHGr1xGrL0vg6X/Kr6x4rFPy+eJCFPG93TrZI3QWYnJhx0QrhTmOQsuo9dGVQ4X2oFxYKw4fC9S1KV4ZXltAjEgl2Ls/i6XyqvoVm/HcyQ== 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=XEXsyfR7IoJsd+fSFxHIoK5/EYa64Ey4BJJYKNphsUo=; b=MSmy5MqXO+Uj2Sppqyo5V9pKaMHOk9l2u8dOnJpiXwA+9tZ/lv7rqXcyjVNq00oHsalqVzqoRVALk6B/QK2flskaDQqO0N6n8D7nqYMMAjr22XQ7XpizDr0k3gRiVm/prFsagBFoFPniNoqOSTRt6W40dJjn6uF52ajo6+duLQQAvhYzX95VGZRgXkvROeJ3vITRLG8q+hsZzhlIxD19FLYFiUrUF1hGwDAW/G+NYMTgvM6YWIC8kVJ/E4XM7SIBD9NZugbojRBpTMSVaHhexlo1RuMVT+xRWszo5VCsRwxp2pa/77BcZGyrbFJjk9Gy5kgMg7Kf1svVOMSOcuvN8w== 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=XEXsyfR7IoJsd+fSFxHIoK5/EYa64Ey4BJJYKNphsUo=; b=QZZMdvStJ2U+fAcQ5/K69Wfr+dCh5BPNiCXm1nPhVcCo69XIcwt6LaTYBfChOMgFi/jhIouj+/DuJqWQYKfkyEFi5dDmZAFeJwPlBB1LvMUEiMEdg0UJGWTXNzGn44EgaiJGhAicOsI9HAX7NeLjbjZ5MpPIY6XBw76fw7s9yoUnNsG+ZXP28Wks1VTWSaJbao2AExAZwiqwOL69N/nbbNTtiCKf+86GU8tYf9z7Xkej6EVRCMjaU2uoh3FTLa5b8u5xPdeqF6RL8hr49lRKC//1Kk0dMUQxpW4HTtxH8h7asqvscjdo4F+tGmexbVhI7F584+iM3DdgzvTorvOolQ== Received: from SA1P222CA0034.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:2d0::7) by CH3PR12MB9080.namprd12.prod.outlook.com (2603:10b6:610:1a7::12) 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:14 +0000 Received: from SA2PEPF00003F61.namprd04.prod.outlook.com (2603:10b6:806:2d0:cafe::ae) by SA1P222CA0034.outlook.office365.com (2603:10b6:806:2d0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.23 via Frontend Transport; Wed, 26 Jun 2024 18:15:14 +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 SA2PEPF00003F61.mail.protection.outlook.com (10.167.248.36) 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:14 +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, 26 Jun 2024 11:15:01 -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:59 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v3 7/8] common/mlx5: add debug mode indicator Date: Wed, 26 Jun 2024 20:14:27 +0200 Message-ID: <20240626181428.1678402-8-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 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: SA2PEPF00003F61:EE_|CH3PR12MB9080:EE_ X-MS-Office365-Filtering-Correlation-Id: eab78524-3d4f-4c10-c811-08dc960becff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230038|82310400024|376012|36860700011|1800799022; X-Microsoft-Antispam-Message-Info: T4LD0yHZPvp+/tT77qyhNEdq/BtzAr5wLZ0hbsT9YDdZm6tF2wULS9Nj8Z5Tzp/fDVYRwO9f7CKUicj4UIZ3cG3DcxKCPq9nEF8DSXWBe9OF+xRFGESBQV/liDAH/lp0BNztb+iCqlw33jD1Ie3dvhzIdvu2RUG5QV/nBl89ebWBa5BuIVHFOZm5GU+VuSqMxpXSFYfooctbEjfMrgR+IQjxIGIyEvJuwauyE/sWSJkyt0lUot77ZY7WQ2sML6jUvoiWsa+dbckWuwKJDtHp6OkIZBs2CVOSc0d3+XK6YfIwtStGPtP4iSUFqzAA8VHjQdrp+rOiMruMJ0fNc+lEfYdFsF6zjZZ0ysnWpxUF2YQCUxdidyhRn+Kg83GUBEJD0KDErLD5/PWfm4+BgBiTCyiCDzASGKvQf7OyHwJdQITka2GeIhrumngzlGlIjmhRlZKclDVybQysC/8pOxSYxVmLJfXxTMXpz2h0t0BssL6gbXwjVrTFo0Vv8RznDgILSZMHwIbIyL34mED7NEr4BCCeNVpv39SbjxYGBqXR+gTAai/HDYS/9sFbTFQr4xzFjXC0E/7X3Fpjsn/PBCTEqbZCgMYurPBaTkA9PK7VRoHLhMqtEPZ1O1blPRr1Vr1g1yrwf5URVGFtHHT2SYAkRl0JfCxf/NpwhYmbM82UL8O9DiKfwL0z+pahBWSNCDhgSIsfFXLKUEZShNrKkxCRnVqFwLgJx4guKS9sYs0sGX6mY6I1nNFKakTIVmoO8sJbpsJJv1avvotwqlEYAjPz2U0ymVQiJKae134ITkGGkrPxudDW34TltW7+maKrXZVedHmGTurWRxXQUe43yWWLe46d8jxnTo8rEqm+Nyv15xgjJHVWRIOIqXvK1jzyFNDOuiP7jb9sjNblrlKGNEQp7xGbvNMkeXRUCZa/Gy7QPwXD8w4Tn0MJrOC9fxa3S6f1RrwcoXL7Gp/b1T9f8OnacBH5hoIolAUBjF9LGAt++FFWWlialiQw8S/wZCSS1CuE2Hp7A/OSoLBZTPwJJkaknbNze9vRwjGFrstFXqGF1YdcGVGZLsyu3OmOlw0XZO4INM3/f0de31tCMuYLr0xfhmbmaH7eIgIcojweyF1bpYSkio8dvsMTwkxw0USGeRbE5YVi0hnljE4xTaJ6BavNrndMHB3FWCeZAPu4SI50Cit1O9hKRnnK/8xuuSh1VUwPBDrL9P7KN3Ue2ysmoImrH1hYjHi14fuUUZdLORMmHz5za7N44/pRilHddZbvw6hxAroiCutSTdP59tDQAvRt+6opDSZV+cy7S49qlyIxtFQdvBMC4pYsnDy2GwmNywe8UnhN2BAuQ+K3Gz2DMpSW7yx8CVTjxPmEvsY8HpXJ/03ig41gndslDgIMkaNrUSCAB7tOLxaOZaE3iMqfVMxKz6CEJSRmJzVX9boUwvrMEFmq0Q1CJHEghA4yeoOBakpp X-Forefront-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:(13230038)(82310400024)(376012)(36860700011)(1800799022); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 18:15:14.3666 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eab78524-3d4f-4c10-c811-08dc960becff 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: SA2PEPF00003F61.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9080 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 Add mlx5_fp_debug_enabled() function which: - returns true if RTE_LIBRTE_MLX5_DEBUG is defined, - returns false otherwise. This allows for conditional execution of code meant to be executed only when mlx5 debug mode is enabled, without adding conditional compilation guards inside source code. When mlx5 debug mode is disabled, any code running if mlx5_fp_debug_enabled() returns true will be removed by optimizing compiler due to dead code elimination. Signed-off-by: Dariusz Sosnowski Acked-by: Ori Kam --- drivers/common/mlx5/mlx5_common.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 14c70edbef..1abd1e8239 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -109,6 +109,19 @@ pmd_drv_log_basename(const char *s) #endif /* RTE_LIBRTE_MLX5_DEBUG */ +/** + * Returns true if debug mode is enabled for fast path operations. + */ +static inline bool +mlx5_fp_debug_enabled(void) +{ +#ifdef RTE_LIBRTE_MLX5_DEBUG + return true; +#else + return false; +#endif +} + /* Allocate a buffer on the stack and fill it with a printf format string. */ #define MKSTR(name, ...) \ int mkstr_size_##name = snprintf(NULL, 0, "" __VA_ARGS__); \ From patchwork Wed Jun 26 18:14:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Sosnowski X-Patchwork-Id: 141890 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7B6EC454E5; Wed, 26 Jun 2024 20:16:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6A7804067E; Wed, 26 Jun 2024 20:15:33 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2044.outbound.protection.outlook.com [40.107.101.44]) by mails.dpdk.org (Postfix) with ESMTP id 404EA40665 for ; Wed, 26 Jun 2024 20:15:28 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bNPknVy5ZZjpiA23FmpGpgOzch/iZuoC9ImUY839Nf0FsNME2Srz8zoTDBEtGFxOoPDv44Cd1lZpzvpLrdBNbVRhALybiQeBczsWDmxYK8CHUu33vu8RLrc6Ubyd0oSZrxNWb4j0Fq3ulcEqMdVWq760sVEJGSOP0L1mUQl+qLf/Utcs5JGyGON6A9ruoUGs6aJTgWokYkESn/JH0YmShgnsnlz8wWIgMITMmLgeCnq6ZJntUhoudAkfVps6GsoXR1OSmLsUv6+b4ISkepzD2V/h18zxCjSd6REiMB+GsyNXxPum4QBOfjYSVT/FkQhmh7nTxzR+HtFi2hdtAhG2nw== 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=9IJ0Cb1uZu+D0G9BC2+PM32Ma1QwUKQL2/gPAPAyvNk=; b=NRUawl1RL3BID4VAWrdSCLKTzc7eKeRe5LWPT5AtuFYiUYxprMXLe7+7B7FeJdU+0tOcwYLj7u4RWYTBhoMBWjFcVC5niW/a50n8NT4Vl8/+mRXSVz/6H113hRX8isdwJkaoqeq439FMjj+IRTCjfXl1SowPVk8n0lwqvT7gz5iNRCvTxff8EbK+fI3RZU/hXFlpFhBwxL+29Dg79HvjL6e3+eDafjO4vGAyromGmG51QhzVptbzRkSad1IuXy6dMEUCmaXao9SN7r9NssiaZOIVAaQ2WaNt2WTgbq7uJsqdJl0GuiYHjxwssRcBLFKEIfDmB8B3tz+4zZY7eVaI+Q== 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=9IJ0Cb1uZu+D0G9BC2+PM32Ma1QwUKQL2/gPAPAyvNk=; b=hkiyh88Lphd+f+kjflrNiwCTmQdVP902SyC2U3VHTlo+hMYB4S/dlKlrBijkE1F7dq5jcy14PclHpqB8Y6UaOYi0mjeQoT0PBvUFodrS0eMHkvlBNup4q4SaDXpiP0R9f8Le7xzECqgrywNvnede8fIPILKxiHgOJcErv0DKihMqUcchYU9jdBCCy6Du03AdBu88bUDaABiouSi0B3NeTtrUzsjYWC75n4AsFrPH/tZTOGaUMgQng0mW1tw0uCNIoVxkHvh/2gsBxJ95fYIQUGACznOnFZXN5YATw1ls6e3SljikpyQQTFeG7p5240Kv6PZYdraYnCeTSXIYD+hbmw== Received: from MW4PR04CA0178.namprd04.prod.outlook.com (2603:10b6:303:85::33) by BL1PR12MB5802.namprd12.prod.outlook.com (2603:10b6:208:392::16) 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:20 +0000 Received: from SJ5PEPF000001CD.namprd05.prod.outlook.com (2603:10b6:303:85:cafe::58) by MW4PR04CA0178.outlook.office365.com (2603:10b6:303:85::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.38 via Frontend Transport; Wed, 26 Jun 2024 18:15:19 +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:19 +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:15:03 -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:15:01 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v3 8/8] net/mlx5: add async flow operation validation Date: Wed, 26 Jun 2024 20:14:28 +0200 Message-ID: <20240626181428.1678402-9-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 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_|BL1PR12MB5802:EE_ X-MS-Office365-Filtering-Correlation-Id: 11064d71-948f-4bdd-348d-08dc960bf033 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: 3H8v4Q34BZWJ+3LcqhYKgDm8755cqyI6lrbpueBhG09yIO1HyPq5tHtifRUu3kqE1HNpGWJS0tV0buinH4+lcVWuSY6BtBwqE/iJgcuwU8wF/5bK0/it73ktqj1ThmBfn6rbUM9yrLXbpBZ8Lf+0VMR5wP2x+ADO147/8pSNdckStuHjz23FIiT8+TIPD44gGJmHq2vAOBNaclTrcwt6RmTtjxny18xAJ8XryXoKEN7NTbOKWI2mKBIa+oFEBTd923pvqLkZcThx7e0lo2J34w40ROdVS7azOSnVud3KpreBJYj5bKTZUnlOjb5hWSoZSc1j5Sa+MJEKXAML1tB5e39bXsWI55YjZ1Z8AFOQ5zRnj/5siTcXpQDNqqCa4TJCrB0wUnr+XCchLbbW5Hc7xxz1eSqrQkqNmLC4TOB8TfIW0JtH7tN1UKC/hsoqkJo59zsCiLV4wUuecHhG4mue2jOMuSm1obIhXd1ZHtaYPofQ/56ST2zzpjjJlf5/4PwbSxCwyENWNnSAx8of2Ddw8zyVQDhb2IIFQ0bjCMl1sZCi25l84DjcLC+B0nLVeYivz9y/1Cal/DCE1QI4NcwjdMrjjIhcEwAfcYZNg6YIZxEMOB2Q5Ek9J+7mYkdhLTIl8m3JCSnRFOabn3fdszx29MRWYGHI5NKjSdGX1wKoC//tBdPwTfgbDxjGRf1Pp+X0NXaNldfP8aiEiTRTOE5uNH6YunrJZBa/LdVhIeJVgnsxFw1aLxu2D5qxWw2iP0VYERCewzN/yAC2gqaZINnAF3Gbyh93AAyKKbAeQtFAGWN2gr4hzKAV4JCa/1lNSl9zlHzwf/IDTMk2Zv0EiRtvAZEgha8W1ENfTEZtvI3tcD7g4jgszgpaGaHIR/4r016Ayps8ImjVIq4N1hL5bS0L76I8qIKsoc/h9VRklwHfOGPSjKVkPyKq8cUxcHknqx5lcgpj7EVRfrqW4maQljQa7C53WPmcCXUl0sUv63s9UlbJSd5X1z0NQhLzKdy2KQiHK2Snnd+YijYzi7WZznb2ZZOG2hHT3kSAz/0n/aH/B90zKTpbTBWEWdDgtXGDcvlfIBrFUYgyrXSMWnxPtHl47G6W2qI6BDjYJxghaCCS4A87VbU7UJyUEaYV3afFQUKhARILmBiLML7XQPmd5FZg2WQtOJpOwcVqPtRpZJUe0VCH8An4n/0YPfSUeNEBsehNdRmfPNWPOXe9ALokAFyDp9VJ964g3iqZIZ5ttZSqb1E2aWY7LNjm7D9j1TpqVHPRY+8PQmt1tT9Qc2zqdZnVN/jaz3je6vduggMZ9PW7gadsCayaSJchtGiYSHFbdeyWPovdTyz+vdmpNeFLABOmKCXBnW8IAqEDLdDY8L1cfN191dJrushm/FjlL7HlvhLVjr4NVVZyXwI5YVW1VQOYm1LBAkf+bOjqEgcVEF/dDIWc+Ihhd/+wZromx6+Ewaof 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:(13230038)(1800799022)(82310400024)(36860700011)(376012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 18:15:19.8305 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 11064d71-948f-4bdd-348d-08dc960bf033 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: BL1PR12MB5802 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 This patch adds validation to implementations of the following API functions: - rte_flow_async_create() - rte_flow_async_create_by_index() - rte_flow_async_update() - rte_flow_async_destroy() These validations are enabled if and only if RTE_LIBRTE_MLX5_DEBUG macro is defined. Signed-off-by: Dariusz Sosnowski Acked-by: Ori Kam --- doc/guides/rel_notes/release_24_07.rst | 1 + drivers/net/mlx5/mlx5_flow_hw.c | 491 ++++++++++++++++++++++++- 2 files changed, 488 insertions(+), 4 deletions(-) diff --git a/doc/guides/rel_notes/release_24_07.rst b/doc/guides/rel_notes/release_24_07.rst index 7c88de381b..cccb3ca834 100644 --- a/doc/guides/rel_notes/release_24_07.rst +++ b/doc/guides/rel_notes/release_24_07.rst @@ -97,6 +97,7 @@ New Features * Added match with Tx queue. * Added match with external Tx queue. * Added match with E-Switch manager. + * Added flow item and actions validation to async flow API. * **Updated TAP driver.** diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index bc084af87e..f389817858 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -332,6 +332,32 @@ mlx5_flow_ct_init(struct rte_eth_dev *dev, static __rte_always_inline uint32_t flow_hw_tx_tag_regc_mask(struct rte_eth_dev *dev); static __rte_always_inline uint32_t flow_hw_tx_tag_regc_value(struct rte_eth_dev *dev); +static int flow_hw_async_create_validate(struct rte_eth_dev *dev, + const uint32_t queue, + const struct rte_flow_template_table *table, + const struct rte_flow_item items[], + const uint8_t pattern_template_index, + const struct rte_flow_action actions[], + const uint8_t action_template_index, + struct rte_flow_error *error); +static int flow_hw_async_create_by_index_validate(struct rte_eth_dev *dev, + const uint32_t queue, + const struct rte_flow_template_table *table, + const uint32_t rule_index, + const struct rte_flow_action actions[], + const uint8_t action_template_index, + struct rte_flow_error *error); +static int flow_hw_async_update_validate(struct rte_eth_dev *dev, + const uint32_t queue, + const struct rte_flow_hw *flow, + const struct rte_flow_action actions[], + const uint8_t action_template_index, + struct rte_flow_error *error); +static int flow_hw_async_destroy_validate(struct rte_eth_dev *dev, + const uint32_t queue, + const struct rte_flow_hw *flow, + struct rte_flow_error *error); + const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops; /* DR action flags with different table. */ @@ -3860,6 +3886,11 @@ flow_hw_async_flow_create(struct rte_eth_dev *dev, uint32_t res_idx = 0; int ret; + if (mlx5_fp_debug_enabled()) { + if (flow_hw_async_create_validate(dev, queue, table, items, pattern_template_index, + actions, action_template_index, error)) + return NULL; + } flow = mlx5_ipool_malloc(table->flow, &flow_idx); if (!flow) goto error; @@ -3999,10 +4030,10 @@ flow_hw_async_flow_create_by_index(struct rte_eth_dev *dev, uint32_t res_idx = 0; int ret; - if (unlikely(rule_index >= table->cfg.attr.nb_flows)) { - rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, - "Flow rule index exceeds table size"); - return NULL; + if (mlx5_fp_debug_enabled()) { + if (flow_hw_async_create_by_index_validate(dev, queue, table, rule_index, + actions, action_template_index, error)) + return NULL; } flow = mlx5_ipool_malloc(table->flow, &flow_idx); if (!flow) @@ -4135,6 +4166,11 @@ flow_hw_async_flow_update(struct rte_eth_dev *dev, uint32_t res_idx = 0; int ret; + if (mlx5_fp_debug_enabled()) { + if (flow_hw_async_update_validate(dev, queue, of, actions, action_template_index, + error)) + return -rte_errno; + } aux = mlx5_flow_hw_aux(dev->data->port_id, of); nf = &aux->upd_flow; memset(nf, 0, sizeof(struct rte_flow_hw)); @@ -4243,6 +4279,10 @@ flow_hw_async_flow_destroy(struct rte_eth_dev *dev, &fh->table->cfg.attr); int ret; + if (mlx5_fp_debug_enabled()) { + if (flow_hw_async_destroy_validate(dev, queue, fh, error)) + return -rte_errno; + } fh->operation_type = !resizable ? MLX5_FLOW_HW_FLOW_OP_TYPE_DESTROY : MLX5_FLOW_HW_FLOW_OP_TYPE_RSZ_TBL_DESTROY; @@ -16152,6 +16192,449 @@ mlx5_reformat_action_destroy(struct rte_eth_dev *dev, return 0; } +static bool +flow_hw_is_item_masked(const struct rte_flow_item *item) +{ + const uint8_t *byte; + int size; + int i; + + if (item->mask == NULL) + return false; + + switch ((int)item->type) { + case MLX5_RTE_FLOW_ITEM_TYPE_TAG: + size = sizeof(struct rte_flow_item_tag); + break; + case MLX5_RTE_FLOW_ITEM_TYPE_SQ: + size = sizeof(struct mlx5_rte_flow_item_sq); + break; + default: + size = rte_flow_conv(RTE_FLOW_CONV_OP_ITEM_MASK, NULL, 0, item, NULL); + /* + * Pattern template items are passed to this function. + * These items were already validated, so error is not expected. + * Also, if mask is NULL, then spec size is bigger than 0 always. + */ + MLX5_ASSERT(size > 0); + } + + byte = (const uint8_t *)item->mask; + for (i = 0; i < size; ++i) + if (byte[i]) + return true; + + return false; +} + +static int +flow_hw_validate_rule_pattern(struct rte_eth_dev *dev, + const struct rte_flow_template_table *table, + const uint8_t pattern_template_idx, + const struct rte_flow_item items[], + struct rte_flow_error *error) +{ + const struct rte_flow_pattern_template *pt; + const struct rte_flow_item *pt_item; + + if (pattern_template_idx >= table->nb_item_templates) + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "Pattern template index out of range"); + + pt = table->its[pattern_template_idx]; + pt_item = pt->items; + + /* If any item was prepended, skip it. */ + if (pt->implicit_port || pt->implicit_tag) + pt_item++; + + for (; pt_item->type != RTE_FLOW_ITEM_TYPE_END; pt_item++, items++) { + if (pt_item->type != items->type) + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, + items, "Item type does not match the template"); + + /* + * Assumptions: + * - Currently mlx5dr layer contains info on which fields in masks are supported. + * - This info is not exposed to PMD directly. + * - Because of that, it is assumed that since pattern template is correct, + * then, items' masks in pattern template have nonzero values only in + * supported fields. + * This is known, because a temporary mlx5dr matcher is created during pattern + * template creation to validate the template. + * - As a result, it is safe to look for nonzero bytes in mask to determine if + * item spec is needed in a flow rule. + */ + if (!flow_hw_is_item_masked(pt_item)) + continue; + + if (items->spec == NULL) + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_SPEC, + items, "Item spec is required"); + + switch (items->type) { + const struct rte_flow_item_ethdev *ethdev; + const struct rte_flow_item_tx_queue *tx_queue; + struct mlx5_txq_ctrl *txq; + + case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT: + ethdev = items->spec; + if (flow_hw_validate_target_port_id(dev, ethdev->port_id)) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, items, + "Invalid port"); + } + break; + case RTE_FLOW_ITEM_TYPE_TX_QUEUE: + tx_queue = items->spec; + if (mlx5_is_external_txq(dev, tx_queue->tx_queue)) + continue; + txq = mlx5_txq_get(dev, tx_queue->tx_queue); + if (!txq) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, items, + "Invalid Tx queue"); + mlx5_txq_release(dev, tx_queue->tx_queue); + default: + break; + } + } + + return 0; +} + +static bool +flow_hw_valid_indirect_action_type(const struct rte_flow_action *user_action, + const enum rte_flow_action_type expected_type) +{ + uint32_t user_indirect_type = MLX5_INDIRECT_ACTION_TYPE_GET(user_action->conf); + uint32_t expected_indirect_type; + + switch ((int)expected_type) { + case RTE_FLOW_ACTION_TYPE_RSS: + case MLX5_RTE_FLOW_ACTION_TYPE_RSS: + expected_indirect_type = MLX5_INDIRECT_ACTION_TYPE_RSS; + break; + case RTE_FLOW_ACTION_TYPE_COUNT: + case MLX5_RTE_FLOW_ACTION_TYPE_COUNT: + expected_indirect_type = MLX5_INDIRECT_ACTION_TYPE_COUNT; + break; + case RTE_FLOW_ACTION_TYPE_AGE: + expected_indirect_type = MLX5_INDIRECT_ACTION_TYPE_AGE; + break; + case RTE_FLOW_ACTION_TYPE_CONNTRACK: + expected_indirect_type = MLX5_INDIRECT_ACTION_TYPE_CT; + break; + case RTE_FLOW_ACTION_TYPE_METER_MARK: + case MLX5_RTE_FLOW_ACTION_TYPE_METER_MARK: + expected_indirect_type = MLX5_INDIRECT_ACTION_TYPE_METER_MARK; + break; + case RTE_FLOW_ACTION_TYPE_QUOTA: + expected_indirect_type = MLX5_INDIRECT_ACTION_TYPE_QUOTA; + break; + default: + return false; + } + + return user_indirect_type == expected_indirect_type; +} + +static int +flow_hw_validate_rule_actions(struct rte_eth_dev *dev, + const struct rte_flow_template_table *table, + const uint8_t actions_template_idx, + const struct rte_flow_action actions[], + struct rte_flow_error *error) +{ + const struct rte_flow_actions_template *at; + const struct mlx5_hw_actions *hw_acts; + const struct mlx5_action_construct_data *act_data; + unsigned int idx; + + if (actions_template_idx >= table->nb_action_templates) + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "Actions template index out of range"); + + at = table->ats[actions_template_idx].action_template; + hw_acts = &table->ats[actions_template_idx].acts; + + for (idx = 0; actions[idx].type != RTE_FLOW_ACTION_TYPE_END; ++idx) { + const struct rte_flow_action *user_action = &actions[idx]; + const struct rte_flow_action *tmpl_action = &at->orig_actions[idx]; + + if (user_action->type != tmpl_action->type) + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, + user_action, + "Action type does not match type specified in " + "actions template"); + } + + /* + * Only go through unmasked actions and check if configuration is provided. + * Configuration of masked actions is ignored. + */ + LIST_FOREACH(act_data, &hw_acts->act_list, next) { + const struct rte_flow_action *user_action; + + user_action = &actions[act_data->action_src]; + + /* Skip actions which do not require conf. */ + switch ((int)user_action->type) { + case RTE_FLOW_ACTION_TYPE_COUNT: + case MLX5_RTE_FLOW_ACTION_TYPE_COUNT: + case MLX5_RTE_FLOW_ACTION_TYPE_METER_MARK: + continue; + default: + break; + } + + if (user_action->conf == NULL) + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, + user_action, + "Action requires configuration"); + + switch ((int)user_action->type) { + enum rte_flow_action_type expected_type; + const struct rte_flow_action_ethdev *ethdev; + const struct rte_flow_action_modify_field *mf; + + case RTE_FLOW_ACTION_TYPE_INDIRECT: + expected_type = act_data->indirect.expected_type; + if (!flow_hw_valid_indirect_action_type(user_action, expected_type)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + user_action, + "Indirect action type does not match " + "the type specified in the mask"); + break; + case RTE_FLOW_ACTION_TYPE_QUEUE: + if (mlx5_flow_validate_target_queue(dev, user_action, error)) + return -rte_errno; + break; + case RTE_FLOW_ACTION_TYPE_RSS: + if (mlx5_validate_action_rss(dev, user_action, error)) + return -rte_errno; + break; + case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD: + /* TODO: Compare other fields if needed. */ + mf = user_action->conf; + if (mf->operation != act_data->modify_header.action.operation || + mf->src.field != act_data->modify_header.action.src.field || + mf->dst.field != act_data->modify_header.action.dst.field || + mf->width != act_data->modify_header.action.width) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + user_action, + "Modify field configuration does not " + "match configuration from actions " + "template"); + break; + case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT: + ethdev = user_action->conf; + if (flow_hw_validate_target_port_id(dev, ethdev->port_id)) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + user_action, "Invalid port"); + } + break; + default: + break; + } + } + + return 0; +} + +static int +flow_hw_async_op_validate(struct rte_eth_dev *dev, + const uint32_t queue, + const struct rte_flow_template_table *table, + struct rte_flow_error *error) +{ + struct mlx5_priv *priv = dev->data->dev_private; + + MLX5_ASSERT(table != NULL); + + if (table->cfg.external && queue >= priv->hw_attr->nb_queue) + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "Incorrect queue"); + + return 0; +} + +/** + * Validate user input for rte_flow_async_create() implementation. + * + * If RTE_LIBRTE_MLX5_DEBUG macro is not defined, this function is a no-op. + * + * @param[in] dev + * Pointer to the rte_eth_dev structure. + * @param[in] queue + * The queue to create the flow. + * @param[in] table + * Pointer to template table. + * @param[in] items + * Items with flow spec value. + * @param[in] pattern_template_index + * The item pattern flow follows from the table. + * @param[in] actions + * Action with flow spec value. + * @param[in] action_template_index + * The action pattern flow follows from the table. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 if user input is valid. + * Negative errno otherwise, rte_errno and error struct is populated. + */ +static int +flow_hw_async_create_validate(struct rte_eth_dev *dev, + const uint32_t queue, + const struct rte_flow_template_table *table, + const struct rte_flow_item items[], + const uint8_t pattern_template_index, + const struct rte_flow_action actions[], + const uint8_t action_template_index, + struct rte_flow_error *error) +{ + if (flow_hw_async_op_validate(dev, queue, table, error)) + return -rte_errno; + + if (table->cfg.attr.insertion_type != RTE_FLOW_TABLE_INSERTION_TYPE_PATTERN) + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "Only pattern insertion is allowed on this table"); + + if (flow_hw_validate_rule_pattern(dev, table, pattern_template_index, items, error)) + return -rte_errno; + + if (flow_hw_validate_rule_actions(dev, table, action_template_index, actions, error)) + return -rte_errno; + + return 0; +} + +/** + * Validate user input for rte_flow_async_create_by_index() implementation. + * + * If RTE_LIBRTE_MLX5_DEBUG macro is not defined, this function is a no-op. + * + * @param[in] dev + * Pointer to the rte_eth_dev structure. + * @param[in] queue + * The queue to create the flow. + * @param[in] table + * Pointer to template table. + * @param[in] rule_index + * Rule index in the table. + * Inserting a rule to already occupied index results in undefined behavior. + * @param[in] actions + * Action with flow spec value. + * @param[in] action_template_index + * The action pattern flow follows from the table. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 if user input is valid. + * Negative errno otherwise, rte_errno and error struct is set. + */ +static int +flow_hw_async_create_by_index_validate(struct rte_eth_dev *dev, + const uint32_t queue, + const struct rte_flow_template_table *table, + const uint32_t rule_index, + const struct rte_flow_action actions[], + const uint8_t action_template_index, + struct rte_flow_error *error) +{ + if (flow_hw_async_op_validate(dev, queue, table, error)) + return -rte_errno; + + if (table->cfg.attr.insertion_type != RTE_FLOW_TABLE_INSERTION_TYPE_INDEX) + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "Only index insertion is allowed on this table"); + + if (rule_index >= table->cfg.attr.nb_flows) + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "Flow rule index exceeds table size"); + + if (flow_hw_validate_rule_actions(dev, table, action_template_index, actions, error)) + return -rte_errno; + + return 0; +} + + +/** + * Validate user input for rte_flow_async_update() implementation. + * + * If RTE_LIBRTE_MLX5_DEBUG macro is not defined, this function is a no-op. + * + * @param[in] dev + * Pointer to the rte_eth_dev structure. + * @param[in] queue + * The queue to create the flow. + * @param[in] flow + * Flow rule to be updated. + * @param[in] actions + * Action with flow spec value. + * @param[in] action_template_index + * The action pattern flow follows from the table. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 if user input is valid. + * Negative errno otherwise, rte_errno and error struct is set. + */ +static int +flow_hw_async_update_validate(struct rte_eth_dev *dev, + const uint32_t queue, + const struct rte_flow_hw *flow, + const struct rte_flow_action actions[], + const uint8_t action_template_index, + struct rte_flow_error *error) +{ + if (flow_hw_async_op_validate(dev, queue, flow->table, error)) + return -rte_errno; + + if (flow_hw_validate_rule_actions(dev, flow->table, action_template_index, actions, error)) + return -rte_errno; + + return 0; +} + +/** + * Validate user input for rte_flow_async_destroy() implementation. + * + * If RTE_LIBRTE_MLX5_DEBUG macro is not defined, this function is a no-op. + * + * @param[in] dev + * Pointer to the rte_eth_dev structure. + * @param[in] queue + * The queue to create the flow. + * @param[in] flow + * Flow rule to be destroyed. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 if user input is valid. + * Negative errno otherwise, rte_errno and error struct is set. + */ +static int +flow_hw_async_destroy_validate(struct rte_eth_dev *dev, + const uint32_t queue, + const struct rte_flow_hw *flow, + struct rte_flow_error *error) +{ + if (flow_hw_async_op_validate(dev, queue, flow->table, error)) + return -rte_errno; + + return 0; +} + static struct rte_flow_fp_ops mlx5_flow_hw_fp_ops = { .async_create = flow_hw_async_flow_create, .async_create_by_index = flow_hw_async_flow_create_by_index,