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 2409E42B34; Thu, 18 May 2023 21:50:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E7BF34282D; Thu, 18 May 2023 21:50:18 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2040.outbound.protection.outlook.com [40.107.92.40]) by mails.dpdk.org (Postfix) with ESMTP id 2385640A8A for ; Thu, 18 May 2023 21:50:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MaYI+pl4z2M+u91rSirbNPhDZaKG1NY0mHFZTG01UBiZlPKzrUUG7uznoRCO1XhKYa4dy1w1DAt0IqbXrOhT7WGSYbIT2eT+FYC+0Qwq5l8H9LLcUgmWg10wyjPGhWyR0ugNsd4XV71px2XShSJksgsjmCwjoCsDYJb09x2f/46es5R4ccx5+p8Ll0iASmENMiMEShUfs0vgWszFvNC/1XCRvgkMHtdFzkp7vqe+iZxL36EDabGWC+qPQS8KQi8bGeqNb4xX+rDPKD65Z/WZokk6zTh6QPg2siEoSZcvSpd6jf1n3DutGF3KNLb7N9fkhPRlmOiR/kRIOLthiYigoQ== 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=FqjfY9PZqn1cY979+v8Jtp7PVbU5RgfKNLB0IaCfb2o=; b=MsZLX01SyZeOVqZ9bH9bBqdMzWtTMDwDMBVTLaz8YB80onPy6MgdO8X/yr/aOcgZlzEyusGEfn9cyiIDLk5Mcaw9JSkggtQPUN1ceuJqCw1j9NxEpav1PXSGhFEKCmcnocQhrE672fSW+EhfjkLTS7EpsL76CnjLHPAs75nrzdVe7vQ3k+KLmZLp+XnEn52krCO0/UlxG05QGPUQUzA8oyBX5DE/ypAlUenCundd36XanSpj+GdiYwymadJMwzkPcWaV1BFxJy5Q52cwtkJxq2DUPGv/5L3P+EORi7wL0WqdHPYI1TEAQrZ+hTRYrKFTJzsIjdXeEv5gZz60CpDdLg== 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=FqjfY9PZqn1cY979+v8Jtp7PVbU5RgfKNLB0IaCfb2o=; b=O93c71YvMnpLBToqULzk8iL4b6xJzaKuONSRTuKJkxYMDjNppPzC90UBPJHqvPK/Z0cPss7Ha7dEYv2XW/twSJeHfo6/qN5Fk4eFwKdvz/R40vOl8g/MFGTUNTsC6e5hnVJ7ESLXEmQfKQIew+ylP+osX49o68AMX3SL2kNSaE8HoknmoccvPh8W2eQdam1lv4LmaNKxCnPrC1pvVTtaVktKFL1jl8naLYe06xlHTtMmqw83OM4pq/Bed97DZUoO2dfKPJhKEYUeeadJ8Otnm20oVQbL1GUf6QKYBMQgAV1cxJmYc6SZHWSgmvgEjfHXmYAcsGeFbn0mqaP5wUqsrQ== Received: from BYAPR07CA0020.namprd07.prod.outlook.com (2603:10b6:a02:bc::33) by SA1PR12MB5616.namprd12.prod.outlook.com (2603:10b6:806:22a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19; Thu, 18 May 2023 19:50:15 +0000 Received: from DM6NAM11FT104.eop-nam11.prod.protection.outlook.com (2603:10b6:a02:bc:cafe::ad) by BYAPR07CA0020.outlook.office365.com (2603:10b6:a02:bc::33) 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 19:50:15 +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 DM6NAM11FT104.mail.protection.outlook.com (10.13.173.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21 via Frontend Transport; Thu, 18 May 2023 19:50:14 +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 12:50:03 -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 12:50:01 -0700 From: Alexander Kozyrev To: CC: , , Subject: [PATCH v2] ethdev: add flow rule actions update API Date: Thu, 18 May 2023 22:49:43 +0300 Message-ID: <20230518194943.2338558-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230418195807.352514-1-akozyrev@nvidia.com> References: <20230418195807.352514-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: DM6NAM11FT104:EE_|SA1PR12MB5616:EE_ X-MS-Office365-Filtering-Correlation-Id: a7003f97-bfc0-4390-44c4-08db57d9195b 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: mMbRvs2xshqdsmpK/fqEJ8apS1w6PtuxJ+IFOHBreJmhHiFnBz6y7s2WJakxAFRBhBBQuf/JdK6/j05uUoAHoZM7dREv5Z983EKbWXVuQIsCwPXtxsjDus9rtA63k5GqsKh7JaGFC6mDOsnysm8Dwl8N3a6zmkVhNNISQDx3uOLgHg41b/vsfIeA+DdWYm60aAFRlVdbdxcgcxdLvvU5vFdFPCcdpVhpgbanmQajIN04Ks5TBOqveoHN/brNSO6X42UahOuhOsXzneCnFjh8hnltzsbqfOarcdOcNSAPuNYeJlsyAWUW2WUYiwpIVWfaULrr6XDYjf++TJtB0Tav11NVFkL96Rcmr1m3MmuQv3cdio7beoE3GcykbeaRFzgH/iOgxql0/LsBWazOKYayaR6YZzfDSF3CooEKw2Az8fLwF/geGXIt048mJRuP7YWQ+MKI5TXb4NQgni32mJYoU94086e9D/5W8H9pFkHBIDqaUIC4nTxt1WzWz/3W0o/3rgwd/bS7/AVdBwlA6Zy6j5Ps45Thhcw6241zTTcymSs2mOv3jFq9N79HftSFcq8MMj+46QYPD1O1ho+9i/BShJ6KYvepgmAgFvpyDhDyGYzzF2tOXB6G3Ub1gIdv3wx67YWintpD/05nXIjTRC4Wr50Ux0BXutFdEKU+roI+aNq1+IE6s3qnBXXgH8bGN8HHE86GYEqY4dz9ukKPvGBp1+j+sRfT4tpZ+bgHPUHB1FZV96BVIuTkz+7S1elQZesZ 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)(396003)(346002)(39860400002)(376002)(136003)(451199021)(46966006)(36840700001)(40470700004)(26005)(40460700003)(1076003)(36860700001)(83380400001)(426003)(40480700001)(47076005)(336012)(2616005)(36756003)(86362001)(7636003)(82310400005)(356005)(82740400003)(16526019)(186003)(54906003)(478600001)(15650500001)(8676002)(30864003)(2906002)(8936002)(316002)(41300700001)(5660300002)(6916009)(70206006)(70586007)(4326008)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 19:50:14.6426 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7003f97-bfc0-4390-44c4-08db57d9195b 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: DM6NAM11FT104.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5616 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..8c9ce56392 100644 --- a/lib/ethdev/ethdev_trace.h +++ b/lib/ethdev/ethdev_trace.h @@ -1595,6 +1595,24 @@ RTE_TRACE_POINT( rte_trace_point_emit_int(ret); ) +RTE_TRACE_POINT( + 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( rte_flow_trace_push, RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue_id, int ret), @@ -2220,6 +2238,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, 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