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 0AB66A0350; Sat, 12 Feb 2022 05:20:04 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A3DDF410F0; Sat, 12 Feb 2022 05:20:02 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2069.outbound.protection.outlook.com [40.107.237.69]) by mails.dpdk.org (Postfix) with ESMTP id 97348410F0 for ; Sat, 12 Feb 2022 05:20:00 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FlIeFzcIErbbo8r6JduX7w9Iq8YTSmsQgmizzsDqfp9HqbIvHlhoa3whbZzjzWD4ZLPiul4z5gz8c1b+lTwN6PHlFKK+fg9NZKoQfVL+KBlsdzHqtU+5an07at961unBnX/JzGj7xnau+FJMVJ3HQG4wy8HwlTGKW3BodCpSu8jqu+jLDNejBMIn3WRXwH9bmLRwuiLW1F+NnVcYYuBW4ZGLbsPhxIu9U2BWT6KI2s5/UA7wUP+EGIVohUCED+IvlVpwYh4KMm2akrSkOMfQiywNGys08G6FexZ/6YLpGviSD0Bdg8LqbZOgT5Go2AN+pBfzdQUcmEqhOBO0+X5ntw== 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=MGDPiajTTY+SdL7FsyjEhNh20v/TQz3JM+RfpD7vwKs=; b=egbVWCyNDMVjsEnUpQIfwM/W3WhVK9roNJSeTwtlf50LbJkg4B8hDiRgd4TTwLBprh+emgRj9dxr86hZcWgZRZeNTOQBUprG5yQutuefnYG+4F8evewEYkCvJ2WQh7REfprxMDS5R/6ures8xYX7pyAuskFoYoLAYKqbGHsHZ3+aIlXdwcAqRysGdN+tWULUVjSn3mSlknEZTtjp0ycn+HCb0Ib/R0z3vkBoLtcmngIePIsnVm2oKQ1cHT7timKB4ivdfhnpsi7zL6rk1cKgFDS6IXvO2mUdgVQJVvXwIC3J7bJ3iurjyNzo6kwwP7Mk1cYzwh8ByTPpbhYKVz1zaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=intel.com 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=MGDPiajTTY+SdL7FsyjEhNh20v/TQz3JM+RfpD7vwKs=; b=Z2IaXEUlaej81ll8VJp58zuFkUsSjCMxOUFAYGC5OgfXC9tEIYHNu6A1XslFvYARRYwAPETyxloEBq5c3/Iv6eiBb1SCzKkIEUEo3yzLU7ifuEbIJ856Rh+StQI0BB9/qQxmD6spKdJil/8+lbQrIjFdGMdM6E/Ddd7T4tkVwcLxta2HUC4keIZdMKO4MQAbPfXWO4b8ImVZr1aaAbiU5klvWpDLcH6XM1c+DzeuHjEwk10SoC5Niv/oA7T/Zo0nknKy2z2H5XHV5bc7JjR1QrkoEsYP54RsU4bRW9qQ0Albufx/cSgeNQ37V28vlQZXN2C/hSKfVpjzznhnq13nUw== Received: from DM5PR1201MB0073.namprd12.prod.outlook.com (2603:10b6:4:50::16) by DM6PR12MB4747.namprd12.prod.outlook.com (2603:10b6:5:30::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.16; Sat, 12 Feb 2022 04:19:57 +0000 Received: from MWHPR11CA0008.namprd11.prod.outlook.com (2603:10b6:301:1::18) by DM5PR1201MB0073.namprd12.prod.outlook.com (2603:10b6:4:50::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.12; Sat, 12 Feb 2022 04:19:56 +0000 Received: from CO1NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:301:1:cafe::40) by MWHPR11CA0008.outlook.office365.com (2603:10b6:301:1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.13 via Frontend Transport; Sat, 12 Feb 2022 04:19:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) 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 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by CO1NAM11FT008.mail.protection.outlook.com (10.13.175.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Sat, 12 Feb 2022 04:19:55 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sat, 12 Feb 2022 04:19:54 +0000 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.9; Fri, 11 Feb 2022 20:19:51 -0800 From: Alexander Kozyrev To: CC: , , , , , , , , , Subject: [PATCH v6 01/10] ethdev: introduce flow pre-configuration hints Date: Sat, 12 Feb 2022 06:19:21 +0200 Message-ID: <20220212041930.1516767-2-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220212041930.1516767-1-akozyrev@nvidia.com> References: <20220211022653.1372318-1-akozyrev@nvidia.com> <20220212041930.1516767-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-Office365-Filtering-Correlation-Id: ecbc884a-a5a3-42d9-2ede-08d9eddeec62 X-MS-TrafficTypeDiagnostic: DM5PR1201MB0073:EE_|DM6PR12MB4747:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uLwfU7b36kzVy0E8e+pXb8DIDkjMvXRm/U9effjJzmirWiyXreAtb12OBLVAJkU56TyixBp9+T/59/1UjtUwH8kZoxb9oqDTFgH3cKfSaJ3KYBkU+UMkz7oqqAPt6CJzY00CUPiAMQUJI9oH1AU8Vsx7SVyyrDAdYelacQlXFSFJwOtTeDTGQIk/mkhXNfPyjG4rJXeYGmltJNjvHGNI9R6E1uGJfMpf4P/mSrdjfjVNSbfPbJiUSuH45zczAj1KiCCl5RIk9gPLxH/ntdm5B0wbQ6Z4CL5xeoQPZTMoxFkr4oAyWoSXxEQtG/UoIz1pSUB96tUQrxeuuoDdzMFEauqAmh3cdi3B5NgzQCk8wOV6vks7iZTzfWyvIAegMExRNzSu9TeSHSfwMSm0ahrBYkmY0jDh9YpRxV7ekoFk54jGNYoNYBOBiVr50O6B42cBoVrgz6V2g9lLRq5Oy+Cwr5qu2ou0uvj0kllw2ouNKbuNm6wRUV55ghB9h/GTYlfREfiVjAeD1BqdKBtnictox9M1uohbxz3Mh9zGho9VUOcLcA9/yk2l9lIBH20rYJV4IJXd6sywBcncg3LfkPyWs3jCxAGJNIu44PiJKDxKbPed16B572IPjI60wx3hvKi0XHWrWNpA/5xwyR9tMpEJ5JgpPJItKtht3A32XZRPlgurjzxXTyFNJpEL19X8vYtc4mqhcRaQwTjEuP2XIgK1qg== X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(40460700003)(2616005)(426003)(356005)(16526019)(36860700001)(6916009)(86362001)(508600001)(70586007)(6666004)(82310400004)(316002)(81166007)(1076003)(54906003)(5660300002)(7416002)(70206006)(47076005)(4326008)(36756003)(2906002)(26005)(83380400001)(186003)(336012)(8936002)(8676002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2022 04:19:55.2609 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ecbc884a-a5a3-42d9-2ede-08d9eddeec62 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4747 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 The flow rules creation/destruction at a large scale incurs a performance penalty and may negatively impact the packet processing when used as part of the datapath logic. This is mainly because software/hardware resources are allocated and prepared during the flow rule creation. In order to optimize the insertion rate, PMD may use some hints provided by the application at the initialization phase. The rte_flow_configure() function allows to pre-allocate all the needed resources beforehand. These resources can be used at a later stage without costly allocations. Every PMD may use only the subset of hints and ignore unused ones or fail in case the requested configuration is not supported. The rte_flow_info_get() is available to retrieve the information about supported pre-configurable resources. Both these functions must be called before any other usage of the flow API engine. Signed-off-by: Alexander Kozyrev Acked-by: Ori Kam --- doc/guides/prog_guide/rte_flow.rst | 37 +++++++++ doc/guides/rel_notes/release_22_03.rst | 6 ++ lib/ethdev/rte_flow.c | 40 +++++++++ lib/ethdev/rte_flow.h | 108 +++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 10 +++ lib/ethdev/version.map | 2 + 6 files changed, 203 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index b4aa9c47c2..72fb1132ac 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -3589,6 +3589,43 @@ Return values: - 0 on success, a negative errno value otherwise and ``rte_errno`` is set. +Flow engine configuration +------------------------- + +Configure flow API management. + +An application may provide some parameters at the initialization phase about +rules engine configuration and/or expected flow rules characteristics. +These parameters may be used by PMD to preallocate resources and configure NIC. + +Configuration +~~~~~~~~~~~~~ + +This function performs the flow API management configuration and +pre-allocates needed resources beforehand to avoid costly allocations later. +Expected number of counters or meters in an application, for example, +allow PMD to prepare and optimize NIC memory layout in advance. +``rte_flow_configure()`` must be called before any flow rule is created, +but after an Ethernet device is configured. + +.. code-block:: c + + int + rte_flow_configure(uint16_t port_id, + const struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error); + +Information about resources that can benefit from pre-allocation can be +retrieved via ``rte_flow_info_get()`` API. It returns the maximum number +of pre-configurable resources for a given port on a system. + +.. code-block:: c + + int + rte_flow_info_get(uint16_t port_id, + struct rte_flow_port_info *port_info, + struct rte_flow_error *error); + .. _flow_isolated_mode: Flow isolated mode diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst index f03183ee86..2a47a37f0a 100644 --- a/doc/guides/rel_notes/release_22_03.rst +++ b/doc/guides/rel_notes/release_22_03.rst @@ -69,6 +69,12 @@ New Features New APIs, ``rte_eth_dev_priority_flow_ctrl_queue_info_get()`` and ``rte_eth_dev_priority_flow_ctrl_queue_configure()``, was added. +* ** Added functions to configure Flow API engine + + * ethdev: Added ``rte_flow_configure`` API to configure Flow Management + engine, allowing to pre-allocate some resources for better performance. + Added ``rte_flow_info_get`` API to retrieve pre-configurable resources. + * **Updated AF_XDP PMD** * Added support for libxdp >=v1.2.2. diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index a93f68abbc..66614ae29b 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -1391,3 +1391,43 @@ rte_flow_flex_item_release(uint16_t port_id, ret = ops->flex_item_release(dev, handle, error); return flow_err(port_id, ret, error); } + +int +rte_flow_info_get(uint16_t port_id, + struct rte_flow_port_info *port_info, + 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); + + if (unlikely(!ops)) + return -rte_errno; + if (likely(!!ops->info_get)) { + return flow_err(port_id, + ops->info_get(dev, port_info, error), + error); + } + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, rte_strerror(ENOTSUP)); +} + +int +rte_flow_configure(uint16_t port_id, + const struct rte_flow_port_attr *port_attr, + 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); + + if (unlikely(!ops)) + return -rte_errno; + if (likely(!!ops->configure)) { + return flow_err(port_id, + ops->configure(dev, port_attr, error), + error); + } + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, rte_strerror(ENOTSUP)); +} diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 1031fb246b..c25d46b866 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -4853,6 +4853,114 @@ rte_flow_flex_item_release(uint16_t port_id, const struct rte_flow_item_flex_handle *handle, struct rte_flow_error *error); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Information about flow engine pre-configurable resources. + * The zero value means a resource cannot be pre-configured. + * + */ +struct rte_flow_port_info { + /** + * Maximum number of pre-configurable counter actions. + * @see RTE_FLOW_ACTION_TYPE_COUNT + */ + uint32_t max_nb_counter_actions; + /** + * Maximum number of pre-configurable aging flows actions. + * @see RTE_FLOW_ACTION_TYPE_AGE + */ + uint32_t max_nb_aging_actions; + /** + * Maximum number of pre-configurable traffic metering actions. + * @see RTE_FLOW_ACTION_TYPE_METER + */ + uint32_t max_nb_meter_actions; +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Get information about flow engine pre-configurable resources. + * + * @param port_id + * Port identifier of Ethernet device. + * @param[out] port_info + * A pointer to a structure of type *rte_flow_port_info* + * to be filled with the resources information of the port. + * @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_info_get(uint16_t port_id, + struct rte_flow_port_info *port_info, + struct rte_flow_error *error); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Flow engine pre-configurable resources settings. + * The zero value means on demand resource allocations only. + * + */ +struct rte_flow_port_attr { + /** + * Number of counter actions pre-configured. + * @see RTE_FLOW_ACTION_TYPE_COUNT + */ + uint32_t nb_counter_actions; + /** + * Number of aging flows actions pre-configured. + * @see RTE_FLOW_ACTION_TYPE_AGE + */ + uint32_t nb_aging_actions; + /** + * Number of traffic metering actions pre-configured. + * @see RTE_FLOW_ACTION_TYPE_METER + */ + uint32_t nb_meter_actions; +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Configure the port's flow API engine. + * + * This API can only be invoked before the application + * starts using the rest of the flow library functions. + * + * The API can be invoked multiple times to change the + * settings. The port, however, may reject the changes. + * + * Parameters in configuration attributes must not exceed + * numbers of resources returned by the rte_flow_info_get API. + * + * @param port_id + * Port identifier of Ethernet device. + * @param[in] port_attr + * Port configuration attributes. + * @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_configure(uint16_t port_id, + const struct rte_flow_port_attr *port_attr, + 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 f691b04af4..7c29930d0f 100644 --- a/lib/ethdev/rte_flow_driver.h +++ b/lib/ethdev/rte_flow_driver.h @@ -152,6 +152,16 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_item_flex_handle *handle, struct rte_flow_error *error); + /** See rte_flow_info_get() */ + int (*info_get) + (struct rte_eth_dev *dev, + struct rte_flow_port_info *port_info, + struct rte_flow_error *err); + /** See rte_flow_configure() */ + int (*configure) + (struct rte_eth_dev *dev, + const struct rte_flow_port_attr *port_attr, + struct rte_flow_error *err); }; /** diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index cd0c4c428d..f1235aa913 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -260,6 +260,8 @@ EXPERIMENTAL { # added in 22.03 rte_eth_dev_priority_flow_ctrl_queue_configure; rte_eth_dev_priority_flow_ctrl_queue_info_get; + rte_flow_info_get; + rte_flow_configure; }; INTERNAL { -- 2.18.2