From patchwork Sun Dec 4 14:16:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13063874 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 4716DC3A5A7 for ; Sun, 4 Dec 2022 14:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230129AbiLDORO (ORCPT ); Sun, 4 Dec 2022 09:17:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230115AbiLDORC (ORCPT ); Sun, 4 Dec 2022 09:17:02 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2066.outbound.protection.outlook.com [40.107.96.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0028A16489 for ; Sun, 4 Dec 2022 06:17:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j0wJfWrd3MnQ66gZhdW87Sz2RRnq2xwrg4vQC78uXISK9vtfy3eS3Cvwrh7+iavTeWwuMKWr6Fzz9mWQutpTvszQpdzJF4JQ9tZYBG0w1HYzknFJ9wwg2ubZhrIOUmN0vupWOKlE+8WRd+Dnd7CSwVHsM97+7gHWUBPd9ZSa/wqa/mSNZ9zy3OSXFnKt4hMeTkngbrn5/HdQsrtVDNbRiQWR9kx40lZHMvP7Ez3OWEjxVm3/vsln8L3+s8GTxIED6ATM4IJzeo/s8MmLjwrVGPKbhUND/Aw8QljZMINoTOOOPxHFpAFF9xpuTES/5RoXW4+n9X7CcTg7dOLS1uTLng== 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=awAETMcjUzKuaPe4Q07eIX8EtZCos0IkjDJ8maM6zQjqWQ2mXdeaVueHJLGHoXuaeO23mh3ezxjzXFnD/aPKY+RbDtNZhQ9tW+GKKBWis1OVmZl7v1GFTyXxBXxZwZjA+ETmR69vLXnJKrj5kYNyMtGAMcVlTFL9Bs5ibk3g6has4X8y2SEv0gHNLt3VtQ02YOms098CjMOwWM6pSfSeyO9FrBaxq7xk273jpomwpNstjLmNXtVY8tlGuc05Fb+Ijm7AP+35ZOVwt4yfsv8WjNqUhcYH7fIgEDh/Yt96NCaS+7bh5Fhhwhl0EZ8GUfBS/o/zZbf4+SH71Or/2zcQGg== 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=W9F+iFJWhJeKD/hEoZoclt5+uBw34Ow1+D4kZaBLOES8AkRKoTdVgXtyI5vZkNTmC8sgNpHNpW50VY88DveThqYwDk6K93C1uY6jUfhNdOXyPG/ehTetYlv85hBldtzd4LzsZpaHDb/ls8BL9x1uahGodVKmmbSrinLtkHfGYxZ/Vul4c+7Ilh1HSFkcCremFd/w1Dlxu82ZCwfu3CKkm0ORGyHIVCSTv9d9+SlVV9l1B03wAYX2ba+NmGZKwq8uCQKzy/OmtvozuLxSkkriWQzM9iUaOhO8G061RqQTU6vHJSRy57dYTGBJhiz+uZdvVqE9BKlTBFY5xqyHyK1Kig== Received: from MW4PR04CA0388.namprd04.prod.outlook.com (2603:10b6:303:81::33) by SJ2PR12MB7867.namprd12.prod.outlook.com (2603:10b6:a03:4cd::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Sun, 4 Dec 2022 14:17:00 +0000 Received: from CO1NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:303:81:cafe::77) by MW4PR04CA0388.outlook.office365.com (2603:10b6:303:81::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13 via Frontend Transport; Sun, 4 Dec 2022 14:17:00 +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 CO1NAM11FT013.mail.protection.outlook.com (10.13.174.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13 via Frontend Transport; Sun, 4 Dec 2022 14:17:00 +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; Sun, 4 Dec 2022 06:16:46 -0800 Received: from nps-server-23.mtl.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sun, 4 Dec 2022 06:16:42 -0800 From: Shay Drory To: , , CC: , , , , Subject: [PATCH net-next V3 1/8] net/mlx5: Introduce IFC bits for migratable Date: Sun, 4 Dec 2022 16:16:25 +0200 Message-ID: <20221204141632.201932-2-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221204141632.201932-1-shayd@nvidia.com> References: <20221204141632.201932-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: CO1NAM11FT013:EE_|SJ2PR12MB7867:EE_ X-MS-Office365-Filtering-Correlation-Id: a73ed285-31d5-42db-47e2-08dad6023597 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qfbzYyLtWEsJlQAQp5ZVJk3tzo8c10bLT3qPSVhLl0WA5Jqucn7C1UfRi4PwMkg46rIqmiqLq6TxfDtpK5GC5BRNxAE+14f7q2qET1DwOXGeWpVs5BrWG/EKQd3loLUHzcY58i7t6kImag5UjXhpquixuk6L483KHVnnQgedjpALDsZMoPBFXSS9lShJoPnRTLFV0UoVmEGPFUmjxq/mKB1DMe/rDG8enRRwbebTCWbFJdikxYHash2V4csyDyOF/L9hO0HHLFeWZ1VX7+P9tk6TrmVgXNYjdGXDHbJU1cjTJi02pLL+gLlslQQFB4lvfTAp65e7L2BSWZOohPiXqOVVa+HZMiycevwmSxSdtLizmx4lVi5isWovAfYrUSbMqO2DQU83dPRPQ23nYxbw4goXySjhr/sVJ/vn8jdFxirpjeVHipbNPVsSA8/WBalzTYicj8M59YocavC0uo4uSY6X+0L/V7y9d+DXlBq+eO1CQSZerYZLgkcvhlJ/uvdt2srtC1fnQIUswB7ElHn1jjz0yQ7/qFkBBTpEtIWLRIY0CEu/qXCDOq7pOA3mLWaZZ1yt2XMwMmHO1dO+L7t03N9YsZONNv8z9LWI6iRa09kpKUN+dhWR87sY7EFAc9c7MykImnTB59p+zoHSrt3G7v+ABN1ZW8JW6IIn1/QFUx85cI7G/g1w/trwgdYFb4WhrvVP5vh6Ah8JKyqhsZzXVg== 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)(376002)(136003)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(40480700001)(36756003)(40460700003)(86362001)(7636003)(478600001)(26005)(107886003)(5660300002)(4326008)(41300700001)(110136005)(8676002)(6666004)(8936002)(316002)(70206006)(54906003)(2906002)(70586007)(82310400005)(36860700001)(356005)(82740400003)(83380400001)(2616005)(1076003)(16526019)(336012)(186003)(47076005)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2022 14:17:00.2013 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a73ed285-31d5-42db-47e2-08dad6023597 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: CO1NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7867 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 Sun Dec 4 14:16:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13063872 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 03A8EC4321E for ; Sun, 4 Dec 2022 14:17:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230116AbiLDORD (ORCPT ); Sun, 4 Dec 2022 09:17:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230108AbiLDOQ7 (ORCPT ); Sun, 4 Dec 2022 09:16:59 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2040.outbound.protection.outlook.com [40.107.243.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 793181741B for ; Sun, 4 Dec 2022 06:16:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jFABqyuJ4NKOr4XNc1tEO/i20n5HODhlJeI54dGPz1NCP5GXIAouhwFv6+INjbfY68/NfQ6Fgl3niVi6r++gu2j33Nep72XyDtnFHQlTaS85yx0KUhmmisb7O6ObqhTdghBNCVz3rYwsMyzgMao0EP2lCsGSgheqH8xgDZ+W1hp3/XO6LR0rOCj4sqv73dextm/xRCwvL1VFWNmELhtwNDvahj/dmlfG65c+NrEVVk5cxuYfNNvZYyFoqTa1dt5gj8vhyPwjOcZZvChshxGfmVTmiD3cD+m3pEfLCIpr5augdX7TvL5zPuOdatoqeNJVAWP4gvN4c9WbbaoiGqgyZQ== 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=GhDlb8jL8S94Uay1+/DxuoQBvdivmilavc+TsBlhFLo=; b=ZrRl4/u9ovB/ntejoZ5BNivSzBri56rG2N4J/UwcoVW15BBaaiEcpkWkyhAWnbKDPGmvT/cv86ukRPSuWu/rpL+/BzX7lPUNA13Bph2rm98hJ0t54lbjG89FQFdegzgnoHdJNQQNSiGINx6tkMT+TZ+mw5GIul7SPd4lyjRLLM7UQxGzM4QTdEYCT17YpIhyaNp/0g9muTUQ5QERTe/N+ogXmeFdGDQHt0fB9Tc1gq0XVLNy9M5ZmaMqY+yAO8C0uZgGwqbQXYg7eZrt53MalBZWqALSAIsI4ZaO75eThCr44+UVe4D7Q6noCCCYSeHa/JfitM7cEQGdIPqUEREh6w== 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=GhDlb8jL8S94Uay1+/DxuoQBvdivmilavc+TsBlhFLo=; b=OUXprYVOqBiL/HqaS0arH09r6/hqqyC6k/YsIu2KbERs0fy5xtzKVeb7V+J7dAjdEEHahSrjZP8O9fjigjUwYp5lvyC/msEcGJrl2allG8NhqC/dGdXvREKYYLx8tBsERKd5Rzt2NTOUAytEdP6Lq5GQt2jS4/1e5uachV1WDh9NeJ4eWj7Vw1L3ek43EGHQb+QcppmeZU9aYvu4thN3D2D5WJWLoMYlK7wecnVZyyl9j1DlEY8+7UL+ns6pDSakjhgPNgl/48WTmhz4DGWYsHph9HeVE7s7vF9nc+2MpJwhoJfTKNIWh5v59/5Kl228y1AeTODRhETUe6y3AXTdZw== Received: from DS7PR03CA0288.namprd03.prod.outlook.com (2603:10b6:5:3ad::23) by CH0PR12MB5089.namprd12.prod.outlook.com (2603:10b6:610:bc::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Sun, 4 Dec 2022 14:16:57 +0000 Received: from DM6NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ad:cafe::d8) by DS7PR03CA0288.outlook.office365.com (2603:10b6:5:3ad::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13 via Frontend Transport; Sun, 4 Dec 2022 14:16:57 +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 DM6NAM11FT018.mail.protection.outlook.com (10.13.172.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13 via Frontend Transport; Sun, 4 Dec 2022 14:16: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; Sun, 4 Dec 2022 06:16: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; Sun, 4 Dec 2022 06:16:46 -0800 From: Shay Drory To: , , CC: , , , , , Shay Drory Subject: [PATCH net-next V3 2/8] devlink: Validate port function request Date: Sun, 4 Dec 2022 16:16:26 +0200 Message-ID: <20221204141632.201932-3-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221204141632.201932-1-shayd@nvidia.com> References: <20221204141632.201932-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: DM6NAM11FT018:EE_|CH0PR12MB5089:EE_ X-MS-Office365-Filtering-Correlation-Id: 25bd8e70-f7c9-444b-972f-08dad6023390 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vXxq6dBneXONcEgNJbJuVcd8dIJ/4F+KmvV/8sQ+7sF+zgxdXyFw5AIx8+MBfMwQYlsMSNb8ApkWL2WDhvo/6TNJ5PGC4J2plkA3ta195ZWXi7rKjhzIjZGTg2YJvBzyxbnnio2pzCKgjY0TQ3Rv8tM0KH0qKiiDPBEA7IxaRK40WO13Ud2CQN227ZmrQNsG615yeZDJ2sDTN7F6HONeSKE+0hUKQFI9tUr/HIPv+xjXuC8Vk0+NFPprn4bm0mgbuOqiHcZoj65E3qEKVw2ZGzYUUSjxEOjaqS9Ibav0AE/FmQopyIVkDZHWtajr7760fSag/rJ7YDhdYAvzj+ESb5BaBZ1fPJ62agUfqbNkgn3cZFwBvnfYnD83WZTNAAlr182leKiE7AY03Yixw9KsdRafrvNRrouLJ9PC4oIAPlsJEV/PpduRyJAxCG2lIrBX4/1d1rCnvFjUN6K7OQziVSEX77xoWKrkkgWSRA0Ccu1ig1zMNJvfJtMICzbP1YpTu4ejc1MCbtZz9yVeRWZS+uSoEALRDXE0PSGONMGVuVxi1eQLYlRkj9/mliETivdvu0IBF7Jbe1B67OwABqkooFDwP3C/HGiZaIrWOzLLTHXVMPbRwzUUJm53B1jZCU1ufxAl/Ohegu5ZGCyGl6IGy2diKzidTWJrQYQaR0BHSx7YCi2/kI+sNcSE2bVcOloaMrjYJRU/Bx1E6yrlb0vzaw== 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)(376002)(346002)(396003)(39860400002)(451199015)(36840700001)(46966006)(40470700004)(426003)(47076005)(478600001)(86362001)(40460700003)(356005)(7636003)(40480700001)(36756003)(82740400003)(26005)(36860700001)(83380400001)(2616005)(16526019)(1076003)(336012)(186003)(82310400005)(8676002)(5660300002)(41300700001)(107886003)(15650500001)(6666004)(70586007)(4326008)(110136005)(70206006)(316002)(8936002)(54906003)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2022 14:16:56.8176 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 25bd8e70-f7c9-444b-972f-08dad6023390 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: DM6NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5089 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 --- v2->v3: - replace NL_SET_ERR_MSG_MOD with NL_SET_ERR_MSG_ATTR --- net/core/devlink.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index fca3ebee97b0..2b6e11277837 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,27 @@ static int devlink_port_fn_state_set(struct devlink_port *port, state = nla_get_u8(attr); ops = port->devlink->ops; - if (!ops->port_fn_state_set) { - NL_SET_ERR_MSG_MOD(extack, - "Function does not support state setting"); + return ops->port_fn_state_set(port, state, extack); +} + +static int devlink_port_function_validate(struct devlink_port *devlink_port, + struct nlattr **tb, + struct netlink_ext_ack *extack) +{ + const struct devlink_ops *ops = devlink_port->devlink->ops; + + if (tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR] && + !ops->port_function_hw_addr_set) { + NL_SET_ERR_MSG_ATTR(extack, tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR], + "Port doesn't support function attributes"); return -EOPNOTSUPP; } - return ops->port_fn_state_set(port, state, extack); + if (tb[DEVLINK_PORT_FN_ATTR_STATE] && !ops->port_fn_state_set) { + NL_SET_ERR_MSG_ATTR(extack, tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR], + "Function does not support state setting"); + return -EOPNOTSUPP; + } + return 0; } static int devlink_port_function_set(struct devlink_port *port, @@ -1684,6 +1694,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 Sun Dec 4 14:16:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13063873 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 B1D19C4321E for ; Sun, 4 Dec 2022 14:17:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230117AbiLDORM (ORCPT ); Sun, 4 Dec 2022 09:17:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230114AbiLDORC (ORCPT ); Sun, 4 Dec 2022 09:17:02 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2065.outbound.protection.outlook.com [40.107.243.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42AE715FE0 for ; Sun, 4 Dec 2022 06:17:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ecOdcWbSc2EGnNNPx8TJnrXbXmbALMsLnp+NNrkzG2HYucEcxKu9IbEhpwtLlp4dd9U08iT45ZOxKpiegtsrSG7oX/QgfRe0oy9QoNhN3Ad8c3SsURs5IUzQSotjRxlM7fi2S0rY3lQ4PzDb6MYq6hbS8j65zMfV3ABPweBtXNlZF9S3iTnVcAM6qff2UyPm/BIQ9B/Uh0Mbdry/2zBdlmUCwHGiln3RCfe3HHPA9HMv4AF3fKHWn82OvNk7xKmErjkLNyVnNfgKRtM8UntYvqQWwTn6Ys4bk2zhAHOamlVgMl3BoGWZJM4i21i/sk70WYLi+frTg5mLJ0ny1J0lzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eyoKRFtcXRa9rAoJOTbpVBI3U6fZeK8XoRhc+Ac85Ak=; b=KpfyaWdngZ7hT/6ZOfl6jzN7Jw/78bS/TGRQeZ1B4svoqs8YwRn6B4G4KuflOPKPGpKlHf1VEEjGTvwEcGYt/Fa14DkBNHVt/3Ot6HCx8Q/eknw2laeQExxGS5tgFkEAljHKGFY+2oz9qpmxnj53vNP3zTQrq/jOILjGisOPoyhb8/JQnlW2C7yaxS1z+D9x4HM8o/OfOrLbWGGb1p6PGjcgG9eU85OtHd4cYsJnZJA4LWGNtlug+S4dWy7niH1S47m8ZimemtRrhMQDSMy65l6QoK8BTiTHLGTHpiihUkBx9JPy2WqNdmlEKHbG1ijT4Ew5S+xFiDW7dTTH/F1Leg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eyoKRFtcXRa9rAoJOTbpVBI3U6fZeK8XoRhc+Ac85Ak=; b=DegxGrhcDI11RFbQf7qlK0TECd0eartxecU4txfABrgIip87aK5aILK36vTt/5zl1cT89zQtUQPOEcLC6YtRmQ+hI2wpV/FX76e8JExyjEh77v6qsRi/ATCkL2yBxcirL6PJ76YCB1NZVVXJe12I79+LsnZ5H/6coJGoTNxJSVKoYWTA7H3xY/y5wO15xz408qdyjw3/QHyp+DyuvjDmHQjtR34KheVlpfEg/CvoP2bSSLFJT/20TqGr79IUWTYOTyLaTAG7Zh9b0kx+ykQM3nnYObTbxYfIn1j/b8FbBGcfPfheXFjZqj6cAxiePt4CUVEF/SLkklkcmrnH824iNg== Received: from DS7PR03CA0275.namprd03.prod.outlook.com (2603:10b6:5:3ad::10) by MN2PR12MB4358.namprd12.prod.outlook.com (2603:10b6:208:24f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Sun, 4 Dec 2022 14:16:59 +0000 Received: from DM6NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ad:cafe::f) 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.13 via Frontend Transport; Sun, 4 Dec 2022 14:16:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT018.mail.protection.outlook.com (10.13.172.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13 via Frontend Transport; Sun, 4 Dec 2022 14:16:59 +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; Sun, 4 Dec 2022 06:16: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; Sun, 4 Dec 2022 06:16:49 -0800 From: Shay Drory To: , , CC: , , , , , Shay Drory Subject: [PATCH net-next V3 3/8] devlink: Move devlink port function hw_addr attr documentation Date: Sun, 4 Dec 2022 16:16:27 +0200 Message-ID: <20221204141632.201932-4-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221204141632.201932-1-shayd@nvidia.com> References: <20221204141632.201932-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: DM6NAM11FT018:EE_|MN2PR12MB4358:EE_ X-MS-Office365-Filtering-Correlation-Id: bb97196f-4fb0-4bca-0589-08dad602350e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GW4Cj4mkmMfX43tBHyyX9mpJ1vnVGz7RjVwChazQUcvZqr1zEDyEULcEqgdm9+1MzMLZwUu+OG8kIhdWzK2yELyPhW0RXsvdARmHAeHyi92iJ9NY9uy1FdEPgBGnO61HwdRH0O2E9sLYizqahvtlq4L0z3WlBIvmkFLEAL4AULp9Ymq3vcJbRqtCY0Q9oZ2aw6Sc1y5N6XpC3KK+b/aCRIImgXvA31+Ae5XVyDSxKoMehGGQr7nly1woFOP+sg30CdPs5S9Q2KDKUNN42/g/j3vlX6Qwo8FaaJhBchAjyBPEcO5v4pvigozvgGupA5KjFb/+eGC4F7rbfIRKHjF7Mfr4VyN/+/IeFoD/XZZiApBshECN0Fuh1YSMBqoAVH3nMWuy9yQ3EpWaZZHf/0dZeNTSiegFKUEdj9xp7xbPa2usI7smU9ajelHwe9n3oGgqiP/IwzioffHMr5MlKp6D7kzcJqSsqmvvjA2CxeULwjifwAsd5mBVlGIUGdSKKNWDQ81ESwOh4ZWIdPLXkpZjZFl/NSUp+O6R2J93E7KFDaq+PC8HU0mvWdTpFIN3qzG7VxUYnuP+WMY2H70iRi+pdik/pzrBbKRvOqrc7dnLUyVzYXDpbDhgKRzY0giunkDmx4ztRQwJ3NaQDkZn3w2LpF3JcdmnNpbKIu6zL2Ai6sGylYH0mPyhWKYmgWn3BfED6xL/Iu61CQQOWzJQAGQTUQ== 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)(346002)(39860400002)(396003)(376002)(451199015)(40470700004)(36840700001)(46966006)(82310400005)(36756003)(40480700001)(47076005)(316002)(426003)(83380400001)(26005)(1076003)(186003)(54906003)(107886003)(6666004)(110136005)(86362001)(2906002)(70586007)(70206006)(36860700001)(4326008)(8676002)(336012)(356005)(40460700003)(7636003)(82740400003)(16526019)(478600001)(2616005)(41300700001)(8936002)(5660300002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2022 14:16:59.3017 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb97196f-4fb0-4bca-0589-08dad602350e 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: DM6NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4358 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org devlink port function hw_addr attr documentation is in mlx5 specific file while there is nothing mlx5 specific about it. Move it to devlink-port.rst. Signed-off-by: Shay Drory Reviewed-by: Jiri Pirko --- .../device_drivers/ethernet/mellanox/mlx5.rst | 38 +---------------- .../networking/devlink/devlink-port.rst | 42 ++++++++++++++++++- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst b/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst index e8fa7ac9e6b1..07cfc1b07db3 100644 --- a/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst +++ b/Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst @@ -351,42 +351,8 @@ driver. MAC address setup ----------------- -mlx5 driver provides mechanism to setup the MAC address of the PCI VF/SF. - -The configured MAC address of the PCI VF/SF will be used by netdevice and rdma -device created for the PCI VF/SF. - -- Get the MAC address of the VF identified by its unique devlink port index:: - - $ devlink port show pci/0000:06:00.0/2 - pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 - function: - hw_addr 00:00:00:00:00:00 - -- Set the MAC address of the VF identified by its unique devlink port index:: - - $ devlink port function set pci/0000:06:00.0/2 hw_addr 00:11:22:33:44:55 - - $ devlink port show pci/0000:06:00.0/2 - pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 - function: - hw_addr 00:11:22:33:44:55 - -- Get the MAC address of the SF identified by its unique devlink port index:: - - $ devlink port show pci/0000:06:00.0/32768 - pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88 - function: - hw_addr 00:00:00:00:00:00 - -- Set the MAC address of the SF identified by its unique devlink port index:: - - $ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 - - $ devlink port show pci/0000:06:00.0/32768 - pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88 - function: - hw_addr 00:00:00:00:88:88 +mlx5 driver support devlink port function attr mechanism to setup MAC +address. (refer to Documentation/networking/devlink/devlink-port.rst) SF state setup -------------- diff --git a/Documentation/networking/devlink/devlink-port.rst b/Documentation/networking/devlink/devlink-port.rst index 98557c2ab1c1..2c637f4aae8e 100644 --- a/Documentation/networking/devlink/devlink-port.rst +++ b/Documentation/networking/devlink/devlink-port.rst @@ -119,9 +119,49 @@ function device to the driver. For subfunctions, this means user should configure port function attribute before activating the port function. A user may set the hardware address of the function using -'devlink port function set hw_addr' command. For Ethernet port function +`devlink port function set hw_addr` command. For Ethernet port function this means a MAC address. +Function attributes +=================== + +MAC address setup +----------------- +The configured MAC address of the PCI VF/SF will be used by netdevice and rdma +device created for the PCI VF/SF. + +- Get the MAC address of the VF identified by its unique devlink port index:: + + $ devlink port show pci/0000:06:00.0/2 + pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 + function: + hw_addr 00:00:00:00:00:00 + +- Set the MAC address of the VF identified by its unique devlink port index:: + + $ devlink port function set pci/0000:06:00.0/2 hw_addr 00:11:22:33:44:55 + + $ devlink port show pci/0000:06:00.0/2 + pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 + function: + hw_addr 00:11:22:33:44:55 + +- Get the MAC address of the SF identified by its unique devlink port index:: + + $ devlink port show pci/0000:06:00.0/32768 + pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88 + function: + hw_addr 00:00:00:00:00:00 + +- Set the MAC address of the SF identified by its unique devlink port index:: + + $ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 + + $ devlink port show pci/0000:06:00.0/32768 + pci/0000:06:00.0/32768: type eth netdev enp6s0pf0sf88 flavour pcisf pfnum 0 sfnum 88 + function: + hw_addr 00:00:00:00:88:88 + Subfunction ============ From patchwork Sun Dec 4 14:16:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13063875 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 06566C4708D for ; Sun, 4 Dec 2022 14:17:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230115AbiLDORP (ORCPT ); Sun, 4 Dec 2022 09:17:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230122AbiLDORE (ORCPT ); Sun, 4 Dec 2022 09:17:04 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2067.outbound.protection.outlook.com [40.107.223.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F4001741A for ; Sun, 4 Dec 2022 06:17:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GLPe9DbzG+Dg1u2xKbQtv3eXEWIQcEwcNhQeYYdE8zAjtbHroHcA0gVVHIqgye4riuPiMAQs/skaPDmHL2yqg7kFLPuXDxL0D65AFlcpuBDjA0EC+fuQUvbmxP7JbVQFehCAyxvyKojTTXgF9K1oLxHcWoax61OwPqbZ64t9nyU1y33JOn3AF9IXyK9nDdHqJZOlqY84ziYO3Q2zqCa3bLChoVUNe+2QCgwcFe3LQ/OvfnM1Gu1xZXyxqLH+X/YREwxwg4Z1HmxDG5Q7cCEx8RSmhtSY5w2iVFSB4fyUKkFN5uBE2mGCA41o60egz4BXi+DTlohuKNsGLbqjLXLYWg== 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=6+0ub8Y60/IvhYN8EY32hTLsVvQva2YYjsQ2fqyozzw=; b=FzHWamz+9pLSLkbZU0b62adjxly3S7o8dPcoiTsTQioP6BxOsfxALkF0Co76Ur57sRt+YIj6ezmnpPBLbzXldByphWm7mi2XFedRRPAdfikJVTGwP0/uxwNu+T/Esd9Of5xs0iPRrNM3Zk+dREPhQVZYa+GGvSJoALH5wYLnioAfOkKuLDWnRZp4z6yhzWQJkSaILInTYaOfT11+sIzcrdiKNVSFVpd58fM+RpCdonMUW5CXfBHzW71Y2FkDvs0Bw19jn9X3horZ+1Nb2A3uT2T51422jZ0jQ/dys/dU40FqZFC8UlwpsIHcFgi9UENdgN8qeaRGA7NaKRYrelCO0w== 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=6+0ub8Y60/IvhYN8EY32hTLsVvQva2YYjsQ2fqyozzw=; b=BDXWYrUbnrDnV7IWfYsA4AqUICcGJ5E1tlARXgGOSowqvG6MCruoCUgQiT81m0mcdUduUWi4KXtWR3j/EFCRUYBYyOrFTEXRtuTkiLfueDcZchB5Q91iw1SQuXdqeFolOFirvg/SsDf64vkWywpYWJUrWChrtAhYaqlLQqGrAl1/ygJJTzS43HZGEzQdXseen1tssowUiTU7KPUZ8gGekZDTK/BhHeUaPo/vjPuxecMGwyGHkEXOj2ln+51WLpMCX1pZqFVPZzJ+oiZLF4+j11OybGGFsnsRVHiuzsCPgfChTDmXFEtQY277qCIDsdL7MqIfuz9Pxv5xKuVsIv/nkg== Received: from DS7PR03CA0292.namprd03.prod.outlook.com (2603:10b6:5:3ad::27) by DM4PR12MB5375.namprd12.prod.outlook.com (2603:10b6:5:389::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Sun, 4 Dec 2022 14:17:01 +0000 Received: from DM6NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ad:cafe::62) by DS7PR03CA0292.outlook.office365.com (2603:10b6:5:3ad::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13 via Frontend Transport; Sun, 4 Dec 2022 14:17:01 +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 DM6NAM11FT018.mail.protection.outlook.com (10.13.172.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13 via Frontend Transport; Sun, 4 Dec 2022 14:17:01 +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; Sun, 4 Dec 2022 06:16:55 -0800 Received: from nps-server-23.mtl.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sun, 4 Dec 2022 06:16:51 -0800 From: Shay Drory To: , , CC: , , , , , Shay Drory Subject: [PATCH net-next V3 4/8] devlink: Expose port function commands to control RoCE Date: Sun, 4 Dec 2022 16:16:28 +0200 Message-ID: <20221204141632.201932-5-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221204141632.201932-1-shayd@nvidia.com> References: <20221204141632.201932-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: DM6NAM11FT018:EE_|DM4PR12MB5375:EE_ X-MS-Office365-Filtering-Correlation-Id: 9012b1f9-8900-4da0-03c0-08dad6023638 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dyZ9TnAVhlXMjJoCbnYFlhJylohQcNVA/P1GHNfXU4OBeYYJot3lE7dRqVK3UjU47WonzRTZHDDJkYhXLMzlTVMd7T+4uDk9Bn5X6HceRGo5Y52AMUgfiwuuJcqJa7h4zoBk8I914RmbKXlyJt3zQ0SNPotgY9/sKB+Yx8enOaKp5H4VV6EA4kohkHqpIjYy/7QafhG1WuK4mmuC1q0OY6D8jAYf13xQMwWYh0/1dx1HgppG/OWbQI3Qdt4ieaOKQnGIc698VcAzFR/cVMmxhHbOFbDZZDTmR1zEJygxG5qHDkLsZHdP+Zk4S+BnCWAPIpYrpwuAa7PW2NvgO1tzTgZq5sy9ufk1RiZYTLJAR2oCB16hwPRD+jcjNME2ABlhBGIhF35+nFdUU0EAoJd7aM3MtIGAJiEpISTl3sOugFx7A2TOEHovpO+Ue2MbC1XTtijXjF/DNhLEfIzDhqXMnoi1NVnegD5nJNjjcmXEC7RAvQGYMU8CncyqgKx7i//qLVUUX378epnW1rFIX3Suo/ZjUx/k6C5pm9k0plhlBojAnqDzGcAV4Ty8smi7F0+Wo1IQQGlqOzKwljcOl45sSwqr80rPEBCb1unRKGi3c8vpEUYSVSGvUBEQTCseUtgAGN9C3JvfuCWrObQLPxt5WZXujHHa4Xg1+J/A9qS/XUoMtLuWj9aWGcxEH+E35snkaqkPctfyj8ClP6XkN++KZw== 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)(396003)(136003)(376002)(346002)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(40480700001)(36756003)(86362001)(40460700003)(478600001)(82310400005)(26005)(36860700001)(186003)(30864003)(107886003)(6666004)(5660300002)(8676002)(4326008)(316002)(8936002)(41300700001)(54906003)(110136005)(2906002)(70206006)(70586007)(82740400003)(7636003)(356005)(1076003)(2616005)(336012)(16526019)(83380400001)(47076005)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2022 14:17:01.2859 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9012b1f9-8900-4da0-03c0-08dad6023638 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: DM6NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5375 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 Reviewed-by: Jiri Pirko --- v2->v3: - change DEVLINK_PORT_FN_SET_CAP to devlink_port_fn_cap_fill. - move out DEVLINK_PORT_FN_CAPS_VALID_MASK from UAPI. - introduce DEVLINK_PORT_FN_CAP_ROCE and add _BIT suffix to devlink_port_fn_attr_cap. - remove DEVLINK_PORT_FN_ATTR_CAPS_MAX --- .../networking/devlink/devlink-port.rst | 34 +++++- include/net/devlink.h | 19 +++ include/uapi/linux/devlink.h | 10 ++ net/core/devlink.c | 113 ++++++++++++++++++ 4 files changed, 175 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/devlink/devlink-port.rst b/Documentation/networking/devlink/devlink-port.rst index 2c637f4aae8e..c3302d23e480 100644 --- a/Documentation/networking/devlink/devlink-port.rst +++ b/Documentation/networking/devlink/devlink-port.rst @@ -110,7 +110,7 @@ devlink ports for both the controllers. Function configuration ====================== -A user can configure the function attribute before enumerating the PCI +Users can configure one or more function attributes before enumerating the PCI function. Usually it means, user should configure function attribute before a bus specific device for the function is created. However, when SRIOV is enabled, virtual function devices are created on the PCI bus. @@ -122,6 +122,9 @@ A user may set the hardware address of the function using `devlink port function set hw_addr` command. For Ethernet port function this means a MAC address. +Users may also set the RoCE capability of the function using +`devlink port function set roce` command. + Function attributes =================== @@ -162,6 +165,35 @@ device created for the PCI VF/SF. function: hw_addr 00:00:00:00:88:88 +RoCE capability setup +--------------------- +Not all PCI VFs/SFs require RoCE capability. + +When RoCE capability is disabled, it saves system memory per PCI VF/SF. + +When user disables RoCE capability for a VF/SF, user application cannot send or +receive any RoCE packets through this VF/SF and RoCE GID table for this PCI +will be empty. + +When RoCE capability is disabled in the device using port function attribute, +VF/SF driver cannot override it. + +- Get RoCE capability of the VF device:: + + $ devlink port show pci/0000:06:00.0/2 + pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 + function: + hw_addr 00:00:00:00:00:00 roce enable + +- Set RoCE capability of the VF device:: + + $ devlink port function set pci/0000:06:00.0/2 roce disable + + $ devlink port show pci/0000:06:00.0/2 + pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 + function: + hw_addr 00:00:00:00:00:00 roce disable + Subfunction ============ diff --git a/include/net/devlink.h b/include/net/devlink.h index 5f6eca5e4a40..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..6cc2925bd478 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -658,11 +658,21 @@ enum devlink_resource_unit { DEVLINK_RESOURCE_UNIT_ENTRY, }; +enum devlink_port_fn_attr_cap { + DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT, + + /* Add new caps above */ + __DEVLINK_PORT_FN_ATTR_CAPS_MAX, +}; + +#define DEVLINK_PORT_FN_CAP_ROCE _BITUL(DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT) + enum devlink_port_function_attr { DEVLINK_PORT_FUNCTION_ATTR_UNSPEC, DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR, /* binary */ DEVLINK_PORT_FN_ATTR_STATE, /* u8 */ DEVLINK_PORT_FN_ATTR_OPSTATE, /* u8 */ + DEVLINK_PORT_FN_ATTR_CAPS, /* bitfield32 */ __DEVLINK_PORT_FUNCTION_ATTR_MAX, DEVLINK_PORT_FUNCTION_ATTR_MAX = __DEVLINK_PORT_FUNCTION_ATTR_MAX - 1 diff --git a/net/core/devlink.c b/net/core/devlink.c index 2b6e11277837..5c4d3abd7677 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -195,11 +195,16 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(devlink_hwmsg); EXPORT_TRACEPOINT_SYMBOL_GPL(devlink_hwerr); EXPORT_TRACEPOINT_SYMBOL_GPL(devlink_trap_report); +#define DEVLINK_PORT_FN_CAPS_VALID_MASK \ + (_BITUL(__DEVLINK_PORT_FN_ATTR_CAPS_MAX) - 1) + static const struct nla_policy devlink_function_nl_policy[DEVLINK_PORT_FUNCTION_ATTR_MAX + 1] = { [DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR] = { .type = NLA_BINARY }, [DEVLINK_PORT_FN_ATTR_STATE] = NLA_POLICY_RANGE(NLA_U8, DEVLINK_PORT_FN_STATE_INACTIVE, DEVLINK_PORT_FN_STATE_ACTIVE), + [DEVLINK_PORT_FN_ATTR_CAPS] = + NLA_POLICY_BITFIELD32(DEVLINK_PORT_FN_CAPS_VALID_MASK), }; static const struct nla_policy devlink_selftest_nl_policy[DEVLINK_ATTR_SELFTEST_ID_MAX + 1] = { @@ -692,6 +697,60 @@ devlink_sb_tc_index_get_from_attrs(struct devlink_sb *devlink_sb, return 0; } +static void devlink_port_fn_cap_fill(struct nla_bitfield32 *caps, + u32 cap, bool is_enable) +{ + caps->selector |= cap; + if (is_enable) + caps->value |= cap; +} + +static int devlink_port_fn_roce_fill(const struct devlink_ops *ops, + struct devlink_port *devlink_port, + struct nla_bitfield32 *caps, + struct netlink_ext_ack *extack) +{ + bool is_enable; + int err; + + if (!ops->port_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_cap_fill(caps, DEVLINK_PORT_FN_CAP_ROCE, is_enable); + return 0; +} + +static int devlink_port_fn_caps_fill(const struct devlink_ops *ops, + struct devlink_port *devlink_port, + struct sk_buff *msg, + struct netlink_ext_ack *extack, + bool *msg_updated) +{ + struct nla_bitfield32 caps = {}; + int err; + + err = devlink_port_fn_roce_fill(ops, devlink_port, &caps, extack); + if (err) + return err; + + if (!caps.selector) + return 0; + err = nla_put_bitfield32(msg, DEVLINK_PORT_FN_ATTR_CAPS, caps.value, + caps.selector); + if (err) + return err; + + *msg_updated = true; + return 0; +} + static int devlink_sb_tc_index_get_from_info(struct devlink_sb *devlink_sb, struct genl_info *info, @@ -1275,6 +1334,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 +1381,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 +1757,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) { @@ -1677,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; } @@ -1704,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 Sun Dec 4 14:16:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13063876 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 7CC71C4321E for ; Sun, 4 Dec 2022 14:17:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230200AbiLDORc (ORCPT ); Sun, 4 Dec 2022 09:17:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230123AbiLDORN (ORCPT ); Sun, 4 Dec 2022 09:17:13 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2065.outbound.protection.outlook.com [40.107.94.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8872615A3F for ; Sun, 4 Dec 2022 06:17:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FzU6efulUaVESeKoEQXDQmggarhep1ec444CKtMBbR1Hf0bcJ9gnM2kFrOK91EaIzHGlQ3qDrdsy+W09tDx4by33mbI0AIKA+W1C11tuPdpa71fKsAP+OkpgVQwCks0HLGbpSySycnj17rWqAqCCK9LLbsECW9IzZvmS5XQMMdHZSNWAEIfMWohhPFGLm8Jf1WUe2s4okSw31AJatMHeJk4u/axC+fcxJ6gYcANu2So40Y4UyP0SdtAfO85KAB3vXxIsl6y3Y85y4fUlb9QTRBXvhD5vqRYTuXqORpLZ5b9/FgbanM/HfOe56YYLxLD2j3DMjTgVk4uOUG7hfbKO+g== 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=Cl0tfMgCjk4SII78T0mhK23fEaqkXEhEDkXu/RabIFCLp+HF/O9yq70WhD01ox+sxAKx7Pc1SaFjDks9lajiOLkf0UBdbANvo5aFf1+PyKVsTLCTJjn8zj/4YHa1FfkWdkz0cYjQCPze2uCXDQDX5S6I6k97+LHzDjYBZqQurgm1Yt1T/2KuxtgSkyxxcPXdyKj68DJMwMx8Z5ib2Tcm6z5M5Ig9lLhpf7fijt6Spkp/cJEo/a9TObbW9RcCBFgCguvrAtiHm2nz1Thuzt2XO1wOHthb9/P10id8TSavEXOXKjUuC8tXlbft2o/idc5Mu1knzKcge8LZj9nvihGOgQ== 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=qXr1jEd66S007qgvs1TkJOlAZxpix6qcG4dezthwF4E=; b=NpedefzA+vLlVkLeuxQtuxiPbW7HiZ75TVEUQcnk9KSLTsK6uoQRIQZPdnPHWpJR2CAgDCQEVsOsgdBKfPwOMhxnLQx67p4an3dn7nxqUaUY3mKG+gemNUOSsCWBPQXNxHMVA3yLs7I7nFXBnFmGw0jmHY4YrGuI2s+cxvFfAsjHPeJ2emTrqkYauwMoVTmTCWJo3xcWKSzcBGi+85shZ4TS2GVY9d4/ug0T7ht5LCg/w0pQMKRklIluNPHG1R1dPxTeRS2eckmxssJ0BD/twE3rYvlVXb3IBKXXg1brM5ua/V+snw6bMJqVjLXh823irxVlf9ZgEKUCF+1zdiSW2Q== Received: from MW4PR04CA0381.namprd04.prod.outlook.com (2603:10b6:303:81::26) by CY8PR12MB7266.namprd12.prod.outlook.com (2603:10b6:930:56::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Sun, 4 Dec 2022 14:17:11 +0000 Received: from CO1NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:303:81:cafe::e7) by MW4PR04CA0381.outlook.office365.com (2603:10b6:303:81::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13 via Frontend Transport; Sun, 4 Dec 2022 14:17:11 +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 CO1NAM11FT013.mail.protection.outlook.com (10.13.174.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13 via Frontend Transport; Sun, 4 Dec 2022 14:17:11 +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; Sun, 4 Dec 2022 06:16: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; Sun, 4 Dec 2022 06:16:55 -0800 From: Shay Drory To: , , CC: , , , , , Shay Drory Subject: [PATCH net-next V3 5/8] net/mlx5: Add generic getters for other functions caps Date: Sun, 4 Dec 2022 16:16:29 +0200 Message-ID: <20221204141632.201932-6-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221204141632.201932-1-shayd@nvidia.com> References: <20221204141632.201932-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: CO1NAM11FT013:EE_|CY8PR12MB7266:EE_ X-MS-Office365-Filtering-Correlation-Id: 2b0fc596-7f0a-497d-2b50-08dad6023c0b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EhSO5SHcQTVaFujlgGvV8l5IypuQ2rbgW22qnxD6iO47udYO9Cw9HxJ7N+zsdy5yVY0Fi6e9F+/7ffRXnC9j9+RF6OHQCWG922/nKMvGeXTF7BUGiUvxKEWrCyBGyOX/tfjqRDFzk1+g8ii3t82jnhc7ZGmySNlygqY9qJE7tfzrQ8SfPGx/IWhcApGUiBqkteaakuCYwFwYQciv7s/bYQxoKWOlbn1vNmAGFcGadKpGFn7JKKCG0AoxsaVqxPNWT3+cf5N7LIctnHJ3ix+86M4cjravK6IQo4Ko/JZKBmZjXpjOe92At+6ELvNmpNe/L1xz3wgeWo+HKEpNTXuwlU8e+ammPUp8xd4tg6WgqeUA5DIdvmGc3kYM888tpUVBdpLevt4Jfum66ADPcgiET5ZDq6P3iXFblOveMPHd0t3QuLcfkWBKqZOthWDGpo9cwag0cZld3CEmqCK83aD9QXTBLmnL/B8rdGh7oLLPXxrODWETzh8pXuLTnRrKCmH/RbquvZIIn9ETFmnCyNN0qwUb9vm03CqtCOXjzB/SOma0wz+rd3qvNIoRGqDG5UWwkK0QjLNlsQi2L2WwBJkBlj3nT0zlcmPBvpwaPctUhRFWECXM3YQciMZ4wb4EFgBS5pQSnTNEMknT6rY+/mXN68IsREYXZSB+oTlyBQVjrWarffp19IJPkaht4QFvuEKeG153i3CLz4frc273NLNdep0Ke7F9nsDfC+AH/7FrAxE= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(39860400002)(346002)(136003)(396003)(451199015)(40470700004)(36840700001)(46966006)(426003)(47076005)(40460700003)(86362001)(478600001)(7636003)(36756003)(40480700001)(356005)(82740400003)(82310400005)(36860700001)(336012)(2616005)(16526019)(1076003)(83380400001)(186003)(8936002)(41300700001)(5660300002)(4326008)(8676002)(26005)(70586007)(6666004)(107886003)(70206006)(110136005)(316002)(54906003)(2906002)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2022 14:17:11.0427 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2b0fc596-7f0a-497d-2b50-08dad6023c0b 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: CO1NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7266 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 Sun Dec 4 14:16:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13063878 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 E179AC4321E for ; Sun, 4 Dec 2022 14:17:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230164AbiLDORm (ORCPT ); Sun, 4 Dec 2022 09:17:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230142AbiLDOR2 (ORCPT ); Sun, 4 Dec 2022 09:17:28 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2065.outbound.protection.outlook.com [40.107.223.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84A1C178B8 for ; Sun, 4 Dec 2022 06:17:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JDWGdcusc8JFgZbUNK5B75jjkKnzxXohdtQfpgsCujTRzzaPR7Gu9WHpnTFcml1+19YoKcbZJdaHvsVBI6eHZ0Snb1GLdHUZUQ6oEp/OAg2ogcMxkuGPdsST4hqOL9CyYl7Rn95zNdrDrZ/bGVbaC+ZCfe6AQ77p4UExKsctFsvQnX5US1Mv82+qDBJHbteX/7JBCxqLg15pUNxs3JDOW0H1WY0Dei1RY8gN+bD2jy9ICbQA7I2uLHISYfit6S7Ar7Ss4gqh9ZU+YKOVr/8ItXXAtzuIevJgi4msd8dtl/6yD7evUdAKKJG0e00gQKcsA+rGCY98pe9MGWmSaAPoLA== 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=oa3dabDLwerRr3nfeEjjg/Joo+1/c5FbiU7pthm7xebFjy05KU3LDOwj9TEzULo9dCp9eC3c2olq3R85n2JQnVVPR8EBvkIUeVcghG/SVwxIiiXge9FQAEj8NP1UEUVI9YUcY9la4nXzn3TJV9yo+U1ZVvZqfrZAuAY53g4c3TpABiwkudZOMGWeA6UAgkAmyAC3LQAFIdBTLuE9zEuc+LO89f9uSLIl2jvq4j9np0ebfsoP+p1IHK1EKaISHMJWcOxEOEbkKUezcOyQPxzVm+mpO67H+n/6UvqVF6Z6MAyIbFAIFkuw47oRq1NwkY7nN1NaeLidC0xK7g8JvNnTyw== 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=cklU5gEz7jWwCwHiUYw/s1wXGXpvEgzGozGPJEn7yto=; b=QXLEeXRhO3q6f17oXbSnmgfi/xnfKcza9KjxuTYHgTcNtYRAwAlCjADt5Zh18gOst0DS9YM58tgnj4C/aG0GHg1TC1yD7MaBOoAaGlgIFjW6ls1xnR4UM28R8gn/UhLxgjgtSaPuGPB5pfDF3cP/CNwMhgoSb6DR8onfZN9JBRlX56vCfWFO4EihuG9CEo8PptqEcbmDKHsfldzaqpWg38itaQReY2n0eqcdFgafq+vWoJuYFR2gYYJsaeOFLqWCor5uJzD9/OqG1eZmWEWT2J9eapCvOumep2pQyqqD2D4ZVdZE3tFHjb6yK6uOlEZGxBc6t7XHDYPgQkZA7O8KkA== Received: from MW4PR03CA0356.namprd03.prod.outlook.com (2603:10b6:303:dc::31) by DS7PR12MB6168.namprd12.prod.outlook.com (2603:10b6:8:97::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Sun, 4 Dec 2022 14:17:14 +0000 Received: from CO1NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::6) by MW4PR03CA0356.outlook.office365.com (2603:10b6:303:dc::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13 via Frontend Transport; Sun, 4 Dec 2022 14:17:14 +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 CO1NAM11FT016.mail.protection.outlook.com (10.13.175.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13 via Frontend Transport; Sun, 4 Dec 2022 14:17:14 +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; Sun, 4 Dec 2022 06:17:00 -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; Sun, 4 Dec 2022 06:16:58 -0800 From: Shay Drory To: , , CC: , , , , , Shay Drory Subject: [PATCH net-next V3 6/8] net/mlx5: E-Switch, Implement devlink port function cmds to control RoCE Date: Sun, 4 Dec 2022 16:16:30 +0200 Message-ID: <20221204141632.201932-7-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221204141632.201932-1-shayd@nvidia.com> References: <20221204141632.201932-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: CO1NAM11FT016:EE_|DS7PR12MB6168:EE_ X-MS-Office365-Filtering-Correlation-Id: 54bc4b83-1998-459f-1830-08dad6023e07 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2b6uN3XLrADSw2FCplPnDM+VXx9NRK0s6kStGmn6gZlLzSSgf3Z4bJau0TJZ3uLwDlQYzw994A2U2CeqzbnxU4lobZ3oa+u87Ox9Mz0lVMW1yCOdkZyGn2mi/xabuqU3tulhcVRSyJc48Qrm3LdEpaYIdKHLmZOjeHEEhNRgM4su54eDsdl9ep50tt1XBihDDnmvdMx/2YYtKbUw5W/imNPB8Au8z1onGH8/a83zH8pF1zQwNL6WsciLhtEqBtYsisNxhtZ05MCKJJsXF/l8G+hei6/W8RatpzS8PW3lFzBODt6K7KHUu3Pm3g2cJdI8IiYwkOYwAMfSbQ6tqnBFsecqD8+Y5hiFsHMCZ00hOIh78WUR05yxnGfMGf+b52puzRT299iXANdL/rSrCrWi0Wu53OP8wDz5DZ6ZsEGQLtJbhUNGo5SsPZETj6oPF5lWQdDf5pnhy/QBFIfdCuME3hT/YkqH9rYKhHThybH8lkMi1/Qade0uyukRk8cfCjcZEtMa0K5oJ8+9gazGcc9WeOZFiisi+dY9gP6qbDKkeRxSvYDKDDCR4SkqlIAMsrtdSyUwGWAfKgu4257WuU9vRXK31cSEL+PSnwgyErLcjFS8dzlXRojGPF9djXqrTKV8DehlVBvJFPIHCu7jbAfgY5+nJt4Ez/dRLqy00lh3J1sOO7CM24rto1gdhESTX4Hx6VSgwFqTVUcup8zZmUKpyQ== 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)(396003)(376002)(346002)(136003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(336012)(30864003)(16526019)(86362001)(186003)(8936002)(47076005)(426003)(5660300002)(36756003)(316002)(40460700003)(110136005)(54906003)(26005)(2616005)(1076003)(41300700001)(70206006)(70586007)(40480700001)(8676002)(4326008)(36860700001)(6666004)(107886003)(2906002)(478600001)(82310400005)(83380400001)(7636003)(356005)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2022 14:17:14.3715 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54bc4b83-1998-459f-1830-08dad6023e07 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: CO1NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6168 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 Sun Dec 4 14:16:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13063877 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 CC00BC4321E for ; Sun, 4 Dec 2022 14:17:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230158AbiLDORd (ORCPT ); Sun, 4 Dec 2022 09:17:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230140AbiLDORQ (ORCPT ); Sun, 4 Dec 2022 09:17:16 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2043.outbound.protection.outlook.com [40.107.96.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D76AE164A6 for ; Sun, 4 Dec 2022 06:17:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lckGHytNEUNZme2YJ2vNo/5ULrnRlEMjat76byc3+N9dNoWcKNQOniGG2R08Lg9jNYzRY3Mv4jm4O2CZ2sDrYHnhCFfw2At3EnWYyJEYnaM+pUbgxYsB1Jw4aQUSWBjwhg8mGI3/rclnDArhsLzBqILb0qLnQs5xFy8C6opx18kF4yYEV3f8UnAsqpHa0K1GEg4LsuJhaB6tkNTom5VsOyjmUAMmvUfUmWAiYr73+FUSlRpWBE01sADZe/Zel0Z/QesRj1VgK/mwTgHACN8qkI+2R5iTYvZ0ENFUZgnK99dNRwRcWf/ZAeWodSWetuATYae2b7CWC+J6S8NsLAkKqw== 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=pRq4H9JHjLX9xcCVP+UOFQpgdcSF0cLNStTrsajMsTU=; b=CittPzPl24NMAdmTEv/fLZHZvd9r6hYL6mcN8drtn8zYzw0dkmR9xwrnI/0357VMow82A5UPCmS/5usRxqBM4Hps1CVVGuqDe4bZtOC2cVPSj0EtQmtBaiegYBt8FoqAmPtX1BdoovI9swBPbwEzlu/fbS7Lv7W7YMYb1BQ9d4dppmVpdQhqz8fl2WnaEa4T3flVl4L2LSfbsa622yDEXQFqtK8ehNknn1J6+73bErGHtp1HA8vLtQZwGCDLCCdKaRnpVetI/qJiZgjFsBDxjrbkEAvSpgcRWSh9E79bZDMONyFQQGmBRfUPhhcBFFlozN+qTFiG9A1dAS8jNPHjsw== 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=pRq4H9JHjLX9xcCVP+UOFQpgdcSF0cLNStTrsajMsTU=; b=U9EYkHslTSpkd5qjzTyKledp2GF2brozErBA7humEyB2s3D/zQ4ewOyzNJ+ucsO5qT1fn7/DNLJvF9LkKHnVdGyZIotjs69TdtbudIhYfckbhulx4+gwRnjXAzGgEtTQ9q3HSNOrc8oXoVtQZrOhi11P/XfI1jKeG57LzkSzsRrNj9M8N6+AlvisKW8AmXAUlSF4FfOohKJJnBwapc07f8wkR+xtgLI+zIE7sRZnXB6cuVsu09/8Ga/RfSxBfAhQaL30JUcd7ZJdZ+XMVJ93sAK8hgaLQqRp5XRgH4j5GVetaMANdnixvOc04FfwgTOGR0fSrPBHRxwZEbjvBLAN2w== Received: from DM6PR17CA0002.namprd17.prod.outlook.com (2603:10b6:5:1b3::15) by MN2PR12MB4485.namprd12.prod.outlook.com (2603:10b6:208:269::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Sun, 4 Dec 2022 14:17:12 +0000 Received: from DM6NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1b3:cafe::2c) by DM6PR17CA0002.outlook.office365.com (2603:10b6:5:1b3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Sun, 4 Dec 2022 14:17:12 +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 DM6NAM11FT054.mail.protection.outlook.com (10.13.173.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13 via Frontend Transport; Sun, 4 Dec 2022 14:17:12 +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; Sun, 4 Dec 2022 06:17:04 -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; Sun, 4 Dec 2022 06:17:00 -0800 From: Shay Drory To: , , CC: , , , , , Shay Drory , Shannon Nelson Subject: [PATCH net-next V3 7/8] devlink: Expose port function commands to control migratable Date: Sun, 4 Dec 2022 16:16:31 +0200 Message-ID: <20221204141632.201932-8-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221204141632.201932-1-shayd@nvidia.com> References: <20221204141632.201932-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: DM6NAM11FT054:EE_|MN2PR12MB4485:EE_ X-MS-Office365-Filtering-Correlation-Id: 8aa7c986-9c93-42e7-59e1-08dad6023ca9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wxRRffKxSs6BO+ThjMJQMQOvScyy2GQ9squfL4vQAdiNY1qBC+EAdr1YIMga/okjWVq19JM4+kGNBjsdPgHFuVU/JzhJ4q91AGmDbYvP9eckFQjVIS/ORh19/Hzvk6qI/iwSB9I6xGHlIrv2M003SthTGMw+sx5eg5VZzP3CnztJA6JZ50qKq4HIUw2AM5pXjmFvlyxEwdhjGMX3tLLSL4aQK7gzY7SvMC59p1PfrGzcPZBSU8/0CrxthhBD+0dI9tfjgUylP8f7fIIkNP8GzJXuI6j+SpsW+0ixG3rzIyrsYxXgyANpbvg9XGL/IWxErO+b/+JsJn0l+8qvfSCxxSAL2aG1o5VPhMKOcZBK/ygJqpbQgkc/VdCNfQre4bHtEfNh7TJwm7LmRdxC7qCNwVggMdl5txUZ81PUUxFTz6vdvoJS7FMmItszq6q2UigldrWPBxCtmFZ92sEibi6sA0IO1gX1wrF1x5NOAP5X3coLOHnckOFae/CcIRnExtxobg2V0gM7Lcg905zr2lPkgkdUFp3ldrxDZbl/hp4sQZ/RoT1hMG3DygyfEbGYkWvvTp32xtgNegN8K/yKUyQAmmULIcZ1s50vdk3I5KuM40oWDWI1+mOSIrlTPwsSh1KWI2bIiasi5SgEuK7/qBa8+1Kt4Sg2jWy2/OYw8Av/TW5OwpVcdWADd7tNh4zJ/F/3Zhuwv0ZfeCeu6ENNgrugRw== 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)(376002)(39860400002)(346002)(396003)(451199015)(36840700001)(46966006)(40470700004)(40480700001)(36756003)(40460700003)(86362001)(478600001)(7636003)(356005)(26005)(83380400001)(8936002)(5660300002)(41300700001)(6666004)(316002)(54906003)(110136005)(2906002)(70586007)(70206006)(4326008)(8676002)(36860700001)(82310400005)(82740400003)(2616005)(336012)(1076003)(186003)(16526019)(47076005)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2022 14:17:12.0951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8aa7c986-9c93-42e7-59e1-08dad6023ca9 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: DM6NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4485 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. Cc: Shannon Nelson Signed-off-by: Shay Drory Reviewed-by: Jiri Pirko --- v2->v3: - fix documentation warning - introduce DEVLINK_PORT_FN_CAP_MIGRATABLE v1->v2: - fix documentation warning --- .../networking/devlink/devlink-port.rst | 46 ++++++++++++++++ include/net/devlink.h | 21 +++++++ include/uapi/linux/devlink.h | 3 + net/core/devlink.c | 55 +++++++++++++++++++ 4 files changed, 125 insertions(+) diff --git a/Documentation/networking/devlink/devlink-port.rst b/Documentation/networking/devlink/devlink-port.rst index c3302d23e480..3da590953ce8 100644 --- a/Documentation/networking/devlink/devlink-port.rst +++ b/Documentation/networking/devlink/devlink-port.rst @@ -125,6 +125,9 @@ this means a MAC address. Users may also set the RoCE capability of the function using `devlink port function set roce` command. +Users may also set the function as migratable using +'devlink port function set migratable' command. + Function attributes =================== @@ -194,6 +197,49 @@ VF/SF driver cannot override it. function: hw_addr 00:00:00:00:00:00 roce disable +migratable capability setup +--------------------------- +Live migration is the process of transferring a live virtual machine +from one physical host to another without disrupting its normal +operation. + +User who want PCI VFs to be able to perform live migration need to +explicitly enable the VF migratable capability. + +When user enables migratable capability for a VF, and the HV binds the VF to VFIO driver +with migration support, the user can migrate the VM with this VF from one HV to a +different one. + +However, when migratable capability is enable, device will disable features which cannot +be migrated. Thus migratable cap can impose limitations on a VF so let the user decide. + +Example of LM with migratable function configuration: +- Get migratable capability of the VF device:: + + $ devlink port show pci/0000:06:00.0/2 + pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 + function: + hw_addr 00:00:00:00:00:00 migratable disable + +- Set migratable capability of the VF device:: + + $ devlink port function set pci/0000:06:00.0/2 migratable enable + + $ devlink port show pci/0000:06:00.0/2 + pci/0000:06:00.0/2: type eth netdev enp6s0pf0vf1 flavour pcivf pfnum 0 vfnum 1 + function: + hw_addr 00:00:00:00:00:00 migratable enable + +- Bind VF to VFIO driver with migration support:: + + $ echo > /sys/bus/pci/devices/0000:08:00.0/driver/unbind + $ echo mlx5_vfio_pci > /sys/bus/pci/devices/0000:08:00.0/driver_override + $ echo > /sys/bus/pci/devices/0000:08:00.0/driver/bind + +Attach VF to the VM. +Start the VM. +Perform live migration. + Subfunction ============ diff --git a/include/net/devlink.h b/include/net/devlink.h index 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 6cc2925bd478..3782d4219ac9 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -660,12 +660,15 @@ enum devlink_resource_unit { enum devlink_port_fn_attr_cap { DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT, + DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE_BIT, /* Add new caps above */ __DEVLINK_PORT_FN_ATTR_CAPS_MAX, }; #define DEVLINK_PORT_FN_CAP_ROCE _BITUL(DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT) +#define DEVLINK_PORT_FN_CAP_MIGRATABLE \ + _BITUL(DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE_BIT) enum devlink_port_function_attr { DEVLINK_PORT_FUNCTION_ATTR_UNSPEC, diff --git a/net/core/devlink.c b/net/core/devlink.c index 5c4d3abd7677..bf2c1d3d6df3 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -727,6 +727,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_cap_fill(caps, DEVLINK_PORT_FN_CAP_MIGRATABLE, is_enable); + return 0; +} + static int devlink_port_fn_caps_fill(const struct devlink_ops *ops, struct devlink_port *devlink_port, struct sk_buff *msg, @@ -740,6 +763,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, @@ -1334,6 +1361,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) @@ -1360,6 +1396,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,18 @@ static int devlink_port_function_validate(struct devlink_port *devlink_port, "Port doesn't support RoCE function attribute"); return -EOPNOTSUPP; } + if (caps.selector & DEVLINK_PORT_FN_CAP_MIGRATABLE) { + if (!ops->port_function_mig_set) { + NL_SET_ERR_MSG_ATTR(extack, attr, + "Port doesn't support migratable function attribute"); + return -EOPNOTSUPP; + } + if (devlink_port->attrs.flavour != DEVLINK_PORT_FLAVOUR_PCI_VF) { + NL_SET_ERR_MSG_ATTR(extack, attr, + "migratable function attribute supported for VFs only"); + return -EOPNOTSUPP; + } + } } return 0; } From patchwork Sun Dec 4 14:16:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Drori X-Patchwork-Id: 13063879 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 DF883C47089 for ; Sun, 4 Dec 2022 14:17:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230168AbiLDORn (ORCPT ); Sun, 4 Dec 2022 09:17:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230143AbiLDOR2 (ORCPT ); Sun, 4 Dec 2022 09:17:28 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2088.outbound.protection.outlook.com [40.107.92.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 914AE17A88 for ; Sun, 4 Dec 2022 06:17:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hnQY5lgeEEjmnTWTodS7x+pEUB7Qa5t99TpcMoVmLqpd8ZGS3HG9TMMMsaS6HtT5ITuW3RF2xaGtQbMQ68GAIcvuVjzDb58k3G/M7f1SVQRhMHHL6fOQlMsgoxbij5Mi8xBAII+BHObsmDxJBTPrh8m8d/aAEidavobvisiQvhszYGujheO6CQ2y6e2/ZfDQjPrhu++M7hC7HWGk6CmBOzHad9oLC7RR7SHYALBHwvv+3IQDJfpNqm7dI3ti+oRheM2v/lC0tM6gkjZuQtupYKL5tuTTu/1BeOmiLukZIBFD4NVpgOD3ZfienApZGwK9PDiMYVWQbkPlRuiOfsMWAg== 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=IdvUHqMkRPKbCd1kdurmKNu6GpnWQ57bbGifAr2puxKdGPMr9lsTLQdaEyc1NFSIotZnaUexnk8rnpcdwPnd9Y93ne7r3a0jVgWMfZM6OApexTiCXNtyEWDc6E3Gek5aus2F7cbjetJoyRVyIYFM4qO8j7jLpWMiwzidaRYaSgSRhirS9mTMWtXS9sytevFMziY4MBm4dEa3o9+yaI2FvOBGtt0NxM9yeHUYgleRQY1b8AhsyR5yl1wVq2de1VHalqmrxCm5yJxB1YIsErOXZUgZozMoeqoE/mM76RRk/X7VvXLn5AxsAkbtH8moS80vmz4yTZ9RMbSZFre/RcqzOA== 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=DqIFIT4ZtOAs+55Ds7vz7+npBJlIf5hvRD5SA9GJpl7vYLmGFTeCGuW/27JX+95W15knImaGxZsCck608xY2MC+RwPH9PBdTm3eNIvhY+dBP3jIeRQP+QkVTvKpuoXyq/+VEeDYcfsrt4Tdp5IEyuUiZ0SEhiwmHxMJzS0YCP4nntSUD23Dr1J3JYGM6I+rZfMjxXhwmzrop99T4viFh/PLslSQxfn0oHLxxo0uJiugK0sALf8m7yEeXsSxEGeb26zGKmEt3AikvetC1QMbt0bDbgONSpU+9m0G2339I43zgPEXX+CGB8bSW/u/iOXxq1bs53pIvyf6RdU+PGyeRZQ== Received: from DM6PR18CA0033.namprd18.prod.outlook.com (2603:10b6:5:15b::46) by DM6PR12MB4060.namprd12.prod.outlook.com (2603:10b6:5:216::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Sun, 4 Dec 2022 14:17:14 +0000 Received: from DM6NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b:cafe::f9) by DM6PR18CA0033.outlook.office365.com (2603:10b6:5:15b::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Sun, 4 Dec 2022 14:17:14 +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 DM6NAM11FT052.mail.protection.outlook.com (10.13.172.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13 via Frontend Transport; Sun, 4 Dec 2022 14:17:13 +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; Sun, 4 Dec 2022 06:17:06 -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; Sun, 4 Dec 2022 06:17:04 -0800 From: Shay Drory To: , , CC: , , , , , Shay Drory Subject: [PATCH net-next V3 8/8] net/mlx5: E-Switch, Implement devlink port function cmds to control migratable Date: Sun, 4 Dec 2022 16:16:32 +0200 Message-ID: <20221204141632.201932-9-shayd@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221204141632.201932-1-shayd@nvidia.com> References: <20221204141632.201932-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: DM6NAM11FT052:EE_|DM6PR12MB4060:EE_ X-MS-Office365-Filtering-Correlation-Id: 8198e737-7b4d-42a0-ac16-08dad6023dbb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WcsUYWLDQDmABrrUVlDRFR8kCIenFoI2j9eMc/XsucKOjXW0BPKwQwNYnnP6il1TetG8ukRdHaCB0vkK4pw3zCSe/I45E7JJMKOP+QQGgIvXjnk3R+ZtJ12arMpjXAaeAD/yEfMssXCHY/Mk9czWOQFWVI2RZgvMA5aWYeS0iZ3AKWjGHUtMfyjScN0dVNxKnXncu2wYAc5tAtJsN19BrFLrNcWf7v/9KHzW7aS/N4JpE3ZSxmW/ogYnhqgRZaoIsHGH0XIWH+C1MErFoF3BqEfUj3uKJkPwwhdQdnvYxtlSliSknQWPlInPP6MFR5g+xzpuecNU1KX4hdCeFQI61mD/1QaJ3zTwBoZOnS3uqWL5yg8qQMvFMaSYdb4fkxCrSUTgNuYG+KHqgyc9MZKrCl564JgYSc8s4fE16KdxyQyxNd9fNzgXFLGGBIusi3WDA5WjnNfbWbtlKJoWaRvluloh3aJnfBrg77V0vU06YVAtpREWihIdDjO4mBJ97kDt0HaHPMRgAqnTURE0Ox2t1kP9t3ZT0vk/0NCeCKDSBLlUAnfe5gDoo84DQ6j1lNtgZj4wvjit0LpT3tk+aitianCw7zggzV8SzW9TKbAe7CNFU7LPwMqXuoip+xh8s9Jkes68tuqfPvhfcqOs6bhluBgEWWmFBtgwWO9LdnZFDxcRv9bCwgL/g0nimbQWVBjwfdF07nf6YYx5NtCf5oMZOA== 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)(396003)(136003)(346002)(39860400002)(376002)(451199015)(46966006)(36840700001)(40470700004)(40480700001)(36756003)(40460700003)(86362001)(7636003)(478600001)(107886003)(70586007)(8936002)(41300700001)(4326008)(8676002)(5660300002)(6666004)(70206006)(54906003)(2906002)(110136005)(316002)(82310400005)(36860700001)(82740400003)(356005)(2616005)(336012)(26005)(83380400001)(1076003)(186003)(16526019)(47076005)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2022 14:17:13.8928 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8198e737-7b4d-42a0-ac16-08dad6023dbb 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: DM6NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4060 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) {