From patchwork Fri Dec 2 08:26: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: 13062396 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 44241C4332F for ; Fri, 2 Dec 2022 08:30:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232829AbiLBIaA (ORCPT ); Fri, 2 Dec 2022 03:30:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231468AbiLBI3P (ORCPT ); Fri, 2 Dec 2022 03:29:15 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2056.outbound.protection.outlook.com [40.107.100.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A368ABA1F for ; Fri, 2 Dec 2022 00:26:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KSzqRnl8negW/FGKCHxeReGycRpZuB6XsBrUjgWnqHMpuxDi6Qy4zrv57uXAEzO67uvUCmrkbLb4KfL/mqE5Th15nT7ugLMl4AmwPlTGa9qelnaOZs6kOPvUHuVWDKrvhF0p2ntWM2IKQQ1KnqK769Wmz7nrcmiiSClyg2owS8lle+CvV0EKE9Ml2Fig/13niiHpC5WCCaLq8lbo+zdGMXbZbebw56iS1z8w+uf3K2HFqIHvIGuY91AA8kEZ6wTFfT6S8IYEPV2RV4qF2TjctU+tXXGVS/ZTWCmObkde1DsJcHAp6Otntt1jzfUZ9OABFRai0Qk3q9pyScKV9CWqKg== 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=ONGy8oKcPoZ8EW0yO9WaTBcbklWLuo7gAAG5cS6ob0ZmSMmZjiDlRWwDTpyKFZ1NtlpCwV0KqZ0B8qOe29yQLVWk++yHVx/bDBblNmJ2QLNdrJ/Y+lF01qbLI3cB/2lyE/fYJGxfYRyNHgqcCbuJChjpF/G3/abPRqWnV1gxC45IwMPOlhcOQvhrmuRucvjSWuUoTvKI0I5oQPfE5+Hp7bNdhKLpnhYHeKkPXV/vC8UqTf7yxDoI1TADBkAQqAwPdLJDfvOTe9FtMTwbp1zUwJoq0/yBIOSizoDc7PqY5TexJPIULOhAyPni56szM33nY6FLtVeIkfLM01wteVR7Bw== 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=LTny/6TSqOFfO8nfwISfiiAAkcHEXJpf2tH80vHe5Fw=; b=JVQPoJQN/dSpwJCN79IAIplY58qbrxU7/knFJo8j4qYNqtkb8d2LL88lBxIQBjnhqTInqv7K66ACWbYB76RRRbWaO3pcuIIoUHc0EiHcj4Nf2DxwUgyeZXb7nQ7Cq+J1tQQiYhDSQdsjUY6t0j72yQHBdAzvdDyJML6E/o562Ls3jdvBrUEGkGM++Vw7szzIWphc92RSiV/suSzYGUYDHS91bZLwPIjt66/1WejjMZrcnU5dHO+Xy8pGh/v9LuyLOuXflrBCQJC0dW5Fg4pyLIYg3onKH/JK03ZvPxyx9F2Pv1mahwA6y/uwTMn1UWo2qZS8R1vCXIG8O1dRrGIJoQ== Received: from MW4PR03CA0212.namprd03.prod.outlook.com (2603:10b6:303:b9::7) by SA0PR12MB4445.namprd12.prod.outlook.com (2603:10b6:806:95::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8; Fri, 2 Dec 2022 08:26:47 +0000 Received: from CO1NAM11FT099.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b9:cafe::61) by MW4PR03CA0212.outlook.office365.com (2603:10b6:303:b9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10 via Frontend Transport; Fri, 2 Dec 2022 08:26:47 +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 CO1NAM11FT099.mail.protection.outlook.com (10.13.175.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.17 via Frontend Transport; Fri, 2 Dec 2022 08:26:47 +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; Fri, 2 Dec 2022 00:26: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; Fri, 2 Dec 2022 00:26:33 -0800 From: Shay Drory To: , , CC: , , , , Subject: [PATCH net-next V2 1/8] net/mlx5: Introduce IFC bits for migratable Date: Fri, 2 Dec 2022 10:26:15 +0200 Message-ID: <20221202082622.57765-2-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202082622.57765-1-shayd@nvidia.com> References: <20221202082622.57765-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: CO1NAM11FT099:EE_|SA0PR12MB4445:EE_ X-MS-Office365-Filtering-Correlation-Id: 54c94dbe-321e-4c23-abe0-08dad43ef44d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZMJWQr123F7G95pi5/R3YK5Hy1zYwELly4HyyGI4lGJ3kMMw2S4oORFT3vZ9zyPgA+blUCKQW+pxcDpuVfF/8/WRLqZjyRbq8ZJgIIuXbUleP+L4L059tKPLkZyOMWr7uvU9v73PvkK9j9/ZoDQdGVD4c1TO90jY4L4/10e9AjATNQOA82XsRrccv2hnCruRe9KojFlJPuIFC9/VDYe22cAoOGW0/k9FnMEi4fVts2eRkXg2QGLuXcTrV2yDmm1BSUlbwVEJBFeJPArfBWtUM3sOMOD9i4PDFRltYfieCyLxKUlTWBycWuZkk6bLwyRZ8PUaEU39nCgIHLNOeIPyCwziS7raDkYts5oOf3IhUrdryB0qXljzR9WNptX7P3Oj/0jfzjnQA/8mu2tfBomlb+EntBBQtP4tFGupx0JDrZ214DMWF3YTpSEwLrC8YiqFOcOp63ML7R2WsDVtbDeFmDmlQA3Pu/TWMZtmT5gAauQM2sSYDs4vOUEGlRNCkurOW4EWN7lznQz/lt3ipfxIRO9CvIl/fswF1f3FPjyCctugG7T7DLRd5upu8f3fV5eqDigEjXdiAyCZt5VkU5Mr0COf7cZTtBnz4XDEWjAtXr3dxdyyH38zl7xVKLN/uIxQm9v+U1TAZxQIBZTwct5IUAh1xOKHqFKnvmb4kNoftcYBHfR71/Nkpu9uSe9RnS/yzmnUU8fNewBZVi2VEXJ6Og== 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)(396003)(136003)(39860400002)(376002)(451199015)(36840700001)(46966006)(40470700004)(82310400005)(478600001)(6666004)(107886003)(7636003)(356005)(86362001)(82740400003)(70206006)(2906002)(40460700003)(54906003)(8936002)(110136005)(316002)(26005)(16526019)(186003)(336012)(1076003)(36756003)(41300700001)(70586007)(4326008)(8676002)(2616005)(40480700001)(83380400001)(426003)(47076005)(36860700001)(5660300002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2022 08:26:47.6575 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54c94dbe-321e-4c23-abe0-08dad43ef44d 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: CO1NAM11FT099.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4445 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 Fri Dec 2 08:26: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: 13062398 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 365F6C4332F for ; Fri, 2 Dec 2022 08:30:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232846AbiLBIaJ (ORCPT ); Fri, 2 Dec 2022 03:30:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231775AbiLBI3Q (ORCPT ); Fri, 2 Dec 2022 03:29:16 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2063.outbound.protection.outlook.com [40.107.94.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C26D6AD309 for ; Fri, 2 Dec 2022 00:26:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RqfgSbuGuj0EPSzYxJhjHxr3JFgr1LcG72TJ7UXKnzqSI6FiMTPkWDZ0VQ25jfuBg0WbUtL782x/469RgifBGlgvTB7k1kNwDSkoi7ZGGc81wH3t5RacjcqdFTYJzzX8X2k47j0+pYs7tJTQslzM7U3IIPgNdTVld8TrGAABTCt6enR0jjaf+iciaTxIB+AZ75RVnUcdcy54j1l4RKY15vVoJtQqXxXTfmchp2W3Ue75C+jeDEgxo/P4lqIegBGr7wT+i63Qf+aPLimBXy18olRKKocIV2b1+RDVx7bXSRmJMXauRjrdYKzs46phaJkxld8HMXM5HNDecCh6Kn7L6g== 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=iuROjBwmMaxRRY9kR3q8lk9vS9JAf0cwOL+3YeWtNz0=; b=BpYIujWqavb+KyntxmlTro2EBdvZ8uxMrO4VzCgpFnDneMrspbZcwRunjIH476aFeVxEjiQHynN+9kHyZYg0ZNqvzg6+AIxnilfXrMODtIbHbuUCB1mPAWmpLGxV+UwtG9hI/GOd+AqRoyvLBDqXu4V21+63x0swZT95qG7+wB0F9mzW4V10pQI5qg6kzBXWjdkmWa243XzG15p3PUeSC/CeDxeXbADBDvnbT5BMvjiR0U0955/hv9N1L9BULmlazg/pW6iGKkNpOkatNlFzluPPELmhgOpocR/D86dsJu2tZi77KzpbvN1oF2J5PLAtc0TRVH757BsbCSrHCdBL1w== 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=iuROjBwmMaxRRY9kR3q8lk9vS9JAf0cwOL+3YeWtNz0=; b=qs9CLesiH/zYyByspuj3NLmiTbb5N7hxg2/yMWT111w82gB3w5fV4hsEBwbuvWOB5ALw3AZpiDfWJEXz1ODe54RZTuc+HzCWbOuUbM3/JUmhW4nICsEAL7WDuks/rPT5OWBc3XnwEXwlRdjZ0kc2TtNYi0w+e0lba7jxqTqZYtyZA112fid2VzuL6g+vy94PpGnLGlf0U9D7dGUZOOpPNVjRs8SIjhyVLi/o27+AyBTyfKC/27vyeiJCbu4mq4s3iixf28J4YsiIeSSw/SyB+UW3pz4Br2FS3hvB/rCmrxWjqIq1d8f6rqZd68ahTzadubt7+eDhHcwZvI9ZhnYSaQ== Received: from MW4PR03CA0144.namprd03.prod.outlook.com (2603:10b6:303:8c::29) by SN7PR12MB8172.namprd12.prod.outlook.com (2603:10b6:806:352::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10; Fri, 2 Dec 2022 08:26:51 +0000 Received: from CO1NAM11FT087.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::c) by MW4PR03CA0144.outlook.office365.com (2603:10b6:303:8c::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Fri, 2 Dec 2022 08:26:51 +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 CO1NAM11FT087.mail.protection.outlook.com (10.13.174.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Fri, 2 Dec 2022 08:26:51 +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; Fri, 2 Dec 2022 00:26:39 -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; Fri, 2 Dec 2022 00:26:36 -0800 From: Shay Drory To: , , CC: , , , , Subject: [PATCH net-next V2 2/8] devlink: Validate port function request Date: Fri, 2 Dec 2022 10:26:16 +0200 Message-ID: <20221202082622.57765-3-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202082622.57765-1-shayd@nvidia.com> References: <20221202082622.57765-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: CO1NAM11FT087:EE_|SN7PR12MB8172:EE_ X-MS-Office365-Filtering-Correlation-Id: 234fc17a-b48d-4c97-46f5-08dad43ef677 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U8A0pbgH9OFX0xmyVsRFVODk+fKjMVulqSzez+i4DH/pGHkCxovdKUCMTxc4vSBiV89HrrlBIUOSADYwpAt1meXVWHcLG6SwOpeddd6Wiw1mtR69MW/ZVL2vEgvFKwxlBStzYMETAumap2M/gkDGScQTm68d/T6Nn1jW6z4cm8rY+TISll/WQCHSmhqGuGClqAx8OLnrO9oK74s5Qho+XqoYxr18L209K3x2aft6LAl+jJAnvTMuTBb0+xdVcEGc6RPSaQwBPcHBJZJz3LOBbvbvBpPx9IBeczTZmcYAG70iVmuZoW0GFenjPHTDW9CmystI55/CSKlSA/CtgpezbgtIwspYpDZLRZ/ncLwxqfydIGf15J2M/O9gECd+UEPdDNdvDqppo3z+Pg5lshRqDz8Q8o11tK/6Ph7b0sasaTVsj2mVwYInWSM0Yb86B/UtXP8dJDxedn69B68BYT/s1mNdtp3aLr8UE8MWGekao16dWJlDxLfXR7B0L+eSGyovnNIKX70M2Ta3BzvwSmSsdxV1+RfA+t9y63gnnIFxgQF+6rHQm1Kh7OiT+2fWratS25KhkuGx+TrWIKzFtvZwZR4Nt3HPlosHeLxmDyr8kVuoglP0CKtljxAQXgjQIgKLsaDpa7/iR9ZIW2nDsk2lTOFIdkrxlCzHXEWzzKeSeBUlfv8iWHfQIrccGM7/xvgVKSfqMn11CAEVxofW/zbVlg== 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)(39860400002)(396003)(136003)(451199015)(40470700004)(46966006)(36840700001)(36756003)(82310400005)(8676002)(70586007)(70206006)(186003)(426003)(336012)(41300700001)(4326008)(5660300002)(1076003)(2616005)(82740400003)(16526019)(47076005)(8936002)(54906003)(110136005)(316002)(15650500001)(2906002)(40480700001)(26005)(6666004)(356005)(7636003)(107886003)(36860700001)(83380400001)(478600001)(86362001)(40460700003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2022 08:26:51.3013 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 234fc17a-b48d-4c97-46f5-08dad43ef677 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: CO1NAM11FT087.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8172 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 | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index fca3ebee97b0..70614dc90f9c 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -1644,11 +1644,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); } @@ -1662,12 +1657,26 @@ 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) { + 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_MOD(extack, "Port doesn't support function attributes"); + return -EOPNOTSUPP; + } + if (tb[DEVLINK_PORT_FN_ATTR_STATE] && !ops->port_fn_state_set) { NL_SET_ERR_MSG_MOD(extack, "Function does not support state setting"); return -EOPNOTSUPP; } - return ops->port_fn_state_set(port, state, extack); + return 0; } static int devlink_port_function_set(struct devlink_port *port, @@ -1684,6 +1693,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 Fri Dec 2 08:26: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: 13062397 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 2986CC4167B for ; Fri, 2 Dec 2022 08:30:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232740AbiLBIaC (ORCPT ); Fri, 2 Dec 2022 03:30:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231736AbiLBI3Q (ORCPT ); Fri, 2 Dec 2022 03:29:16 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20617.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::617]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1810FAD300 for ; Fri, 2 Dec 2022 00:26:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M8aSRB8OJMdkm1lsiiJ0qcxbJLjnpghqCieX+FDEglZWJJZyGfleqizafHV45MSCH/uDQg8b8iLlFmka0yFnmJhs2krylIATsQ4CBagGHu/ELF9g/uitY6P8pM7ITQhzb4CbtiDVlbgmW6fFmazpnvt2BuABGu2JGPqyzjPK+2VHzmJbyTZYCbD9t/59EugzHFBUfnNt6TlcZl9DzuS7YVkYtmn7ipFovV1arxcu70aEAEa03yGcfl36qPOPbPfEzyhsFI5FHoaRPpZEK22s56zEpiNL5R7PQn8kOAvy9zi9vjUgdmuRoeycpB2edIrauRCP1h9hsg0mEM1WkwKvSQ== 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=jI0oqAapzluA1YpkyjzcyXMuhaJW2qVrtZSa5F9r4sg=; b=hGs0gRiqKO4NvoOr+5z5md/fKPVTquMsmS303n4YfVGMQsSXuAoyxVtyU1PPZMsh/wkW+/CxF1SJqWEJFUFAhslQ2zRVF1BOG85enBn/pDHRk4f4MrxV9qqIxa/G4iGqAyBy1bffUF9Qn1+lPNEnTUaWEJIyjUVW+/4lhREW0UM4KM2EbPgBcei1Tkdllt/TWVlelKhI0Vrtw/+nrYnKQvkW6Y/VT2tMM4SoSh0wHZ/vys0rEAjlVWVJEc9ZbraPNEPVufdZEUNAK3VnR0zMq1eEVu3zMOKBDwRejjfq671wM5tk3kkQaAEeXyc4pNqRVOv8b7yXm0BXNlnbx/5rzQ== 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=jI0oqAapzluA1YpkyjzcyXMuhaJW2qVrtZSa5F9r4sg=; b=GP00q3ZwVnBUyEqNRGRLjMjaIIbAXF4d3iBGBf2ecxX6h7E8fPoXD6jphg4g+PauhA3pK1NgmzRGenhokOc7eWCyNRK5/0nsmX330R2jNWcfQD48AuHr+7I4GkWd2Z0H+tdF9wRUkXy1L6e9TqN7wnB/YEomILK8bgudYu5dX/fBUH0k+wwq7ATXpaXYLWxYHK6gNPZrmU55d+FyAqNrPL9sS/L+t4XhZihzZY6VgdxJGPQ73ioEmwzEbXT0tUGWzWCBc2Ns7CML8711Ll5C++AZrFTtb3szyjmkrz6xQ6F6rlMv7KhCjp2t4vZFEHeZg4UQFC1w6pEqu5hVNwLGeg== Received: from DM6PR08CA0047.namprd08.prod.outlook.com (2603:10b6:5:1e0::21) by BY5PR12MB4163.namprd12.prod.outlook.com (2603:10b6:a03:202::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Fri, 2 Dec 2022 08:26:50 +0000 Received: from DM6NAM11FT078.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1e0:cafe::3b) by DM6PR08CA0047.outlook.office365.com (2603:10b6:5:1e0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10 via Frontend Transport; Fri, 2 Dec 2022 08:26:49 +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 DM6NAM11FT078.mail.protection.outlook.com (10.13.173.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Fri, 2 Dec 2022 08:26:49 +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; Fri, 2 Dec 2022 00:26:42 -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; Fri, 2 Dec 2022 00:26:39 -0800 From: Shay Drory To: , , CC: , , , , Subject: [PATCH net-next V2 3/8] devlink: Move devlink port function hw_addr attr documentation Date: Fri, 2 Dec 2022 10:26:17 +0200 Message-ID: <20221202082622.57765-4-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202082622.57765-1-shayd@nvidia.com> References: <20221202082622.57765-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: DM6NAM11FT078:EE_|BY5PR12MB4163:EE_ X-MS-Office365-Filtering-Correlation-Id: aed26a8d-6d75-4622-2d4b-08dad43ef594 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eEaSxDszEQ0hjSuZMatc6FDNO0lR/6IJ110mNF+rvmiB6eoQih3PYfd3YohU0gdMhBr3Fh99Qjq1ASrH9xQ8YYQZiklqEpoIJY8WiLQAGZohQnzn2knhDlyrzjBcGzkGct8tt6oDlpKqxFsCzmU9WXFVCCfzJIKPrmfUQX/pYWKu9r3UDRnDVOhl7mG/oIcWFSnOW/XZNsTBEh19E+tFQxuA4hOpvs4y+GpRnoVNm8WcXhO6f8TpcT4FxkSXhIanATvc3WcG9XPY8lyyKXKbHGxeroUKKWXapgYJdgz6ECu6P+XrpyQhBstMCFH1O73J2bbwAmO5Q4OA7Z19HAWHiL9cpNzAwTb+2l9hpwylPpzIz7jq+paLH49GC0mSmqfLy+4rYcJRhAMSV6+jBSYPOygLrRoVldQLIABFrX9/m/MpH/JTlBWIhWbVba28iuIW9cexFZDQdm+glWvyzQma8hJgnkbZ3NnCU65fskxp0kVyBeueLpQVBrjZYmCZZhQ0bZ2qqsVS4HATZaqGgg/9r52TggCG/iKpDrl4e+Zes28VW0dV9JL+pVE2cfqzhFfDqglnz51vZgSSDbzdCjQNCTFXd0PQRSLWeuENOQhtbM806gnHP3NDN+jgqWE15e1y+3bj1l5AfdQ/k6h2YYf4h6TKY3R04dkzSurlLyq/WNtd3o1/kLOy4Vy41KTe4P6hL40LVTCWqbdklP53OyfAhA== 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)(346002)(376002)(39860400002)(136003)(396003)(451199015)(40470700004)(36840700001)(46966006)(426003)(47076005)(7636003)(40460700003)(40480700001)(2616005)(8676002)(54906003)(41300700001)(5660300002)(336012)(316002)(36756003)(26005)(16526019)(4326008)(70586007)(1076003)(8936002)(82310400005)(186003)(356005)(82740400003)(110136005)(70206006)(2906002)(83380400001)(86362001)(107886003)(6666004)(36860700001)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2022 08:26:49.7973 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aed26a8d-6d75-4622-2d4b-08dad43ef594 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: DM6NAM11FT078.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4163 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 | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+), 36 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..0b520363c6af 100644 --- a/Documentation/networking/devlink/devlink-port.rst +++ b/Documentation/networking/devlink/devlink-port.rst @@ -122,6 +122,46 @@ 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. +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 VF 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 pcivf pfnum 0 sfnum 88 + function: + hw_addr 00:00:00:00:88:88 + Subfunction ============ From patchwork Fri Dec 2 08:26: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: 13062400 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 4B91EC47088 for ; Fri, 2 Dec 2022 08:30:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232854AbiLBIaa (ORCPT ); Fri, 2 Dec 2022 03:30:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232214AbiLBI3R (ORCPT ); Fri, 2 Dec 2022 03:29:17 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2063.outbound.protection.outlook.com [40.107.237.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE87BAE4EA for ; Fri, 2 Dec 2022 00:26:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lyl1wwpdinH4kj7uN9eOTwkBoYdhncTtiYdnuN5I1aqyRe1CRcnNSPgTLLUYfUdPN0+kugYAx2DtpJnPaU2I9Sd920Nj/nYS+YxgKfE3sePROq8zZSzsjsBL4sZbzYKCFyB6k/Pw+i72TRtGf2ZHNEsGzw3o2e7HE43cdpPUujUF3QTnTtyyDoJEBf6jLtM+VlGav2gfiC3ztNIqVc0Be6BABbI3OLwfa0dXiBrD01Ot+sATJA33rhpRAJlcNN6zkyOgsmxLBVFJBMiC/qDVrIucFVl02M683AyCbUKTrXO2NXru3M/GWinyrClw8VHJ1Pbx9pQEwZYWSLMcCjWo5A== 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=t4vdJuVLVBZrPBAuzIDidf+s+xbLYCiBco/upLX7rCI=; b=cCw/ZjbofNw27tBVDIPBiAOHwnLukiXfFDGwYt/0ZWU1aoPkiP9OZUXjOFz4nIam7pIBwKrpePmcWKGpL6OZYBkpxS8p7ciTMAF+4Jb337LfNf6r7l5vFs+msmltC7IdBVEy62AerG2kt7wo6BdIKjez4TlbHAGHkKQerx5vzY5s/3P/KKqDpatNOGZKxhPCfVZT63MD0MTTVygi4PdBNk48IgrXmtLbZZ2EN10FUz2H6RMyaUbM8LRRIklR5mAoUxIB2tMUwoQTu0liSB1l6zB3p9kaskO8nx/WVvaBZ2ijfFExV2qNiUt7AXnI+8q11aSpvvGiq+snVsLwvZGGFA== 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=t4vdJuVLVBZrPBAuzIDidf+s+xbLYCiBco/upLX7rCI=; b=QInmmJHHQdn41xP9nS/8Bzwyz1uXOLfih5KDrvOee69hItG+ULcoCddGt+tUAq+qJCDHYGOKmoUsbLqasZtvHHsj5kLhMPUp39eANyLLmIRf5khEr+FAwtbDr94XD2pIwf9SgesizcKteb4Dr2WVk+5s5GFJsSCVBJVbDVjNuK2onkXUUUvLFPoG3dCDUbZIUqiTcEYLQsiC10E+/6Wk1h1bvB+2nF6dMFnOoVCT7hximLCPBfp8n7JP6AQaKi7ltHZsr32+cdn/6cNbfC1B/H3Fx4ctZ6X1tZ/Txls7FUvT1txftADbPUCPtDsAArq3B/nsd/I7UZjBm3X208xC0A== Received: from MW4PR03CA0150.namprd03.prod.outlook.com (2603:10b6:303:8c::35) by SA1PR12MB7128.namprd12.prod.outlook.com (2603:10b6:806:29c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Fri, 2 Dec 2022 08:26:58 +0000 Received: from CO1NAM11FT087.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::4e) by MW4PR03CA0150.outlook.office365.com (2603:10b6:303:8c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10 via Frontend Transport; Fri, 2 Dec 2022 08:26:57 +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 CO1NAM11FT087.mail.protection.outlook.com (10.13.174.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Fri, 2 Dec 2022 08:26:57 +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; Fri, 2 Dec 2022 00:26:45 -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; Fri, 2 Dec 2022 00:26:42 -0800 From: Shay Drory To: , , CC: , , , , Subject: [PATCH net-next V2 4/8] devlink: Expose port function commands to control RoCE Date: Fri, 2 Dec 2022 10:26:18 +0200 Message-ID: <20221202082622.57765-5-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202082622.57765-1-shayd@nvidia.com> References: <20221202082622.57765-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: CO1NAM11FT087:EE_|SA1PR12MB7128:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e325e31-9a62-48e8-1a16-08dad43efa4b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h9y+k2C/N6D/IWXabz9JX/9htdxHCE/ud6RIdD0aZ3B5ZcD8wMIQSzl1u39Tft8jhvUyXEuwbyajVDIn9Dq4jbrOLGZQzoXwY4vaUcIKVEf1kfKvzGrar/hjB0qhiSalA6jwgCbfgV/vNH3oP2iUbwEftP1LPEemLpUlDhrKJWqotJ64I4+Nwf6vK6v1ZFfZG1P1otQbujFBRUZIJLOqFB6Pha/T/qUrwNFC057SxUgEJ3V+xZApFvInN0eYM/mMXzfI0XpMMttL3klflq8UsRH9Bqao3kkE+9T3Y+02oxpkJqpwUhaQrGIrLaBtzn413Ya2IACqlN74QxRZEdTggUUX+bhUPJev9uzHjaKd7tU1P+pD3eWbJUgeLJ/wx2vHF9zKzw1WW8tuRkDtRLMV0BzEuyGuTFgehruh1gEKfnvTj4DR+MGJLpgdHXJoc7mWO9M2Nr0Fj27wzjF1xBVyVBvEzx526ly7XZLEl48hLq1U7qK9agRpgP/tJSbWJwa3BBDp6CkOGNvNLawHLKP7XA7758gU1sPdRk+OXuKAvAzR5kvfRIIQWzXE3SRjaVcVp2XZIZyqIea+NlmpIFJ8xaXL2U8VnbRlQViJGrepOalmaZjbLxvc/44+B0jRgRSv06pfPikPPraBKxB3hekpyLwwLN+nMfjP7LgZF7E9d9er0yyFNnCwE5ALJzBmqCA6DLFvg8z0ERT8OTV9QnvqYg== 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)(346002)(39860400002)(376002)(396003)(451199015)(40470700004)(46966006)(36840700001)(40480700001)(7636003)(478600001)(82310400005)(40460700003)(70586007)(82740400003)(26005)(356005)(6666004)(8676002)(36756003)(70206006)(54906003)(336012)(316002)(4326008)(86362001)(110136005)(47076005)(426003)(5660300002)(41300700001)(186003)(8936002)(16526019)(1076003)(2616005)(107886003)(83380400001)(36860700001)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2022 08:26:57.6914 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e325e31-9a62-48e8-1a16-08dad43efa4b 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: CO1NAM11FT087.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7128 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 --- .../networking/devlink/devlink-port.rst | 34 +++++- include/net/devlink.h | 19 +++ include/uapi/linux/devlink.h | 12 ++ net/core/devlink.c | 114 ++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/devlink/devlink-port.rst b/Documentation/networking/devlink/devlink-port.rst index 0b520363c6af..79f9c0390b47 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..20306fb8a1d9 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1451,6 +1451,25 @@ 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_function_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_function_roce_get)(struct devlink_port *devlink_port, + bool *is_enable, + struct netlink_ext_ack *extack); + /** + * @port_function_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_function_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..830f8ffd69d1 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -658,11 +658,23 @@ enum devlink_resource_unit { DEVLINK_RESOURCE_UNIT_ENTRY, }; +enum devlink_port_fn_attr_cap { + DEVLINK_PORT_FN_ATTR_CAP_ROCE, + + /* Add new caps above */ + __DEVLINK_PORT_FN_ATTR_CAPS_MAX, + DEVLINK_PORT_FN_ATTR_CAPS_MAX = __DEVLINK_PORT_FN_ATTR_CAPS_MAX - 1 +}; + +#define DEVLINK_PORT_FN_ATTR_CAPS_VALID_MASK \ + (_BITUL(__DEVLINK_PORT_FN_ATTR_CAPS_MAX) - 1) + 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 70614dc90f9c..dcf6aae443a9 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -200,6 +200,8 @@ static const struct nla_policy devlink_function_nl_policy[DEVLINK_PORT_FUNCTION_ [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_ATTR_CAPS_VALID_MASK), }; static const struct nla_policy devlink_selftest_nl_policy[DEVLINK_ATTR_SELFTEST_ID_MAX + 1] = { @@ -692,6 +694,64 @@ devlink_sb_tc_index_get_from_attrs(struct devlink_sb *devlink_sb, return 0; } +#define DEVLINK_PORT_FN_CAP(_name) \ + BIT(DEVLINK_PORT_FN_ATTR_CAP_##_name) + +#define DEVLINK_PORT_FN_SET_CAP(caps, cap, enable) \ + do { \ + typeof(cap) cap_ = (cap); \ + typeof(caps) caps_ = (caps); \ + (caps_)->selector |= cap_; \ + if (enable) \ + (caps_)->value |= cap_; \ + } while (0) + +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_function_roce_get) + return 0; + + err = ops->port_function_roce_get(devlink_port, &is_enable, extack); + if (err) { + if (err == -EOPNOTSUPP) + return 0; + return err; + } + + DEVLINK_PORT_FN_SET_CAP(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, @@ -1275,6 +1335,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_function_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) @@ -1293,6 +1382,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) @@ -1665,6 +1758,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) { @@ -1676,6 +1770,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_function_roce_set) { + NL_SET_ERR_MSG_ATTR(extack, attr, + "Port doesn't support RoCE function attribute"); + return -EOPNOTSUPP; + } + } return 0; } @@ -1703,6 +1809,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 Fri Dec 2 08:26: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: 13062399 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 8D70AC4332F for ; Fri, 2 Dec 2022 08:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232849AbiLBIa3 (ORCPT ); Fri, 2 Dec 2022 03:30:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232182AbiLBI3Q (ORCPT ); Fri, 2 Dec 2022 03:29:16 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2070.outbound.protection.outlook.com [40.107.101.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C714A7BC30 for ; Fri, 2 Dec 2022 00:26:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eb0frO0HhBHOqeghRZb6Y0xgrDy4IfVCDkVp33muHZ1dlPJ1fOLzM4tX8QApH5+on24/q7ok2Pa03mMYoYGl6isNgIxs9W2fbmtpnhHTAZrRkYg2lyP4j0YyAZcWvU5x9tu6zlxoSPzIC/yN+22NtGFmagcexg2NfqwjR1BZgAqgp5buUk3GiuVEl4php/BQKyc40gFVCiH5kt2uvpVpchqLzg1zMZIOg4x+ceqPaEvYL9ttgk+MdLCAew/O+I9pHZZ3l+T/ACgdZMZzOM9Bzbz15FMcTqfAOxYnFsI2my13HJD3dQEqNFQRLg5GYn0pH1rGz/6PHKwsREJIP+2qdQ== 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=DU7pwmIkYMUT0RfPtBKOE4x7DhabbTkf8QglJ+SvoGFAxzwZHqdjXEpzEZuLIY/KvPMHhnCWkHY91OHOza+KG/+Oj8UhhC21x1ct/v3Vm8ZCOHJ20UYJDVzJhtDK/6eLMw5ksl6JrvVMdx9QPE69SiFOLaC8WzAw65LJApA3wFkdKxth8PFLOoAtnycTKS39gSAiPj6oGq0WviQv+rnWS57d0BcTtE2zvWurJ3ElKV7z0Bg7ZbPTqW+T44fnOe6vFkGBm/jwn48KrDq5gDojBtqBd07pO6UYIPu9c+4ojOCAQJ0yBHvFwZ35f4f2SWRgxYvoxjQ/jf9+kcs9bETIsg== 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=Cohp42hgKFB2ktw1KV+MTsCcJt+jONQqO+ZkXNAbk11NshOZXFzGYRwJtmy02WffJUZlqGx3MQb7Bq0rkqwk7fvddwp1B11KjIMaL/bOLIUdBnd48WCVnni5fOjXW9EJky29CCQL5LstprSHp4//nRqNzGcvZb/yJJcNH6g1N8lNIcHLbaFcQ/8p0Mx87GyWom6qpOMflXspKXvHolZBU3N6hgngt8Zll6d/DHlOk+FmeVu/uA02gsqujMXHhjuwsQiP7CIHOU+/Xlzq2EtM4SpkzIrPtKfR1wpiFYBeniIkj53rCnm8cQwyCq7SEqAWuAciokbJCnZmFjnuNqlQEg== Received: from DS7PR03CA0296.namprd03.prod.outlook.com (2603:10b6:5:3ad::31) by PH8PR12MB6987.namprd12.prod.outlook.com (2603:10b6:510:1be::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.17; Fri, 2 Dec 2022 08:26:56 +0000 Received: from DM6NAM11FT096.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ad:cafe::3b) by DS7PR03CA0296.outlook.office365.com (2603:10b6:5:3ad::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Fri, 2 Dec 2022 08:26: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 DM6NAM11FT096.mail.protection.outlook.com (10.13.173.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10 via Frontend Transport; Fri, 2 Dec 2022 08:26: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; Fri, 2 Dec 2022 00:26:48 -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; Fri, 2 Dec 2022 00:26:45 -0800 From: Shay Drory To: , , CC: , , , , Subject: [PATCH net-next V2 5/8] net/mlx5: Add generic getters for other functions caps Date: Fri, 2 Dec 2022 10:26:19 +0200 Message-ID: <20221202082622.57765-6-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202082622.57765-1-shayd@nvidia.com> References: <20221202082622.57765-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: DM6NAM11FT096:EE_|PH8PR12MB6987:EE_ X-MS-Office365-Filtering-Correlation-Id: 3cc9b776-37d7-47ee-db7c-08dad43ef948 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rq6RTaip088mW5MPot1NRk2oDPZi9G/amBZJScBi/Ec4Me7LsOab1iH9+5SIHvsoW0cc/DsgsmTEnIbj4N11sxijOCnn0peByr0J8BAemIuc04vJK38WBmzt8u0sZFHX6grNsGZKcmRuCRS5wyWXxU3xYOCvfXfQ/1RE+oXjJwSnwbiqadlo2L4OqdJkMusk5dLPBSZgksS4uXC8j1axkTJqBtz7HDt97frRl+8Rn5AxtZLmaGDKCih3dBEiS113eMfF4jq+CgQHQXpwMUj5MRBXvG6g8DM1Am/G+Odj8W/+M20lA+JAQrA1WUx8fvY5hiFVmTfEMXEKtvyPszffh/3xR3dLT11Qrnmq3XT9/WV5Q72j8YCS61dm1Cvs30H+PbL3YZuM2vRItLOq+/eFSj/T5umZBR4x7NMfS51CY2Opl9lH9y+mLJN10UVv/HRQodfAQJuhRfwLrbori9hth4/ZOELecXFuAhwIHgLJmviaOK3hupH7pOOPWjWMFTDVtt3Mgm41A4IRKCyp9HyA++IRfKk9TwQU+3a84IKYorCs2TXpX6YIm1z7m0fr3ygL6XtpheeqG1sf0RCTtOLcABXJRUrNpq/NEba+l7dlWvBIAjLfAPZiOGTjoJIErO8+cb7toTL2LXAknSwubfc0snU5g6O0d/LJbo9SXRpJ7yY/5fShZ0JRfYZ5heDb768US8FepyDdKyHJ5msK4GGDBazPFKFj3x/9OlxPUXWjwFM= 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)(136003)(396003)(346002)(39860400002)(376002)(451199015)(46966006)(36840700001)(40470700004)(86362001)(36756003)(40480700001)(7636003)(478600001)(6666004)(2906002)(107886003)(26005)(82310400005)(41300700001)(110136005)(4326008)(5660300002)(70206006)(54906003)(356005)(316002)(8936002)(8676002)(70586007)(47076005)(336012)(82740400003)(36860700001)(40460700003)(1076003)(2616005)(186003)(16526019)(83380400001)(426003)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2022 08:26:56.0146 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3cc9b776-37d7-47ee-db7c-08dad43ef948 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: DM6NAM11FT096.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6987 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 Fri Dec 2 08:26:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13062401 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 61209C4332F for ; Fri, 2 Dec 2022 08:30:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232855AbiLBIab (ORCPT ); Fri, 2 Dec 2022 03:30:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232228AbiLBI3S (ORCPT ); Fri, 2 Dec 2022 03:29:18 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20620.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::620]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB41EAFCDB for ; Fri, 2 Dec 2022 00:27:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UvKINsh2B9NQFWa+v2nVW25KfIf2rU79XgnuZZUsDWqHvyh/3iIzgxWH/KmyLEpXtqsyi/docI5vv0Ay7FWB8UI2avXg9TEBe43LmorbFPYLWN4bS1IYf7YxJTvolz0nWi8p2G2Hn/Ok+mA+WJJfXAYG9DYa7Xp/lumqdDYbYxwoPbvkn1n40BizW9NaRJxVqeQQ0UADFylpAfQWMh0xFov9qMoziJzZ9z3ueXkmLHJeU9uSpzI/eolR7W5dYRklQbI3ng2CcyiQJ7/kZ98m9QPnlxzhqzmoZ4od8Ha1Fyc/0yMp/P84M1KHRmhVTRiOwll2ShGRF8V1t2/TdaQAog== 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=cklU5gEz7jWwCwHiUYw/s1wXGXpvEgzGozGPJEn7yto=; b=RNF9Rtxds/oN1sYo/5Q/2trXrxIsE7yQGu2r6sLy9kHqgeu5mIgUO0umJB4S1ekegiAFr/GXJpR3JvWm1F2jDhoEz160yVMoaUB1t2R8ojtk/rqBDSuoqb09PwSWz/RIFjynWAfRD7FL5PxMGqZtl0B4xhZwFxliz7evaile5fJxMkvY+DVnT+0NOIDx4czYBAu4B9wWy4IQHhFJXWHGlTdr+FbcXAP8Er6CR6qNKzFE5yW5I9HRmJkSIQ6hwGoIJUBr18WylVM5i71iVAFsd4b6inp6iM8AV06IYyyW0F/nYWmJ5SFDxLgpG/GOx4rxBaVmQHJZ9XPZUHk4SBrJiA== 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=cklU5gEz7jWwCwHiUYw/s1wXGXpvEgzGozGPJEn7yto=; b=XRIzJnFKz2LcvdNRlEBWqaZFQGldK22V2Gg8ff+P45DBnNU+ZhuQuA6SfgeQSggVal5AG2fEeoe7vQoHdGivR7uqXvDCjfd+wyf9tXkIGyLBMHgueMXqqAqp8NHLt2/EPteg7treb1g4IKR3Kmy2eiK4nISz0HIO+EkVbHvbOBiHgZfRkZjwtvlAYfyytOkJgOln3tAkjX2YqD4iJku9DA0NuTFIkxY062tA6gMN3ZpIpHDl9/maLCOeyeVI0czcOMczvY3KXwH7s1RqPOIjiLRYyjLyK5iRJnUFwAfzYBekwh5NL4xKiYLdqCJQkHTibY6mVBbwdeg2swktBgzFXg== Received: from DS7PR03CA0275.namprd03.prod.outlook.com (2603:10b6:5:3ad::10) by CH2PR12MB4277.namprd12.prod.outlook.com (2603:10b6:610:ae::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Fri, 2 Dec 2022 08:27:00 +0000 Received: from DM6NAM11FT096.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ad:cafe::25) by DS7PR03CA0275.outlook.office365.com (2603:10b6:5:3ad::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Fri, 2 Dec 2022 08:27:00 +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 DM6NAM11FT096.mail.protection.outlook.com (10.13.173.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10 via Frontend Transport; Fri, 2 Dec 2022 08:27:00 +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; Fri, 2 Dec 2022 00:26:51 -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; Fri, 2 Dec 2022 00:26:48 -0800 From: Shay Drory To: , , CC: , , , , Subject: [PATCH net-next V2 6/8] net/mlx5: E-Switch, Implement devlink port function cmds to control RoCE Date: Fri, 2 Dec 2022 10:26:20 +0200 Message-ID: <20221202082622.57765-7-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202082622.57765-1-shayd@nvidia.com> References: <20221202082622.57765-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: DM6NAM11FT096:EE_|CH2PR12MB4277:EE_ X-MS-Office365-Filtering-Correlation-Id: d5d95758-e49c-4f4f-c6c3-08dad43efbc7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k8llcJOCjO+2bc1mUqZVnFUHx+cTs4XHRQJ6BCaQJ6FB3VyM6KoTLB/OMdeBH25xvqWVPrMwGuxm2QPcHZ80H+vv3InvLVnn3VzViw+ile4VIWZ2sUI3349ChkrdTCJW0acA3UXezqixvPI+YZa944Hl7n8BiRYKFtl/cpL4n7gzPhgMN+57hyOedc1czODJ8KbF6W4qGX3wzJXdww0S4tEV96H+4kqmZvoXQkOuq6s3o/efv3iR52nCR68Zunp48HVKn2O0gZSqusTlDGgyk51NiwgpL1SS0p3MAKYPHvretQvVtfU+jGye53ln+kQuKLrMT8hvJfwmyifrgLsPzmuqpZsyqIiE6KLN2cun/qc8jbojpgBGzofy7ZybCoPyjIg26L/1UZ59JIlz/0VPFbs41CSR48R1tzHRunCe0K46Mqm8wpwmBl6t1CCBg0pHHwr+iEorW0atJOuJrKmn77zAIH1JcsPd9a5TWySfzlKGA7DJdnTlKbEcGWfwfMooec2bCDLBOU42wBzSVzWjT2KuudK5Xl2ZYmQYMeVw5JHSaqYlGXwXLpSziZSUytllM7+92r3hLNod6iAtnXgc5JV+WGIclUw2U0+5ZlfM1V9DWwP4T6xp/NQUqZnjvdwfksIUW0458Qmjg7Hyb0r7dxT8Py+vSbw5Wd7Dt3rJZbb6hxpw48ZEKHivsOs03XaPghjgeI4jsoKFs/OOZCj1uw== 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)(136003)(39860400002)(346002)(376002)(396003)(451199015)(46966006)(40470700004)(36840700001)(47076005)(5660300002)(426003)(40480700001)(110136005)(54906003)(40460700003)(30864003)(41300700001)(16526019)(70206006)(82310400005)(356005)(336012)(7636003)(82740400003)(8936002)(8676002)(4326008)(186003)(1076003)(2906002)(26005)(2616005)(36756003)(70586007)(36860700001)(86362001)(6666004)(316002)(83380400001)(107886003)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2022 08:27:00.2018 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d5d95758-e49c-4f4f-c6c3-08dad43efbc7 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: DM6NAM11FT096.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4277 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 --- .../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..992cdb3b7cc8 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_function_roce_get = mlx5_devlink_port_function_roce_get, + .port_function_roce_set = mlx5_devlink_port_function_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..71f27fb35c49 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_function_roce_get(struct devlink_port *port, bool *is_enabled, + struct netlink_ext_ack *extack); +int mlx5_devlink_port_function_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..f258fd7e27a8 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_function_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_function_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_function_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_function_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_function_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 Fri Dec 2 08:26:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13062402 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 D93C0C47088 for ; Fri, 2 Dec 2022 08:30:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232862AbiLBIad (ORCPT ); Fri, 2 Dec 2022 03:30:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232406AbiLBI3S (ORCPT ); Fri, 2 Dec 2022 03:29:18 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2057.outbound.protection.outlook.com [40.107.92.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A007B0B75 for ; Fri, 2 Dec 2022 00:27:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=liMTGXLn7zRAJ4GA6294pOsScGHkr65M4HAmrG6Bwz+EFT461as+1Hm5QXT/Ko97ItfYnZIu5Bq271NldT8eJ5MLVWdh9YKVGa5Ag2wwrGX0tdpaB+6nE/AIaEfDbYeR3nyM7IlAEdZktycovCnAL/DCLOCIin1+miklKzmH+K495biqu4+j/gUeutm3eGVXCBVbe40ad8YZ50MuJTEeDTLVJG0SBFIDcCBPMipImLlix7DuSiA9w/ETCzvt3sjzsU44oCs07s0+27Lq4tVsgeFV6nsF2gAj1gxjcqu7j/ZfGlxt2XbGGMAJVjrxS6mq6QQAYb6dXcyP+CWiC8/rxQ== 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=wWFdRmCdeB0qwnmZbBuyUCx7h0WXmtCUhh3eXF1joUk=; b=RZF0F2M9lpHfpXzq1KIaVxwKJDJhXcKobcVK01Nbdmiho6uKmORoZVWc99Z8vNl0kEaaudd6J1DHHAQsuky0DxQpgnRtsLKj+0rLc+WxDwNgv/uveKbX7BMiRdHAMxFrdLQmbY2atoDr8+b05Ls0npKSOSk6l9pu6G/AUCaGx1qP5T3qdWZPDP+QKmrpWy2dDC8b/7Lb4qxpyeunhtPPJtHYKA8/4zs3wunk5e5/CSatMNg+iF95hLL9d/Re9UcybbWpRVmnkfSvpqMXBkOVV4DbUxu4T9VMRxLDMNq3UTG7e0yFTUzm9rA0GJ6+IaBmfL7yXebhONsrDzHYfBrkVQ== 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=wWFdRmCdeB0qwnmZbBuyUCx7h0WXmtCUhh3eXF1joUk=; b=WjKzpKzaBoTRtDjs7gRC1eBxaNEflmqSft1+BKyP7A2nxIfK7ihfb69OgUO8BeyB1ntw+zLK6GHYV55KRhM2s02dbPIkj2JFyuH1wLnCtJbWpuZ1K05dGZMCSazMtc+tqdsBRkae9UjuggfmbJIfODL0t730/+Mn1sCsSe9CBNf2dPsH4PrTrr+uGwogmE07lo9spjuSF+JizvC1j6U2CtPLtLJyLDWUUoytbJoW1YjaOgbY6hcVg8qiWFpqFk8Ry2VNxiIExVJ2e4fStQXHDq5qUVv5pUi8yQwPy+uLPyzar8Wl2vXjwlNCh1h8diIpzJ32pIADTI6UhEsqT3AA7A== Received: from MW4PR03CA0337.namprd03.prod.outlook.com (2603:10b6:303:dc::12) by DS7PR12MB5765.namprd12.prod.outlook.com (2603:10b6:8:74::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Fri, 2 Dec 2022 08:27:07 +0000 Received: from CO1NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::3) by MW4PR03CA0337.outlook.office365.com (2603:10b6:303:dc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10 via Frontend Transport; Fri, 2 Dec 2022 08:27: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 CO1NAM11FT049.mail.protection.outlook.com (10.13.175.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10 via Frontend Transport; Fri, 2 Dec 2022 08:27: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; Fri, 2 Dec 2022 00:26:54 -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; Fri, 2 Dec 2022 00:26:51 -0800 From: Shay Drory To: , , CC: , , , , Subject: [PATCH net-next V2 7/8] devlink: Expose port function commands to control migratable Date: Fri, 2 Dec 2022 10:26:21 +0200 Message-ID: <20221202082622.57765-8-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202082622.57765-1-shayd@nvidia.com> References: <20221202082622.57765-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: CO1NAM11FT049:EE_|DS7PR12MB5765:EE_ X-MS-Office365-Filtering-Correlation-Id: 24477438-74b6-4e10-be53-08dad43effa9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j+HrHTFlmEaNXXyyd5nCZyfUKxt2ngJn/7XbxmM1ogqy3vAWJxKIvwdGzSVBGTWxp1IqR9Wmlwq/iqfmrXcYe/J0u+saiJ85glptY+pjHYm/F/UyObS/W8JsUiR4qSXdaBQGpXoT4OFRhPZNigTLkVKWz13YZXOCXEzqVL2yBvGU9+lxdR57Yu1Felm83dsHJm/tcGvFDPhwBy74nmsmDVPoODgnVxs1bISz0LsoA3v/YqPQOVGJlC8QwZNSwEnGXShe3Idt9Lgp1itwT1lo/26jnKORzY3d4u8TRvHQ7U7kuiQUqF6jmZd/rqp6scctR2VzboIeRDXAk5w+sROJ59CpH9E+eSenJvvMp+VqHhiOoVxxZYvCZTXf14p1J+5id4GxhWK2xehcJDhvmNo4t++WQjD9DXPov30B+JHmUDs84zSdINbLPLIHe214iG+iDzFdDjiVTFiuF88c4cVA66/RYp7dViWRia87IOJnt8eaKeLpL6U3iE0Jrttfm6r0Txh9taWnCXudp8whmDC5LHAi4IY6UR1ZtY9JwVDXtL65nFNyB5eWHIt70SCjqfMrzXQh+AjJqv3tO127+rg4TTVpJmbOwKV2d4bC3FcPh2JFSGvc9ouM/DZF3VzgvAyRpH/pYEkPtRjHnP5TQSy+om2dgGhqiZuEs2e8KDJ+9NkPWp79GnlEavCCkk7nXHK686f7LRvKqg9FePYrhCvD5g== 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)(136003)(376002)(396003)(346002)(451199015)(36840700001)(46966006)(40470700004)(7636003)(40480700001)(40460700003)(356005)(6666004)(2906002)(36756003)(2616005)(107886003)(86362001)(16526019)(478600001)(186003)(8936002)(36860700001)(26005)(316002)(70586007)(5660300002)(41300700001)(70206006)(110136005)(4326008)(54906003)(8676002)(82740400003)(336012)(1076003)(82310400005)(83380400001)(47076005)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2022 08:27:06.7315 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 24477438-74b6-4e10-be53-08dad43effa9 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: CO1NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5765 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 enable 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. Signed-off-by: Shay Drory Reviewed-by: Jiri Pirko Reported-by: kernel test robot --- v1->v2: - fix documentation warning --- .../networking/devlink/devlink-port.rst | 46 ++++++++++++++++ include/net/devlink.h | 21 ++++++++ include/uapi/linux/devlink.h | 1 + net/core/devlink.c | 54 +++++++++++++++++++ 4 files changed, 122 insertions(+) diff --git a/Documentation/networking/devlink/devlink-port.rst b/Documentation/networking/devlink/devlink-port.rst index 79f9c0390b47..2e3d17291ae0 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 20306fb8a1d9..fdb5e8da33ce 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1470,6 +1470,27 @@ struct devlink_ops { int (*port_function_roce_set)(struct devlink_port *devlink_port, bool enable, struct netlink_ext_ack *extack); + /** + * @port_function_mig_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_function_mig_get)(struct devlink_port *devlink_port, + bool *is_enable, + struct netlink_ext_ack *extack); + /** + * @port_function_mig_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_function_mig_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 830f8ffd69d1..5a2b87a05c74 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -660,6 +660,7 @@ enum devlink_resource_unit { enum devlink_port_fn_attr_cap { DEVLINK_PORT_FN_ATTR_CAP_ROCE, + DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE, /* Add new caps above */ __DEVLINK_PORT_FN_ATTR_CAPS_MAX, diff --git a/net/core/devlink.c b/net/core/devlink.c index dcf6aae443a9..9ea6d1f854db 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -728,6 +728,29 @@ static int devlink_port_fn_roce_fill(const struct devlink_ops *ops, return 0; } +static int devlink_port_function_mig_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_function_mig_get || + devlink_port->attrs.flavour != DEVLINK_PORT_FLAVOUR_PCI_VF) + return 0; + + err = ops->port_function_mig_get(devlink_port, &is_enable, extack); + if (err) { + if (err == -EOPNOTSUPP) + return 0; + return err; + } + + DEVLINK_PORT_FN_SET_CAP(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, @@ -741,6 +764,10 @@ static int devlink_port_fn_caps_fill(const struct devlink_ops *ops, if (err) return err; + err = devlink_port_function_mig_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, @@ -1335,6 +1362,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_function_mig_set(devlink_port, enable, extack); +} + static int devlink_port_fn_roce_set(struct devlink_port *devlink_port, bool enable, struct netlink_ext_ack *extack) @@ -1361,6 +1397,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; } @@ -1781,6 +1824,17 @@ 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_function_mig_set) { + NL_SET_ERR_MSG_ATTR(extack, attr, + "Port doesn't support migratable function attribute"); + } + 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 Fri Dec 2 08:26:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13062403 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 C1EF8C4332F for ; Fri, 2 Dec 2022 08:30:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232288AbiLBIau (ORCPT ); Fri, 2 Dec 2022 03:30:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232412AbiLBI3T (ORCPT ); Fri, 2 Dec 2022 03:29:19 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2042.outbound.protection.outlook.com [40.107.237.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C56D6B0B77 for ; Fri, 2 Dec 2022 00:27:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iZ8Uu/MtxqSE4ZWIQzeIycUc1MFQt7S9T8Rs32V3vgkAW1P63f5uKYU1ZYQg1PL1197RRc6g3sDXOy51EAKUxe9isjkeDYgt3brM/h6/nIExFlLFtmYuXHBuOYAzKkn5UJ/s68hiI/q+30h8KexdZjTsN4JeaJdGa4oy2CFUdEB2exQUYZN8cMvwrWKRNF1vtPsT2o6LpTIYLmkwkLmjbUmNida+vtHVsna1cusmSfjXmHNH8b5Q7j8XvJSjEAel0CJQex4/noUA7NnP/71f9nRWPv2QuKPZas5eHBAx4xtnHdXccHs07lxibdOD2N7mEStJ+ulH+TJshQmsCZmktQ== 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=0mEsBYf0YCHE+52R+L01sHCVv6+tB/Pr7te8VPcd03U=; b=SMQ5jKx3mhN5LMVgy+0iH9UJNFCgSIMko9ZHA5ytxRwGqO7eDqSyMDkL5GmnCpGOF8YRdrsq4n2tP++gPrXWmt9rpnm4J2WetLxnnHzXYhgeTgb2pmAOIBF2CVqSqAGNXv+Qux1SD3UiPUKW887EBkNVKDJqGGh1uSl/pYy5VSwAj1t3dJ38Q/oOfW+fdNAe8p4RgH7yApOfBj81svK4jnI2Dvu3kmiFkufjoTv8NZ4CQ8NN5GmRN27o8tWmGhFYioG5rxd9lUUasqzVYEkO0JXMyNCFgpOiqidLdBmoZ7F7Q9iTpn2+bSs1h6arebDtFR7XS08bRCajEmDJQqXh2g== 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=0mEsBYf0YCHE+52R+L01sHCVv6+tB/Pr7te8VPcd03U=; b=QwwcMMuSEqmt4S/Dda4EefsCQnpKVOwT6F02cbO/iQagG+55GV+HhhmMdV5w7FcPD6Yg2FZz0UanpUsia9q+iUm1LmRiU+S5qFWRBVYOUg4TFLKMnyeGD8ghSdYmuhKT+209w+VKWAAe9HOeMQDGzb2+9UlBPd1C0vZ6eZBRz1h+ueezXfCdlQiaN9gZ8/+ZRb7wm0pesBOQQz6VuWetBgdhjWYwtR+hcoyYcL1IYgVe0ELvh9V5z8Ihq3joy0O7vDtI3aPKGT3md5ypBMEsce2UEVdPc2jxotRZjpW5LtkYgQ4e4f9UZbr8wrjRKAhge+zOUEjdq3en1838TpA7EA== Received: from DS7PR03CA0180.namprd03.prod.outlook.com (2603:10b6:5:3b2::35) by IA1PR12MB6650.namprd12.prod.outlook.com (2603:10b6:208:3a1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Fri, 2 Dec 2022 08:27:07 +0000 Received: from DM6NAM11FT112.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b2::4) by DS7PR03CA0180.outlook.office365.com (2603:10b6:5:3b2::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10 via Frontend Transport; Fri, 2 Dec 2022 08:27:07 +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 DM6NAM11FT112.mail.protection.outlook.com (10.13.173.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10 via Frontend Transport; Fri, 2 Dec 2022 08:27:07 +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; Fri, 2 Dec 2022 00:26:57 -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; Fri, 2 Dec 2022 00:26:54 -0800 From: Shay Drory To: , , CC: , , , , Subject: [PATCH net-next V2 8/8] net/mlx5: E-Switch, Implement devlink port function cmds to control migratable Date: Fri, 2 Dec 2022 10:26:22 +0200 Message-ID: <20221202082622.57765-9-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202082622.57765-1-shayd@nvidia.com> References: <20221202082622.57765-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: DM6NAM11FT112:EE_|IA1PR12MB6650:EE_ X-MS-Office365-Filtering-Correlation-Id: 9caa8d8b-ac65-4014-a93d-08dad43f0005 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zAZ99De/RL6ZYXERIYKcOZxQCvyByT3HEP6OjUZf8HvZi6dWduO5opDNG8Har4ikfkB+DHf2s8gPOwzfMxMrcbbSCGQcxTrta2GTl3KZQG+rNNdZijkKtUFL34N4tmAM7cI9T73q4wYwmYMfzzvDNhKTchcCJktPJ+t7OnD8VIPjxucg+vXSOGrhDUBsCVt3iTH4p9PxKiKtTu4VJjdCgyjLuhu221hXf/wGNXDbJP66XD1J5t/kcBPJGcADAWxqaAMx/SJZZ8krqKv+EfsfXZyeHsK+8/VDA5EFT8QbQSthtbwVqAjZm6u7lFTKntf7Xs5NXkk/yo6h9QjOYXKIrvm+v8FzoPGXbxQbtFEhlkvhKzRtjSt5u7Qp63YYYrLve/A3gtjcHuSdBAzTfUFGfmbApuJdhaC2d+uzDEQAEq5YpdNjpzanEEcT2pYJsQ+Ucee2b09dbn0PDKAGlJmHq8z+xT/vY/dIspgtZ/SHeJVpIulT0IiZ352wlua1CsDi5XH0ZNWdnU4GfINHHZDyPO7KkIhVNfYCSecsYT89pd8k122F3vcuMsKsvtazC6GzfcfQNeCh5T82Z3Vv6oWs/bONaAS//sTKtlNDGCtRiBW+hcSdJcSbW67M6dbBGr4nP8AHbBTKW8jzTaQ5QlHAQ3Xb/Ktnslu9mE3vYCZDtJUDCerkAnTJwNP0AUbulWS2loSuGdbldQY17LrCdEhWxg== 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)(376002)(396003)(136003)(451199015)(46966006)(40470700004)(36840700001)(186003)(2616005)(1076003)(36860700001)(426003)(107886003)(47076005)(336012)(16526019)(5660300002)(36756003)(6666004)(82310400005)(70206006)(86362001)(26005)(478600001)(82740400003)(8676002)(8936002)(83380400001)(4326008)(40480700001)(356005)(54906003)(70586007)(41300700001)(7636003)(2906002)(40460700003)(316002)(110136005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2022 08:27:07.3339 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9caa8d8b-ac65-4014-a93d-08dad43f0005 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: DM6NAM11FT112.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6650 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 --- .../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 | 100 ++++++++++++++++++ 5 files changed, 123 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 992cdb3b7cc8..a674bf0b6046 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_function_roce_get = mlx5_devlink_port_function_roce_get, .port_function_roce_set = mlx5_devlink_port_function_roce_set, + .port_function_mig_get = mlx5_devlink_port_function_mig_get, + .port_function_mig_set = mlx5_devlink_port_function_mig_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 71f27fb35c49..8625b97411a9 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 */ @@ -509,6 +510,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_function_mig_get(struct devlink_port *port, bool *is_enabled, + struct netlink_ext_ack *extack); +int mlx5_devlink_port_function_mig_set(struct devlink_port *port, bool enable, + struct netlink_ext_ack *extack); int mlx5_devlink_port_function_roce_get(struct devlink_port *port, bool *is_enabled, struct netlink_ext_ack *extack); int mlx5_devlink_port_function_roce_set(struct devlink_port *port, bool enable, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index f258fd7e27a8..ce38d9c0ad71 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c @@ -4038,6 +4038,106 @@ mlx5_devlink_port_function_get_vport(struct devlink_port *port, struct mlx5_eswi return mlx5_eswitch_get_vport(esw, vport_num); } +int mlx5_devlink_port_function_mig_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_function_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_function_mig_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_function_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_function_roce_get(struct devlink_port *port, bool *is_enabled, struct netlink_ext_ack *extack) {