From patchwork Fri Oct 15 16:18:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 101800 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 CCBF8A034F; Fri, 15 Oct 2021 18:18:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A0D3B4112E; Fri, 15 Oct 2021 18:18:48 +0200 (CEST) Received: from AZHDRRW-EX02.NVIDIA.COM (azhdrrw-ex02.nvidia.com [20.64.145.131]) by mails.dpdk.org (Postfix) with ESMTP id B61BB4111E for ; Fri, 15 Oct 2021 18:18:45 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.175) by mxs.oss.nvidia.com (10.13.234.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.15; Fri, 15 Oct 2021 09:18:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=coJbBjvbmM4ico1l87u/jQC1HYzkoSRf2fdBTnklOha9Am1NEsq3HYbLfjaeT5PGcDn4MCM7zbKwtvhcUAB+CADu+WVLPkXWYL9dLSFv41DrqglEbUq80O11aXoKiaa9BEOZN056Os81eazq3AsRQRpM2ESr2ARCHERvzaK6/3yjM87u+rDuaaCI+i5dzxd1wLKhiwzDHeICnr/zdKAZNTr6m9dJo/qa8D9034bGZG+tW6b9hS/63QZzhFBHsh4FnmV9e3i+gU5uLtzghCPoBYdOoyArZ/x6gp6GgEUuuFgn/zIjhAv02RP9YHEy96OuFGsdDDsmC/Ry0caQi/HWMQ== 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=/tEggOzUPrcmYDf/aToJehiBrdHqjqmUvbN/zwjH4HY=; b=Sy0qkBSA/AeNTqGRtVNLuSjqhUgALTN/PIfKtL1B3co+MXVwGES5Uf7pzyix6RL0nmhMzTFWxya2goHOi/uQozPe14dZf4DShfMBFPzqw17DkZ89SSWB3M2IDlo7dxSinyXTsXb0rqO4dM91tcGIaak4inNcii5NeKQEYh0kW9UFbrMgG3ztnB8r+pfZ+dVpRLbSOaYs13++x1nlBAXVdg5l1w0g8ui7DCHz6r8tkUszvNXsvjTso4ae8Om0SrQY+cnOGnfpZt3DTenKLdG/RHQSitrHGmssrdGtjSAy8KNO57Nekb4TVRi9GqDe173qP6hF92JsVsL+VR9jNdpYCA== 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=quarantine 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=/tEggOzUPrcmYDf/aToJehiBrdHqjqmUvbN/zwjH4HY=; b=DVQr89fN41fz4I6L2sYlARxI5mzY1drUhOyvo43pqNB50TWDn7XD7OWXi5XaZnjjtIvHjXp1HGLsXHJMXr9vbf5GlZ2n0YEHpcnU3i93UUJ9N6hebvVt/ihLTQtj6YPPExR9dutc+w5sOiAd3M9uD4Oye54ninw8sQOlvLgH3ALFDQ0pcrUaYu6JPJyY3ohPb7RFrmLHfNikz76hKw6iPz0mDwvivJ2xngp01lcTOszlxDkuxXECKTU66HZkhLlpLKb97j6hVqdX58Nvfebbkk8jKVyrlvDMPu6aVZmMktC3f6y2SFQk3alaYO4yk9UPrOpvAWF4zDbhW+/w8Fqzig== Received: from DM5PR1101CA0009.namprd11.prod.outlook.com (2603:10b6:4:4c::19) by MWHPR12MB1775.namprd12.prod.outlook.com (2603:10b6:300:109::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Fri, 15 Oct 2021 16:18:39 +0000 Received: from DM6NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:4:4c::4) by DM5PR1101CA0009.outlook.office365.com (2603:10b6:4:4c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.14 via Frontend Transport; Fri, 15 Oct 2021 16:18:39 +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 DM6NAM11FT032.mail.protection.outlook.com (10.13.173.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Fri, 15 Oct 2021 16:18:39 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 15 Oct 2021 16:18:37 +0000 From: Dmitry Kozlyuk To: CC: Ori Kam , Thomas Monjalon , "Ferruh Yigit" , Andrew Rybchenko Date: Fri, 15 Oct 2021 19:18:18 +0300 Message-ID: <20211015161822.3099818-2-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015161822.3099818-1-dkozlyuk@nvidia.com> References: <20211005005216.2427489-1-dkozlyuk@nvidia.com> <20211015161822.3099818-1-dkozlyuk@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 28f9210f-16f3-43c6-d0d4-08d98ff772fd X-MS-TrafficTypeDiagnostic: MWHPR12MB1775: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-Transport-Forked: True 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: QmskpVVlyYUWTMaIbPI+DWx+POQukKEMtvTRepJt4g6mNuC6nS8TM493B6CZpDdC1+O+HeWnYjksrn/UGwPXwFwgZjzlHnecZAj5SrtA9XMj4ROX+2/ojDPMY9NSR9IaxTLNbDH+RnWw9b9LKloyX7EKcfqpgHOETqEg1BkLP754GPiYY1nFmAYObr5JxvlZUeNtUmeK3tumI4m0SBLUnyhSP6t32+OGY4ZL86UorD/EJc7IiKOhAwmx0FcQxljbzeVsnN89eBWpGd2O1R9WDLfz+K1w/bR4bSaxiTRyIrziSZOjKT+ABbphwS1MdXcoiUQjUs+AVCbTThofqiQYq+/GY8cXbf5kjKZuLni6Wv7nebpN9K6dUeyB79F08EHK1cQnc5ceNj0/+jQ9oM/ZRjKcAm26fToI6Mjly1jLpjUcj5xTzhRKiN5k0pVvaK9SXMWEU5cOOO2l0rM0Vme9EGuuuRmKTFNGIuGUhn14O/g2XsSxu8eN/JMMcyEgirnBV0CZGm91nir6711OCA2qFr7x+/UDPH27jXTkoM2u1PHz8lGvy4hX0QHCEs/SewEgtiU4iA5JOuzy26JqlE4ql/wL+9jgvpwxvZ0G+rAcVIqvZetBPhNN0GSDjTrqak7Ghmdu3dlXD8W843Y+3k0FDgsXmlMcwB5kPtzglvttX7VQYZO7F7nhxZJRAVbYbzeqNqBiHSY5YywYncSZW8bj4A== 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)(46966006)(36840700001)(83380400001)(47076005)(55016002)(2616005)(36906005)(7636003)(2906002)(1076003)(8936002)(36860700001)(6666004)(316002)(6286002)(54906003)(356005)(26005)(70206006)(4326008)(5660300002)(508600001)(6916009)(16526019)(186003)(36756003)(82310400003)(86362001)(336012)(8676002)(107886003)(7696005)(70586007)(426003); DIR:OUT; SFP:1101; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2021 16:18:39.7487 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28f9210f-16f3-43c6-d0d4-08d98ff772fd 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: DM6NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1775 Subject: [dpdk-dev] [PATCH v2 1/5] ethdev: add capability to keep flow rules on restart 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" Currently, it is not specified what happens to the flow rules when the device is stopped, possibly reconfigured, then started. If flow rules were kept, it could be convenient for application developers, because they wouldn't need to save and restore them. However, due to the number of flows and possible creation rate it is impractical to save all flow rules in DPDK layer. This means that flow rules persistence really depends on whether PMD and HW can implement it efficiently. It can also be limited by the rule item and action types, and its attributes transfer bit, which together comprise the rule kind. Add a device capability bit for PMDs that can keep at least some of the flow rules across restart. Without this capability behavior is still unspecified, which is now explicitly stated. Declare that the application can test for persitence of flow rules of a particular kind by attempting to create a rule of that kind when the device is stopped and checking for the specific error. This is logical because if the PMD can to create the flow rule when the device is not started and use it after the start happens, it is natural that it can move its internal flow rule object to the same state when the device is stopped and restore the state when the device is started. If the device is being reconfigured in a way that is incompatible with existing flow rules, PMD is required to report an error. This is mandatory, because flow API does not supply users with capabilities, so this is the only way for a user to learn that configuration is invalid. For example, if queue count changes and the action of a flow rule specifies queues that are going away, the user must update or remove the flow rule before removing the queues. Signed-off-by: Dmitry Kozlyuk --- doc/guides/prog_guide/rte_flow.rst | 27 +++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 7 +++++++ lib/ethdev/rte_flow.h | 1 + 3 files changed, 35 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 2b42d5ec8c..b0ced4209b 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -87,6 +87,33 @@ To avoid resource leaks on the PMD side, handles must be explicitly destroyed by the application before releasing associated resources such as queues and ports. +By default it is unspecified if the flow rules persist after the device stop. +If ``RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP`` is not advertised, +then rules must be explicitly flushed before stopping the device +if the application needs to ensure they are removed. +If it is advertised, this means the PMD can keep at least some rules +across the device stop and start with possible reconfiguration in between. +However, it may be only supported for some kinds of rules. +The kind is a combination of the following rule properties: + +- the sequence of item types; +- the sequence of action types; +- the value of the transfer attribute. + +To test if a particular kind of rules is kept, the application must try +to create a valid rule of that kind when the device is stopped +(after it has been configured or started previously). +If it succeeds, all rules of the same kind are kept at the device stop. +If it fails with an error of type ``RTE_FLOW_ERROR_TYPE_STATE``, +rules of this kind are flushed when the device is stopped. +Rules of a kept kind that are created when the device is stopped, including +the rules created for the test, will be kept after the device is started. +Some configuration changes may be incompatible with existing rules. +In this case ``rte_eth_dev_configure()``, ``rte_eth_rx/tx_queue_setup()``, +and/or ``rte_eth_dev_start()`` will fail with a log message from the PMD that +should be similar to the one that would be emitted by ``rte_flow_create()`` +if an attempt was made to create the offending rule with the new configuration. + The following sections cover: - **Attributes** (represented by ``struct rte_flow_attr``): properties of a diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 6d80514ba7..a0b388bb25 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -90,6 +90,11 @@ * - flow director filtering mode (but not filtering rules) * - NIC queue statistics mappings * + * The following configuration may be retained or not + * depending on the device capabilities: + * + * - flow rules + * * Any other configuration will not be stored and will need to be re-entered * before a call to rte_eth_dev_start(). * @@ -1445,6 +1450,8 @@ struct rte_eth_conf { #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP 0x00000001 /** Device supports Tx queue setup after device started. */ #define RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP 0x00000002 +/** Device supports keeping flow rules across restart. */ +#define RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP 0x00000004 /**@}*/ /* diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index a89945061a..aa0182d021 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3344,6 +3344,7 @@ enum rte_flow_error_type { RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */ RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */ RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */ + RTE_FLOW_ERROR_TYPE_STATE, /**< Current device state. */ }; /** From patchwork Fri Oct 15 16:18:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 101799 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 38894A034F; Fri, 15 Oct 2021 18:18:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7ADF1410F8; Fri, 15 Oct 2021 18:18:45 +0200 (CEST) Received: from AZHDRRW-EX01.nvidia.com (azhdrrw-ex01.nvidia.com [20.51.104.162]) by mails.dpdk.org (Postfix) with ESMTP id 8BC26410F8 for ; Fri, 15 Oct 2021 18:18:43 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.176) by mxs.oss.nvidia.com (10.13.234.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.15; Fri, 15 Oct 2021 09:18:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Le1G93TBhTZh6eItdp5EQImHKOHaL+WQOWaNC5/R/Hil1f6XRNe8VklrQJVAjrvN5Wne9PGU9y0oBOmk+nK03bflx/WtTXBvcuZfixOyVtVXmSbKwxUGjc0+bpa7EQHCS3C92Z7UOa9oOTVZxEpAo12O5BXtZVVY1bCr9x94eTMFHClcyUh0shBJoI51oByu2i5BWYxbvT3v8OcYtDuFAOofqRZ9fOVzW1bWC3tpH6CnjfTZ1HsYYTRFNKdxuaFu8YDO26bf35i5zMAY9NJVPck2K0MaG6b29Pso7P5riGGEt75dBDWjVC+7lTqtnocq4+YG/svJA4DNVyuVVrSbrw== 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=bfKxNwqSe6gIGzZ0VF2Bxm98PRreFos1Boa2JIFmpoo=; b=EIKmP2l/Q9O2xIx6qB4V9VYkRbn/BnwWbxgw4rCVXVvQK6rfsU1oQD3gpr+qbhD17PzIr5GMDh0Zf7fmWEobSg1Ww7vewV9t+QZ1w0AK4m8L6Ip1QYS0Uh2gAarzW+myrPdUlS+m8Tbiiq9wboD9UanXmVLTcGGHXbFCLnCBA1MFTyGrWTVHNGxWwyJqbLDPt8vcWK1OkxfUvN3Xba1ox/h67kVNHj+bQR+vWhUcrZO09TYBcPxPsEMI8Vtdn56TUWqP6Fx65m/rtgwNBBgtMU3mZvgKNT6X4kNVR5lN0h/N1wgX0iT+mTBTZ6qdrhXvSKNn3e2uqkUB4bQs+3qVkg== 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=quarantine 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=bfKxNwqSe6gIGzZ0VF2Bxm98PRreFos1Boa2JIFmpoo=; b=tNwkqDCItEcbitQrm99n5JzA0eSDCZNye1nhYP6rvyH7Ufz9NObHAEstjm1aC89W73dmy2OurcCnVZq98GlAscrafbkDp4GkV+2JKr7ja49IN8IfkLvYW2nBb9Xu8NH60PLXTCVB4RIYb9ZmDqkbBLuIvqhK1iFI6cj7BmAucGLNdvmjsVSiqRZh+zJWywF9dgygFkDQ+cHIp2Cnl084oyYGOOr4Qq9/MDyw2WMH12neKr3GqTwk1ynZCA0wOeX1XAXZkzD9du8K0sTCa9CZwgbe4W0zPQKJeiLZq5iJH6c8KrYuM4sZIEcc7/C8yhdL4E7Qjlbj+wCPEzIsxUZEyg== Received: from DM5PR1101CA0021.namprd11.prod.outlook.com (2603:10b6:4:4c::31) by MN2PR12MB3280.namprd12.prod.outlook.com (2603:10b6:208:ad::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.25; Fri, 15 Oct 2021 16:18:40 +0000 Received: from DM6NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:4:4c:cafe::c0) by DM5PR1101CA0021.outlook.office365.com (2603:10b6:4:4c::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.14 via Frontend Transport; Fri, 15 Oct 2021 16:18:40 +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 DM6NAM11FT032.mail.protection.outlook.com (10.13.173.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Fri, 15 Oct 2021 16:18:40 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 15 Oct 2021 16:18:38 +0000 From: Dmitry Kozlyuk To: CC: Ori Kam , Thomas Monjalon , "Ferruh Yigit" , Andrew Rybchenko Date: Fri, 15 Oct 2021 19:18:19 +0300 Message-ID: <20211015161822.3099818-3-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015161822.3099818-1-dkozlyuk@nvidia.com> References: <20211005005216.2427489-1-dkozlyuk@nvidia.com> <20211015161822.3099818-1-dkozlyuk@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 15560f3d-33fe-4717-6678-08d98ff77358 X-MS-TrafficTypeDiagnostic: MN2PR12MB3280: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-Transport-Forked: True 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: CWqnym1qWpEYcl9MkklvxAW+nyfWT7jSqT4vpwT4GFLgE3jk1N4sIKm0Tdrp1jTvT4k1ohJjZ3jVodQX+++ss8agMDQfHiexSnAnyzmGZEHO9xpoUA263jcJ0OEXhIqpxJgl4u4DkzR0fBbVuaQMPLVW4/t6tCeS9Lxe1goV0PqVaFOKJSUhlERsIuddhtGcHCopBz8x9Oq7tAApA0gkCRAy0baY86y72fLAjAlMB+RnowxTGCt9dohIgKzZP/aWP8kzccEGuJ+pU/RC526AxtwVLWtGPQO1F8MUNW/qcZecyItSxD9rSNNAY7hW5P8v/Y0vG+GYGlvquKW1Qk9y6UJSh54W/d1oyyZJyTu864updx2Lgagn9jLDKnxNg94U6gvGoAC7FkJsPGcwKwJ7uvZ6Luy64XApT/qMWd8xFT7VvEu0IPOwRfbNFxTcT1nXHKC4j6LgOdKHB0HkjulnSliXe7ffNGu4YolY8oSsfWo+ILMFIshpjPrK4Wfcyblr0ZNJrdShHryVp/OCZDnk0FhZQThS2lZ/uVvF4ZFFFh/AXxkKZkTC8e9mTshQCSHHxIMHq0MXrbmTfuGksH6Ji2kBAeLqOn4So043VIlLG8DJLFvZ3dAd1EPnM59+hSZGTDgkGzPjxX4SyxuB13VL0uYkJMdEhm1cyaNjJAKOu6FwCgmeoGcLILdC4YYCTYfDSgr+IaVxV75ZD1VaZQiCKg== 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)(46966006)(36840700001)(54906003)(16526019)(8676002)(83380400001)(36860700001)(70586007)(2616005)(426003)(36756003)(86362001)(70206006)(82310400003)(55016002)(4326008)(316002)(336012)(6286002)(1076003)(7696005)(2906002)(7636003)(186003)(5660300002)(356005)(47076005)(6666004)(508600001)(107886003)(26005)(6916009)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2021 16:18:40.3463 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15560f3d-33fe-4717-6678-08d98ff77358 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: DM6NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3280 Subject: [dpdk-dev] [PATCH v2 2/5] ethdev: add capability to keep shared objects on restart 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" rte_flow_action_handle_create() did not mention what happens with an indirect action when a device is stopped, possibly reconfigured, and started again. It is natural for some indirect actions to be persistent, like counters and meters; keeping others just saves application time and complexity. However, not all PMDs can support it. Also the support may be limited by particular action kinds, that is, combinations of action type and the value of the transfer bit in its configuration. Add a device capability to indicate if at least some indirect actions are kept across the above sequence. Without this capability the behavior is still unspecified, but now it is stated explicitly. In the future, indirect actions may not be the only type of objects shared between flow rules. The capability bit intends to cover all possible types of such objects, hence its name. Declare that the application can test for the persistence of a particular indirect action kind by attempting to create an indirect action of that kind when the device is stopped and checking for the specific error type. This is logical because if the PMD can to create the flow rule when the device is not started and use it after the start happens, it is natural that it can move its internal flow shared object to the same state when the device is stopped and restore the state when the device is started. If the device is being reconfigured in a way that is incompatible with an existing shared objects, PMD is required to report an error. This is mandatory, because flow API does not supply users with capabilities, so this is the only way for a user to learn that configuration is invalid. For example, if queue count changes and RSS indirect action specifies queues that are going away, the user must update the action before removing the queues or remove the action and all flow rules that were using it. Signed-off-by: Dmitry Kozlyuk --- doc/guides/prog_guide/rte_flow.rst | 24 ++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index b0ced4209b..bf96ad830f 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2812,6 +2812,30 @@ updated depend on the type of the ``action`` and different for every type. The indirect action specified data (e.g. counter) can be queried by ``rte_flow_action_handle_query()``. +By default it is unspecified if indirect actions persist after the device stop. +If ``RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP`` is not advertised, +then indirect actions must be explicitly destroyed before stopping the device +if the application needs to ensure they are removed. +If it is advertised, this means the PMD can keep at least some indirect actions +across device stop and start with possible reconfiguration in between. +However, it may be only supported for certain kinds of indirect actions. +The kind is a combination of the action type and the value of its transfer bit. +To test if a particular kind of indirect actions is kept, +the application must try to create a valid indirect action of that kind +when the device is stopped (after it has been configured or started previously). +If it succeeds, all indirect actions of the same kind are kept +when the device is stopped. +If it fails with an error of type ``RTE_FLOW_ERROR_TYPE_STATE``, +indirect actions of this kind are flushed when the device is stopped. +Indirect actions of a kept kind that are created when the device is stopped, +including the ones created for the test, will be kept after the device start. +Some configuration changes may be incompatible with existing indirect actions. +In this case ``rte_eth_dev_configure()``, ``rte_eth_rx/tx_queue_setup()``, +and/or ``rte_eth_dev_start()`` will fail with a log message from the PMD that +should be similar to the one that would be emitted +by ``rte_flow_action_handle_create()`` if an attempt was made +to create the offending rule with the new configuration. + .. _table_rte_flow_action_handle: .. table:: INDIRECT diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index a0b388bb25..12fc7262eb 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -94,6 +94,7 @@ * depending on the device capabilities: * * - flow rules + * - flow-related shared objects, e.g. indirect actions * * Any other configuration will not be stored and will need to be re-entered * before a call to rte_eth_dev_start(). @@ -1452,6 +1453,8 @@ struct rte_eth_conf { #define RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP 0x00000002 /** Device supports keeping flow rules across restart. */ #define RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP 0x00000004 +/** Device supports keeping shared flow objects across restart. */ +#define RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP 0x00000008 /**@}*/ /* From patchwork Fri Oct 15 16:18:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 101801 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 71AD4A034F; Fri, 15 Oct 2021 18:19:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C98934115F; Fri, 15 Oct 2021 18:18:49 +0200 (CEST) Received: from AZHDRRW-EX01.nvidia.com (azhdrrw-ex01.nvidia.com [20.51.104.162]) by mails.dpdk.org (Postfix) with ESMTP id 3FDEE4112E; Fri, 15 Oct 2021 18:18:47 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (104.47.73.170) by mxs.oss.nvidia.com (10.13.234.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.15; Fri, 15 Oct 2021 09:18:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hw7a+x+uYUetaS/Rk8QVD+IqIUJyIw0SDcEreXBHIdS6qzlhkz75000zmcyvKI0AYZArDbxCriJqEXz3hqdzQhJsXRibNM5R2+rIjdA6zM1feKXFE2CvzQ+d6gpepAsz313sPrTDIlDZrTQGNhfEj5kzJePTx1L8DEhp8IEIjoEm+y43bzENz1mu6IJrW0zDCirORq3ZwVAbVS3t4Zc+GVdorLYzNRkOlqVvm+s6RkgHsWf+8dtmZXeOQ6GC0EBjtpBVLd6EWOjpswNE7uUz2qBdoQxlN/xIm3ijeMBPaZ96aBtDW/jEuhcoVcCcg8vwM16o4Uqa1FY/wZpU8LSABA== 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=BYmjf649AjxfufmyExX1H9A/RXBudrCIcO65K2pPD+E=; b=DwzGydX14inDs4BPsz+gKrLZIpNm7L1ANgQy9yPwsp9J+H0OBlVOmgyV388GhdhkU2ls2SBTTcVInaCFBFWZLFhacf0/AV0zG73zv/tYXF/ZcFtX2G3aFqIUetn0U5BlG51q5SUBiUliBIfK236EDa32gZY1cPqLrqTvMDCHwXfba28qXbb2Cy6AsE81RrD3TS2/38mPU7mmVcMCZGJRLadpM/7ij8twY6znk9AiFqX0G153eIptMw4yXdwqoUFWG33G1OGWm7Iipz1qfaV6cm8fxEWHKE4PCo/gU1VdIJ50H8OMf+CBBdN9QyRiWLNcgVYc0Hjlp/63D/jcgkRHJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine 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=BYmjf649AjxfufmyExX1H9A/RXBudrCIcO65K2pPD+E=; b=AD4mUJQKtHJ6XuwvOv9LYFJ6qnDNlXswnsgocTKnQzvRmxVYhE8OnXgV6Pllltqt0fMr+AXihBEHZPhNLea2c3RzRDI75LTJe1jtNUjA4klKFwbcl5d/EjIRzgUjDSlXo38YMFYhQMU5H0dKfZi9oiX9kCuSResHDvlxTt4oPNm0dHWDwF7zhFEij0gL/NUfylmJ/k0cdA7Cn7wSZ/hXhwXokNd0jiH9PRmI5nQmzC0vPetYo1fp4m9bTmPfmnivzEKtTul5YEKm1r3gP2fLxJjPInfJWec0mYNbLUWorhqs4UmcxtF90vb5I0BMSeCD7bHhem21ynNyqiouIgkjbQ== Received: from DM6PR18CA0025.namprd18.prod.outlook.com (2603:10b6:5:15b::38) by BL1PR12MB5126.namprd12.prod.outlook.com (2603:10b6:208:312::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Fri, 15 Oct 2021 16:18:45 +0000 Received: from DM6NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b::4) by DM6PR18CA0025.outlook.office365.com (2603:10b6:5:15b::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.14 via Frontend Transport; Fri, 15 Oct 2021 16:18:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; 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 DM6NAM11FT012.mail.protection.outlook.com (10.13.173.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Fri, 15 Oct 2021 16:18:43 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 15 Oct 2021 16:18:40 +0000 From: Dmitry Kozlyuk To: CC: , Matan Azrad , Viacheslav Ovsiienko Date: Fri, 15 Oct 2021 19:18:20 +0300 Message-ID: <20211015161822.3099818-4-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015161822.3099818-1-dkozlyuk@nvidia.com> References: <20211005005216.2427489-1-dkozlyuk@nvidia.com> <20211015161822.3099818-1-dkozlyuk@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4a02fe4b-be49-47ed-2cc5-08d98ff775dc X-MS-TrafficTypeDiagnostic: BL1PR12MB5126: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1751; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C41ZcpP1OSdhzjxqVSeXys70/DvN7hGFXJFOnw9Fx4o7VRd1xHXCk4hNaWsWEA/G9ZGtceAmZbzJNngooy/AbxQoudZRNS6TSXJgCkfSvjlI3Lkph4i01n8hgo1WNl0EXnbgoRT5vgsuDA86UcWshVKFE0oNE7B+2ThZ6582DZmshIPcRD1qsxpatYQioQ/I6MPQWXUzw96h0cuSZylyKrUU4VAV1jfIWADTpv9ax6X0FQyaXdO8PmlYii7ARPjUjaF6yl1VwzBnzJk07YRL7azg/QEwLa9kTnfVolB7T6ohBTMSiBQuguyMOt/54Lyttp9vHcOupR3boiuCQ/cWcfXWCwqqQM6JfNYtgJqztFEBBVF3EgqvvrgN23w8BMbHz2juZS0P0wY3sJ/7kA/XXIN6VAYNEVT2jGo+OQJX0Q8zaK8sXSjsOuowrIpFnggrzw0tbR4GnlBjQk29mx0G8IlbAwS6OaWGRNkekz24FMLk8cjymzUp+OPcNHkq8nqDXQF/UkLQqivpvcn88h2laLDGjV225CMUjChh55sPD3lKuBa+FHEZfoZ8qZoT4dlMGA0bIRDsj44vgIwP3ELuvvClFOSv0aOJbDF76byp3oNIZPaCQL7xjbWtnFpJ+0gjFvkvlF1AdVEGfYcg1ClgFpnuryTYK5kgbDcXGZjxCOVfaAb39t9XbnBX3QshItl6URGIU9V640rNSzyN64uRfg== 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)(47076005)(36756003)(5660300002)(356005)(7636003)(336012)(316002)(450100002)(30864003)(7696005)(107886003)(1076003)(86362001)(6666004)(186003)(16526019)(55016002)(26005)(426003)(70586007)(2906002)(70206006)(8676002)(6286002)(36860700001)(508600001)(6916009)(83380400001)(8936002)(2616005)(4326008)(82310400003)(54906003); DIR:OUT; SFP:1101; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2021 16:18:43.9138 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4a02fe4b-be49-47ed-2cc5-08d98ff775dc 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: DM6NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5126 Subject: [dpdk-dev] [PATCH v2 3/5] net/mlx5: discover max flow priority using DevX 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" Maximum available flow priority was discovered using Verbs API regardless of the selected flow engine. This required some Verbs objects to be initialized in order to use DevX engine. Make priority discovery an engine method and implement it for DevX using its API. Cc: stable@dpdk.org Signed-off-by: Dmitry Kozlyuk Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 1 - drivers/net/mlx5/mlx5_flow.c | 98 +++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 4 ++ drivers/net/mlx5/mlx5_flow_dv.c | 103 +++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_verbs.c | 77 +++------------------ 5 files changed, 215 insertions(+), 68 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 3746057673..8ee7ada51b 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1830,7 +1830,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->drop_queue.hrxq = mlx5_drop_action_create(eth_dev); if (!priv->drop_queue.hrxq) goto error; - /* Supported Verbs flow priority number detection. */ err = mlx5_flow_discover_priorities(eth_dev); if (err < 0) { err = -err; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index c914a7120c..bfc3e20c9a 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -9416,3 +9416,101 @@ mlx5_dbg__print_pattern(const struct rte_flow_item *item) } printf("END\n"); } + +/* Map of Verbs to Flow priority with 8 Verbs priorities. */ +static const uint32_t priority_map_3[][MLX5_PRIORITY_MAP_MAX] = { + { 0, 1, 2 }, { 2, 3, 4 }, { 5, 6, 7 }, +}; + +/* Map of Verbs to Flow priority with 16 Verbs priorities. */ +static const uint32_t priority_map_5[][MLX5_PRIORITY_MAP_MAX] = { + { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, + { 9, 10, 11 }, { 12, 13, 14 }, +}; + +/** + * Discover the number of available flow priorities. + * + * @param dev + * Ethernet device. + * + * @return + * On success, number of available flow priorities. + * On failure, a negative errno-style code and rte_errno is set. + */ +int +mlx5_flow_discover_priorities(struct rte_eth_dev *dev) +{ + static const uint16_t vprio[] = {8, 16}; + const struct mlx5_priv *priv = dev->data->dev_private; + const struct mlx5_flow_driver_ops *fops; + enum mlx5_flow_drv_type type; + int ret; + + type = mlx5_flow_os_get_type(); + if (type == MLX5_FLOW_TYPE_MAX) { + type = MLX5_FLOW_TYPE_VERBS; + if (priv->config.devx && priv->config.dv_flow_en) + type = MLX5_FLOW_TYPE_DV; + } + fops = flow_get_drv_ops(type); + if (fops->discover_priorities == NULL) { + DRV_LOG(ERR, "Priority discovery not supported"); + rte_errno = ENOTSUP; + return -rte_errno; + } + ret = fops->discover_priorities(dev, vprio, RTE_DIM(vprio)); + if (ret < 0) + return ret; + switch (ret) { + case 8: + ret = RTE_DIM(priority_map_3); + break; + case 16: + ret = RTE_DIM(priority_map_5); + break; + default: + rte_errno = ENOTSUP; + DRV_LOG(ERR, + "port %u maximum priority: %d expected 8/16", + dev->data->port_id, ret); + return -rte_errno; + } + DRV_LOG(INFO, "port %u supported flow priorities:" + " 0-%d for ingress or egress root table," + " 0-%d for non-root table or transfer root table.", + dev->data->port_id, ret - 2, + MLX5_NON_ROOT_FLOW_MAX_PRIO - 1); + return ret; +} + +/** + * Adjust flow priority based on the highest layer and the request priority. + * + * @param[in] dev + * Pointer to the Ethernet device structure. + * @param[in] priority + * The rule base priority. + * @param[in] subpriority + * The priority based on the items. + * + * @return + * The new priority. + */ +uint32_t +mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, + uint32_t subpriority) +{ + uint32_t res = 0; + struct mlx5_priv *priv = dev->data->dev_private; + + switch (priv->config.flow_prio) { + case RTE_DIM(priority_map_3): + res = priority_map_3[priority][subpriority]; + break; + case RTE_DIM(priority_map_5): + res = priority_map_5[priority][subpriority]; + break; + } + return res; +} diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 5c68d4f7d7..8f94125f26 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1226,6 +1226,9 @@ typedef int (*mlx5_flow_create_def_policy_t) (struct rte_eth_dev *dev); typedef void (*mlx5_flow_destroy_def_policy_t) (struct rte_eth_dev *dev); +typedef int (*mlx5_flow_discover_priorities_t) + (struct rte_eth_dev *dev, + const uint16_t *vprio, int vprio_n); struct mlx5_flow_driver_ops { mlx5_flow_validate_t validate; @@ -1260,6 +1263,7 @@ struct mlx5_flow_driver_ops { mlx5_flow_action_update_t action_update; mlx5_flow_action_query_t action_query; mlx5_flow_sync_domain_t sync_domain; + mlx5_flow_discover_priorities_t discover_priorities; }; /* mlx5_flow.c */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index c6370cd1d6..155745748f 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -17978,6 +17978,108 @@ flow_dv_sync_domain(struct rte_eth_dev *dev, uint32_t domains, uint32_t flags) return 0; } +/** + * Discover the number of available flow priorities + * by trying to create a flow with the highest priority value + * for each possible number. + * + * @param[in] dev + * Ethernet device. + * @param[in] vprio + * List of possible number of available priorities. + * @param[in] vprio_n + * Size of @p vprio array. + * @return + * On success, number of available flow priorities. + * On failure, a negative errno-style code and rte_errno is set. + */ +static int +flow_dv_discover_priorities(struct rte_eth_dev *dev, + const uint16_t *vprio, int vprio_n) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_indexed_pool *pool = priv->sh->ipool[MLX5_IPOOL_MLX5_FLOW]; + struct rte_flow_item_eth eth; + struct rte_flow_item item = { + .type = RTE_FLOW_ITEM_TYPE_ETH, + .spec = ð, + .mask = ð, + }; + struct mlx5_flow_dv_matcher matcher = { + .mask = { + .size = sizeof(matcher.mask.buf), + }, + }; + union mlx5_flow_tbl_key tbl_key; + struct mlx5_flow flow; + void *action; + struct rte_flow_error error; + uint8_t misc_mask; + int i, err, ret = -ENOTSUP; + + /* + * Prepare a flow with a catch-all pattern and a drop action. + * Use drop queue, because shared drop action may be unavailable. + */ + action = priv->drop_queue.hrxq->action; + if (action == NULL) { + DRV_LOG(ERR, "Priority discovery requires a drop action"); + rte_errno = ENOTSUP; + return -rte_errno; + } + memset(&flow, 0, sizeof(flow)); + flow.handle = mlx5_ipool_zmalloc(pool, &flow.handle_idx); + if (flow.handle == NULL) { + DRV_LOG(ERR, "Cannot create flow handle"); + rte_errno = ENOMEM; + return -rte_errno; + } + flow.ingress = true; + flow.dv.value.size = MLX5_ST_SZ_BYTES(fte_match_param); + flow.dv.actions[0] = action; + flow.dv.actions_n = 1; + memset(ð, 0, sizeof(eth)); + flow_dv_translate_item_eth(matcher.mask.buf, flow.dv.value.buf, + &item, /* inner */ false, /* group */ 0); + matcher.crc = rte_raw_cksum(matcher.mask.buf, matcher.mask.size); + for (i = 0; i < vprio_n; i++) { + /* Configure the next proposed maximum priority. */ + matcher.priority = vprio[i] - 1; + memset(&tbl_key, 0, sizeof(tbl_key)); + err = flow_dv_matcher_register(dev, &matcher, &tbl_key, &flow, + /* tunnel */ NULL, + /* group */ 0, + &error); + if (err != 0) { + /* This action is pure SW and must always succeed. */ + DRV_LOG(ERR, "Cannot register matcher"); + ret = -rte_errno; + break; + } + /* Try to apply the flow to HW. */ + misc_mask = flow_dv_matcher_enable(flow.dv.value.buf); + __flow_dv_adjust_buf_size(&flow.dv.value.size, misc_mask); + err = mlx5_flow_os_create_flow + (flow.handle->dvh.matcher->matcher_object, + (void *)&flow.dv.value, flow.dv.actions_n, + flow.dv.actions, &flow.handle->drv_flow); + if (err == 0) { + claim_zero(mlx5_flow_os_destroy_flow + (flow.handle->drv_flow)); + flow.handle->drv_flow = NULL; + } + claim_zero(flow_dv_matcher_release(dev, flow.handle)); + if (err != 0) + break; + ret = vprio[i]; + } + mlx5_ipool_free(pool, flow.handle_idx); + /* Set rte_errno if no expected priority value matched. */ + if (ret < 0) + rte_errno = -ret; + return ret; +} + const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops = { .validate = flow_dv_validate, .prepare = flow_dv_prepare, @@ -18011,6 +18113,7 @@ const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops = { .action_update = flow_dv_action_update, .action_query = flow_dv_action_query, .sync_domain = flow_dv_sync_domain, + .discover_priorities = flow_dv_discover_priorities, }; #endif /* HAVE_IBV_FLOW_DV_SUPPORT */ diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index b93fd4d2c9..72b9db6c7f 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -28,17 +28,6 @@ #define VERBS_SPEC_INNER(item_flags) \ (!!((item_flags) & MLX5_FLOW_LAYER_TUNNEL) ? IBV_FLOW_SPEC_INNER : 0) -/* Map of Verbs to Flow priority with 8 Verbs priorities. */ -static const uint32_t priority_map_3[][MLX5_PRIORITY_MAP_MAX] = { - { 0, 1, 2 }, { 2, 3, 4 }, { 5, 6, 7 }, -}; - -/* Map of Verbs to Flow priority with 16 Verbs priorities. */ -static const uint32_t priority_map_5[][MLX5_PRIORITY_MAP_MAX] = { - { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, - { 9, 10, 11 }, { 12, 13, 14 }, -}; - /* Verbs specification header. */ struct ibv_spec_header { enum ibv_flow_spec_type type; @@ -50,13 +39,17 @@ struct ibv_spec_header { * * @param[in] dev * Pointer to the Ethernet device structure. - * + * @param[in] vprio + * Expected result variants. + * @param[in] vprio_n + * Number of entries in @p vprio array. * @return - * number of supported flow priority on success, a negative errno + * Number of supported flow priority on success, a negative errno * value otherwise and rte_errno is set. */ -int -mlx5_flow_discover_priorities(struct rte_eth_dev *dev) +static int +flow_verbs_discover_priorities(struct rte_eth_dev *dev, + const uint16_t *vprio, int vprio_n) { struct mlx5_priv *priv = dev->data->dev_private; struct { @@ -79,7 +72,6 @@ mlx5_flow_discover_priorities(struct rte_eth_dev *dev) }; struct ibv_flow *flow; struct mlx5_hrxq *drop = priv->drop_queue.hrxq; - uint16_t vprio[] = { 8, 16 }; int i; int priority = 0; @@ -87,7 +79,7 @@ mlx5_flow_discover_priorities(struct rte_eth_dev *dev) rte_errno = ENOTSUP; return -rte_errno; } - for (i = 0; i != RTE_DIM(vprio); i++) { + for (i = 0; i != vprio_n; i++) { flow_attr.attr.priority = vprio[i] - 1; flow = mlx5_glue->create_flow(drop->qp, &flow_attr.attr); if (!flow) @@ -95,59 +87,9 @@ mlx5_flow_discover_priorities(struct rte_eth_dev *dev) claim_zero(mlx5_glue->destroy_flow(flow)); priority = vprio[i]; } - switch (priority) { - case 8: - priority = RTE_DIM(priority_map_3); - break; - case 16: - priority = RTE_DIM(priority_map_5); - break; - default: - rte_errno = ENOTSUP; - DRV_LOG(ERR, - "port %u verbs maximum priority: %d expected 8/16", - dev->data->port_id, priority); - return -rte_errno; - } - DRV_LOG(INFO, "port %u supported flow priorities:" - " 0-%d for ingress or egress root table," - " 0-%d for non-root table or transfer root table.", - dev->data->port_id, priority - 2, - MLX5_NON_ROOT_FLOW_MAX_PRIO - 1); return priority; } -/** - * Adjust flow priority based on the highest layer and the request priority. - * - * @param[in] dev - * Pointer to the Ethernet device structure. - * @param[in] priority - * The rule base priority. - * @param[in] subpriority - * The priority based on the items. - * - * @return - * The new priority. - */ -uint32_t -mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, - uint32_t subpriority) -{ - uint32_t res = 0; - struct mlx5_priv *priv = dev->data->dev_private; - - switch (priv->config.flow_prio) { - case RTE_DIM(priority_map_3): - res = priority_map_3[priority][subpriority]; - break; - case RTE_DIM(priority_map_5): - res = priority_map_5[priority][subpriority]; - break; - } - return res; -} - /** * Get Verbs flow counter by index. * @@ -2105,4 +2047,5 @@ const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = { .destroy = flow_verbs_destroy, .query = flow_verbs_query, .sync_domain = flow_verbs_sync_domain, + .discover_priorities = flow_verbs_discover_priorities, }; From patchwork Fri Oct 15 16:18:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 101802 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 90027A034F; Fri, 15 Oct 2021 18:19:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1515411D4; Fri, 15 Oct 2021 18:18:55 +0200 (CEST) Received: from AZHDRRW-EX01.nvidia.com (azhdrrw-ex01.nvidia.com [20.51.104.162]) by mails.dpdk.org (Postfix) with ESMTP id 7FC6A41179; Fri, 15 Oct 2021 18:18:50 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.102) by mxs.oss.nvidia.com (10.13.234.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.15; Fri, 15 Oct 2021 09:18:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bgo0lu9PvWTMhNJOhndQZ/YHpf8mlhEbxZ0a7ls771qNeTMfN1JANdgjqwbQ0dVZswSZKzj2MVVoJZK47J5A02m8WBQiiR9g9rKtH78imH8qVYfDuG4G9UtsZju9EiuL4Ufqm9TAoYnNqQDZibDYxpyumqDlOzYSsiA99vGTYoJohoOM6i1M8mCUS7nAeCqXTpquu71mKMfgrvFWalGZgXpERMCJhIrUG71b70LJDScnPBEa9k0p6I6uc0wCRFzMVAXsDd+ahI0borcycx8zfNE0ZOCjr7/rdbd4fM9OALgqfhyQ4NB1h+iP1bwBJ+cd0QYTK6VsntMr/EDBz0oVBQ== 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=rF6PCjc6Foa8qHZ8zEJfNghrMALKfxb+VpRT8ojcUIE=; b=Ds8bdi7AYss1sXlu3v3MSIQljVxpDDambUrxBNOtV+gXLOuvVKCCEnBnsSbnXVwkfExopfkt+FYUZfJTR5TjpOQx9SD6y99hnJjipa2m1hE5zfg4BcA1SBcC1p6NKuZck6Dhpn7iDxvraPsbNhtGORW21lLPROoRaN5q9oq2tCidJc0guCHo9dtub/e+vonyc1II9sNYE/c0xu+fH3jQ8BFWlf9h/5imbXavipvZRTFp93xZ1m15vsulako0RvIEdFEQJC9gwSoSnLVNe4aIHBI5Oki7OmIYEMnK0DR++cmEG+GAGDiuMbfsKPrr9/fAvlxEtEwNXrQX+zWXUWdC+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine 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=rF6PCjc6Foa8qHZ8zEJfNghrMALKfxb+VpRT8ojcUIE=; b=Wu6e68IDyKrLac+ln8vb196KdEvdj/wHz1ttUaS7AiDLfnunJxWSl9kty74TxaUDKIxjkJ5Ydf4SVpzku9vy0CdvEf961AnL/W0qIF+9wi2+gF7luwvQBidEL8b0m9YbCtQKk6momy75WOiQJR9XiDeKDew4sSt6W0SKtMNU+Lo/5XYx2UGpfnwsJI8Eo8qflrhHTIB3RmyWbM+fGI2lm5vLRpOYxjNpPziZRLSiypfmIpdWItt1+qic2uRAVeTgpWQOiJuZuF9ghZtq8Rf7VS2aXzS7gwW0v8jqhygflxVmH2YeNeEZc+/qltq7Qgyq5FhEh9b1/pwzJcd3TbxXOA== Received: from DM6PR18CA0025.namprd18.prod.outlook.com (2603:10b6:5:15b::38) by BN6PR12MB1410.namprd12.prod.outlook.com (2603:10b6:404:18::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Fri, 15 Oct 2021 16:18:46 +0000 Received: from DM6NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b:cafe::24) by DM6PR18CA0025.outlook.office365.com (2603:10b6:5:15b::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.14 via Frontend Transport; Fri, 15 Oct 2021 16:18:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; 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 DM6NAM11FT012.mail.protection.outlook.com (10.13.173.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Fri, 15 Oct 2021 16:18:45 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 15 Oct 2021 16:18:42 +0000 From: Dmitry Kozlyuk To: CC: , Matan Azrad , Viacheslav Ovsiienko Date: Fri, 15 Oct 2021 19:18:21 +0300 Message-ID: <20211015161822.3099818-5-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015161822.3099818-1-dkozlyuk@nvidia.com> References: <20211005005216.2427489-1-dkozlyuk@nvidia.com> <20211015161822.3099818-1-dkozlyuk@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b90d220b-9b4b-4d92-4c19-08d98ff776b9 X-MS-TrafficTypeDiagnostic: BN6PR12MB1410: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: asuTaTxRfOr6SkepytHj1OMa4Sn+FA/GjfznSjcoEp/2kxT9cc/5rKYWpj3Gb5nZ60SmAKV53XhYO1cWqEr/e1l5d5zioMbwdjfMMZuJb0jt0bTJRE8QOdn1HtagoJ8JliYdZ+Aqs610VdkK7a5svfDyNP4hY+KveWzdauIsbgiUZxtLD10/ZWOmTlFKPCeHmdwbRR3hHBxQLTAW1QL+oz6KDTM8TBUzTakCWhKWC+Bfg+GLWqDFnDk2pnE358ujRBIVocZLm4MGxj9Sg33G2msMl7PcyAg6jxb3L+F+rg2xOXlCj64rIN0mATxXMRTjcK29UB3w2MeyudtBLQlJRDQsy+ahLMkoAvzwQHHjZR6Mf5hPm4yANOqUW6Gg++xev+QW8bEXi4YubP4EmTxjHkwKFklredmyTZ6NQQ7WFnSQsl+OgOsXkT6oSUylYbS2DGCkCHF/WpJuhmn5Nf+eLJ8BRJgVf36eDDw24sOy31WfOt264vQH0FbuPZpGzQvWSaXXucBpi9dGB/tZsQiAshmojf84qS7Jv3BxJY+jwqZ2b12Lkz8KIemeMbjNtG4CkHfo7z4VKbygcnHmNhXVOX8w/6AN2dl3C94L3Y93fDFIMr1VF8Cwr2kNO5562IEtWzSuateDC9gsUZu9oeobREsPeD9LOF55Os69WaBmzN+W4YRbEWMbX6rQ8wpaoaOJNNRuTuk+BtxGFCiaEHqSnw== 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)(46966006)(36840700001)(107886003)(7696005)(316002)(6916009)(4326008)(6666004)(54906003)(450100002)(55016002)(356005)(83380400001)(86362001)(6286002)(7636003)(508600001)(5660300002)(36756003)(47076005)(70586007)(70206006)(82310400003)(16526019)(2906002)(426003)(36860700001)(8936002)(1076003)(186003)(8676002)(2616005)(26005)(30864003)(336012); DIR:OUT; SFP:1101; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2021 16:18:45.6138 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b90d220b-9b4b-4d92-4c19-08d98ff776b9 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: DM6NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1410 Subject: [dpdk-dev] [PATCH v2 4/5] net/mlx5: create drop queue using DevX 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" Drop queue creation and destruction were not implemented for DevX flow engine and Verbs engine methods were used as a workaround. Implement these methods for DevX so that there is a valid queue ID that can be used regardless of queue configuration via API. Cc: stable@dpdk.org Signed-off-by: Dmitry Kozlyuk Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 4 - drivers/net/mlx5/mlx5_devx.c | 211 ++++++++++++++++++++++++++----- 2 files changed, 180 insertions(+), 35 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 8ee7ada51b..985f0bd489 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1790,10 +1790,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, } if (config->devx && config->dv_flow_en && config->dest_tir) { priv->obj_ops = devx_obj_ops; - priv->obj_ops.drop_action_create = - ibv_obj_ops.drop_action_create; - priv->obj_ops.drop_action_destroy = - ibv_obj_ops.drop_action_destroy; #ifndef HAVE_MLX5DV_DEVX_UAR_OFFSET priv->obj_ops.txq_obj_modify = ibv_obj_ops.txq_obj_modify; #else diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c index a1db53577a..1e62108c94 100644 --- a/drivers/net/mlx5/mlx5_devx.c +++ b/drivers/net/mlx5/mlx5_devx.c @@ -226,17 +226,17 @@ mlx5_rx_devx_get_event(struct mlx5_rxq_obj *rxq_obj) * * @param dev * Pointer to Ethernet device. - * @param idx - * Queue index in DPDK Rx queue array. + * @param rxq_data + * RX queue data. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_rxq_create_devx_rq_resources(struct rte_eth_dev *dev, uint16_t idx) +mlx5_rxq_create_devx_rq_resources(struct rte_eth_dev *dev, + struct mlx5_rxq_data *rxq_data) { struct mlx5_priv *priv = dev->data->dev_private; - struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; struct mlx5_rxq_ctrl *rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); struct mlx5_devx_create_rq_attr rq_attr = { 0 }; @@ -289,20 +289,20 @@ mlx5_rxq_create_devx_rq_resources(struct rte_eth_dev *dev, uint16_t idx) * * @param dev * Pointer to Ethernet device. - * @param idx - * Queue index in DPDK Rx queue array. + * @param rxq_data + * RX queue data. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_rxq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx) +mlx5_rxq_create_devx_cq_resources(struct rte_eth_dev *dev, + struct mlx5_rxq_data *rxq_data) { struct mlx5_devx_cq *cq_obj = 0; struct mlx5_devx_cq_attr cq_attr = { 0 }; struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_dev_ctx_shared *sh = priv->sh; - struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; struct mlx5_rxq_ctrl *rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); unsigned int cqe_n = mlx5_rxq_cqe_num(rxq_data); @@ -497,13 +497,13 @@ mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx) tmpl->fd = mlx5_os_get_devx_channel_fd(tmpl->devx_channel); } /* Create CQ using DevX API. */ - ret = mlx5_rxq_create_devx_cq_resources(dev, idx); + ret = mlx5_rxq_create_devx_cq_resources(dev, rxq_data); if (ret) { DRV_LOG(ERR, "Failed to create CQ."); goto error; } /* Create RQ using DevX API. */ - ret = mlx5_rxq_create_devx_rq_resources(dev, idx); + ret = mlx5_rxq_create_devx_rq_resources(dev, rxq_data); if (ret) { DRV_LOG(ERR, "Port %u Rx queue %u RQ creation failure.", dev->data->port_id, idx); @@ -536,6 +536,11 @@ mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx) * Pointer to Ethernet device. * @param log_n * Log of number of queues in the array. + * @param queues + * List of RX queue indices or NULL, in which case + * the attribute will be filled by drop queue ID. + * @param queues_n + * Size of @p queues array or 0 if it is NULL. * @param ind_tbl * DevX indirection table object. * @@ -563,6 +568,11 @@ mlx5_devx_ind_table_create_rqt_attr(struct rte_eth_dev *dev, } rqt_attr->rqt_max_size = priv->config.ind_table_max_size; rqt_attr->rqt_actual_size = rqt_n; + if (queues == NULL) { + for (i = 0; i < rqt_n; i++) + rqt_attr->rq_list[i] = priv->drop_queue.rxq->rq->id; + return rqt_attr; + } for (i = 0; i != queues_n; ++i) { struct mlx5_rxq_data *rxq = (*priv->rxqs)[queues[i]]; struct mlx5_rxq_ctrl *rxq_ctrl = @@ -595,11 +605,12 @@ mlx5_devx_ind_table_new(struct rte_eth_dev *dev, const unsigned int log_n, { struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_devx_rqt_attr *rqt_attr = NULL; + const uint16_t *queues = dev->data->dev_started ? ind_tbl->queues : + NULL; MLX5_ASSERT(ind_tbl); - rqt_attr = mlx5_devx_ind_table_create_rqt_attr(dev, log_n, - ind_tbl->queues, - ind_tbl->queues_n); + rqt_attr = mlx5_devx_ind_table_create_rqt_attr(dev, log_n, queues, + ind_tbl->queues_n); if (!rqt_attr) return -rte_errno; ind_tbl->rqt = mlx5_devx_cmd_create_rqt(priv->sh->ctx, rqt_attr); @@ -670,7 +681,8 @@ mlx5_devx_ind_table_destroy(struct mlx5_ind_table_obj *ind_tbl) * @param[in] hash_fields * Verbs protocol hash field to make the RSS on. * @param[in] ind_tbl - * Indirection table for TIR. + * Indirection table for TIR. If table queues array is NULL, + * a TIR for drop queue is assumed. * @param[in] tunnel * Tunnel type. * @param[out] tir_attr @@ -686,19 +698,27 @@ mlx5_devx_tir_attr_set(struct rte_eth_dev *dev, const uint8_t *rss_key, int tunnel, struct mlx5_devx_tir_attr *tir_attr) { struct mlx5_priv *priv = dev->data->dev_private; - struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[ind_tbl->queues[0]]; - struct mlx5_rxq_ctrl *rxq_ctrl = - container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); - enum mlx5_rxq_type rxq_obj_type = rxq_ctrl->type; + enum mlx5_rxq_type rxq_obj_type; bool lro = true; uint32_t i; - /* Enable TIR LRO only if all the queues were configured for. */ - for (i = 0; i < ind_tbl->queues_n; ++i) { - if (!(*priv->rxqs)[ind_tbl->queues[i]]->lro) { - lro = false; - break; + /* NULL queues designate drop queue. */ + if (ind_tbl->queues != NULL) { + struct mlx5_rxq_data *rxq_data = + (*priv->rxqs)[ind_tbl->queues[0]]; + struct mlx5_rxq_ctrl *rxq_ctrl = + container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); + rxq_obj_type = rxq_ctrl->type; + + /* Enable TIR LRO only if all the queues were configured for. */ + for (i = 0; i < ind_tbl->queues_n; ++i) { + if (!(*priv->rxqs)[ind_tbl->queues[i]]->lro) { + lro = false; + break; + } } + } else { + rxq_obj_type = priv->drop_queue.rxq->rxq_ctrl->type; } memset(tir_attr, 0, sizeof(*tir_attr)); tir_attr->disp_type = MLX5_TIRC_DISP_TYPE_INDIRECT; @@ -857,7 +877,7 @@ mlx5_devx_hrxq_modify(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq, } /** - * Create a DevX drop action for Rx Hash queue. + * Create a DevX drop Rx queue. * * @param dev * Pointer to Ethernet device. @@ -866,14 +886,99 @@ mlx5_devx_hrxq_modify(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq, * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_devx_drop_action_create(struct rte_eth_dev *dev) +mlx5_rxq_devx_obj_drop_create(struct rte_eth_dev *dev) { - (void)dev; - DRV_LOG(ERR, "DevX drop action is not supported yet."); - rte_errno = ENOTSUP; + struct mlx5_priv *priv = dev->data->dev_private; + int socket_id = dev->device->numa_node; + struct mlx5_rxq_ctrl *rxq_ctrl; + struct mlx5_rxq_data *rxq_data; + struct mlx5_rxq_obj *rxq = NULL; + int ret; + + /* + * Initialize dummy control structures. + * They are required to hold pointers for cleanup + * and are only accessible via drop queue DevX objects. + */ + rxq_ctrl = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*rxq_ctrl), + 0, socket_id); + if (rxq_ctrl == NULL) { + DRV_LOG(ERR, "Port %u could not allocate drop queue control", + dev->data->port_id); + rte_errno = ENOMEM; + goto error; + } + rxq = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*rxq), 0, socket_id); + if (rxq == NULL) { + DRV_LOG(ERR, "Port %u could not allocate drop queue object", + dev->data->port_id); + rte_errno = ENOMEM; + goto error; + } + rxq->rxq_ctrl = rxq_ctrl; + rxq_ctrl->type = MLX5_RXQ_TYPE_STANDARD; + rxq_ctrl->priv = priv; + rxq_ctrl->obj = rxq; + rxq_data = &rxq_ctrl->rxq; + /* Create CQ using DevX API. */ + ret = mlx5_rxq_create_devx_cq_resources(dev, rxq_data); + if (ret != 0) { + DRV_LOG(ERR, "Port %u drop queue CQ creation failed.", + dev->data->port_id); + goto error; + } + /* Create RQ using DevX API. */ + ret = mlx5_rxq_create_devx_rq_resources(dev, rxq_data); + if (ret != 0) { + DRV_LOG(ERR, "Port %u drop queue RQ creation failed.", + dev->data->port_id); + rte_errno = ENOMEM; + goto error; + } + /* Change queue state to ready. */ + ret = mlx5_devx_modify_rq(rxq, MLX5_RXQ_MOD_RST2RDY); + if (ret != 0) + goto error; + /* Initialize drop queue. */ + priv->drop_queue.rxq = rxq; + return 0; +error: + ret = rte_errno; /* Save rte_errno before cleanup. */ + if (rxq != NULL) { + if (rxq->rq_obj.rq != NULL) + mlx5_devx_rq_destroy(&rxq->rq_obj); + if (rxq->cq_obj.cq != NULL) + mlx5_devx_cq_destroy(&rxq->cq_obj); + if (rxq->devx_channel) + mlx5_os_devx_destroy_event_channel + (rxq->devx_channel); + mlx5_free(rxq); + } + if (rxq_ctrl != NULL) + mlx5_free(rxq_ctrl); + rte_errno = ret; /* Restore rte_errno. */ return -rte_errno; } +/** + * Release drop Rx queue resources. + * + * @param dev + * Pointer to Ethernet device. + */ +static void +mlx5_rxq_devx_obj_drop_release(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_rxq_obj *rxq = priv->drop_queue.rxq; + struct mlx5_rxq_ctrl *rxq_ctrl = rxq->rxq_ctrl; + + mlx5_rxq_devx_obj_release(rxq); + mlx5_free(rxq); + mlx5_free(rxq_ctrl); + priv->drop_queue.rxq = NULL; +} + /** * Release a drop hash Rx queue. * @@ -883,9 +988,53 @@ mlx5_devx_drop_action_create(struct rte_eth_dev *dev) static void mlx5_devx_drop_action_destroy(struct rte_eth_dev *dev) { - (void)dev; - DRV_LOG(ERR, "DevX drop action is not supported yet."); - rte_errno = ENOTSUP; + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_hrxq *hrxq = priv->drop_queue.hrxq; + + if (hrxq->tir != NULL) + mlx5_devx_tir_destroy(hrxq); + if (hrxq->ind_table->ind_table != NULL) + mlx5_devx_ind_table_destroy(hrxq->ind_table); + if (priv->drop_queue.rxq->rq != NULL) + mlx5_rxq_devx_obj_drop_release(dev); +} + +/** + * Create a DevX drop action for Rx Hash queue. + * + * @param dev + * Pointer to Ethernet device. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +mlx5_devx_drop_action_create(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_hrxq *hrxq = priv->drop_queue.hrxq; + int ret; + + ret = mlx5_rxq_devx_obj_drop_create(dev); + if (ret != 0) { + DRV_LOG(ERR, "Cannot create drop RX queue"); + return ret; + } + /* hrxq->ind_table queues are NULL, drop RX queue ID will be used */ + ret = mlx5_devx_ind_table_new(dev, 0, hrxq->ind_table); + if (ret != 0) { + DRV_LOG(ERR, "Cannot create drop hash RX queue indirection table"); + goto error; + } + ret = mlx5_devx_hrxq_new(dev, hrxq, /* tunnel */ false); + if (ret != 0) { + DRV_LOG(ERR, "Cannot create drop hash RX queue"); + goto error; + } + return 0; +error: + mlx5_devx_drop_action_destroy(dev); + return ret; } /** From patchwork Fri Oct 15 16:18:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 101803 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 1EAEAA034F; Fri, 15 Oct 2021 18:19:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4440D4120C; Fri, 15 Oct 2021 18:18:57 +0200 (CEST) Received: from AZHDRRW-EX01.nvidia.com (azhdrrw-ex01.nvidia.com [20.51.104.162]) by mails.dpdk.org (Postfix) with ESMTP id 31791411AD; Fri, 15 Oct 2021 18:18:52 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) by mxs.oss.nvidia.com (10.13.234.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.15; Fri, 15 Oct 2021 09:18:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DcnUisDzFc9DXIb51btrZpgXAhHi04Lw4/j0QnvcMLnPgkw1awRkiOvPHU+aNOSiOOJNLo+1rB1FRUiBJB/x3iOoUfPx2l56SiVWkRFV8m91Gp1GzNFFcNIJ6GOqc1gJlpYMnwWnLDMTjLDQPdbOl2E7a3dJ7j3J9M/kP7JRAhu+kwP+ZIEH1/I99W0CWttLMZ9QFBlBfBoCHvXPo5tJathAuj/+xd94BVWBC519F7+QDRW4ywcySqs9xQw7dyQp8OJ3BpfgdveaiuXbtgQfpIbiVXIiPnHPsaiAe1hhYhn7O6Nj2V6gqHLdDfMPTcKLdAKLcw/UaKtr46FEWuhZSA== 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=JYkVMJ8vaoSQDwl1W6yxyP3Fv43hkDLUBJvhvAbizK4=; b=VfjWv+x7lBbDbDTNuC0IXdOFo7Vj6AX1LZOx/LB8DzFgAbltHYsPaoeQlBvuS+UC3a30SnRAzAnbkCQKGnwmiRR1iIdlZ/S9NhWek75A34cGC5oXeifZBgeSRkxyTwFJYbUbqUnFZJ/UlDFQnegX3O1xqpqejgbgBcQwQuXtEp6XIc5LIaNLlypsnfPBMaNjxdeU5fGdlWavqoK+wgt+nDgu04GvXGVjpZboGOQX43HWUt3Mxm+CgCJit/C7BA89VeIK92UUiG94yZc2XVXxifV8q5gziewcohtH3w9lJT+kF7ifzJItqzXousFyGvG+20lqL5oqGzH5X1jtfNRkQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine 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=JYkVMJ8vaoSQDwl1W6yxyP3Fv43hkDLUBJvhvAbizK4=; b=N9lMe4hTz6hZGR33AEtlcZWXQzIxIw0fCrY4ggW+pRhhwvfB20cjl2vHTBch0U9Z/xv3HSCPCid8IyzP4lUwLf+u5v7HyC2nJnv142byKbPPTJ7+Tz00PyId9BQfjZLz/mJy7wvQMbHPt7j2IrLnG6ymNUct6XVTVn2YC3nZHJ22mSdUfd+6uxO7M+OaXSxewAe3Lus8/+BEy6CuCFKdgdFsdMZbpVmOFzDVtc/oPmybf7SeleDqcFw6+0rNyWPvSs+j9vydr1GKzXaZymwBMEMRq5lhUuwe+0Zs4+QfWpIzMh0yE/oURK/oybc+DwgPHAJG6zAcBNdWb08Wltwi3g== Received: from DM6PR18CA0036.namprd18.prod.outlook.com (2603:10b6:5:15b::49) by DM5PR12MB1145.namprd12.prod.outlook.com (2603:10b6:3:77::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Fri, 15 Oct 2021 16:18:49 +0000 Received: from DM6NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b:cafe::8d) by DM6PR18CA0036.outlook.office365.com (2603:10b6:5:15b::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Fri, 15 Oct 2021 16:18:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; 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 DM6NAM11FT012.mail.protection.outlook.com (10.13.173.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Fri, 15 Oct 2021 16:18:49 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 15 Oct 2021 16:18:43 +0000 From: Dmitry Kozlyuk To: CC: , , Matan Azrad , Viacheslav Ovsiienko Date: Fri, 15 Oct 2021 19:18:22 +0300 Message-ID: <20211015161822.3099818-6-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015161822.3099818-1-dkozlyuk@nvidia.com> References: <20211005005216.2427489-1-dkozlyuk@nvidia.com> <20211015161822.3099818-1-dkozlyuk@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0e32a642-375b-40ce-17f2-08d98ff778c9 X-MS-TrafficTypeDiagnostic: DM5PR12MB1145: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:291; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F9Q+XBBMaXclZil0iAd8dL1mg7ZlGARFY74tjmKePuevSGOpo0DO7OxTIxEOotDsRvZBJU49XsoLxVkkA1LvrtUbLhLkKU1aH2KPaHUT22BGujQoaA2Ghg0WOHw0amYGSjBPLaDrRi16fxvahDl7bqkuukuln2OZn1dM98LLrnkiA+rP97CXTkWx3QGPhvNm7fnMA6xXs5dVVy+aof36SLfIn09MOBdBiUPX1XZ54fz7+HOJNhjq78j7Ne5rm33PDKE4YAW3Mc3YGuH0nO1BLIJvKaTMWhNREjhZ9atOwLsaRUjM+4kHXZGuAsfRCgxB5In48zhh3YyMq52ZbrI1F1jmHfpGUTObaZTKLlvDGWm909WP5iY5pZWzSPx2fNXumbwvv+QG0bxJLP0jqDpzOQ1W7trJruucCjpoaIcRwgKn/k/xPYggQsMb9SkRz+Q2JUXyEsJGl0Ikw9ALb2/6fW8p80QWM5wibhfAvtTuvX9mg17Eh11wRvUiQUmVK/xT1gBVQ28p8QWkcGDbW7NloGUiDMDmsxPVinrLKj0ysPBkt6xBPBLSLEO0YEVUdCf6bWwm2DvTa0mlTJnxuHzmlAdI6ExUtChKK0Guoy9damWS0LKlz0vuv1rA0XVLGEp56cJlOIwW+eve9DKIv5IYGcu3XqxdsRuSE+0vNXqD0J2aHKoLovwqtH9iYqUOrSdFeu5gPmG7Wmk41BQVHg9ENw== 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)(46966006)(36840700001)(8936002)(316002)(8676002)(47076005)(5660300002)(508600001)(86362001)(54906003)(6286002)(2906002)(356005)(4326008)(83380400001)(30864003)(82310400003)(450100002)(36756003)(7636003)(6916009)(36860700001)(426003)(186003)(2616005)(6666004)(55016002)(7696005)(16526019)(70586007)(26005)(70206006)(336012)(107886003)(1076003); DIR:OUT; SFP:1101; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2021 16:18:49.1457 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e32a642-375b-40ce-17f2-08d98ff778c9 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: DM6NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1145 Subject: [dpdk-dev] [PATCH v2 5/5] net/mlx5: preserve indirect actions on restart 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" MLX5 PMD uses reference counting to manage RX queue resources. After port stop shared RSS actions kept references to RX queues, preventing resource release. As a result, internal PMD mempool for such queues had been exhausted after a number of port restarts. Diagnostic message from rte_eth_dev_start(): Rx queue allocation failed: Cannot allocate memory Dereference RX queues used by indirect actions on port stop (detach) and restore references on port start (attach) in order to allow RX queue resource release, but keep indirect RSS across the port restart. Replace queue IDs in HW by drop queue ID on detach and restore actual queue IDs on attach. When the port is stopped, create indirect RSS in the detached state. As a result, MLX5 PMD is able to keep all its indirect actions across port restart. Advertise this capability. Fixes: 4b61b8774be9 ("ethdev: introduce indirect flow action") Cc: bingz@nvidia.com Cc: stable@dpdk.org Signed-off-by: Dmitry Kozlyuk Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_ethdev.c | 1 + drivers/net/mlx5/mlx5_flow.c | 194 ++++++++++++++++++++++++++++---- drivers/net/mlx5/mlx5_flow.h | 2 + drivers/net/mlx5/mlx5_rx.h | 4 + drivers/net/mlx5/mlx5_rxq.c | 99 ++++++++++++++-- drivers/net/mlx5/mlx5_trigger.c | 10 ++ 6 files changed, 276 insertions(+), 34 deletions(-) diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index 82e2284d98..419fec3e4e 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -321,6 +321,7 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) info->rx_offload_capa = (mlx5_get_rx_port_offloads() | info->rx_queue_offload_capa); info->tx_offload_capa = mlx5_get_tx_port_offloads(dev); + info->dev_capa = RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP; info->if_index = mlx5_ifindex(dev); info->reta_size = priv->reta_idx_n ? priv->reta_idx_n : config->ind_table_max_size; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index bfc3e20c9a..c10b911259 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1560,6 +1560,58 @@ mlx5_flow_validate_action_queue(const struct rte_flow_action *action, return 0; } +/** + * Validate queue numbers for device RSS. + * + * @param[in] dev + * Configured device. + * @param[in] queues + * Array of queue numbers. + * @param[in] queues_n + * Size of the @p queues array. + * @param[out] error + * On error, filled with a textual error description. + * @param[out] queue + * On error, filled with an offending queue index in @p queues array. + * + * @return + * 0 on success, a negative errno code on error. + */ +static int +mlx5_validate_rss_queues(const struct rte_eth_dev *dev, + const uint16_t *queues, uint32_t queues_n, + const char **error, uint32_t *queue_idx) +{ + const struct mlx5_priv *priv = dev->data->dev_private; + enum mlx5_rxq_type rxq_type = MLX5_RXQ_TYPE_UNDEFINED; + uint32_t i; + + for (i = 0; i != queues_n; ++i) { + struct mlx5_rxq_ctrl *rxq_ctrl; + + if (queues[i] >= priv->rxqs_n) { + *error = "queue index out of range"; + *queue_idx = i; + return -EINVAL; + } + if (!(*priv->rxqs)[queues[i]]) { + *error = "queue is not configured"; + *queue_idx = i; + return -EINVAL; + } + rxq_ctrl = container_of((*priv->rxqs)[queues[i]], + struct mlx5_rxq_ctrl, rxq); + if (i == 0) + rxq_type = rxq_ctrl->type; + if (rxq_type != rxq_ctrl->type) { + *error = "combining hairpin and regular RSS queues is not supported"; + *queue_idx = i; + return -ENOTSUP; + } + } + return 0; +} + /* * Validate the rss action. * @@ -1580,8 +1632,9 @@ mlx5_validate_action_rss(struct rte_eth_dev *dev, { struct mlx5_priv *priv = dev->data->dev_private; const struct rte_flow_action_rss *rss = action->conf; - enum mlx5_rxq_type rxq_type = MLX5_RXQ_TYPE_UNDEFINED; - unsigned int i; + int ret; + const char *message; + uint32_t queue_idx; if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT && rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ) @@ -1645,27 +1698,12 @@ mlx5_validate_action_rss(struct rte_eth_dev *dev, return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, "No queues configured"); - for (i = 0; i != rss->queue_num; ++i) { - struct mlx5_rxq_ctrl *rxq_ctrl; - - if (rss->queue[i] >= priv->rxqs_n) - return rte_flow_error_set - (error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_CONF, - &rss->queue[i], "queue index out of range"); - if (!(*priv->rxqs)[rss->queue[i]]) - return rte_flow_error_set - (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION_CONF, - &rss->queue[i], "queue is not configured"); - rxq_ctrl = container_of((*priv->rxqs)[rss->queue[i]], - struct mlx5_rxq_ctrl, rxq); - if (i == 0) - rxq_type = rxq_ctrl->type; - if (rxq_type != rxq_ctrl->type) - return rte_flow_error_set - (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION_CONF, - &rss->queue[i], - "combining hairpin and regular RSS queues is not supported"); + ret = mlx5_validate_rss_queues(dev, rss->queue, rss->queue_num, + &message, &queue_idx); + if (ret != 0) { + return rte_flow_error_set(error, -ret, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + &rss->queue[queue_idx], message); } return 0; } @@ -8547,6 +8585,116 @@ mlx5_action_handle_flush(struct rte_eth_dev *dev) return ret; } +/** + * Validate existing indirect actions against current device configuration + * and attach them to device resources. + * + * @param dev + * Pointer to Ethernet device. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_action_handle_attach(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_indexed_pool *ipool = + priv->sh->ipool[MLX5_IPOOL_RSS_SHARED_ACTIONS]; + struct mlx5_shared_action_rss *shared_rss, *shared_rss_last; + int ret = 0; + uint32_t idx; + + ILIST_FOREACH(ipool, priv->rss_shared_actions, idx, shared_rss, next) { + struct mlx5_ind_table_obj *ind_tbl = shared_rss->ind_tbl; + const char *message; + uint32_t queue_idx; + + ret = mlx5_validate_rss_queues(dev, ind_tbl->queues, + ind_tbl->queues_n, + &message, &queue_idx); + if (ret != 0) { + DRV_LOG(ERR, "Port %u cannot use queue %u in RSS: %s", + dev->data->port_id, ind_tbl->queues[queue_idx], + message); + break; + } + } + if (ret != 0) + return ret; + ILIST_FOREACH(ipool, priv->rss_shared_actions, idx, shared_rss, next) { + struct mlx5_ind_table_obj *ind_tbl = shared_rss->ind_tbl; + + ret = mlx5_ind_table_obj_attach(dev, ind_tbl); + if (ret != 0) { + DRV_LOG(ERR, "Port %u could not attach " + "indirection table obj %p", + dev->data->port_id, (void *)ind_tbl); + goto error; + } + } + return 0; +error: + shared_rss_last = shared_rss; + ILIST_FOREACH(ipool, priv->rss_shared_actions, idx, shared_rss, next) { + struct mlx5_ind_table_obj *ind_tbl = shared_rss->ind_tbl; + + if (shared_rss == shared_rss_last) + break; + if (mlx5_ind_table_obj_detach(dev, ind_tbl) != 0) + DRV_LOG(CRIT, "Port %u could not detach " + "indirection table obj %p on rollback", + dev->data->port_id, (void *)ind_tbl); + } + return ret; +} + +/** + * Detach indirect actions of the device from its resources. + * + * @param dev + * Pointer to Ethernet device. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_action_handle_detach(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_indexed_pool *ipool = + priv->sh->ipool[MLX5_IPOOL_RSS_SHARED_ACTIONS]; + struct mlx5_shared_action_rss *shared_rss, *shared_rss_last; + int ret = 0; + uint32_t idx; + + ILIST_FOREACH(ipool, priv->rss_shared_actions, idx, shared_rss, next) { + struct mlx5_ind_table_obj *ind_tbl = shared_rss->ind_tbl; + + ret = mlx5_ind_table_obj_detach(dev, ind_tbl); + if (ret != 0) { + DRV_LOG(ERR, "Port %u could not detach " + "indirection table obj %p", + dev->data->port_id, (void *)ind_tbl); + goto error; + } + } + return 0; +error: + shared_rss_last = shared_rss; + ILIST_FOREACH(ipool, priv->rss_shared_actions, idx, shared_rss, next) { + struct mlx5_ind_table_obj *ind_tbl = shared_rss->ind_tbl; + + if (shared_rss == shared_rss_last) + break; + if (mlx5_ind_table_obj_attach(dev, ind_tbl) != 0) + DRV_LOG(CRIT, "Port %u could not attach " + "indirection table obj %p on rollback", + dev->data->port_id, (void *)ind_tbl); + } + return ret; +} + #ifndef HAVE_MLX5DV_DR #define MLX5_DOMAIN_SYNC_FLOW ((1 << 0) | (1 << 1)) #else diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 8f94125f26..6bc7946cc3 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1574,6 +1574,8 @@ void mlx5_flow_destroy_sub_policy_with_rxq(struct rte_eth_dev *dev, struct mlx5_flow_meter_policy *mtr_policy); int mlx5_flow_dv_discover_counter_offset_support(struct rte_eth_dev *dev); int mlx5_flow_discover_dr_action_support(struct rte_eth_dev *dev); +int mlx5_action_handle_attach(struct rte_eth_dev *dev); +int mlx5_action_handle_detach(struct rte_eth_dev *dev); int mlx5_action_handle_flush(struct rte_eth_dev *dev); void mlx5_release_tunnel_hub(struct mlx5_dev_ctx_shared *sh, uint16_t port_id); int mlx5_alloc_tunnel_hub(struct mlx5_dev_ctx_shared *sh); diff --git a/drivers/net/mlx5/mlx5_rx.h b/drivers/net/mlx5/mlx5_rx.h index 2b7ad3e48b..d44c8078de 100644 --- a/drivers/net/mlx5/mlx5_rx.h +++ b/drivers/net/mlx5/mlx5_rx.h @@ -222,6 +222,10 @@ int mlx5_ind_table_obj_modify(struct rte_eth_dev *dev, struct mlx5_ind_table_obj *ind_tbl, uint16_t *queues, const uint32_t queues_n, bool standalone); +int mlx5_ind_table_obj_attach(struct rte_eth_dev *dev, + struct mlx5_ind_table_obj *ind_tbl); +int mlx5_ind_table_obj_detach(struct rte_eth_dev *dev, + struct mlx5_ind_table_obj *ind_tbl); struct mlx5_list_entry *mlx5_hrxq_create_cb(void *tool_ctx, void *cb_ctx); int mlx5_hrxq_match_cb(void *tool_ctx, struct mlx5_list_entry *entry, void *cb_ctx); diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index b68443bed5..fd2b5779ff 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -2015,6 +2015,26 @@ mlx5_ind_table_obj_new(struct rte_eth_dev *dev, const uint16_t *queues, return ind_tbl; } +static int +mlx5_ind_table_obj_check_standalone(struct rte_eth_dev *dev __rte_unused, + struct mlx5_ind_table_obj *ind_tbl) +{ + uint32_t refcnt; + + refcnt = __atomic_load_n(&ind_tbl->refcnt, __ATOMIC_RELAXED); + if (refcnt <= 1) + return 0; + /* + * Modification of indirection tables having more than 1 + * reference is unsupported. + */ + DRV_LOG(DEBUG, + "Port %u cannot modify indirection table %p (refcnt %u > 1).", + dev->data->port_id, (void *)ind_tbl, refcnt); + rte_errno = EINVAL; + return -rte_errno; +} + /** * Modify an indirection table. * @@ -2047,18 +2067,8 @@ mlx5_ind_table_obj_modify(struct rte_eth_dev *dev, MLX5_ASSERT(standalone); RTE_SET_USED(standalone); - if (__atomic_load_n(&ind_tbl->refcnt, __ATOMIC_RELAXED) > 1) { - /* - * Modification of indirection ntables having more than 1 - * reference unsupported. Intended for standalone indirection - * tables only. - */ - DRV_LOG(DEBUG, - "Port %u cannot modify indirection table (refcnt> 1).", - dev->data->port_id); - rte_errno = EINVAL; + if (mlx5_ind_table_obj_check_standalone(dev, ind_tbl) < 0) return -rte_errno; - } for (i = 0; i != queues_n; ++i) { if (!mlx5_rxq_get(dev, queues[i])) { ret = -rte_errno; @@ -2084,6 +2094,73 @@ mlx5_ind_table_obj_modify(struct rte_eth_dev *dev, return ret; } +/** + * Attach an indirection table to its queues. + * + * @param dev + * Pointer to Ethernet device. + * @param ind_table + * Indirection table to attach. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_ind_table_obj_attach(struct rte_eth_dev *dev, + struct mlx5_ind_table_obj *ind_tbl) +{ + unsigned int i; + int ret; + + ret = mlx5_ind_table_obj_modify(dev, ind_tbl, ind_tbl->queues, + ind_tbl->queues_n, true); + if (ret != 0) { + DRV_LOG(ERR, "Port %u could not modify indirect table obj %p", + dev->data->port_id, (void *)ind_tbl); + return ret; + } + for (i = 0; i < ind_tbl->queues_n; i++) + mlx5_rxq_get(dev, ind_tbl->queues[i]); + return 0; +} + +/** + * Detach an indirection table from its queues. + * + * @param dev + * Pointer to Ethernet device. + * @param ind_table + * Indirection table to detach. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_ind_table_obj_detach(struct rte_eth_dev *dev, + struct mlx5_ind_table_obj *ind_tbl) +{ + struct mlx5_priv *priv = dev->data->dev_private; + const unsigned int n = rte_is_power_of_2(ind_tbl->queues_n) ? + log2above(ind_tbl->queues_n) : + log2above(priv->config.ind_table_max_size); + unsigned int i; + int ret; + + ret = mlx5_ind_table_obj_check_standalone(dev, ind_tbl); + if (ret != 0) + return ret; + MLX5_ASSERT(priv->obj_ops.ind_table_modify); + ret = priv->obj_ops.ind_table_modify(dev, n, NULL, 0, ind_tbl); + if (ret != 0) { + DRV_LOG(ERR, "Port %u could not modify indirect table obj %p", + dev->data->port_id, (void *)ind_tbl); + return ret; + } + for (i = 0; i < ind_tbl->queues_n; i++) + mlx5_rxq_release(dev, ind_tbl->queues[i]); + return ret; +} + int mlx5_hrxq_match_cb(void *tool_ctx __rte_unused, struct mlx5_list_entry *entry, void *cb_ctx) diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c index 54173bfacb..c3adf5082e 100644 --- a/drivers/net/mlx5/mlx5_trigger.c +++ b/drivers/net/mlx5/mlx5_trigger.c @@ -14,6 +14,7 @@ #include #include "mlx5.h" +#include "mlx5_flow.h" #include "mlx5_mr.h" #include "mlx5_rx.h" #include "mlx5_tx.h" @@ -1113,6 +1114,14 @@ mlx5_dev_start(struct rte_eth_dev *dev) mlx5_rxq_timestamp_set(dev); /* Set a mask and offset of scheduling on timestamp into Tx queues. */ mlx5_txq_dynf_timestamp_set(dev); + /* Attach indirection table objects detached on port stop. */ + ret = mlx5_action_handle_attach(dev); + if (ret) { + DRV_LOG(ERR, + "port %u failed to attach indirect actions: %s", + dev->data->port_id, rte_strerror(rte_errno)); + goto error; + } /* * In non-cached mode, it only needs to start the default mreg copy * action and no flow created by application exists anymore. @@ -1185,6 +1194,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev) /* All RX queue flags will be cleared in the flush interface. */ mlx5_flow_list_flush(dev, MLX5_FLOW_TYPE_GEN, true); mlx5_flow_meter_rxq_flush(dev); + mlx5_action_handle_detach(dev); mlx5_rx_intr_vec_disable(dev); priv->sh->port[priv->dev_port - 1].ih_port_id = RTE_MAX_ETHPORTS; priv->sh->port[priv->dev_port - 1].devx_ih_port_id = RTE_MAX_ETHPORTS;