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 BBD15A034E; Sat, 19 Feb 2022 05:12:18 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 123574114B; Sat, 19 Feb 2022 05:12:13 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2089.outbound.protection.outlook.com [40.107.223.89]) by mails.dpdk.org (Postfix) with ESMTP id C8CC64114B for ; Sat, 19 Feb 2022 05:12:11 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FdkYmV0xWENaNvNJup1/fGRGje8mL8Cs/MvP9+EdaHAy+GyHg2A3gQL9XfxAyqJvdeVwdxUiFDxzOlKZMzHJN2fqz1x/9ckU73RX2SjUrlzujuYR7pL69vaxAXUgDSO5Gq8VMLtEjp4OUMaChgpyUHgatJ/VRgdFoY5YXCL6Qv8sJMBknTlxGCPtC2kbfRrxi3rTyg4Z3i9mRt2m7GJBNMLAFlxhpC8jXbMbpw0YXzFxDGSPqL4MzjpvF/xKvkURUbe94lu0VPsOYgVF+E1K3gGuyuTjEph9QKDpt/F7QZKqzbJRD7SiMQpq5w+GEc8NX08DvM/gtFFixS7M0vkjWg== 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=UAPbBBk9Vf59LbcnsDPBz9S05kMkMGCCKymhJzi4j8I=; b=D1z0gw7WMmxxyrfRTLoO05QVTtA0NL+yH2dKinCOYNSyKkKA1ybImPSaUzLDar0Qol84AOI+Qfn9sAhb4iQasAwyjXnDRjQ3l8Khqazcs2YjPTY4ovN9fZQZGalsCANIE6iGWADitqcSpbOP63zhW5TN/MEgGjPyz5wN11XwuTWgo5SByZs8afP9dpo4BYQhLAgYlqY8Vj7i5pf4rYJIJpUZn5nXqUvpKG+5+eyye6ZDqD1zNmmhspWq6Q087qTNhLur8NuZYo1nLMiQe5omBKlbxRFlCl662/ZJwqxNHQwZUVPivQXL1Jhmi1ovpYBnfEyLUwPO/OOfz4um4ZWv0g== 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=UAPbBBk9Vf59LbcnsDPBz9S05kMkMGCCKymhJzi4j8I=; b=nCRpfIuPeZZ3cVSTA8gd10/A7OWfBY6ScuzjOuKjOVGHI1YqiAY/sacCFmmkFDRwXs4Z/W2WS2uxGWynZtAo59fR+TFK1ArQwY0wLMyVX2T+6BXR8CQBk21FJ3s+MY/K30dWdvbz1GZh2QJ/gfusf5N3n4ABho3ksjabVsgdNTf7mYPxecRY1PcL5P2tENmAuCZCEby2D7wN2TpInNqMuTkalIKhN362m8kMoLWq3FUBGdjt9vn8t5eaZ3Sh2VWGceYvS8obIp9iSy22WxlLk50jQl0PuF1th7PxkVHRx2h7IPMf7ALove+0Hb5l5hRtGU+S0wT/AZPFxTIDgV7+zg== Received: from DM4PR12MB5230.namprd12.prod.outlook.com (2603:10b6:5:399::11) by BYAPR12MB2726.namprd12.prod.outlook.com (2603:10b6:a03:66::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Sat, 19 Feb 2022 04:12:09 +0000 Received: from BN0PR07CA0017.namprd07.prod.outlook.com (2603:10b6:408:141::31) by DM4PR12MB5230.namprd12.prod.outlook.com (2603:10b6:5:399::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16; Sat, 19 Feb 2022 04:12:08 +0000 Received: from BN8NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:408:141:cafe::a7) by BN0PR07CA0017.outlook.office365.com (2603:10b6:408:141::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14 via Frontend Transport; Sat, 19 Feb 2022 04:12:07 +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 BN8NAM11FT003.mail.protection.outlook.com (10.13.177.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4995.15 via Frontend Transport; Sat, 19 Feb 2022 04:12:06 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sat, 19 Feb 2022 04:12:05 +0000 Received: from pegasus01.mtr.labs.mlnx (10.126.230.35) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Fri, 18 Feb 2022 20:12:02 -0800 From: Alexander Kozyrev To: CC: , , , , , , , , , Subject: [PATCH v7 01/11] ethdev: introduce flow engine configuration Date: Sat, 19 Feb 2022 06:11:34 +0200 Message-ID: <20220219041144.2145380-2-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220219041144.2145380-1-akozyrev@nvidia.com> References: <20220212041930.1516767-1-akozyrev@nvidia.com> <20220219041144.2145380-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 drhqmail201.nvidia.com (10.126.190.180) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a8ec12a2-1528-4cd6-c62f-08d9f35dfde0 X-MS-TrafficTypeDiagnostic: DM4PR12MB5230:EE_|BYAPR12MB2726:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mvlEI0x35udnk8EI7ivK0QITfwOdWXnkt4YSj5MPPvyiqwLlYuGFcZzSGa1XkuVlgj2K+MOLqr/gHinWoQK4gsc/fLO4rIiF/x7ORHfRJ6mGWygT4fx6E8AnmM1uRSVFiavnKnC8T26kyOqshbx8FiXEtZatFnZfqaOHAg5RJuXQZs5hDdNu+vxfTsclVqNXwOpopA51dejSPhKQYixLJ05hL7O3NWEWR9orW02iErRuk2Kd6Mxz5wdW2X69CPqjVu17JO6IDl90VYs4kZ9YI4PKLgWSxuyG2NPB5xZkSzXUIsn4zYsatcsOz1eV3GrhXOMWuw94e90uqV1Qg6BaDICn5owdQhmF4J6u+YbyfgDGcyU0+wJXOAlVKQsDVSndQmDEIfjepvAfd6PLTw21D0kezRo49ZSvcV5aygL663ttxMnqfZ0X9lXBtvGkUee/FN2VNKuafDOcGVBbOepIf41Vk3cCSgqZiO/WflK15lGH115pviuMMtn7AqUg0TmVaWxdBE+XQH9F5ynCvIS6fPkMDotN1igrCk/fMrvbb0HYZReQlnXBKYfY/CZQu5aiqzsdQPpCTwtzzp0ISDBLl9AolX/uLd0HX+Hz1nMV7Kwg6MpGPzx1vbbzxNX+9B4xcE5cO3PBGLQ33ip/gT1yTduUqY70LMQjVHLXpNDXbm7t3teQChgiQ654ndYOFDlhC/WIWV/dewv1MeCmk82HYg== 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:ErrorRetry; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(30864003)(5660300002)(7416002)(2906002)(8936002)(2616005)(4326008)(82310400004)(8676002)(6666004)(70206006)(70586007)(47076005)(356005)(36860700001)(83380400001)(86362001)(40460700003)(186003)(16526019)(26005)(1076003)(81166007)(426003)(336012)(508600001)(6916009)(316002)(54906003)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2022 04:12:06.3229 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a8ec12a2-1528-4cd6-c62f-08d9f35dfde0 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: BN8NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2726 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 | 36 ++++++++ doc/guides/rel_notes/release_22_03.rst | 6 ++ lib/ethdev/ethdev_driver.h | 7 +- lib/ethdev/rte_flow.c | 69 +++++++++++++++ lib/ethdev/rte_flow.h | 111 +++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 10 +++ lib/ethdev/version.map | 2 + 7 files changed, 240 insertions(+), 1 deletion(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 0e475019a6..c89161faef 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -3606,6 +3606,42 @@ 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 engine configuration and allocates +requested resources beforehand to avoid costly allocations later. +Expected number of resources in an application allows PMD to prepare +and optimize NIC hardware configuration and 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 the number of available resources can be retrieved via +``rte_flow_info_get()`` API. + +.. 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 ff3095d742..eceab07576 100644 --- a/doc/guides/rel_notes/release_22_03.rst +++ b/doc/guides/rel_notes/release_22_03.rst @@ -99,6 +99,12 @@ New Features The information of these properties is important for debug. As the information is private, a dump function is introduced. +* ** 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 available resources. + * **Updated AF_XDP PMD** * Added support for libxdp >=v1.2.2. diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index 6d697a879a..06f0896e1e 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -138,7 +138,12 @@ struct rte_eth_dev_data { * Indicates whether the device is configured: * CONFIGURED(1) / NOT CONFIGURED(0) */ - dev_configured : 1; + dev_configured:1, + /** + * Indicates whether the flow engine is configured: + * CONFIGURED(1) / NOT CONFIGURED(0) + */ + flow_configured:1; /** Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0) */ uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT]; diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 7f93900bc8..ffd48e40d5 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -1392,3 +1392,72 @@ 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 (port_info == NULL) { + RTE_FLOW_LOG(ERR, "Port %"PRIu16" info is NULL.\n", port_id); + return -EINVAL; + } + if (dev->data->dev_configured == 0) { + RTE_FLOW_LOG(INFO, + "Device with port_id=%"PRIu16" is not configured.\n", + port_id); + return -EINVAL; + } + 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); + int ret; + + dev->data->flow_configured = 0; + if (port_attr == NULL) { + RTE_FLOW_LOG(ERR, "Port %"PRIu16" info is NULL.\n", port_id); + return -EINVAL; + } + if (dev->data->dev_configured == 0) { + RTE_FLOW_LOG(INFO, + "Device with port_id=%"PRIu16" is not configured.\n", + port_id); + return -EINVAL; + } + if (dev->data->dev_started != 0) { + RTE_FLOW_LOG(INFO, + "Device with port_id=%"PRIu16" already started.\n", + port_id); + return -EINVAL; + } + if (unlikely(!ops)) + return -rte_errno; + if (likely(!!ops->configure)) { + ret = ops->configure(dev, port_attr, error); + if (ret == 0) + dev->data->flow_configured = 1; + return flow_err(port_id, ret, 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 765beb3e52..cdb7b2be68 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -43,6 +43,9 @@ extern "C" { #endif +#define RTE_FLOW_LOG(level, ...) \ + rte_log(RTE_LOG_ ## level, rte_eth_dev_logtype, "" __VA_ARGS__) + /** * Flow rule attributes. * @@ -4872,6 +4875,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 resources. + * The zero value means a resource is not supported. + * + */ +struct rte_flow_port_info { + /** + * Maximum number of counters. + * @see RTE_FLOW_ACTION_TYPE_COUNT + */ + uint32_t max_nb_counters; + /** + * Maximum number of aging objects. + * @see RTE_FLOW_ACTION_TYPE_AGE + */ + uint32_t max_nb_aging_objects; + /** + * Maximum number traffic meters. + * @see RTE_FLOW_ACTION_TYPE_METER + */ + uint32_t max_nb_meters; +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Get information about flow engine 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 resources settings. + * The zero value means on demand resource allocations only. + * + */ +struct rte_flow_port_attr { + /** + * Number of counters to configure. + * @see RTE_FLOW_ACTION_TYPE_COUNT + */ + uint32_t nb_counters; + /** + * Number of aging objects to configure. + * @see RTE_FLOW_ACTION_TYPE_AGE + */ + uint32_t nb_aging_objects; + /** + * Number of traffic meters to configure. + * @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 d5cc56a560..0d849c153f 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -264,6 +264,8 @@ EXPERIMENTAL { rte_eth_ip_reassembly_capability_get; rte_eth_ip_reassembly_conf_get; rte_eth_ip_reassembly_conf_set; + rte_flow_info_get; + rte_flow_configure; }; INTERNAL { -- 2.18.2