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 E320442B83; Tue, 23 May 2023 20:40:25 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7DEF140A80; Tue, 23 May 2023 20:40:25 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2069.outbound.protection.outlook.com [40.107.93.69]) by mails.dpdk.org (Postfix) with ESMTP id DC82140689 for ; Tue, 23 May 2023 20:40:23 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WDcH89ykspxxDdXciEOP3Wp9h01GijnyY9hZXd2lRBJPEk7Dl2w+73bD6UC4LRZzm1H0PuHHCzlTanSr8zSK4AxDT8fwGb3oJYBU3KMo/3sr2YzJA2M+O0G5xwJFaDq3++E6/R0P3I6vC7FKc+R7Lsuq1Lbv7v0uyRKTtNCcN1u7VU1z1AX9DKFP+GeTHFNuyRWFAPUWrnHyHQKTdeH3Vxja/s2XB3JOgJzpenIkjStX/BEHebt3rB9VzVq7w+2CyI0sUxYFyFfos9QZ20Lj1ViWYPcae8wXr9axDxh4lFVW7ppmDoQLNMq2e6I0W08nZLxla5/Ow6gy0ur/Q1ZIkQ== 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=CQb6aFvsvzqGERhSLo+cW4fUc2qHFG8wGXGywxmtGw8=; b=llqnSnH09a8ZrG6K4IB+4+DGaE2NcJNzJuGXoqtTzk4sP4i1vpdWwGONFLbzmPtWkdacZg8EQTmv6m2+BG+3b84Tlm7pODOTrxi/rZdbZvAVwYFQoBwpJmcPEoC1hBAujUyJnX3eqNJxEk7F+tP0g8vowLTRNIHfPlJb6cl1+oD3yXZGovDQXDhte9o1aX2Dws6Aby0QzL+Sh+Dwktmk/CE2aTG/jJXByGsIjZBA7Y87aswAh6W6s+8n0lqZb0cX6ROs8l1iy54njBO1aQalUP7T5u5FFQh1LpCrLHK6NKM8rrMMVF+AJo63BGxaRR13Q5+JN84XTRPnM9uwBtu/4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=temperror 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=CQb6aFvsvzqGERhSLo+cW4fUc2qHFG8wGXGywxmtGw8=; b=sc1shbXpLddbYm8sPd6ANN26eGPUSIcjqiFpAvLpumAI2pBWP4lnwNp3Qiustf05/2NfqHdYl/Di/lODZou2Lg3Cu9X2vcCAXk3bkJmbYF1zt8D5+LZITcS/SNS7s7l79u4ggHUGR47xBhki1+Z5qpO4qq0CFbRwoDeV3JnDPQNsRwrutx5uSjo7rGaiWgnqVtedrUwiPhebndUSuJ1WystqkgLGoH5qi6I5rAYrNAKmdpekGSgVmgAbCyh408i3wwRL1VREnwo4cStvDIHaNMfwYnm/yICIomYaR2uRsID9fsun+l9qk07lL3iM0v7Xf6NxZ4eurslrKmFlfV53Og== Received: from MW4PR03CA0223.namprd03.prod.outlook.com (2603:10b6:303:b9::18) by CY5PR12MB6297.namprd12.prod.outlook.com (2603:10b6:930:22::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 18:40:21 +0000 Received: from CO1NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b9:cafe::85) by MW4PR03CA0223.outlook.office365.com (2603:10b6:303:b9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28 via Frontend Transport; Tue, 23 May 2023 18:40:21 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=nvidia.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of nvidia.com: DNS Timeout) Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT085.mail.protection.outlook.com (10.13.174.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29 via Frontend Transport; Tue, 23 May 2023 18:40:20 +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; Tue, 23 May 2023 11:40:10 -0700 Received: from pegasus01.mtr.labs.mlnx (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.986.37; Tue, 23 May 2023 11:40:07 -0700 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH v4] ethdev: add flow rule actions update API Date: Tue, 23 May 2023 21:39:48 +0300 Message-ID: <20230523183948.3403023-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230518214852.2364233-1-akozyrev@nvidia.com> References: <20230518214852.2364233-1-akozyrev@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.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: CO1NAM11FT085:EE_|CY5PR12MB6297:EE_ X-MS-Office365-Filtering-Correlation-Id: 732641f9-7bdb-4007-e7d1-08db5bbd2980 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: EXcqzY05tNTHn7PJsTi/VqDhBxyBQ1dvvUAA0ZhGTYQVVrMdLmYThajeZ4VB+n1L+euMl7oAS0kyHta7rclgyROoLDIcHitZDHOrQ0k40gdN07W+6Clf2WcVpi3lJCkY8Q2cS2qutM/e4+TiK7vLvRwZn3bIhdlyIr/pIhGQwUmSQ4BeMHmtZEYttX+h2U6c9dusB/g7qGnYiqq+4ZCA/AG9+5vMgKWkTauaK0nOfdUiHv4uWj0Z8iyZ36hIGojcAkg8IG/C2th8+MBgt6V/8AOA/3AC5oVb+63WS7afYUC2Lpedq/a0ClaMN1/I4NskQ1kGwUCo/Ucw61/5wt7ZKqLRi5/0nofxMItLxGABGDy0O6flBo7qWBbDVf59XNBYA9so2sk15xZBJBQFC90vDwHchDuIY7AurupHkJSa7Q4skCnddKS/3R+At3XObWqsDPTLMf7Lyr6sonfD1fp50KyW4PJm0IKlHFQyB6ZCRjvENYfd0erQHOn3v+WS1kstwBdhEFJ7ENlHx+Oj+buLytttwBlrkotUbe+bsCVYIC4l908ZmSCWGoHIq0DwlfhWniIIVUp47UO+URkf0MSpTwU9nj35e2/mhmf2lwXN44e8MlFr7X9X+l9NpwGTseBCC+AKCVUaAmXKd/+LnTy9sWoaxFq4bKBmA7keyn5OpwURi8GjHz2X/ysNBQRHWWEUPq6KB2o3cMw4jQaBzTo0BXBj7cbud03yJbLQ1wMCKzUNC/OueTpzXoFb1rDqXZGT 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)(136003)(346002)(376002)(39860400002)(396003)(451199021)(36840700001)(46966006)(40470700004)(70206006)(70586007)(8676002)(83380400001)(8936002)(5660300002)(336012)(82310400005)(47076005)(63350400001)(426003)(1076003)(26005)(36860700001)(86362001)(16526019)(186003)(82740400003)(356005)(7636003)(2616005)(40460700003)(6916009)(478600001)(40480700001)(6666004)(316002)(4326008)(36756003)(41300700001)(63370400001)(54906003)(2906002)(30864003)(15650500001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 18:40:20.4911 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 732641f9-7bdb-4007-e7d1-08db5bbd2980 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: CO1NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6297 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_actions_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_actions_update() is added as well. The matcher is not updated, only the action list is. Signed-off-by: Alexander Kozyrev Acked-by: Ori Kam --- doc/guides/prog_guide/rte_flow.rst | 42 +++++++++++++++++ doc/guides/rel_notes/release_23_07.rst | 5 +++ lib/ethdev/ethdev_trace.h | 29 ++++++++++++ lib/ethdev/ethdev_trace_points.c | 6 +++ lib/ethdev/rte_flow.c | 54 ++++++++++++++++++++++ lib/ethdev/rte_flow.h | 62 ++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 16 +++++++ lib/ethdev/version.map | 4 ++ 8 files changed, 218 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 32fc45516a..dada2568fe 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_actions_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_actions_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..76377614d2 100644 --- a/doc/guides/rel_notes/release_23_07.rst +++ b/doc/guides/rel_notes/release_23_07.rst @@ -55,6 +55,11 @@ 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_actions_update() and + rte_flow_async_actions_update() functions. Removed Items ------------- diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h index 3dc7d028b8..f14c67e1c6 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_actions_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_actions_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..ac5961da98 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_actions_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_actions_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..518306fdc0 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_actions_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->actions_update)) { + fts_enter(dev); + ret = ops->actions_update(dev, flow, actions, error); + fts_exit(dev); + + rte_flow_trace_actions_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,34 @@ rte_flow_async_destroy(uint16_t port_id, return ret; } +int +rte_flow_async_actions_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_actions_update(dev, queue_id, op_attr, + flow, actions, + actions_template_index, + user_data, error), + error); + + rte_flow_trace_async_actions_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..261344f41a 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_actions_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_actions_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..1b329842da 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_actions_update(). */ + int (*actions_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_actions_update() */ + int (*async_actions_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..041f0da31f 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -299,6 +299,10 @@ EXPERIMENTAL { rte_flow_action_handle_query_update; rte_flow_async_action_handle_query_update; rte_flow_async_create_by_index; + + # added in 23.07 + rte_flow_actions_update; + rte_flow_async_actions_update; }; INTERNAL { -- 2.18.2