From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0440741C37; Wed, 8 Feb 2023 04:07:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E8AED42B7E; Wed, 8 Feb 2023 04:07:03 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2069.outbound.protection.outlook.com [40.107.220.69]) by mails.dpdk.org (Postfix) with ESMTP id 76F0340DDB for ; Wed, 8 Feb 2023 04:07:02 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BWGjAyHEdwgoJVqZCm0ohmI0MC/7PZ2pbZknucwXiHtUkQPQum03CN19veE3dF9sqKGD04i4Ya2dCnE2AP9WYYc8xwRP10tVHn80c1UltkuRzyGsWosHkzb08Rr4r19o7QbW1bepMC5pcUbb9XJBELojcE7Bg3sN9vaEAEZNRTq3PTLe3fZZclpTuPMuFq+sPqTuiVz6GZUzDKmlN3zEX0aBGOZq6+Igt+BFK7iGqOiTnizpcJnhgbyZR50yEPU4BX5hvfgNXgyKrPEarmc/oZ/vo3xprhCFGkXjk5r+f67FGRktAv2NprZn5EvWrgLG+A7eEbmKvomZjvbnwh7+kg== 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=jF6WaOix9N7nYRi+o1Ty2a8cniMJH4E3pyfYJa0d5Dc=; b=A2EakWR2tqzXWWlqNRHd1ssa6w/lcetJEVn31vCki0yPXPyeYdmoLHTBm3ssObRcvAX0XDPZzR76OE/Q4UCNnXKsveks/XMKToLSF14EzQF9x3Y3A+CjQPkknZ2Gm8nnt9xJOgy+6ZAIEKmBJ8QoIzpFv81Let5ERk/4X7Flg0FlX0FYMkDkulJ4q6NHdgKH1Feq72RIT6jACvdOsBuG84867S1VpT/pSywSCYiVCmb+YBb6iuAOFxxmtXiSoEtadPNCy2OuUCmQpiMLYu7C8rIi4dgO2Ym5mfDJ+2Sf2In+CPuHT04XiO84iHLXXV2hjAs/Qa1tcMjVDIJqYWVuLg== 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 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=jF6WaOix9N7nYRi+o1Ty2a8cniMJH4E3pyfYJa0d5Dc=; b=dPB6GHTyN2BhscsUg9fhlCBTFAvKjT9OxCEAfDqnse94O6nO429jD3K2uMYyDtQtaAFSiynaP+AFO6/gB15g3SvSloIEWCgjo13rtvP/NVX5KY9mEj7/4HLSdyR/JQ2CW/4IjfS4/0CTmIEUEnypykbJD5uJFkRb1Vw5eR3zDqY7OX+2Uv27fDbrPeH791f9MHBm0Yxx0AG37irPTrw5ZB2l1bciuLm35bJs2IcihIulo6DgJl3Yvwei4eAnb3RZ4own/jC0aReoDx5nENblxyCX7uspmqmpEbq5otwj/jBhCYVkP7jUwyCdu78ddSWd2p4CMLdSdygGBCmH3IE8aA== Received: from MW4P222CA0024.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::29) by MN2PR12MB4408.namprd12.prod.outlook.com (2603:10b6:208:26c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Wed, 8 Feb 2023 03:06:57 +0000 Received: from CO1NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:303:114:cafe::c6) by MW4P222CA0024.outlook.office365.com (2603:10b6:303:114::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36 via Frontend Transport; Wed, 8 Feb 2023 03:06:57 +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 CO1NAM11FT049.mail.protection.outlook.com (10.13.175.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17 via Frontend Transport; Wed, 8 Feb 2023 03:06:56 +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.986.36; Tue, 7 Feb 2023 19:06:48 -0800 Received: from pegasus01.mtr.labs.mlnx (10.126.230.37) 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.986.36; Tue, 7 Feb 2023 19:06:46 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH v4 1/4] ethdev: add template table insertion type Date: Wed, 8 Feb 2023 05:06:21 +0200 Message-ID: <20230208030624.78465-2-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230208030624.78465-1-akozyrev@nvidia.com> References: <20230208024755.72743-1-akozyrev@nvidia.com> <20230208030624.78465-1-akozyrev@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT049:EE_|MN2PR12MB4408:EE_ X-MS-Office365-Filtering-Correlation-Id: a6fd265a-9b7b-43fd-eb9d-08db098189ce X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jnSLt/KnLmwlKTo1G63vXu3uvOtmFVqlTWW9TURikVWaOhZxKcxAzTUIZN4PejJr+/aZkbGYV8Ub1x6SBqVKhrYbU/EJsGNnu33bj4ZPlAqD9V4+q0y464LRB8UriN9vyN9mV4fJ6mMhjbaqGgSiI3k58UQthnHlfQn0/D6gD5elop7D3P6R3whhX1qm9sy0E6R/7y+zvLS0HW/raxjjWL1/irMYoYw8YCUxmi8WullS5CSkf6tb56pD6vNfNiZKlwvRQ1Dcn9HZHVuepGZQWKQ+VDfQckkYF86IdSFkF7bUMDbQrvCKLxCQHjSZShjGHNgYiTfrHET8t1mdSV2G4hFc6IzXTh4Qxct8lSEweMCzCzwB6y0w7A1NGhQa1+qd+9+yRqoaASrMLI04bxlLcFJ8bBonv8WzS4wsRDVN+p47W/Nx2VqLpZfxJp6hIYPOkiZH0+8RbTUR4exqzlF5zjfiBOjj0aAdhODM/ATJKKWTNyQxzE77iFFXAC14/9yweXRDjnO+JMcTf/+nzRLOJ0ZQrejw9Sdbu2fHItdbhHKaANLLjH3NXNZFKlvMYyhtu5/CIHPgcZNrHraTG4CZwbc9sR8GvwEZ3R7P8edUXkntugaiBxubsF4KjmQk0May4Z1M7kKioqEumGC/WDdA2zJoPSVQNy1jmldOnp7UKZtueaXyA3DqZlOnhQ5+nvit0cZqCxRToMif/FY72okdyw== 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:(13230025)(4636009)(39860400002)(376002)(396003)(136003)(346002)(451199018)(40470700004)(46966006)(36840700001)(83380400001)(316002)(36756003)(7636003)(82740400003)(54906003)(47076005)(86362001)(40460700003)(41300700001)(2906002)(356005)(426003)(1076003)(40480700001)(107886003)(6666004)(186003)(26005)(16526019)(36860700001)(5660300002)(8936002)(336012)(82310400005)(4326008)(6916009)(8676002)(478600001)(2616005)(70586007)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2023 03:06:56.9590 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a6fd265a-9b7b-43fd-eb9d-08db098189ce 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: CO1NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4408 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 Allow user to specify insertion type used in template tables. The insertion type is responsible for choosing the appropriate key value used to map inserted flow rules into a template table. Flow rules can be inserted by calculating the hash value for the pattern or inserted by index via the new create_by_index() API. The idea of the index-based insertion is to avoid additional matches and simply execute predefined actions after jumping to the index. This is how the regular pattern-based table works: 1. The hash is calculated on a 5-tuple of a packet. 2. The corresponding entry in the table is checked for collisions. 3. Actions are executed once the final entry is found. The index-based table skips any lookups for the packet: 1. The index value is taken from a specified field. 2. Actions are executed at the specified index in the table. The insertion into an already occupied index results in an error. The old rule must be destroyed first. An index cannot be bigger than the size of the table, otherwise, the rule is rejected as well. Signed-off-by: Alexander Kozyrev --- doc/guides/prog_guide/rte_flow.rst | 20 ++++++++ doc/guides/rel_notes/release_23_03.rst | 7 +++ lib/ethdev/rte_flow.c | 24 ++++++++++ lib/ethdev/rte_flow.h | 65 ++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 11 +++++ lib/ethdev/version.map | 3 ++ 6 files changed, 130 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 3e6242803d..fbed7da9d8 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -3669,6 +3669,26 @@ Enqueueing a flow rule creation operation is similar to simple creation. A valid handle in case of success is returned. It must be destroyed later by calling ``rte_flow_async_destroy()`` even if the rule is rejected by HW. +Enqueue creation by index operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Enqueueing a flow rule creation operation to insert a rule at a table index. + +.. code-block:: c + + struct rte_flow * + rte_flow_async_create_by_index(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct rte_flow_template_table *template_table, + uint32_t rule_index, + const struct rte_flow_action actions[], + uint8_t actions_template_index, + void *user_data, + struct rte_flow_error *error); + +A valid handle in case of success is returned. It must be destroyed later +by calling ``rte_flow_async_destroy()`` even if the rule is rejected by HW. + Enqueue destruction operation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index c15f6fbb9f..d3bddfb0f5 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -69,6 +69,13 @@ New Features ``rte_event_dev_config::nb_single_link_event_port_queues`` parameter required for eth_rx, eth_tx, crypto and timer eventdev adapters. +* **Added index-based rules insertion in flow API.** + + * Added ``rte_flow_table_insertion_type`` to allow the creation + of index-based template tables in addition to pattern-based tables. + * Introduced new function ``rte_flow_async_create_by_index()`` + to insert rules by index into index-based template tables. + Removed Items ------------- diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 7d0c24366c..013eb355ca 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -1765,6 +1765,30 @@ rte_flow_async_create(uint16_t port_id, return flow; } +struct rte_flow * +rte_flow_async_create_by_index(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct rte_flow_template_table *template_table, + uint32_t rule_index, + const struct rte_flow_action actions[], + uint8_t actions_template_index, + void *user_data, + struct rte_flow_error *error) +{ + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + const struct rte_flow_ops *ops = rte_flow_ops_get(port_id, error); + struct rte_flow *flow; + + flow = ops->async_create_by_index(dev, queue_id, + op_attr, template_table, rule_index, + actions, actions_template_index, + user_data, error); + if (flow == NULL) + flow_err(port_id, -rte_errno, error); + return flow; +} + int rte_flow_async_destroy(uint16_t port_id, uint32_t queue_id, diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index b60987db4b..2ba616eeb1 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -5187,6 +5187,23 @@ rte_flow_actions_template_destroy(uint16_t port_id, */ struct rte_flow_template_table; +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Template table flow rules insertion type. + */ +enum rte_flow_table_insertion_type { + /** + * Pattern-based insertion. + */ + RTE_FLOW_TABLE_INSERTION_TYPE_PATTERN, + /** + * Index-based insertion. + */ + RTE_FLOW_TABLE_INSERTION_TYPE_INDEX, +}; + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice. @@ -5202,6 +5219,10 @@ struct rte_flow_template_table_attr { * Maximum number of flow rules that this table holds. */ uint32_t nb_flows; + /** + * Insertion type for flow rules. + */ + enum rte_flow_table_insertion_type insertion_type; }; /** @@ -5336,6 +5357,50 @@ rte_flow_async_create(uint16_t port_id, void *user_data, struct rte_flow_error *error); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Enqueue rule creation operation. + * + * @param port_id + * Port identifier of Ethernet device. + * @param queue_id + * Flow queue used to insert the rule. + * @param[in] op_attr + * Rule creation operation attributes. + * @param[in] template_table + * Template table to select templates from. + * @param[in] rule_index + * Rule index in the table. + * @param[in] actions + * List of actions to be used. + * The list order should match the order in the actions template. + * @param[in] actions_template_index + * Actions template index in the table. + * @param[in] user_data + * The user data that will be returned on the completion events. + * @param[out] error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * Handle on success, NULL otherwise and rte_errno is set. + * The rule handle doesn't mean that the rule has been populated. + * Only completion result indicates that if there was success or failure. + */ +__rte_experimental +struct rte_flow * +rte_flow_async_create_by_index(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct rte_flow_template_table *template_table, + uint32_t rule_index, + const struct rte_flow_action actions[], + uint8_t actions_template_index, + void *user_data, + struct rte_flow_error *error); + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice. diff --git a/lib/ethdev/rte_flow_driver.h b/lib/ethdev/rte_flow_driver.h index c7d0699c91..b5b597dd28 100644 --- a/lib/ethdev/rte_flow_driver.h +++ b/lib/ethdev/rte_flow_driver.h @@ -221,6 +221,17 @@ struct rte_flow_ops { uint8_t actions_template_index, void *user_data, struct rte_flow_error *err); + /** See rte_flow_async_create_by_index() */ + struct rte_flow *(*async_create_by_index) + (struct rte_eth_dev *dev, + uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct rte_flow_template_table *template_table, + uint32_t rule_index, + const struct rte_flow_action actions[], + uint8_t actions_template_index, + void *user_data, + struct rte_flow_error *err); /** See rte_flow_async_destroy() */ int (*async_destroy) (struct rte_eth_dev *dev, diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 17201fbe0f..dbc2bffe64 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -298,6 +298,9 @@ EXPERIMENTAL { rte_flow_get_q_aged_flows; rte_mtr_meter_policy_get; rte_mtr_meter_profile_get; + + # added in 23.03 + rte_flow_async_create_by_index; }; INTERNAL { -- 2.18.2