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 D0EF041C35; Wed, 8 Feb 2023 03:48:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 28D5D42670; Wed, 8 Feb 2023 03:48:29 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2083.outbound.protection.outlook.com [40.107.220.83]) by mails.dpdk.org (Postfix) with ESMTP id D15D540DDB for ; Wed, 8 Feb 2023 03:48:26 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BZ0rxmcv1EEJ30rTXf5SFG/v+jJJ00M9DF+SztkBiIBxdaSIdppKgszjAi+IqajoaZPZYd3H+YAINsT8ocRm+DpnG+UxAt2rJafpJj75vQ+SKJgkgz3E+Mhx2R+ye+ejNNyfT5QhafpL5fufXhrDJxottgIEnTSsJI62Sa+gfeeaWESJ0fb/4aFQElN3nkIpWidX59iDXN/87JwJyI2iZH3jMxA8bbwvx/h1Lz3Easno3x/iVo/S24222LuWoIkwYMp/7X0ghiKCDG4Ff2IJjYiEM7ow5PPI6y3bbIkCrVZjU0YK4TYz9e6d8bxheGh5OlGA5WygBL+GClp+jRrhCg== 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=+OuvHax+2+MIF8f+/ql0PzHMWqSRYnhrBy4e9GaXm/I=; b=KIB2y8xOONRgFqfncKygMBn4esT+ymzIeiIIB9P0iP8K5RksqweSx/QBWNbMYleyvFsxKwA6cXG35k47FxjHfSXOT9IhuH+KxO5N5sAlG8UfuecVp5W1996CjUirbxr9Ze+kO7qPZUR+1VutqomsNcBM6yzzXIvRjdFhj0a4xri4t/agiJJtU4zz4nnLDDsLCLRJxh1h40AbuYrf30f8Ncr2y2PrHSZReEsERf1woDYH6dDZLsDfr/8ca4zQhmWf2Lhmbkw4OMr7Gyy1WNgeU6OaH/zH1sLWtH9Cb06tp5QGQMRzKPlNGX/T360n/fe4VyMwO2DKIeBe4Osl8aQ7GA== 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=+OuvHax+2+MIF8f+/ql0PzHMWqSRYnhrBy4e9GaXm/I=; b=F89i0H6y4DXElSLQrOtxZbVFVrNubA+4JDWKPvriDt5IFTGuoy2y6eLsPxIt0+4GEFtRkwClDtHG2R9+YdU9vvgOlaqZlYMEInFzXMBd1esnh2CRzxXVibfWnSlakmWMOP9B0IOOuQvPaRgXN4PEf8vZJ5QNJXxU/H7Be5fRyM6vcrUgfPQPJXlH6RHjm3dOsLpH3Idt/3U7UBiKEFbFSxmN86bWLIwo/g/SeU3iy+VFrndsOKxefwxPxstnT4P0gIpMC4dtfHQmxvos2wFNoJ0KICWxfZSZN7ltIXE3kHpoWOo0IElQ3XZnzlUOY8EqZI7lr8QoAiY6e4dKNTVqZw== Received: from DS7PR03CA0170.namprd03.prod.outlook.com (2603:10b6:5:3b2::25) by SA1PR12MB7443.namprd12.prod.outlook.com (2603:10b6:806:2b7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Wed, 8 Feb 2023 02:48:23 +0000 Received: from DS1PEPF0000E653.namprd02.prod.outlook.com (2603:10b6:5:3b2:cafe::1a) by DS7PR03CA0170.outlook.office365.com (2603:10b6:5:3b2::25) 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 02:48:23 +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 DS1PEPF0000E653.mail.protection.outlook.com (10.167.18.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.16 via Frontend Transport; Wed, 8 Feb 2023 02:48:23 +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 18:48:13 -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 18:48:11 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH v3 1/4] ethdev: add template table insertion type Date: Wed, 8 Feb 2023 04:47:52 +0200 Message-ID: <20230208024755.72743-2-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230208024755.72743-1-akozyrev@nvidia.com> References: <20230126232802.3960109-1-akozyrev@nvidia.com> <20230208024755.72743-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: DS1PEPF0000E653:EE_|SA1PR12MB7443:EE_ X-MS-Office365-Filtering-Correlation-Id: 47eafc73-e9c5-4a70-8230-08db097ef224 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: xDBOuTnd0QBR4J/irk1VpVzDPDziE78BCB0yRXQMMuxy+3JF4cXx6xs/M10kdp4/CB4vvCiClCbPOJQEZa0S8KFep7ObXlTzjK9oe0DXT+PeEMNFPWRagbiV1nWgCQcPRhNu0OJJYynhyF1lS6pF6jFuVm1JB5Xv4zVLAIJ40sNz6fn24RGA3Rn+/o/usaHE2s0SrNx4xiG8vHkZqezySqidwfAuy1Crr8pK3927EvL6KdqixjFd5wC/NJrifA5QO1T5HaWrn5O0fu1p1eIc+LK91LXFczfgJovlPiGJ+e1x6lwQUfxUlVIkoWyEL1PpjkbJe8Sm6yXdyAN9qiE35Rj0Fyh+mfupgv4B69jltph+V1iANlH7hKw4IuCzP+leB7Te0RbYdEJCQE5fKgmZe2EdjNQt+TqvafcPT48lHlUB9sZAud6Xcy7Vi+pLgP2EIsCMLVgFPqzkOa8H0rD6zTF61lnMbVgOmyFtkDbcdZ9JvzIxddMuEloN5916p5zCZBkac0uqYqa9XUlrTxfWqJf1rUPfFVf/yfSeXT6HAs5QDR0qGrgl2TEcX3DeB2teayACSBFcjwJtQ0BScBlbdosnoLTLa8mr1fqkWjbxwgPIogLG6QKhP54d/MMdBSDTw06zOr44GKBGyRuzCnD2jlbsj26CP7HkpCYz/MuOf4azDGdmbmkzFgihmsyJxT+/Mk2lXz/H7l4PZ5v5eeNaCw== 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)(136003)(376002)(346002)(39860400002)(396003)(451199018)(40470700004)(36840700001)(46966006)(47076005)(82310400005)(41300700001)(36756003)(40460700003)(83380400001)(86362001)(7636003)(356005)(36860700001)(26005)(82740400003)(8676002)(2616005)(336012)(426003)(16526019)(186003)(40480700001)(54906003)(6666004)(107886003)(1076003)(478600001)(5660300002)(316002)(70586007)(6916009)(8936002)(70206006)(4326008)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2023 02:48:23.4659 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 47eafc73-e9c5-4a70-8230-08db097ef224 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: DS1PEPF0000E653.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7443 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 calclulated 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