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 AB606A00BE; Fri, 11 Feb 2022 03:27:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CB7DF426E5; Fri, 11 Feb 2022 03:27:35 +0100 (CET) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2074.outbound.protection.outlook.com [40.107.100.74]) by mails.dpdk.org (Postfix) with ESMTP id 71932426D9 for ; Fri, 11 Feb 2022 03:27:34 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B+x+GRj1WrOyA0xkbETeWBSJK1TuiNaopFxkDJsc32s4OqkeST2L3c4Wrx97oYRWk32NK7581LF7G54EfIn+SoPHmSvBzzQphWZSO69wl8ngd2+eIaMKMZ/qRD9P2IketGxb+nbD5Qto35y47/cPngZb+dCwDBcXrWHJo6+n/Pwu3kk63gSVGEmbFW81p+XgPD7ZTIHD0Gvc1b67fX2r6a6uMwyYxOrJWBOJl/IMHVJTDp9sOfAaPuZ6mNP+hbsszsrM6KDHSko7ay2///yPjSWIqzBB04KVQx9VECQdmGRbwVBePzk8ICo0FtXeXYKZaHRdCt0to5B26s3JZcOjSA== 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=5ldIwqFcSQEgC04JQBhVGsQO0KLEKvsmcF92WoiZkto=; b=J7ddabbbCy+HqiBpJDTx1yJgpQNPNb73QUXHFzcjrXCVQ0TshgXnf4nAWoomlcwrSgzyhoX5I8zeJRhSQYacFPPBxk2TZszcuIHWSyoCMDsoG5aq8w6q5Zop5UBFry+QhK2/S2PitAnTE0aE1Ndfx1VN9l4CtzGV6uMPkhVJ+6nkVcjRJwYoPeXF7fDUAKdcfDHDNmyirPPkHxVrKCBDplB3yvV/4CcZdex52XYdPjQdnZRDZRm4jp8/gN809QRFlnKMDAWSToXYC0EPfkjPa8kBChg8wN0fuigGViBQs/P4bGBJn/XuWcri7NkgJZSw76co/TQHLJb2B7d6pWy/Jw== 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=5ldIwqFcSQEgC04JQBhVGsQO0KLEKvsmcF92WoiZkto=; b=ngkvuaoCESWpvRmioqAqBMXytpaS1FW93+7zShF+YgsYYahIYh8Zeal4DfreoCjR9M6hgmh9dT/NwJcx/grO/3Uytn1iZPc6YYyIXw7ntNiTTq0j7vniatpDDxQr97B51dx0OO+GEeQaAT9EESidm7cYZqhYsod2ntijMSae2gwYLftcfJjtG5WfmhSFy61F0qkAZRRIqTe3o/asNSrzx7/I8wbR9ETfJyfH9SA6h1d3lCkmpXEbAD++4Kw4qYkW1EmZ0NAMvdt4DtjDegdBpLBhyjtcEM7GSQ+VDT3EjkT+jfnMo3vwDzUMs7iWll8rQiUy7cyiUnRaE8m9pREzpw== Received: from MN0PR12MB5811.namprd12.prod.outlook.com (2603:10b6:208:377::12) by CH0PR12MB5217.namprd12.prod.outlook.com (2603:10b6:610:d0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Fri, 11 Feb 2022 02:27:32 +0000 Received: from MW4PR04CA0343.namprd04.prod.outlook.com (2603:10b6:303:8a::18) by MN0PR12MB5811.namprd12.prod.outlook.com (2603:10b6:208:377::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Fri, 11 Feb 2022 02:27:21 +0000 Received: from CO1NAM11FT067.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8a:cafe::2f) by MW4PR04CA0343.outlook.office365.com (2603:10b6:303:8a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Fri, 11 Feb 2022 02:27:20 +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 CO1NAM11FT067.mail.protection.outlook.com (10.13.174.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Fri, 11 Feb 2022 02:27:20 +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; Fri, 11 Feb 2022 02:27:19 +0000 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.9; Thu, 10 Feb 2022 18:27:16 -0800 From: Alexander Kozyrev To: CC: , , , , , , , , , Subject: [PATCH v5 01/10] ethdev: introduce flow pre-configuration hints Date: Fri, 11 Feb 2022 04:26:44 +0200 Message-ID: <20220211022653.1372318-2-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220211022653.1372318-1-akozyrev@nvidia.com> References: <20220209213809.1208269-1-akozyrev@nvidia.com> <20220211022653.1372318-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-Office365-Filtering-Correlation-Id: ca71afe0-8793-446a-7aa2-08d9ed0607f1 X-MS-TrafficTypeDiagnostic: MN0PR12MB5811:EE_|CH0PR12MB5217:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KXVkRswhI6X56EP4j6pQJpSltyezLM6eJaOnaZEUA64YRGpgV/lqEbQBwcDEaqG32nvlcsXLFk2Td1fqTTvXUrv8Y0G8Sepzc2ssWT3Y6GxacRAaA20q+UAiIqo7y7rUxG8q3bkKA4WG+UGkUvcps5yvwcu2QZbToiVptkEdjXgvj2uXn5GbEHycEs4bFb3LiidonfF2ARGWCp0G4KRsN+6iOVDxxmCxsN+TmnXyZwus1IdmlYhWdQFmp9V4U3WgGvfDp6Ytw/r/nMsLc01wdBeZVIZfirbhhBafxhn8SSnHFsl77l8qfnzY/F8K2Yu10RkwY3dWzfGP6IodtiGs1Ciqaly8WEE36jYEhH/4LzpnCibrKkvrie3iFbRKoz3JLz2SCkceWfJB38JPqxFmyQ2Txg7GMuFqomgT3/gaumjFYxqk0C8w+FPAf76fQKYEF6oxxLRrb7bP/5kTvHHt8mGTFCWcwAa3WDkae9Fdr2UCH3ti06mDITENeQzLd1jdTnlwX9LJUjmSXw7HXKjwPjfShRXKByoelo/KHIlCizV9dyaLl3N7hwR9Pvj1IrW4PhZn116UlFFK+grez/NOYK426M+8PR2Zs7MbTzeQf0DB0X5HyBiRBJBQutXZ9YQYvIqZCp13OjcL5vGtDGHTPNOHLg1QbZofjixIH0S9FtfLtnSTV5rZJPw0zP6P8lvskaPslIGOgxkqqu3jjJFPqg== 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)(426003)(186003)(2616005)(1076003)(40460700003)(508600001)(336012)(36756003)(16526019)(86362001)(6916009)(26005)(36860700001)(47076005)(83380400001)(54906003)(8676002)(70206006)(70586007)(5660300002)(4326008)(81166007)(356005)(2906002)(6666004)(7416002)(8936002)(82310400004)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2022 02:27:20.7394 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ca71afe0-8793-446a-7aa2-08d9ed0607f1 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: CO1NAM11FT067.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5217 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..92be2a9a89 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 available pre-configurable resources. + * The zero value means a resource cannot be pre-allocated. + * + */ +struct rte_flow_port_info { + /** + * Number of pre-configurable counter actions. + * @see RTE_FLOW_ACTION_TYPE_COUNT + */ + uint32_t nb_counters; + /** + * Number of pre-configurable aging flows actions. + * @see RTE_FLOW_ACTION_TYPE_AGE + */ + uint32_t nb_aging_flows; + /** + * Number of pre-configurable traffic metering actions. + * @see RTE_FLOW_ACTION_TYPE_METER + */ + uint32_t nb_meters; +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Retrieve configuration attributes supported by the port. + * + * @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 contextual 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. + * + * Resource pre-allocation and pre-configuration 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_counters; + /** + * Number of aging flows actions pre-configured. + * @see RTE_FLOW_ACTION_TYPE_AGE + */ + uint32_t nb_aging_flows; + /** + * Number of traffic metering actions pre-configured. + * @see RTE_FLOW_ACTION_TYPE_METER + */ + uint32_t nb_meters; +}; + +/** + * @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