From patchwork Tue Aug 10 11:46:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 12428743 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 X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5FDBC4338F for ; Tue, 10 Aug 2021 11:46:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6F0C604D7 for ; Tue, 10 Aug 2021 11:46:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240203AbhHJLrD (ORCPT ); Tue, 10 Aug 2021 07:47:03 -0400 Received: from mail-bn8nam11on2072.outbound.protection.outlook.com ([40.107.236.72]:58529 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233534AbhHJLrC (ORCPT ); Tue, 10 Aug 2021 07:47:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R01P5wlsde9vnR0QhItQPJyPvFLl2rlUFNfWtr47ZHR4j1ve3n0OjgTyhx1hNKb20T98D4VcsKko3IOw2nrx5yHxr/fsJc1tm5kCb8iGvX2EpNo730GCnBmUe+6HB/pkZDQ077RMAzCfEFOGy4eIfOkjdNOCZNrUwaXCqdeyAG3lGXpV5fZGEn7Va6A3zjwrqvYAPqDNUuKekw5gULRBvkekgyeX5Y5CPPp605PEtwCMnEya7TLF335un4iXggclX+NgbTmxzv0G48QUuc501n/2WX6CRLFQOLwlLtUU9mBupAFc0KO+gQ48NA4xav54Qc6M2MNXKMwKQvEeoRsF+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-SenderADCheck; bh=ucsQipBWhfn8p1v19fYk1ba8LLdehNnjXA23LrWumeY=; b=NK9pmOAUkvoMbd54ataIfu1ZSJJ47yZ6ETmLTBomnKKRkL5YMIwYfs2UW1SZM2h8uKkkWxzgrjkPZCE5O15cJoQkrIVGcc+xnwonEDapq8BmbqCwWq+bVlYW80KyPrvKM6U2d8sdeYRfqI4xJ4sk7JOjcB2coG8td7DoFU8n/Lx6Zio1CuvErn0nhm6DsB9WfL84iWJvL1Tgqky2gUvFxJ2wgFZCdmS1pY0/I+1OiG5vZFtxjBYSahhG1MxA8K2huCm0YCOnBo1KT+pmCxn1RBBFBqkKj5s4LAoD2vGK3CbEJcUok8xsz+KSGi0+Rb0Vn+4DKwYUTGKCc4iFQ9DWug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ucsQipBWhfn8p1v19fYk1ba8LLdehNnjXA23LrWumeY=; b=CaUsHP5dQI9FuzOXS2ReCVz7KHGUp6Y8uHL6knkO1QkO51uLSeimFHo6FinB234nETrBvfJkaV5ch7vKi79mcYuTSztaagOFBMHI0aDZI5XHjdaiNFqWej8ci5BMRQ8GGrl+mPGgA1j5ecV3TbKHzVsCJR/8dtddP4Retv9nr/v6jh0t9iM6LWBdKD4f/zX5pgrAYHpRrVp5GWrSTIW1A7T8jQepuLq+BvXyLL7PwPja3wGpq8CjxBsxoZKZIn17dvDJUKR6ysnT6GQFyYyKJ8vHvp/m+htzEgaVYZzVxIhn40VleLuGXpJBOWDKlF1TlpJ9vNAaAwIBga0erd2bDA== Received: from BN9P222CA0012.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::17) by BL0PR12MB4964.namprd12.prod.outlook.com (2603:10b6:208:1c7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.14; Tue, 10 Aug 2021 11:46:39 +0000 Received: from BN8NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::cd) by BN9P222CA0012.outlook.office365.com (2603:10b6:408:10c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Tue, 10 Aug 2021 11:46:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT064.mail.protection.outlook.com (10.13.176.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4394.16 via Frontend Transport; Tue, 10 Aug 2021 11:46:39 +0000 Received: from sw-mtx-036.mtx.labs.mlnx (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 10 Aug 2021 11:46:38 +0000 From: Parav Pandit To: , , CC: Parav Pandit , Jiri Pirko , "Leon Romanovsky" Subject: [PATCH net-next 01/10] devlink: Add new "enable_eth" generic device param Date: Tue, 10 Aug 2021 14:46:11 +0300 Message-ID: <20210810114620.8397-2-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210810114620.8397-1-parav@nvidia.com> References: <20210810114620.8397-1-parav@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 280cfcbe-edd1-4224-4d1b-08d95bf48429 X-MS-TrafficTypeDiagnostic: BL0PR12MB4964: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aXU/OAudK7UusV/kVACg7qJEiNoXSowsPrkYyxZY2F2/H2y9BfWNh0PAgGlq0ybw5AHu5A7do2zvgd6oVJEpXGN/XJWoSUCBT0HQgHZGvhrnWbwcSvPMolC3SfbJadXwQNpDiaP1SHO2vzHyRiIvnZRvse9jgFVRjGSTJaFxSQpIILlcrQ78Fe+wQEF2TP47SJ84R3QyiG3EXZIq8XqpLMW55t7CTp5WG4alPe0Orio7JkaCvMbfjqt0Q68C3n2sobs+FE0nD2STugy01uG5I1UF5RQh9LAEekFBuOjgMzqpCAN9jpnu+hejkKToQmsmiDMTTzP4ZjLO0YYaZAJ+I2C+aACWBnxt7fOSLp6DVMPOQ9lgeVK7oqivLRltNXexG9ki7Wy3npkmk4lihCpks65wSqye+zTdsSy7bFpgUC/AsdHzCvelFzCh5pgNIfZyb+r3aq3dczWy5KEowpBY2sbBW5WCG3Cymqkr6lLzbBlpQWSPZD5rUitaSZSR5OzkxoCx7tZqwS0t3yJYTrO0AF8YRh02KJ7vEgPH+mpM30B3qBIJUuIAhdwcQs6kIwg/zsuaXqgnziTaYxKS925o32mfwZs68X5B12pbHt3QitnO9FGdePabVlBS+YGVUt9T9QXM9EbuDrk4Lyl5+UpseW1kNu03Ch3H806V/QVZiTUVMUtIj9GThgwUikCUyofLlMGse36loQ3rh1FoASwKk9p6pv6hHEC9RbhuXsZ/Z40= X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(396003)(346002)(376002)(136003)(39860400002)(36840700001)(46966006)(6666004)(336012)(36906005)(356005)(1076003)(54906003)(110136005)(316002)(7636003)(82740400003)(16526019)(8676002)(478600001)(186003)(26005)(8936002)(107886003)(36756003)(70206006)(83380400001)(5660300002)(36860700001)(70586007)(47076005)(2616005)(4326008)(426003)(82310400003)(2906002)(86362001)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2021 11:46:39.5064 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 280cfcbe-edd1-4224-4d1b-08d95bf48429 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4964 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add new device generic parameter to enable/disable creation of Ethernet auxiliary device and associated device functionality in the devlink instance. User who prefers to disable such functionality can disable it using below example. $ devlink dev param set pci/0000:06:00.0 \ name enable_eth value false cmode driverinit $ devlink dev reload pci/0000:06:00.0 At this point devlink instance do not create auxiliary device for the Ethernet functionality. Signed-off-by: Parav Pandit Reviewed-by: Jiri Pirko Reviewed-by: Leon Romanovsky --- Documentation/networking/devlink/devlink-params.rst | 4 ++++ include/net/devlink.h | 4 ++++ net/core/devlink.c | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/Documentation/networking/devlink/devlink-params.rst b/Documentation/networking/devlink/devlink-params.rst index 54c9f107c4b0..219c1272f2d6 100644 --- a/Documentation/networking/devlink/devlink-params.rst +++ b/Documentation/networking/devlink/devlink-params.rst @@ -97,6 +97,10 @@ own name. * - ``enable_roce`` - Boolean - Enable handling of RoCE traffic in the device. + * - ``enable_eth`` + - Boolean + - When enabled, the device driver will instantiate Ethernet specific + auxiliary device of the devlink device. * - ``internal_err_reset`` - Boolean - When enabled, the device driver will reset the device on internal diff --git a/include/net/devlink.h b/include/net/devlink.h index 0236c77f2fd0..1e3e183bb2c2 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -519,6 +519,7 @@ enum devlink_param_generic_id { DEVLINK_PARAM_GENERIC_ID_RESET_DEV_ON_DRV_PROBE, DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE, DEVLINK_PARAM_GENERIC_ID_ENABLE_REMOTE_DEV_RESET, + DEVLINK_PARAM_GENERIC_ID_ENABLE_ETH, /* add new param generic ids above here*/ __DEVLINK_PARAM_GENERIC_ID_MAX, @@ -559,6 +560,9 @@ enum devlink_param_generic_id { #define DEVLINK_PARAM_GENERIC_ENABLE_REMOTE_DEV_RESET_NAME "enable_remote_dev_reset" #define DEVLINK_PARAM_GENERIC_ENABLE_REMOTE_DEV_RESET_TYPE DEVLINK_PARAM_TYPE_BOOL +#define DEVLINK_PARAM_GENERIC_ENABLE_ETH_NAME "enable_eth" +#define DEVLINK_PARAM_GENERIC_ENABLE_ETH_TYPE DEVLINK_PARAM_TYPE_BOOL + #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \ { \ .id = DEVLINK_PARAM_GENERIC_ID_##_id, \ diff --git a/net/core/devlink.c b/net/core/devlink.c index b02d54ab59ac..9a59f45c8bf9 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -4277,6 +4277,11 @@ static const struct devlink_param devlink_param_generic[] = { .name = DEVLINK_PARAM_GENERIC_ENABLE_REMOTE_DEV_RESET_NAME, .type = DEVLINK_PARAM_GENERIC_ENABLE_REMOTE_DEV_RESET_TYPE, }, + { + .id = DEVLINK_PARAM_GENERIC_ID_ENABLE_ETH, + .name = DEVLINK_PARAM_GENERIC_ENABLE_ETH_NAME, + .type = DEVLINK_PARAM_GENERIC_ENABLE_ETH_TYPE, + }, }; static int devlink_param_generic_verify(const struct devlink_param *param) From patchwork Tue Aug 10 11:46:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 12428747 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 X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F89DC4338F for ; Tue, 10 Aug 2021 11:46:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4446E60F38 for ; Tue, 10 Aug 2021 11:46:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240255AbhHJLrG (ORCPT ); Tue, 10 Aug 2021 07:47:06 -0400 Received: from mail-dm6nam12on2082.outbound.protection.outlook.com ([40.107.243.82]:27233 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240121AbhHJLrD (ORCPT ); Tue, 10 Aug 2021 07:47:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iUWtkk7HTzpBeOX48syeC4mEW6OJ1qBD4ZCNPniz6y/a2Co+5h9CSK7aDl6hGqN1mV09PLL6LxxVYid+QuFimp6LMjdyQA8it8hn0kW6X/LD4qc6xUL6Lxiw7hEkYiAQSM6UqLIoJ3DLAKu3mL01KD90hMVTzumTbRRXg+dHeC7KeRyCgFyBaswSE5wtkLds157eoFi5FHB1Ix7SBKwZb0zwvw+G6S1BNeR0Gru7a5Cnorv/6QpYQyKNEc+VYe5Z4VIN3u1lF1+HKItNoQFFvWmJG8QlR938AH7/oZ3XT2YxKEmMqqGsMSp7zIeHB+ywI2Tu6kW4SosFgMVr0U88cA== 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-SenderADCheck; bh=/4TP67xCYbvJGydxqx01Hd7b5IUy0HkbZU1Dxdmel6g=; b=Z3KWhDxvFrTFq+wxPAVWKAdA9/tPCgVarg3n0X8pMgUecHKkiUfObmBYsREDnasE3tsl3XRfWPMv6qAGLiV8Cq6WFgIXhY4PzaQh4Lowsaczl6CfAR5jwtskA7VzgRIuQGPknBfZctma7tU0ShewZZMc10GeLOehJLXpH0sh5h9rR6WAIv8QufapQ9FE//75PR1uXB8GcJHDo/n40znGoCxeRzR0g5rR/xRjPMIsDOnDW4oABsvqNJvqzMXwJU5j/j8pXx0SEsacGLO0jMigMhok5pzcWk6PgsyKbsrJk9xVBYBRCh3nrx94jChhwklgSmTj8+UyOrnPleRb7dBQvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/4TP67xCYbvJGydxqx01Hd7b5IUy0HkbZU1Dxdmel6g=; b=rOdQEr6zAr6AydMZhUqi2ctMtY+qj0zg1R5CkIJnfhuxGPCkofx1tUTJF/cdzEJC1PxTyiR0OXuK4bf5af36v0lSuHMHpdv4PZtDZkONFGPLlhtAc0GzAEonDyHyaD0ZWlBXssh9ByaufUQFxVVRhD2eXaPkOFjxiqcPU27OUvSd/IY3MWfLFqWiHpYqjX2XnCSYckW1Bgbxb6jiNaedf3PYeZP9kITbzhH0zudFQ2ooahPiQjsCWcnHEUiXReoTu8iAmcMfK8HGK5MC00ajWu8ip4Pa9kENNAwjuEoGWqEYNL9XdsQD96UdMBfao5hXMpBHJpil4Q4A5ixfyib1hg== Received: from BN9P222CA0004.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::9) by BL1PR12MB5046.namprd12.prod.outlook.com (2603:10b6:208:313::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Tue, 10 Aug 2021 11:46:40 +0000 Received: from BN8NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::39) by BN9P222CA0004.outlook.office365.com (2603:10b6:408:10c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Tue, 10 Aug 2021 11:46:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT064.mail.protection.outlook.com (10.13.176.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4394.16 via Frontend Transport; Tue, 10 Aug 2021 11:46:39 +0000 Received: from sw-mtx-036.mtx.labs.mlnx (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 10 Aug 2021 11:46:38 +0000 From: Parav Pandit To: , , CC: Parav Pandit , Jiri Pirko , "Leon Romanovsky" Subject: [PATCH net-next 02/10] devlink: Add new "enable_rdma" generic device param Date: Tue, 10 Aug 2021 14:46:12 +0300 Message-ID: <20210810114620.8397-3-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210810114620.8397-1-parav@nvidia.com> References: <20210810114620.8397-1-parav@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 263b60d5-d122-43ca-a42c-08d95bf48462 X-MS-TrafficTypeDiagnostic: BL1PR12MB5046: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OsWHGpzq6deRYBYDhiswpMDDz/Y1uyQ9Dif978BjJDMYeJgRJA+KX2hAqwEtE0b/PMmciDrrpEZXNMlTUF9eNKlivrhdjPKmb8/RnOrsupkrCN6/dNUaURbBTlU5TDj/Ix9H2zZtVXGma0LamO5H8G3enREMZWHS5KAZCAcnd6mHAT3+fnvS7L+Pxfg5qWgMwKxguas103xq+AcLSu26xyojTS2xq6R0BPDnIfiWxX9vU218z1B4hQ/1FxB/mC9QgS7Upnly9DMowEmlTyrW86kSrfQNxuaIj7uvjozoLXES+P6vqKqFIH7hIyNcnaATPsZWYb0S5kwWvw6Rsjg7X90YdQpei7jisroDwCkB5d8pOmJAYv2JsfnzWemecA8uTFi21PLwHARgzpyp/NhWlfuV+NNgHW63fbhlWFocy8vPjI1CkutUcMii7tn2WKYexVKmneZ5yt5UX3vMd+yMxavmw3Zj6qw9SOAytWplrU86LpNbFjNptXxMqZSAAw5kOM2aWVaj8Zbo47566eZ+YOedgox3BavFiNxzQgx/WPoOdVJK4ke8rVuKmnhFxOqnSkD6fo/bhOocNcfteKZbEA11MChsVKRYDj/atg4JWff9BcX8XiSLWn+rmfr94ZAOEyoedS1w7Osd9XlAixN1xTRzluSOqG9dYXAjktD+3qlBZWhkmUmQHMHohx6OUAS0L0DgZeNpCKB+UNUuQwknOBfJixGsZzP3naMhJnYVOis= X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(136003)(396003)(39860400002)(346002)(376002)(46966006)(36840700001)(107886003)(2906002)(36906005)(7636003)(82740400003)(16526019)(6666004)(8676002)(316002)(186003)(36756003)(110136005)(4326008)(83380400001)(356005)(82310400003)(70206006)(70586007)(26005)(426003)(54906003)(478600001)(86362001)(36860700001)(336012)(2616005)(47076005)(1076003)(8936002)(5660300002)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2021 11:46:39.9311 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 263b60d5-d122-43ca-a42c-08d95bf48462 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5046 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add new device generic parameter to enable/disable creation of RDMA auxiliary device and associated device functionality in the devlink instance. User who prefers to disable such functionality can disable it using below example. $ devlink dev param set pci/0000:06:00.0 \ name enable_rdma value false cmode driverinit $ devlink dev reload pci/0000:06:00.0 At this point devlink instance do not create auxiliary device for the RDMA functionality. Signed-off-by: Parav Pandit Reviewed-by: Jiri Pirko Reviewed-by: Leon Romanovsky --- Documentation/networking/devlink/devlink-params.rst | 4 ++++ include/net/devlink.h | 4 ++++ net/core/devlink.c | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/Documentation/networking/devlink/devlink-params.rst b/Documentation/networking/devlink/devlink-params.rst index 219c1272f2d6..a49da0b049b6 100644 --- a/Documentation/networking/devlink/devlink-params.rst +++ b/Documentation/networking/devlink/devlink-params.rst @@ -101,6 +101,10 @@ own name. - Boolean - When enabled, the device driver will instantiate Ethernet specific auxiliary device of the devlink device. + * - ``enable_rdma`` + - Boolean + - When enabled, the device driver will instantiate RDMA specific + auxiliary device of the devlink device. * - ``internal_err_reset`` - Boolean - When enabled, the device driver will reset the device on internal diff --git a/include/net/devlink.h b/include/net/devlink.h index 1e3e183bb2c2..6f4f0416e598 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -520,6 +520,7 @@ enum devlink_param_generic_id { DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE, DEVLINK_PARAM_GENERIC_ID_ENABLE_REMOTE_DEV_RESET, DEVLINK_PARAM_GENERIC_ID_ENABLE_ETH, + DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA, /* add new param generic ids above here*/ __DEVLINK_PARAM_GENERIC_ID_MAX, @@ -563,6 +564,9 @@ enum devlink_param_generic_id { #define DEVLINK_PARAM_GENERIC_ENABLE_ETH_NAME "enable_eth" #define DEVLINK_PARAM_GENERIC_ENABLE_ETH_TYPE DEVLINK_PARAM_TYPE_BOOL +#define DEVLINK_PARAM_GENERIC_ENABLE_RDMA_NAME "enable_rdma" +#define DEVLINK_PARAM_GENERIC_ENABLE_RDMA_TYPE DEVLINK_PARAM_TYPE_BOOL + #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \ { \ .id = DEVLINK_PARAM_GENERIC_ID_##_id, \ diff --git a/net/core/devlink.c b/net/core/devlink.c index 9a59f45c8bf9..b68d6921d34f 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -4282,6 +4282,11 @@ static const struct devlink_param devlink_param_generic[] = { .name = DEVLINK_PARAM_GENERIC_ENABLE_ETH_NAME, .type = DEVLINK_PARAM_GENERIC_ENABLE_ETH_TYPE, }, + { + .id = DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA, + .name = DEVLINK_PARAM_GENERIC_ENABLE_RDMA_NAME, + .type = DEVLINK_PARAM_GENERIC_ENABLE_RDMA_TYPE, + }, }; static int devlink_param_generic_verify(const struct devlink_param *param) From patchwork Tue Aug 10 11:46:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 12428749 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 X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB39FC4338F for ; Tue, 10 Aug 2021 11:46:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 928C2604D7 for ; Tue, 10 Aug 2021 11:46:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240272AbhHJLrJ (ORCPT ); Tue, 10 Aug 2021 07:47:09 -0400 Received: from mail-sn1anam02on2069.outbound.protection.outlook.com ([40.107.96.69]:7770 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233534AbhHJLrE (ORCPT ); Tue, 10 Aug 2021 07:47:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CzGqcGtzcpN+uztyc2/+YUHljmQmwOpA47oqH8CiJueMW2AQABljQ783n02+rIu4P2Rtz79ie2JCWnnEKMMq2OnDuiBMGfwAwAvIrkbokuuvUjf7kQ+9Mf29bWGC7yd3R6PsADXlTXDkX7gEr4T9otZvR9WMhdigAq+kUVn/PFNh/d/4+PVDyMTZtuvwkDvrUSAaKLHa6FDIJ5a6xUKExqkxLPU9I9tryVevbb1jF8lpZcBERuQV3iwJlQny+IKSMjaOhIiCDhMPTUpA+IkVGNYKi+MsxvLhlRKKYe3aaBy0ZzQ2PzIpbELCORNVvqTcQWTq/sTgXeeoHpUz2WTvqQ== 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-SenderADCheck; bh=w4/S67V7WOYwqMo9/yFokbt27R1+xYcr9QtOyrtDXIQ=; b=EWHAwtRUC8RaDlUcYMKEgzZ21TKasU0T7LE14qTbVJB+lPaJS+4KuEuDA6scptZNzP4WYvOqaIozlZE47j9iTjvMmrPnr2nAVljcu3R9ZixaQMMJXsYKDCJenh9p2AyekUuB3ViMTdV5QsXbqOI7G0c6sUFjDf+ZJ/EKlF3CkwbAgrMrmQFepHh26QPTEF8fbR9yQzo0rJcXEowjtP9RYxIqUndp6bG+uqU197bUXhTSZeJa60mBWnvd8rZ9gaz80rtIjnrLvZwSd70UUsT7KSLXTNqJ2Av8g9CMI36amsuTNIdXLs5rO2iBzkIUd7hSNnbPDqF4UH73RE4CtliAfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w4/S67V7WOYwqMo9/yFokbt27R1+xYcr9QtOyrtDXIQ=; b=aWyVL2X+BsDAMqX8zzddJJMwHGifx+II4cqVf3c74ZjzKeTAxAsPBTodcnJ7L8LTAlPSjKOii8kpP9CkiMoEaCNCje750X/rNHGhG7iWqkpBlN0juvxdeSv9hNT70rlDmRXLITZ+vxll7m7SZccVCm4+1NDGKLB+2g/0V4i9UuvbrrVVBsiKV7ftRZTxETBt7FchlIF0lxc2pSnN2Fi3b7H7upBKVszEdW2h8WGhSXTFqnd+gtR+AIc+u2c9Nuz8Bc5BB6fbOX2pTRxTGoIBJgjFs/3Vo76kb/lcV2pLCA2MMTqjKZHbwJyv5QOy0dshhmN+uwklHFbGfdMRic9CdQ== Received: from BN9P222CA0026.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::31) by BYAPR12MB2998.namprd12.prod.outlook.com (2603:10b6:a03:dd::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15; Tue, 10 Aug 2021 11:46:40 +0000 Received: from BN8NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::28) by BN9P222CA0026.outlook.office365.com (2603:10b6:408:10c::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Tue, 10 Aug 2021 11:46:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT064.mail.protection.outlook.com (10.13.176.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4394.16 via Frontend Transport; Tue, 10 Aug 2021 11:46:40 +0000 Received: from sw-mtx-036.mtx.labs.mlnx (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 10 Aug 2021 11:46:39 +0000 From: Parav Pandit To: , , CC: Parav Pandit , Jiri Pirko , "Leon Romanovsky" Subject: [PATCH net-next 03/10] devlink: Add new "enable_vnet" generic device param Date: Tue, 10 Aug 2021 14:46:13 +0300 Message-ID: <20210810114620.8397-4-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210810114620.8397-1-parav@nvidia.com> References: <20210810114620.8397-1-parav@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 01e1cabc-e902-4fbf-1dce-08d95bf4849e X-MS-TrafficTypeDiagnostic: BYAPR12MB2998: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oxDvgfm/F3ez9H66l6yYwrilxb9TRNYv/VWqKAHM8piq4z8e9qesXk75vPWnlUwhSOJ4b2eO9SkhTG4rhCDk3KSomVkrCKtjNlFB6IHYWJmb1DheF6nS/5UuLcNKC7xDjyvSHvyWOA1uoFjg2IC5dRb21vpu/8OiLDpWexFF3AQMBsrcmTUO52bx6fkUVGX9lh+zqgjwZs78vD6qhT/ll8lSmElmT060cmkvUmlC559ZNhjPakk8gxqB6ZlXv6AvaZRzgbBZ9+khvIgFJcmKVRf7S/rAODMm/+i76M6u2ELXNdZ9uUOrSFHuilBjwkVcLdNUwxWphZcywvgbX/d6F4Yw1lJxn9XQDx1Xzdwr8WKzNnLQhFfV1MHCGd6hzB4MTt31Igt9HjrBXCOKWbon4BP4wvO76aVJNYrX4ICTfGD3IeP67LA4q54kN7yVJokwwvV2P4nrblR7kKCvMQFMlVQiSGr/pjTvp9zYDpQDv5hyCJzck/pXsgWA9RaxOiqNDLovX0N/gK3uLWIxBdfTZqsdHILOAddeaqy5OjaB/LxhHSEKDUdlNtc8jOdNPQ/7aTQ31M18xhu9U1b1UzSt0qnlDWlKFY3hOrLNfEqvl5ro60epYcicQ9wqJbEwBQkz5AR4jo43xGcD52Kq8cD1EGrAGSNSvT1XJjtpYZ1gvx8HIMoC59VZPpJGw+m6iEivOmUFGyNyXIOSiAoqaBNj3BW+tDkX3CS8uJCZiPyF7DQ= X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(396003)(39860400002)(346002)(376002)(136003)(46966006)(36840700001)(36860700001)(86362001)(26005)(36756003)(8676002)(82740400003)(4326008)(336012)(8936002)(478600001)(7636003)(36906005)(1076003)(6666004)(16526019)(5660300002)(83380400001)(316002)(110136005)(54906003)(47076005)(2616005)(356005)(70206006)(186003)(426003)(70586007)(107886003)(2906002)(82310400003)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2021 11:46:40.3049 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01e1cabc-e902-4fbf-1dce-08d95bf4849e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2998 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add new device generic parameter to enable/disable creation of VDPA net auxiliary device and associated device functionality in the devlink instance. User who prefers to disable such functionality can disable it using below example. $ devlink dev param set pci/0000:06:00.0 \ name enable_vnet value false cmode driverinit $ devlink dev reload pci/0000:06:00.0 At this point devlink instance do not create auxiliary device for the VDPA net functionality. Signed-off-by: Parav Pandit Reviewed-by: Jiri Pirko Reviewed-by: Leon Romanovsky --- Documentation/networking/devlink/devlink-params.rst | 4 ++++ include/net/devlink.h | 4 ++++ net/core/devlink.c | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/Documentation/networking/devlink/devlink-params.rst b/Documentation/networking/devlink/devlink-params.rst index a49da0b049b6..4878907e9232 100644 --- a/Documentation/networking/devlink/devlink-params.rst +++ b/Documentation/networking/devlink/devlink-params.rst @@ -105,6 +105,10 @@ own name. - Boolean - When enabled, the device driver will instantiate RDMA specific auxiliary device of the devlink device. + * - ``enable_vnet`` + - Boolean + - When enabled, the device driver will instantiate VDPA networking + specific auxiliary device of the devlink device. * - ``internal_err_reset`` - Boolean - When enabled, the device driver will reset the device on internal diff --git a/include/net/devlink.h b/include/net/devlink.h index 6f4f0416e598..0a0becbcdc49 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -521,6 +521,7 @@ enum devlink_param_generic_id { DEVLINK_PARAM_GENERIC_ID_ENABLE_REMOTE_DEV_RESET, DEVLINK_PARAM_GENERIC_ID_ENABLE_ETH, DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA, + DEVLINK_PARAM_GENERIC_ID_ENABLE_VNET, /* add new param generic ids above here*/ __DEVLINK_PARAM_GENERIC_ID_MAX, @@ -567,6 +568,9 @@ enum devlink_param_generic_id { #define DEVLINK_PARAM_GENERIC_ENABLE_RDMA_NAME "enable_rdma" #define DEVLINK_PARAM_GENERIC_ENABLE_RDMA_TYPE DEVLINK_PARAM_TYPE_BOOL +#define DEVLINK_PARAM_GENERIC_ENABLE_VNET_NAME "enable_vnet" +#define DEVLINK_PARAM_GENERIC_ENABLE_VNET_TYPE DEVLINK_PARAM_TYPE_BOOL + #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \ { \ .id = DEVLINK_PARAM_GENERIC_ID_##_id, \ diff --git a/net/core/devlink.c b/net/core/devlink.c index b68d6921d34f..867ae7e39788 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -4287,6 +4287,11 @@ static const struct devlink_param devlink_param_generic[] = { .name = DEVLINK_PARAM_GENERIC_ENABLE_RDMA_NAME, .type = DEVLINK_PARAM_GENERIC_ENABLE_RDMA_TYPE, }, + { + .id = DEVLINK_PARAM_GENERIC_ID_ENABLE_VNET, + .name = DEVLINK_PARAM_GENERIC_ENABLE_VNET_NAME, + .type = DEVLINK_PARAM_GENERIC_ENABLE_VNET_TYPE, + }, }; static int devlink_param_generic_verify(const struct devlink_param *param) From patchwork Tue Aug 10 11:46:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 12428751 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 X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DCC8C432BE for ; Tue, 10 Aug 2021 11:46:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E838604D7 for ; Tue, 10 Aug 2021 11:46:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240265AbhHJLrN (ORCPT ); Tue, 10 Aug 2021 07:47:13 -0400 Received: from mail-dm6nam11on2057.outbound.protection.outlook.com ([40.107.223.57]:25144 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240227AbhHJLrE (ORCPT ); Tue, 10 Aug 2021 07:47:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eS6vEecY/xZbdEFguOSQT7XibDHMIpawbHFVWWBcxHthW8vYf6Ml5N5+87lW4KRU0/0Wp3SS0olpZyUcVS5SGEIHeqskW2UxGG3W1j4jofoB2QuWBTXykDXKNCcc8r07cdSiB1OZQefIMforbDetA/hWoqV5u1hNpZJbhT1hyfWfUAdl5+dsdYwXSAVOflHwulULFdEouEfxaFP/bfpQ4pTLJUrl6hWLWnssz3lV1shYysP+P+7zof205zesO1RI3B+2Me5wkO7521CyKyBM5LFGu36cHe7Jf91q8JDegr+69c3PuSIH/5+UjrLRB9bh743bevN9eiuO5/9J3f94XQ== 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-SenderADCheck; bh=lMMYImPDjzX3tlIYCUsUxidRBJpfw8dwpK6xM3+B8nQ=; b=aOJrs1aDdl/GkQXcBHhnYPID5WD4lwYk/slREXD+E0/xgWBC5qrXyFq7lckHVZXOE8wIbEpjefcY9fqWaAyGVIifa+8BEskMuY5/Gay1mMVWObQi6n6IEQlu9X8V9Xm9XQDS6V5I5O9yelEdeQCitZ1d/1sXrkNXwMZAVNYn2uVlKvY0Pv1f9jEjX9P4u0nFtt0Wfyrl5PByV2vkMpoyAgp3LeFbkyRhEjIent4Pz/HVz7iwbBAaJiq9M+l+GmbD7Ff/cj46fbkszsQ1d3zcNoR2jLe35Mc5NcpVDmqDFrH+E7J2CfAmRzpQjZnIL4ux2SNVjBaBVVT2FV2VMjQ7Aw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lMMYImPDjzX3tlIYCUsUxidRBJpfw8dwpK6xM3+B8nQ=; b=Zn4zvqKoIBEKJBIUVIhI2OxHSvUPAUEHXr5iimsRO3cyFZKRNdgh16FZYW5pJhGL/t1PylXdN6HbMeSqGa01etbD3e4/N0xRz8boGAYQosycxYKqXa1Cm6Jvk9wHvhKrFZhWrTiz9JQYFLIkX8F3SfGKpLLzlCJ4MkWHs9u3eG9gziNmRlFWxfxuKK92Yn9kNT79gcNPwNtjcrS57iHUiUoOXIu1/rjp+OiwmGqqbpmLmfCgPJ+RcneM3ifG+N55XuYTPJQB/qYU6obG+B8PGA2gLP2d0IiX6f0Nh2KgdE7yIMl5AwMQ0HRyVd/yQop0Piw2Z4edhBILBWbYxsIOsA== Received: from BN9P222CA0017.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::22) by BN6PR1201MB0050.namprd12.prod.outlook.com (2603:10b6:405:4e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.19; Tue, 10 Aug 2021 11:46:41 +0000 Received: from BN8NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::34) by BN9P222CA0017.outlook.office365.com (2603:10b6:408:10c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Tue, 10 Aug 2021 11:46:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT064.mail.protection.outlook.com (10.13.176.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4394.16 via Frontend Transport; Tue, 10 Aug 2021 11:46:41 +0000 Received: from sw-mtx-036.mtx.labs.mlnx (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 10 Aug 2021 11:46:40 +0000 From: Parav Pandit To: , , CC: Parav Pandit , Jiri Pirko , "Leon Romanovsky" Subject: [PATCH net-next 04/10] devlink: Create a helper function for one parameter registration Date: Tue, 10 Aug 2021 14:46:14 +0300 Message-ID: <20210810114620.8397-5-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210810114620.8397-1-parav@nvidia.com> References: <20210810114620.8397-1-parav@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 85b42a41-9a72-49d1-1ab7-08d95bf48545 X-MS-TrafficTypeDiagnostic: BN6PR1201MB0050: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:597; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cTjSbE+jvW4AbcZTiaOptOOnUSBBpDmFaMyhYNa7jwVjdWUczlkG9IpRmpzt0IWbs+FiV0nxGVLer4jnkHinrbCErMd7C25sjmjKoPkZzW4T7DUX53QORoWXVrLIN/FsmMiAd3mG4CKiDwo6jaJLNvTSjFDYFG1gp13K89rUCUpKrrP3AGHNnnwwQGC3+5eSqK8fUqDZmfOYY+LvjxXwQJivdaejKEdUG28QdBf2mqHJFtC8ONRJxcTphMlPb9ICNGo0K6T6ryr4p4hSPAB6pXM7QbHlheB7hY9UiMNO00AGdVuIToPlMyZzWgHDc0zJMYFvXDfRpo/lMlhdxJxq32ztIs3417ck9L47+UhvJpAIIsV5Plzn9ix/ArOX2xLzxbfPZluDlXbk2QpJJvpZdcVN2oG8RCv5im7Yh67xTv3zJcC2xKEAyYJEw9BnBFVH1xrAmiWTOftawMO8Iec+On7k6mrIRMG7qkRPby0cP8jvxZyzm2taqqpu3oiqBJKK/MbdgtiIil6hlcEU/BWHfWOwf9e1LDhOJ6Kkbw/GxDEdSlb5YwYj5jsTG7E2vs7HHyH+Sdc6XO6YAWBPkumd2GydqO+ETG9WCohZH1QRN156WIZFDVOgvc6CYpcJaP4Zi3MYhvPsf6xP4RrqdgUlUlh06uwuLD8V3Bz0ANpIZU+vAf0Phm1aTOy7zpho934kIQiJIridt9D6lUYwjRx60A== X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(8936002)(316002)(110136005)(86362001)(36860700001)(54906003)(1076003)(508600001)(36906005)(8676002)(36756003)(47076005)(7636003)(2616005)(6666004)(83380400001)(336012)(107886003)(16526019)(186003)(70206006)(70586007)(2906002)(356005)(5660300002)(82310400003)(426003)(4326008)(26005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2021 11:46:41.3983 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 85b42a41-9a72-49d1-1ab7-08d95bf48545 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1201MB0050 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Create and use a helper function for one parameter registration. Subsequent patch also will reuse this for driver facing routine to register a single parameter. Signed-off-by: Parav Pandit Reviewed-by: Jiri Pirko Reviewed-by: Leon Romanovsky --- net/core/devlink.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index 867ae7e39788..050dd7271a45 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -9800,6 +9800,22 @@ static int devlink_param_verify(const struct devlink_param *param) return devlink_param_driver_verify(param); } +static int __devlink_param_register_one(struct devlink *devlink, + unsigned int port_index, + struct list_head *param_list, + const struct devlink_param *param, + enum devlink_command reg_cmd) +{ + int err; + + err = devlink_param_verify(param); + if (err) + return err; + + return devlink_param_register_one(devlink, port_index, + param_list, param, reg_cmd); +} + static int __devlink_params_register(struct devlink *devlink, unsigned int port_index, struct list_head *param_list, @@ -9814,12 +9830,8 @@ static int __devlink_params_register(struct devlink *devlink, mutex_lock(&devlink->lock); for (i = 0; i < params_count; i++, param++) { - err = devlink_param_verify(param); - if (err) - goto rollback; - - err = devlink_param_register_one(devlink, port_index, - param_list, param, reg_cmd); + err = __devlink_param_register_one(devlink, port_index, + param_list, param, reg_cmd); if (err) goto rollback; } From patchwork Tue Aug 10 11:46:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 12428753 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 X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2C17C4338F for ; Tue, 10 Aug 2021 11:46:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AFE13604D7 for ; Tue, 10 Aug 2021 11:46:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240296AbhHJLrQ (ORCPT ); Tue, 10 Aug 2021 07:47:16 -0400 Received: from mail-dm6nam11on2061.outbound.protection.outlook.com ([40.107.223.61]:48096 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233318AbhHJLrF (ORCPT ); Tue, 10 Aug 2021 07:47:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ib1RVgCopUJHCHkqfQRpyw8DIFP08doEhHny9AmHT7cwcAglI8cnmnkHS8q+oOwYJW8upyxICnvl780B372N6goUlAMaM4cJvason1b996iMGQjGtbEvDrz7+NWa3KmE++TDgJo08JZeSsMCb4lilwRgpCL232u2ALxa/ZadKvuqZM1bH7vnhOKgTP0cUt6mF7c8BcPGLTiduJaHdfdjYMhey6YJjqCZxd7GHw2TZZk/9kxcoJESvGoEaSl8Uqbqqui7CfsUoUVGpD3tk9edtgTB4gYTFAAY+3dEpJdpD0gYlnmQYY3sSJUVzfw3cqpwaL9LRiNnTyenOwP6XO0WlA== 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-SenderADCheck; bh=drnAII7q7Sg0ir7JPDzE3fON+Ec+o1taOtnrCCLk71w=; b=X6he/hR1EUOF6JzvrozUVjmzc6kNLSQI1PJ7d7bzUmICEIsffJG4jWiTGJYWEKVeuNJPplNybK3UNZpc2nyh9PXJOHTsilEwPA61u9hKz2M2llOWYaJafLyulM4XjITg1yr8FsHmqNxLiv6qsWH5GwqVZf/03yB6pdyBxdjwrvLGWEayseC3WYj9/zLTp3o+MoZZsE1SzV7YjWuIYfZTIpzWQ4+d3hmpKiyeCDXFhr287wb2MDFHKbvBvhi++TZzoEy5a4g18VnkyhlBqhuMHZM+7hzzegw/T4fAGtGZSHkSiWdgYq3gCJ34Un8SRkYZJfzhpJe8LhAddDqxqxtVZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=drnAII7q7Sg0ir7JPDzE3fON+Ec+o1taOtnrCCLk71w=; b=IX2sJ+G8sQHXmQ4Zed+89G/EfFjl/46QSfc2q1oXM/M61R9FHmXjskbB+mtEgJL0PJvFgKp+u2KnR8mvU3JoULHKSEH3IZlXtA9ZFN/IrfJ5eFCMfyzZ85JdStCELfP+tRH6TrHpSZzZJbIeSIEBN6M8G90Vu3DQ2cWxic+vsGmt5e27MBVTduiD+eObXxIS6kq/lZx/ABlnM7lnLEDrWIMWojoPmbESbQmer1L5oa2AKV9xYT3d4G9OXEqj2UhhvU/Eq8kP0ItioezpT02eSHApCv68lPcFpBRDJhnYM0PL/ttveoxgl+HV8+PmQUqlJEr1RBkGUgqFo79eCV6CaA== Received: from BN9P222CA0012.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::17) by BYAPR12MB2599.namprd12.prod.outlook.com (2603:10b6:a03:6b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.13; Tue, 10 Aug 2021 11:46:42 +0000 Received: from BN8NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::52) by BN9P222CA0012.outlook.office365.com (2603:10b6:408:10c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Tue, 10 Aug 2021 11:46:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT064.mail.protection.outlook.com (10.13.176.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4394.16 via Frontend Transport; Tue, 10 Aug 2021 11:46:42 +0000 Received: from sw-mtx-036.mtx.labs.mlnx (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 10 Aug 2021 11:46:40 +0000 From: Parav Pandit To: , , CC: Parav Pandit , Jiri Pirko , "Leon Romanovsky" Subject: [PATCH net-next 05/10] devlink: Add API to register and unregister single parameter Date: Tue, 10 Aug 2021 14:46:15 +0300 Message-ID: <20210810114620.8397-6-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210810114620.8397-1-parav@nvidia.com> References: <20210810114620.8397-1-parav@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: de0dcb91-0bac-4705-4133-08d95bf485c8 X-MS-TrafficTypeDiagnostic: BYAPR12MB2599: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xdGz1qTyUydGsc/1uk1kHPzcxx7pPSbJClee1kqJUAZHQqg+vUQ6J7lr76/1asyaph3UiesFRhS1rGXRQ5vWWiHNUDUvleptmkTdM6RcNubn/7oSo2FD8nLQjAASBw/TmZmFthv183G3iwe2+G4/EbX8JeZAF9ZuUCNuuj0o5Lk569QifKY6QA8nJts34pOWI8jl7F/kOP54jKU6cvtaAX2YDnLQCZqWOdOt4rt4RoMOtIbw7Z1H8H54YJRcRLtsIDccgFHW/rgelILmgq6OQRBui7XilNuARi6MUh++iGkauziRsWKpECOxn3XIobPYyVCU0GRcv08CXVXpp6oGu+DvrmySRH4z3qYSZsQI/JGkKtD6BESGW1FytgJIksrriqj2eYBH7fSvfjvi7Bqo9IQE/Co7K1VqdUCBhZHhZUdY4Mwul2yQz2sYfLTCIdzrj4vLFNmYM23sizoA1xLIDpvSE8g5e3f5RZTooEUAOXeQotYV9hyROcH8RzazDKDNWS7saz5ntyWNB31tvh7Lr8bbTG2YclpN+nY5Pg+dCwY2b491Rt0JqhYgVanPWOcnAZdc3SnmYUnO+cPCNDK1HtdIeK0UfUCaNi1N3sajB38tLL8o3M8SaS/2ByLM0FpEFt9QbATL2hwybPe2g1APMTR0VWNcoFUBY22Y7EDuD4Ke1p8+wjEWhkMueZw0ZN4A X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(376002)(39860400002)(136003)(396003)(346002)(46966006)(36840700001)(70586007)(70206006)(8936002)(8676002)(82310400003)(47076005)(336012)(36906005)(356005)(83380400001)(6666004)(16526019)(36756003)(478600001)(26005)(86362001)(186003)(5660300002)(36860700001)(2616005)(2906002)(54906003)(110136005)(7636003)(1076003)(426003)(316002)(107886003)(4326008)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2021 11:46:42.2118 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de0dcb91-0bac-4705-4133-08d95bf485c8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2599 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently device configuration parameters can be registered as an array. Due to this a constant array must be registered. A single driver supporting multiple devices each with different device capabilities end up registering all parameters even if it doesn't support it. One possible workaround a driver can do is, it registers multiple single entry arrays to overcome such limitation. Better is to provide a API that enables driver to register/unregister a single parameter. This also further helps in two ways. (1) to reduce the memory of devlink_param_entry by avoiding in registering parameters which are not supported by the device. (2) avoid generating multiple parameter add, delete, publish, unpublish, init value notifications for such unsupported parameters Signed-off-by: Parav Pandit Reviewed-by: Jiri Pirko Reviewed-by: Leon Romanovsky --- include/net/devlink.h | 4 ++++ net/core/devlink.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/net/devlink.h b/include/net/devlink.h index 0a0becbcdc49..f6459ee77114 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1645,6 +1645,10 @@ int devlink_params_register(struct devlink *devlink, void devlink_params_unregister(struct devlink *devlink, const struct devlink_param *params, size_t params_count); +int devlink_param_register(struct devlink *devlink, + const struct devlink_param *param); +void devlink_param_unregister(struct devlink *devlink, + const struct devlink_param *param); void devlink_params_publish(struct devlink *devlink); void devlink_params_unpublish(struct devlink *devlink); int devlink_port_params_register(struct devlink_port *devlink_port, diff --git a/net/core/devlink.c b/net/core/devlink.c index 050dd7271a45..629291175af3 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -9903,6 +9903,43 @@ void devlink_params_unregister(struct devlink *devlink, } EXPORT_SYMBOL_GPL(devlink_params_unregister); +/** + * devlink_param_register - register one configuration parameter + * + * @devlink: devlink + * @param: one configuration parameter + * + * Register the configuration parameter supported by the driver. + * Return: returns 0 on successful registration or error code otherwise. + */ +int devlink_param_register(struct devlink *devlink, + const struct devlink_param *param) +{ + int err; + + mutex_lock(&devlink->lock); + err = __devlink_param_register_one(devlink, 0, &devlink->param_list, + param, DEVLINK_CMD_PARAM_NEW); + mutex_unlock(&devlink->lock); + return err; +} +EXPORT_SYMBOL_GPL(devlink_param_register); + +/** + * devlink_param_unregister - unregister one configuration parameter + * @devlink: devlink + * @param: configuration parameter to unregister + */ +void devlink_param_unregister(struct devlink *devlink, + const struct devlink_param *param) +{ + mutex_lock(&devlink->lock); + devlink_param_unregister_one(devlink, 0, &devlink->param_list, param, + DEVLINK_CMD_PARAM_DEL); + mutex_unlock(&devlink->lock); +} +EXPORT_SYMBOL_GPL(devlink_param_unregister); + /** * devlink_params_publish - publish configuration parameters * From patchwork Tue Aug 10 11:46:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 12428755 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 X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD46CC4338F for ; Tue, 10 Aug 2021 11:47:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BBC286023E for ; Tue, 10 Aug 2021 11:47:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240301AbhHJLrT (ORCPT ); Tue, 10 Aug 2021 07:47:19 -0400 Received: from mail-mw2nam10on2062.outbound.protection.outlook.com ([40.107.94.62]:27960 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240121AbhHJLrG (ORCPT ); Tue, 10 Aug 2021 07:47:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lKweNDGESlngWO97LYSRuLmPUUrg4WnjPrmip6eNCuX81AOjbi+Mh/EnDcNW+NAHMlgNgay09vq6o3vVDV4jZDisFZX/jSiPL2KiWZROozIitpf2P4MM8fC2fwY3rHfFbPZvnJM/BFSrzK5gEagQ9uUyyXLk7/5ma5HFOLyenqH6RQqn3C48ACY0ehvNsENezfx8EO3CfyjxBZixRHgwE+sJxD5mzYjwQKuy/YA0yxcymp6QBKiF5viksz9htMWQbAHM5490wjfHVtxBs7SAON8mV/YXFCyCnj1QMknU5c3rCdWfcKv8yFLy5o3+GOnPEyyirCfEHwjyWqAa4uR0pw== 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-SenderADCheck; bh=zOWPJ9JIrwjGsqY/KrjRI8m9WzSl5Cf6VcnQWxLM6SE=; b=Qv+VqWVzROh5lUDn/bzyN0UrzoQhX3ZNlGnNah2xIuMM//OTypcdCL3AlMxKdpitQNYn0EMRL9vvPc5pgTSzWVZInJjizFUPqwfGFydjOZwxj6dbvueRjPAFZ6DcV2Ev4RvdzWDxvyrbnZWdtTNgO3hX7IEH105ZwaxzeJsj84EemMdba4gZxPSWjUWnd0RBjYWpEPR7d5cQPJAfVBhnlOFZGrsoCCoOvdjvrE9/14Wh3IWlrrtUdhRNWA9BayJL6pE1vqMLitUIe5iwWO5mqqhPlVwZ6i3DbCH9bfxk0K/Fnp8wNW0awYOJovnG2ISs3EXfNqt/Hl6pmsn3Q1eJjw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zOWPJ9JIrwjGsqY/KrjRI8m9WzSl5Cf6VcnQWxLM6SE=; b=rvRoHxdrGMKf3Unu4u2499mD29OvDU8c7R/51rQf3tVT+jmYUT4FdD1I4G56Wto7wQuk4Xp4d2c7MS5oT/Ntiijh4ppQQ9Up56Pta5zYOk/uHF0R4gJrUp1q5vE4qe3PQbbc1VwSCjs23HcSrLvSKkIhOqrSvK+NZi7wBgQfcuSEFx4j5jH0KjZFy6WFb84ib+VygGLcPcK/rE5MTo00de3Y0P3aqjWGKMykk46p/WsaiHvVRXGe5Sv4SO/0FgJXroOA8OPgeDIh2lHGYwJ/EG5F+W64s/nlm+W1S2YYny6j5hDu+XfkkPV8uLgdaM0Pw2jpCHPCHX1wyY1Okor3ag== Received: from BN9P222CA0012.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::17) by CY4PR12MB1381.namprd12.prod.outlook.com (2603:10b6:903:42::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Tue, 10 Aug 2021 11:46:43 +0000 Received: from BN8NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::52) by BN9P222CA0012.outlook.office365.com (2603:10b6:408:10c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Tue, 10 Aug 2021 11:46:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT064.mail.protection.outlook.com (10.13.176.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4394.16 via Frontend Transport; Tue, 10 Aug 2021 11:46:43 +0000 Received: from sw-mtx-036.mtx.labs.mlnx (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 10 Aug 2021 11:46:41 +0000 From: Parav Pandit To: , , CC: Parav Pandit , Jiri Pirko , "Leon Romanovsky" Subject: [PATCH net-next 06/10] devlink: Add APIs to publish, unpublish individual parameter Date: Tue, 10 Aug 2021 14:46:16 +0300 Message-ID: <20210810114620.8397-7-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210810114620.8397-1-parav@nvidia.com> References: <20210810114620.8397-1-parav@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 66a006e9-3d14-413c-0c2f-08d95bf4868e X-MS-TrafficTypeDiagnostic: CY4PR12MB1381: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lBQ6ecANqAYeirnOIKkAoFALGj+mxF+Kw3Wg9BqwwAtXC2QdhNT9as3r/3rYZzxgQdfrTC1uk28B75bJe2JwNoXV18fHJOVkzgcoYpqId9i88EO2GaJsW4P2onzKMp/kLTTRV2MdEbD2fAHQmq99YsKq9Uj+I15OGjRJwELejFMGd+xaf63vFIE3TvzQfSXNYHkIrzAOwnPthCnofAmrk+kqahtrQ+Pdk8F/gahZFQ1tCFg0jqkqtI+KBiEdahZnosvS0Zp1OisBQXmw63M3tLxaqNqJ1M2Thb+T2n0cl5mYOPaO7dZWmopIcozYm9bbhuv0fg85c6HUuSe8RP7Yi7eMRqpmAEXLk/3PvY2cMyrVGhPvp49Ktg/Y6xwtDrRiDAGn6cJUEGNQ4SDWPmwZSbyYSbM6LojcODJbedcrjvCcu/+TsohPbWu9UNRDNkRbfLGzhSPUK+oDZ0sOi9/b2s6Wgz12VBt5e7aJXPLLLZRw09/0H3ixtzfF/LdXXOl7kGHrgH0q4n6I5jJM2AkzccAB88H0DRp3RxaoVcBSEZkCCSROb28zyh51S+ezYD/1OqfPl3fFfwFSq0QVsAWupdYhxrXxSuAO+mjaYWl+oIMDBqcx6lV1Rkyv5DaM1+k2jw9rkZFZaxzmYeEy12ulqUcKU1LJkYZviMPxfLcvinp8DxoO6x9JSTHl6a/pBljPGKXWkeCVD3tnRulshWRC2A== X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(26005)(70586007)(1076003)(16526019)(5660300002)(70206006)(186003)(36860700001)(110136005)(107886003)(54906003)(47076005)(4326008)(316002)(36906005)(508600001)(356005)(426003)(2906002)(336012)(86362001)(2616005)(8936002)(8676002)(6666004)(36756003)(7636003)(82310400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2021 11:46:43.5630 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66a006e9-3d14-413c-0c2f-08d95bf4868e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1381 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Enable drivers to publish/unpublish individual parameter. Signed-off-by: Parav Pandit Reviewed-by: Jiri Pirko Reviewed-by: Leon Romanovsky --- include/net/devlink.h | 4 ++++ net/core/devlink.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/include/net/devlink.h b/include/net/devlink.h index f6459ee77114..1151497c0ec5 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1651,6 +1651,10 @@ void devlink_param_unregister(struct devlink *devlink, const struct devlink_param *param); void devlink_params_publish(struct devlink *devlink); void devlink_params_unpublish(struct devlink *devlink); +void devlink_param_publish(struct devlink *devlink, + const struct devlink_param *param); +void devlink_param_unpublish(struct devlink *devlink, + const struct devlink_param *param); int devlink_port_params_register(struct devlink_port *devlink_port, const struct devlink_param *params, size_t params_count); diff --git a/net/core/devlink.c b/net/core/devlink.c index 629291175af3..ee9787314cff 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -9982,6 +9982,54 @@ void devlink_params_unpublish(struct devlink *devlink) } EXPORT_SYMBOL_GPL(devlink_params_unpublish); +/** + * devlink_param_publish - publish one configuration parameter + * + * @devlink: devlink + * @param: one configuration parameter + * + * Publish previously registered configuration parameter. + */ +void devlink_param_publish(struct devlink *devlink, + const struct devlink_param *param) +{ + struct devlink_param_item *param_item; + + list_for_each_entry(param_item, &devlink->param_list, list) { + if (param_item->param != param || param_item->published) + continue; + param_item->published = true; + devlink_param_notify(devlink, 0, param_item, + DEVLINK_CMD_PARAM_NEW); + break; + } +} +EXPORT_SYMBOL_GPL(devlink_param_publish); + +/** + * devlink_param_unpublish - unpublish one configuration parameter + * + * @devlink: devlink + * @param: one configuration parameter + * + * Unpublish previously registered configuration parameter. + */ +void devlink_param_unpublish(struct devlink *devlink, + const struct devlink_param *param) +{ + struct devlink_param_item *param_item; + + list_for_each_entry(param_item, &devlink->param_list, list) { + if (param_item->param != param || !param_item->published) + continue; + param_item->published = false; + devlink_param_notify(devlink, 0, param_item, + DEVLINK_CMD_PARAM_DEL); + break; + } +} +EXPORT_SYMBOL_GPL(devlink_param_unpublish); + /** * devlink_port_params_register - register port configuration parameters * From patchwork Tue Aug 10 11:46:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 12428757 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 X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6FF1C4320A for ; Tue, 10 Aug 2021 11:47:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADF4C60E09 for ; Tue, 10 Aug 2021 11:47:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240310AbhHJLrX (ORCPT ); Tue, 10 Aug 2021 07:47:23 -0400 Received: from mail-dm6nam10on2046.outbound.protection.outlook.com ([40.107.93.46]:48736 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240257AbhHJLrH (ORCPT ); Tue, 10 Aug 2021 07:47:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TgxxeeWXTqzh8RzfGoEhQ5NLyCl7hIc2R9Z8E9r5bNUaDbhow7f0nMF0euvWp+skqNxZI4mqffRAxFfUi8VjIYwpVj+0cKD0NNyTQAH9+ohrNasjXln/1fW6TeThRJ7/swJt0mwrpIPwvxaB1A+GGdyGtd/qfAxEdeokzHl/2sGARUcdrcr8GrlYj/XyMvng5BINjAHnQknwP3ojQ+jz4+QK/k46MbwcswyiDBF+VT4Fn5I+X4k6NgBLo+zWoCZgH58v6LukAbWeUzyZZLwIszusOXKl7ruES3kM2nRy2MDxMXX/JLPFYEaYODfRT7nnmyxVsD6DK18a2oofwsxCdw== 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-SenderADCheck; bh=AXr1xJ9xsuCjzTyvW2827Y7vv2eBERDsEbuANeR9gAM=; b=AKqtOcsw7wNBOz4Y+4JuKL4srhL6YJjXylvRootWB3B7feRp3bgQc/WdWLVlVYAEpZ5nNiIifi4/jufZyN1Cd25FXV83jRHxuAJ72Zx3j6N6WjB4/nY0oTCa0CUkeK1Fgd0ODXWpXuqeyE86Z3//AHYJpzBzAjLgIJVaplbY9XE/V4Wkoi/m67MWabpq6eEd6tjb8jNYU7tG+N2IMjJIh1Mxg0lcqpIvG3UXxRu1mtgq8FTSeS141/kNt1+jHJTkq7tGKDmfPEghdz96ie0kUODcXiPohP+L4aC0AJbqMHqPcvvMv1b/VcCcXIOz1SgV8zd29+ESGTAq0p1+8PwW8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AXr1xJ9xsuCjzTyvW2827Y7vv2eBERDsEbuANeR9gAM=; b=WHd+HQDxGnSPJjmkKnSqaJlZlXTXlhk6BBY8YoA1vgV1t7dC/g57NbrN5zsduVIW9B2V/dLB8MIH7zYe9kv1NZMjcPE3+0NXWfr1LvgZX3h4j8vUBzpw+qU4AMwF+M9E22el2Y4OszkPyWs/K1slU0ERB6Cr2akZOFFcVOU4sOwkaDzqji1f60iYx2s25i+/iNunOj+xavhoaJWLYRXT6aQGSmRazNq+cenoVJbLjdW52E02d4W+3b8Bk344Xp5PzPPprf/+KwvKalCPBemX+HJfp5hndEFK2yyoSZLWUnHk6Joyvp1TSSMT1WZBowFxKB9L+91dQGMj9Y16wP6RHg== Received: from BN9P222CA0008.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::13) by BL1PR12MB5254.namprd12.prod.outlook.com (2603:10b6:208:31e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.19; Tue, 10 Aug 2021 11:46:44 +0000 Received: from BN8NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::fe) by BN9P222CA0008.outlook.office365.com (2603:10b6:408:10c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17 via Frontend Transport; Tue, 10 Aug 2021 11:46:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT064.mail.protection.outlook.com (10.13.176.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4394.16 via Frontend Transport; Tue, 10 Aug 2021 11:46:44 +0000 Received: from sw-mtx-036.mtx.labs.mlnx (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 10 Aug 2021 11:46:42 +0000 From: Parav Pandit To: , , CC: Parav Pandit , Jiri Pirko , "Leon Romanovsky" Subject: [PATCH net-next 07/10] net/mlx5: Fix unpublish devlink parameters Date: Tue, 10 Aug 2021 14:46:17 +0300 Message-ID: <20210810114620.8397-8-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210810114620.8397-1-parav@nvidia.com> References: <20210810114620.8397-1-parav@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bbf06065-58ea-457c-834e-08d95bf486ed X-MS-TrafficTypeDiagnostic: BL1PR12MB5254: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:854; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DuvJcqJPMekiuUPwJgU217Nh3YxHC8/79tSNfkPzQ3WBTNHYAXykbIjrbA+xOCHva3OPS7VoqIVuadQFtny9m7qpaEDTroQzBHc2prmpN2SPOgCnL9KMaXmd4biAqyTrDy6FWnqMIeK7HcUTjFI3bqgBQJbdSIyXSQo5axGzA84FIoAOfor9Np9Mub+9l1K9G1fB59p8O1joggUbCvenM82kOAdqIzJStFixE0YiZrxmwDaXLZSfzix7vVT+Zv/6kXxN/I+4GOlY+ZAWgrSgOz6bgTzUJ2XX6DtgOkRTwKYU7q0oFhs9xhjFS3C+TRVMOUrEaMuvxwFO8XAj4F5D40lOyogPPFivQH8jfNAUpe2u3nes9OgUV1BUfMJXW+mRDdg4sYn69OJTp2vybsr8S+YcAY0+q2dD0pUqQHM8h8YtFX5kyrZ9hOm6ChSXItLVeOJOZLIWYPJkdkBJ4zGU2bnP8YW/dgMc2IPMwdUlUlDICEeLJyUQoqz6dBfI8lM/EUjpVV/BI2UT46ozCzbLCPVkDUtKJuWv/sxFeM3gZGjm0TvTeAWmqQnyYMCQJ49+4I2SZQSd/q/MQe0579mFMAprvDOhyvDEnYIpRXH65HH6deipxda+rJ1O7kicOvyuxKytceFUsYkTvsJ8US+zQ+XVOu9t8BTOgyU1e5gkv1AMgYGKs9H6hQGTBT7yTD2+PyXrcEVHRl9UK+ZiZFP4SQ== X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(356005)(86362001)(36756003)(336012)(6666004)(2616005)(8936002)(426003)(1076003)(8676002)(36860700001)(47076005)(82310400003)(16526019)(7636003)(70586007)(70206006)(2906002)(508600001)(26005)(186003)(4326008)(5660300002)(36906005)(316002)(110136005)(54906003)(107886003)(4744005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2021 11:46:44.1787 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bbf06065-58ea-457c-834e-08d95bf486ed X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5254 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Cleanup routine missed to unpublish the parameters. Add it. Fixes: e890acd5ff18 ("net/mlx5: Add devlink flow_steering_mode parameter") Signed-off-by: Parav Pandit Reviewed-by: Jiri Pirko Reviewed-by: Leon Romanovsky --- drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index f38553ff538b..0ec446d0fd6a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -671,6 +671,7 @@ int mlx5_devlink_register(struct devlink *devlink) void mlx5_devlink_unregister(struct devlink *devlink) { mlx5_devlink_traps_unregister(devlink); + devlink_params_unpublish(devlink); devlink_params_unregister(devlink, mlx5_devlink_params, ARRAY_SIZE(mlx5_devlink_params)); devlink_unregister(devlink); From patchwork Tue Aug 10 11:46:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 12428761 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 X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9639DC432BE for ; Tue, 10 Aug 2021 11:47:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E57D60EBB for ; Tue, 10 Aug 2021 11:47:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240285AbhHJLr1 (ORCPT ); Tue, 10 Aug 2021 07:47:27 -0400 Received: from mail-bn8nam11on2085.outbound.protection.outlook.com ([40.107.236.85]:24129 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240266AbhHJLrI (ORCPT ); Tue, 10 Aug 2021 07:47:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kiItoetZsKfT0pyifLfwtrc8GL3dquFElZwFF/HVQHpuCxfoxtc+JhpciqpvdPwY/TF/3hnXZ5X98s57HJys4s7MwTCl8Nx+KUFQ2RdtEfe0xtmHHvL0XrpK60gMJPW3proHa0trgdhKsmJYjyPbNatSY3fdj3gcoEGAprfi+IVfcq41VOk9LCoyX/yogvN+YHG+yWWK3ImWet4YlGoFzjvTJZzsWtDtnPbp6x/WaeB3s5m0ajSVB6FMszWoqacpYcKZ6WZTbLhaK2DufKa0g+WiV/9Dhh3zHYSh/IQsMTGrWzA2YMPWzWEg956msNM3p/9+wLPeIVSaDylP3jNX8A== 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-SenderADCheck; bh=U1HicVjzcJPAfyQKAKYqTxta5g8FHZk/th/PL0AvTeg=; b=ZwvR0yH8/gfbr17cKeuj3fBcQbdmFuE7LPe1+eDL/JPKMtVKOSyyhokv1qCIG21tMrrVL28LB0qd2eA/U+PCjDgBlW27AcgVpFRK/5P1T3EuWG6Zl5cKJHOgUHP+U6c11RV9Wlb6FIMYk0ldCKsK5Rxylq8sXeGsFrwM+gpSZO465bppboeTXofMV8suQy/TqcKShpa+QvvfLV39wZUjTaSe6NW2wjKJhd5PmPVhF8wc9pfai4ZDYLF9HNPe2/nQFkQNmtFBLSfcwIh815PDCvyjXPqrMFbzLwoFj9b37xL81zKa1JBTPcn3nTU8QlDDFWQa8J5VOEeWdwmLcijrtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U1HicVjzcJPAfyQKAKYqTxta5g8FHZk/th/PL0AvTeg=; b=PdfFs3IoKW0+Egmag/IWewv7KXHhOUaBlJ4sJFGSwMV37kXdhwF5AHGa09zrXau+1el4twsTXKWAFvEMbnGJsF43Shw+d0un6oxdETWk5W6zoykbBXRXKM522KGmqGBIJWXtACW2VLkC4m3x7AMPfMu2WPaHB2L63ikqWDSwpAdbLBsV/WVavvzzH53B/YYQsfkTpjKTjItppDLVFAEh6LLgFrSMZhrpxs+AsAG9lc6+KyyqcA21smTnSkBjKg+boku/ZSy7Rpm7vfFLWhryU+WhkuLlbxVEygmODpiJ0I0gQt64KesAjHqqJHBv+mAcCFiQAsl2fL6tT4jdX/4ilA== Received: from BN9P222CA0006.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::11) by BN9PR12MB5068.namprd12.prod.outlook.com (2603:10b6:408:135::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.18; Tue, 10 Aug 2021 11:46:45 +0000 Received: from BN8NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::fc) by BN9P222CA0006.outlook.office365.com (2603:10b6:408:10c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.14 via Frontend Transport; Tue, 10 Aug 2021 11:46:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT064.mail.protection.outlook.com (10.13.176.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4394.16 via Frontend Transport; Tue, 10 Aug 2021 11:46:45 +0000 Received: from sw-mtx-036.mtx.labs.mlnx (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 10 Aug 2021 11:46:43 +0000 From: Parav Pandit To: , , CC: Parav Pandit , Leon Romanovsky Subject: [PATCH net-next 08/10] net/mlx5: Support enable_eth devlink dev param Date: Tue, 10 Aug 2021 14:46:18 +0300 Message-ID: <20210810114620.8397-9-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210810114620.8397-1-parav@nvidia.com> References: <20210810114620.8397-1-parav@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e970e71-38f7-4014-6409-08d95bf48775 X-MS-TrafficTypeDiagnostic: BN9PR12MB5068: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gwOFOS5WGS3dSHeLr9/LuSs5WY/Grk/8leI42dKLCniikIuZl+P016aOZ62h7WnPUqs/o1zBwxdV9VOXmJBJcJI5W/zaphf+ciB42SuuvJyHNZC98KKxA4sqFEcb+RhfA4/GSaJcFVRHcRZ4LKbhEt7BUbXIj07MIQ944yOggUbDyqbEuBnOJjwcltK7CJzhY56W+Z4pPY1itDoTIR8NI1xxj+BfrPQ1WZoUXsnz2We5iFwjnKas0ld3UXRibnFKsZdAam3K83l2s/NHtkGzNaxSK1XeHo6jS9l18nmvh/4qIqZLyDMED4kftktMCbVoz+THJAjvroKewJTw/DJ/+zAPGcV9jGDXk6CvhMqiaS+iZBbSjobFnhFlx2JUHa2DBqIL/TGegvDQkJ7T47/300NttTX4J7jeHYVmiLSIZTlTtl9Ujpw+AsEzhWcMJA+Q+XJLpUXlYjhHsTm7UWDHIx8tsLQYsBGLUObl+iTs9eGff64cAFtWDrwEl3lpORF8TtVLQg7c8lZC+WO5+JJe4t4ftvBy4ADTnIN5cOnSzq7PZ6UReu9QwHXD/b3DvHmWksQYQPsYahxZErzM9slwqB1HzWJ2FCaU0GR7QlUBJt57n6U/004pwU3LWQNrqyrNe0RRtQlbmXxVjt8+0KorYGZhGVpanmU3JHX2b63fHzlfqPfHomqcxOkm6gpI/3SjPGmG60TC6OSBKSJq3nmAkg== X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(136003)(376002)(39860400002)(346002)(396003)(36840700001)(46966006)(7636003)(36906005)(2906002)(316002)(86362001)(82740400003)(26005)(36756003)(336012)(82310400003)(36860700001)(83380400001)(107886003)(1076003)(2616005)(70206006)(47076005)(110136005)(54906003)(16526019)(4326008)(186003)(6666004)(356005)(8936002)(5660300002)(8676002)(478600001)(426003)(70586007);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2021 11:46:45.0792 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e970e71-38f7-4014-6409-08d95bf48775 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5068 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Enable user to disable Ethernet auxiliary device so that when it is not required, user can disable it. For example, $ devlink dev param set pci/0000:06:00.0 \ name enable_eth value false cmode driverinit $ devlink dev reload pci/0000:06:00.0 At this point devlink instance do not create mlx5_core.eth.2 auxiliary device for the Ethernet functionality. Signed-off-by: Parav Pandit Reviewed-by: Leon Romanovsky --- drivers/net/ethernet/mellanox/mlx5/core/dev.c | 42 ++++++++++++++- .../net/ethernet/mellanox/mlx5/core/devlink.c | 53 +++++++++++++++++++ .../ethernet/mellanox/mlx5/core/mlx5_core.h | 3 ++ 3 files changed, 96 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c index def2156e50ee..10c4309f29be 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c @@ -53,7 +53,7 @@ static bool is_eth_rep_supported(struct mlx5_core_dev *dev) return true; } -static bool is_eth_supported(struct mlx5_core_dev *dev) +bool mlx5_eth_supported(struct mlx5_core_dev *dev) { if (!IS_ENABLED(CONFIG_MLX5_CORE_EN)) return false; @@ -105,6 +105,17 @@ static bool is_eth_supported(struct mlx5_core_dev *dev) return true; } +static bool is_eth_enabled(struct mlx5_core_dev *dev) +{ + union devlink_param_value val; + int err; + + err = devlink_param_driverinit_value_get(priv_to_devlink(dev), + DEVLINK_PARAM_GENERIC_ID_ENABLE_ETH, + &val); + return err ? false : val.vbool; +} + static bool is_vnet_supported(struct mlx5_core_dev *dev) { if (!IS_ENABLED(CONFIG_MLX5_VDPA_NET)) @@ -201,13 +212,15 @@ enum { static const struct mlx5_adev_device { const char *suffix; bool (*is_supported)(struct mlx5_core_dev *dev); + bool (*is_enabled)(struct mlx5_core_dev *dev); } mlx5_adev_devices[] = { [MLX5_INTERFACE_PROTOCOL_VNET] = { .suffix = "vnet", .is_supported = &is_vnet_supported }, [MLX5_INTERFACE_PROTOCOL_IB] = { .suffix = "rdma", .is_supported = &is_ib_supported }, [MLX5_INTERFACE_PROTOCOL_ETH] = { .suffix = "eth", - .is_supported = &is_eth_supported }, + .is_supported = &mlx5_eth_supported, + .is_enabled = &is_eth_enabled }, [MLX5_INTERFACE_PROTOCOL_ETH_REP] = { .suffix = "eth-rep", .is_supported = &is_eth_rep_supported }, [MLX5_INTERFACE_PROTOCOL_IB_REP] = { .suffix = "rdma-rep", @@ -308,6 +321,14 @@ int mlx5_attach_device(struct mlx5_core_dev *dev) if (!priv->adev[i]) { bool is_supported = false; + if (mlx5_adev_devices[i].is_enabled) { + bool enabled; + + enabled = mlx5_adev_devices[i].is_enabled(dev); + if (!enabled) + continue; + } + if (mlx5_adev_devices[i].is_supported) is_supported = mlx5_adev_devices[i].is_supported(dev); @@ -360,6 +381,14 @@ void mlx5_detach_device(struct mlx5_core_dev *dev) if (!priv->adev[i]) continue; + if (mlx5_adev_devices[i].is_enabled) { + bool enabled; + + enabled = mlx5_adev_devices[i].is_enabled(dev); + if (!enabled) + goto skip_suspend; + } + adev = &priv->adev[i]->adev; /* Auxiliary driver was unbind manually through sysfs */ if (!adev->dev.driver) @@ -447,12 +476,21 @@ static void delete_drivers(struct mlx5_core_dev *dev) if (!priv->adev[i]) continue; + if (mlx5_adev_devices[i].is_enabled) { + bool enabled; + + enabled = mlx5_adev_devices[i].is_enabled(dev); + if (!enabled) + goto del_adev; + } + if (mlx5_adev_devices[i].is_supported && !delete_all) is_supported = mlx5_adev_devices[i].is_supported(dev); if (is_supported) continue; +del_adev: del_adev(&priv->adev[i]->adev); priv->adev[i] = NULL; } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index 0ec446d0fd6a..557973c9212f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -596,6 +596,52 @@ static void mlx5_devlink_set_params_init_values(struct devlink *devlink) #endif } +static const struct devlink_param enable_eth_param = + DEVLINK_PARAM_GENERIC(ENABLE_ETH, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), + NULL, NULL, NULL); + +static int mlx5_devlink_eth_param_register(struct devlink *devlink) +{ + struct mlx5_core_dev *dev = devlink_priv(devlink); + union devlink_param_value value; + int err; + + if (!mlx5_eth_supported(dev)) + return 0; + + err = devlink_param_register(devlink, &enable_eth_param); + if (err) + return err; + + value.vbool = true; + devlink_param_driverinit_value_set(devlink, + DEVLINK_PARAM_GENERIC_ID_ENABLE_ETH, + value); + devlink_param_publish(devlink, &enable_eth_param); + return 0; +} + +static void mlx5_devlink_eth_param_unregister(struct devlink *devlink) +{ + struct mlx5_core_dev *dev = devlink_priv(devlink); + + if (!mlx5_eth_supported(dev)) + return; + + devlink_param_unpublish(devlink, &enable_eth_param); + devlink_param_unregister(devlink, &enable_eth_param); +} + +static int mlx5_devlink_auxdev_params_register(struct devlink *devlink) +{ + return mlx5_devlink_eth_param_register(devlink); +} + +static void mlx5_devlink_auxdev_params_unregister(struct devlink *devlink) +{ + mlx5_devlink_eth_param_unregister(devlink); +} + #define MLX5_TRAP_DROP(_id, _group_id) \ DEVLINK_TRAP_GENERIC(DROP, DROP, _id, \ DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \ @@ -654,6 +700,10 @@ int mlx5_devlink_register(struct devlink *devlink) mlx5_devlink_set_params_init_values(devlink); devlink_params_publish(devlink); + err = mlx5_devlink_auxdev_params_register(devlink); + if (err) + goto auxdev_reg_err; + err = mlx5_devlink_traps_register(devlink); if (err) goto traps_reg_err; @@ -661,6 +711,8 @@ int mlx5_devlink_register(struct devlink *devlink) return 0; traps_reg_err: + mlx5_devlink_auxdev_params_unregister(devlink); +auxdev_reg_err: devlink_params_unregister(devlink, mlx5_devlink_params, ARRAY_SIZE(mlx5_devlink_params)); params_reg_err: @@ -671,6 +723,7 @@ int mlx5_devlink_register(struct devlink *devlink) void mlx5_devlink_unregister(struct devlink *devlink) { mlx5_devlink_traps_unregister(devlink); + mlx5_devlink_auxdev_params_unregister(devlink); devlink_params_unpublish(devlink); devlink_params_unregister(devlink, mlx5_devlink_params, ARRAY_SIZE(mlx5_devlink_params)); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h index 343807ac2036..b3dfecf4f433 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h @@ -270,4 +270,7 @@ static inline u32 mlx5_sriov_get_vf_total_msix(struct pci_dev *pdev) return MLX5_CAP_GEN_MAX(dev, num_total_dynamic_vf_msix); } + +bool mlx5_eth_supported(struct mlx5_core_dev *dev); + #endif /* __MLX5_CORE_H__ */ From patchwork Tue Aug 10 11:46:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 12428759 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 X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8823AC4338F for ; Tue, 10 Aug 2021 11:47:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6369D6023E for ; Tue, 10 Aug 2021 11:47:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240341AbhHJLrZ (ORCPT ); Tue, 10 Aug 2021 07:47:25 -0400 Received: from mail-dm6nam11on2085.outbound.protection.outlook.com ([40.107.223.85]:12481 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240267AbhHJLrJ (ORCPT ); Tue, 10 Aug 2021 07:47:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kxPZ2Y19yNZ0W/kJciLRU8h6jY2SAkUhrqkdNDVgZ9B9tEQHF0S4vo9OR9c2WasUyoqaOEpZ3mt1gwM/ogrV3KDFOCgK/XAfRcpKwemxwtIaUH55/usfh7+5RYi/UE8JJZeABQEED6z7GJ9zCeeFg/qwTsG7J7jqHanQfisk/mRezgxE7yPtca8VpxwHwCglpsYAzcquzD6Cmu8bp2BfHL03P/va/1dFLlWuCGuzhG44SsKWHklA6Ktt23XlKAWoNOyhUlLduBUq5ETsoUz4bH4uLgAKMl8cHyyH2uduKyqnHlPOy+igNknvbBA+hx6XrS+rooTeE3oHU+bH8Zi5rA== 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-SenderADCheck; bh=2iXo4z2/Ri5/oZGcxg8c8pCO+V3MDICBW3Ltzca7OPw=; b=HEm9PNt/cx/AxVePZsoB/MNspnT28ay4U4BCc+zJGnPtPeeu5LYdqLy60PUPUONXkIMtDU0yPHSVIdD9Cr3tcvL/NBeTbBbQwF+dMayVsklJb6QgTnPgsD98X6rkaQmcivQ6YqXqy8Hnk4oPmHBmr01vz146neCXLSHKnDeGdK85MlJrxxr/0m/ayaNC+GbsZyg9fN8beUvpjzisrAjpIxB4cGmJzQhGHIhQ5N56kgoCeYE9bMYqbnZF3/3OcbcejCgjBomgP+1abZsIOu+k8nHoTZf7HNjDDc3Mh9eosQohSk1MiqPeD6cMJYwXb2FT6jJk0PNpkc8J093BY5mwGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2iXo4z2/Ri5/oZGcxg8c8pCO+V3MDICBW3Ltzca7OPw=; b=nzVlBk0tkGBelk4hu5il6K3Tvy2tsZDjHhGmGEEhJYVWo/neyRLQvv+LRFIvNAjz3NOuOy33e50Kle/CskW8oalCVqdq0Q3HqXiBU/vWBgTc2/2iIK9uCwy/LtxQ9lzP0vYbsg2vDhYnEFvgQBOQA6chieauAymPSyIDz0dMsN+gjy+23zt++Z3QQgIuRsaylTC3sKyarQkUxC4vo2YSygCTcVYlZ1bQGmbSjqsa0cDUmVYf0C0UARJtnqyufmZMp/QMJRaN2DZ0j3SjDDRoexVSSxKzu3xnoaaJ/5mzhDFsVXEddVo/ZKIkHFATORQGLnMJyTgMbXoNR40Crpovzw== Received: from BN9P222CA0026.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::31) by BYAPR12MB2998.namprd12.prod.outlook.com (2603:10b6:a03:dd::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15; Tue, 10 Aug 2021 11:46:45 +0000 Received: from BN8NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::1) by BN9P222CA0026.outlook.office365.com (2603:10b6:408:10c::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Tue, 10 Aug 2021 11:46:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT064.mail.protection.outlook.com (10.13.176.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4394.16 via Frontend Transport; Tue, 10 Aug 2021 11:46:45 +0000 Received: from sw-mtx-036.mtx.labs.mlnx (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 10 Aug 2021 11:46:43 +0000 From: Parav Pandit To: , , CC: Parav Pandit , Leon Romanovsky Subject: [PATCH net-next 09/10] net/mlx5: Support enable_rdma devlink dev param Date: Tue, 10 Aug 2021 14:46:19 +0300 Message-ID: <20210810114620.8397-10-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210810114620.8397-1-parav@nvidia.com> References: <20210810114620.8397-1-parav@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 90dadf90-df67-4a0e-ea74-08d95bf487b3 X-MS-TrafficTypeDiagnostic: BYAPR12MB2998: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wXzlcJCqd0s5juT4ay7iHmNZCqLiDrp2isc3bONfFbAgtMBgX81yeQKHMKSdF+YKe8y4c8xnnt/R2TKyPsPdxoTJjjZpEhiyyhAXCfGvJLFfckbms1p2NE7apNhBnpxQY6VkosuswgxuHDwWy6KmfWSrkoBqsJYINr1H0hubdsJKWfrOJUpSsZBa2U3u0T3gu03Gpdx1N3yu3ttA8Rykosm70QGn4DF8OQASbuBZexTczoLq33xBHbfCSHfYAOntpLn+juUcG0qJyZ7r0VM7K13OS8lt6RMeW8wjbENmem8GdAfRQw+/XcPwi2F0IN+wBH1jQZWBplTwhzCvrMAJXGaRQJaT0+PxmdU/vgjjeYJFkFFGKrNjTvVKOyjOdWRlMf0x4LBw2C4tHK2e2xaeq4vlBvTQCwoPpg2ZWk7w94hDn3AQS05QRonxAqHa2JMvwuBXajENhvO+VkQAFynWXvaPTJtbPc77eFdcPack7xO+7qoxPLb+m5155TpGTvbavotwxyja5N3OjGWG9hiDEzwnALFlqebOwZbWAVzHFflzXM4wMQr4EZUuSoqY+2KFNrEIh6C/j+nTLBa5nwcZpmwD1nTo8FzQKIG0vMOXYw/Pntx+fkCRLbr8h/aoCmuLY0SE0s+Astln5uQ35FfxX+dCCXan5KSC71Yi6wKq+6SHC/AkhGr6C9Uzbp4XjjGPNwK54OV8qBkKosk/i2Uiyg== X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(396003)(39860400002)(346002)(376002)(136003)(46966006)(36840700001)(36860700001)(86362001)(26005)(36756003)(8676002)(82740400003)(4326008)(336012)(8936002)(478600001)(7636003)(36906005)(1076003)(6666004)(16526019)(5660300002)(83380400001)(316002)(110136005)(54906003)(47076005)(2616005)(356005)(70206006)(186003)(426003)(70586007)(107886003)(2906002)(82310400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2021 11:46:45.4859 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90dadf90-df67-4a0e-ea74-08d95bf487b3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2998 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Enable user to disable RDMA auxiliary device so that when it is not required, user can disable it. For example, $ devlink dev param set pci/0000:06:00.0 \ name enable_rdma value false cmode driverinit $ devlink dev reload pci/0000:06:00.0 At this point devlink instance do not create auxiliary device mlx5_core.rdma.2 for the RDMA functionality. Signed-off-by: Parav Pandit Reviewed-by: Leon Romanovsky --- drivers/net/ethernet/mellanox/mlx5/core/dev.c | 16 ++++- .../net/ethernet/mellanox/mlx5/core/devlink.c | 65 ++++++++++++++++++- .../ethernet/mellanox/mlx5/core/mlx5_core.h | 1 + 3 files changed, 79 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c index 10c4309f29be..cb86844099c0 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c @@ -181,7 +181,7 @@ static bool is_mp_supported(struct mlx5_core_dev *dev) return true; } -static bool is_ib_supported(struct mlx5_core_dev *dev) +bool mlx5_rdma_supported(struct mlx5_core_dev *dev) { if (!IS_ENABLED(CONFIG_MLX5_INFINIBAND)) return false; @@ -198,6 +198,17 @@ static bool is_ib_supported(struct mlx5_core_dev *dev) return true; } +static bool is_ib_enabled(struct mlx5_core_dev *dev) +{ + union devlink_param_value val; + int err; + + err = devlink_param_driverinit_value_get(priv_to_devlink(dev), + DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA, + &val); + return err ? false : val.vbool; +} + enum { MLX5_INTERFACE_PROTOCOL_ETH, MLX5_INTERFACE_PROTOCOL_ETH_REP, @@ -217,7 +228,8 @@ static const struct mlx5_adev_device { [MLX5_INTERFACE_PROTOCOL_VNET] = { .suffix = "vnet", .is_supported = &is_vnet_supported }, [MLX5_INTERFACE_PROTOCOL_IB] = { .suffix = "rdma", - .is_supported = &is_ib_supported }, + .is_supported = &mlx5_rdma_supported, + .is_enabled = &is_ib_enabled }, [MLX5_INTERFACE_PROTOCOL_ETH] = { .suffix = "eth", .is_supported = &mlx5_eth_supported, .is_enabled = &is_eth_enabled }, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index 557973c9212f..f247ffb325a9 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -632,13 +632,76 @@ static void mlx5_devlink_eth_param_unregister(struct devlink *devlink) devlink_param_unregister(devlink, &enable_eth_param); } +static int mlx5_devlink_enable_rdma_validate(struct devlink *devlink, u32 id, + union devlink_param_value val, + struct netlink_ext_ack *extack) +{ + struct mlx5_core_dev *dev = devlink_priv(devlink); + bool new_state = val.vbool; + + if (new_state && !mlx5_rdma_supported(dev)) + return -EOPNOTSUPP; + return 0; +} + +static const struct devlink_param enable_rdma_param = + DEVLINK_PARAM_GENERIC(ENABLE_RDMA, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), + NULL, NULL, mlx5_devlink_enable_rdma_validate); + +static int mlx5_devlink_rdma_param_register(struct devlink *devlink) +{ + struct mlx5_core_dev *dev = devlink_priv(devlink); + union devlink_param_value value; + int err; + + if (!IS_ENABLED(CONFIG_MLX5_INFINIBAND) || MLX5_ESWITCH_MANAGER(dev)) + return 0; + + err = devlink_param_register(devlink, &enable_rdma_param); + if (err) + return err; + + value.vbool = true; + devlink_param_driverinit_value_set(devlink, + DEVLINK_PARAM_GENERIC_ID_ENABLE_RDMA, + value); + devlink_param_publish(devlink, &enable_rdma_param); + return 0; +} + +static void mlx5_devlink_rdma_param_unregister(struct devlink *devlink) +{ + struct mlx5_core_dev *dev = devlink_priv(devlink); + + if (!IS_ENABLED(CONFIG_MLX5_INFINIBAND) || MLX5_ESWITCH_MANAGER(dev)) + return; + + devlink_param_unpublish(devlink, &enable_rdma_param); + devlink_param_unregister(devlink, &enable_rdma_param); +} + static int mlx5_devlink_auxdev_params_register(struct devlink *devlink) { - return mlx5_devlink_eth_param_register(devlink); + int err; + + err = mlx5_devlink_eth_param_register(devlink); + if (err) + return err; + + err = mlx5_devlink_rdma_param_register(devlink); + if (err) + goto rdma_err; + + return 0; + +rdma_err: + mlx5_devlink_eth_param_unregister(devlink); + return err; } static void mlx5_devlink_auxdev_params_unregister(struct devlink *devlink) { + mlx5_devlink_rdma_param_unregister(devlink); mlx5_devlink_eth_param_unregister(devlink); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h index b3dfecf4f433..b36fbcdc048e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h @@ -272,5 +272,6 @@ static inline u32 mlx5_sriov_get_vf_total_msix(struct pci_dev *pdev) } bool mlx5_eth_supported(struct mlx5_core_dev *dev); +bool mlx5_rdma_supported(struct mlx5_core_dev *dev); #endif /* __MLX5_CORE_H__ */ From patchwork Tue Aug 10 11:46:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 12428763 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 X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7501FC4338F for ; Tue, 10 Aug 2021 11:47:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E4D3604D7 for ; Tue, 10 Aug 2021 11:47:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240302AbhHJLrb (ORCPT ); Tue, 10 Aug 2021 07:47:31 -0400 Received: from mail-bn8nam12on2066.outbound.protection.outlook.com ([40.107.237.66]:29665 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240274AbhHJLrK (ORCPT ); Tue, 10 Aug 2021 07:47:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GG0n6bPkfKb2bUkZ6m8DN8DbzEQHJjPDJ0pYVeej/t49aE+rJQNr8kX0ES3DD4+Jxu238sXY7BmN/s+gY+GylcPmngpFxvWUetB2Oh9Vszky3jcKFTHs2zQK66kUbflWxh3OQdJZc+k4qPyOK2lvfXUXYNoBkWjIk744ausOPUknknCaWy/UKu+88NUiymCP6dJpO1DQwkoEsIjUw2v+JJpV9dxH1H9xcOTPM4zMHOVhm18CK3pUd/wYFi5PLcMDCOEp2S893saAoDHJb5E6LVq2vTP59cIA1KyepYikNKfTiNyKGbZVkGTSVLq93ObGf3rP7hGUEd32mnjRgILcww== 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-SenderADCheck; bh=oIi8hzPJyZfyI2sfgdbiTFzKy/YbYasDVyImO8S2Rt8=; b=MP+B6pdKUUkZklP7payBnKwZWrKp0glyiEdIuXmIwfxcQv5W5WqhSCohihG6Zcd8tKDloEsXClCY+mLokjtNeltVJI09MC3IDZ5zvpDhmbCvzYDxcqvrqtw2lMyK9CUdp+Xv9sR5JUbON0cJnLL4Bbwc5JZZ+c2ATTXfZMI3PXK6zHma4zWfTrZSDl+Tv8Azl+XJKU7mmx4cul8Y8n+SvaeHtVnylbLvFg/mlkVJLpiftVjx6mE/ngXo6GN9UW+2o3inviOi2Xnzf8JBXuc1oa2pNKINZ1X/cTNPQYYtUjADNDJ2+UB6zSFlu+fFPLW0pFJuoxgPjePG3+pCI3jjGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oIi8hzPJyZfyI2sfgdbiTFzKy/YbYasDVyImO8S2Rt8=; b=Ph1x0Rnnavzh5jcjGjx84BOX1pbiLkfXFckcO8enU93sxzDxNq1MJ391WODq958JZ0YheZBAmx0/ODcc/yJhZJKljMUfKLuB31oNIjJUVlXrM5gvgMr98LhufdmJcbWwpunoxCderJJ+QeNR1QsxuIasMVMljXY0MeKCL0SY2foNv41V3L44fyp/skfH9ggA0EI+iCuClZI3XnZrZbBP5/I6YSZZfjmEWc013+8k7kyFH6W5y6SRpAMaYhC0f+GbJRD84b/Mu5xHPGstwn2GA/BbyxP2muMCAJoHVC1yv7VwJAO/VZii0iib0hjk81mAZ7zWlBqZ5h6QNnQBABRrLA== Received: from BN9P222CA0018.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::23) by BYAPR12MB2648.namprd12.prod.outlook.com (2603:10b6:a03:69::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15; Tue, 10 Aug 2021 11:46:46 +0000 Received: from BN8NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::35) by BN9P222CA0018.outlook.office365.com (2603:10b6:408:10c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17 via Frontend Transport; Tue, 10 Aug 2021 11:46:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT064.mail.protection.outlook.com (10.13.176.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4394.16 via Frontend Transport; Tue, 10 Aug 2021 11:46:46 +0000 Received: from sw-mtx-036.mtx.labs.mlnx (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 10 Aug 2021 11:46:44 +0000 From: Parav Pandit To: , , CC: Parav Pandit , Leon Romanovsky Subject: [PATCH net-next 10/10] net/mlx5: Support enable_vnet devlink dev param Date: Tue, 10 Aug 2021 14:46:20 +0300 Message-ID: <20210810114620.8397-11-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210810114620.8397-1-parav@nvidia.com> References: <20210810114620.8397-1-parav@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e8519c82-8d6c-4402-39e5-08d95bf4881c X-MS-TrafficTypeDiagnostic: BYAPR12MB2648: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ikY3NHrw4Fbl3g1VkeEU6oGCLo+NbAw5/WArPxtmd89K/X6ARRobRe0S5MOG28r83yV+PUhwpbIDLsq02XhipINYfPNStzrJHAKewChPqwnG3mfZEV68cu/SN5XEMghT/eaURuModacGazhYI+4rSOQ0642jTeZvZRnTxGeynO7ESFcQsJWIjiEzUSXJCV+QLMAKg7Sm2WV+LQE1jVvq6lSSQlILzL8c59V/FBWKz4WWbLYKk5T/yrmkaguOFp+NGFZOFoGe0vIc7IMCWICbQVUxeKQQNJjcdywGe6MUCzcJGbfQte7f8HXr2FGZBXRoO2tD3w2iPyQsn5yew1KFHQGjAgKDbwt5i6MoIvrZjfX11W0f1+efhzXKG2/G+uI/4uLMxAvIXyTCBAXdBCbK82eBHTH3MpRsN2P8OsEGPXogdu90aSx6iZt5Snuz3qF8s6YNgRR768+i2IBnmy0BFGxBJMBBzuJ5xnOg+0r7fvIOeOzWmCkpnmiEZf4qrc7TBqCEFztr5O7AYLvgsiB5OwsfRPzPQ8lmYrqqPpw9W82hfeqlVBb1rL8Q2FqmSMYnUF68mtquTnflSy35SbLb/wSJChP+ibN34EJ7y1kuPB0LbS0zxvR7nXUfIQyEXREO7s9NtdUlwo0HNCB690rNVJJ6KYzyN63MYBCIbCx31Pa8ce9dA0iDgxjHTkWHp7R++AaO4X1aoEHj9w4mn3sRmQ== X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(39860400002)(136003)(396003)(346002)(376002)(46966006)(36840700001)(110136005)(1076003)(82740400003)(36860700001)(54906003)(316002)(83380400001)(2616005)(36756003)(36906005)(356005)(426003)(2906002)(82310400003)(8676002)(86362001)(4326008)(26005)(8936002)(336012)(70206006)(478600001)(16526019)(186003)(7636003)(47076005)(6666004)(5660300002)(107886003)(70586007);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2021 11:46:46.1655 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e8519c82-8d6c-4402-39e5-08d95bf4881c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2648 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Enable user to disable VDPA net auxiliary device so that when it is not required, user can disable it. For example, $ devlink dev param set pci/0000:06:00.0 \ name enable_vnet value false cmode driverinit $ devlink dev reload pci/0000:06:00.0 At this point devlink instance do not create auxiliary device mlx5_core.vnet.2 for the VDPA net functionality. Signed-off-by: Parav Pandit Reviewed-by: Leon Romanovsky --- drivers/net/ethernet/mellanox/mlx5/core/dev.c | 16 ++++++- .../net/ethernet/mellanox/mlx5/core/devlink.c | 42 +++++++++++++++++++ .../ethernet/mellanox/mlx5/core/mlx5_core.h | 1 + 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c index cb86844099c0..ff6b03dc7e32 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c @@ -116,7 +116,7 @@ static bool is_eth_enabled(struct mlx5_core_dev *dev) return err ? false : val.vbool; } -static bool is_vnet_supported(struct mlx5_core_dev *dev) +bool mlx5_vnet_supported(struct mlx5_core_dev *dev) { if (!IS_ENABLED(CONFIG_MLX5_VDPA_NET)) return false; @@ -138,6 +138,17 @@ static bool is_vnet_supported(struct mlx5_core_dev *dev) return true; } +static bool is_vnet_enabled(struct mlx5_core_dev *dev) +{ + union devlink_param_value val; + int err; + + err = devlink_param_driverinit_value_get(priv_to_devlink(dev), + DEVLINK_PARAM_GENERIC_ID_ENABLE_VNET, + &val); + return err ? false : val.vbool; +} + static bool is_ib_rep_supported(struct mlx5_core_dev *dev) { if (!IS_ENABLED(CONFIG_MLX5_INFINIBAND)) @@ -226,7 +237,8 @@ static const struct mlx5_adev_device { bool (*is_enabled)(struct mlx5_core_dev *dev); } mlx5_adev_devices[] = { [MLX5_INTERFACE_PROTOCOL_VNET] = { .suffix = "vnet", - .is_supported = &is_vnet_supported }, + .is_supported = &mlx5_vnet_supported, + .is_enabled = &is_vnet_enabled }, [MLX5_INTERFACE_PROTOCOL_IB] = { .suffix = "rdma", .is_supported = &mlx5_rdma_supported, .is_enabled = &is_ib_enabled }, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index f247ffb325a9..6f4d7c7f06e0 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -680,6 +680,42 @@ static void mlx5_devlink_rdma_param_unregister(struct devlink *devlink) devlink_param_unregister(devlink, &enable_rdma_param); } +static const struct devlink_param enable_vnet_param = + DEVLINK_PARAM_GENERIC(ENABLE_VNET, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), + NULL, NULL, NULL); + +static int mlx5_devlink_vnet_param_register(struct devlink *devlink) +{ + struct mlx5_core_dev *dev = devlink_priv(devlink); + union devlink_param_value value; + int err; + + if (!mlx5_vnet_supported(dev)) + return 0; + + err = devlink_param_register(devlink, &enable_vnet_param); + if (err) + return err; + + value.vbool = true; + devlink_param_driverinit_value_set(devlink, + DEVLINK_PARAM_GENERIC_ID_ENABLE_VNET, + value); + devlink_param_publish(devlink, &enable_rdma_param); + return 0; +} + +static void mlx5_devlink_vnet_param_unregister(struct devlink *devlink) +{ + struct mlx5_core_dev *dev = devlink_priv(devlink); + + if (!mlx5_vnet_supported(dev)) + return; + + devlink_param_unpublish(devlink, &enable_vnet_param); + devlink_param_unregister(devlink, &enable_vnet_param); +} + static int mlx5_devlink_auxdev_params_register(struct devlink *devlink) { int err; @@ -692,8 +728,13 @@ static int mlx5_devlink_auxdev_params_register(struct devlink *devlink) if (err) goto rdma_err; + err = mlx5_devlink_vnet_param_register(devlink); + if (err) + goto vnet_err; return 0; +vnet_err: + mlx5_devlink_rdma_param_unregister(devlink); rdma_err: mlx5_devlink_eth_param_unregister(devlink); return err; @@ -701,6 +742,7 @@ static int mlx5_devlink_auxdev_params_register(struct devlink *devlink) static void mlx5_devlink_auxdev_params_unregister(struct devlink *devlink) { + mlx5_devlink_vnet_param_unregister(devlink); mlx5_devlink_rdma_param_unregister(devlink); mlx5_devlink_eth_param_unregister(devlink); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h index b36fbcdc048e..2059b7319867 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h @@ -273,5 +273,6 @@ static inline u32 mlx5_sriov_get_vf_total_msix(struct pci_dev *pdev) bool mlx5_eth_supported(struct mlx5_core_dev *dev); bool mlx5_rdma_supported(struct mlx5_core_dev *dev); +bool mlx5_vnet_supported(struct mlx5_core_dev *dev); #endif /* __MLX5_CORE_H__ */