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 DFF5FA034E; Sun, 6 Feb 2022 04:26:00 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E1084410EA; Sun, 6 Feb 2022 04:25:54 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2069.outbound.protection.outlook.com [40.107.243.69]) by mails.dpdk.org (Postfix) with ESMTP id BBBE840042 for ; Sun, 6 Feb 2022 04:25:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cDD8FGtOMcZFVTnuSVCaqLw93MPxQNI/9v+li4uCCVm8/gPirn1ZeEwN6EFuqkZHuTr3Sfa7uvzczGLqvlinW8aqPWwFPKcMD7zFD9IWdPD1i2HnEukze9JL+GzXKh3qIhuIS8t5TamuSyh+7xYNR04UyNIfmuzcToGJgd+ourOAWHV8wvMqhzDoecECcA8opJfkTuwVxI+vcmBJrL1sImHPzA7ti7O5Cvy5WfUJNiis+SBP8RsKSnrnEHdKpEbC1jBiIORuf1zGV1Sw0hYizvvnFLeFDqzJJPl8H0pOQj80xbqaZYss+DDA/WwOVYRHa1zL0Nno1wVpTi/SbEOYiQ== 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=Sq0L48tfeINQbg2lisWYiEM+Anl8bVBoyWOFW2akFfU=; b=lwr7XpBlDMjNY23mMoFwrFeJG2X4RfitDoFt9TifGuree7EGgWlTSQFn27JdnwXN5eToXpWBOI5D0YkYcfjALTcxbrdENUaBXWVcjiyizIMvtlJVHU45aHTAG2y40Zmp5yoGtRiQ3Gh1rMz+UlYE72BdEmchQvy//5t+vfFv1SNq/ZtVdOeUZWu98AtmMP+2yasU8FN0BKesdtQvQs6Ripp1g7MH216vAxPDLuddQNRpv1ULzYG+GNXMf0LTjSzKuxgB0umqQX45zrXJLYwOrQOLp5XE57AjOkiXncAzPXZa917qQIpnoAdwEI1S/lBY3b1ndfcpz7APgqnSUfCuPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) 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=Sq0L48tfeINQbg2lisWYiEM+Anl8bVBoyWOFW2akFfU=; b=GWa7rWhp/lJRUuCl0n335w6ZC3NEPWX6qDjO0eER/iVVwunWVyPxSD72BCI5S4R+3iNs2iznPMNqXhOqjrQiERMjUaF9slhGX9jOWDRXcRAibxlkM8oArHinQqD3qcVr6zIWOM6hZk9Chs+2xMh4u8zIlrdaY8dQ3y5sfU5MlA0d1TwIBkxgyyQF5RdUzDug56whVWjLdsq8jl1rpPDaD5ron0EAz8N1cjcj6Qd/b1CaBYAvfqKf+6HLhzOCAHdZkI9sAOJPFi4FbQoNRxNAdHGQ65tGiJKSKHznx4a7J0YeAF/tlNsUbcJodoJbQiUOwF8yQsUowZq1YPAGG1ik/w== Received: from CH0PR12MB5346.namprd12.prod.outlook.com (2603:10b6:610:d5::24) by CY4PR1201MB0165.namprd12.prod.outlook.com (2603:10b6:910:1c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Sun, 6 Feb 2022 03:25:50 +0000 Received: from BN9PR03CA0771.namprd03.prod.outlook.com (2603:10b6:408:13a::26) by CH0PR12MB5346.namprd12.prod.outlook.com (2603:10b6:610:d5::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Sun, 6 Feb 2022 03:25:48 +0000 Received: from BN8NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13a:cafe::11) by BN9PR03CA0771.outlook.office365.com (2603:10b6:408:13a::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Sun, 6 Feb 2022 03:25:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) 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.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by BN8NAM11FT066.mail.protection.outlook.com (10.13.177.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Sun, 6 Feb 2022 03:25:48 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sun, 6 Feb 2022 03:25:47 +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; Sat, 5 Feb 2022 19:25:44 -0800 From: Alexander Kozyrev To: CC: , , , , , , , , Subject: [PATCH v3 01/10] ethdev: introduce flow pre-configuration hints Date: Sun, 6 Feb 2022 05:25:17 +0200 Message-ID: <20220206032526.816079-2-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220206032526.816079-1-akozyrev@nvidia.com> References: <20220118153027.3947448-1-akozyrev@nvidia.com> <20220206032526.816079-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: 9abf30a8-4f02-4e95-9ff0-08d9e9205e84 X-MS-TrafficTypeDiagnostic: CH0PR12MB5346:EE_|CY4PR1201MB0165: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: gjpiWhs/n+8m+olALPXj+VIwnMO4g2pE4Z/ZoYZfPZQQsl9oYuoBJ6tTCjbmKf1UOj6BrtCutCHOwdO1AXimeFOugZ9rtY3IlzHZ3u1mBZIj2za9w9IeggUZatELOtmJEIOS82YuGkNtxqnOupHydZmzV8wsfoSMVOazvviINTbxsFa/G4QydFwz1LFk4kUDruMCEJ1ldmJEFOtt7tk2e13EffGBh4E5/Og+RDkjgfD45rJl5THOtxYHYanJoRMCaQ9ovT2GIe0ECMoSo0NjvRxnX3ByWrpj8u0s7hIaT1moMJkYUbdm4s3oQOg/jWiNSnKSGrHl68oJUWerr/Va9KDzcQ2v6puEzGFKcYNjnTisRtutnM9JISDaKQa6KK6kohByAU6yNv6fGMOnSCG8CPy7bMiGjTU1PoePiAXV1x6s/kPOdfbXnENh7Zlws6MIyuhtpUukuqnGFel2+K/9PA4BlMAc/dWqoFtoixEQxc3UxmIQAX3RtkBR49+KlTtTUvUb6JxSOSww9fxapyVAbTcSyxU+A7u7TgtPkZN3K86cfFgmb/PR4EBt/ReBAzMVdyRs+zdGlWN3HbSphXIfJsx6C13MHjxsLMuMF9WD3IafvUGf4QdHWEY2LT0xVvuunrDvnhM6QrsadE2+paHYqVmJY2OTKa01TX7jvILJRHjCDHkvFnQdmet2uMKrpznrRC20c0KPTIi1+IGLvbblrQ== X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(83380400001)(47076005)(36860700001)(8936002)(40460700003)(16526019)(2906002)(70206006)(8676002)(4326008)(70586007)(5660300002)(36756003)(82310400004)(316002)(54906003)(86362001)(508600001)(336012)(186003)(426003)(1076003)(2616005)(6666004)(26005)(81166007)(356005)(6916009)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2022 03:25:48.1111 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9abf30a8-4f02-4e95-9ff0-08d9e9205e84 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.238]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0165 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 --- doc/guides/prog_guide/rte_flow.rst | 37 ++++++++++++ doc/guides/rel_notes/release_22_03.rst | 4 ++ lib/ethdev/rte_flow.c | 40 +++++++++++++ lib/ethdev/rte_flow.h | 82 ++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 10 ++++ lib/ethdev/version.map | 4 ++ 6 files changed, 177 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index b4aa9c47c2..5b4c5dd609 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 hints at the initialization phase about +rules engine configuration and/or expected flow rules characteristics. +These hints may be used by PMD to pre-allocate resources and configure NIC. + +Configuration +~~~~~~~~~~~~~ + +This function performs the flow API management configuration and +pre-allocates needed resources beforehand to avoid costly allocations later. +Hints about the 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_attr *port_attr, + 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 bf2e3f78a9..8593db3f6a 100644 --- a/doc/guides/rel_notes/release_22_03.rst +++ b/doc/guides/rel_notes/release_22_03.rst @@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* 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..e7e6478bed 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_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->info_get)) { + return flow_err(port_id, + ops->info_get(dev, port_attr, 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..f3c7159484 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -4853,6 +4853,88 @@ 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. + * + * Resource pre-allocation settings. + * The zero value means on demand resource allocations only. + * + */ +struct rte_flow_port_attr { + /** + * Version of the struct layout, should be 0. + */ + uint32_t version; + /** + * 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. + * + * Retrieve configuration attributes supported by the port. + * + * @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_info_get(uint16_t port_id, + struct rte_flow_port_attr *port_attr, + struct rte_flow_error *error); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Pre-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. + * + * @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..503700aec4 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_attr *port_attr, + 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 1f7359c846..59785c3634 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -256,6 +256,10 @@ EXPERIMENTAL { rte_flow_flex_item_create; rte_flow_flex_item_release; rte_flow_pick_transfer_proxy; + + # added in 22.03 + rte_flow_info_get; + rte_flow_configure; }; INTERNAL { -- 2.18.2