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 2639142980; Tue, 18 Apr 2023 21:58:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B4F9F4021F; Tue, 18 Apr 2023 21:58:42 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2057.outbound.protection.outlook.com [40.107.101.57]) by mails.dpdk.org (Postfix) with ESMTP id A2A304014F for ; Tue, 18 Apr 2023 21:58:41 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cKTS904msG8VPDidnzObkRux1s9asLQE0fKdUfDCCl2mEYW3So5k2gqV4MH9QsE9/g+T4s6i6DvA1ij7ZYgs4iELie9RQ6kfw1JJYXkLanSHu9uJG0bc4KJZIzusRgiBfnF0bQE8L1kEzMva/KhfxppDpa2cVFnn3Y1+dYBIIgUnCDfjvYNlkcXIpJ7IDB7vNe4JweEf8vCbY+zLHQQUAIMlUYK9culAaeXToc3LZwQk/2fPEC1APUC9ocWUA5Vl4czxDqWS5bGK72TwyPzqVF/6unqxLTx/ZpQcj5THzCv6SE0m0hfmoL1ub/e43q8v4T9xvSEMXEECkvHq37eYaA== 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=RnQxaR71VYh/L6NIpVrBLLG2Ze6ry4qRI+C5af9Zsy0=; b=MHPohz2NnjPznCtPnF+yZ7+1OVdNK5qvVgOr+IDNpvzZr01NIgXtiHCBRiOieaKYvZRhjhn24ZaLAFXQehez5SYHmOMsDM258ufXq3Q11LdO0jlfNZ2k827BJtZ+hk0ICcq4zrS0lB29cH9h1FR0gvKDg2W6duI4DOtXCilzbfl7ldAPHiYxaZqBiUSeJgDsOBWFBkdlw5BBfM7u77n5M8NINAabm0gGQrWmVkpenTRdWPbX18m2686TE/6ZGIvQEQJQCRbH/cY4ZeQtkMk9Rb1Xl7leze+wft9HgEyNgeoINCO2BSwivEhI81POf+vN+jbMF2BMbu8Yk8yBEDOiVw== 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=RnQxaR71VYh/L6NIpVrBLLG2Ze6ry4qRI+C5af9Zsy0=; b=PN/vE8X8E0YXU8+262u7EzFCJR4P7ep2nUATgqJ34hahcrP6s9ox6iEOrMOMKKzFKeAqU8V6qB8bfYLRgvadIPz0XUCjy+m5QfPQkVEBnIlRYva4fNaPbB38HqHySZLbKfMi0Cv73hSlWAQc1jegGVqzIFEn671tQjPt/6q/Lr8B96X4u9kDriDcKWJGG1Z19A3FfNznGl6yjYeFSpykrWItIWycF++Tsngg//DcobymBeiMIpAhxtzSvw0B17GDJCnkqrvHNZAK+P1nkB8M23J3LXhM/fYBb17T3wrWMNI4F02e/wX/s74ZWKdu1y88sCcBRxuNHY/eVCaXErO3mQ== Received: from MW4PR04CA0162.namprd04.prod.outlook.com (2603:10b6:303:85::17) by MW3PR12MB4474.namprd12.prod.outlook.com (2603:10b6:303:2e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.45; Tue, 18 Apr 2023 19:58:39 +0000 Received: from CO1NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:303:85:cafe::5f) by MW4PR04CA0162.outlook.office365.com (2603:10b6:303:85::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.47 via Frontend Transport; Tue, 18 Apr 2023 19:58:39 +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 CO1NAM11FT046.mail.protection.outlook.com (10.13.174.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22 via Frontend Transport; Tue, 18 Apr 2023 19:58:39 +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.5; Tue, 18 Apr 2023 12:58:26 -0700 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.37; Tue, 18 Apr 2023 12:58:24 -0700 From: Alexander Kozyrev To: CC: , , Subject: [PATCH] ethdev: add flow rule actions update API Date: Tue, 18 Apr 2023 22:58:07 +0300 Message-ID: <20230418195807.352514-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 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: CO1NAM11FT046:EE_|MW3PR12MB4474:EE_ X-MS-Office365-Filtering-Correlation-Id: 64c1c602-3691-4e04-a62b-08db40474d97 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: NzQgwk9tPI+v/XtPGhhGxDHcgWp/1Z8b5Eveu1Le04xdNvicXmbDVR/okix6QfvUHZ7mLqvQcwfQtViF2Vz7n4pRSPWJllFCPu2QYotKe+t00N+6vv9nMM85D5xRDfnMC54LSYg5uTsjhbM+r5V9VAr9ls+HYovLr24ds9XgXqfSL+p9vY7TZ3NS2n+4CADyXDUOCf2wwauP6LxzMLtZdEeEI+tNhkVnDJ3xzWPX96S3i3VxqJox6M3FwuPKe0IFMj01Uku0xfUeYyisxWQ2A3I663LZqY1l8+eZBPwQE5s62weyMSlaNEkCzIlGhcRZgAY00+jilVTQobpaYOmkV4SSQkhwcxETf8K7qHUyVbb5bPaUlzORPK+WH6ahRS3WFd+gKwxRjYmOOJIlfmHIMExbFPz8P9i+zvSqEqnAgJdA9/+C1WkmzE5l8SKTZ7WBivC/xoygjDo8/R4Ckl8WA76q6zDnqYQtcktqR0B2uSFS+a/lhJfO3/D9zDgEWz9+OIBj41qK69bOCCHyLjIEEB9PL+RAZSaWuTMjKf9jdyBC9oAwhQYi7zc6wlxpRQiITk9iqvYsSe+TrRCSv4S74ONg5WR0NHC28AVyOwa8obQjg1Wd7Pl2xsquk3S9wN2gb0h1R0ilyGr4y6TaJj3GhXB1AZKiWyKP9Dv+FS5Bnq03xkDMgzb1G4WeYbLGxU8T8wgZei3v1F3TbBCQ55Y4z93vVFU94YpGDI2wQXFzw+/wMVk1o0MbSXB6j0bSTYpS6kdR3v8UQb7viXGXY+SVstFpzDLGJbqlpPbWkIhS/D8= 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:(13230028)(4636009)(396003)(346002)(136003)(39860400002)(376002)(451199021)(36840700001)(46966006)(40470700004)(336012)(6666004)(478600001)(86362001)(34020700004)(2616005)(47076005)(426003)(36860700001)(26005)(40480700001)(107886003)(83380400001)(1076003)(16526019)(186003)(40460700003)(82740400003)(36756003)(7636003)(356005)(70586007)(316002)(70206006)(2906002)(4326008)(8936002)(6916009)(5660300002)(8676002)(15650500001)(41300700001)(82310400005)(54906003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2023 19:58:39.0759 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 64c1c602-3691-4e04-a62b-08db40474d97 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: CO1NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4474 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/rte_flow.c | 43 ++++++++++++++++++ lib/ethdev/rte_flow.h | 62 ++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 16 +++++++ lib/ethdev/version.map | 2 + 6 files changed, 169 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/rte_flow.c b/lib/ethdev/rte_flow.c index 69e6e749f7..1ebb17ae3c 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -441,6 +441,29 @@ 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); + 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 +2008,26 @@ 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); + + return flow_err(port_id, + ops->async_update(dev, queue_id, op_attr, flow, + actions, actions_template_index, + user_data, error), + error); +} + 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