From patchwork Tue Dec 6 18:51:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13066214 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03D63C4708C for ; Tue, 6 Dec 2022 18:52:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229685AbiLFSwD (ORCPT ); Tue, 6 Dec 2022 13:52:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229781AbiLFSwC (ORCPT ); Tue, 6 Dec 2022 13:52:02 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 187D23D902 for ; Tue, 6 Dec 2022 10:51:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FVYZUInk70y3QK0PhhAWp2dwMNZXe+t7Xd+plYZ6kiGdu2+KwvwzOqo4gCLWUO5wEP4CseXtCf9Ce7mXPWLpC7hbLUHFFMhyaivjWtg0I2THH59RI3Qe2OvzRGR03my18PU2+fJXBvznM6G7pgwYDjCJC/AV/b1XQXtOq/cFSWYtVqeTwRR+uVKOOz9bGcMv4wSjohobcOyl6mWHTXGCbbUhxh2thIClKTnuzse0unJAVjHif0wNRnPMNZJ/T/KE2xmvZ/cZwVyuOAGNLaeUcU1A8oySN6s5kAPRCIUpHqVMnIu18vBrUkCEJYI7wyLoC/F44fSBnWAV3sG3ZZsjqg== 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=LTny/6TSqOFfO8nfwISfiiAAkcHEXJpf2tH80vHe5Fw=; b=dgKu1zwvX/S1CEuJXhTCqjZnl8hX43S+2ny9wxgWJxsOk3lYrUQ4RKIhhMKuRviLdi+qbQdNUXFCYzwg9Peclb7aagoEThErQCIsTJkMlOxVKZgFHeCLr3+nvgzK4KzxiOyrH1XCMGOAUrRS14iswMItc8soe6XomT7lBCAWm0tkx1Z/N4r1d3N//+/vEAa731feFSSxGz1GSyNvZsyfZGRlP8RZtbbtCzQYcHV6NZjhY68/wP6Trj9YlAz2xHwzvPD1o34fPVLcEae1jPPWa1AJzmUB4trhYXloc8MG3gJHdx/fcaXB/9K/M1eOBqorPhAH2jKp2gBzhVZbBYRqeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LTny/6TSqOFfO8nfwISfiiAAkcHEXJpf2tH80vHe5Fw=; b=GW/xvObYY1wPiQXP71J623M3sdh6tE5KvoIBesIcHtTG8uU530/lsjNr24RWiYwoUkUUs+iDsbJq9geC9juW90jqH8cBaO/pVHmB+NlFAZCJINKgXUNuc0Sql+B1dZx5XS8OmBE3hLBfJrw3Yk8IAOO6sA2qYdPBctOyKqNY5C+73GjXG9GnCXF8kUI0s6dQJaPK6SllvKWNMGrGPUQ+dcJY7tJ9EySGp2+Q91rMRrnml6TcehOKGFK/YQG2UrM1He23HPDNC+7qGF6pfO/WSKWirV6DWtLVWpB6tYSi/CyOwLYo8xU/YLuWIyBCX0/2CE3lAaAHWUA8FKdnhF+bFQ== Received: from BN8PR12CA0009.namprd12.prod.outlook.com (2603:10b6:408:60::22) by SJ1PR12MB6291.namprd12.prod.outlook.com (2603:10b6:a03:456::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Tue, 6 Dec 2022 18:51:57 +0000 Received: from BN8NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:408:60:cafe::e9) by BN8PR12CA0009.outlook.office365.com (2603:10b6:408:60::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Tue, 6 Dec 2022 18:51:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT025.mail.protection.outlook.com (10.13.177.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5901.14 via Frontend Transport; Tue, 6 Dec 2022 18:51:56 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:33 -0800 Received: from nps-server-23.mtl.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:30 -0800 From: Shay Drory To: , , CC: , , , , Subject: [PATCH net-next V4 1/8] net/mlx5: Introduce IFC bits for migratable Date: Tue, 6 Dec 2022 20:51:12 +0200 Message-ID: <20221206185119.380138-2-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206185119.380138-1-shayd@nvidia.com> References: <20221206185119.380138-1-shayd@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT025:EE_|SJ1PR12MB6291:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f0e3a5f-ba51-461d-5ed3-08dad7baf2c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5ALvhjv/IvfRDqXoefz1cgIOVOwpzez+OZvfnL1dnYhfHqWzaQ9jzbeG9tCePf35K6b+eOr+J8fgZt5EGMLfdOztVurq0YqtG4cj1XdC3xzF2IMscvyBb/gfxj74nEO91KyfRvbq9zVcunoK3uXmKlJWf9TsDNd6PqR/4Ue86yvjvS/MhPicM8Ko0ueEn75cWJIe7rA9viGa/AGok//nMPly+S5qJqfXwuT1x22ZWJQhKNxReE8uBHJXZ+fnsXXHggurXdE1i/BdKs1w6hKJDmfK64xdWXeQGI9EgJFHLj6FXHg0aDpvdHLpVWBTZBoiMng6GhYLnYvVAXXSVzV6wjyd1QwcDZ5gyRaV6LsFK9CA5F9ruAmTDvBaZEoRvd4kpzIJvjC1j8uPyD61VZ9B60UJMoCbl9qyPb32F6FzCA6Un3RYIky81fGKLPhn9QTSnv34HviVnlS1RN74CgS/e6i6JonCrgr3+W4I+Q+Rd24hYqDw7p6/gLwr6FKj+yokdiJudlrpu4nKrbkzLpR3epEyEusJPkKmlpzqsXBzVQQRk6Q5yGtJ+DVQhYv3oTLbjxqm0BJAcvjNYClqdEbFstITPht3ROJyDZKyi6ItD0XFcJ2w0EC+3NdX1a4ZHEVEda+vnyJTpQLbGTiyBWbSvZV7PBjOAtPE886WE0+e2duVKIFgXsMwC+1apO0xEnZd3IWYiRRyOjDu1fEEAD4hBQ== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(136003)(396003)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(478600001)(16526019)(107886003)(47076005)(316002)(82740400003)(2906002)(41300700001)(26005)(6666004)(186003)(110136005)(82310400005)(86362001)(40460700003)(336012)(54906003)(36756003)(40480700001)(426003)(36860700001)(70586007)(70206006)(5660300002)(2616005)(8936002)(356005)(7636003)(1076003)(4326008)(8676002)(83380400001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2022 18:51:56.1094 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4f0e3a5f-ba51-461d-5ed3-08dad7baf2c3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6291 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Yishai Hadas Introduce IFC related capabilities to enable setting VF to be able to perform live migration. e.g.: to be migratable. Signed-off-by: Yishai Hadas Reviewed-by: Mark Bloch Acked-by: Saeed Mahameed --- include/linux/mlx5/mlx5_ifc.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h index 5a4e914e2a6f..2093131483c7 100644 --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h @@ -68,6 +68,7 @@ enum { MLX5_SET_HCA_CAP_OP_MOD_ODP = 0x2, MLX5_SET_HCA_CAP_OP_MOD_ATOMIC = 0x3, MLX5_SET_HCA_CAP_OP_MOD_ROCE = 0x4, + MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE2 = 0x20, MLX5_SET_HCA_CAP_OP_MODE_PORT_SELECTION = 0x25, }; @@ -1875,7 +1876,10 @@ struct mlx5_ifc_cmd_hca_cap_bits { }; struct mlx5_ifc_cmd_hca_cap_2_bits { - u8 reserved_at_0[0xa0]; + u8 reserved_at_0[0x80]; + + u8 migratable[0x1]; + u8 reserved_at_81[0x1f]; u8 max_reformat_insert_size[0x8]; u8 max_reformat_insert_offset[0x8]; From patchwork Tue Dec 6 18:51:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13066212 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3F6AC352A1 for ; Tue, 6 Dec 2022 18:51:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229744AbiLFSvx (ORCPT ); Tue, 6 Dec 2022 13:51:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229507AbiLFSvv (ORCPT ); Tue, 6 Dec 2022 13:51:51 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2077.outbound.protection.outlook.com [40.107.94.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E15ED3B9C1 for ; Tue, 6 Dec 2022 10:51:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AiEQU2alY19jukEl6HTi6wxvf9G0fyO8mUvvl+HKkD86gzJL0SsEmGRyLbQAwxIQ1xyaaRlhioupEc2bNITqml1P6vWxGSsdXB76A5bIPEGYsIXLnnHkjbPpUhSwUgpTDO91XZAZ3wbnNYqOfUcT+UczjSoWadWQnBmd5RcBEG81DbHLld/u0gw/Svg3D2iqxwSZ58rLqhR+06YFExPlrNcRmmoWb+OyRRWKDYAS/sooVy9IMMSFD5EDh9uRVEN/xOpmZFLwEYhaC/y4gmiijVTjsvE12tOcETc3Lsx66oKWd/pb8FwPqF6t64HQXWQkA7bAKMeFpSy3d3EnM5nuuA== 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=XEk75armTjQMXhv/3iXutSaYHINTuBgEa3LZ8ajTnKk=; b=iUi44nBdXfY1t2z1Tpl4UdtKeYLdQhw7dqNa6W7nhujqyrwJIEkEQB8C7XwHAllrdMmJEeKwSop/4POyw3gQV5ISG8VQIbGHrdpixOGpsPN56ayxFNdqkzBPpeX9Jg2fxQMwpcOOVmoh3dKI9cMRTZqvD6H1JMf+EB5WUrWyyDfe+qRBis8TV85GA+JUi/On1aDm4Lnjsee3QpjSHT9zYkm0bOOv7v5Sbx6YY1P9UqZHzI4vbfcJYqy8Nw5y3uFEHkmETYPGRHq+vNHD/XctYDTC7+0imM6On2MDJggTrkHRnpSWPwK/YP3uumd+RqRDOM+cxE+6pAfTHGIj5YKkwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XEk75armTjQMXhv/3iXutSaYHINTuBgEa3LZ8ajTnKk=; b=rX1/pVFqFyjQCEQGy2gGtE9YPKJUt816NXE8D8o72lTlvjDrnTSooqJQESn66rGlgirJqV+iqa2asxNXy6rghnLDFqFoCTefiarjO0sqU0Y/Oq4gyWdMfDrrjaiQcxnpk/vdFtKKm9W1ZOO0iE84ecElye+0sAnyak0rReEC9na1N9+VOaecYhP6Sbe+er0YaRg2+gwWfV2gsjwCR/dd37zco0Pu2sMCKd3nqWcDg+gHbkxu5dxIwdjt78OdPGWGWLPGknwKMjBoxnLwHMTivB7gbD2VDcLkGXQrrTPG3BIXyJCtErTCW9fgecpSSlf11mOW1Yeta+7I8q8LgbbUjA== Received: from DS7PR06CA0040.namprd06.prod.outlook.com (2603:10b6:8:54::28) by CH2PR12MB4101.namprd12.prod.outlook.com (2603:10b6:610:a8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Tue, 6 Dec 2022 18:51:46 +0000 Received: from DS1PEPF0000E645.namprd02.prod.outlook.com (2603:10b6:8:54:cafe::20) by DS7PR06CA0040.outlook.office365.com (2603:10b6:8:54::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Tue, 6 Dec 2022 18:51:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DS1PEPF0000E645.mail.protection.outlook.com (10.167.17.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Tue, 6 Dec 2022 18:51:46 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:36 -0800 Received: from nps-server-23.mtl.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:34 -0800 From: Shay Drory To: , , CC: , , , , , Shay Drory Subject: [PATCH net-next V4 2/8] devlink: Validate port function request Date: Tue, 6 Dec 2022 20:51:13 +0200 Message-ID: <20221206185119.380138-3-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206185119.380138-1-shayd@nvidia.com> References: <20221206185119.380138-1-shayd@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E645:EE_|CH2PR12MB4101:EE_ X-MS-Office365-Filtering-Correlation-Id: 47588b28-e1f3-4029-0cb7-08dad7baecdf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZNfLPyLOT0MDFJj3rh3Bqgq/yp0RgEgyn+L0xD/OxjrRtG4yD4GDp8cIcWXgbJwzUe3a0iE9Ex6ri7xNt5hqaclchjtdYg0WfdF8mHUjKonf3vLFE2nfGKY1dKQRFTo5DB8YsEJtmAQA96cYB2AZ5h0GTvNQKIUofBOfkS4xvp8DVY1G037E2LO/88oY4GWabv/OI39pmVdumnDEH8mQE9GxuYRdVVC8eTq/AFGIWzawaGJU+y0OhxO59q7SNUkMu51UupxDyDAuqld5fPWRBUyMMvbySjYXMMg3vXTb7ARaPminyjaNsJefd6UUEleXQZZmjMSWbssygAeMwadz0zWyYf5E2VXF9aqeyYsQ5WBMH8dK5YXWe8doeTAKCR2J5od/G9NJGyzAlmXP5LTRkqYuZFGwFJCgHOJ7WAhmatQ67ObJWiLAB3EvFbo8403QAosO2zI9XIzjojfEz2/N6B+AUSNrTBkZ0KPgTkqGR6HP+w7KJfvb+wI7m9WVqdaDiEzeib9tAfj0vgna3gPDnc+s0d3ScpdVeirumUtbhkfyyvG6iRDTrfDkaZl9OFegnF1JofEGzt6xXQl2R/Z8orLGUfO4hSWZpedNSjSyLmQDrfTcHlmU+3U/0jqA8y8OtTEq2/fLOPHPCHRrC78hQiZ9zmlUuX4GpQ+beYvS87UsKdtC+IWE/f7b2ei32ENJXZABYgGzKF+t3o1C7YW6XA== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(39860400002)(396003)(346002)(136003)(451199015)(36840700001)(40470700004)(46966006)(26005)(110136005)(54906003)(478600001)(107886003)(6666004)(36756003)(426003)(47076005)(40480700001)(82740400003)(356005)(7636003)(86362001)(186003)(16526019)(1076003)(2616005)(336012)(36860700001)(82310400005)(83380400001)(40460700003)(15650500001)(2906002)(5660300002)(4326008)(70206006)(70586007)(8676002)(8936002)(41300700001)(316002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2022 18:51:46.2713 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 47588b28-e1f3-4029-0cb7-08dad7baecdf X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E645.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4101 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In order to avoid partial request processing, validate the request before processing it. Signed-off-by: Shay Drory Reviewed-by: Jiri Pirko --- net/core/devlink.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index 907df7124157..035249c5dd17 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -1632,11 +1632,6 @@ static int devlink_port_function_hw_addr_set(struct devlink_port *port, } } - if (!ops->port_function_hw_addr_set) { - NL_SET_ERR_MSG_MOD(extack, "Port doesn't support function attributes"); - return -EOPNOTSUPP; - } - return ops->port_function_hw_addr_set(port, hw_addr, hw_addr_len, extack); } @@ -1650,12 +1645,27 @@ static int devlink_port_fn_state_set(struct devlink_port *port, state = nla_get_u8(attr); ops = port->devlink->ops; - if (!ops->port_fn_state_set) { - NL_SET_ERR_MSG_MOD(extack, - "Function does not support state setting"); + return ops->port_fn_state_set(port, state, extack); +} + +static int devlink_port_function_validate(struct devlink_port *devlink_port, + struct nlattr **tb, + struct netlink_ext_ack *extack) +{ + const struct devlink_ops *ops = devlink_port->devlink->ops; + + if (tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR] && + !ops->port_function_hw_addr_set) { + NL_SET_ERR_MSG_ATTR(extack, tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR], + "Port doesn't support function attributes"); return -EOPNOTSUPP; } - return ops->port_fn_state_set(port, state, extack); + if (tb[DEVLINK_PORT_FN_ATTR_STATE] && !ops->port_fn_state_set) { + NL_SET_ERR_MSG_ATTR(extack, tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR], + "Function does not support state setting"); + return -EOPNOTSUPP; + } + return 0; } static int devlink_port_function_set(struct devlink_port *port, @@ -1672,6 +1682,10 @@ static int devlink_port_function_set(struct devlink_port *port, return err; } + err = devlink_port_function_validate(port, tb, extack); + if (err) + return err; + attr = tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR]; if (attr) { err = devlink_port_function_hw_addr_set(port, attr, extack); From patchwork Tue Dec 6 18:51:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13066216 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8603C3A5A7 for ; Tue, 6 Dec 2022 18:52:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbiLFSwQ (ORCPT ); Tue, 6 Dec 2022 13:52:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229786AbiLFSwG (ORCPT ); Tue, 6 Dec 2022 13:52:06 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D296E3B9CE for ; Tue, 6 Dec 2022 10:52:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bv+o5BNtacKQhSOURWGIvcfl7DiXhmcNfDWAVek42XL1ErmP1YrEtlaVRH5UXnTXdKb+lBXZjpgbhrbfDWznjweOxgFKy5vvAlyegyfwLRVDMTtx6uzvgsOc3eoHLxjwg9GJvjDfJ2wVITAiOviOnc9UpFLGxwll1yllDk6En0lTUJAGDeNSUxF548jIV5hBfT35ltQg8EvxKJjzkRys/c1BgPAdJYCIJWzKqEqe6c3XvwthRZG73zqWKUkDVDWIzU3E4TVv6LasXmdAQL8mzh/r1OI4d59F5RrT0o0EEWLra/kk4c6FUjXkxpB2rH/nqsUt6VuIxwpKuHkWpGh32A== 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=eyoKRFtcXRa9rAoJOTbpVBI3U6fZeK8XoRhc+Ac85Ak=; b=BndtwysYes7PV2xVVeAK8hmvr4Y8ARlD0kbfyiK15zWsw/RKXU7dUIn3cIhrBfwuOuuK97BL03NX65JgGtk5FUr0uY7vI0IVKIgLafjOmgu5JjcsvOCogYdVZ6k69NPQjqBcPo6TRhEYw9JixLKxA3ajagBWlbTxXLhsUpiM8dtPwXtO9ZrfgUbhi00n/3K4fUGBcpkh13EONagnGyKRK6XBtMUh6g/R0bKwEhXH7NL5ZkXiXhSQy+Qhs8UupjkcCmVhiLj14pOErE4lwa+tQzfzQoR2F+dSe6/TC9GqER6fTnMNxj3dLLwK3hbTldgNDwSrU9sfhZxBNHGa0ygTcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eyoKRFtcXRa9rAoJOTbpVBI3U6fZeK8XoRhc+Ac85Ak=; b=cXzAeQccGLWz+QWaPyHletpnye25iC76GnmOepWiurnnBZtsuphuclAH56OhBIaXNKjwbtIZ0H+4hXsnCAlV39f8ByRzc30xYu9axtfIEMlnCuRIVQTunTwUVwMMLIe0UyBkdhkexLgJSNv/JorP2Fq7mIFjK2n4SLsE40LGBeVpxxxtVTg2EShjMGivNfa1ASdaGDdHzp9YUMDzjRajY8LqdzxleX9CA7Glrqm9dfxOVC4UOTGxnCGczkQhvJa5WWHOJmDEdRk1cOQTqRXlS6HFHykjlckA684o9kWeDSKK6dht8U7OgcaCf6zz0+kMYPIhNvS8bHd7Oyx5cw1TeQ== Received: from BN8PR12CA0019.namprd12.prod.outlook.com (2603:10b6:408:60::32) by DM4PR12MB6063.namprd12.prod.outlook.com (2603:10b6:8:b1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Tue, 6 Dec 2022 18:51:59 +0000 Received: from BN8NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:408:60:cafe::9e) by BN8PR12CA0019.outlook.office365.com (2603:10b6:408:60::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Tue, 6 Dec 2022 18:51:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT025.mail.protection.outlook.com (10.13.177.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5901.14 via Frontend Transport; Tue, 6 Dec 2022 18:51:58 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:40 -0800 Received: from nps-server-23.mtl.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:37 -0800 From: Shay Drory To: , , CC: , , , , , Shay Drory Subject: [PATCH net-next V4 3/8] devlink: Move devlink port function hw_addr attr documentation Date: Tue, 6 Dec 2022 20:51:14 +0200 Message-ID: <20221206185119.380138-4-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206185119.380138-1-shayd@nvidia.com> References: <20221206185119.380138-1-shayd@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT025:EE_|DM4PR12MB6063:EE_ X-MS-Office365-Filtering-Correlation-Id: 66dfcea2-9ea2-4ca8-2fcb-08dad7baf462 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iRVp+3DeS5STqLMq+Wnl+RHLBhkL9CUhXl91pW/+2jCw+En20Z4iOArZqWK/jkiJzFEj6Vje7ObDxV7jHvBjvayHH/7ja24W3RZAAF6OV4HubhbNQGSjjflfNj2aGjkw1QphHKRd+VkSPiZ/4TiOS7AgYD2UMNQStg6Y8BdGu7GPek8NK0xiD4o5t1d2d4K9uTAbhtXkyxrYv0PIfIhcFcldULFaciD7uoqBZ/+HxlOHgtLpXM2W2QCb32mzoAxqMDz1St+MzE/jGMSqTTTGgKPNAt+Bt289O3aP7Or0T8zTUk6DAyNs6L/dtNdUpzBaR9FfuAbhDxcC8xFOdoyu3IKwwlGgBzUp58I0+cfCIv/UDU1OvWPHFxuUoJipqzooqABQg+QDKG1d/lBeQshArakx1uH3WKN3svjOcafoU4q8rVt4GKjd5DYq0rm1w+z3Pl6N7ceK6xT8dnnDvA8LFYuApSSiRy9LI4SuH02eNJ5FX1Sr3gHemPqfyJn4v1W3dJwjNF+rTL72YtjsWourIZHoMY3lOuZ1a0EwO+hh09VF4meT5XGrZW1NXRHWuekqQ8MXBWc9Kl3Uqs0RpCOBpSHN65M8vbD0MJQSfOv7rI2F9DhbpzflEuPABD0QrRkubxmSKSYIMmTHR5CvoDijcvX0yj0QSepDw3dc/1PXb2FZnUdgmTHDCGMp4rqy8+h4Y+YTQE41oPNfw/KlScAXtw== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(136003)(396003)(376002)(451199015)(36840700001)(40470700004)(46966006)(41300700001)(186003)(16526019)(36860700001)(1076003)(478600001)(6666004)(86362001)(107886003)(82310400005)(2616005)(426003)(26005)(47076005)(336012)(82740400003)(356005)(7636003)(2906002)(8936002)(70206006)(5660300002)(8676002)(54906003)(4326008)(36756003)(40460700003)(316002)(70586007)(110136005)(83380400001)(40480700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2022 18:51:58.8279 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66dfcea2-9ea2-4ca8-2fcb-08dad7baf462 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6063 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org devlink port function hw_addr attr documentation is in mlx5 specific file while there is nothing mlx5 specific about it. Move it to devlink-port.rst. Signed-off-by: Shay Drory Reviewed-by: Jiri Pirko --- .../device_drivers/ethernet/mellanox/mlx5.rst | 38 +---------------- .../networking/devlink/devlink-port.rst | 42 ++++++++++++++++++- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst b/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst index e8fa7ac9e6b1..07cfc1b07db3 100644 --- a/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst +++ b/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst @@ -351,42 +351,8 @@ driver. MAC address setup ----------------- -mlx5 driver provides mechanism to setup the MAC address of the PCI VF/SF. - -The configured MAC address of the PCI VF/SF will be used by netdevice and rdma -device created for the PCI VF/SF. - -- Get the MAC address of the VF identified by its unique devlink port index:: - - $ devlink port show pci/0000:06:00.0/2 - pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 - function: - hw_addr 00:00:00:00:00:00 - -- Set the MAC address of the VF identified by its unique devlink port index:: - - $ devlink port function set pci/0000:06:00.0/2 hw_addr 00:11:22:33:44:55 - - $ devlink port show pci/0000:06:00.0/2 - pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 - function: - hw_addr 00:11:22:33:44:55 - -- Get the MAC address of the SF identified by its unique devlink port index:: - - $ devlink port show pci/0000:06:00.0/32768 - pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88 - function: - hw_addr 00:00:00:00:00:00 - -- Set the MAC address of the SF identified by its unique devlink port index:: - - $ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 - - $ devlink port show pci/0000:06:00.0/32768 - pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88 - function: - hw_addr 00:00:00:00:88:88 +mlx5 driver support devlink port function attr mechanism to setup MAC +address. (refer to Documentation/networking/devlink/devlink-port.rst) SF state setup -------------- diff --git a/Documentation/networking/devlink/devlink-port.rst b/Documentation/networking/devlink/devlink-port.rst index 98557c2ab1c1..2c637f4aae8e 100644 --- a/Documentation/networking/devlink/devlink-port.rst +++ b/Documentation/networking/devlink/devlink-port.rst @@ -119,9 +119,49 @@ function device to the driver. For subfunctions, this means user should configure port function attribute before activating the port function. A user may set the hardware address of the function using -'devlink port function set hw_addr' command. For Ethernet port function +`devlink port function set hw_addr` command. For Ethernet port function this means a MAC address. +Function attributes +=================== + +MAC address setup +----------------- +The configured MAC address of the PCI VF/SF will be used by netdevice and rdma +device created for the PCI VF/SF. + +- Get the MAC address of the VF identified by its unique devlink port index:: + + $ devlink port show pci/0000:06:00.0/2 + pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 + function: + hw_addr 00:00:00:00:00:00 + +- Set the MAC address of the VF identified by its unique devlink port index:: + + $ devlink port function set pci/0000:06:00.0/2 hw_addr 00:11:22:33:44:55 + + $ devlink port show pci/0000:06:00.0/2 + pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 + function: + hw_addr 00:11:22:33:44:55 + +- Get the MAC address of the SF identified by its unique devlink port index:: + + $ devlink port show pci/0000:06:00.0/32768 + pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88 + function: + hw_addr 00:00:00:00:00:00 + +- Set the MAC address of the SF identified by its unique devlink port index:: + + $ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 + + $ devlink port show pci/0000:06:00.0/32768 + pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88 + function: + hw_addr 00:00:00:00:88:88 + Subfunction ============ From patchwork Tue Dec 6 18:51:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13066213 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72535C352A1 for ; Tue, 6 Dec 2022 18:52:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229787AbiLFSwB (ORCPT ); Tue, 6 Dec 2022 13:52:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbiLFSv7 (ORCPT ); Tue, 6 Dec 2022 13:51:59 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2074.outbound.protection.outlook.com [40.107.94.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C39023B9CE for ; Tue, 6 Dec 2022 10:51:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CjxrnS1RT2yy95cKE+V/LtUyIXna+jH7/Es32JyEa25ed9zhRRPkWh1NDVQFnv2nRF4kbjxG/c2nNl+awACLiLiJljpUhxauD5eB1YsFNL1WvKCI6u66FssIzvXDT8NLZs62FVft7Mis4/HX7FMmNebVIlqUbJ3MHfnE3+d2FoiahO+REa79rZeIk2lvxL5D7OSC4Jn/EIHfpAQjLTZzGFAeQlYVRV+jdszLjXB94fyq6uiAycgijXgyghKsKhsiXKf7k2+JzK4rlmpImZlgUyPx67GXjA6hbqiuoZMYx1ME9+aH4eQ1Z5R+L9efE7L4M8vaezStbwK09nD5htSGjw== 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=zpRDAUU0UvG5X5FYsrar0ok1kKUQteygubuyxk1Lo1M=; b=P9eOocMzJwVz3U8KabeGTyiTvEjc84iXsKHDDeaj6QoxkkLxdh7AHWIaWxsQFcXtpZuHsymc8azI626Nsm6GIlQFQZ3ju/Vsr4QGIBFFb01axKLzaLNDjyHS7ER2/y3rvAVyAYD8cIA1rTH+IRZEgFEzsuAPqvk40SUAFSWj3w7Eu1g0fT2uSVvQ/NgeoORD9Otr4PJqdRBluLuJu9SQO89yqBy/OrTfklf6+eo47k04v8Zed7QyWQs915WV2Wxb/Ltgh4qpZMBWsgwDHNFZrhCXe35PcUQMeM7HP6ZLWs3JqCUpAyq1M/D6F8uGvvf+hCZ/do0ZtynlDS/8usMCjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zpRDAUU0UvG5X5FYsrar0ok1kKUQteygubuyxk1Lo1M=; b=os/1gctkBwgP2MzuY50JtFro82ulmu2rMgHfeW7dLm5/PyEX/+nP5jnjZrbbd7DuIc63ybdNVVk2cC8sTTzaZd8M+NVqUhb8bUBvocEngP/NIR9fB/Ag53aEONZzkZyx+X0gno6yDivoTqhknIKCIGmDASjfoMxy9cW0BEF5eAf35AN/tcJ1ehA2ElG8s+CeYPcdH2/2bUXn/wj+sX0e88MnBEpMh+eZ7gUFWlsnA3dxYn6g2KKEFAqwnAAOOtPE/V9saIvo1FesjXH6xx0+XRZBcAk16H05PWqD+jEMhKEACqESyB/JW8JV1B1l6F5CK5ZlYWIUw3EPAFqoDrxmWg== Received: from DM6PR17CA0032.namprd17.prod.outlook.com (2603:10b6:5:1b3::45) by CO6PR12MB5426.namprd12.prod.outlook.com (2603:10b6:5:35d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Tue, 6 Dec 2022 18:51:53 +0000 Received: from DS1PEPF0000E643.namprd02.prod.outlook.com (2603:10b6:5:1b3:cafe::cf) by DM6PR17CA0032.outlook.office365.com (2603:10b6:5:1b3::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Tue, 6 Dec 2022 18:51:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DS1PEPF0000E643.mail.protection.outlook.com (10.167.17.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Tue, 6 Dec 2022 18:51:52 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:43 -0800 Received: from nps-server-23.mtl.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:40 -0800 From: Shay Drory To: , , CC: , , , , , Shay Drory Subject: [PATCH net-next V4 4/8] devlink: Expose port function commands to control RoCE Date: Tue, 6 Dec 2022 20:51:15 +0200 Message-ID: <20221206185119.380138-5-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206185119.380138-1-shayd@nvidia.com> References: <20221206185119.380138-1-shayd@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E643:EE_|CO6PR12MB5426:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f3243c9-3ed1-48bc-e32d-08dad7baf0bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 62dx1VnxEq16GF3nmVwE2XbCSkQzDHG3nIrvwZbT7hvR/Ovf8nmyWGKzncqcFxDKIJSPR+1bq3uHyfuyMoB90PaCJR0eyRi+lwozi80d0X/prd4T7aQWZVFHnbeS0yep7hjvoBM71S+42qrSR3+epykfZB5Co2SrY2lZy9i3UCXcGA+JXyrVq7WClyaRnCxxntbrZd3uAoddcma9HLLuDx8BaVjf9yKk3JHHfA47i2RJehdqHPlnuhy3P7Jocdccdn9i76IcGpqE0zdiSdlh2zLw14mRLt/9ek2gIrS/NTXQTXrnTD1YrwHa6wHG93mOgF8KFXxlX6dSOQkIspiAhgm3TDiojZylTIzflATP7KBULOiVDWIm2oc7HEN2Y403W8p+HEg/3tB3iURpiFhMDxlOv1mIawJj5V9qzL0bpptR30KU4QzuPPzRYh+Cz2M/ZZj79GwRC3xs5IyhRjrBLlbK8NgYQY1ph4ZRpTkATLoEhvAzw2iWTmHIZpeH6RsjMeUQzqVNsCMnP/cFYP3F7qylq3l028b20cERBHs66JNtExo/VFwgFB3b9dttK8l6dO5uzP4sMOvt608RarNUTILWYaSNZcPXYGsn7ZFdJvvHhQkhYpFBzjaR366yVR94qzs3hWvKBIV6ALXlZX4w4bKBJVvp5MdAGNdpojszQ6VFFLhjbsdrW5XZg6PHAGvVFUn2c/fu5gENNhCvAISu9w== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(396003)(136003)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(36756003)(82740400003)(5660300002)(86362001)(7636003)(356005)(8936002)(40460700003)(4326008)(41300700001)(30864003)(2906002)(36860700001)(83380400001)(54906003)(70586007)(316002)(70206006)(2616005)(110136005)(40480700001)(8676002)(16526019)(82310400005)(478600001)(107886003)(6666004)(426003)(1076003)(47076005)(186003)(26005)(336012);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2022 18:51:52.7583 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4f3243c9-3ed1-48bc-e32d-08dad7baf0bc X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E643.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR12MB5426 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Expose port function commands to enable / disable RoCE, this is used to control the port RoCE device capabilities. When RoCE is disabled for a function of the port, function cannot create any RoCE specific resources (e.g GID table). It also saves system memory utilization. For example disabling RoCE enable a VF/SF saves 1 Mbytes of system memory per function. Example of a PCI VF port which supports function configuration: Set RoCE of the VF's port function. $ devlink port show pci/0000:06:00.0/2 pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 function: hw_addr 00:00:00:00:00:00 roce enable $ devlink port function set pci/0000:06:00.0/2 roce disable $ devlink port show pci/0000:06:00.0/2 pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 function: hw_addr 00:00:00:00:00:00 roce disable Signed-off-by: Shay Drory Reviewed-by: Jiri Pirko --- v3-v4: - change port_function_roce to port_fn_roce. v2->v3: - change DEVLINK_PORT_FN_SET_CAP to devlink_port_fn_cap_fill. - move out DEVLINK_PORT_FN_CAPS_VALID_MASK from UAPI. - introduce DEVLINK_PORT_FN_CAP_ROCE and add _BIT suffix to devlink_port_fn_attr_cap. --- .../networking/devlink/devlink-port.rst | 34 +++++- include/net/devlink.h | 18 +++ include/uapi/linux/devlink.h | 10 ++ net/core/devlink.c | 113 ++++++++++++++++++ 4 files changed, 174 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/devlink/devlink-port.rst b/Documentation/networking/devlink/devlink-port.rst index 2c637f4aae8e..c3302d23e480 100644 --- a/Documentation/networking/devlink/devlink-port.rst +++ b/Documentation/networking/devlink/devlink-port.rst @@ -110,7 +110,7 @@ devlink ports for both the controllers. Function configuration ====================== -A user can configure the function attribute before enumerating the PCI +Users can configure one or more function attributes before enumerating the PCI function. Usually it means, user should configure function attribute before a bus specific device for the function is created. However, when SRIOV is enabled, virtual function devices are created on the PCI bus. @@ -122,6 +122,9 @@ A user may set the hardware address of the function using `devlink port function set hw_addr` command. For Ethernet port function this means a MAC address. +Users may also set the RoCE capability of the function using +`devlink port function set roce` command. + Function attributes =================== @@ -162,6 +165,35 @@ device created for the PCI VF/SF. function: hw_addr 00:00:00:00:88:88 +RoCE capability setup +--------------------- +Not all PCI VFs/SFs require RoCE capability. + +When RoCE capability is disabled, it saves system memory per PCI VF/SF. + +When user disables RoCE capability for a VF/SF, user application cannot send or +receive any RoCE packets through this VF/SF and RoCE GID table for this PCI +will be empty. + +When RoCE capability is disabled in the device using port function attribute, +VF/SF driver cannot override it. + +- Get RoCE capability of the VF device:: + + $ devlink port show pci/0000:06:00.0/2 + pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 + function: + hw_addr 00:00:00:00:00:00 roce enable + +- Set RoCE capability of the VF device:: + + $ devlink port function set pci/0000:06:00.0/2 roce disable + + $ devlink port show pci/0000:06:00.0/2 + pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 + function: + hw_addr 00:00:00:00:00:00 roce disable + Subfunction ============ diff --git a/include/net/devlink.h b/include/net/devlink.h index 5f6eca5e4a40..ce4c65d2f2e7 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1451,6 +1451,24 @@ struct devlink_ops { int (*port_function_hw_addr_set)(struct devlink_port *port, const u8 *hw_addr, int hw_addr_len, struct netlink_ext_ack *extack); + /** + * @port_fn_roce_get: Port function's roce get function. + * + * Query RoCE state of a function managed by the devlink port. + * Return -EOPNOTSUPP if port function RoCE handling is not supported. + */ + int (*port_fn_roce_get)(struct devlink_port *devlink_port, + bool *is_enable, + struct netlink_ext_ack *extack); + /** + * @port_fn_roce_set: Port function's roce set function. + * + * Enable/Disable the RoCE state of a function managed by the devlink + * port. + * Return -EOPNOTSUPP if port function RoCE handling is not supported. + */ + int (*port_fn_roce_set)(struct devlink_port *devlink_port, + bool enable, struct netlink_ext_ack *extack); /** * port_new() - Add a new port function of a specified flavor * @devlink: Devlink instance diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index 70191d96af89..6cc2925bd478 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -658,11 +658,21 @@ enum devlink_resource_unit { DEVLINK_RESOURCE_UNIT_ENTRY, }; +enum devlink_port_fn_attr_cap { + DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT, + + /* Add new caps above */ + __DEVLINK_PORT_FN_ATTR_CAPS_MAX, +}; + +#define DEVLINK_PORT_FN_CAP_ROCE _BITUL(DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT) + enum devlink_port_function_attr { DEVLINK_PORT_FUNCTION_ATTR_UNSPEC, DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR, /* binary */ DEVLINK_PORT_FN_ATTR_STATE, /* u8 */ DEVLINK_PORT_FN_ATTR_OPSTATE, /* u8 */ + DEVLINK_PORT_FN_ATTR_CAPS, /* bitfield32 */ __DEVLINK_PORT_FUNCTION_ATTR_MAX, DEVLINK_PORT_FUNCTION_ATTR_MAX = __DEVLINK_PORT_FUNCTION_ATTR_MAX - 1 diff --git a/net/core/devlink.c b/net/core/devlink.c index 035249c5dd17..8c0ad52431c5 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -195,11 +195,16 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(devlink_hwmsg); EXPORT_TRACEPOINT_SYMBOL_GPL(devlink_hwerr); EXPORT_TRACEPOINT_SYMBOL_GPL(devlink_trap_report); +#define DEVLINK_PORT_FN_CAPS_VALID_MASK \ + (_BITUL(__DEVLINK_PORT_FN_ATTR_CAPS_MAX) - 1) + static const struct nla_policy devlink_function_nl_policy[DEVLINK_PORT_FUNCTION_ATTR_MAX + 1] = { [DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR] = { .type = NLA_BINARY }, [DEVLINK_PORT_FN_ATTR_STATE] = NLA_POLICY_RANGE(NLA_U8, DEVLINK_PORT_FN_STATE_INACTIVE, DEVLINK_PORT_FN_STATE_ACTIVE), + [DEVLINK_PORT_FN_ATTR_CAPS] = + NLA_POLICY_BITFIELD32(DEVLINK_PORT_FN_CAPS_VALID_MASK), }; static const struct nla_policy devlink_selftest_nl_policy[DEVLINK_ATTR_SELFTEST_ID_MAX + 1] = { @@ -680,6 +685,60 @@ devlink_sb_tc_index_get_from_attrs(struct devlink_sb *devlink_sb, return 0; } +static void devlink_port_fn_cap_fill(struct nla_bitfield32 *caps, + u32 cap, bool is_enable) +{ + caps->selector |= cap; + if (is_enable) + caps->value |= cap; +} + +static int devlink_port_fn_roce_fill(const struct devlink_ops *ops, + struct devlink_port *devlink_port, + struct nla_bitfield32 *caps, + struct netlink_ext_ack *extack) +{ + bool is_enable; + int err; + + if (!ops->port_fn_roce_get) + return 0; + + err = ops->port_fn_roce_get(devlink_port, &is_enable, extack); + if (err) { + if (err == -EOPNOTSUPP) + return 0; + return err; + } + + devlink_port_fn_cap_fill(caps, DEVLINK_PORT_FN_CAP_ROCE, is_enable); + return 0; +} + +static int devlink_port_fn_caps_fill(const struct devlink_ops *ops, + struct devlink_port *devlink_port, + struct sk_buff *msg, + struct netlink_ext_ack *extack, + bool *msg_updated) +{ + struct nla_bitfield32 caps = {}; + int err; + + err = devlink_port_fn_roce_fill(ops, devlink_port, &caps, extack); + if (err) + return err; + + if (!caps.selector) + return 0; + err = nla_put_bitfield32(msg, DEVLINK_PORT_FN_ATTR_CAPS, caps.value, + caps.selector); + if (err) + return err; + + *msg_updated = true; + return 0; +} + static int devlink_sb_tc_index_get_from_info(struct devlink_sb *devlink_sb, struct genl_info *info, @@ -1263,6 +1322,35 @@ static int devlink_port_fn_state_fill(const struct devlink_ops *ops, return 0; } +static int +devlink_port_fn_roce_set(struct devlink_port *devlink_port, bool enable, + struct netlink_ext_ack *extack) +{ + const struct devlink_ops *ops = devlink_port->devlink->ops; + + return ops->port_fn_roce_set(devlink_port, enable, extack); +} + +static int devlink_port_fn_caps_set(struct devlink_port *devlink_port, + const struct nlattr *attr, + struct netlink_ext_ack *extack) +{ + struct nla_bitfield32 caps; + u32 caps_value; + int err; + + caps = nla_get_bitfield32(attr); + caps_value = caps.value & caps.selector; + if (caps.selector & DEVLINK_PORT_FN_CAP_ROCE) { + err = devlink_port_fn_roce_set(devlink_port, + caps_value & DEVLINK_PORT_FN_CAP_ROCE, + extack); + if (err) + return err; + } + return 0; +} + static int devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *port, struct netlink_ext_ack *extack) @@ -1281,6 +1369,10 @@ devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *por &msg_updated); if (err) goto out; + err = devlink_port_fn_caps_fill(ops, port, msg, extack, + &msg_updated); + if (err) + goto out; err = devlink_port_fn_state_fill(ops, port, msg, extack, &msg_updated); out: if (err || !msg_updated) @@ -1653,6 +1745,7 @@ static int devlink_port_function_validate(struct devlink_port *devlink_port, struct netlink_ext_ack *extack) { const struct devlink_ops *ops = devlink_port->devlink->ops; + struct nlattr *attr; if (tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR] && !ops->port_function_hw_addr_set) { @@ -1665,6 +1758,18 @@ static int devlink_port_function_validate(struct devlink_port *devlink_port, "Function does not support state setting"); return -EOPNOTSUPP; } + attr = tb[DEVLINK_PORT_FN_ATTR_CAPS]; + if (attr) { + struct nla_bitfield32 caps; + + caps = nla_get_bitfield32(attr); + if (caps.selector & DEVLINK_PORT_FN_CAP_ROCE && + !ops->port_fn_roce_set) { + NL_SET_ERR_MSG_ATTR(extack, attr, + "Port doesn't support RoCE function attribute"); + return -EOPNOTSUPP; + } + } return 0; } @@ -1692,6 +1797,14 @@ static int devlink_port_function_set(struct devlink_port *port, if (err) return err; } + + attr = tb[DEVLINK_PORT_FN_ATTR_CAPS]; + if (attr) { + err = devlink_port_fn_caps_set(port, attr, extack); + if (err) + return err; + } + /* Keep this as the last function attribute set, so that when * multiple port function attributes are set along with state, * Those can be applied first before activating the state. From patchwork Tue Dec 6 18:51:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13066217 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9685DC352A1 for ; Tue, 6 Dec 2022 18:52:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229778AbiLFSwS (ORCPT ); Tue, 6 Dec 2022 13:52:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbiLFSwH (ORCPT ); Tue, 6 Dec 2022 13:52:07 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2059.outbound.protection.outlook.com [40.107.237.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 433BA3D92B for ; Tue, 6 Dec 2022 10:52:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bmsma7UA4654NgJBqa8nzCcRtm6lqzNpkMqcx2jD7EUfwViab8EQzcDLb1AOw0avVX5K93DxSO3AKYN/dMo83uLtm5CPsRtFgDPkKI4PaB9Bx6QpS1kwV3AjMzgjc0MQX8K5UZfYd+AuuHZRaDtP0oOkaQgZAT5qMEoVVAgEUgQ/lFf16QZHLxu8fwwGlNrW9/44gQmHPkTDRP9cK0BTrBQX11HzaRvNCsWjxFo0bi16oE2pQriuNZeRE5Gk3LNw+cO8nxed4yv03FyF7dQb+81hhQe3hyzpZcr+pqrc88tRzDCyTDjhYv62Xho4pUCZXcdXAjFxbOuhtw+IMvdeNA== 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=qXr1jEd66S007qgvs1TkJOlAZxpix6qcG4dezthwF4E=; b=H958ZYs1XWLKJ91+gCrhU8WvFWV/a7vrimFZ7q/JaK/A7y7efg4Gn3Ds5rTBI5Hx78kwiHLsAVX3faRbx/MaZrhMcnR8ezEWhVICV6LqOxWMnTJRO34QoI3xHW4+OkCohvSVF9kDm1XhG1fWOlE6DiotnrTZ1Sg+CIUOPxAvWhTLEiUpP3b+1MCKk1KZG5fk7w6dw6mNYxMCUgVNmbr4nsQZJBRec78j4Qr/32PS1bbS42TnOaPck/dbZPyJ1RfTvJaR0wbUk/YG2DyYpFsnZi677avBKiTfMI3qWYoetWI4BYHaLsqvcRy4X6OBSBAaWQUHiW96oBz44ZWZFg5UKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qXr1jEd66S007qgvs1TkJOlAZxpix6qcG4dezthwF4E=; b=qmj27x2SvPxQnTPcgBsoFxd8g2Sn45z7OA7zjsH+1tEKnNXG5AIsPXFuhAA0hrZpjUutAyNTCXYmOw3dVyQ22yNuUeybJgX+e79wUxt57OCgJK2vhTbFcIPhR3+YF6+fcqCVYX+AO7F6jVFyXTuHKS1E7+C5ey4e8Tqiv1e1KF1keLKoak2KkVhJoE932APYQF5CLxxqwg/pyrv0x4bOIkQTRmNj9qQVhlhskXLJXBA/OYeNnz3RgESStaTMe90OSFWb4VDpLXWWIaxxUjLAkJq1MyVNNVIrp5yDNfr+HMNAvQuQ7HZnUDh+bSTQxmAAyXyhut2J0n3vKkP5S9oovw== Received: from BN7PR02CA0016.namprd02.prod.outlook.com (2603:10b6:408:20::29) by DM4PR12MB6136.namprd12.prod.outlook.com (2603:10b6:8:a9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Tue, 6 Dec 2022 18:52:02 +0000 Received: from BN8NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:408:20:cafe::d5) by BN7PR02CA0016.outlook.office365.com (2603:10b6:408:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Tue, 6 Dec 2022 18:52:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT064.mail.protection.outlook.com (10.13.176.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5901.14 via Frontend Transport; Tue, 6 Dec 2022 18:52:02 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:46 -0800 Received: from nps-server-23.mtl.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:43 -0800 From: Shay Drory To: , , CC: , , , , , Shay Drory Subject: [PATCH net-next V4 5/8] net/mlx5: Add generic getters for other functions caps Date: Tue, 6 Dec 2022 20:51:16 +0200 Message-ID: <20221206185119.380138-6-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206185119.380138-1-shayd@nvidia.com> References: <20221206185119.380138-1-shayd@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT064:EE_|DM4PR12MB6136:EE_ X-MS-Office365-Filtering-Correlation-Id: 2cf46d94-948d-484f-9bec-08dad7baf662 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W/Z3nyRYlqxFTVqNsS9t/poRJ0Laz8CZYLcMX9oO2SHPmcJkro9NdtL/D5jYtQY5z3EZN/yXbXHlq65CioGHbY2wJeWI/J8QrX/B98MbDKV3sK5ivCPVcIuF03tRQAXrqQCNOLbw+MQO5WYfx5scvnQPrvJR4IhHOkZMnf0qEHFy8UrIctsYrva9/t1fyDHlW1ksFKUSPE3x0JILidGxVNPxBeS3UHt0CYdPgYb4EOV3GFf34/L9Q2tQiEMnHKSVaYoYWpSPWaUMzxpdYa2K7kaojCDYwA/aFpold00cZ44gmoEJQQXxgglreK/B3PSmAnBPtK25qo7p4hebxeZcW/xfVqVImCrEhk1h86+4frs1T9+DMuOxoKmGX2wBsWOpcrjcyT2ekaLERxmLLOxj+574M9lby0IewotJDUVQ9yASgH0d4RvZbenMdPQDbbrwV8XK2ddXmzDfSVDFlE7DISFssZX46BKTb20vf3/qz/oj/TAlly92V48J6VNcvY/H0RrpjXJs3ZWt4+W+QZuGNhEu5SqYj9PH9dS1DRbBgCNwNBQj+wvya4mDho73DL3tD6B2TuOW+yHFGNRXTYi9E86PlwPdajEBQ2fjXtXBEqmmPCmji9UT6jcovJ2e6ZWIVNk6ZdpOUCxkMsZmt8z0WJQsmOcSIeylwaPRyeLMEwxL6CI8b/RjASG6XCGPalw3nPJ4NwWHuZs3OKDJLV/z3pReAY+pbQIkj4a7Z9j5jBo= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(39860400002)(396003)(136003)(346002)(451199015)(36840700001)(46966006)(40470700004)(36756003)(2616005)(7636003)(36860700001)(336012)(82740400003)(6666004)(356005)(478600001)(54906003)(110136005)(40480700001)(1076003)(83380400001)(2906002)(26005)(86362001)(107886003)(82310400005)(40460700003)(316002)(5660300002)(8676002)(4326008)(8936002)(47076005)(16526019)(426003)(70206006)(70586007)(186003)(41300700001)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2022 18:52:02.1861 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2cf46d94-948d-484f-9bec-08dad7baf662 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6136 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Downstream patch requires to get other function GENERAL2 caps while mlx5_vport_get_other_func_cap() gets only one type of caps (general). Rename it to represent this and introduce a generic implementation of mlx5_vport_get_other_func_cap(). Signed-off-by: Shay Drory Reviewed-by: Mark Bloch Acked-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h | 3 ++- drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c | 3 ++- drivers/net/ethernet/mellanox/mlx5/core/vport.c | 6 ++++-- include/linux/mlx5/vport.h | 2 ++ 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index 9b6fbb19c22a..33dffcb8bdd7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c @@ -3889,7 +3889,7 @@ static int mlx5_esw_query_vport_vhca_id(struct mlx5_eswitch *esw, u16 vport_num, if (!query_ctx) return -ENOMEM; - err = mlx5_vport_get_other_func_cap(esw->dev, vport_num, query_ctx); + err = mlx5_vport_get_other_func_general_cap(esw->dev, vport_num, query_ctx); if (err) goto out_free; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h index a806e3de7b7c..09473983778f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h @@ -324,7 +324,8 @@ void mlx5_unload_one_devl_locked(struct mlx5_core_dev *dev); int mlx5_load_one(struct mlx5_core_dev *dev, bool recovery); int mlx5_load_one_devl_locked(struct mlx5_core_dev *dev, bool recovery); -int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out); +#define mlx5_vport_get_other_func_general_cap(dev, fid, out) \ + mlx5_vport_get_other_func_cap(dev, fid, out, MLX5_CAP_GENERAL) void mlx5_events_work_enqueue(struct mlx5_core_dev *dev, struct work_struct *work); static inline u32 mlx5_sriov_get_vf_total_msix(struct pci_dev *pdev) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c index 662f1d55e30e..6bde18bcd42f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "mlx5_core.h" #include "mlx5_irq.h" #include "pci_irq.h" @@ -101,7 +102,7 @@ int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int function_id, goto out; } - ret = mlx5_vport_get_other_func_cap(dev, function_id, query_cap); + ret = mlx5_vport_get_other_func_general_cap(dev, function_id, query_cap); if (ret) goto out; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vport.c b/drivers/net/ethernet/mellanox/mlx5/core/vport.c index d5c317325030..7eca7582f243 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/vport.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/vport.c @@ -1160,14 +1160,16 @@ u64 mlx5_query_nic_system_image_guid(struct mlx5_core_dev *mdev) } EXPORT_SYMBOL_GPL(mlx5_query_nic_system_image_guid); -int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out) +int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out, + u16 opmod) { - u16 opmod = (MLX5_CAP_GENERAL << 1) | (HCA_CAP_OPMOD_GET_MAX & 0x01); u8 in[MLX5_ST_SZ_BYTES(query_hca_cap_in)] = {}; + opmod = (opmod << 1) | (HCA_CAP_OPMOD_GET_MAX & 0x01); MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP); MLX5_SET(query_hca_cap_in, in, op_mod, opmod); MLX5_SET(query_hca_cap_in, in, function_id, function_id); MLX5_SET(query_hca_cap_in, in, other_function, true); return mlx5_cmd_exec_inout(dev, query_hca_cap, in, out); } +EXPORT_SYMBOL_GPL(mlx5_vport_get_other_func_cap); diff --git a/include/linux/mlx5/vport.h b/include/linux/mlx5/vport.h index aad53cb72f17..7f31432f44c2 100644 --- a/include/linux/mlx5/vport.h +++ b/include/linux/mlx5/vport.h @@ -132,4 +132,6 @@ int mlx5_nic_vport_affiliate_multiport(struct mlx5_core_dev *master_mdev, int mlx5_nic_vport_unaffiliate_multiport(struct mlx5_core_dev *port_mdev); u64 mlx5_query_nic_system_image_guid(struct mlx5_core_dev *mdev); +int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out, + u16 opmod); #endif /* __MLX5_VPORT_H__ */ From patchwork Tue Dec 6 18:51:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13066215 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0D13C352A1 for ; Tue, 6 Dec 2022 18:52:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229850AbiLFSwO (ORCPT ); Tue, 6 Dec 2022 13:52:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229785AbiLFSwG (ORCPT ); Tue, 6 Dec 2022 13:52:06 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20604.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::604]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40FCA3B9C3 for ; Tue, 6 Dec 2022 10:52:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tf3ig43vUPthUQ5vtyMyEkfCefqGTdQl1ijElu+dFU3RrUp8PNtNMcmCSBu5+ZgOqCowQE2fmytxvSMkXNTtC0Z6SvvyY+9xgfsuGdZTheYlVIUPx5crGI25IqroJ8UN6wNRKvbLLfqXQAAxvNGi+xbXvCWKOTkolYrz9IUs0BLJ9o8OsRKRYf3Y2yu4zCIbq8OtcufcpXrLPvfN5WH2GGet2rfq3D8Ulg+tevbyXIrKvdQcVRsVEk0sK0yg11d0OaiGrVH/0UaJncGuVXmD0Ft6zOel+eNYfAYqOlXf661vqWYAH7s9Y786KNweTZ5r/F+yvxd5gyZJXTaI11qG6g== 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=krBek1wHe+OTgfKcNIuLtmUww7KEIvbXAVjW0Dc1Hd4=; b=H12/H7m2uioeNXWTqLw0M3F5SHuxCmSdUqts5ap0XaNXlApXopcTarm+A7xTxdq/yEBTF+CnGEjHDfxtz0yH+wTa4IHPHkQNbH41s2ap2K4X5x1swxaSap45400NfuHTrPVadvGYA9agrHSL2aNkBro5G+ye5aKHMEASj7wbnsEGdnv4zFkkMau24RjYeoyzCesvtBHYF5sq9ItZth4JQviKTcjhmGBrcAhKA+6ysjdSAYpMorX2XFpek49hkDVtQEI1zZDw+14Igy88dJfiIuAbwMmfWHlo0LHgJ/9TJ9boGwxcjh1LJGfi1tDPwh9ZobXbPwblqhFD87XlMS1dUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=krBek1wHe+OTgfKcNIuLtmUww7KEIvbXAVjW0Dc1Hd4=; b=fvr2XkQHTQVAgTsiDtTmwdCOkfCLMT+ZsN2R69PoRSuJbtIxXvNFfii9xupDKHqyp3pxc/WiMeNg4XjoD/+8Vy+Hab+JODacETRh6HdVjYf87y/0qJ1thW3BUdlMKJps2kx9VbLKdnuLGdNhDmJtdNCaEn91kgVNURqmeR+n8FaG/0iwf4D9sppWoKQFg08PcL6GItflCFYq+Tq7Y8WPljkEdpK0DvXTAZnfT8CLN699DQTmNAXefYHc7rvyE7ZXO0cx8Nj8SNXBnkIBqJzQh/l+gdlvD4Oh+hWRQNRx+MzCpM8O1Bj+K2dmBY0/mxrEynYTmLcjhQw0qDrUnjEvxw== Received: from DM6PR17CA0034.namprd17.prod.outlook.com (2603:10b6:5:1b3::47) by MN2PR12MB4173.namprd12.prod.outlook.com (2603:10b6:208:1d8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Tue, 6 Dec 2022 18:51:59 +0000 Received: from DS1PEPF0000E643.namprd02.prod.outlook.com (2603:10b6:5:1b3:cafe::27) by DM6PR17CA0034.outlook.office365.com (2603:10b6:5:1b3::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Tue, 6 Dec 2022 18:51:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DS1PEPF0000E643.mail.protection.outlook.com (10.167.17.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Tue, 6 Dec 2022 18:51:59 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:49 -0800 Received: from nps-server-23.mtl.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:46 -0800 From: Shay Drory To: , , CC: , , , , , Shay Drory Subject: [PATCH net-next V4 6/8] net/mlx5: E-Switch, Implement devlink port function cmds to control RoCE Date: Tue, 6 Dec 2022 20:51:17 +0200 Message-ID: <20221206185119.380138-7-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206185119.380138-1-shayd@nvidia.com> References: <20221206185119.380138-1-shayd@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E643:EE_|MN2PR12MB4173:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c2b49d0-613b-4e33-3e1d-08dad7baf4a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3zhRb35ZWPconmtJpJ4Dj2hVJGxyoB4/JGVQ5o3L/qL7at2IwKkQL/u7QefsLZ1xinDQfTzLVJphO3FXKtRZRyHIuwf3K8ZpRAK8mqusQYFxOlY8l4DX36Q+kK1EJqQBu+ZQzgFxF4im3F075HsES+PKzBVjBaRuQihyd7DFdSwTA3v9um3cKdk9A2eFcMeXThIhTBZ4I3M3aQs9ov9rxghdgx6+nvCxAXLrDOzSrJVjH8RzxilStGad+VqnW9xI61KmUW+b8K/uEse196lWeAaRwpW0vHLSAiLxRtBvEkIPX9SWEMO3D1ANl5/Qs296AjhYJ8KKXpbwDCKVTyC1eB+q79TK8ofQbO5HJ0On19N+QRvrkKl+zNG8PVMlmW9BLVNoDiPP0CsDM0XCe3EsOIDltvm0v0azPXlgVFKvZ4DQVeucEaitByDKhKTo2CtiYO0nMfHHm9q9q3VPPVoThnFi9VOw47EV7nVG0CkJH5pDyo4sn0VikojE40ASnK8WdmCOD66MuJxjcbg5iAX1X1HuAaDECXR1N3S5zqpIFljyg+Wy7pLjQEUwZOt+yHtuEV496RRUt1afPlp1w8XHqcQWwnR7WB7wda6VnsuOcBQYDOdBAgjB0g9iU+U6Xrrk5Fghi0d1FbFasM91M8TRRzcpCBxJuIq9C2NvvDH8RKQRtBW0amX8b7YoZpFCULXw9sMPqjVELcwASNBcIsYgMQ== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(396003)(136003)(451199015)(40470700004)(46966006)(36840700001)(36756003)(82740400003)(5660300002)(86362001)(7636003)(356005)(8936002)(40460700003)(4326008)(41300700001)(30864003)(2906002)(36860700001)(83380400001)(54906003)(70586007)(316002)(70206006)(2616005)(110136005)(40480700001)(8676002)(16526019)(82310400005)(478600001)(107886003)(6666004)(426003)(1076003)(47076005)(186003)(26005)(336012);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2022 18:51:59.3208 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c2b49d0-613b-4e33-3e1d-08dad7baf4a6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E643.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4173 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Yishai Hadas Implement devlink port function commands to enable / disable RoCE. This is used to control the RoCE device capabilities. This patch implement infrastructure which will be used by downstream patches that will add additional capabilities. Signed-off-by: Yishai Hadas Signed-off-by: Daniel Jurgens Signed-off-by: Shay Drory Reviewed-by: Parav Pandit Reviewed-by: Mark Bloch Acked-by: Saeed Mahameed --- v3-v4: - change port_function_roce to port_fn_roce. --- .../device_drivers/ethernet/mellanox/mlx5.rst | 10 ++ .../net/ethernet/mellanox/mlx5/core/devlink.c | 2 + .../net/ethernet/mellanox/mlx5/core/eswitch.c | 35 ++++++ .../net/ethernet/mellanox/mlx5/core/eswitch.h | 6 +- .../mellanox/mlx5/core/eswitch_offloads.c | 108 ++++++++++++++++++ .../ethernet/mellanox/mlx5/core/mlx5_core.h | 2 + .../net/ethernet/mellanox/mlx5/core/vport.c | 24 ++++ 7 files changed, 186 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst b/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst index 07cfc1b07db3..8b8f95d1293a 100644 --- a/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst +++ b/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst @@ -354,6 +354,16 @@ MAC address setup mlx5 driver support devlink port function attr mechanism to setup MAC address. (refer to Documentation/networking/devlink/devlink-port.rst) +RoCE capability setup +--------------------- +Not all mlx5 PCI devices/SFs require RoCE capability. + +When RoCE capability is disabled, it saves 1 Mbytes worth of system memory per +PCI devices/SF. + +mlx5 driver support devlink port function attr mechanism to setup RoCE +capability. (refer to Documentation/networking/devlink/devlink-port.rst) + SF state setup -------------- To use the SF, the user must activate the SF using the SF function state diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index 751bc4a9edcf..336c7b7fa494 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -314,6 +314,8 @@ static const struct devlink_ops mlx5_devlink_ops = { .rate_node_new = mlx5_esw_devlink_rate_node_new, .rate_node_del = mlx5_esw_devlink_rate_node_del, .rate_leaf_parent_set = mlx5_esw_devlink_rate_parent_set, + .port_fn_roce_get = mlx5_devlink_port_fn_roce_get, + .port_fn_roce_set = mlx5_devlink_port_fn_roce_set, #endif #ifdef CONFIG_MLX5_SF_MANAGER .port_new = mlx5_devlink_sf_port_new, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c index 374e3fbdc2cf..001fb1e62135 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c @@ -772,6 +772,33 @@ static void esw_vport_cleanup_acl(struct mlx5_eswitch *esw, esw_vport_destroy_offloads_acl_tables(esw, vport); } +static int mlx5_esw_vport_caps_get(struct mlx5_eswitch *esw, struct mlx5_vport *vport) +{ + int query_out_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out); + void *query_ctx; + void *hca_caps; + int err; + + if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager)) + return 0; + + query_ctx = kzalloc(query_out_sz, GFP_KERNEL); + if (!query_ctx) + return -ENOMEM; + + err = mlx5_vport_get_other_func_cap(esw->dev, vport->vport, query_ctx, + MLX5_CAP_GENERAL); + if (err) + goto out_free; + + hca_caps = MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability); + vport->info.roce_enabled = MLX5_GET(cmd_hca_cap, hca_caps, roce); + +out_free: + kfree(query_ctx); + return err; +} + static int esw_vport_setup(struct mlx5_eswitch *esw, struct mlx5_vport *vport) { u16 vport_num = vport->vport; @@ -785,6 +812,10 @@ static int esw_vport_setup(struct mlx5_eswitch *esw, struct mlx5_vport *vport) if (mlx5_esw_is_manager_vport(esw, vport_num)) return 0; + err = mlx5_esw_vport_caps_get(esw, vport); + if (err) + goto err_caps; + mlx5_modify_vport_admin_state(esw->dev, MLX5_VPORT_STATE_OP_MOD_ESW_VPORT, vport_num, 1, @@ -804,6 +835,10 @@ static int esw_vport_setup(struct mlx5_eswitch *esw, struct mlx5_vport *vport) vport->info.qos, flags); return 0; + +err_caps: + esw_vport_cleanup_acl(esw, vport); + return err; } /* Don't cleanup vport->info, it's needed to restore vport configuration */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h index 42d9df417e20..eea0521729df 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h @@ -153,6 +153,7 @@ struct mlx5_vport_info { u8 qos; u8 spoofchk: 1; u8 trusted: 1; + u8 roce_enabled: 1; }; /* Vport context events */ @@ -508,7 +509,10 @@ int mlx5_devlink_port_function_hw_addr_get(struct devlink_port *port, int mlx5_devlink_port_function_hw_addr_set(struct devlink_port *port, const u8 *hw_addr, int hw_addr_len, struct netlink_ext_ack *extack); - +int mlx5_devlink_port_fn_roce_get(struct devlink_port *port, bool *is_enabled, + struct netlink_ext_ack *extack); +int mlx5_devlink_port_fn_roce_set(struct devlink_port *port, bool enable, + struct netlink_ext_ack *extack); void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type); int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index 33dffcb8bdd7..7618c51351ca 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c @@ -4022,3 +4022,111 @@ int mlx5_devlink_port_function_hw_addr_set(struct devlink_port *port, return mlx5_eswitch_set_vport_mac(esw, vport_num, hw_addr); } + +static struct mlx5_vport * +mlx5_devlink_port_fn_get_vport(struct devlink_port *port, struct mlx5_eswitch *esw) +{ + u16 vport_num; + + if (!MLX5_CAP_GEN(esw->dev, vhca_resource_manager)) + return ERR_PTR(-EOPNOTSUPP); + + vport_num = mlx5_esw_devlink_port_index_to_vport_num(port->index); + if (!is_port_function_supported(esw, vport_num)) + return ERR_PTR(-EOPNOTSUPP); + + return mlx5_eswitch_get_vport(esw, vport_num); +} + +int mlx5_devlink_port_fn_roce_get(struct devlink_port *port, bool *is_enabled, + struct netlink_ext_ack *extack) +{ + struct mlx5_eswitch *esw; + struct mlx5_vport *vport; + int err = -EOPNOTSUPP; + + esw = mlx5_devlink_eswitch_get(port->devlink); + if (IS_ERR(esw)) + return PTR_ERR(esw); + + vport = mlx5_devlink_port_fn_get_vport(port, esw); + if (IS_ERR(vport)) { + NL_SET_ERR_MSG_MOD(extack, "Invalid port"); + return PTR_ERR(vport); + } + + mutex_lock(&esw->state_lock); + if (vport->enabled) { + *is_enabled = vport->info.roce_enabled; + err = 0; + } + mutex_unlock(&esw->state_lock); + return err; +} + +int mlx5_devlink_port_fn_roce_set(struct devlink_port *port, bool enable, + struct netlink_ext_ack *extack) +{ + int query_out_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out); + struct mlx5_eswitch *esw; + struct mlx5_vport *vport; + int err = -EOPNOTSUPP; + void *query_ctx; + void *hca_caps; + u16 vport_num; + + esw = mlx5_devlink_eswitch_get(port->devlink); + if (IS_ERR(esw)) + return PTR_ERR(esw); + + vport = mlx5_devlink_port_fn_get_vport(port, esw); + if (IS_ERR(vport)) { + NL_SET_ERR_MSG_MOD(extack, "Invalid port"); + return PTR_ERR(vport); + } + vport_num = vport->vport; + + mutex_lock(&esw->state_lock); + if (!vport->enabled) { + NL_SET_ERR_MSG_MOD(extack, "Eswitch vport is disabled"); + goto out; + } + + if (vport->info.roce_enabled == enable) { + err = 0; + goto out; + } + + query_ctx = kzalloc(query_out_sz, GFP_KERNEL); + if (!query_ctx) { + err = -ENOMEM; + goto out; + } + + err = mlx5_vport_get_other_func_cap(esw->dev, vport_num, query_ctx, + MLX5_CAP_GENERAL); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Failed getting HCA caps"); + goto out_free; + } + + hca_caps = MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability); + memcpy(hca_caps, MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability), + MLX5_UN_SZ_BYTES(hca_cap_union)); + MLX5_SET(cmd_hca_cap, hca_caps, roce, enable); + + err = mlx5_vport_set_other_func_cap(esw->dev, hca_caps, vport_num, + MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Failed setting HCA roce cap"); + goto out_free; + } + + vport->info.roce_enabled = enable; + +out_free: + kfree(query_ctx); +out: + mutex_unlock(&esw->state_lock); + return err; +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h index 09473983778f..029305a8b80a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h @@ -324,6 +324,8 @@ void mlx5_unload_one_devl_locked(struct mlx5_core_dev *dev); int mlx5_load_one(struct mlx5_core_dev *dev, bool recovery); int mlx5_load_one_devl_locked(struct mlx5_core_dev *dev, bool recovery); +int mlx5_vport_set_other_func_cap(struct mlx5_core_dev *dev, const void *hca_cap, u16 function_id, + u16 opmod); #define mlx5_vport_get_other_func_general_cap(dev, fid, out) \ mlx5_vport_get_other_func_cap(dev, fid, out, MLX5_CAP_GENERAL) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vport.c b/drivers/net/ethernet/mellanox/mlx5/core/vport.c index 7eca7582f243..ba7e3df22413 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/vport.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/vport.c @@ -1173,3 +1173,27 @@ int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, vo return mlx5_cmd_exec_inout(dev, query_hca_cap, in, out); } EXPORT_SYMBOL_GPL(mlx5_vport_get_other_func_cap); + +int mlx5_vport_set_other_func_cap(struct mlx5_core_dev *dev, const void *hca_cap, + u16 function_id, u16 opmod) +{ + int set_sz = MLX5_ST_SZ_BYTES(set_hca_cap_in); + void *set_hca_cap; + void *set_ctx; + int ret; + + set_ctx = kzalloc(set_sz, GFP_KERNEL); + if (!set_ctx) + return -ENOMEM; + + MLX5_SET(set_hca_cap_in, set_ctx, opcode, MLX5_CMD_OP_SET_HCA_CAP); + MLX5_SET(set_hca_cap_in, set_ctx, op_mod, opmod << 1); + set_hca_cap = MLX5_ADDR_OF(set_hca_cap_in, set_ctx, capability); + memcpy(set_hca_cap, hca_cap, MLX5_ST_SZ_BYTES(cmd_hca_cap)); + MLX5_SET(set_hca_cap_in, set_ctx, function_id, function_id); + MLX5_SET(set_hca_cap_in, set_ctx, other_function, true); + ret = mlx5_cmd_exec_in(dev, set_hca_cap, set_ctx); + + kfree(set_ctx); + return ret; +} From patchwork Tue Dec 6 18:51:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13066218 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7790C352A1 for ; Tue, 6 Dec 2022 18:52:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229580AbiLFSwf (ORCPT ); Tue, 6 Dec 2022 13:52:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229849AbiLFSwO (ORCPT ); Tue, 6 Dec 2022 13:52:14 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F038C3E097 for ; Tue, 6 Dec 2022 10:52:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jhA/U4DcSpQ6e94gvLOWNKNjVbyHUP2+cZeTlQzpvznWV782U6nBB3KQt3SMLAtQ4lJDpgS2jm1gF+MhAcqXL5nqCw6pVCEdEVCJ3+5mwyAIc6TW2xhUk0Ds/mAELkiCuQOuM0kn6gAMq7x0bdhmqe5khmKnO2ekhNrp5cLhkLMI9jZA8TIj6zScC5xlxJQadYQIKCA0mU4acywpJQwfKzn0u6b5GntCPmy0MyyErjVQh4/nW4wpAdynKM4aUDOr+4o5WDqcvS1FUfVhTlZaa+eclCVbo1CN4T32IChqubzg4LPPxWJh2KmQxzFiKBfX7WtvO0oLUp/0vqfypx/1Gw== 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=Q3aL3fqrTH2HDbvmQvVt7e0hu3VESTDYktDeDoXNSDU=; b=VvaA+E5+7kPApEUFwWIot1lJD/bqpuC9YxvNG7RuWelROWQwu2D50ViRqjv5GPvRoruhhW2eAYlVvjexSjG+3Tvjve2kSL1ClqJtk1WBVHhMEq8PpPvnRgeD4lfByUY8QE3LjmdzbambRQzY51SENNNsMrho6ZAKE9IBoe2Crc646tByOrdfqx8KIgsQEvw1XdEF/uSc2IMQCzoCBvUYpLwbIEqxUMfxXkYusWTB74AoGbV0N1IWYzrUmLh/6yHXpuC8BW/UFGwtVZAaIlybuC7rga5XiFtbIwro4OrT6Jki1MK41VW6XKlb2XGLki2axh10R1XjJ2lsHpVQbP4VCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q3aL3fqrTH2HDbvmQvVt7e0hu3VESTDYktDeDoXNSDU=; b=acstU7mdZsDNCuDYRCGR4MPxV/k4HFk3ClqtmLQN0OUneP3zUtD9gV9dfB3q+hns/C9/KvqLOmGL+YWlt8oHlSIt/pZ78Yj7ct65b2xFHwQsgDBN5AZFr+2ACvHHzJL207IbFKKYAZGnRYvnYoBGhvSnh6tSgX219yRiwLbfBaFOdv0q8Q8h1MSL+JjZY9UE+VsCTZd6CpJ+pCE27koy2fSDqq35wCC//kLobC/xyWFU/X0pRhonI4pMh+06LKtzVoz+EI0za+QLi6EnL1ipF4HO/s5qZRzHwQN7ySGgtCZ0OQpjqqA+i5LNB4vy7+sckW4OAPV6xmr9iGHFVJrlOw== Received: from MW3PR05CA0019.namprd05.prod.outlook.com (2603:10b6:303:2b::24) by DS0PR12MB7780.namprd12.prod.outlook.com (2603:10b6:8:152::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Tue, 6 Dec 2022 18:52:07 +0000 Received: from CO1NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2b:cafe::cb) by MW3PR05CA0019.outlook.office365.com (2603:10b6:303:2b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Tue, 6 Dec 2022 18:52:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT003.mail.protection.outlook.com (10.13.175.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5901.14 via Frontend Transport; Tue, 6 Dec 2022 18:52:06 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:52 -0800 Received: from nps-server-23.mtl.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:49 -0800 From: Shay Drory To: , , CC: , , , , , Shay Drory , Shannon Nelson Subject: [PATCH net-next V4 7/8] devlink: Expose port function commands to control migratable Date: Tue, 6 Dec 2022 20:51:18 +0200 Message-ID: <20221206185119.380138-8-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206185119.380138-1-shayd@nvidia.com> References: <20221206185119.380138-1-shayd@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT003:EE_|DS0PR12MB7780:EE_ X-MS-Office365-Filtering-Correlation-Id: ccdbe645-1a82-4c9f-7485-08dad7baf8e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rBiOu5nIPT1q06p5hAx8sZa4nBKm0F3U/hgA7uI3VTTeUz720RZofZJF8RlGKMBOv5pfcc0GdZBYLA+i5MQE0Xa0PEO5H/ARHEM2uq98xiOB98LWdFgaKTv1bG0SBHOHUIC2D6UbaZ5eTyXciuNx0lBIMAhmIEPJP2UIdDNN4ZaEr86gg42hK94c860cQcwwp+kQBWqLy3WWYDMJS7WBXJGAn3klGvZmvDrZAia1k31g4bh2CR6HQN4EmzKCsBdFLcUd0GyHMh2DM9oQQDdswJbUduuf1/VhGvkc1uXiAeP/y5+RRFlo/9Y8n/hIKG7Cya4z4KDdG+3WAieNOEWqVb0/JNrzS92YPAb2LVeFddXtW2qTWqikOKns3Djyl/3zejyl6EvnWkUTiwhjzqALzN5OLJfBCea5R9BccodzGekgEeZYcLnoocu2w50FNG5ZpfiYSUIh+I9lit5R/xJZ6viBSClcoJ9m5I06ltY2wkfEnYuvfOQYLcLVxw7lddxJIQUaWn7EEltZ/fwiK8ie3iGVOqOItHKiy2kiZ5BSaOKU7BkfgdrIjZMJvh6e4to+1ZmxovN91l3ECIgruGf04Ecq+SHXaGy0Ofz1iKVNOvfJyZeyJ09I3YjCfq6tflPXeKtBJ1WCQZ2Wppk7PdA1sX8Birmx6aKkU2lW8EAJBOAqm+n0mzI29+YUtai+wvz3kDK6EMZ+k8MDVMZvGtcDmw== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(136003)(396003)(376002)(451199015)(40470700004)(46966006)(36840700001)(478600001)(47076005)(83380400001)(316002)(5660300002)(40460700003)(8936002)(6666004)(426003)(86362001)(336012)(16526019)(2906002)(1076003)(2616005)(110136005)(36860700001)(36756003)(82310400005)(54906003)(356005)(7636003)(8676002)(70586007)(82740400003)(26005)(70206006)(186003)(40480700001)(4326008)(41300700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2022 18:52:06.4132 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ccdbe645-1a82-4c9f-7485-08dad7baf8e0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7780 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Expose port function commands to enable / disable migratable capability, this is used to set the port function as migratable. Live migration is the process of transferring a live virtual machine from one physical host to another without disrupting its normal operation. In order for a VM to be able to perform LM, all the VM components must be able to perform migration. e.g.: to be migratable. In order for VF to be migratable, VF must be bound to VFIO driver with migration support. When migratable capability is enabled for a function of the port, the device is making the necessary preparations for the function to be migratable, which might include disabling features which cannot be migrated. Example of LM with migratable function configuration: Set migratable of the VF's port function. $ devlink port show pci/0000:06:00.0/2 pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 function: hw_addr 00:00:00:00:00:00 migratable disable $ devlink port function set pci/0000:06:00.0/2 migratable enable $ devlink port show pci/0000:06:00.0/2 pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 function: hw_addr 00:00:00:00:00:00 migratable enable Bind VF to VFIO driver with migration support: $ echo > /sys/bus/pci/devices/0000:08:00.0/driver/unbind $ echo mlx5_vfio_pci > /sys/bus/pci/devices/0000:08:00.0/driver_override $ echo > /sys/bus/pci/devices/0000:08:00.0/driver/bind Attach VF to the VM. Start the VM. Perform LM. Cc: Shannon Nelson Signed-off-by: Shay Drory Reviewed-by: Jiri Pirko Acked-by: Shannon Nelson --- v3->v4: - change port_function_mig to port_fn_migratable v2->v3: - fix documentation warning - introduce DEVLINK_PORT_FN_CAP_MIGRATABLE v1->v2: - fix documentation warning --- .../networking/devlink/devlink-port.rst | 46 ++++++++++++++++ include/net/devlink.h | 21 +++++++ include/uapi/linux/devlink.h | 3 + net/core/devlink.c | 55 +++++++++++++++++++ 4 files changed, 125 insertions(+) diff --git a/Documentation/networking/devlink/devlink-port.rst b/Documentation/networking/devlink/devlink-port.rst index c3302d23e480..3da590953ce8 100644 --- a/Documentation/networking/devlink/devlink-port.rst +++ b/Documentation/networking/devlink/devlink-port.rst @@ -125,6 +125,9 @@ this means a MAC address. Users may also set the RoCE capability of the function using `devlink port function set roce` command. +Users may also set the function as migratable using +'devlink port function set migratable' command. + Function attributes =================== @@ -194,6 +197,49 @@ VF/SF driver cannot override it. function: hw_addr 00:00:00:00:00:00 roce disable +migratable capability setup +--------------------------- +Live migration is the process of transferring a live virtual machine +from one physical host to another without disrupting its normal +operation. + +User who want PCI VFs to be able to perform live migration need to +explicitly enable the VF migratable capability. + +When user enables migratable capability for a VF, and the HV binds the VF to VFIO driver +with migration support, the user can migrate the VM with this VF from one HV to a +different one. + +However, when migratable capability is enable, device will disable features which cannot +be migrated. Thus migratable cap can impose limitations on a VF so let the user decide. + +Example of LM with migratable function configuration: +- Get migratable capability of the VF device:: + + $ devlink port show pci/0000:06:00.0/2 + pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 + function: + hw_addr 00:00:00:00:00:00 migratable disable + +- Set migratable capability of the VF device:: + + $ devlink port function set pci/0000:06:00.0/2 migratable enable + + $ devlink port show pci/0000:06:00.0/2 + pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 + function: + hw_addr 00:00:00:00:00:00 migratable enable + +- Bind VF to VFIO driver with migration support:: + + $ echo > /sys/bus/pci/devices/0000:08:00.0/driver/unbind + $ echo mlx5_vfio_pci > /sys/bus/pci/devices/0000:08:00.0/driver_override + $ echo > /sys/bus/pci/devices/0000:08:00.0/driver/bind + +Attach VF to the VM. +Start the VM. +Perform live migration. + Subfunction ============ diff --git a/include/net/devlink.h b/include/net/devlink.h index ce4c65d2f2e7..0f376a28b9c4 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1469,6 +1469,27 @@ struct devlink_ops { */ int (*port_fn_roce_set)(struct devlink_port *devlink_port, bool enable, struct netlink_ext_ack *extack); + /** + * @port_fn_migratable_get: Port function's migratable get function. + * + * Query migratable state of a function managed by the devlink port. + * Return -EOPNOTSUPP if port function migratable handling is not + * supported. + */ + int (*port_fn_migratable_get)(struct devlink_port *devlink_port, + bool *is_enable, + struct netlink_ext_ack *extack); + /** + * @port_fn_migratable_set: Port function's migratable set function. + * + * Enable/Disable migratable state of a function managed by the devlink + * port. + * Return -EOPNOTSUPP if port function migratable handling is not + * supported. + */ + int (*port_fn_migratable_set)(struct devlink_port *devlink_port, + bool enable, + struct netlink_ext_ack *extack); /** * port_new() - Add a new port function of a specified flavor * @devlink: Devlink instance diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index 6cc2925bd478..3782d4219ac9 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -660,12 +660,15 @@ enum devlink_resource_unit { enum devlink_port_fn_attr_cap { DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT, + DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE_BIT, /* Add new caps above */ __DEVLINK_PORT_FN_ATTR_CAPS_MAX, }; #define DEVLINK_PORT_FN_CAP_ROCE _BITUL(DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT) +#define DEVLINK_PORT_FN_CAP_MIGRATABLE \ + _BITUL(DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE_BIT) enum devlink_port_function_attr { DEVLINK_PORT_FUNCTION_ATTR_UNSPEC, diff --git a/net/core/devlink.c b/net/core/devlink.c index 8c0ad52431c5..ab40ebcb4aea 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -715,6 +715,29 @@ static int devlink_port_fn_roce_fill(const struct devlink_ops *ops, return 0; } +static int devlink_port_fn_migratable_fill(const struct devlink_ops *ops, + struct devlink_port *devlink_port, + struct nla_bitfield32 *caps, + struct netlink_ext_ack *extack) +{ + bool is_enable; + int err; + + if (!ops->port_fn_migratable_get || + devlink_port->attrs.flavour != DEVLINK_PORT_FLAVOUR_PCI_VF) + return 0; + + err = ops->port_fn_migratable_get(devlink_port, &is_enable, extack); + if (err) { + if (err == -EOPNOTSUPP) + return 0; + return err; + } + + devlink_port_fn_cap_fill(caps, DEVLINK_PORT_FN_CAP_MIGRATABLE, is_enable); + return 0; +} + static int devlink_port_fn_caps_fill(const struct devlink_ops *ops, struct devlink_port *devlink_port, struct sk_buff *msg, @@ -728,6 +751,10 @@ static int devlink_port_fn_caps_fill(const struct devlink_ops *ops, if (err) return err; + err = devlink_port_fn_migratable_fill(ops, devlink_port, &caps, extack); + if (err) + return err; + if (!caps.selector) return 0; err = nla_put_bitfield32(msg, DEVLINK_PORT_FN_ATTR_CAPS, caps.value, @@ -1322,6 +1349,15 @@ static int devlink_port_fn_state_fill(const struct devlink_ops *ops, return 0; } +static int +devlink_port_fn_mig_set(struct devlink_port *devlink_port, bool enable, + struct netlink_ext_ack *extack) +{ + const struct devlink_ops *ops = devlink_port->devlink->ops; + + return ops->port_fn_migratable_set(devlink_port, enable, extack); +} + static int devlink_port_fn_roce_set(struct devlink_port *devlink_port, bool enable, struct netlink_ext_ack *extack) @@ -1348,6 +1384,13 @@ static int devlink_port_fn_caps_set(struct devlink_port *devlink_port, if (err) return err; } + if (caps.selector & DEVLINK_PORT_FN_CAP_MIGRATABLE) { + err = devlink_port_fn_mig_set(devlink_port, caps_value & + DEVLINK_PORT_FN_CAP_MIGRATABLE, + extack); + if (err) + return err; + } return 0; } @@ -1769,6 +1812,18 @@ static int devlink_port_function_validate(struct devlink_port *devlink_port, "Port doesn't support RoCE function attribute"); return -EOPNOTSUPP; } + if (caps.selector & DEVLINK_PORT_FN_CAP_MIGRATABLE) { + if (!ops->port_fn_migratable_set) { + NL_SET_ERR_MSG_ATTR(extack, attr, + "Port doesn't support migratable function attribute"); + return -EOPNOTSUPP; + } + if (devlink_port->attrs.flavour != DEVLINK_PORT_FLAVOUR_PCI_VF) { + NL_SET_ERR_MSG_ATTR(extack, attr, + "migratable function attribute supported for VFs only"); + return -EOPNOTSUPP; + } + } } return 0; } From patchwork Tue Dec 6 18:51:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13066219 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 433C4C352A1 for ; Tue, 6 Dec 2022 18:52:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229541AbiLFSwt (ORCPT ); Tue, 6 Dec 2022 13:52:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbiLFSwQ (ORCPT ); Tue, 6 Dec 2022 13:52:16 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 184323D90A for ; Tue, 6 Dec 2022 10:52:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hX/s2XyOhlQJ+LQKF74XAXryXbMjBkaFcer5uA56DHVxpXjtjGVBdQRenzP+xxxvavjmo2VqgXw1r2kQnS6WpFIItpQY+loaWkwq8v/+nRF0n1QFgEloeyNaJurlrPK+rBA27hLpVsUr4bex+BFsiJMW4nOioQTXIdYOkoiYCbCScbgZNhivKRFUiqyjImmSXxBJr0008mga+s21khpG9taW9yYW7wjSvZNtn1ydy5v2A0F92D0xFVvkf9AIyheIyhVX1px4IyiK+P/6t7e3u3S2yKx4UrUBh4SnV8yVO0ogK81LbbSQcqWECDD/oBBYxIinY6h26xcCWT8XjRPwGA== 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=ADo/j24LhoFGPxD7bML+Il7TOrn7/hIl3EPEOR0ZPss=; b=ec4ktI3hLuIvZs1jUIxobHQ213XtZQ/OGQYWIOlDNlvI3HKeQ58JVwWsoxcKbGKLm9shNZeBobVkqViBpM2aoHbzz8XZ5VRTu13TNeAVhdR5Z40gcOSNpTFD8KzgCPUNB0fv3QZ0xvVm8ERMTPRcxCCqOS6lKAIBKXsVdvXTNnu2qnYKC9yqmY1u4Z8e3346WY/YS8obLk3jmQMzazLzvqndC8NkPf3pXH/J5KVlUyDB13XgkpLrtQ5QXRyZ+wVBqOoAP2YDHmHr6duKAaVcIEpxoKlwPYtwARmY4UVIb8p9Yi6ZrjO+vakuIVH/vjPzelh8kBsFiSzw16UuVgTOag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ADo/j24LhoFGPxD7bML+Il7TOrn7/hIl3EPEOR0ZPss=; b=gBDrNUYSqN5H5znVUcd6k6sdUMvFcOflH1aQub8hZ1vtKLeeZazrgrG7dvNe8csjGIvKNkmifG1Mfn1nFBV9qTtxNt7MHtEoNYKlvTFuA0y/qZkwlH6iqA/tBYI+utGi4B4nWfHKG9i2BjG90SBUart5vwhQ6vl8WLLZu8AZDtJY8RnVYKFdEQnUxy5thmKfsO2+WaC4VtFltiMBr67W2YF3B0EaBxPpIEkHQ+sqblhkiARc3bd/U+lQgWnRMVwzhqbvrX0nZoGFtZFyjB26V8wU0aJRcdoi8ixmJzdDSP0xvumvPmb8A93s1uBiIoBeKqeMgcGeOB/DUcrKscTo2Q== Received: from MW4PR03CA0050.namprd03.prod.outlook.com (2603:10b6:303:8e::25) by IA0PR12MB7699.namprd12.prod.outlook.com (2603:10b6:208:431::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Tue, 6 Dec 2022 18:52:13 +0000 Received: from CO1NAM11FT086.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::8e) by MW4PR03CA0050.outlook.office365.com (2603:10b6:303:8e::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Tue, 6 Dec 2022 18:52:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT086.mail.protection.outlook.com (10.13.175.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5901.14 via Frontend Transport; Tue, 6 Dec 2022 18:52:12 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:55 -0800 Received: from nps-server-23.mtl.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 6 Dec 2022 10:51:52 -0800 From: Shay Drory To: , , CC: , , , , , Shay Drory Subject: [PATCH net-next V4 8/8] net/mlx5: E-Switch, Implement devlink port function cmds to control migratable Date: Tue, 6 Dec 2022 20:51:19 +0200 Message-ID: <20221206185119.380138-9-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206185119.380138-1-shayd@nvidia.com> References: <20221206185119.380138-1-shayd@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT086:EE_|IA0PR12MB7699:EE_ X-MS-Office365-Filtering-Correlation-Id: 03e6f355-acce-4003-453e-08dad7bafc48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wArdm9b/GYsk0n7PBmR6W9DG/ejPRCoVIME1uRkaxMD3qFEo+DNPO92xHMEMmSOmBfeRv9eKHGvmpqV5HOasuISfSzeuTr4LO1MiZlTyFClK72xVvb8ZCP1CajSTRTl44MwTnAGNLczc6uwPhqmmJQFZqoHnZE0zir6rlnYsCFwQ9hhFYiomlCFdumOYrDvgt8WG3tAS8rWWOvtYOxsl/rKPJxVxuztNCFcluO9NfuyZ1S0dxxpRuqIpb6wmuimAZdZYEn1wBdF31ZPLPkLd1yR8yXbDNF2lKpztAWQ3FHc66Pgec1iFYnYkJSdDrLXNsal87U2uS9usvGVcq/ElqPLtkfozfSo5NCkga1yKgcjPpO48dsVjy4rB7b6HTjzxxzXviIGnVx83J0uplsKe8AEgsD2oysq5NpSQTaWE9ttWJqm2i/M2+L9aGSQEtrKLNOX0al+0jyoZPDrCuSAw1Rix9siUpWFIFPPRcDWLaXNvO7ncA6DIHDRUOeEjoFpffpBHzH+NbQmXcR6b9D+AcBDJJF/L1pdo2F+gEC94Pi+1LRDZkcB/3bEszS103rrUId5sca93lg0+D5cR7qtH4sspaTH3+OruP5W5YlrdNW/IxQa2TWLL2S3FKbSjR2hTCQSyYFy4UdKhHbGYb3SfoBZv/8RynTG6FwDPMhHrolMUYyIeoSb/tG+kiNvyHjc3xEDARdQ5ddcwh4YgLEHE+w== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(396003)(39860400002)(346002)(376002)(451199015)(36840700001)(46966006)(40470700004)(1076003)(336012)(186003)(16526019)(316002)(478600001)(110136005)(54906003)(36756003)(356005)(82740400003)(7636003)(40480700001)(86362001)(40460700003)(47076005)(107886003)(83380400001)(2616005)(26005)(82310400005)(426003)(6666004)(8676002)(5660300002)(2906002)(4326008)(70206006)(36860700001)(70586007)(8936002)(41300700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2022 18:52:12.1267 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 03e6f355-acce-4003-453e-08dad7bafc48 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT086.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7699 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Implement devlink port function commands to enable / disable migratable. This is used to control the migratable capability of the device. Signed-off-by: Shay Drory Reviewed-by: Mark Bloch Acked-by: Saeed Mahameed --- v3->v4: - change port_function_mig to port_fn_migratable --- .../device_drivers/ethernet/mellanox/mlx5.rst | 8 ++ .../net/ethernet/mellanox/mlx5/core/devlink.c | 2 + .../net/ethernet/mellanox/mlx5/core/eswitch.c | 8 ++ .../net/ethernet/mellanox/mlx5/core/eswitch.h | 5 + .../mellanox/mlx5/core/eswitch_offloads.c | 101 ++++++++++++++++++ 5 files changed, 124 insertions(+) diff --git a/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst b/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst index 8b8f95d1293a..6969652f593c 100644 --- a/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst +++ b/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst @@ -364,6 +364,14 @@ PCI devices/SF. mlx5 driver support devlink port function attr mechanism to setup RoCE capability. (refer to Documentation/networking/devlink/devlink-port.rst) +migratable capability setup +--------------------------- +User who wants mlx5 PCI VFs to be able to perform live migration need to +explicitly enable the VF migratable capability. + +mlx5 driver support devlink port function attr mechanism to setup migratable +capability. (refer to Documentation/networking/devlink/devlink-port.rst) + SF state setup -------------- To use the SF, the user must activate the SF using the SF function state diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index 336c7b7fa494..ddb197970c22 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -316,6 +316,8 @@ static const struct devlink_ops mlx5_devlink_ops = { .rate_leaf_parent_set = mlx5_esw_devlink_rate_parent_set, .port_fn_roce_get = mlx5_devlink_port_fn_roce_get, .port_fn_roce_set = mlx5_devlink_port_fn_roce_set, + .port_fn_migratable_get = mlx5_devlink_port_fn_migratable_get, + .port_fn_migratable_set = mlx5_devlink_port_fn_migratable_set, #endif #ifdef CONFIG_MLX5_SF_MANAGER .port_new = mlx5_devlink_sf_port_new, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c index 001fb1e62135..527e4bffda8d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c @@ -794,6 +794,14 @@ static int mlx5_esw_vport_caps_get(struct mlx5_eswitch *esw, struct mlx5_vport * hca_caps = MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability); vport->info.roce_enabled = MLX5_GET(cmd_hca_cap, hca_caps, roce); + memset(query_ctx, 0, query_out_sz); + err = mlx5_vport_get_other_func_cap(esw->dev, vport->vport, query_ctx, + MLX5_CAP_GENERAL_2); + if (err) + goto out_free; + + hca_caps = MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability); + vport->info.mig_enabled = MLX5_GET(cmd_hca_cap_2, hca_caps, migratable); out_free: kfree(query_ctx); return err; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h index eea0521729df..5a85a5d32be7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h @@ -154,6 +154,7 @@ struct mlx5_vport_info { u8 spoofchk: 1; u8 trusted: 1; u8 roce_enabled: 1; + u8 mig_enabled: 1; }; /* Vport context events */ @@ -513,6 +514,10 @@ int mlx5_devlink_port_fn_roce_get(struct devlink_port *port, bool *is_enabled, struct netlink_ext_ack *extack); int mlx5_devlink_port_fn_roce_set(struct devlink_port *port, bool enable, struct netlink_ext_ack *extack); +int mlx5_devlink_port_fn_migratable_get(struct devlink_port *port, bool *is_enabled, + struct netlink_ext_ack *extack); +int mlx5_devlink_port_fn_migratable_set(struct devlink_port *port, bool enable, + struct netlink_ext_ack *extack); void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type); int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index 7618c51351ca..c6a14202c62c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c @@ -4038,6 +4038,107 @@ mlx5_devlink_port_fn_get_vport(struct devlink_port *port, struct mlx5_eswitch *e return mlx5_eswitch_get_vport(esw, vport_num); } +int mlx5_devlink_port_fn_migratable_get(struct devlink_port *port, bool *is_enabled, + struct netlink_ext_ack *extack) +{ + struct mlx5_eswitch *esw; + struct mlx5_vport *vport; + int err = -EOPNOTSUPP; + + esw = mlx5_devlink_eswitch_get(port->devlink); + if (IS_ERR(esw)) + return PTR_ERR(esw); + + if (!MLX5_CAP_GEN(esw->dev, migration)) { + NL_SET_ERR_MSG_MOD(extack, "Device doesn't support migration"); + return err; + } + + vport = mlx5_devlink_port_fn_get_vport(port, esw); + if (IS_ERR(vport)) { + NL_SET_ERR_MSG_MOD(extack, "Invalid port"); + return PTR_ERR(vport); + } + + mutex_lock(&esw->state_lock); + if (vport->enabled) { + *is_enabled = vport->info.mig_enabled; + err = 0; + } + mutex_unlock(&esw->state_lock); + return err; +} + +int mlx5_devlink_port_fn_migratable_set(struct devlink_port *port, bool enable, + struct netlink_ext_ack *extack) +{ + int query_out_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out); + struct mlx5_eswitch *esw; + struct mlx5_vport *vport; + void *query_ctx; + void *hca_caps; + int err = -EOPNOTSUPP; + + esw = mlx5_devlink_eswitch_get(port->devlink); + if (IS_ERR(esw)) + return PTR_ERR(esw); + + if (!MLX5_CAP_GEN(esw->dev, migration)) { + NL_SET_ERR_MSG_MOD(extack, "Device doesn't support migration"); + return err; + } + + vport = mlx5_devlink_port_fn_get_vport(port, esw); + if (IS_ERR(vport)) { + NL_SET_ERR_MSG_MOD(extack, "Invalid port"); + return PTR_ERR(vport); + } + + mutex_lock(&esw->state_lock); + if (!vport->enabled) { + NL_SET_ERR_MSG_MOD(extack, "Eswitch vport is disabled"); + goto out; + } + + if (vport->info.mig_enabled == enable) { + err = 0; + goto out; + } + + query_ctx = kzalloc(query_out_sz, GFP_KERNEL); + if (!query_ctx) { + err = -ENOMEM; + goto out; + } + + err = mlx5_vport_get_other_func_cap(esw->dev, vport->vport, query_ctx, + MLX5_CAP_GENERAL_2); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Failed getting HCA caps"); + goto out_free; + } + + hca_caps = MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability); + memcpy(hca_caps, MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability), + MLX5_UN_SZ_BYTES(hca_cap_union)); + MLX5_SET(cmd_hca_cap_2, hca_caps, migratable, 1); + + err = mlx5_vport_set_other_func_cap(esw->dev, hca_caps, vport->vport, + MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE2); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Failed setting HCA migratable cap"); + goto out_free; + } + + vport->info.mig_enabled = enable; + +out_free: + kfree(query_ctx); +out: + mutex_unlock(&esw->state_lock); + return err; +} + int mlx5_devlink_port_fn_roce_get(struct devlink_port *port, bool *is_enabled, struct netlink_ext_ack *extack) {