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 1EE3F42B3D; Thu, 18 May 2023 23:49:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E7EAD41141; Thu, 18 May 2023 23:49:39 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2054.outbound.protection.outlook.com [40.107.237.54]) by mails.dpdk.org (Postfix) with ESMTP id E7D3D40E25 for ; Thu, 18 May 2023 23:49:37 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EsibfWckJTYdj2u5YeZ0y2A/zYJLeVDSeeUiUmgsU8pAS6TG7b/ITt3hCyFGgJkRwVKCwY5bOo5GQ3sRtI4NwiJ7CdtZRDY4wTtLETxvjifWhzEtpU0t8P6y2I9vmoxQN3ovURdffnUYO1hGV89GFyLjIjfr3DoGf2FVMncH61tu/ZfUR+L58zHd9IUDL+YkLEFH86/dvIHwjvS9yZ+L8punkKcldv0P2soTEcZ3S3WTf9EtkpEtCapZE4lLWp+lzSwfi133t0I9LruPE/NDDnY4Z9iVog0fN8wMd6QUvDNgGXmJb9wydIjZKfYq5yodz+PYEaJ0Mdx+mP6XvV6bcw== 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=B+qKt90oNp7KpBA9hZHl+iOT1c9rMnCOzxwl+V4rhA0=; b=BsH003+a0JZo9PqsnZqLp93mTfQGycOKUpR3QRgCozunEmU1SuVu66tJc7L1g2mE4mQ2y8BrpB4iqpQbLuNnxiAOkgQu2wsVEcZ4g62VtLg0xvSjhoxO2JtuQTL7TU/23GO3TKgfWwv+p2/Dqt2D1XaSDTEqnF23ghuMyiLojr+cs4RniXJJIEhUGZxv9DBr+eaKAP8XZsFbDACnb0Q+I8LTk2DkiIrgu02BOLe3fxXehcEbbE0QgXcuARbMbz7JsWPiKwzT8afCHV0MK7CVEEejbFZ5Q8X0k0xuVh8QG63WS6UhkV655fJXvv2XQPEvgi0J1jiMrcbKn4a3OdIMMw== 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=B+qKt90oNp7KpBA9hZHl+iOT1c9rMnCOzxwl+V4rhA0=; b=LHUz8/Y6Ig/cS+RWBM9JZsC0aOO6yAwA6ETfApCBrRAhtE6UQx3tPFv0RibsZyW0mG36GVR5M8YiviXDtmgKAoruXyGT6pnsTacLDmc6pDID1JCjqDiHDeVZcsY6q02jRYOZLnyF4yyDdqQDh9YkoWHb2j36N26lVLG2vqcGhdw3mvxdPhOwD6MuhTR/Ce3QF7eyoa5+wvJKv9OCsFlvvlVPzWDTH9+9/drBl2WTHrH58+l1MJjGHEjgaH+S9s1GgmCmz3ZwxTwuZVMqLrK4MXLI3waRewAXiGs7G9Tg/WI3QvEG3Y1pSpOkznfzXEe8R4kqHbD88IoT1evdfhIqQA== Received: from DS7PR03CA0304.namprd03.prod.outlook.com (2603:10b6:8:2b::16) by MN0PR12MB5977.namprd12.prod.outlook.com (2603:10b6:208:37c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.30; Thu, 18 May 2023 21:49:33 +0000 Received: from DS1PEPF0000E646.namprd02.prod.outlook.com (2603:10b6:8:2b:cafe::15) by DS7PR03CA0304.outlook.office365.com (2603:10b6:8:2b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 21:49:32 +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 DS1PEPF0000E646.mail.protection.outlook.com (10.167.18.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.11 via Frontend Transport; Thu, 18 May 2023 21:49:32 +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.5; Thu, 18 May 2023 14:49:14 -0700 Received: from pegasus01.mtr.labs.mlnx (10.126.231.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.986.37; Thu, 18 May 2023 14:49:12 -0700 From: Alexander Kozyrev To: CC: , , Subject: [PATCH v3] ethdev: add flow rule actions update API Date: Fri, 19 May 2023 00:48:52 +0300 Message-ID: <20230518214852.2364233-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230518194943.2338558-1-akozyrev@nvidia.com> References: <20230518194943.2338558-1-akozyrev@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.231.35] 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: DS1PEPF0000E646:EE_|MN0PR12MB5977:EE_ X-MS-Office365-Filtering-Correlation-Id: a98ffa5f-8a40-4451-bf34-08db57e9c377 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: hg5BwRr1SL5Vnz0sUXvswQ0e4RXYNpZusUcZoO+WTaD6OkDzOsXMljeNBV9ZzALtmEjEVg+1nAb19kZD56hGcF4ixaJ3mZQG8m7QCRvIXNCht4C4scJgBVTVBfQ5V4a36fZU6YhONlqcOi1vBEDDIN6Fo8wDftu3pmTsmhdxJ1gYGI+9PLwopsGQw/9tCZVJub27sBN9PcG0gmVjVd7lBpYWOv4S33zU72v5duvg9alWLgcI6qFGI8BkSiEV8+aShMiSEdrZh2atYvf2Ji9cMZzXgl91f2xNilZpK9MJW8CqId4Qd7mCF8XE4/l0XhZ/crv0OF5AXdYStiObPVHqF6vOuObmHvvx9m75NH5+S1I544d5FtVmHEgZ2+UcT9YWeb9hSrnrV5s054dp96XgX7UTuzCrPtP/e56OFyw+fCI8zDp174HEBER7RRHJqSV/7WveMYhF+JL0ZYrFiKbpYR/B4FbnpwdQuoTYlArk+HrekHzzYPy5ixmwezqQcGzJSkTF0/MDDzETZ2Qgs1RRqNF+noag96Ewj7fOQVx5RYjb0pxA2UiRZrRQQXaIpJtyzufZE/Ul0pdhWo9pZ5IwmiF2ceOgY6jH02VRp0qluf8HUBBmi6cy2fCAIBMy10Wr/wJZ1Wb919ILQqywxvOfj7fZ08YdDR4IJIyPMm6FaZptFVHdUhsVzIIA0yHr/l1cD0Si6dsdGFoCXnYLugkEtrx35rPscImQPIhE5ZTjFBoN2DWXAxwV1jOo/KeTLRN+ 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:(13230028)(4636009)(346002)(396003)(376002)(136003)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(82310400005)(83380400001)(426003)(336012)(47076005)(36860700001)(6916009)(316002)(82740400003)(2906002)(356005)(7636003)(41300700001)(4326008)(478600001)(5660300002)(70586007)(40480700001)(2616005)(26005)(70206006)(40460700003)(8676002)(54906003)(86362001)(16526019)(8936002)(30864003)(15650500001)(186003)(1076003)(36756003)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 21:49:32.0208 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a98ffa5f-8a40-4451-bf34-08db57e9c377 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: DS1PEPF0000E646.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5977 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 Introduce the new rte_flow_update() API allowing users to update the action list in the already existing rule. Flow rules can be updated now without the need to destroy the rule first and create a new one instead. A single API call ensures that no packets are lost by guaranteeing atomicity and flow state correctness. The rte_flow_async_update() is added as well. The matcher is not updated, only the action list is. Signed-off-by: Alexander Kozyrev --- doc/guides/prog_guide/rte_flow.rst | 42 +++++++++++++++++ doc/guides/rel_notes/release_23_07.rst | 4 ++ lib/ethdev/ethdev_trace.h | 29 ++++++++++++ lib/ethdev/ethdev_trace_points.c | 6 +++ lib/ethdev/rte_flow.c | 53 ++++++++++++++++++++++ lib/ethdev/rte_flow.h | 62 ++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 16 +++++++ lib/ethdev/version.map | 2 + 8 files changed, 214 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 32fc45516a..0930accfea 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -3446,6 +3446,31 @@ Return values: - 0 on success, a negative errno value otherwise and ``rte_errno`` is set. +Update +~~~~~~ + +Update an existing flow rule with a new set of actions. + +.. code-block:: c + + struct rte_flow * + rte_flow_update(uint16_t port_id, + struct rte_flow *flow, + const struct rte_flow_action *actions[], + struct rte_flow_error *error); + +Arguments: + +- ``port_id``: port identifier of Ethernet device. +- ``flow``: flow rule handle to update. +- ``actions``: associated actions (list terminated by the END action). +- ``error``: perform verbose error reporting if not NULL. PMDs initialize + this structure in case of error only. + +Return values: + +- 0 on success, a negative errno value otherwise and ``rte_errno`` is set. + Flush ~~~~~ @@ -3795,6 +3820,23 @@ Enqueueing a flow rule destruction operation is similar to simple destruction. void *user_data, struct rte_flow_error *error); +Enqueue update operation +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Enqueueing a flow rule update operation to replace actions in the existing rule. + +.. code-block:: c + + int + rte_flow_async_update(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct rte_flow *flow, + const struct rte_flow_action actions[], + uint8_t actions_template_index, + void *user_data, + struct rte_flow_error *error); + Enqueue indirect action creation operation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst index a9b1293689..94e9f8b3ae 100644 --- a/doc/guides/rel_notes/release_23_07.rst +++ b/doc/guides/rel_notes/release_23_07.rst @@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= + * **Added flow rule update to the Flow API.** + + * Added API for updating the action list in the already existing rule. + Introduced both rte_flow_update() and rte_flow_async_update() functions. Removed Items ------------- diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h index 3dc7d028b8..ba7871aa3e 100644 --- a/lib/ethdev/ethdev_trace.h +++ b/lib/ethdev/ethdev_trace.h @@ -2220,6 +2220,17 @@ RTE_TRACE_POINT_FP( rte_trace_point_emit_int(ret); ) +/* Called in loop in app/test-flow-perf */ +RTE_TRACE_POINT_FP( + rte_flow_trace_update, + RTE_TRACE_POINT_ARGS(uint16_t port_id, const struct rte_flow *flow, + const struct rte_flow_action *actions, int ret), + rte_trace_point_emit_u16(port_id); + rte_trace_point_emit_ptr(flow); + rte_trace_point_emit_ptr(actions); + rte_trace_point_emit_int(ret); +) + RTE_TRACE_POINT_FP( rte_flow_trace_query, RTE_TRACE_POINT_ARGS(uint16_t port_id, const struct rte_flow *flow, @@ -2345,6 +2356,24 @@ RTE_TRACE_POINT_FP( rte_trace_point_emit_ptr(flow); ) +RTE_TRACE_POINT_FP( + rte_flow_trace_async_update, + RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + const struct rte_flow *flow, + const struct rte_flow_action *actions, + uint8_t actions_template_index, + const void *user_data, int ret), + rte_trace_point_emit_u16(port_id); + rte_trace_point_emit_u32(queue_id); + rte_trace_point_emit_ptr(op_attr); + rte_trace_point_emit_ptr(flow); + rte_trace_point_emit_ptr(actions); + rte_trace_point_emit_u8(actions_template_index); + rte_trace_point_emit_ptr(user_data); + rte_trace_point_emit_int(ret); +) + RTE_TRACE_POINT_FP( rte_flow_trace_pull, RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue_id, diff --git a/lib/ethdev/ethdev_trace_points.c b/lib/ethdev/ethdev_trace_points.c index 61010cae56..f7bc6f342b 100644 --- a/lib/ethdev/ethdev_trace_points.c +++ b/lib/ethdev/ethdev_trace_points.c @@ -490,6 +490,9 @@ RTE_TRACE_POINT_REGISTER(rte_flow_trace_create, RTE_TRACE_POINT_REGISTER(rte_flow_trace_destroy, lib.ethdev.flow.destroy) +RTE_TRACE_POINT_REGISTER(rte_flow_trace_update, + lib.ethdev.flow.update) + RTE_TRACE_POINT_REGISTER(rte_flow_trace_flush, lib.ethdev.flow.flush) @@ -580,6 +583,9 @@ RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_create, RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_destroy, lib.ethdev.flow.async_destroy) +RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_update, + lib.ethdev.flow.async_update) + RTE_TRACE_POINT_REGISTER(rte_flow_trace_push, lib.ethdev.flow.push) diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 69e6e749f7..baef9e92ea 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -441,6 +441,32 @@ rte_flow_destroy(uint16_t port_id, NULL, rte_strerror(ENOSYS)); } +int +rte_flow_update(uint16_t port_id, + struct rte_flow *flow, + const struct rte_flow_action actions[], + 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); + int ret; + + if (unlikely(!ops)) + return -rte_errno; + if (likely(!!ops->update)) { + fts_enter(dev); + ret = ops->update(dev, flow, actions, error); + fts_exit(dev); + + rte_flow_trace_update(port_id, flow, actions, ret); + + return flow_err(port_id, ret, error); + } + return rte_flow_error_set(error, ENOSYS, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, rte_strerror(ENOSYS)); +} + /* Destroy all flow rules associated with a port. */ int rte_flow_flush(uint16_t port_id, @@ -1985,6 +2011,33 @@ rte_flow_async_destroy(uint16_t port_id, return ret; } +int +rte_flow_async_update(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct rte_flow *flow, + 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); + int ret; + + ret = flow_err(port_id, + ops->async_update(dev, queue_id, op_attr, flow, + actions, actions_template_index, + user_data, error), + error); + + rte_flow_trace_async_update(port_id, queue_id, op_attr, flow, + actions, actions_template_index, + user_data, ret); + + return ret; +} + int rte_flow_push(uint16_t port_id, uint32_t queue_id, diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 713ba8b65c..79bfc07a1c 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -4343,6 +4343,29 @@ rte_flow_destroy(uint16_t port_id, struct rte_flow *flow, struct rte_flow_error *error); +/** + * Update a flow rule with new actions on a given port. + * + * @param port_id + * Port identifier of Ethernet device. + * @param flow + * Flow rule handle to update. + * @param[in] actions + * Associated actions (list terminated by the END action). + * @param[out] error + * Perform verbose error reporting if not NULL. PMDs initialize this + * structure in case of error only. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +__rte_experimental +int +rte_flow_update(uint16_t port_id, + struct rte_flow *flow, + const struct rte_flow_action actions[], + struct rte_flow_error *error); + /** * Destroy all flow rules associated with a port. * @@ -5770,6 +5793,45 @@ rte_flow_async_destroy(uint16_t port_id, void *user_data, struct rte_flow_error *error); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Enqueue rule update 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] flow + * Flow rule to be updated. + * @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 + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +__rte_experimental +int +rte_flow_async_update(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct rte_flow *flow, + 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 a129a4605d..193b09a7d3 100644 --- a/lib/ethdev/rte_flow_driver.h +++ b/lib/ethdev/rte_flow_driver.h @@ -302,6 +302,22 @@ struct rte_flow_ops { const void *update, void *query, enum rte_flow_query_update_mode qu_mode, void *user_data, struct rte_flow_error *error); + /** See rte_flow_update(). */ + int (*update) + (struct rte_eth_dev *dev, + struct rte_flow *flow, + const struct rte_flow_action actions[], + struct rte_flow_error *error); + /** See rte_flow_async_update() */ + int (*async_update) + (struct rte_eth_dev *dev, + uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct rte_flow *flow, + const struct rte_flow_action actions[], + uint8_t actions_template_index, + void *user_data, + struct rte_flow_error *error); }; /** diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 357d1a88c0..d4f49cb918 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -299,6 +299,8 @@ EXPERIMENTAL { rte_flow_action_handle_query_update; rte_flow_async_action_handle_query_update; rte_flow_async_create_by_index; + rte_flow_update; + rte_flow_async_update; }; INTERNAL { -- 2.18.2