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: 494801 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 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: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: 494800 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 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: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: 494799 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 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: 494798 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 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__ */