From patchwork Wed Oct 6 04:48:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 100557 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 61C5CA0C45; Wed, 6 Oct 2021 06:49:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1DB8E40685; Wed, 6 Oct 2021 06:49:01 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2071.outbound.protection.outlook.com [40.107.244.71]) by mails.dpdk.org (Postfix) with ESMTP id 87E1A40140 for ; Wed, 6 Oct 2021 06:48:59 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YmNxlFX0mb70YUfGv+CV9f4CtfS5Ufrll76to3NnzdXkgj5XCkuKTjFmN9hNkH0L5tbSmf8WvRuriXH9dqIhyZnzJjnckTR1SPGzoqR7uM5HI9C9LNMzYDn8e46AIcJV6nY7lJ6ENt1GIRM8NejAzBdhBuk6hAbCGuWLq35FpUccPazlj2PuRJaRCQ9uHxL7SJkL8nb5VHfVdKT6aBLwMl3PXP6Nuesnu0oyzURO1xoSNiyDqLdUVeOQKqeiQ/n+5wbAa7svQrZua32Aw9c8vyU2Mcx/fF5xsAFBEeKj1cwHIxB6UVeK77jKaQBMa9f8b3/DBG/8geneG82iLn7Cug== 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=kMFXKh3jQ23AcrqdXxPz2YMiLitUoXXFYK/+YdCvnTw=; b=U2CWKhljA/Dr7SNqti4xaNzLGW0CIZ5bldjvv5spQAQznzdQ0yLxfQXgWRp6n7vNwLnYCJEYxhc0RnXU6/QFDboJsShtl2O5MzSAHuWujVTh8nJHqJABTCEKDlVwMWaYRHKG4Kiq4Y7ToP2Aq5dBoHpfMtali1S7JBqbe2jdFScK1dPxaSvkCQ7V3JlfGMcOx9xzOLC3Eq+5dbLZhpkqaCzhOgmqrD0bRDr9oQrFvm/duGpQMYVRmiC8KhzwPpqae58SCZwqsK3wmaK4w/UCp5O6+PEEnzDIvyLJlYisLera15uaHvsOrDxSdThtHNT+ZqAiYni+A0yk4SQungTBPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=kMFXKh3jQ23AcrqdXxPz2YMiLitUoXXFYK/+YdCvnTw=; b=bEKoZGEs5x/Fp0u8WykOEdVTXwr4zP1+UAKosbjUwSXqa54eY5ubFlt3KYnThX1AKRfubMz5yRMJ1QoBo+PH29sU3Xt5NLiCm2HJwbca9eOrT1s3QxfKPZKNIH3+HtpuriCl+msUQHuPI/+F130Z8FzkmHPYxcDkUxnjDgSxJN41nECNwYgZ+pQy0I5bihLQQEsZiMXQuyzkddOG/fXwlw98hL3AtY+4ko7KBOFvVV4S5MPp/wJaEglWMmoVx0bkghklJkaSz8Lnm6HZ7Hx3qgBlqGPxU1QHDj4zCijb/dD2uRUsSlyXyZv0Cb9v2LE8fkFmT/OGhmumP4ocrifjPQ== Received: from BN6PR2001CA0018.namprd20.prod.outlook.com (2603:10b6:404:b4::28) by MN2PR12MB4390.namprd12.prod.outlook.com (2603:10b6:208:26e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Wed, 6 Oct 2021 04:48:57 +0000 Received: from BN8NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:404:b4:cafe::e8) by BN6PR2001CA0018.outlook.office365.com (2603:10b6:404:b4::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Wed, 6 Oct 2021 04:48:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT030.mail.protection.outlook.com (10.13.177.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4587.18 via Frontend Transport; Wed, 6 Oct 2021 04:48:56 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 6 Oct 2021 04:48:53 +0000 From: Alexander Kozyrev To: CC: , , , , , , , , Date: Wed, 6 Oct 2021 07:48:33 +0300 Message-ID: <20211006044835.3936226-2-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20211006044835.3936226-1-akozyrev@nvidia.com> References: <20211006044835.3936226-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3e9f10ea-0898-4a21-6c06-08d988849b17 X-MS-TrafficTypeDiagnostic: MN2PR12MB4390: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,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: hqVB0yC40xaduiDuaPhpd++QLtNMsI4FrgtRWypaJ5WNIX8Yfw7Dk0hmYhZXk9unjeSqXffSiC50Dh/UK2zKaZxw4GrmRJLdJoLLM4Skp1bhc7Art++s7FV809m/zkIinnndgYfF9fEdNxtwPuEjB8h00QfuWAVBD3YLETXRhiMQT286ZUUCw9bTm0QBaKoyIjluvIddoohYeTgiUu0223gl0mq2BsRztB5zJ8wXCgwHwIjygScz/QGlZTFqt9cOAZjKLVe2BduF16J9AZyVrU4jFkvpM2D4PjW2R9R39AH4d0UxMwXH8JjN5UJif5y5bSV3d0AkFqv8P7f6DmY+6a5ld3NdcgEpHCL0sMRyvpdg1i1Xqx1Us+P8Ts0HRuyAHTme8OcK/d6b7kAcODmiz1BUO9atiGHgkDiBwQpHbIRp4SMDiUDjjtiW+05dbrq11+24uU+I66cXjNWkQEbPikDuEFdlqg4QooSDACFF6hSdiPjfbb07r7B01e1+02Alm/KGpQcG52T26PId722EEyL4bGMEhCf7dRR5K1hcpBwQM5ChSOvLJGTbRCnBPnSa1LiMJ+llYJQGxtWnQRZzHUhVWL5Y3Iyir2WbaBn0Ra+Hb3ytWkYcnvU/SGQ19vuaOIdAzIU7RFnzGDeAsvg2N1A0I6gDc88/2DotNG+kwkC9RsOfMS5oM8CDMhVXXGtp9c3nPLfi36PYmdWLcZKB/w== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(508600001)(8676002)(5660300002)(86362001)(1076003)(36860700001)(70206006)(47076005)(6286002)(83380400001)(2906002)(6666004)(36756003)(82310400003)(2616005)(54906003)(26005)(7636003)(6916009)(70586007)(55016002)(7696005)(8936002)(426003)(336012)(316002)(16526019)(4326008)(186003)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2021 04:48:56.7000 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e9f10ea-0898-4a21-6c06-08d988849b17 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4390 Subject: [dpdk-dev] [PATCH 1/3] ethdev: introduce flow pre-configuration hints 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 Sender: "dev" 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. Signed-off-by: Alexander Kozyrev Suggested-by: Ori Kam --- lib/ethdev/rte_flow.h | 70 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 7b1ed7f110..c69d503b90 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -4288,6 +4288,76 @@ rte_flow_tunnel_item_release(uint16_t port_id, struct rte_flow_item *items, uint32_t num_of_items, struct rte_flow_error *error); + +/** + * Flow engine configuration. + */ +__extension__ +struct rte_flow_port_attr { + /** + * Version of the struct layout, should be 0. + */ + uint32_t version; + /** + * Memory size allocated for the flow rules management. + * If set to 0, memory is allocated dynamically. + */ + uint32_t mem_size; + /** + * 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; + /** + * Resources reallocation strategy. + * If set to 1, PMD is not allowed to allocate more resources on demand. + * An application can only allocate more resources by calling the + * configure API again with new values (may not be supported by PMD). + */ + uint32_t fixed_resource_size:1; +}; + +/** + * @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. + * 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 From patchwork Wed Oct 6 04:48:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 100559 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 22FA8A0C45; Wed, 6 Oct 2021 06:49:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A253F413BF; Wed, 6 Oct 2021 06:49:04 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2057.outbound.protection.outlook.com [40.107.94.57]) by mails.dpdk.org (Postfix) with ESMTP id D706F413B7 for ; Wed, 6 Oct 2021 06:49:02 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U0XsF6TSkOZ5C7Dn6OIcgw/9B057UVBBxFK8FlOufcIGClVAIEsRaHW7Nl0oZXUyMgEqO1fqVyy1jXuc2YiTPhYCTaHisS0aJTu3j1ClLV/yUdbfO4PTkE1D1SXSBLUeKzhRsYNwm3cwvdiGG6uilpedoIMS0ulbn8CgU4xNaUU5e25ahcB44NplMjupxpNAuw6p8iJEnFqTtA+Vy6xclnwm/H9LbBw9K073vY32ZLi7dUVziW3eK4iAyBEu8w+ngWJoe3ihBQG5RtnAKKZ5rHF5LOqhu1hv5s6+66Znskmg1Em+wDVaDQnQqiaXpk6T6MipZpa+xfyLMIeC7tIAeg== 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=3zexaPHokFKDxS4cE9KItiY9yF05uhHzi7Z3zJbWO1A=; b=SFq6E0lcj6lAM4FTsa6+sUB70iaAeDkjiLdVnkpk5cjGL3h2+FOefVAjkQqpHTf832MMZdXUEcO7+cy6D0Y6rQftMGxj8xrctCNEVacHTL9jp0MWX/Dd4jb+UBaEqSWccrPJnmzA3yhFHR9fiKspH2mKJpnX6FxqftCtcJ5tGcklwY6U+srv33QLwg+6eFGv0rNjPE9EqPtaqxU7KGWF2mYcM5m2uKsKK4C5BlPeuu3tNy5QCD2be6EYO+8+qeYFyh7cobo9IqncRpdeOqewsi2gNkNCbd78sKeS7emhmLf0VsmRu3W2X25z5nP5b5ImZ71nfoWFFDG978Nfx1XXkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=3zexaPHokFKDxS4cE9KItiY9yF05uhHzi7Z3zJbWO1A=; b=SsvqsEPm9HAGkplJ0r9VaRFnyudtNd+5uaz+V2AtK85N37rFOBxK9IpLxz584EY1+tpRdIPEOYDNAuu5xkkyB3KSxwBcMuHMgNe60Ngje5t4aoNVsYkqru3/1bL9RUWsq9Yrv4eMy4O8VTKsmPfbN0XsBJq0dgawDH5OxXdoKkFOCw/2AeACdkfJTf58It1qXtPTCvRAqA3ZxTXLb/beY1KjaoBYlxUYGgVwV7/CaRrGv075VvJVmqLU1kXPnYmupssu02MF/KGEQAHsguVNgBh0Vmhz11taVU4un1L3QnrHraCy/iNs1+CAgnw8zsMEmPHw/L3jD7n5UZpSUxPDHQ== Received: from BN9PR03CA0318.namprd03.prod.outlook.com (2603:10b6:408:112::23) by DM6PR12MB4603.namprd12.prod.outlook.com (2603:10b6:5:166::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Wed, 6 Oct 2021 04:49:00 +0000 Received: from BN8NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:408:112:cafe::ef) by BN9PR03CA0318.outlook.office365.com (2603:10b6:408:112::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.22 via Frontend Transport; Wed, 6 Oct 2021 04:49:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT046.mail.protection.outlook.com (10.13.177.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4587.18 via Frontend Transport; Wed, 6 Oct 2021 04:48:59 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 6 Oct 2021 04:48:56 +0000 From: Alexander Kozyrev To: CC: , , , , , , , , Date: Wed, 6 Oct 2021 07:48:34 +0300 Message-ID: <20211006044835.3936226-3-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20211006044835.3936226-1-akozyrev@nvidia.com> References: <20211006044835.3936226-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 17948f5f-9abc-4f76-6037-08d988849cf6 X-MS-TrafficTypeDiagnostic: DM6PR12MB4603: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1hH0KptwSRInI6obYJlGyF6QYXG5kPYqOjdvCbIRWqrlefDiuQQId1vBV82N8Bcqr30l8/o+mV31Qi7V5aZfYwb8f+rINrUndmsKdA2LaWKB695qn8hnpcjJtT2IWdYSyYk9QZ2rtEgM38D7roivDZLPV+7lhWZZpAHkXusL3/xRXc7NTvchMeb0+dPLxIwECw+Cj35TRJFnDsSVsvm/8e+weG1DRf3xFrcLQR6kkabRfsDLVWiGFlF3dlInZ43pQ488hgyQ47bt8Qo1RHp6QIBMvwPv0DlHPb5U/4OJr42B+DOdxmq5j10tXeCWVD2HZY6/zEitBBk5rPoK7kDYYbL2cyMO2MWyNJrbqWraks97WAbO5UD8Aqeiew9Tptsd2ovaCgUTOSgDr45S5wKT0bVskXdq8ngWbnhn0mcqeU5eChQeS4xxyUCUfd0NzHyvS8sHSP7VaziirhVV7ZZU6NiJRTIADRVXtrdC798fSgo0pRT4FVQ34QPOl59kVLPxRmMRIVShZ7gbkanl1mh0NwaIEoszpYGnaMZv/gZCtt9MvULrkPbhFIM41XHzA+H++tA6urU9eyqZBF5rSh9GNd8mxNJS9RGu+V9MbypuZRLnpFWZM8ZxKwT38EEymaROSJ2OauSNa33E6xzoA4d4vIHgNR/C2cGTI4MGjmwFDmTKPKVVSOkhPkPyTpTz315W3eK21hp40GlL90IXHCk9Og== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(54906003)(47076005)(36756003)(36860700001)(26005)(83380400001)(86362001)(16526019)(55016002)(7696005)(6286002)(186003)(508600001)(2906002)(6916009)(6666004)(356005)(70586007)(70206006)(426003)(30864003)(336012)(1076003)(5660300002)(4326008)(8936002)(8676002)(316002)(82310400003)(2616005)(7636003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2021 04:48:59.7703 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17948f5f-9abc-4f76-6037-08d988849cf6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4603 Subject: [dpdk-dev] [PATCH 2/3] ethdev: add flow item/action templates 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 Sender: "dev" Treating every single flow rule as a completely independent and separate entity negatively impacts the flow rules insertion rate. Oftentimes in an application, many flow rules share a common structure (the same item mask and/or action list) so they can be grouped and classified together. This knowledge may be used as a source of optimization by a PMD/HW. The item template defines common matching fields (the item mask) without values. The action template holds a list of action types that will be used together in the same rule. The specific values for items and actions will be given only during the rule creation. A table combines item and action templates along with shared flow rule attributes (group ID, priority and traffic direction). This way a PMD/HW can prepare all the resources needed for efficient flow rules creation in the datapath. To avoid any hiccups due to memory reallocation, the maximum number of flow rules is defined at table creation time. The flow rule creation is done by selecting a table, an item template and an action template (which are bound to the table), and setting unique values for the items and actions. Signed-off-by: Alexander Kozyrev Suggested-by: Ori Kam --- lib/ethdev/rte_flow.h | 268 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 268 insertions(+) diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index c69d503b90..ba3204b17e 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -4358,6 +4358,274 @@ int rte_flow_configure(uint16_t port_id, const struct rte_flow_port_attr *port_attr, struct rte_flow_error *error); + +/** + * Opaque type returned after successfull creation of item template. + * This handle can be used to manage the created item template. + */ +struct rte_flow_item_template; + +__extension__ +struct rte_flow_item_template_attr { + /** + * Version of the struct layout, should be 0. + */ + uint32_t version; + /* No attributes so far. */ +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Create item template. + * The item template defines common matching fields (item mask) without values. + * For example, matching on 5 tuple TCP flow, the template will be + * eth(null) + IPv4(source + dest) + TCP(s_port + d_port), + * while values for each rule will be set during the flow rule creation. + * The order of items in the template must be the same at rule insertion. + * + * @param port_id + * Port identifier of Ethernet device. + * @param[in] attr + * Item template attributes. + * @param[in] items + * Pattern specification (list terminated by the END pattern item). + * The spec member of an item is not used unless the end member is used. + * @param[out] error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * Handle on success, NULL otherwise and rte_errno is set. + */ +__rte_experimental +struct rte_flow_item_template * +rte_flow_item_template_create(uint16_t port_id, + const struct rte_flow_item_template_attr *attr, + const struct rte_flow_item items[], + struct rte_flow_error *error); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Destroy item template. + * This function may be called only when + * there are no more tables referencing this template. + * + * @param port_id + * Port identifier of Ethernet device. + * @param[in] template + * Handle to the template to be destroyed. + * @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_item_template_destroy(uint16_t port_id, + struct rte_flow_item_template *template, + struct rte_flow_error *error); + +/** + * Opaque type returned after successfull creation of action template. + * This handle can be used to manage the created action template. + */ +struct rte_flow_action_template; + +__extension__ +struct rte_flow_action_template_attr { + /** + * Version of the struct layout, should be 0. + */ + uint32_t version; + /* No attributes so far. */ +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Create action template. + * The action template holds a list of action types without values. + * For example, the template to change TCP ports is TCP(s_port + d_port), + * while values for each rule will be set during the flow rule creation. + * + * The order of the action in the template must be kept when inserting rules. + * + * @param port_id + * Port identifier of Ethernet device. + * @param[in] attr + * Template attributes. + * @param[in] actions + * Associated actions (list terminated by the END action). + * The spec member is only used if the mask is 1. + * @param[in] masks + * List of actions that marks which of the action's member is constant. + * A mask has the same format as the corresponding action. + * If the action field in @p masks is not 0, + * the corresponding value in an action from @p actions will be the part + * of the template and used in all flow rules. + * The order of actions in @p masks is the same as in @p actions. + * In case of indirect actions present in @p actions, + * the actual action type should be present in @p mask. + * @param[out] error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * handle on success, NULL otherwise and rte_errno is set. + */ +__rte_experimental +struct rte_flow_action_template * +rte_flow_action_template_create(uint16_t port_id, + const struct rte_flow_action_template_attr *attr, + const struct rte_flow_action actions[], + const struct rte_flow_action masks[], + struct rte_flow_error *error); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Destroy action template. + * This function may be called only when + * there are no more tables referencing this template. + * + * @param port_id + * Port identifier of Ethernet device. + * @param[in] template + * Handle to the template to be destroyed. + * @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_action_template_destroy(uint16_t port_id, + const struct rte_flow_action_template *template, + struct rte_flow_error *error); + + +/** + * Opaque type returned after successfull creation of table. + * This handle can be used to manage the created table. + */ +struct rte_flow_table; + +enum rte_flow_table_mode { + /** + * Fixed size, the number of flow rules will be limited. + * It is possible that some of the rules will not be inserted + * due to conflicts/lack of space. + * When rule insertion fails with try again error, + * the application may use one of the following ways + * to address this state: + * 1. Keep this rule processing in the software. + * 2. Try to offload this rule at a later time, + * after some rules have been removed from the hardware. + * 3. Create a new table and add this rule to the new table. + */ + RTE_FLOW_TABLE_MODE_FIXED, + /** + * Resizable, the PMD/HW will insert all rules. + * No try again error will be received in this mode. + */ + RTE_FLOW_TABLE_MODE_RESIZABLE, +}; + +/** + * Table attributes. + */ +struct rte_flow_table_attr { + /** + * Version of the struct layout, should be 0. + */ + uint32_t version; + /** + * Flow attributes that will be used in the table. + */ + struct rte_flow_attr attr; + /** + * Maximum number of flow rules that this table holds. + * It can be hard or soft limit depending on the mode. + */ + uint32_t max_rules; + /** + * Table mode. + */ + enum rte_flow_table_mode mode; +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Create table. + * Table is a group of flow rules with the same flow attributes + * (group ID, priority and traffic direction) defined for it. + * The table holds multiple item and action templates to build a flow rule. + * Each rule is free to use any combination of item and action templates + * and specify particular values for items and actions it would like to change. + * + * @param port_id + * Port identifier of Ethernet device. + * @param[in] attr + * Table attributes. + * @param[in] item_templates + * Array of item templates to be used in this table. + * @param[in] nb_item_templates + * The number of item templates in the item_templates array. + * @param[in] action_templates + * Array of action templates to be used in this table. + * @param[in] nb_action_templates + * The number of action templates in the action_templates array. + * @param[out] error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * Handle on success, NULL otherwise and rte_errno is set. + */ +__rte_experimental +struct rte_flow_table * +rte_flow_table_create(uint16_t port_id, struct rte_flow_table_attr *attr, + const struct rte_flow_item_template *item_templates[], + uint8_t nb_item_templates, + const struct rte_flow_action_template *action_templates[], + uint8_t nb_action_templates, + struct rte_flow_error *error); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Destroy table. + * This function may be called only when + * there are no more flow rules referencing this table. + * + * @param port_id + * Port identifier of Ethernet device. + * @param[in] table + * Handle to the table to be destroyed. + * @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_table_destroy(uint16_t port_id, struct rte_flow_table *table, + struct rte_flow_error *error); #ifdef __cplusplus } #endif From patchwork Wed Oct 6 04:48:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 100560 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BB0C5A0C45; Wed, 6 Oct 2021 06:49:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C4B88413E2; Wed, 6 Oct 2021 06:49:05 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2071.outbound.protection.outlook.com [40.107.220.71]) by mails.dpdk.org (Postfix) with ESMTP id 095A4413C4 for ; Wed, 6 Oct 2021 06:49:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CtpkW0ngU2YrhzqW3tH0EtfJaw4EZ+RMePZ/DBeoYcnGF43cwN7H0w8bwn66KI4JKGrABYLHRSqwGNXkxvsGqVHmaksY9xHe4loFoORreYGphEspyhyBZ89tdMLKN209e5BSmvRdLygtbLH3uQyJ68tNBaEr2tsJGVefYyZfU223vXUFdNx41ymeTt7zG/fxUjsWHinFTzg5tAOrjX07Sn5cyXacKbgbCqnIAdAWvhzeed3nVyIYXPELQhlaxqRNKeHNogMRdsuNyx9hCAXOl7edbAiKqLxhsA/M7iszOy4USA92b4l8YInuQxclt6uf4hyLAL84dxhzNIxBtv+YnA== 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=sZ+ybkKc+rl6ffUH0347R4s910mVdamhCHiSOZhN8Qg=; b=i5jAt9/wN11KbUZGFrU5Bk4WxXdzxMPT5smEqPNg3uUPI+2uDGiRDHEUTWqgsVTNXThFg5iAlAtsKvGv8+tj9dM3RbI/oR3SWPhI+dK2ASWTQDDZtkie8e3Paqk5bQ3mg01YjOXb+3+T81md6bINQopMdoeSJZjxRSAfdQFOq6f8ujZJ8xwOhDdP15qxeLYoXikyKagwDECArXEn2MIHF88oMKacZa1ie7b4Lnbcu9IoRHC5y5Pab2JKAOoP0jYOh93q5ePSmqERhvXY8hNxLrYaHrQTaT0XUYpc2Rf91LTzmU4vFTkg5EnwBNx1moRFdmN3tY/5txaZnS94s7jK4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=sZ+ybkKc+rl6ffUH0347R4s910mVdamhCHiSOZhN8Qg=; b=AbXn/C91LOxF66I8YAgz2Q88gZuUAcqazVmJnu9z2z97VDjJpphKi7+9TwrP0Meubg1g50ILuCRzK8U6O/WOhRLhMfxAtQTELXnBwS/QgfvU3u6O26pOdRKI1epiRdLvrCmwZ1DJl5EGXxfgqrGtwMvxGaDcZiWn0L77pdvHRVYXKPoX0AehoG9QTOuQ1pLxk63shbH7OsRO2uzNjHEpNgoUpBelhrIj1HcBEueIgyj8M0FMoaXng6gcm0u68zUAN2SWHBpkRa6o86nF2NwF4Tu/G9AT7CQkVTSOwL7JNR7avR3ZLdqPAU5MxaCDDPGpCS6vuBeoBOu21JMQvNWxgA== Received: from BN9PR03CA0323.namprd03.prod.outlook.com (2603:10b6:408:112::28) by DM6PR12MB3612.namprd12.prod.outlook.com (2603:10b6:5:11b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.22; Wed, 6 Oct 2021 04:49:02 +0000 Received: from BN8NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:408:112:cafe::77) by BN9PR03CA0323.outlook.office365.com (2603:10b6:408:112::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.22 via Frontend Transport; Wed, 6 Oct 2021 04:49:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT046.mail.protection.outlook.com (10.13.177.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4587.18 via Frontend Transport; Wed, 6 Oct 2021 04:49:01 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 6 Oct 2021 04:48:59 +0000 From: Alexander Kozyrev To: CC: , , , , , , , , Date: Wed, 6 Oct 2021 07:48:35 +0300 Message-ID: <20211006044835.3936226-4-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20211006044835.3936226-1-akozyrev@nvidia.com> References: <20211006044835.3936226-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 970f1c13-70b5-41c5-8e2c-08d988849e05 X-MS-TrafficTypeDiagnostic: DM6PR12MB3612: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:243; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zNfa5GAhfRoYgCgPTKMA204h1YVemI+j7s+rFHJpYLlpz+7JEoPb93MgcLoR2/iXyOx8OpXSOxPFLdkWJNdEg9x9EwbikoB4xik5BguS9M5bwXTNKvZ8QtQgZSB8RqAoGn3JmtzxTSjbGFAvtwZbt1uzzk6i1EsDALEF5JhKUkvN70V9rA/Gt+odErfMXTyToMLslTF4B7WCYvuPH1Oi1JK+TcuKECFJLKUdhyLmrxFWoSC6i3oEoRvyWESWpWIM8Ut0PQt6CwZ7sBCthLUOT7IMT8hcXIbElRyphQGygTWRnstYPS9c0T3VQ1O6vQBvSb4KdoEdtlM+Ft08kmNQp7+dlsEcuKWMGqKWYdeGD025RAcjfjMQfrxkNj1DuDGq7/mH/zuzQ2Lq/QlSYC+eD2Iw3mhFmmbRIdxbwswlgnI/DkCImJEgV43QNBLOzXDN0ClE++I5t8cTlJDh9LouhMKJHgVk7Q/LC1xhr1kZ9if3IkDgxggxejgGo3M5DhlNeG/G5tnz3QOQqvWCIWQhJhT1KYSHAprrV9s3fz3KRShP5i51tYOOaKsOTSQ5MPYYN0W5zzKVG0vdzpMIXaftzV9XnQTclKOS7fBeRx2/aR4nyc7+Z+yvhZykLNkDVShUWGyNnnCqe9CIRg4ESMl4/5A797D52yLJr7uF+kjoQcYGzPMMABZ1yTjWFnBE/pQNComMiYMVDHMMd6EYkPDPBQ== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(4326008)(26005)(16526019)(508600001)(2616005)(336012)(36756003)(70206006)(70586007)(36860700001)(7636003)(30864003)(356005)(186003)(83380400001)(7696005)(6666004)(86362001)(47076005)(6916009)(5660300002)(316002)(8676002)(6286002)(55016002)(1076003)(2906002)(8936002)(54906003)(426003)(82310400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2021 04:49:01.6228 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 970f1c13-70b5-41c5-8e2c-08d988849e05 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3612 Subject: [dpdk-dev] [PATCH 3/3] ethdev: add async queue-based flow rules operations 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 Sender: "dev" A new, faster, queue-based flow rules management mechanism is needed for applications offloading rules inside the datapath. This asynchronous and lockless mechanism frees the CPU for further packet processing and reduces the performance impact of the flow rules creation/destruction on the datapath. Note that queues are not thread-safe and queue-based operations can be safely invoked without any locks from a single thread. The rte_flow_q_flow_create() function enqueues a flow creation to the requested queue. It benefits from already configured resources and sets unique values on top of item and action templates. A flow rule is enqueued on the specified flow queue and offloaded asynchronously to the hardware. The function returns immediately to spare CPU for further packet processing. The application must invoke the rte_flow_q_dequeue() function to complete the flow rule operation offloading, to clear the queue, and to receive the operation status. The rte_flow_q_flow_destroy() function enqueues a flow destruction to the requested queue. Signed-off-by: Alexander Kozyrev Suggested-by: Ori Kam --- lib/ethdev/rte_flow.h | 288 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+) diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index ba3204b17e..8cdffd8d2e 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -4298,6 +4298,13 @@ struct rte_flow_port_attr { * Version of the struct layout, should be 0. */ uint32_t version; + /** + * Number of flow queues to be configured. + * Flow queues are used for asyncronous flow rule creation/destruction. + * The order of operations is not guaranteed inside a queue. + * Flow queues are not thread-safe. + */ + uint16_t nb_queues; /** * Memory size allocated for the flow rules management. * If set to 0, memory is allocated dynamically. @@ -4330,6 +4337,21 @@ struct rte_flow_port_attr { uint32_t fixed_resource_size:1; }; +/** + * Flow engine queue configuration. + */ +__extension__ +struct rte_flow_queue_attr { + /** + * Version of the struct layout, should be 0. + */ + uint32_t version; + /** + * Number of flow rule operations a queue can hold. + */ + uint32_t size; +}; + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice. @@ -4346,6 +4368,8 @@ struct rte_flow_port_attr { * Port identifier of Ethernet device. * @param[in] port_attr * Port configuration attributes. + * @param[in] queue_attr + * Array that holds attributes for each queue. * @param[out] error * Perform verbose error reporting if not NULL. * PMDs initialize this structure in case of error only. @@ -4357,6 +4381,7 @@ __rte_experimental int rte_flow_configure(uint16_t port_id, const struct rte_flow_port_attr *port_attr, + const struct rte_flow_queue_attr *queue_attr[], struct rte_flow_error *error); /** @@ -4626,6 +4651,269 @@ __rte_experimental int rte_flow_table_destroy(uint16_t port_id, struct rte_flow_table *table, struct rte_flow_error *error); + +/** + * Queue operation attributes + */ +__extension__ +struct rte_flow_q_ops_attr { + /** + * Version of the struct layout, should be 0. + */ + uint32_t version; + /** + * The user data that will be returned on the completion. + */ + void *user_data; + /** + * When set, the requested action must be sent to the HW without + * any delay. Any prior requests must be also sent to the HW. + * If this bit is cleared, the application must call the + * rte_flow_queue_flush API to actually send the request to the HW. + */ + uint32_t flush:1; +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Enqueue rule creation operation. + * + * @param port_id + * Port identifier of Ethernet device. + * @param queue + * Flow queue used to insert the rule. + * @param[in] attr + * Rule creation operation attributes. + * @param[in] table + * Table to select templates from. + * @param[in] items + * List of pattern items to be used. + * The list order should match the order in the item template. + * The spec is the only relevant member of the item that is being used. + * @param[in] item_template_index + * Item template index in the table. + * @param[in] actions + * List of actions to be used. + * The list order should match the order in the action template. + * @param[in] action_template_index + * Action template index in the table. + * @param[out] error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * Handle on success, NULL otherwise and rte_errno is set. + * The rule handle doesn't mean that the rule was offloaded. + * Only completion result indicates that the rule was offloaded. + */ +__rte_experimental +struct rte_flow * +rte_flow_q_flow_create(uint16_t port_id, uint32_t queue, + const struct rte_flow_q_ops_attr *attr, + const struct rte_flow_table *table, + const struct rte_flow_item items[], + uint8_t item_template_index, + const struct rte_flow_action actions[], + uint8_t action_template_index, + struct rte_flow_error *error); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Enqueue rule destruction operation. + * + * This function enqueues a destruction operation on the queue. + * Application should assume that after calling this function + * the rule handle is not valid anymore. + * Completion indicates the full removal of the rule from the HW. + * + * @param port_id + * Port identifier of Ethernet device. + * @param queue + * Flow queue which is used to destroy the rule. + * This must match the queue on which the rule was created. + * @param[in] attr + * Rule destroy operation attributes. + * @param[in] flow + * Flow handle to be destroyed. + * @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_q_flow_destroy(uint16_t port_id, uint32_t queue, + struct rte_flow_q_ops_attr *attr, + struct rte_flow *flow, + struct rte_flow_error *error); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Enqueue indirect rule creation operation. + * @see rte_flow_action_handle_create + * + * @param[in] port_id + * Port identifier of Ethernet device. + * @param[in] queue + * Flow queue which is used to create the rule. + * @param[in] attr + * Queue operation attributes. + * @param[in] conf + * Action configuration for the indirect action object creation. + * @param[in] action + * Specific configuration of the indirect action object. + * @param[out] error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * - (0) if success. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOSYS) if underlying device does not support this functionality. + * - (-EIO) if underlying device is removed. + * - (-ENOENT) if action pointed by *action* handle was not found. + * - (-EBUSY) if action pointed by *action* handle still used by some rules + * rte_errno is also set. + */ +__rte_experimental +struct rte_flow_action_handle * +rte_flow_q_action_handle_create(uint16_t port_id, uint32_t queue, + const struct rte_flow_q_ops_attr *attr, + const struct rte_flow_indir_action_conf *conf, + const struct rte_flow_action *action, + struct rte_flow_error *error); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Enqueue indirect rule destruction operation. + * The destroy queue must be the same + * as the queue on which the action was created. + * + * @param[in] port_id + * Port identifier of Ethernet device. + * @param[in] queue + * Flow queue which is used to destroy the rule. + * @param[in] attr + * Queue operation attributes. + * @param[in] handle + * Handle for the indirect action object to be destroyed. + * @param[out] error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * - (0) if success. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOSYS) if underlying device does not support this functionality. + * - (-EIO) if underlying device is removed. + * - (-ENOENT) if action pointed by *action* handle was not found. + * - (-EBUSY) if action pointed by *action* handle still used by some rules + * rte_errno is also set. + */ +__rte_experimental +int +rte_flow_q_action_handle_destroy(uint16_t port_id, uint32_t queue, + struct rte_flow_q_ops_attr *attr, + struct rte_flow_action_handle *handle, + struct rte_flow_error *error); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Flush all internally stored rules to the HW. + * Non-flushed rules are rules that were inserted without the flush flag set. + * Can be used to notify the HW about batch of rules prepared by the SW to + * reduce the number of communications between the HW and SW. + * + * @param port_id + * Port identifier of Ethernet device. + * @param queue + * Flow queue to be flushed. + * @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_q_flush(uint16_t port_id, uint32_t queue, + struct rte_flow_error *error); + +/** + * Dequeue operation status. + */ +enum rte_flow_q_op_status { + /** + * The operation was completed successfully. + */ + RTE_FLOW_Q_OP_SUCCESS, + /** + * The operation was not completed successfully. + */ + RTE_FLOW_Q_OP_ERROR, +}; + +/** + * Dequeue operation result. + */ +struct rte_flow_q_op_res { + /** + * Version of the struct layout, should be 0. + */ + uint32_t version; + /** + * Returns the status of the operation that this completion signals. + */ + enum rte_flow_q_op_status status; + /** + * User data that was supplied during operation submission. + */ + void *user_data; +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Dequeue a rte flow operation. + * The application must invoke this function in order to complete + * the flow rule offloading and to receive the flow rule operation status. + * + * @param port_id + * Port identifier of Ethernet device. + * @param queue + * Flow queue which is used to dequeue the operation. + * @param[out] res + * Array of results that will be set. + * @param[in] n_res + * Maximum number of results that can be returned. + * This value is equal to the size of the res array. + * @param[out] error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * Number of results that were dequeued, + * a negative errno value otherwise and rte_errno is set. + */ +__rte_experimental +int +rte_flow_q_dequeue(uint16_t port_id, uint32_t queue, + struct rte_flow_q_op_res res[], uint16_t n_res, + struct rte_flow_error *error); #ifdef __cplusplus } #endif