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 98229A034C; Tue, 18 Jan 2022 16:31:30 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 047EB42788; Tue, 18 Jan 2022 16:31:09 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2077.outbound.protection.outlook.com [40.107.236.77]) by mails.dpdk.org (Postfix) with ESMTP id 7EB7442786 for ; Tue, 18 Jan 2022 16:31:07 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LPRkjHNwFkExMcQeU5wV4VPzHnVlcplLqt7eDCHixVNSo8AVn6f7LL8ptDlNr4dvlsLj5/cWRS4dUkCxRNNjqlvmqoA6X7DaPQk5qb0d/kxKF/Ya31Jqe4yCQxoJIF5Pf/JpL1kqERJza67SizuUBJNKAR1SjrWOydBGtloqXU9+IS8EEppGlnkKn1jGh+nDa3DE4/66rCaYuy5NvY9GmK4Rna89zaN+pMPN7LyjlXjrhlYnb9CPbVLS/4JQhOFIClrcr44S9i0Kg1OtgKfpkCcu70o/mEoffGgjjTh8CtG0SPFOb3eDoIB0qm/DaECFbZkA0qUd0hAmYkfa4AjMNQ== 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=FvN0KM5JZaCB/g6dIwzBKwJnmR8zfYpNq9LmEndfKC8=; b=PCrC7wMSHZiAUcV6ceQBm6meYEX41SJ0/NgIybCxKnCJSoKaRdxsxgAsZRST/Im69iSS+dr6yb5ReTGOQZJZbXVkgWajB3rYyxp2GuNWgyWyI5Wt2+eGSJWJhIKyXK8rP61uW9Yj4oPV7bBSDB6/zCPaw+LwYkl7wHG0BNRVouihjIdI0i4CuYym2YGkoS8LJX/tQByNPzkgKcs3J0eZl4GTS1ZTfzqsVTeaNizR3jSR+vhZZ+EATo7dyDwM5LbNcvb3giFyUifJ0rfccgLEPUJRk6qSQWwUoCyKWUVRoJagtbg9qkGcrk3R0sQGoE7uG1/cel3TAn1XgXXRZ9Xa3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) 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=FvN0KM5JZaCB/g6dIwzBKwJnmR8zfYpNq9LmEndfKC8=; b=U056GKUG5VNd4kNmigr8fYdKg8dTF98ho9tl1k7bYzAmM4HXmesP3zKdWtHKSIdDYM6QOpOaMbJOo6rbyJoRWIqHq2ufm0gd2XusQ08D3grn8bmbbgGthhvWdHIztqcM8ETIiyvdidQYnb0IRdixl67XxHkCBvXFZ6ZXYwKJfVn+Rgsz/SXSQx86jRatIHQh861kxwQ9iYGWvOTD/i5QJFWeU8RnaNsX9SeIr+cunxt7XRbv+4OXkhlYFVQBflfZEtKw6J+PECPfjVaNTaQWlT2hobhwraSR5xZNKiCxix6F3nGSeyIjusT0p+Dc9PteBNHIUBlJA35mT4U+zJVpbA== Received: from DM5PR12MB2343.namprd12.prod.outlook.com (2603:10b6:4:b3::38) by DM5PR12MB1945.namprd12.prod.outlook.com (2603:10b6:3:10f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Tue, 18 Jan 2022 15:31:01 +0000 Received: from DM3PR12CA0046.namprd12.prod.outlook.com (2603:10b6:0:56::14) by DM5PR12MB2343.namprd12.prod.outlook.com (2603:10b6:4:b3::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.12; Tue, 18 Jan 2022 15:30:52 +0000 Received: from DM6NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:0:56:cafe::e) by DM3PR12CA0046.outlook.office365.com (2603:10b6:0:56::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10 via Frontend Transport; Tue, 18 Jan 2022 15:30:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) 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.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by DM6NAM11FT013.mail.protection.outlook.com (10.13.173.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4888.9 via Frontend Transport; Tue, 18 Jan 2022 15:30:51 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 18 Jan 2022 15:30:51 +0000 Received: from nvidia.com (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_CBC_SHA384) id 15.2.986.9; Tue, 18 Jan 2022 07:30:48 -0800 From: Alexander Kozyrev To: CC: , , , , , , , , Subject: [PATCH v2 01/10] ethdev: introduce flow pre-configuration hints Date: Tue, 18 Jan 2022 17:30:18 +0200 Message-ID: <20220118153027.3947448-2-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220118153027.3947448-1-akozyrev@nvidia.com> References: <20211006044835.3936226-1-akozyrev@nvidia.com> <20220118153027.3947448-1-akozyrev@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 32a9bb6b-e166-44b1-fa81-08d9da9782db X-MS-TrafficTypeDiagnostic: DM5PR12MB2343:EE_|DM5PR12MB1945: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: JrNItxdwq4DwQEmMu7yjGjxbBg28QdrhNSD1h3lcuFi1tqZiGf28m1W3qaQFyXvrVblIILBBlHYfzr3AFAoFMaTKCJGrAIrYzu5bi4bDAzotC9lvKsT/0zbDFWYUnb53E6xRVUJxoGZRnQfWUuX7OgaU8goVHtJ/7FiYQcqf1a3UPrLsBH7fsHoiK1BomHGYegxUwLRgdwQF1cpNUjZr7NnRWBj/4TXkpDs3V5x1FUmX/ugmFuxvwmvywwhx8XXC/i7NcjYV7caKJ0ZoShjEFvRKN44/0wIeeVX7BPsCGkSJ+N7ESM32k6pXaoNy+YGdFYar/g4pRarn87VMmY3H4CR68bShPSbs6h2aKmWrSZnMMQRYKlllzibGzlvqRkp9NbKR5gYN4TucBPcjyYMVY/SwGdKF9TlOvzyNToDpH288zEDFOr9QIUgRyeD9e0tM4/B/IubLesNYTvArFybEkD5hStc95juDnpTwdTw+kdQceJgRuyUzTNAAfriwAjtXQUF42XrQiw+FO8d2o4vTlr2GUUJxRSlwwBs36Og9kZHAMUblcdAcT+3HU4z7GjLHEx+7pgMEKQ7WQdmzn8PTgrQbgbknXdy1j6O5351Zn+mVoST75TldwHf1jqz7UXHeB5PqtTn5W+Z63baeGIsySed4eNTZYmLfE3bxNno7THtp4e4NPlOkiAQl9SKuISKHxNPIa/OOPgpzqvl2Dt4j+NLf2iIykAQpLdBUnCWUsk9KC5tvXGSc9HAWztXjjmH9OhDUN1RxEFrsHhnIpMcuR+1nC8dmsqlEfPnP0rTLSx4= X-Forefront-Antispam-Report: CIP:12.22.5.235; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(4636009)(36840700001)(40470700002)(46966006)(54906003)(83380400001)(2906002)(2616005)(86362001)(8936002)(40460700001)(47076005)(336012)(426003)(4326008)(82310400004)(70586007)(5660300002)(36860700001)(6916009)(356005)(8676002)(70206006)(316002)(7696005)(26005)(6666004)(186003)(16526019)(81166007)(55016003)(1076003)(6286002)(508600001)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 15:30:51.8913 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 32a9bb6b-e166-44b1-fa81-08d9da9782db 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.235]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1945 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. Signed-off-by: Alexander Kozyrev --- doc/guides/prog_guide/rte_flow.rst | 37 +++++++++++++++ doc/guides/rel_notes/release_22_03.rst | 2 + lib/ethdev/rte_flow.c | 20 ++++++++ lib/ethdev/rte_flow.h | 63 ++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 5 ++ lib/ethdev/version.map | 3 ++ 6 files changed, 130 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index b4aa9c47c2..86f8c8bda2 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. +Rules management configuration +------------------------------ + +Configure flow rules management. + +An application may provide some hints at the initialization phase about +rules management 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 rules 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); + +Arguments: + +- ``port_id``: port identifier of Ethernet device. +- ``port_attr``: port attributes for flow management library. +- ``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. + .. _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 16c66c0641..71b3f0a651 100644 --- a/doc/guides/rel_notes/release_22_03.rst +++ b/doc/guides/rel_notes/release_22_03.rst @@ -55,6 +55,8 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* ethdev: Added ``rte_flow_configure`` API to configure Flow Management + library, allowing to pre-allocate some resources for better performance. Removed Items ------------- diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index a93f68abbc..5b78780ef9 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -1391,3 +1391,23 @@ 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_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..e145e68525 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -4853,6 +4853,69 @@ 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. + * + * Flow engine port configuration attributes. + */ +__extension__ +struct rte_flow_port_attr { + /** + * Version of the struct layout, should be 0. + */ + uint32_t version; + /** + * Number of counter actions pre-configured. + * If set to 0, PMD will allocate counters dynamically. + * @see RTE_FLOW_ACTION_TYPE_COUNT + */ + uint32_t nb_counters; + /** + * Number of aging actions pre-configured. + * If set to 0, PMD will allocate aging dynamically. + * @see RTE_FLOW_ACTION_TYPE_AGE + */ + uint32_t nb_aging; + /** + * Number of traffic metering actions pre-configured. + * If set to 0, PMD will allocate meters dynamically. + * @see RTE_FLOW_ACTION_TYPE_METER + */ + uint32_t nb_meters; +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Configure flow rules module. + * To pre-allocate resources as per the flow port attributes + * this configuration function must be called before any flow rule is created. + * Must be called only after Ethernet device is configured, but may be called + * before or after the device is started as long as there are no flow rules. + * No other rte_flow function should be called while this function is invoked. + * This function can be called again to change the configuration. + * Some PMDs may not support re-configuration at all, + * or may only allow increasing the number of resources allocated. + * + * @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..5f722f1a39 100644 --- a/lib/ethdev/rte_flow_driver.h +++ b/lib/ethdev/rte_flow_driver.h @@ -152,6 +152,11 @@ 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_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 c2fb0669a4..7645796739 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -256,6 +256,9 @@ EXPERIMENTAL { rte_flow_flex_item_create; rte_flow_flex_item_release; rte_flow_pick_transfer_proxy; + + # added in 22.03 + rte_flow_configure; }; INTERNAL { -- 2.18.2