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 3CC8C42436; Sat, 21 Jan 2023 06:22:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5D0F6427F2; Sat, 21 Jan 2023 06:22:29 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2084.outbound.protection.outlook.com [40.107.223.84]) by mails.dpdk.org (Postfix) with ESMTP id C6BF142DB4 for ; Sat, 21 Jan 2023 06:22:27 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SgJtOcqmx4Rvu/+Bf9Ydo19iVDA3oDJnzcuZrdoJxuZcG5sl0JR/sJJR2r6oQMCc2HV7syrY1WGy+kU8RhumITdOmUQl20fUwCNxRat6MgtojTlaRQU3yhZaYjNfGOT7thWEFerz/1KGY1Wv9y13PCA0rQrbsr07wnYwwE6V0oYS5GTV2XNrlRTSoVFQ2yf1dUOJB02nI3PQpKJMbi972qoqAAEQ/S6rExHhNyYGfT26UPMSIbW/769EeEvyCuMcemqtPki3vklBnjknRx0ZpHJTdZBn+goQ/ch7hIA/PdCANZEauGDkp1m+uFn/rVD9epK5w3Z63oZ0XQPbtBseIw== 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=CVqVWYTIX/SkkV+ClGWwWt8k5ltHZ7wTVtMIYrAtJU0=; b=O/tnUnmuXmajeY4tC9twPOqoZSerwDms93PQyIw8QUXKVO+cMqfha20u+n5nuZbPQcXa/i4E0g+PPDPUPX2HyQVi6tMAnqkzrftyUdcnvx85x3PJ8myMy9DifIUaew6r/D/NzLc8fmZ6ruBTDpn/a0VrKHlowcjKzNCUIF2e9hC0URyEkGB8YD1U5ZTf9azzM61xs/iQC8R0TUmYrMCA2BaAmw5BPavXKxPOtf2zbS9ss5LcNSxbss5cNpdjBmS6DQUzcXz6lr/xKQP2Ab8ciB4y0dHwFh/ccfT7ZU6ciMnpCVq/A9WUNBHRd/1FaNCniuKHRRbEjvMg1hff3qoBcQ== 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 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=CVqVWYTIX/SkkV+ClGWwWt8k5ltHZ7wTVtMIYrAtJU0=; b=g2ZLDYSKZtvg4Vn56dEjaqz+4i84ESyW01TyIfbDdp22LxSWLc9spYQaGMOBvGHDq/Z2v7KmWmQxpogbLaCeLgA+tFj9LrSg1V1hVGq4lP+RrocvTju/F3CvAI+0e3wnHoLzsIuaG6I+m7g+SMg6gNp9UwaA/IHigeEoQG5eKiHq78scikYpb1X8njUXL+KLb1vqmIlesemLTdvhnfLyswBZ/+xDiuiDZ1EoV8E8kBbM5Und9LqHq1AYa+vw5hXsc0hSGbiTyS9kyW08lzhheYvOJhcHvHr4X83IyI8R/lfDPesPsSVZmoipgn38kQCOzOKr/K1CJFttIJIYK+QWUA== Received: from BN9PR03CA0538.namprd03.prod.outlook.com (2603:10b6:408:131::33) by DM4PR12MB5055.namprd12.prod.outlook.com (2603:10b6:5:39a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.27; Sat, 21 Jan 2023 05:22:26 +0000 Received: from BN8NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:408:131:cafe::a1) by BN9PR03CA0538.outlook.office365.com (2603:10b6:408:131::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.27 via Frontend Transport; Sat, 21 Jan 2023 05:22:25 +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 BN8NAM11FT050.mail.protection.outlook.com (10.13.177.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6023.16 via Frontend Transport; Sat, 21 Jan 2023 05:22:25 +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.986.36; Fri, 20 Jan 2023 21:22:22 -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; Fri, 20 Jan 2023 21:22:20 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH 1/4] ethdev: add template table insertion type Date: Sat, 21 Jan 2023 07:21:55 +0200 Message-ID: <20230121052158.2928238-2-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230121052158.2928238-1-akozyrev@nvidia.com> References: <20221214022110.393410-1-akozyrev@nvidia.com> <20230121052158.2928238-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: BN8NAM11FT050:EE_|DM4PR12MB5055:EE_ X-MS-Office365-Filtering-Correlation-Id: 80a59ee0-44c1-451f-07ae-08dafb6f7b5f 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: cgF34XQ0Ea+pobom1xrTycPUXDQkK1kxJYXv069QY6J9XuE9jhiPho1gsj6Fo+YRiDgkdl+SWNsPyPPtWAw+GeXoVOQlpy7AnQtA4Ig2ULSZXuRHtSGTeMwcPiYnO9lcyO4gOTAYvaOeDJZCH3N9YXaKGKtg89S8nP0YtQ3fLYELnXOIzEnp4CbqqQ5Cj/r9z0aSkprQzcC1TpnU1bsxiPksTR7WKbhrr6YYE6DYONLlB4Rnm2JeQ/vY/wdKzhhFRAxkbyq7j1TXfw4MazfBZQMQGqIh6Zyy0/mt9E/D0lRqtbM26vaYvVDP72tgNPCUVRfB+7ia+OKrH/XunVbx17FQp1hhqklEaXZJ5nMKfyQ+4Arw5unPtEgZjz29tpE2uLrs5vko1logV+7f47Xd1RDtAumsVJYf1CiE5VBvHDQ4sy5ORDVPRVUWGxjEnB6OEFiJbfPBlhTxDvHac8eb1oaNl/AD5tQBr8CnasAH2ZL31+obfPZtrP4mFzAcP7LWT+9v/eUDu1aIGhmGSCLCSYClAR/MnGOeIQ6o7jN3pJBX86/891TpRGRX9YBJQNJYORq96JGUIuarR1nZVIKmkAMFhZ/+HxL0Q6EyclbtYJdMAbIZ4baH8ftPnxgx4UUe3dmLjPwTXtUr+sZp3w+e94Xe0FcGzeIjLPS4eUvEtZCWkqtAwJBMr6CGHU+v4UZwdaxo99yPBQyLflvLybrS1g== 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:(13230022)(4636009)(346002)(376002)(136003)(396003)(39860400002)(451199015)(46966006)(36840700001)(40470700004)(5660300002)(8936002)(4326008)(82310400005)(8676002)(6916009)(70206006)(70586007)(6666004)(107886003)(54906003)(16526019)(26005)(186003)(2906002)(36756003)(478600001)(2616005)(316002)(36860700001)(83380400001)(41300700001)(40480700001)(82740400003)(40460700003)(356005)(7636003)(86362001)(426003)(47076005)(336012)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2023 05:22:25.4082 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80a59ee0-44c1-451f-07ae-08dafb6f7b5f 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: BN8NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5055 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 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 new create_by_index() API. The idea of the index-based insertion is to avoid additional match and simply execute predefined actions after jumping to the index. The insertion to already existing index is undefined and depends on PMD implementation. Old rule must be destroyed first. Index cannot be bigger than the size of the table. 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 | 66 ++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 11 +++++ lib/ethdev/version.map | 3 ++ 6 files changed, 131 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 3e6242803d..7d05acb2db 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 the rule at a table index. + +.. code-block:: c + + struct rte_flow * + rte_flow_async_create(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 b8c5b68d6c..13dd368f2e 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -56,6 +56,13 @@ New Features ======================================================= +* **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..88d0c6a724 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,51 @@ 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. + * Inserting a rule to already occupied index results in undefined behavior. + * @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