From patchwork Thu Feb 2 13:47:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Etelson X-Patchwork-Id: 122962 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1D0EE41BAE; Thu, 2 Feb 2023 14:48:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 075E742F96; Thu, 2 Feb 2023 14:48:26 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2084.outbound.protection.outlook.com [40.107.244.84]) by mails.dpdk.org (Postfix) with ESMTP id 8ADE942BAC for ; Thu, 2 Feb 2023 14:48:24 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hZs/EdcHrtqzTQFXHlX1XQjLcswhJXyT/yZ8jPgBaQN9JASNoOVm4MUcnd95x+EtqisfdMvMbhGJcRwlmZhGSDUE5fHI+Yw+gSQgdDWNP9lgkFwuZ7eYDUFL18qYxZI+xwVKMGZMb4HMVFKH7W3SMC4Ehm7536OhExwQdMpaiYwR25no+03HlWAVkpg3RUpdDA+G7+rJXVfQNpZeSWWVvo0UmH4OkbzOOfvpt6DgHiLer0BPbOrStCUtiA/U1mRChBARtyZvEMzxDyuhCdhW2amYo2NeDZzFBZibzlPuJGNWagGSKafZiZOrZFLf2Re+QQVUi+eepiI8FE7mryXBqw== 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=c6BVHLJ0YPHplBmz1dgFqHIBnQ860T82IuRFOB5LdkQ=; b=ap9rzVVYCSd0NdRsibLon9iqJHZhH20wxUY0qEHsAIlp3265A1HFXTdOwy9NoBpSyk93QpzFIC2jbTZKthdfSAY24+33J/kqnw4Cy7sSWoVUWva0mqOI3g9Nq//DFLocUetwSgKjXOLe0201QaQQmxADC0AAKJOmuQFu5RnTlEpDvbuwlQlF7hLDJmnEPtYk0j7Ux/yyqxewjPqCpUWYhZ7hbO2+D3+qkCi627kasK3zhhNAUII0aZZyooumXe5ttbAzAjRT886mbIBr/X3iClo0YFUM+FyfvTSuYFtTrXg6Ch43MunkYD/tNeOGdo3vA8M1nBOQVQLhD00c0/Lf+Q== 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=c6BVHLJ0YPHplBmz1dgFqHIBnQ860T82IuRFOB5LdkQ=; b=CmB25zwc/Axk5wZcur0g+YRdETFDRmmexU4fnfxotbffm7mTBinqaWN7TxJd/wWE5Nj3MiEsSG8pEyBMKj7jMyVNdo3SM7AIsSCly0ooczEI8YGE1xU/jN8mqeHmzdKA/hbFiGbA43JnDEfbDndH2OAWKB6Sq92hOqtGIy8WMBjIUp6w5IZsDNETxMypMFn3JVzYw6QgVIe2VHYHUALgW2gi8D0ASCNt8v/dK63GOx0wjq4hXT8lDoTFe77eqFKaa4L3XaOQ/xxbVKilW+fQWW2BkBbn0b2BuSm0iFdKwNwWfM9XFW0mmQs+kBnjsiNT5TMpSAZpHA6JqH95baJ0mw== Received: from BN0PR02CA0013.namprd02.prod.outlook.com (2603:10b6:408:e4::18) by IA1PR12MB6652.namprd12.prod.outlook.com (2603:10b6:208:38a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25; Thu, 2 Feb 2023 13:48:22 +0000 Received: from BN8NAM11FT071.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e4:cafe::a4) by BN0PR02CA0013.outlook.office365.com (2603:10b6:408:e4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28 via Frontend Transport; Thu, 2 Feb 2023 13:48:22 +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 BN8NAM11FT071.mail.protection.outlook.com (10.13.177.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25 via Frontend Transport; Thu, 2 Feb 2023 13:48:21 +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.36; Thu, 2 Feb 2023 05:48:10 -0800 Received: from nvidia.com (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; Thu, 2 Feb 2023 05:48:07 -0800 From: Gregory Etelson To: CC: , , , Ori Kam , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Subject: [PATCH v10 1/2] ethdev: add query and update sync and async function calls Date: Thu, 2 Feb 2023 15:47:49 +0200 Message-ID: <20230202134750.10418-1-getelson@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221221073547.988-1-getelson@nvidia.com> References: <20221221073547.988-1-getelson@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT071:EE_|IA1PR12MB6652:EE_ X-MS-Office365-Filtering-Correlation-Id: dd4ecee4-d4fa-4b3a-91e7-08db0524262f 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: iCacPBtFja5AscilRVGoPZnNHDF/8SHGCRg7UiLWAVqC8VrxGSyEr69yk4NO8GtCQutoUPZnc8ojuAQs8d9JjqdWIPbpfVOfKEM8MU1Evt//x8INUJljCnLWj0uBfp04fFjiMlqIfiYOckr5o31e+OyZyKB44wwdzhiN5l8rqRazQhkoi1D2yMua4EsRg0VIvIWfF2YBBQWaPBx1kDKHc24WNjYRFbmCRnqsLqGlRhk7vJgDlYdzuLCfS8X3+/shRAdG1V59HlQr/XUzG9Y2pxpXCbQn0i+lyhNSwUwku26cyRzGz67I6iAGKa0XRjb6Zf7g6Wts0gli1OjGKNiKNLrWKf/YbnRpyK95IqA4OEe7vasRIbNcokVaYM3f0Rnk/9WyBM2THueGIT3Alhdvv8IpHIzVNfCku5SS71WNkANtT2pErRT/YwQHFivQX8/jdoZ1vmySe4VFWfydUMdxbCtIpLoJF/uKeOrpRDAPBVHBdin7DXk1Gm8uN0okDW7liQAYz/zDqzj9IHw6gqb0kGhrqxCtk6WKVWQY/CAhGgxWwSc3G0sQAI/d6fNGUQMsZMHJUAABcnJrcq0ctEpcYnBca80sGkle8nUgkELZxoTxvVQGU0ZBey/DsW0y/o11UbA8mHSa9Bbl1iA5muF3eAA8vdqtE1f230cwiOE4XUWp/1ppuuHGXvlPkOSjSiej3Vl58lKOeTcX+f/dIi0A2g== 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:(13230025)(4636009)(39860400002)(136003)(376002)(346002)(396003)(451199018)(46966006)(36840700001)(40470700004)(47076005)(356005)(82310400005)(86362001)(40460700003)(36756003)(55016003)(40480700001)(82740400003)(36860700001)(7636003)(15650500001)(4326008)(7696005)(8676002)(41300700001)(2906002)(316002)(8936002)(54906003)(5660300002)(2616005)(83380400001)(336012)(426003)(6666004)(26005)(478600001)(70586007)(70206006)(6916009)(186003)(16526019)(6286002)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 13:48:21.8639 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dd4ecee4-d4fa-4b3a-91e7-08db0524262f 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: BN8NAM11FT071.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6652 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 Current API allows either query or update indirect flow action. If indirect action must be conditionally updated according to it's present state application must first issue action query then analyze returned data and if needed issue update request. When the update will be processed, action state can change and the update can invalidate the action. Add `rte_flow_action_handle_query_update` function call, and it's async version `rte_flow_async_action_handle_query_update` to atomically query and update flow action. Application can control query and update order, if that is supported by port hardware, by setting `qu_mode` parameter to RTE_FLOW_QU_QUERY_FIRST or RTE_FLOW_QU_UPDATE_FIRST. Signed-off-by: Gregory Etelson Acked-by: Ori Kam --- v2: Remove RTE_FLOW_QU_DEFAULT query-update mode. v3: Update release release notes. Fix doxygen errors. v4: Add returned errno codes. v5: Update the patch description. Fix typos. v6: Resolve merge conflict with the main branch. v7: Update documentation. v8: Style fixes. v9: Add parameters validation. v10: Code update. --- doc/guides/rel_notes/release_23_03.rst | 8 ++ lib/ethdev/rte_flow.c | 54 +++++++++++++ lib/ethdev/rte_flow.h | 100 +++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 15 ++++ lib/ethdev/version.map | 5 ++ 5 files changed, 182 insertions(+) diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index 73f5d94e14..5ab90f5118 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -78,6 +78,14 @@ New Features ``rte_event_dev_config::nb_single_link_event_port_queues`` parameter required for eth_rx, eth_tx, crypto and timer eventdev adapters. +* **Added functions to atomically query and update indirect flow action.** + + Added synchronous and asynchronous functions to atomically query and update + indirect flow action: + + - ``rte_flow_action_handle_query_update`` + - ``rte_flow_async_action_handle_query_update`` + Removed Items ------------- diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 7d0c24366c..923d795be1 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -1883,3 +1883,57 @@ rte_flow_async_action_handle_query(uint16_t port_id, action_handle, data, user_data, error); return flow_err(port_id, ret, error); } + +int +rte_flow_action_handle_query_update(uint16_t port_id, + struct rte_flow_action_handle *handle, + const void *update, void *query, + enum rte_flow_query_update_mode mode, + struct rte_flow_error *error) +{ + int ret; + struct rte_eth_dev *dev; + const struct rte_flow_ops *ops; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + if (!handle) + return -EINVAL; + if (!update && !query) + return -EINVAL; + dev = &rte_eth_devices[port_id]; + ops = rte_flow_ops_get(port_id, error); + if (!ops || !ops->action_handle_query_update) + return -ENOTSUP; + ret = ops->action_handle_query_update(dev, handle, update, + query, mode, error); + return flow_err(port_id, ret, error); +} + +int +rte_flow_async_action_handle_query_update(uint16_t port_id, uint32_t queue_id, + const struct rte_flow_op_attr *attr, + struct rte_flow_action_handle *handle, + const void *update, void *query, + enum rte_flow_query_update_mode mode, + void *user_data, + struct rte_flow_error *error) +{ + int ret; + struct rte_eth_dev *dev; + const struct rte_flow_ops *ops; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + if (!handle) + return -EINVAL; + if (!update && !query) + return -EINVAL; + dev = &rte_eth_devices[port_id]; + ops = rte_flow_ops_get(port_id, error); + if (!ops || !ops->async_action_handle_query_update) + return -ENOTSUP; + ret = ops->async_action_handle_query_update(dev, queue_id, attr, + handle, update, + query, mode, + user_data, error); + return flow_err(port_id, ret, error); +} diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index b60987db4b..b754330579 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -5622,6 +5622,106 @@ rte_flow_async_action_handle_query(uint16_t port_id, void *user_data, struct rte_flow_error *error); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Query and update operational mode. + * + * @see rte_flow_action_handle_query_update() + * @see rte_flow_async_action_handle_query_update() + */ +enum rte_flow_query_update_mode { + RTE_FLOW_QU_QUERY_FIRST = 1, /**< Query before update. */ + RTE_FLOW_QU_UPDATE_FIRST, /**< Query after update. */ +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Query and/or update indirect flow action. + * If both query and update not NULL, the function atomically + * queries and updates indirect action. Query and update are carried in order + * specified in the mode parameter. + * If ether query or update is NULL, the function executes + * complementing operation. + * + * @param port_id + * Port identifier of Ethernet device. + * @param handle + * Handle for the indirect action object to be updated. + * @param update + * If not NULL, update profile specification used to modify the action + * pointed by handle. + * @param query + * If not NULL pointer to storage for the associated query data type. + * @param mode + * Operational mode. + * @param 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. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOTSUP) if underlying device does not support this functionality. + * - (-EINVAL) if *handle* or *mode* invalid or + * both *query* and *update* are NULL. + */ +__rte_experimental +int +rte_flow_action_handle_query_update(uint16_t port_id, + struct rte_flow_action_handle *handle, + const void *update, void *query, + enum rte_flow_query_update_mode mode, + struct rte_flow_error *error); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Enqueue async indirect flow action query and/or update + * + * @param port_id + * Port identifier of Ethernet device. + * @param queue_id + * Flow queue which is used to update the rule. + * @param attr + * Indirect action update operation attributes. + * @param handle + * Handle for the indirect action object to be updated. + * @param update + * If not NULL, update profile specification used to modify the action + * pointed by handle. + * @param query + * If not NULL, pointer to storage for the associated query data type. + * Query result returned on async completion event. + * @param mode + * Operational mode. + * @param user_data + * The user data that will be returned on async completion event. + * @param 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. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOTSUP) if underlying device does not support this functionality. + * - (-EINVAL) if *handle* or *mode* invalid or + * both *update* and *query* are NULL. + */ +__rte_experimental +int +rte_flow_async_action_handle_query_update(uint16_t port_id, uint32_t queue_id, + const struct rte_flow_op_attr *attr, + struct rte_flow_action_handle *handle, + const void *update, void *query, + enum rte_flow_query_update_mode mode, + void *user_data, + struct rte_flow_error *error); + #ifdef __cplusplus } #endif diff --git a/lib/ethdev/rte_flow_driver.h b/lib/ethdev/rte_flow_driver.h index c7d0699c91..7358c10a7a 100644 --- a/lib/ethdev/rte_flow_driver.h +++ b/lib/ethdev/rte_flow_driver.h @@ -114,6 +114,13 @@ struct rte_flow_ops { const struct rte_flow_action_handle *handle, void *data, struct rte_flow_error *error); + /** See rte_flow_action_handle_query_update() */ + int (*action_handle_query_update) + (struct rte_eth_dev *dev, + struct rte_flow_action_handle *handle, + const void *update, void *query, + enum rte_flow_query_update_mode qu_mode, + struct rte_flow_error *error); /** See rte_flow_tunnel_decap_set() */ int (*tunnel_decap_set) (struct rte_eth_dev *dev, @@ -276,6 +283,14 @@ struct rte_flow_ops { void *data, void *user_data, struct rte_flow_error *error); + /** See rte_flow_async_action_handle_query_update */ + int (*async_action_handle_query_update) + (struct rte_eth_dev *dev, uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct rte_flow_action_handle *action_handle, + const void *update, void *query, + enum rte_flow_query_update_mode qu_mode, + void *user_data, struct rte_flow_error *error); }; /** diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 17201fbe0f..628c486081 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -298,6 +298,11 @@ EXPERIMENTAL { rte_flow_get_q_aged_flows; rte_mtr_meter_policy_get; rte_mtr_meter_profile_get; + + # added in 23.03 + rte_flow_action_handle_query_update; + rte_flow_async_action_handle_query_update; + }; INTERNAL {