From patchwork Wed Apr 13 15:17:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12812117 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD033C433F5 for ; Wed, 13 Apr 2022 15:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234831AbiDMPUo (ORCPT ); Wed, 13 Apr 2022 11:20:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231593AbiDMPUm (ORCPT ); Wed, 13 Apr 2022 11:20:42 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2064.outbound.protection.outlook.com [40.107.243.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0420C252AE for ; Wed, 13 Apr 2022 08:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aCgG+ZeH+80vIcx4y09meI4UHxxWmCDajlGBIUDE4pytmV0BuKlbDVx8wVhiA+Ysw2/P2wq5xRCl4KVGStm0hwX75xJRXPwPz2Er3TUJbL11naicpbEU3cvH3VR+0+LwMQJxJ/ydbaOubl4IrWSU9j77xgdN0u5DKKdt20wxAUklAB4NFlDuoMSUsSN3S9Ao49rkhnO3IqIuVZHkm0S5jYRHtyn6/EkbOKX0R+RhnIoQUj/bePrbQ9QgSh9EGLGpbPib8n972HpY8J6m8NIO0tRKlELujpsObad0FE4XPj3elzJGXU3HkKarhM2ZiaQd81v53n+MaTS/Gv2Ot+KYOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=39C+ETEiIdY2n7bjKdwz8FqoQDrH2o35ENkJwZg0yaQ=; b=Ml74jZwloJmIbfkGGwhGHdlhvvm5EVFcAqOSJLqMlYaFugAUhnbqUcopOOneP6V/m446ojiVWvVb3Y88koZ/L6ykjRj0yojOPFWBtrUrlHYtMUxzutbdgB6YNptOeU/d9eha38MbwJxack0OVXBvbhhsV8nuSp5qZWYcYDQCyQ+BPqbrgMKUcECKlWNXTauZ/OOV4rarka4TK8f1XMB1fK84DLM+AXuW63Iu/P0Uh9nYjVQBw3tJ4/eFGiLa3ewuk2xSJm8UHJ9lqyjtpMOoRwVjbR0soteXk7A73NrI9a65MPLCWqllN85R+DECt/qdwxwu8MmQ+MyGJeDQKugXyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=39C+ETEiIdY2n7bjKdwz8FqoQDrH2o35ENkJwZg0yaQ=; b=FwZzj+2VB0cJ1YEAkYKKb/3Qs3CE0X/pUFNJCH3+VmCcCaJw9ohq7QE9OJ2usZf/KJKvbj2zwmq1I9dWdHMN91sMSY203J6YZEhX+IEaye/nFJ1Wj4OKWXVLRovw1U5t8wxjj/aPKPRBRx96iTaVl6UGq1z4uHYOjWoPpH70iN5KZzONRd9Q0VuoUvkX+Vi1C0CGGUlF5ibOr44Vie/YYW9alcrgMS1KeIIeIJgwcB8D5Y6WikCUwdH2y78uYPCnCoMhDQ1uqHp9xIMYgy12Yo6sgbOHKbRji3gOqgnWhKzoHK9aGJTWlshme+bAppxKXnJ9a65Li0toGRjO65ICIA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by BL1PR12MB5238.namprd12.prod.outlook.com (2603:10b6:208:31e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29; Wed, 13 Apr 2022 15:18:15 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402%5]) with mapi id 15.20.5144.029; Wed, 13 Apr 2022 15:18:15 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, petrm@nvidia.com, vadimp@nvidia.com, jiri@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 1/9] mlxsw: core: Extend interfaces for cable info access with slot argument Date: Wed, 13 Apr 2022 18:17:25 +0300 Message-Id: <20220413151733.2738867-2-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220413151733.2738867-1-idosch@nvidia.com> References: <20220413151733.2738867-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR06CA0163.eurprd06.prod.outlook.com (2603:10a6:803:c8::20) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8cdfd604-2d78-4433-560f-08da1d60d502 X-MS-TrafficTypeDiagnostic: BL1PR12MB5238:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4Rs34qFPS213Awl287RRM3NWJpHngTyZMGmNo6n+PBLWBy0hg5dzT1OY1rffXyiyEVObfT4svR6KM26U8CcGA2/gmYeDrA3cczFCW5gIWRP2mWlMEnChzctOzOABQ34Z9t7CmyLtRPbLDTHJ/YL2i1noZfLcPb6Ckj00tnEIxZTCGPEa9oFPMEAMkPbsjDvWHDrg5RdpX7h9iVErDb3yIvhGQOI7DOY6QM9Kvf1Ex/xVotY+qHWNvindgy+nuwb5uPK3T3OYHdgymqqiVySGMOPzkjIDB246+NMcwp66EbX/JTU7a5Eu7/axEe06iqXLUmpb8VaOW3BNv9xYrXgpK/1R9K58+Vga745rLMM0orX1/e6p9DJl7F6UQEXCsaa0/f8R+gkkjamN/WXf3fbwobPYg1bNZlGDZsfdkIgKQ2vg2o6H6otyz+aSQZKTAOcnLLhR0KxA1oeU8BDvHBpxsOT8yvtqUtfhkS+pO0GhqSLGvBsqQ1YufDO+p1sgaCV+UqHdw3/H+uz16zU3etECHckBCJpLmH73qCgsADZOvPuN4MIIeCvhc/ktxMWW3XaIjNLFhBlPr+5oejqywdr8diYBINRhCoece9Vb4tGKCN+NWWtm2ZjjafcaA/DkHbPJGpolQpKWzX6VRZ/19AunDw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(508600001)(4326008)(1076003)(316002)(107886003)(38100700002)(6512007)(36756003)(5660300002)(30864003)(83380400001)(186003)(26005)(2906002)(6666004)(8676002)(86362001)(6506007)(2616005)(6486002)(66476007)(6916009)(66556008)(8936002)(66946007)(579004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cANyhNDf1rGfPGh0FkxePB/kK77PFrrVdcq9Y+DoJZofQOk4Fyv49y5Kio/bamchivGxM8k1VrY32VghRQKQSi9+axpAPm8pF52R5X37G97Bks58Ptb+EALy8E2q3csJNEnzrzTwtMLSO7ckMwWFH3BumkD98fwP5l6Cm9YR0qJGxAPnx/0Ed8gMmCSiVWIiD4Okb3uKpYXHSpaMTxbKN+YGiP2tfgAXRD0b6ARtNGovvOZfM/XwuvCz6RP8NWagZrynOlAmWL1Ki6Jkt7/2rwUIdSRHAJLT876w4WeV3xsRG9GA7WJszdQmc0YE87iHRCIXSRBXv5vJm+KHJgXx+UxdB1jLuWR8XPs8YT/QiZFqRBcJgCPjGeRYnVrb3gDSyagPowc5eXWVc0Y+J9Tzmp8cN9Ge1j6FFVkExtOk0XXPcKBozORnh7W1pGEvHLTVmiLsUxH8u7VCngwE0dY3juKqaM1+3mIQdaBXkut9XHblc2TeDd6aalPl6ND3dxntNBhWbUhKgagqY+xZDkM6WwIpF9BPODquu7iP/HjRhru9DGxh79ctRR0QBnhh0oOi5/v6uCDP6yVBJ9XpVnsEjf5X50p3kUvRMvct9+BbjKsjsd/+lxwJjFVRtIw1pRqo0GaUBd2NoCfaydMo8upEDyc/yXOhUwJ2kZTEEa6Qj7cxpEeLmYvAZlQrd2oZouegU9uzVprcLTiknhEYRxupP9gqx9JShYchXl74CepEGV5nC9ATtJAPaLfku2qBmFNYZgYUn3w3QIcu8VffVNBvm5R27lgfqpLxUzwGO46EbUoGvnybNDSNBTbUDOCAtHRp2aZIp7btZgvhCXQ8TIHSUsS7038Hl95TeNe2wftfShoR6t76mNCkImjH+NgaQQpN3DvwNKrRwhOuGFvjV/DmBKCb+BXDCk4+2Lf7RLRI14unkTxMlltBQRvfoUZC2xricPowuHbtdAC0CZJBtzN2mowvFY6Qpn+J4PWQV6+Wuu8UjiEzSpOG0g9k0+nC3LBRlEEVM6sgYh6UxuiLDD/C4nvKSy9ARRsq8rdQMShqnhoa4ZBQnA5EM1z745KdPqg3QTIHvlP2eSVcZgMu5Du7vCF0U/1RxL3PEmCr7tCnokoYqPZg3E8iWZvIyzGB49lr0SblOq1BP9Q7V0Pf5yrB8+s62eB1GQ5xD8rsMbPvpqMGLOyZMl57r0+Q/04Sx+jdXgjlJyPxG3PTwKkRmed85FzXD88WVHevLBuefyBEVQY84HCzgYtBjuW7g7L2rhyic1q7V02J1NfXLdktYwaAOT3dG31j3S//UOlpEX9XE2CrU32hq6ZTbEZ15AS0v8/HvpkbMgGX05HJQ2wp/Fsu+QuFypgVV2GOonpS6fehOvsbShCooXGotuuWW0X/ocl8g/qnpkEp2iieyxJXKKQJTIyMvSTGzQqZNaQRTMJfx9FzGYQGy0Zuhv/1E4PNxQ9zvKWfeHIQq/voouDqzqeSS+jr7KW3QExlweLa0iKdy+g+Vd+0YAH4+ETYNnUsyTPN1Kknjv0xWpWUFFO+FpgMPAZGBGn66Zw9W56LCPr8bKKdBeTW9G3h9MtkgJJYcg66qMMryqbv7GpHiaSK17rq+NVZPa9/hJKSvANkiewfIhPL3oxAYHfP9qX70Jdug5DS6zDXQ09M7domNbemON6crpQieQsP1uO2f2+Oz99zQREufTwY0D4YswTT9WV1UpcZoAd+H5Q3wAsoZjg/p9d/RA== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8cdfd604-2d78-4433-560f-08da1d60d502 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 15:18:15.7393 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kzF+UyoUik8lL7sROZJcvyt5G94L20HGUH+Dq35owbnqCwLfBV1RZ7FI6V1Ffy7pV+Go/jPUv+NjYyBkMd/RDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5238 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vadim Pasternak Extend all cable info APIs with 'slot_index' argument. For main board, slot will always be set to zero and these APIs will work as before. If reading cable information is required from cages located on line cards, slot should be set to the physical slot number, where line card is located in modular systems. Signed-off-by: Vadim Pasternak Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/core_env.c | 198 +++++++++++------- .../net/ethernet/mellanox/mlxsw/core_env.h | 43 ++-- .../net/ethernet/mellanox/mlxsw/core_hwmon.c | 10 +- .../ethernet/mellanox/mlxsw/core_thermal.c | 4 +- drivers/net/ethernet/mellanox/mlxsw/minimal.c | 24 ++- .../net/ethernet/mellanox/mlxsw/spectrum.c | 21 +- .../mellanox/mlxsw/spectrum_ethtool.c | 18 +- 7 files changed, 184 insertions(+), 134 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c index f1bb243dfb8c..95fbfb1ca421 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c @@ -28,7 +28,8 @@ struct mlxsw_env { struct mlxsw_env_module_info module_info[]; }; -static int __mlxsw_env_validate_module_type(struct mlxsw_core *core, u8 module) +static int __mlxsw_env_validate_module_type(struct mlxsw_core *core, + u8 slot_index, u8 module) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(core); int err; @@ -44,33 +45,35 @@ static int __mlxsw_env_validate_module_type(struct mlxsw_core *core, u8 module) return err; } -static int mlxsw_env_validate_module_type(struct mlxsw_core *core, u8 module) +static int mlxsw_env_validate_module_type(struct mlxsw_core *core, + u8 slot_index, u8 module) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(core); int err; mutex_lock(&mlxsw_env->module_info_lock); - err = __mlxsw_env_validate_module_type(core, module); + err = __mlxsw_env_validate_module_type(core, slot_index, module); mutex_unlock(&mlxsw_env->module_info_lock); return err; } static int -mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id, bool *qsfp, - bool *cmis) +mlxsw_env_validate_cable_ident(struct mlxsw_core *core, u8 slot_index, int id, + bool *qsfp, bool *cmis) { char mcia_pl[MLXSW_REG_MCIA_LEN]; char *eeprom_tmp; u8 ident; int err; - err = mlxsw_env_validate_module_type(core, id); + err = mlxsw_env_validate_module_type(core, slot_index, id); if (err) return err; - mlxsw_reg_mcia_pack(mcia_pl, 0, id, 0, MLXSW_REG_MCIA_PAGE0_LO_OFF, 0, - 1, MLXSW_REG_MCIA_I2C_ADDR_LOW); + mlxsw_reg_mcia_pack(mcia_pl, slot_index, id, 0, + MLXSW_REG_MCIA_PAGE0_LO_OFF, 0, 1, + MLXSW_REG_MCIA_I2C_ADDR_LOW); err = mlxsw_reg_query(core, MLXSW_REG(mcia), mcia_pl); if (err) return err; @@ -99,8 +102,8 @@ mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id, bool *qsfp, } static int -mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module, - u16 offset, u16 size, void *data, +mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, u8 slot_index, + int module, u16 offset, u16 size, void *data, bool qsfp, unsigned int *p_read_size) { char mcia_pl[MLXSW_REG_MCIA_LEN]; @@ -145,7 +148,7 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module, } } - mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page, offset, size, + mlxsw_reg_mcia_pack(mcia_pl, slot_index, module, 0, page, offset, size, i2c_addr); err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mcia), mcia_pl); @@ -163,8 +166,9 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module, return 0; } -int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, - int off, int *temp) +int +mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, u8 slot_index, + int module, int off, int *temp) { unsigned int module_temp, module_crit, module_emerg; union { @@ -178,8 +182,9 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, int page; int err; - mlxsw_reg_mtmp_pack(mtmp_pl, 0, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, - false, false); + mlxsw_reg_mtmp_pack(mtmp_pl, slot_index, + MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, false, + false); err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl); if (err) return err; @@ -208,7 +213,8 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, */ /* Validate module identifier value. */ - err = mlxsw_env_validate_cable_ident(core, module, &qsfp, &cmis); + err = mlxsw_env_validate_cable_ident(core, slot_index, module, &qsfp, + &cmis); if (err) return err; @@ -220,12 +226,12 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, page = MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM; else page = MLXSW_REG_MCIA_TH_PAGE_NUM; - mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page, + mlxsw_reg_mcia_pack(mcia_pl, slot_index, module, 0, page, MLXSW_REG_MCIA_TH_PAGE_OFF + off, MLXSW_REG_MCIA_TH_ITEM_SIZE, MLXSW_REG_MCIA_I2C_ADDR_LOW); } else { - mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, + mlxsw_reg_mcia_pack(mcia_pl, slot_index, module, 0, MLXSW_REG_MCIA_PAGE0_LO, off, MLXSW_REG_MCIA_TH_ITEM_SIZE, MLXSW_REG_MCIA_I2C_ADDR_HIGH); @@ -243,8 +249,8 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, } int mlxsw_env_get_module_info(struct net_device *netdev, - struct mlxsw_core *mlxsw_core, int module, - struct ethtool_modinfo *modinfo) + struct mlxsw_core *mlxsw_core, u8 slot_index, + int module, struct ethtool_modinfo *modinfo) { u8 module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE]; u16 offset = MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE; @@ -252,15 +258,16 @@ int mlxsw_env_get_module_info(struct net_device *netdev, unsigned int read_size; int err; - err = mlxsw_env_validate_module_type(mlxsw_core, module); + err = mlxsw_env_validate_module_type(mlxsw_core, slot_index, module); if (err) { netdev_err(netdev, "EEPROM is not equipped on port module type"); return err; } - err = mlxsw_env_query_module_eeprom(mlxsw_core, module, 0, offset, - module_info, false, &read_size); + err = mlxsw_env_query_module_eeprom(mlxsw_core, slot_index, module, 0, + offset, module_info, false, + &read_size); if (err) return err; @@ -289,9 +296,10 @@ int mlxsw_env_get_module_info(struct net_device *netdev, break; case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP: /* Verify if transceiver provides diagnostic monitoring page */ - err = mlxsw_env_query_module_eeprom(mlxsw_core, module, - SFP_DIAGMON, 1, &diag_mon, - false, &read_size); + err = mlxsw_env_query_module_eeprom(mlxsw_core, slot_index, + module, SFP_DIAGMON, 1, + &diag_mon, false, + &read_size); if (err) return err; @@ -330,8 +338,9 @@ int mlxsw_env_get_module_info(struct net_device *netdev, EXPORT_SYMBOL(mlxsw_env_get_module_info); int mlxsw_env_get_module_eeprom(struct net_device *netdev, - struct mlxsw_core *mlxsw_core, int module, - struct ethtool_eeprom *ee, u8 *data) + struct mlxsw_core *mlxsw_core, u8 slot_index, + int module, struct ethtool_eeprom *ee, + u8 *data) { int offset = ee->offset; unsigned int read_size; @@ -344,12 +353,14 @@ int mlxsw_env_get_module_eeprom(struct net_device *netdev, memset(data, 0, ee->len); /* Validate module identifier value. */ - err = mlxsw_env_validate_cable_ident(mlxsw_core, module, &qsfp, &cmis); + err = mlxsw_env_validate_cable_ident(mlxsw_core, slot_index, module, + &qsfp, &cmis); if (err) return err; while (i < ee->len) { - err = mlxsw_env_query_module_eeprom(mlxsw_core, module, offset, + err = mlxsw_env_query_module_eeprom(mlxsw_core, slot_index, + module, offset, ee->len - i, data + i, qsfp, &read_size); if (err) { @@ -395,7 +406,8 @@ static int mlxsw_env_mcia_status_process(const char *mcia_pl, } int -mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module, +mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, + u8 slot_index, u8 module, const struct ethtool_module_eeprom *page, struct netlink_ext_ack *extack) { @@ -403,7 +415,7 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module, u16 device_addr; int err; - err = mlxsw_env_validate_module_type(mlxsw_core, module); + err = mlxsw_env_validate_module_type(mlxsw_core, slot_index, module); if (err) { NL_SET_ERR_MSG_MOD(extack, "EEPROM is not equipped on port module type"); return err; @@ -420,7 +432,7 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module, size = min_t(u8, page->length - bytes_read, MLXSW_REG_MCIA_EEPROM_SIZE); - mlxsw_reg_mcia_pack(mcia_pl, 0, module, 0, page->page, + mlxsw_reg_mcia_pack(mcia_pl, slot_index, module, 0, page->page, device_addr + bytes_read, size, page->i2c_address); mlxsw_reg_mcia_bank_number_set(mcia_pl, page->bank); @@ -444,18 +456,20 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module, } EXPORT_SYMBOL(mlxsw_env_get_module_eeprom_by_page); -static int mlxsw_env_module_reset(struct mlxsw_core *mlxsw_core, u8 module) +static int mlxsw_env_module_reset(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module) { char pmaos_pl[MLXSW_REG_PMAOS_LEN]; - mlxsw_reg_pmaos_pack(pmaos_pl, 0, module); + mlxsw_reg_pmaos_pack(pmaos_pl, slot_index, module); mlxsw_reg_pmaos_rst_set(pmaos_pl, true); return mlxsw_reg_write(mlxsw_core, MLXSW_REG(pmaos), pmaos_pl); } int mlxsw_env_reset_module(struct net_device *netdev, - struct mlxsw_core *mlxsw_core, u8 module, u32 *flags) + struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module, u32 *flags) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); u32 req = *flags; @@ -467,7 +481,7 @@ int mlxsw_env_reset_module(struct net_device *netdev, mutex_lock(&mlxsw_env->module_info_lock); - err = __mlxsw_env_validate_module_type(mlxsw_core, module); + err = __mlxsw_env_validate_module_type(mlxsw_core, slot_index, module); if (err) { netdev_err(netdev, "Reset module is not supported on port module type\n"); goto out; @@ -486,7 +500,7 @@ int mlxsw_env_reset_module(struct net_device *netdev, goto out; } - err = mlxsw_env_module_reset(mlxsw_core, module); + err = mlxsw_env_module_reset(mlxsw_core, slot_index, module); if (err) { netdev_err(netdev, "Failed to reset module\n"); goto out; @@ -501,7 +515,8 @@ int mlxsw_env_reset_module(struct net_device *netdev, EXPORT_SYMBOL(mlxsw_env_reset_module); int -mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, +mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module, struct ethtool_module_power_mode_params *params, struct netlink_ext_ack *extack) { @@ -512,7 +527,7 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, mutex_lock(&mlxsw_env->module_info_lock); - err = __mlxsw_env_validate_module_type(mlxsw_core, module); + err = __mlxsw_env_validate_module_type(mlxsw_core, slot_index, module); if (err) { NL_SET_ERR_MSG_MOD(extack, "Power mode is not supported on port module type"); goto out; @@ -520,7 +535,7 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, params->policy = mlxsw_env->module_info[module].power_mode_policy; - mlxsw_reg_mcion_pack(mcion_pl, 0, module); + mlxsw_reg_mcion_pack(mcion_pl, slot_index, module); err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mcion), mcion_pl); if (err) { NL_SET_ERR_MSG_MOD(extack, "Failed to retrieve module's power mode"); @@ -543,12 +558,12 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, EXPORT_SYMBOL(mlxsw_env_get_module_power_mode); static int mlxsw_env_module_enable_set(struct mlxsw_core *mlxsw_core, - u8 module, bool enable) + u8 slot_index, u8 module, bool enable) { enum mlxsw_reg_pmaos_admin_status admin_status; char pmaos_pl[MLXSW_REG_PMAOS_LEN]; - mlxsw_reg_pmaos_pack(pmaos_pl, 0, module); + mlxsw_reg_pmaos_pack(pmaos_pl, slot_index, module); admin_status = enable ? MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED : MLXSW_REG_PMAOS_ADMIN_STATUS_DISABLED; mlxsw_reg_pmaos_admin_status_set(pmaos_pl, admin_status); @@ -558,12 +573,13 @@ static int mlxsw_env_module_enable_set(struct mlxsw_core *mlxsw_core, } static int mlxsw_env_module_low_power_set(struct mlxsw_core *mlxsw_core, - u8 module, bool low_power) + u8 slot_index, u8 module, + bool low_power) { u16 eeprom_override_mask, eeprom_override; char pmmp_pl[MLXSW_REG_PMMP_LEN]; - mlxsw_reg_pmmp_pack(pmmp_pl, 0, module); + mlxsw_reg_pmmp_pack(pmmp_pl, slot_index, module); mlxsw_reg_pmmp_sticky_set(pmmp_pl, true); /* Mask all the bits except low power mode. */ eeprom_override_mask = ~MLXSW_REG_PMMP_EEPROM_OVERRIDE_LOW_POWER_MASK; @@ -576,24 +592,26 @@ static int mlxsw_env_module_low_power_set(struct mlxsw_core *mlxsw_core, } static int __mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, - u8 module, bool low_power, + u8 slot_index, u8 module, + bool low_power, struct netlink_ext_ack *extack) { int err; - err = mlxsw_env_module_enable_set(mlxsw_core, module, false); + err = mlxsw_env_module_enable_set(mlxsw_core, slot_index, module, false); if (err) { NL_SET_ERR_MSG_MOD(extack, "Failed to disable module"); return err; } - err = mlxsw_env_module_low_power_set(mlxsw_core, module, low_power); + err = mlxsw_env_module_low_power_set(mlxsw_core, slot_index, module, + low_power); if (err) { NL_SET_ERR_MSG_MOD(extack, "Failed to set module's power mode"); goto err_module_low_power_set; } - err = mlxsw_env_module_enable_set(mlxsw_core, module, true); + err = mlxsw_env_module_enable_set(mlxsw_core, slot_index, module, true); if (err) { NL_SET_ERR_MSG_MOD(extack, "Failed to enable module"); goto err_module_enable_set; @@ -602,14 +620,16 @@ static int __mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, return 0; err_module_enable_set: - mlxsw_env_module_low_power_set(mlxsw_core, module, !low_power); + mlxsw_env_module_low_power_set(mlxsw_core, slot_index, module, + !low_power); err_module_low_power_set: - mlxsw_env_module_enable_set(mlxsw_core, module, true); + mlxsw_env_module_enable_set(mlxsw_core, slot_index, module, true); return err; } int -mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, +mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module, enum ethtool_module_power_mode_policy policy, struct netlink_ext_ack *extack) { @@ -625,7 +645,7 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, mutex_lock(&mlxsw_env->module_info_lock); - err = __mlxsw_env_validate_module_type(mlxsw_core, module); + err = __mlxsw_env_validate_module_type(mlxsw_core, slot_index, module); if (err) { NL_SET_ERR_MSG_MOD(extack, "Power mode set is not supported on port module type"); @@ -640,8 +660,8 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, goto out_set_policy; low_power = policy == ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO; - err = __mlxsw_env_set_module_power_mode(mlxsw_core, module, low_power, - extack); + err = __mlxsw_env_set_module_power_mode(mlxsw_core, slot_index, module, + low_power, extack); if (err) goto out; @@ -654,14 +674,14 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, EXPORT_SYMBOL(mlxsw_env_set_module_power_mode); static int mlxsw_env_module_has_temp_sensor(struct mlxsw_core *mlxsw_core, - u8 module, + u8 slot_index, u8 module, bool *p_has_temp_sensor) { char mtbr_pl[MLXSW_REG_MTBR_LEN]; u16 temp; int err; - mlxsw_reg_mtbr_pack(mtbr_pl, 0, + mlxsw_reg_mtbr_pack(mtbr_pl, slot_index, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1); err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mtbr), mtbr_pl); if (err) @@ -682,13 +702,15 @@ static int mlxsw_env_module_has_temp_sensor(struct mlxsw_core *mlxsw_core, return 0; } -static int mlxsw_env_temp_event_set(struct mlxsw_core *mlxsw_core, - u16 sensor_index, bool enable) +static int +mlxsw_env_temp_event_set(struct mlxsw_core *mlxsw_core, u8 slot_index, + u16 sensor_index, bool enable) { char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0}; enum mlxsw_reg_mtmp_tee tee; int err, threshold_hi; + mlxsw_reg_mtmp_slot_index_set(mtmp_pl, slot_index); mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, sensor_index); err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mtmp), mtmp_pl); if (err) @@ -696,6 +718,7 @@ static int mlxsw_env_temp_event_set(struct mlxsw_core *mlxsw_core, if (enable) { err = mlxsw_env_module_temp_thresholds_get(mlxsw_core, + slot_index, sensor_index - MLXSW_REG_MTMP_MODULE_INDEX_MIN, SFP_TEMP_HIGH_WARN, @@ -722,14 +745,15 @@ static int mlxsw_env_temp_event_set(struct mlxsw_core *mlxsw_core, return mlxsw_reg_write(mlxsw_core, MLXSW_REG(mtmp), mtmp_pl); } -static int mlxsw_env_module_temp_event_enable(struct mlxsw_core *mlxsw_core) +static int mlxsw_env_module_temp_event_enable(struct mlxsw_core *mlxsw_core, + u8 slot_index) { int i, err, sensor_index; bool has_temp_sensor; for (i = 0; i < mlxsw_core_env(mlxsw_core)->module_count; i++) { - err = mlxsw_env_module_has_temp_sensor(mlxsw_core, i, - &has_temp_sensor); + err = mlxsw_env_module_has_temp_sensor(mlxsw_core, slot_index, + i, &has_temp_sensor); if (err) return err; @@ -737,7 +761,8 @@ static int mlxsw_env_module_temp_event_enable(struct mlxsw_core *mlxsw_core) continue; sensor_index = i + MLXSW_REG_MTMP_MODULE_INDEX_MIN; - err = mlxsw_env_temp_event_set(mlxsw_core, sensor_index, true); + err = mlxsw_env_temp_event_set(mlxsw_core, slot_index, + sensor_index, true); if (err) return err; } @@ -838,6 +863,7 @@ static void mlxsw_env_temp_warn_event_unregister(struct mlxsw_env *mlxsw_env) struct mlxsw_env_module_plug_unplug_event { struct mlxsw_env *mlxsw_env; + u8 slot_index; u8 module; struct work_struct work; }; @@ -858,7 +884,9 @@ static void mlxsw_env_pmpe_event_work(struct work_struct *work) mlxsw_env->module_info[event->module].is_overheat = false; mutex_unlock(&mlxsw_env->module_info_lock); - err = mlxsw_env_module_has_temp_sensor(mlxsw_env->core, event->module, + err = mlxsw_env_module_has_temp_sensor(mlxsw_env->core, + event->slot_index, + event->module, &has_temp_sensor); /* Do not disable events on modules without sensors or faulty sensors * because FW returns errors. @@ -870,7 +898,8 @@ static void mlxsw_env_pmpe_event_work(struct work_struct *work) goto out; sensor_index = event->module + MLXSW_REG_MTMP_MODULE_INDEX_MIN; - mlxsw_env_temp_event_set(mlxsw_env->core, sensor_index, true); + mlxsw_env_temp_event_set(mlxsw_env->core, event->slot_index, + sensor_index, true); out: kfree(event); @@ -897,6 +926,7 @@ mlxsw_env_pmpe_listener_func(const struct mlxsw_reg_info *reg, char *pmpe_pl, return; event->mlxsw_env = mlxsw_env; + event->slot_index = 0; event->module = module; INIT_WORK(&event->work, mlxsw_env_pmpe_event_work); mlxsw_core_schedule_work(&event->work); @@ -924,14 +954,15 @@ mlxsw_env_module_plug_event_unregister(struct mlxsw_env *mlxsw_env) } static int -mlxsw_env_module_oper_state_event_enable(struct mlxsw_core *mlxsw_core) +mlxsw_env_module_oper_state_event_enable(struct mlxsw_core *mlxsw_core, + u8 slot_index) { int i, err; for (i = 0; i < mlxsw_core_env(mlxsw_core)->module_count; i++) { char pmaos_pl[MLXSW_REG_PMAOS_LEN]; - mlxsw_reg_pmaos_pack(pmaos_pl, 0, i); + mlxsw_reg_pmaos_pack(pmaos_pl, slot_index, i); mlxsw_reg_pmaos_e_set(pmaos_pl, MLXSW_REG_PMAOS_E_GENERATE_EVENT); mlxsw_reg_pmaos_ee_set(pmaos_pl, true); @@ -943,8 +974,8 @@ mlxsw_env_module_oper_state_event_enable(struct mlxsw_core *mlxsw_core) } int -mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 module, - u64 *p_counter) +mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module, u64 *p_counter) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); @@ -956,7 +987,8 @@ mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 module, } EXPORT_SYMBOL(mlxsw_env_module_overheat_counter_get); -void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 module) +void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); @@ -966,7 +998,8 @@ void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 module) } EXPORT_SYMBOL(mlxsw_env_module_port_map); -void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 module) +void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); @@ -976,7 +1009,8 @@ void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 module) } EXPORT_SYMBOL(mlxsw_env_module_port_unmap); -int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module) +int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); int err = 0; @@ -993,8 +1027,8 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module) /* Transition to high power mode following first port using the module * being put administratively up. */ - err = __mlxsw_env_set_module_power_mode(mlxsw_core, module, false, - NULL); + err = __mlxsw_env_set_module_power_mode(mlxsw_core, slot_index, module, + false, NULL); if (err) goto out_unlock; @@ -1006,7 +1040,8 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module) } EXPORT_SYMBOL(mlxsw_env_module_port_up); -void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 module) +void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); @@ -1024,7 +1059,8 @@ void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 module) /* Transition to low power mode following last port using the module * being put administratively down. */ - __mlxsw_env_set_module_power_mode(mlxsw_core, module, true, NULL); + __mlxsw_env_set_module_power_mode(mlxsw_core, slot_index, module, true, + NULL); out_unlock: mutex_unlock(&mlxsw_env->module_info_lock); @@ -1032,7 +1068,7 @@ void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 module) EXPORT_SYMBOL(mlxsw_env_module_port_down); static int -mlxsw_env_module_type_set(struct mlxsw_core *mlxsw_core) +mlxsw_env_module_type_set(struct mlxsw_core *mlxsw_core, u8 slot_index) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); int i; @@ -1041,7 +1077,7 @@ mlxsw_env_module_type_set(struct mlxsw_core *mlxsw_core) char pmtm_pl[MLXSW_REG_PMTM_LEN]; int err; - mlxsw_reg_pmtm_pack(pmtm_pl, 0, i); + mlxsw_reg_pmtm_pack(pmtm_pl, slot_index, i); err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(pmtm), pmtm_pl); if (err) return err; @@ -1091,15 +1127,15 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) if (err) goto err_module_plug_event_register; - err = mlxsw_env_module_oper_state_event_enable(mlxsw_core); + err = mlxsw_env_module_oper_state_event_enable(mlxsw_core, 0); if (err) goto err_oper_state_event_enable; - err = mlxsw_env_module_temp_event_enable(mlxsw_core); + err = mlxsw_env_module_temp_event_enable(mlxsw_core, 0); if (err) goto err_temp_event_enable; - err = mlxsw_env_module_type_set(mlxsw_core); + err = mlxsw_env_module_type_set(mlxsw_core, 0); if (err) goto err_type_set; diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.h b/drivers/net/ethernet/mellanox/mlxsw/core_env.h index ec6564e5d2ee..6b494c64a4d7 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_env.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.h @@ -9,47 +9,56 @@ struct ethtool_modinfo; struct ethtool_eeprom; -int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, - int off, int *temp); +int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, + u8 slot_index, int module, int off, + int *temp); int mlxsw_env_get_module_info(struct net_device *netdev, - struct mlxsw_core *mlxsw_core, int module, - struct ethtool_modinfo *modinfo); + struct mlxsw_core *mlxsw_core, u8 slot_index, + int module, struct ethtool_modinfo *modinfo); int mlxsw_env_get_module_eeprom(struct net_device *netdev, - struct mlxsw_core *mlxsw_core, int module, - struct ethtool_eeprom *ee, u8 *data); + struct mlxsw_core *mlxsw_core, u8 slot_index, + int module, struct ethtool_eeprom *ee, + u8 *data); int -mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, u8 module, +mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, + u8 slot_index, u8 module, const struct ethtool_module_eeprom *page, struct netlink_ext_ack *extack); int mlxsw_env_reset_module(struct net_device *netdev, - struct mlxsw_core *mlxsw_core, u8 module, - u32 *flags); + struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module, u32 *flags); int -mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, +mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module, struct ethtool_module_power_mode_params *params, struct netlink_ext_ack *extack); int -mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module, +mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module, enum ethtool_module_power_mode_policy policy, struct netlink_ext_ack *extack); int -mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 module, - u64 *p_counter); +mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module, u64 *p_counter); -void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 module); +void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module); -void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 module); +void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module); -int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 module); +int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module); -void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 module); +void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 slot_index, + u8 module); int mlxsw_env_init(struct mlxsw_core *core, struct mlxsw_env **p_env); void mlxsw_env_fini(struct mlxsw_env *env); diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c index 2bc4c4556895..5df54a5bf292 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c @@ -311,8 +311,9 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev, int err; module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; - err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, module, - SFP_TEMP_HIGH_WARN, p_temp); + err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0, + module, SFP_TEMP_HIGH_WARN, + p_temp); if (err) { dev_err(dev, "Failed to query module temperature thresholds\n"); return err; @@ -345,8 +346,9 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev, int err; module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; - err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, module, - SFP_TEMP_HIGH_ALARM, p_temp); + err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0, + module, SFP_TEMP_HIGH_ALARM, + p_temp); if (err) { dev_err(dev, "Failed to query module temperature thresholds\n"); return err; diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c index adb2820430b1..d64af27e5bac 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -150,13 +150,13 @@ mlxsw_thermal_module_trips_update(struct device *dev, struct mlxsw_core *core, * EEPROM if we got valid thresholds from MTMP. */ if (!emerg_temp || !crit_temp) { - err = mlxsw_env_module_temp_thresholds_get(core, tz->module, + err = mlxsw_env_module_temp_thresholds_get(core, 0, tz->module, SFP_TEMP_HIGH_WARN, &crit_temp); if (err) return err; - err = mlxsw_env_module_temp_thresholds_get(core, tz->module, + err = mlxsw_env_module_temp_thresholds_get(core, 0, tz->module, SFP_TEMP_HIGH_ALARM, &emerg_temp); if (err) diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c index 3bc012dafd08..eb906b73b4e2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c @@ -59,7 +59,8 @@ static int mlxsw_m_port_open(struct net_device *dev) struct mlxsw_m_port *mlxsw_m_port = netdev_priv(dev); struct mlxsw_m *mlxsw_m = mlxsw_m_port->mlxsw_m; - return mlxsw_env_module_port_up(mlxsw_m->core, mlxsw_m_port->module); + return mlxsw_env_module_port_up(mlxsw_m->core, 0, + mlxsw_m_port->module); } static int mlxsw_m_port_stop(struct net_device *dev) @@ -67,7 +68,7 @@ static int mlxsw_m_port_stop(struct net_device *dev) struct mlxsw_m_port *mlxsw_m_port = netdev_priv(dev); struct mlxsw_m *mlxsw_m = mlxsw_m_port->mlxsw_m; - mlxsw_env_module_port_down(mlxsw_m->core, mlxsw_m_port->module); + mlxsw_env_module_port_down(mlxsw_m->core, 0, mlxsw_m_port->module); return 0; } @@ -110,7 +111,7 @@ static int mlxsw_m_get_module_info(struct net_device *netdev, struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; - return mlxsw_env_get_module_info(netdev, core, mlxsw_m_port->module, + return mlxsw_env_get_module_info(netdev, core, 0, mlxsw_m_port->module, modinfo); } @@ -121,8 +122,8 @@ mlxsw_m_get_module_eeprom(struct net_device *netdev, struct ethtool_eeprom *ee, struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; - return mlxsw_env_get_module_eeprom(netdev, core, mlxsw_m_port->module, - ee, data); + return mlxsw_env_get_module_eeprom(netdev, core, 0, + mlxsw_m_port->module, ee, data); } static int @@ -133,7 +134,8 @@ mlxsw_m_get_module_eeprom_by_page(struct net_device *netdev, struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; - return mlxsw_env_get_module_eeprom_by_page(core, mlxsw_m_port->module, + return mlxsw_env_get_module_eeprom_by_page(core, 0, + mlxsw_m_port->module, page, extack); } @@ -142,7 +144,7 @@ static int mlxsw_m_reset(struct net_device *netdev, u32 *flags) struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; - return mlxsw_env_reset_module(netdev, core, mlxsw_m_port->module, + return mlxsw_env_reset_module(netdev, core, 0, mlxsw_m_port->module, flags); } @@ -154,7 +156,7 @@ mlxsw_m_get_module_power_mode(struct net_device *netdev, struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; - return mlxsw_env_get_module_power_mode(core, mlxsw_m_port->module, + return mlxsw_env_get_module_power_mode(core, 0, mlxsw_m_port->module, params, extack); } @@ -166,7 +168,7 @@ mlxsw_m_set_module_power_mode(struct net_device *netdev, struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; - return mlxsw_env_set_module_power_mode(core, mlxsw_m_port->module, + return mlxsw_env_set_module_power_mode(core, 0, mlxsw_m_port->module, params->policy, extack); } @@ -311,7 +313,7 @@ static int mlxsw_m_port_module_map(struct mlxsw_m *mlxsw_m, u16 local_port, if (WARN_ON_ONCE(module >= max_ports)) return -EINVAL; - mlxsw_env_module_port_map(mlxsw_m->core, module); + mlxsw_env_module_port_map(mlxsw_m->core, 0, module); mlxsw_m->module_to_port[module] = ++mlxsw_m->max_ports; return 0; @@ -320,7 +322,7 @@ static int mlxsw_m_port_module_map(struct mlxsw_m *mlxsw_m, u16 local_port, static void mlxsw_m_port_module_unmap(struct mlxsw_m *mlxsw_m, u8 module) { mlxsw_m->module_to_port[module] = -1; - mlxsw_env_module_port_unmap(mlxsw_m->core, module); + mlxsw_env_module_port_unmap(mlxsw_m->core, 0, module); } static int mlxsw_m_ports_create(struct mlxsw_m *mlxsw_m) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 8eb05090ffec..684910ca7cf4 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -539,7 +539,7 @@ mlxsw_sp_port_module_map(struct mlxsw_sp *mlxsw_sp, u16 local_port, char pmlp_pl[MLXSW_REG_PMLP_LEN]; int i, err; - mlxsw_env_module_port_map(mlxsw_sp->core, port_mapping->module); + mlxsw_env_module_port_map(mlxsw_sp->core, 0, port_mapping->module); mlxsw_reg_pmlp_pack(pmlp_pl, local_port); mlxsw_reg_pmlp_width_set(pmlp_pl, port_mapping->width); @@ -554,19 +554,19 @@ mlxsw_sp_port_module_map(struct mlxsw_sp *mlxsw_sp, u16 local_port, return 0; err_pmlp_write: - mlxsw_env_module_port_unmap(mlxsw_sp->core, port_mapping->module); + mlxsw_env_module_port_unmap(mlxsw_sp->core, 0, port_mapping->module); return err; } static void mlxsw_sp_port_module_unmap(struct mlxsw_sp *mlxsw_sp, u16 local_port, - u8 module) + u8 slot_index, u8 module) { char pmlp_pl[MLXSW_REG_PMLP_LEN]; mlxsw_reg_pmlp_pack(pmlp_pl, local_port); mlxsw_reg_pmlp_width_set(pmlp_pl, 0); mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); - mlxsw_env_module_port_unmap(mlxsw_sp->core, module); + mlxsw_env_module_port_unmap(mlxsw_sp->core, slot_index, module); } static int mlxsw_sp_port_open(struct net_device *dev) @@ -575,7 +575,7 @@ static int mlxsw_sp_port_open(struct net_device *dev) struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; int err; - err = mlxsw_env_module_port_up(mlxsw_sp->core, + err = mlxsw_env_module_port_up(mlxsw_sp->core, 0, mlxsw_sp_port->mapping.module); if (err) return err; @@ -586,7 +586,7 @@ static int mlxsw_sp_port_open(struct net_device *dev) return 0; err_port_admin_status_set: - mlxsw_env_module_port_down(mlxsw_sp->core, + mlxsw_env_module_port_down(mlxsw_sp->core, 0, mlxsw_sp_port->mapping.module); return err; } @@ -598,7 +598,7 @@ static int mlxsw_sp_port_stop(struct net_device *dev) netif_stop_queue(dev); mlxsw_sp_port_admin_status_set(mlxsw_sp_port, false); - mlxsw_env_module_port_down(mlxsw_sp->core, + mlxsw_env_module_port_down(mlxsw_sp->core, 0, mlxsw_sp_port->mapping.module); return 0; } @@ -1449,7 +1449,7 @@ static int mlxsw_sp_port_overheat_init_val_set(struct mlxsw_sp_port *mlxsw_sp_po u64 overheat_counter; int err; - err = mlxsw_env_module_overheat_counter_get(mlxsw_sp->core, module, + err = mlxsw_env_module_overheat_counter_get(mlxsw_sp->core, 0, module, &overheat_counter); if (err) return err; @@ -1775,7 +1775,8 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u16 local_port, mlxsw_sp_port_swid_set(mlxsw_sp, local_port, MLXSW_PORT_SWID_DISABLED_PORT); err_port_swid_set: - mlxsw_sp_port_module_unmap(mlxsw_sp, local_port, port_mapping->module); + mlxsw_sp_port_module_unmap(mlxsw_sp, local_port, 0, + port_mapping->module); return err; } @@ -1804,7 +1805,7 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u16 local_port) mlxsw_core_port_fini(mlxsw_sp->core, local_port); mlxsw_sp_port_swid_set(mlxsw_sp, local_port, MLXSW_PORT_SWID_DISABLED_PORT); - mlxsw_sp_port_module_unmap(mlxsw_sp, local_port, module); + mlxsw_sp_port_module_unmap(mlxsw_sp, local_port, 0, module); } static int mlxsw_sp_cpu_port_create(struct mlxsw_sp *mlxsw_sp) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c index 8b5d7f83b9b0..f72c26ce0391 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c @@ -573,7 +573,7 @@ mlxsw_sp_port_get_transceiver_overheat_stats(struct mlxsw_sp_port *mlxsw_sp_port u64 stats; int err; - err = mlxsw_env_module_overheat_counter_get(mlxsw_core, + err = mlxsw_env_module_overheat_counter_get(mlxsw_core, 0, port_mapping.module, &stats); if (err) @@ -1035,7 +1035,7 @@ static int mlxsw_sp_get_module_info(struct net_device *netdev, struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(netdev); struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; - return mlxsw_env_get_module_info(netdev, mlxsw_sp->core, + return mlxsw_env_get_module_info(netdev, mlxsw_sp->core, 0, mlxsw_sp_port->mapping.module, modinfo); } @@ -1046,7 +1046,7 @@ static int mlxsw_sp_get_module_eeprom(struct net_device *netdev, struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(netdev); struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; - return mlxsw_env_get_module_eeprom(netdev, mlxsw_sp->core, + return mlxsw_env_get_module_eeprom(netdev, mlxsw_sp->core, 0, mlxsw_sp_port->mapping.module, ee, data); } @@ -1060,8 +1060,8 @@ mlxsw_sp_get_module_eeprom_by_page(struct net_device *dev, struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; u8 module = mlxsw_sp_port->mapping.module; - return mlxsw_env_get_module_eeprom_by_page(mlxsw_sp->core, module, page, - extack); + return mlxsw_env_get_module_eeprom_by_page(mlxsw_sp->core, 0, module, + page, extack); } static int @@ -1204,7 +1204,7 @@ static int mlxsw_sp_reset(struct net_device *dev, u32 *flags) struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; u8 module = mlxsw_sp_port->mapping.module; - return mlxsw_env_reset_module(dev, mlxsw_sp->core, module, flags); + return mlxsw_env_reset_module(dev, mlxsw_sp->core, 0, module, flags); } static int @@ -1216,8 +1216,8 @@ mlxsw_sp_get_module_power_mode(struct net_device *dev, struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; u8 module = mlxsw_sp_port->mapping.module; - return mlxsw_env_get_module_power_mode(mlxsw_sp->core, module, params, - extack); + return mlxsw_env_get_module_power_mode(mlxsw_sp->core, 0, module, + params, extack); } static int @@ -1229,7 +1229,7 @@ mlxsw_sp_set_module_power_mode(struct net_device *dev, struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; u8 module = mlxsw_sp_port->mapping.module; - return mlxsw_env_set_module_power_mode(mlxsw_sp->core, module, + return mlxsw_env_set_module_power_mode(mlxsw_sp->core, 0, module, params->policy, extack); } From patchwork Wed Apr 13 15:17:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12812118 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FE97C433EF for ; Wed, 13 Apr 2022 15:18:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234856AbiDMPUx (ORCPT ); Wed, 13 Apr 2022 11:20:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234843AbiDMPUq (ORCPT ); Wed, 13 Apr 2022 11:20:46 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2058.outbound.protection.outlook.com [40.107.93.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 850262D1CE for ; Wed, 13 Apr 2022 08:18:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E2ykqT9Uur0IXB4AVEnkJUC4R5lNtS56JBbrm/PCuRtBm0GmcRgMvWC861sCQKeT77CsGVsTgNx1KBPDCwO1eLCB5n0W14McgSRqlSwWuAkcjFO+a0gwj0+ERWdgtE+AlpC0CtlHGGZEJXOi8LtcBFOicfTMeYJnJDARjEuwr2oX7FZnsd4dUOg+/xP/y+1AkIz2j7C0XlRyXowe9NXzuH5ULa0EHZfeBVxfAebl6yHUA7OFB1igtFX7YXqqqY5McM5GLYe7FSYwM2hi+KOIocM/fwc/viPqi/z2NCCbEod3TQ0cQcJPSK9BBzbSsFmDi3QbL5FpXafq1jWcBb6ZhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PClBECFP6l1UjENJpU6yq+zhq2XbsMAJSw+2fk3U8ks=; b=ONR3VmtmijVcKT9Ym9B8Y3IP2Bu4X71Zp116yWD1VRBIuD7du0qF9gkhgjiwOt3ph4TXhN/Abo0p0KAdRjf36HVSzJeXBRQOjA7JAYGIjReG+TCOdcU+y3MA0GDXAYRME/3ChGhSY0+NId32iqWEnHhkW67HBrzUN5yPZviT8EuRbHYlYJIZR3PmwOWNX5o0++LZO72CepK4mxsEV2u4GYZdEOk46+GBBXO0oHzGlXuY/cLHU4deOPCkf/z7lwVjuMOGI4+cnPnGvoL788AHvAauVADEWncFvaZFqLx5nT6XP7Q0OIYYXCASVeEbAkhWTx9FgLoTwbFpx6nQ/ZMewg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=PClBECFP6l1UjENJpU6yq+zhq2XbsMAJSw+2fk3U8ks=; b=qBRXW4UgxvZJEIy7S70ekMHyKpBXnQhcCATKr1XCKEXdDhxnTsyLVlz/nSRpHiA0BxGBoz29B/yBceUD9+Jh21sUnD8RUHYl/vemsPZNOwUpblmFLXwLMtdKEQH0AjhU5Ij7W/345nZvXjc3DlPemTPiwzE8gQJkiiWlvXjNgGN7x8K8TQ/cwe06ew5Q7hSvDVXzO1EhlPCm8o9aTrpzwLFFOM8jIarEQ7nqwKBf5/s23efqI+HxByKNkosk/IiwUc+rbgU0xJrKqrcNa1t+9PsuLctUwEi4K4bVGfzZNmFpZtQJiNxIgDiKo5A8+z1ZowSxeKFMSFPb9mhs84Z7fg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by BYAPR12MB4616.namprd12.prod.outlook.com (2603:10b6:a03:a2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.18; Wed, 13 Apr 2022 15:18:22 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402%5]) with mapi id 15.20.5144.029; Wed, 13 Apr 2022 15:18:22 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, petrm@nvidia.com, vadimp@nvidia.com, jiri@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 2/9] mlxsw: core: Extend port module data structures for line cards Date: Wed, 13 Apr 2022 18:17:26 +0300 Message-Id: <20220413151733.2738867-3-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220413151733.2738867-1-idosch@nvidia.com> References: <20220413151733.2738867-1-idosch@nvidia.com> X-ClientProxiedBy: VI1P194CA0048.EURP194.PROD.OUTLOOK.COM (2603:10a6:803:3c::37) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cb39e88d-a2f3-4077-470e-08da1d60d8f3 X-MS-TrafficTypeDiagnostic: BYAPR12MB4616:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oAgNgZI/7CMmkynGvru9kb0BbE4wRTYe3B4FbFdxwtIe0ZzwLTRd8OnMHXcl0jrlwGK+aLfdwHLggyeTM9mKx+jvjBjGTgkrI+/N7TAQBI7UpE1reqstszsadLzVcoq585Kpz3SpUStEQAFqPgyLBoiZHaoR6/cO3HgkLr9X7upRGaTNfuDWmRA9VLDR7xML2xyS8aOsLldFMCCTX1Eb8KGdRSQuVRzGi+5tTDRlkSxxeUYCt5CXhIPcLZLxsalSOpmhn16sD3ehGoKa7YmJjsq+CsfzPeoKOAyXNxQN0D7c3QYfQSHstC6MVsEcGV5BPKl/E5ZvxgbDIAsF0PWysao4fclCheIzw1rKOlcoAaN+UBtDImVvBNsFPKrn6TZp/cRhxgoYiG7QGSXH/HqUOKtXEFCkKarP6Q3QG/q49LpkL+FfT9pJNJ9yB+pu3Qo/k+QrkCVP8AoMfcpjtkHZaxmQycsBlLYizHnVIddW2LFChw422m5BeaTpUqXb4lh/dR7xeECr0dWZoWw87LhDHj8t8JAGh3NZNYwvivs0JANo1gtFw41gpPAP0abYGK7oFA+U3C7H5JtsotDj+y4tyIPipXbrfoEn25D0mElsGjpyyJ+CUvy0Y5NW8UoZq1lI4BOafP0W8lF5dYZcwVOrbg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(38100700002)(8936002)(5660300002)(30864003)(1076003)(66946007)(2906002)(36756003)(6512007)(26005)(8676002)(186003)(4326008)(66476007)(66556008)(86362001)(6486002)(6916009)(6506007)(83380400001)(2616005)(107886003)(508600001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0+lT25miKByNpGP9hKQ81/n28bCWmRVZ4FumH4TxNkhj+gSTAHOUlamLTXYHlQBXllmCNZ05RucowhdraGc9pSEZch3i+hnYuZdgw8lffIfCT8JtiHc0g++BPOmHMjWYtOZa2gMBd/YBOqikK4+vq4Y2ckcRatiQ96O9FWMJckZQy3KkA18DVERR5evX2DIfxY9gClfWD5IgkqSU6W7Dw968D3Hpo5SIOOdhYAPJYqoxVDPQ4wTB/8aQ6T74QhjbQCdYd35DcLd91fb3PxtM1pT2xN8K6IBaFTWjsx3aToZXOH1LTnLkWmDf1TzH5m0oJEmWM/l1NYXYunFqSuIT4Z01i1t44kyFV4L8xgEvPKwNrNheaMTPpf9Kw5kw8UkklZQt2byWBZ3eF+C+Kgcu1KmLnfBbqLxQPkn9wRRPaEdlyfU52xnQsDawu9iwBSINVX7QJnK/KKaD0oSTPYaJEQshQJXlvzvVFpWkk6cnzK6/UAGEdU7hm19CVDPMcbskW0O5QolYTDXyV131kOTBCjEGsn7saH1yRlwHxym1apupzzLKninJmvhkf8Wo3he89rdi5CzIq+GlRr5xy7YrH7DTSp/Wr2wQ5K8xUgdh4WtkL+WqoYpSFLAv4J3IKcEedBwXiKzt0Bglu3V6oXPg353ws9eTrLFh5agSda2eybH7faWNBCHN5tWzWV/ooK9HJhiDyowroOOkVd+Ltw9JajK4rTAcWLwGAv4oeaXV0UC+uQtqow+T6rR6GMUX8KoLUK9xIBMbktAH4VKc8ehYopuqBbt5opQd0JT7UDWD70QvSuGbDnRq6oUkkWaOZ0+CqE7adjCwASY2/TYzjZndK6zgJq1WitkZljzSwbtBuYxcEYxyhfw1NrBjOGvSu8AVsIIgGCzpzLUow8oeM6J3k2/46ST1qtxVdxMUB56dOKAPzs7EQztgLh1CadP3jSoBdD87IPxZtWW9D/4P+61oYn6Ux3h9doiurtqoyTssM0nTMnosuee66pegp4eYgW2/OL29AXF8oRSuVy+V5Ckq6yr7loIlYd4iRBbLxdjlLtq5PqcOxB9CONxNYeG9RL31y3MiSfYGQIysyq+JohKG87mDVgGMibTsiR+2wjRI2VdjUbCkwLrSHr/W/veJFrh5wC4nl8zofvGrpznm+8yb0OuQN9A10+67VcxzKoG/0I/ROKWAhpebakj3Yv8TrHG+/B0sxjH1tQHjRfaqVC1BQTkh+cmECXAAvsXYNSTudumHHEvUignzhFNuaIEh3nN8kUCrBojER5Oak/auGCCbLLqo/MZ52T+ZQo2liKIeHoPSpAykr3kx7XrcL9rg4h3cAaf3xi8m+HKPv3WfRBLFP5qjZijWFd29OpQAteluZKQsYU1wJYJqOuxOBRiDmdr2RIwIwwNlkk504YHgN1705bIPIEnBHTmYuE1qPHZmib5pcx+r8Gr2VEvhNHpEHyZ+7DzLbnYM2XaKULAo9s4yUd8iZ8JwWiFlgtEzNqbmc5lahmEnwVCvBP1h96xuPq9MzlQrJFWbf6tmOs9jRzlDvyixqeADmSb1T2M47wFQpCA6harqIN+czGTdOOgQRK4onlDFS5RpZXtRVS6B+5fdHB23evmem/Nc7hX5mZGEKoWhd+Jnb0B5bg8+XnJ27XeFrlDw8nQb3/+hUCQZnjbh5cUmrqMihTHxqQ29sTSLvstzeEemgySvPXiKkylwWJ+7d9VzfEY8GrqEV8cfkbFmUg== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb39e88d-a2f3-4077-470e-08da1d60d8f3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 15:18:22.2421 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vg4DqOaz3Q/Xk/Ij3irZaR+rcqN2IC5tMxKDsh8XrTVcULVKoZv5dzvdBeFUMI5cugKo5/yNBMTdFClvfSZ2sg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB4616 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vadim Pasternak The port module core is tasked with module operations such as setting power mode policy and reset. The per-module information is currently stored in one large array suited for non-modular systems where only the main board is present (i.e., slot index 0). As a preparation for line cards support, allocate a per line card array according to the queried number of slots in the system. For each line card, allocate a module array according to the queried maximum number of modules per-slot. Signed-off-by: Vadim Pasternak Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/core_env.c | 242 ++++++++++++------ 1 file changed, 169 insertions(+), 73 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c index 95fbfb1ca421..9adaa8978d68 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c @@ -21,20 +21,36 @@ struct mlxsw_env_module_info { enum mlxsw_reg_pmtm_module_type type; }; -struct mlxsw_env { - struct mlxsw_core *core; +struct mlxsw_env_line_card { u8 module_count; - struct mutex module_info_lock; /* Protects 'module_info'. */ struct mlxsw_env_module_info module_info[]; }; +struct mlxsw_env { + struct mlxsw_core *core; + u8 max_module_count; /* Maximum number of modules per-slot. */ + u8 num_of_slots; /* Including the main board. */ + struct mutex line_cards_lock; /* Protects line cards. */ + struct mlxsw_env_line_card *line_cards[]; +}; + +static struct +mlxsw_env_module_info *mlxsw_env_module_info_get(struct mlxsw_core *mlxsw_core, + u8 slot_index, u8 module) +{ + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + + return &mlxsw_env->line_cards[slot_index]->module_info[module]; +} + static int __mlxsw_env_validate_module_type(struct mlxsw_core *core, u8 slot_index, u8 module) { - struct mlxsw_env *mlxsw_env = mlxsw_core_env(core); + struct mlxsw_env_module_info *module_info; int err; - switch (mlxsw_env->module_info[module].type) { + module_info = mlxsw_env_module_info_get(core, slot_index, module); + switch (module_info->type) { case MLXSW_REG_PMTM_MODULE_TYPE_TWISTED_PAIR: err = -EINVAL; break; @@ -51,9 +67,9 @@ static int mlxsw_env_validate_module_type(struct mlxsw_core *core, struct mlxsw_env *mlxsw_env = mlxsw_core_env(core); int err; - mutex_lock(&mlxsw_env->module_info_lock); + mutex_lock(&mlxsw_env->line_cards_lock); err = __mlxsw_env_validate_module_type(core, slot_index, module); - mutex_unlock(&mlxsw_env->module_info_lock); + mutex_unlock(&mlxsw_env->line_cards_lock); return err; } @@ -472,6 +488,7 @@ int mlxsw_env_reset_module(struct net_device *netdev, u8 module, u32 *flags) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + struct mlxsw_env_module_info *module_info; u32 req = *flags; int err; @@ -479,7 +496,7 @@ int mlxsw_env_reset_module(struct net_device *netdev, !(req & (ETH_RESET_PHY << ETH_RESET_SHARED_SHIFT))) return 0; - mutex_lock(&mlxsw_env->module_info_lock); + mutex_lock(&mlxsw_env->line_cards_lock); err = __mlxsw_env_validate_module_type(mlxsw_core, slot_index, module); if (err) { @@ -487,13 +504,14 @@ int mlxsw_env_reset_module(struct net_device *netdev, goto out; } - if (mlxsw_env->module_info[module].num_ports_up) { + module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); + if (module_info->num_ports_up) { netdev_err(netdev, "Cannot reset module when ports using it are administratively up\n"); err = -EINVAL; goto out; } - if (mlxsw_env->module_info[module].num_ports_mapped > 1 && + if (module_info->num_ports_mapped > 1 && !(req & (ETH_RESET_PHY << ETH_RESET_SHARED_SHIFT))) { netdev_err(netdev, "Cannot reset module without \"phy-shared\" flag when shared by multiple ports\n"); err = -EINVAL; @@ -509,7 +527,7 @@ int mlxsw_env_reset_module(struct net_device *netdev, *flags &= ~(ETH_RESET_PHY | (ETH_RESET_PHY << ETH_RESET_SHARED_SHIFT)); out: - mutex_unlock(&mlxsw_env->module_info_lock); + mutex_unlock(&mlxsw_env->line_cards_lock); return err; } EXPORT_SYMBOL(mlxsw_env_reset_module); @@ -521,11 +539,12 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, struct netlink_ext_ack *extack) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + struct mlxsw_env_module_info *module_info; char mcion_pl[MLXSW_REG_MCION_LEN]; u32 status_bits; int err; - mutex_lock(&mlxsw_env->module_info_lock); + mutex_lock(&mlxsw_env->line_cards_lock); err = __mlxsw_env_validate_module_type(mlxsw_core, slot_index, module); if (err) { @@ -533,7 +552,8 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, goto out; } - params->policy = mlxsw_env->module_info[module].power_mode_policy; + module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); + params->policy = module_info->power_mode_policy; mlxsw_reg_mcion_pack(mcion_pl, slot_index, module); err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mcion), mcion_pl); @@ -552,7 +572,7 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, params->mode = ETHTOOL_MODULE_POWER_MODE_HIGH; out: - mutex_unlock(&mlxsw_env->module_info_lock); + mutex_unlock(&mlxsw_env->line_cards_lock); return err; } EXPORT_SYMBOL(mlxsw_env_get_module_power_mode); @@ -634,6 +654,7 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, struct netlink_ext_ack *extack) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + struct mlxsw_env_module_info *module_info; bool low_power; int err = 0; @@ -643,7 +664,7 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, return -EOPNOTSUPP; } - mutex_lock(&mlxsw_env->module_info_lock); + mutex_lock(&mlxsw_env->line_cards_lock); err = __mlxsw_env_validate_module_type(mlxsw_core, slot_index, module); if (err) { @@ -652,11 +673,12 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, goto out; } - if (mlxsw_env->module_info[module].power_mode_policy == policy) + module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); + if (module_info->power_mode_policy == policy) goto out; /* If any ports are up, we are already in high power mode. */ - if (mlxsw_env->module_info[module].num_ports_up) + if (module_info->num_ports_up) goto out_set_policy; low_power = policy == ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO; @@ -666,9 +688,9 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, goto out; out_set_policy: - mlxsw_env->module_info[module].power_mode_policy = policy; + module_info->power_mode_policy = policy; out: - mutex_unlock(&mlxsw_env->module_info_lock); + mutex_unlock(&mlxsw_env->line_cards_lock); return err; } EXPORT_SYMBOL(mlxsw_env_set_module_power_mode); @@ -748,10 +770,11 @@ mlxsw_env_temp_event_set(struct mlxsw_core *mlxsw_core, u8 slot_index, static int mlxsw_env_module_temp_event_enable(struct mlxsw_core *mlxsw_core, u8 slot_index) { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); int i, err, sensor_index; bool has_temp_sensor; - for (i = 0; i < mlxsw_core_env(mlxsw_core)->module_count; i++) { + for (i = 0; i < mlxsw_env->line_cards[slot_index]->module_count; i++) { err = mlxsw_env_module_has_temp_sensor(mlxsw_core, slot_index, i, &has_temp_sensor); if (err) @@ -779,6 +802,7 @@ struct mlxsw_env_module_temp_warn_event { static void mlxsw_env_mtwe_event_work(struct work_struct *work) { struct mlxsw_env_module_temp_warn_event *event; + struct mlxsw_env_module_info *module_info; struct mlxsw_env *mlxsw_env; int i, sensor_warning; bool is_overheat; @@ -787,7 +811,7 @@ static void mlxsw_env_mtwe_event_work(struct work_struct *work) work); mlxsw_env = event->mlxsw_env; - for (i = 0; i < mlxsw_env->module_count; i++) { + for (i = 0; i < mlxsw_env->max_module_count; i++) { /* 64-127 of sensor_index are mapped to the port modules * sequentially (module 0 is mapped to sensor_index 64, * module 1 to sensor_index 65 and so on) @@ -795,9 +819,10 @@ static void mlxsw_env_mtwe_event_work(struct work_struct *work) sensor_warning = mlxsw_reg_mtwe_sensor_warning_get(event->mtwe_pl, i + MLXSW_REG_MTMP_MODULE_INDEX_MIN); - mutex_lock(&mlxsw_env->module_info_lock); - is_overheat = - mlxsw_env->module_info[i].is_overheat; + mutex_lock(&mlxsw_env->line_cards_lock); + /* MTWE only supports main board. */ + module_info = mlxsw_env_module_info_get(mlxsw_env->core, 0, i); + is_overheat = module_info->is_overheat; if ((is_overheat && sensor_warning) || (!is_overheat && !sensor_warning)) { @@ -805,21 +830,21 @@ static void mlxsw_env_mtwe_event_work(struct work_struct *work) * warning OR current state in "no warning" and MTWE * does not report warning. */ - mutex_unlock(&mlxsw_env->module_info_lock); + mutex_unlock(&mlxsw_env->line_cards_lock); continue; } else if (is_overheat && !sensor_warning) { /* MTWE reports "no warning", turn is_overheat off. */ - mlxsw_env->module_info[i].is_overheat = false; - mutex_unlock(&mlxsw_env->module_info_lock); + module_info->is_overheat = false; + mutex_unlock(&mlxsw_env->line_cards_lock); } else { /* Current state is "no warning" and MTWE reports * "warning", increase the counter and turn is_overheat * on. */ - mlxsw_env->module_info[i].is_overheat = true; - mlxsw_env->module_info[i].module_overheat_counter++; - mutex_unlock(&mlxsw_env->module_info_lock); + module_info->is_overheat = true; + module_info->module_overheat_counter++; + mutex_unlock(&mlxsw_env->line_cards_lock); } } @@ -871,6 +896,7 @@ struct mlxsw_env_module_plug_unplug_event { static void mlxsw_env_pmpe_event_work(struct work_struct *work) { struct mlxsw_env_module_plug_unplug_event *event; + struct mlxsw_env_module_info *module_info; struct mlxsw_env *mlxsw_env; bool has_temp_sensor; u16 sensor_index; @@ -880,9 +906,12 @@ static void mlxsw_env_pmpe_event_work(struct work_struct *work) work); mlxsw_env = event->mlxsw_env; - mutex_lock(&mlxsw_env->module_info_lock); - mlxsw_env->module_info[event->module].is_overheat = false; - mutex_unlock(&mlxsw_env->module_info_lock); + mutex_lock(&mlxsw_env->line_cards_lock); + module_info = mlxsw_env_module_info_get(mlxsw_env->core, + event->slot_index, + event->module); + module_info->is_overheat = false; + mutex_unlock(&mlxsw_env->line_cards_lock); err = mlxsw_env_module_has_temp_sensor(mlxsw_env->core, event->slot_index, @@ -909,12 +938,14 @@ static void mlxsw_env_pmpe_listener_func(const struct mlxsw_reg_info *reg, char *pmpe_pl, void *priv) { + u8 slot_index = mlxsw_reg_pmpe_slot_index_get(pmpe_pl); struct mlxsw_env_module_plug_unplug_event *event; enum mlxsw_reg_pmpe_module_status module_status; u8 module = mlxsw_reg_pmpe_module_get(pmpe_pl); struct mlxsw_env *mlxsw_env = priv; - if (WARN_ON_ONCE(module >= mlxsw_env->module_count)) + if (WARN_ON_ONCE(module >= mlxsw_env->max_module_count || + slot_index >= mlxsw_env->num_of_slots)) return; module_status = mlxsw_reg_pmpe_module_status_get(pmpe_pl); @@ -926,7 +957,7 @@ mlxsw_env_pmpe_listener_func(const struct mlxsw_reg_info *reg, char *pmpe_pl, return; event->mlxsw_env = mlxsw_env; - event->slot_index = 0; + event->slot_index = slot_index; event->module = module; INIT_WORK(&event->work, mlxsw_env_pmpe_event_work); mlxsw_core_schedule_work(&event->work); @@ -957,9 +988,10 @@ static int mlxsw_env_module_oper_state_event_enable(struct mlxsw_core *mlxsw_core, u8 slot_index) { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); int i, err; - for (i = 0; i < mlxsw_core_env(mlxsw_core)->module_count; i++) { + for (i = 0; i < mlxsw_env->line_cards[slot_index]->module_count; i++) { char pmaos_pl[MLXSW_REG_PMAOS_LEN]; mlxsw_reg_pmaos_pack(pmaos_pl, slot_index, i); @@ -978,10 +1010,12 @@ mlxsw_env_module_overheat_counter_get(struct mlxsw_core *mlxsw_core, u8 slot_ind u8 module, u64 *p_counter) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + struct mlxsw_env_module_info *module_info; - mutex_lock(&mlxsw_env->module_info_lock); - *p_counter = mlxsw_env->module_info[module].module_overheat_counter; - mutex_unlock(&mlxsw_env->module_info_lock); + mutex_lock(&mlxsw_env->line_cards_lock); + module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); + *p_counter = module_info->module_overheat_counter; + mutex_unlock(&mlxsw_env->line_cards_lock); return 0; } @@ -991,10 +1025,12 @@ void mlxsw_env_module_port_map(struct mlxsw_core *mlxsw_core, u8 slot_index, u8 module) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + struct mlxsw_env_module_info *module_info; - mutex_lock(&mlxsw_env->module_info_lock); - mlxsw_env->module_info[module].num_ports_mapped++; - mutex_unlock(&mlxsw_env->module_info_lock); + mutex_lock(&mlxsw_env->line_cards_lock); + module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); + module_info->num_ports_mapped++; + mutex_unlock(&mlxsw_env->line_cards_lock); } EXPORT_SYMBOL(mlxsw_env_module_port_map); @@ -1002,10 +1038,12 @@ void mlxsw_env_module_port_unmap(struct mlxsw_core *mlxsw_core, u8 slot_index, u8 module) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + struct mlxsw_env_module_info *module_info; - mutex_lock(&mlxsw_env->module_info_lock); - mlxsw_env->module_info[module].num_ports_mapped--; - mutex_unlock(&mlxsw_env->module_info_lock); + mutex_lock(&mlxsw_env->line_cards_lock); + module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); + module_info->num_ports_mapped--; + mutex_unlock(&mlxsw_env->line_cards_lock); } EXPORT_SYMBOL(mlxsw_env_module_port_unmap); @@ -1013,15 +1051,17 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 slot_index, u8 module) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + struct mlxsw_env_module_info *module_info; int err = 0; - mutex_lock(&mlxsw_env->module_info_lock); + mutex_lock(&mlxsw_env->line_cards_lock); - if (mlxsw_env->module_info[module].power_mode_policy != + module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); + if (module_info->power_mode_policy != ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) goto out_inc; - if (mlxsw_env->module_info[module].num_ports_up != 0) + if (module_info->num_ports_up != 0) goto out_inc; /* Transition to high power mode following first port using the module @@ -1033,9 +1073,9 @@ int mlxsw_env_module_port_up(struct mlxsw_core *mlxsw_core, u8 slot_index, goto out_unlock; out_inc: - mlxsw_env->module_info[module].num_ports_up++; + module_info->num_ports_up++; out_unlock: - mutex_unlock(&mlxsw_env->module_info_lock); + mutex_unlock(&mlxsw_env->line_cards_lock); return err; } EXPORT_SYMBOL(mlxsw_env_module_port_up); @@ -1044,16 +1084,18 @@ void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 slot_index, u8 module) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + struct mlxsw_env_module_info *module_info; - mutex_lock(&mlxsw_env->module_info_lock); + mutex_lock(&mlxsw_env->line_cards_lock); - mlxsw_env->module_info[module].num_ports_up--; + module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, module); + module_info->num_ports_up--; - if (mlxsw_env->module_info[module].power_mode_policy != + if (module_info->power_mode_policy != ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) goto out_unlock; - if (mlxsw_env->module_info[module].num_ports_up != 0) + if (module_info->num_ports_up != 0) goto out_unlock; /* Transition to low power mode following last port using the module @@ -1063,17 +1105,57 @@ void mlxsw_env_module_port_down(struct mlxsw_core *mlxsw_core, u8 slot_index, NULL); out_unlock: - mutex_unlock(&mlxsw_env->module_info_lock); + mutex_unlock(&mlxsw_env->line_cards_lock); } EXPORT_SYMBOL(mlxsw_env_module_port_down); +static int mlxsw_env_line_cards_alloc(struct mlxsw_env *env) +{ + struct mlxsw_env_module_info *module_info; + int i, j; + + for (i = 0; i < env->num_of_slots; i++) { + env->line_cards[i] = kzalloc(struct_size(env->line_cards[i], + module_info, + env->max_module_count), + GFP_KERNEL); + if (!env->line_cards[i]) + goto kzalloc_err; + + /* Firmware defaults to high power mode policy where modules + * are transitioned to high power mode following plug-in. + */ + for (j = 0; j < env->max_module_count; j++) { + module_info = &env->line_cards[i]->module_info[j]; + module_info->power_mode_policy = + ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH; + } + } + + return 0; + +kzalloc_err: + for (i--; i >= 0; i--) + kfree(env->line_cards[i]); + return -ENOMEM; +} + +static void mlxsw_env_line_cards_free(struct mlxsw_env *env) +{ + int i = env->num_of_slots; + + for (i--; i >= 0; i--) + kfree(env->line_cards[i]); +} + static int mlxsw_env_module_type_set(struct mlxsw_core *mlxsw_core, u8 slot_index) { struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); int i; - for (i = 0; i < mlxsw_env->module_count; i++) { + for (i = 0; i < mlxsw_env->line_cards[slot_index]->module_count; i++) { + struct mlxsw_env_module_info *module_info; char pmtm_pl[MLXSW_REG_PMTM_LEN]; int err; @@ -1082,8 +1164,9 @@ mlxsw_env_module_type_set(struct mlxsw_core *mlxsw_core, u8 slot_index) if (err) return err; - mlxsw_env->module_info[i].type = - mlxsw_reg_pmtm_module_type_get(pmtm_pl); + module_info = mlxsw_env_module_info_get(mlxsw_core, slot_index, + i); + module_info->type = mlxsw_reg_pmtm_module_type_get(pmtm_pl); } return 0; @@ -1091,32 +1174,38 @@ mlxsw_env_module_type_set(struct mlxsw_core *mlxsw_core, u8 slot_index) int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) { + u8 module_count, num_of_slots, max_module_count; char mgpir_pl[MLXSW_REG_MGPIR_LEN]; struct mlxsw_env *env; - u8 module_count; - int i, err; + int err; mlxsw_reg_mgpir_pack(mgpir_pl, 0); err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mgpir), mgpir_pl); if (err) return err; - mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count, NULL); + mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, &module_count, + &num_of_slots); + /* If the system is modular, get the maximum number of modules per-slot. + * Otherwise, get the maximum number of modules on the main board. + */ + max_module_count = num_of_slots ? + mlxsw_reg_mgpir_max_modules_per_slot_get(mgpir_pl) : + module_count; - env = kzalloc(struct_size(env, module_info, module_count), GFP_KERNEL); + env = kzalloc(struct_size(env, line_cards, num_of_slots + 1), + GFP_KERNEL); if (!env) return -ENOMEM; - /* Firmware defaults to high power mode policy where modules are - * transitioned to high power mode following plug-in. - */ - for (i = 0; i < module_count; i++) - env->module_info[i].power_mode_policy = - ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH; - - mutex_init(&env->module_info_lock); env->core = mlxsw_core; - env->module_count = module_count; + env->num_of_slots = num_of_slots + 1; + env->max_module_count = max_module_count; + err = mlxsw_env_line_cards_alloc(env); + if (err) + goto err_mlxsw_env_line_cards_alloc; + + mutex_init(&env->line_cards_lock); *p_env = env; err = mlxsw_env_temp_warn_event_register(mlxsw_core); @@ -1127,6 +1216,10 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) if (err) goto err_module_plug_event_register; + /* Set 'module_count' only for main board. Actual count for line card + * is to be set after line card is activated. + */ + env->line_cards[0]->module_count = num_of_slots ? 0 : module_count; err = mlxsw_env_module_oper_state_event_enable(mlxsw_core, 0); if (err) goto err_oper_state_event_enable; @@ -1148,7 +1241,9 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) err_module_plug_event_register: mlxsw_env_temp_warn_event_unregister(env); err_temp_warn_event_register: - mutex_destroy(&env->module_info_lock); + mutex_destroy(&env->line_cards_lock); + mlxsw_env_line_cards_free(env); +err_mlxsw_env_line_cards_alloc: kfree(env); return err; } @@ -1159,6 +1254,7 @@ void mlxsw_env_fini(struct mlxsw_env *env) /* Make sure there is no more event work scheduled. */ mlxsw_core_flush_owq(); mlxsw_env_temp_warn_event_unregister(env); - mutex_destroy(&env->module_info_lock); + mutex_destroy(&env->line_cards_lock); + mlxsw_env_line_cards_free(env); kfree(env); } From patchwork Wed Apr 13 15:17:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12812120 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64EA4C433EF for ; Wed, 13 Apr 2022 15:18:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236222AbiDMPVH (ORCPT ); Wed, 13 Apr 2022 11:21:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235799AbiDMPVG (ORCPT ); Wed, 13 Apr 2022 11:21:06 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2085.outbound.protection.outlook.com [40.107.220.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA8892ED47 for ; Wed, 13 Apr 2022 08:18:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YPgT/44ArygPoJLBiT6E3AGH+D2kpRJjtBSxQNEOyba30bgKi37sBV9M9jsS42O6ka4aT0t1NwhZKaLpVzMMo80fmqCj5c/WOtmf3/H36TIjGl8yw7GXqHx7JOm3snenjqAezDImtOix1OAHuVllJAovsv+FTB6T15u88XEeCGgCkcTi3eRKF2yZp4q087U5BWuexT8qJyz0OBMnwmyWUcIsGrWqQxnz8w8dI2mk/OTYQn1RYt7DkqrCz5kZjQMTu5AOFf3lEhDVsGECumGwM+HyxxAt/6DwIZWI/+xWxxQ69jlgqUsE+TXQ2NtALnQ0w5eSTQvUaqxuTfiidAxeSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0SCLLaGAnEIsrffHO6tPiUmVlYRDL7OR7P6QtNNuEuQ=; b=CVIsHdBtOHnMxsmlhJbA/OlY+aXNh5JFrKHOdjW14uASxqrt/Ob4S2qP+xNYtrcBA6nSRi9U0P4+YNfSY6WR9MmfsG6YLFVmLigzx6eutVt8TWQdAI9IIbhd6m7Gkwmzp67lEnpEqqFSE880opd6/xRiPl/zGheBMH+o6uKPhs4q2VgH9UEaJRilCa/oGiGptaVbrFzfqKMw58s3yDNsLx9GtxBr8xvGVhwzCAQ7eEZk117XkoU/83WwkMhY2UMWjGY9vg+jXBuP06iR3oQPMpOIhCe3sHPjGqg6xQKZrBtu7KmcvTbNv4yrJlUWe9J4MJbOzIoeugxyM1WRH7TTRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=0SCLLaGAnEIsrffHO6tPiUmVlYRDL7OR7P6QtNNuEuQ=; b=BRaVNdPclhfLzyvnVlP7I9srGrYKEnRXCuWQHfUpaS9wFWvMRGLOL42AGz0KJAhETCcdRuqz+WTvaWFtoigKwC2cnOv26wHp9+YDI6Ue6ENMlvoD/EiwvwMROEyMOAyIN2vO7izEwFsdVH5PKlESUAO2knGnTmE/Zh7KNUiqg+C5V4nd9VSNmdKALF1MnKOZ2/nSSIKCZKDKCSJSeE0Yoh12Xop47Uzcneg4QkvHGbcN8k9zz6M2igh9rdOJpG00B+XK27CHbRy8RMWBiEucDV53w5dVPi3ctIFKpQvR8cQQIDGvDZBdolqmRrIn1U7IEluAIbHX3lZeOPHGl+YqFg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MN2PR12MB3279.namprd12.prod.outlook.com (2603:10b6:208:105::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29; Wed, 13 Apr 2022 15:18:29 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402%5]) with mapi id 15.20.5144.029; Wed, 13 Apr 2022 15:18:29 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, petrm@nvidia.com, vadimp@nvidia.com, jiri@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 3/9] mlxsw: core: Move port module events enablement to a separate function Date: Wed, 13 Apr 2022 18:17:27 +0300 Message-Id: <20220413151733.2738867-4-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220413151733.2738867-1-idosch@nvidia.com> References: <20220413151733.2738867-1-idosch@nvidia.com> X-ClientProxiedBy: VE1PR08CA0020.eurprd08.prod.outlook.com (2603:10a6:803:104::33) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a1a3be5-c9e4-4b2c-979f-08da1d60dd15 X-MS-TrafficTypeDiagnostic: MN2PR12MB3279:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dUXup8DWa4kNdUFizTY1yraKJXjlLznSqdgWkFKTnsaOLPY46OxOm0zG95twC90SGNfdM17sdGhKr8dU9KAm1uj+gjQg36w0X49+Xv5CoGn8Z3Ku1KWrPKqe/awGyBTLH/UbpUPBxZQfnIPP5t1MD0L9cz5+IUF7H0UzjjF8T6hW56KDRzgqK07YlfnyGm/ZwkZ46a8KmLvxVfJ/9Ll7dsitf3s9i3tiPPtLNr/vVtHHaj/gpIy28GgFIXo+7b2r3wLVsHrahOl6QIlWM46egAPnPefOAyfE0GMjtg+iqjS62su0cN2EOdGMDwjpyKSVfYeCCEgPxzfjmOjBH5NjUCbTjHWdjFRRq+TbtvjbuPU+yTLN4DmHBFVUTC/V/nkvYSdcpuuCS9mdftK1LBYfOysj3EYkQTGgXBOnaeISvQ/OocEeysNX9rvVnQkRJ+dBzOrtfr12CcwXJT+Dm646pZxv90i32tVjphkWzmIhIUj2YqgBw47wIAJ9IhTntAC3udLRhjcySl1VXURDl1rnOb1Iw0jHKbJfhAxCi8WY0y8D7QNFjeb1IQGjvHiNQJBk+2v8lZt/FrgVjJNRTVis5XTt3hyQWeNdJQKklPkVXle59+A2m1vGtfUSnerCZe2C2C3UbJuBwHvQdsfagnkDmA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(66946007)(8936002)(508600001)(186003)(26005)(107886003)(1076003)(2906002)(38100700002)(83380400001)(86362001)(36756003)(6506007)(2616005)(66476007)(66556008)(4326008)(8676002)(6916009)(6512007)(316002)(6486002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I4I6IwHPOdBGnT32CsTFW3HM+rjugKVt4lAZJTg4j9N/U2UKYMkPH9qNrIb8A0C8MOsKtojl1HOKwI8OAyhhp/VxoYqswok0RInhutna1lFy8viXH3KPEf8K0I6c+p1dZsRWyDK70lTnntdM6g8iQeutuh1shRiLj/Ebhwl1WXCiMzqOOnxflUWwtrU7AjiXwXLoCGDYxqcM1Dsct9xx1kqgtSQ9H3n/cPeo1mSQgT7NgqSvY/Qc2pwZtZ2kEpWtMT/BfUd9y6ABdzSYI5IAONK3UORwSpI8eLoUklyyOc8+MGBk4S6KPQwul+LD+Xo+5/dMawySri4LBXVzxgYtnUAIU81yisSrSPVOOTptZFIENgmT4RRg5cUynD6AVi89pPrOISQ0QVh00VziITgJuYscsMmn5ZXcSdwkeMF6gfZOVSuditAfaiqzkxK0j/Ng5ZhoM6uZeKPuKg4+ZwIqOuEbQ6ORMDAUQ6LM94asc5PmDCHxclKSTYrM3om0TOsXZ2mztHPvGwIWknK9jiJs94t35+SQsF9INlntmsFq0UKeizjqlNXDOy4xDLZIghNK14ePBv0fGiQQtaqeP86/edCVGtMHKCrhjYKRFlaqgDk4nOSP1ONaBJaPJVGm4PuKqpX29c82zQDDa8LvGr/VdqoTCApOUOhXPngHV9BJrCkdrBKQ//bOc7+AOZbl07TZKI3nPmI1U6lKKesCIYnDoH++/DnJbDEb4xsSOUGeMSiDnE2ueFWKuWjy7G6QRcM+GyIxBv9Bte89aneGH3dMpJ42UjO3CrGq5sM6t7N406IRlOJNAC3X9/L0PedSXjAS4UFlA/JBei+m9j+gUrRGq8G0aQ9zrR7nWb5AfWIIeetWAultbdRAZDKi59W/Gi3GkSP5414aS5XOh53e5jBgef+hZ07CtRhK9Ex1oJuDP0LtUEoJeniA+z36biqUD2DCwuFSxpWkvPmJvC8e3KtwOCFyPUOTKOaADElXeuIoXVZljiqo/kST+SjZ5z+baGk6BJR6ZX6YqHAjNLH2aMaKLNWobwsMPyfB8LKsgyZVDU/XzWx1b43XJkbY+g5L51tcOVH8RBXD39rltoCRCp+q2GeEK7emiWNu03lSjrs6BR0vkxkUtkuFcYQrZfY520lka1kS2scFKK9hMMuO0MmB2aRiPx8F/vjy98WDowYFgLl4rAYEfbbdHn1iy5Cn67Abt+K+5ztGWSFlYDK6KA2PgaE0YE5boD7/Pn3IJ19odnEApnGrFw+BOPgIUQJvXW/Y+PsvR9sWu1Pv9McvlTHckLAiOx/WyYF1CafNLvgti99/vGRA4PGLCACdiwkxhBAGdjPcKHIhktuR6D9xB3ozDCC7WBukXTW/I5Rt5LgC6GzP4a0JQhfoHHtu47nrq4nQ4ViBXJu3y8EHNBiMWsP2Sz2gDILeLid34TuF6rBgpZyFCicqrttYW04zePbrjW0As1KTN70yc5NpWbeh5mGFJSnla5gJa+ob81A068/9yGiENm1uCLl4v8ZRlLTGBoYkSvATWLfVc1fsqL964SPb/le9Eq0P8DoQhLU/pdQX5D5pvvZy+p0PvpXq7rRela7d4suuOmEN3NWqniYMWFH4UhAkjpLBw/o+mOJRjDZjLUQr+KEd6xvaHuBfOf2TY05J+NBaS7nFYBUaOyu6VP61HV3iOIGJzbdb628042cPSWmEjO8sEqBCvzfSgEvqxMgSJ0BGuEdey9SFwMo3jmgmpg== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a1a3be5-c9e4-4b2c-979f-08da1d60dd15 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 15:18:29.0685 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kp94A9eBOKA7SNKW/79cjHHlidZtZgb3PhlMEHHu1jP9nhjCdrNVEev6DYWAiGlD63IjK4HfZetyhH3Ag8seZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3279 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vadim Pasternak Use a separate function for enablement of port module events such plug/unplug and temperature threshold crossing. The motivation is to reuse the function for line cards. Signed-off-by: Vadim Pasternak Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/core_env.c | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c index 9adaa8978d68..b3b8a9015cd6 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c @@ -1148,6 +1148,28 @@ static void mlxsw_env_line_cards_free(struct mlxsw_env *env) kfree(env->line_cards[i]); } +static int +mlxsw_env_module_event_enable(struct mlxsw_env *mlxsw_env, u8 slot_index) +{ + int err; + + err = mlxsw_env_module_oper_state_event_enable(mlxsw_env->core, + slot_index); + if (err) + return err; + + err = mlxsw_env_module_temp_event_enable(mlxsw_env->core, slot_index); + if (err) + return err; + + return 0; +} + +static void +mlxsw_env_module_event_disable(struct mlxsw_env *mlxsw_env, u8 slot_index) +{ +} + static int mlxsw_env_module_type_set(struct mlxsw_core *mlxsw_core, u8 slot_index) { @@ -1220,13 +1242,13 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) * is to be set after line card is activated. */ env->line_cards[0]->module_count = num_of_slots ? 0 : module_count; - err = mlxsw_env_module_oper_state_event_enable(mlxsw_core, 0); - if (err) - goto err_oper_state_event_enable; - - err = mlxsw_env_module_temp_event_enable(mlxsw_core, 0); + /* Enable events only for main board. Line card events are to be + * configured only after line card is activated. Before that, access to + * modules on line cards is not allowed. + */ + err = mlxsw_env_module_event_enable(env, 0); if (err) - goto err_temp_event_enable; + goto err_mlxsw_env_module_event_enable; err = mlxsw_env_module_type_set(mlxsw_core, 0); if (err) @@ -1235,8 +1257,8 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) return 0; err_type_set: -err_temp_event_enable: -err_oper_state_event_enable: + mlxsw_env_module_event_disable(env, 0); +err_mlxsw_env_module_event_enable: mlxsw_env_module_plug_event_unregister(env); err_module_plug_event_register: mlxsw_env_temp_warn_event_unregister(env); @@ -1250,6 +1272,7 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env) void mlxsw_env_fini(struct mlxsw_env *env) { + mlxsw_env_module_event_disable(env, 0); mlxsw_env_module_plug_event_unregister(env); /* Make sure there is no more event work scheduled. */ mlxsw_core_flush_owq(); From patchwork Wed Apr 13 15:17:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12812121 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBED1C433F5 for ; Wed, 13 Apr 2022 15:18:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236266AbiDMPVS (ORCPT ); Wed, 13 Apr 2022 11:21:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236241AbiDMPVR (ORCPT ); Wed, 13 Apr 2022 11:21:17 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2073.outbound.protection.outlook.com [40.107.220.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 668012E9E3 for ; Wed, 13 Apr 2022 08:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NwOfay1z1Sb+VKVAt3UF2F90cfjrKvsKZwyrPdSqLY91oAj5qLDHLvmNPTGTb0TVj0KDbAiIINF6JR1OmHM8QkjfUumKXWSDb4hwlx5JweIxKbeaOwhY1vBQOFRCuYEA2IXbD0RVQkK48DV9n7k20ICHH3xGG6i3QgMCf5g/AmwwDXR8VibdrwJcNY8FclarTVddy1X6ppsf/dI/M6ZDGqF8De1nZvD+gzQ0pf+I7viTtRlPD6Bkm/+g98hdY5Ox/pqOcpUhIawcgAa9oQI7IuwvZn+tMWKNOSTyRcnK3BzeU9Tvmb9zilaUZducDCdGo1JPQmE44XoOmiTfVXbvKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qSFm1+A0v57iVhq8p/599hsbHo8atLSb+JxgrqjJa50=; b=cVB/LgY9DZ0qxNpGhtedQ0SBDxZkqOj5Bv3kDLTvoEDpCZ14+HHigsZmjM6rdPYnw6tntg5BoFzC0GIIpIM5Mx/Z846pPlcV/l1pRh+vOBD81yvVwX/iDz5AHo3SpfD/jRJVkWDHd/Ggq7jxkywXpdex5gKsxksTWYx1Naa/wyl3RcNU4pwE2BFyYT6v1WSJfsZZuhEahz2KiSN4imAgqF+GqveZpv0uI8K4ZcdPJg23jzDZsa8zphBT4hr5gNpxDbYof4SKdTZLoAVd8WdVS99zP0oMEm+Z4iuDn5d+IBt6LWvGkKg3hKSN7NoymkRCeettCzZBu7g4EsZJlkpJIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=qSFm1+A0v57iVhq8p/599hsbHo8atLSb+JxgrqjJa50=; b=bQDtHzavoKw3S5rDp+IPICoJ8lzPiKOU6sICV5bNpNtFIpPg694AlhV8m94PFMHH7S2oHORQBZt6mLr7CTJpTrNp46PszwF74pKqHkqAy5DBjBaxmNXwq+qs32xiezJkNbuk4IWl6JhVzx4KYO3JBtqJFoujiIUANPScNSYjdR70EYQSF3o2ivnEm5GaJamgHJQT4WTFFlPBQ3SuMHW9+5ghw/RNOkqWoG7KpjKgI3bq9rAyFZgmyl1MQf9Y2jPKMSAoUfeVT4ViP0TvNZz0hG3wLZIGaQ2ehs/dU7eMkHzG07oiWwJX2H88oq+QjbZZjGpiz7ElWzStp3bLV6FsfQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MN2PR12MB3279.namprd12.prod.outlook.com (2603:10b6:208:105::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29; Wed, 13 Apr 2022 15:18:35 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402%5]) with mapi id 15.20.5144.029; Wed, 13 Apr 2022 15:18:35 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, petrm@nvidia.com, vadimp@nvidia.com, jiri@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 4/9] mlxsw: core_hwmon: Extend internal structures to support multi hwmon objects Date: Wed, 13 Apr 2022 18:17:28 +0300 Message-Id: <20220413151733.2738867-5-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220413151733.2738867-1-idosch@nvidia.com> References: <20220413151733.2738867-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR09CA0185.eurprd09.prod.outlook.com (2603:10a6:800:120::39) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 048d4b88-c6c6-4e76-977f-08da1d60e0bc X-MS-TrafficTypeDiagnostic: MN2PR12MB3279:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3JqSwR3iT2c++g/9L26rkWZGtFASNGYQe2Bw2MAkXBmREwePpPyX4YgOFtFAaK+tAXxJQvcks3NAMNRp3PefiCMXTOMr2La+2XPI8tK1POZEOubpvCB/FfwavAxLYJuidQSwXBHsHUHyDJSEEybnYFubvDpRdTf4V42G9aLQdXbCJdGjOap9XFbhogEUmdGpSiYAzbnRTrQj57ApyY04CZk0fnu6qDdC4WdKZq8lDdpmzUQb1YJKFbEdur3UdO1fH9cqJdMj1/ZLeIB3dDlKdWN3jjl4tRCHccrdNJKBntoPO+GJ717uu1ya8FM8ph262KNXu9bWgrevVAJG2dqoh44O31NkUbdLHUbue5NGAFADtyDdGMAp0dWGoarBv1UBfeUwvpNo+eHqbF+JhKxQXk11xIRqvlU2zj7jYgdGogzBmFr/EfEbdHmJa1F+s0s2a8jyRl1o9j4Nfpr2syC2rEFgP9P9qSMLfePNfZSFYWIZg99gOu0D3cRgRVdplGy8Sg36M9+YgpBpmJR66PQQ4Zs7llwIlKBs1tauoye4nAwXdObajP187Z4LM2nC3JAFtGRk3A3yt7t+ugCwkjA5CNWumXO0Bb7u2UHiSFSaHUJzaTcXSPHOXtuy0Mgl9HU/aHFnhkmmMhvurdvU+uHPEQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(66946007)(8936002)(508600001)(186003)(26005)(107886003)(1076003)(2906002)(38100700002)(83380400001)(86362001)(36756003)(6506007)(2616005)(66476007)(66556008)(6666004)(30864003)(4326008)(8676002)(6916009)(6512007)(316002)(6486002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IZ+qAPInvCalhjX8E82BADH015P6nre31RxY6eDuacTPlzdmfRuBTqwnQDrXJ+ouVGQfZfitpqR5Vqc/VaOOjIRwfOwxSpWvopSnmXAxBTKHtP1bk+WMpxOnG77NbKGlej+Dq4AuvgRyTNhRp3NoXwqPSGAlKE2ljBkHVqryxdzIpATd954kf92hDckSYli6b3xrhyJ1UHlvOqrVIVVaoJsfu5YGgyk1lC/KF0Dmyp2yZ79PO2azFpgd25hBUsYPD1ALqzUPEm4xoUeWrQTChPEl3vuHTAYaD0gjcBh8PtbNPR14UAYCSLsuy3BrqQl8e3Ix0NP0FVw1eReB3dThCyGP7Ktn9zAnto0HnDEfPpUshbFntCh6IdORWtenCfOA0oYtglKSdDc/fywRmBMJZ28dEk0IlQhOEIgGSdIKvp6Bt3rdqlFg95UemvMANIQT9Wdb2DCDYIEw0KznjetHG7EXQ9tLaxOT7exTcmuWSJvnIMyIDhedtuBHvDWxQX7I30bsDca6JNGJ+uXa682GOMZ30cv9gw7rQ4/OD9Kvcfja2kbcakYIzrAx2vmTGRIhLgsHiFgPku7LBtL1V2mBYw7faJmP6B4Ng9qW6rzuh919LuOHm3t84K7tBr6IYqVOsEr4hO/vQIQmh17qXkvnFi+C29kNsBVWS+OCZLvo7Jqo4qE85S7qrHccYpDi8jjbU71VhPI5n/YOhg0ez+XSvanvdPBWOn5kHMaxkgvyhFKpeLxYipA0KITRYnb7Wv/0ociHvSvY6UG7oDwQmi2GHyi/XnR9vYt2QA5LpjDN3zbFxPQOoDZpPXKJWrOTBM2/YbAwHUFEksM18FKcqvmgUTQkxXx1xS72aEA/g5Vk/7aobiy1P7u6TkbglLbuuEr8hqqN9N8anaY2GdcA6KInqLeEa5K77HzMtOIPMLof7xcfhG9Hyn7oCny0rtwfJtrL1w8YEWk+bhX821MYSJ0tPF5LenS+yB9M/Cm9vfyYSnmVj8MzhWodJmpgpQdpMvZZaZ/dVl3hjE85s1TOrA8Mr0ZP6jFadKAMJLrvcTUxKwyNM6+evpWMiqQ0kovE6c6g+3CucNjv6io8nKH1ue2u28HmdPgnE4m5hd7NkL9kggUbj2QSTp3AJ54K5rVODgXbQ0SHipx1yUk03rLxDHhVwyUrqHTWYOf7aT/3c419ndroZCxi1zjIExyMv3tdxa/a1Ab8liD8XceKO3qjjJDKBlF1942bgpH+gZ56VZGBJEqfbq6lGqjsrxbzBO9+viTGb890eHicaRsqyUGbm2ciUnShSgV4qWL2f4bMukzmAL9SmMWwLedt5aWfTTj9DGBgwnMa9rBMcCxV7fl2UreRZL16XeaNvWUyiIi4zY3q+l3AFmSiURABjnl5RWe1UVexjqpI/TNFetu8D/xxh8RrRljYHBQ79gn1HEuizeeVybrgIIEFbSc/TBljzztVNWMcwphSSlR3jLOxGI/yjYfwpMGDnRhjfQJ0+I3dn361hCNi0z40Mi0v7GWVU1FakTuHQticirV0NKz/pc1ohCmID4NxESTucp2iaBkNFe5w75jRha+u7mGu/76fuH/9uHs5MCnEsJV2zptoaRF1Of1WPuat9mFyL3WW4scTu9c7/C9Ai2lmVsNOMMiixpY6W3QMMWIWDRxvNIvm8i1Gkg1FA0+8wj1OcbIE5F0OvRSVNUX2XorGYTod70bAco0yf57JVnP2DyJ3LZ4CkI0LNg4e8g== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 048d4b88-c6c6-4e76-977f-08da1d60e0bc X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 15:18:35.3211 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iJ5fZK1aGoOkGZUYbGuHUmuS+xhlLZWZQSfaG6abaUHEmp6Ha56mRXPQHtIkNZm6hMAothEY4O6mJcaOkZkX2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3279 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vadim Pasternak Currently, mlxsw supports a single hwmon device and registers it with attributes corresponding to the various objects found on the main board such as fans and gearboxes. Line cards can have the same objects, but unlike the main board they can be added and removed while the system is running. The various hwmon objects found on these line cards should be created when the line card becomes available and destroyed when the line card becomes unavailable. The above can be achieved by representing each line card as a different hwmon device and registering / unregistering it when the line card becomes available / unavailable. Prepare for multi hwmon device support by splitting 'struct mlxsw_hwmon' into 'struct mlxsw_hwmon' and 'struct mlxsw_hwmon_dev'. The first will hold information relevant to all hwmon devices, whereas the second will hold per-hwmon device information. Signed-off-by: Vadim Pasternak Reviewed-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/core_hwmon.c | 187 +++++++++++------- 1 file changed, 111 insertions(+), 76 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c index 5df54a5bf292..d35aa135beed 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c @@ -27,7 +27,7 @@ struct mlxsw_hwmon_attr { struct device_attribute dev_attr; - struct mlxsw_hwmon *hwmon; + struct mlxsw_hwmon_dev *mlxsw_hwmon_dev; unsigned int type_index; char name[32]; }; @@ -40,9 +40,8 @@ static int mlxsw_hwmon_get_attr_index(int index, int count) return index; } -struct mlxsw_hwmon { - struct mlxsw_core *core; - const struct mlxsw_bus_info *bus_info; +struct mlxsw_hwmon_dev { + struct mlxsw_hwmon *hwmon; struct device *hwmon_dev; struct attribute_group group; const struct attribute_group *groups[2]; @@ -53,19 +52,26 @@ struct mlxsw_hwmon { u8 module_sensor_max; }; +struct mlxsw_hwmon { + struct mlxsw_core *core; + const struct mlxsw_bus_info *bus_info; + struct mlxsw_hwmon_dev line_cards[]; +}; + static ssize_t mlxsw_hwmon_temp_show(struct device *dev, struct device_attribute *attr, char *buf) { struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = container_of(attr, struct mlxsw_hwmon_attr, dev_attr); - struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; char mtmp_pl[MLXSW_REG_MTMP_LEN]; int temp, index; int err; index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, - mlxsw_hwmon->module_sensor_max); + mlxsw_hwmon_dev->module_sensor_max); mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); if (err) { @@ -82,13 +88,14 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev, { struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = container_of(attr, struct mlxsw_hwmon_attr, dev_attr); - struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; char mtmp_pl[MLXSW_REG_MTMP_LEN]; int temp_max, index; int err; index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, - mlxsw_hwmon->module_sensor_max); + mlxsw_hwmon_dev->module_sensor_max); mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); if (err) { @@ -105,8 +112,9 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev, { struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = container_of(attr, struct mlxsw_hwmon_attr, dev_attr); - struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; - char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0}; + struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; + char mtmp_pl[MLXSW_REG_MTMP_LEN]; unsigned long val; int index; int err; @@ -118,7 +126,7 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev, return -EINVAL; index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, - mlxsw_hwmon->module_sensor_max); + mlxsw_hwmon_dev->module_sensor_max); mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, index); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); @@ -140,7 +148,8 @@ static ssize_t mlxsw_hwmon_fan_rpm_show(struct device *dev, { struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = container_of(attr, struct mlxsw_hwmon_attr, dev_attr); - struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; char mfsm_pl[MLXSW_REG_MFSM_LEN]; int err; @@ -159,7 +168,8 @@ static ssize_t mlxsw_hwmon_fan_fault_show(struct device *dev, { struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = container_of(attr, struct mlxsw_hwmon_attr, dev_attr); - struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; char fore_pl[MLXSW_REG_FORE_LEN]; bool fault; int err; @@ -180,7 +190,8 @@ static ssize_t mlxsw_hwmon_pwm_show(struct device *dev, { struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = container_of(attr, struct mlxsw_hwmon_attr, dev_attr); - struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; char mfsc_pl[MLXSW_REG_MFSC_LEN]; int err; @@ -200,7 +211,8 @@ static ssize_t mlxsw_hwmon_pwm_store(struct device *dev, { struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = container_of(attr, struct mlxsw_hwmon_attr, dev_attr); - struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; char mfsc_pl[MLXSW_REG_MFSC_LEN]; unsigned long val; int err; @@ -226,12 +238,13 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev, { struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = container_of(attr, struct mlxsw_hwmon_attr, dev_attr); - struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; char mtmp_pl[MLXSW_REG_MTMP_LEN]; u8 module; int err; - module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; + module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; mlxsw_reg_mtmp_pack(mtmp_pl, 0, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, false, false); @@ -264,15 +277,16 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev, { struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = container_of(attr, struct mlxsw_hwmon_attr, dev_attr); - struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; char mtbr_pl[MLXSW_REG_MTBR_LEN] = {0}; u8 module, fault; u16 temp; int err; - module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; - mlxsw_reg_mtbr_pack(mtbr_pl, 0, - MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1); + module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; + mlxsw_reg_mtbr_pack(mtbr_pl, 0, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, + 1); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl); if (err) { dev_err(dev, "Failed to query module temperature sensor\n"); @@ -306,11 +320,12 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev, { struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = container_of(attr, struct mlxsw_hwmon_attr, dev_attr); - struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; u8 module; int err; - module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; + module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0, module, SFP_TEMP_HIGH_WARN, p_temp); @@ -341,11 +356,12 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev, { struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = container_of(attr, struct mlxsw_hwmon_attr, dev_attr); - struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; u8 module; int err; - module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count; + module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0, module, SFP_TEMP_HIGH_ALARM, p_temp); @@ -390,9 +406,9 @@ mlxsw_hwmon_gbox_temp_label_show(struct device *dev, { struct mlxsw_hwmon_attr *mlxsw_hwmon_attr = container_of(attr, struct mlxsw_hwmon_attr, dev_attr); - struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_attr->hwmon; + struct mlxsw_hwmon_dev *mlxsw_hwmon_dev = mlxsw_hwmon_attr->mlxsw_hwmon_dev; int index = mlxsw_hwmon_attr->type_index - - mlxsw_hwmon->module_sensor_max + 1; + mlxsw_hwmon_dev->module_sensor_max + 1; return sprintf(buf, "gearbox %03u\n", index); } @@ -461,14 +477,15 @@ enum mlxsw_hwmon_attr_type { MLXSW_HWMON_ATTR_TYPE_TEMP_EMERGENCY_ALARM, }; -static void mlxsw_hwmon_attr_add(struct mlxsw_hwmon *mlxsw_hwmon, +static void mlxsw_hwmon_attr_add(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev, enum mlxsw_hwmon_attr_type attr_type, - unsigned int type_index, unsigned int num) { + unsigned int type_index, unsigned int num) +{ struct mlxsw_hwmon_attr *mlxsw_hwmon_attr; unsigned int attr_index; - attr_index = mlxsw_hwmon->attrs_count; - mlxsw_hwmon_attr = &mlxsw_hwmon->hwmon_attrs[attr_index]; + attr_index = mlxsw_hwmon_dev->attrs_count; + mlxsw_hwmon_attr = &mlxsw_hwmon_dev->hwmon_attrs[attr_index]; switch (attr_type) { case MLXSW_HWMON_ATTR_TYPE_TEMP: @@ -568,16 +585,17 @@ static void mlxsw_hwmon_attr_add(struct mlxsw_hwmon *mlxsw_hwmon, } mlxsw_hwmon_attr->type_index = type_index; - mlxsw_hwmon_attr->hwmon = mlxsw_hwmon; + mlxsw_hwmon_attr->mlxsw_hwmon_dev = mlxsw_hwmon_dev; mlxsw_hwmon_attr->dev_attr.attr.name = mlxsw_hwmon_attr->name; sysfs_attr_init(&mlxsw_hwmon_attr->dev_attr.attr); - mlxsw_hwmon->attrs[attr_index] = &mlxsw_hwmon_attr->dev_attr.attr; - mlxsw_hwmon->attrs_count++; + mlxsw_hwmon_dev->attrs[attr_index] = &mlxsw_hwmon_attr->dev_attr.attr; + mlxsw_hwmon_dev->attrs_count++; } -static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon *mlxsw_hwmon) +static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) { + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; char mtcap_pl[MLXSW_REG_MTCAP_LEN] = {0}; int i; int err; @@ -587,8 +605,8 @@ static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon *mlxsw_hwmon) dev_err(mlxsw_hwmon->bus_info->dev, "Failed to get number of temp sensors\n"); return err; } - mlxsw_hwmon->sensor_count = mlxsw_reg_mtcap_sensor_count_get(mtcap_pl); - for (i = 0; i < mlxsw_hwmon->sensor_count; i++) { + mlxsw_hwmon_dev->sensor_count = mlxsw_reg_mtcap_sensor_count_get(mtcap_pl); + for (i = 0; i < mlxsw_hwmon_dev->sensor_count; i++) { char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0}; mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, i); @@ -605,18 +623,19 @@ static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon *mlxsw_hwmon) i); return err; } - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_TEMP, i, i); - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_TEMP_MAX, i, i); - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_TEMP_RST, i, i); } return 0; } -static int mlxsw_hwmon_fans_init(struct mlxsw_hwmon *mlxsw_hwmon) +static int mlxsw_hwmon_fans_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) { + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; char mfcr_pl[MLXSW_REG_MFCR_LEN] = {0}; enum mlxsw_reg_mfcr_pwm_frequency freq; unsigned int type_index; @@ -634,10 +653,10 @@ static int mlxsw_hwmon_fans_init(struct mlxsw_hwmon *mlxsw_hwmon) num = 0; for (type_index = 0; type_index < MLXSW_MFCR_TACHOS_MAX; type_index++) { if (tacho_active & BIT(type_index)) { - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_FAN_RPM, type_index, num); - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_FAN_FAULT, type_index, num++); } @@ -645,15 +664,16 @@ static int mlxsw_hwmon_fans_init(struct mlxsw_hwmon *mlxsw_hwmon) num = 0; for (type_index = 0; type_index < MLXSW_MFCR_PWMS_MAX; type_index++) { if (pwm_active & BIT(type_index)) - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_PWM, type_index, num++); } return 0; } -static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) +static int mlxsw_hwmon_module_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) { + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; char mgpir_pl[MLXSW_REG_MGPIR_LEN]; u8 module_sensor_max; int i, err; @@ -671,28 +691,28 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) * sensor_count are already utilized by the sensors connected through * mtmp register by mlxsw_hwmon_temp_init(). */ - mlxsw_hwmon->module_sensor_max = mlxsw_hwmon->sensor_count + - module_sensor_max; - for (i = mlxsw_hwmon->sensor_count; - i < mlxsw_hwmon->module_sensor_max; i++) { - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_dev->module_sensor_max = mlxsw_hwmon_dev->sensor_count + + module_sensor_max; + for (i = mlxsw_hwmon_dev->sensor_count; + i < mlxsw_hwmon_dev->module_sensor_max; i++) { + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE, i, i); - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE_FAULT, i, i); - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE_CRIT, i, i); - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE_EMERG, i, i); - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE_LABEL, i, i); - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_TEMP_CRIT_ALARM, i, i); - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_TEMP_EMERGENCY_ALARM, i, i); } @@ -700,8 +720,9 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) return 0; } -static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon) +static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) { + struct mlxsw_hwmon *mlxsw_hwmon = mlxsw_hwmon_dev->hwmon; enum mlxsw_reg_mgpir_device_type device_type; int index, max_index, sensor_index; char mgpir_pl[MLXSW_REG_MGPIR_LEN]; @@ -720,10 +741,10 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon) !gbox_num) return 0; - index = mlxsw_hwmon->module_sensor_max; - max_index = mlxsw_hwmon->module_sensor_max + gbox_num; + index = mlxsw_hwmon_dev->module_sensor_max; + max_index = mlxsw_hwmon_dev->module_sensor_max + gbox_num; while (index < max_index) { - sensor_index = index % mlxsw_hwmon->module_sensor_max + + sensor_index = index % mlxsw_hwmon_dev->module_sensor_max + MLXSW_REG_MTMP_GBOX_INDEX_MIN; mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, true, true); err = mlxsw_reg_write(mlxsw_hwmon->core, @@ -733,15 +754,15 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon) sensor_index); return err; } - mlxsw_hwmon_attr_add(mlxsw_hwmon, MLXSW_HWMON_ATTR_TYPE_TEMP, - index, index); - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, + MLXSW_HWMON_ATTR_TYPE_TEMP, index, index); + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_TEMP_MAX, index, index); - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_TEMP_RST, index, index); - mlxsw_hwmon_attr_add(mlxsw_hwmon, + mlxsw_hwmon_attr_add(mlxsw_hwmon_dev, MLXSW_HWMON_ATTR_TYPE_TEMP_GBOX_LABEL, index, index); index++; @@ -754,44 +775,58 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core, const struct mlxsw_bus_info *mlxsw_bus_info, struct mlxsw_hwmon **p_hwmon) { + char mgpir_pl[MLXSW_REG_MGPIR_LEN]; struct mlxsw_hwmon *mlxsw_hwmon; struct device *hwmon_dev; + u8 num_of_slots; int err; - mlxsw_hwmon = kzalloc(sizeof(*mlxsw_hwmon), GFP_KERNEL); + mlxsw_reg_mgpir_pack(mgpir_pl, 0); + err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mgpir), mgpir_pl); + if (err) + return err; + + mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, NULL, + &num_of_slots); + + mlxsw_hwmon = kzalloc(struct_size(mlxsw_hwmon, line_cards, + num_of_slots + 1), GFP_KERNEL); if (!mlxsw_hwmon) return -ENOMEM; + mlxsw_hwmon->core = mlxsw_core; mlxsw_hwmon->bus_info = mlxsw_bus_info; + mlxsw_hwmon->line_cards[0].hwmon = mlxsw_hwmon; - err = mlxsw_hwmon_temp_init(mlxsw_hwmon); + err = mlxsw_hwmon_temp_init(&mlxsw_hwmon->line_cards[0]); if (err) goto err_temp_init; - err = mlxsw_hwmon_fans_init(mlxsw_hwmon); + err = mlxsw_hwmon_fans_init(&mlxsw_hwmon->line_cards[0]); if (err) goto err_fans_init; - err = mlxsw_hwmon_module_init(mlxsw_hwmon); + err = mlxsw_hwmon_module_init(&mlxsw_hwmon->line_cards[0]); if (err) goto err_temp_module_init; - err = mlxsw_hwmon_gearbox_init(mlxsw_hwmon); + err = mlxsw_hwmon_gearbox_init(&mlxsw_hwmon->line_cards[0]); if (err) goto err_temp_gearbox_init; - mlxsw_hwmon->groups[0] = &mlxsw_hwmon->group; - mlxsw_hwmon->group.attrs = mlxsw_hwmon->attrs; + mlxsw_hwmon->line_cards[0].groups[0] = &mlxsw_hwmon->line_cards[0].group; + mlxsw_hwmon->line_cards[0].group.attrs = mlxsw_hwmon->line_cards[0].attrs; hwmon_dev = hwmon_device_register_with_groups(mlxsw_bus_info->dev, - "mlxsw", mlxsw_hwmon, - mlxsw_hwmon->groups); + "mlxsw", + &mlxsw_hwmon->line_cards[0], + mlxsw_hwmon->line_cards[0].groups); if (IS_ERR(hwmon_dev)) { err = PTR_ERR(hwmon_dev); goto err_hwmon_register; } - mlxsw_hwmon->hwmon_dev = hwmon_dev; + mlxsw_hwmon->line_cards[0].hwmon_dev = hwmon_dev; *p_hwmon = mlxsw_hwmon; return 0; @@ -806,6 +841,6 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core, void mlxsw_hwmon_fini(struct mlxsw_hwmon *mlxsw_hwmon) { - hwmon_device_unregister(mlxsw_hwmon->hwmon_dev); + hwmon_device_unregister(mlxsw_hwmon->line_cards[0].hwmon_dev); kfree(mlxsw_hwmon); } From patchwork Wed Apr 13 15:17:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12812119 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91236C433F5 for ; Wed, 13 Apr 2022 15:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236312AbiDMPVH (ORCPT ); Wed, 13 Apr 2022 11:21:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234843AbiDMPVG (ORCPT ); Wed, 13 Apr 2022 11:21:06 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2056.outbound.protection.outlook.com [40.107.92.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 694D52E0BA for ; Wed, 13 Apr 2022 08:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y/tw6kXden7B0nTAcDJgGTBPTaZgQN6ZLQr04IJiDo3llWCNOLxUgRI9N9VFqAinYepq8nQe+reK7+4SMXUVlwR1/6vtQMeE3LxHdSUAKcq4nCG6flD4J2dPBfdM8lb99VKI9zb1sYxtM5zN1lbqx4/GfP/FPy/NQjPCtQRWE0q49F5EtDBmDv+JgM6Y9KBt5s2YmUOKYcTiy3DJuZK1Y5dHy+7oMns6srQgjgAI64M3foz79mnZC6xR9NbzO7TCk0EtlhNd/xigIvvs550RT6QzAoRjdD2iL2pcewRybhn27ZLXLN9o5pkkiByA8ytEvlJ9Mat+uAq0SQFEE0OOvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4hZ/ymCJss9L5uLxpzJW36xJQXg3386X7Olz/KXUPkk=; b=B5NmGUron9Omn3p5wQHxJR0vyyaBrYojqS4E3iMJV6HR18nbtp6lpaKB7j/JPylg52I0xMdwOtfq4SNAu7ZTlpiBjl2GoOku10qx/9mFRptva1SCMOwuAYcMaM1toKF4jVj283z4oVzhzFJ+/LqHZSVG170Pdtq+92En3EXGglQvtX9jX+4FTM8ZvKlges0kJjhlpyDg/L8l0oIasXTGIuTfwG4/cwrDD5vBzFTnL9YYdJy+4vmOlrI+4B32e2nELrib8TwiireN5SPbwq0DVTWmcSU7sO5D/z+eeNF1v8Qh+Z38+RJbQAdYyqFrBUZjj3xEGNj6p0WLfdnltHOj8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=4hZ/ymCJss9L5uLxpzJW36xJQXg3386X7Olz/KXUPkk=; b=EPWtkXOCmkTDloAlXcKTHG2F98+Ap57rbTzciNAh6azgSnDnhbll8gcP3z/Ym1roBUo0rlpZ50Qxw/dzZIHX2+sKv+GaFKlx8e+Ukl7kdDKhCrrD8Lb1nqeBqDrMVyEv5guu0qRHgzHCjTPJvyIl1U6nixeLdHoEIaIkhlI4I9QtwRODt6Cvi26Wo61Ymb/zAt5bYlyQOktGxChtrrze2RvFd3ccRNWpTNpWTvSpx9WeTb/7t7hj3KQ67vdqiHnPs6zOIAhtWaOljtDj/AR8oloCtX0wcZx3EmLivn+jQNjOjd5as8zq3qedDRryxIZGfKuapNsoW+UnLKrzFjWdWQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MN2PR12MB3885.namprd12.prod.outlook.com (2603:10b6:208:16c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29; Wed, 13 Apr 2022 15:18:41 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402%5]) with mapi id 15.20.5144.029; Wed, 13 Apr 2022 15:18:41 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, petrm@nvidia.com, vadimp@nvidia.com, jiri@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 5/9] mlxsw: core_hwmon: Introduce slot parameter in hwmon interfaces Date: Wed, 13 Apr 2022 18:17:29 +0300 Message-Id: <20220413151733.2738867-6-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220413151733.2738867-1-idosch@nvidia.com> References: <20220413151733.2738867-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR04CA0066.eurprd04.prod.outlook.com (2603:10a6:802:2::37) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 26c649a3-327f-4460-d0d5-08da1d60e489 X-MS-TrafficTypeDiagnostic: MN2PR12MB3885:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VV6Dnq3kaaqpgrFgf/BF7haqf/iHAk/brFJniONElPZXYVa8p72fIHn70z2NBB+VnrvoxH1KyKNy6KUewQCent24nfJel00QwHptM2JmazvQ0HzrDPxT06J+v+lkAsokHm0ui7huN43SnMDuErZbo1354R469G2/jzCKWSL4zu6LGjCll8jorjwmhjivOFpcW0ppK0y3iBnubK0U8JOj2rIs8oBH85ygXZLP6TY88CM+JRKnfvZU1noBThS8LUWYCcXE/toldOJHMieTZU2Bp3Sot84uySbjswS/je+TRAz3oYYNjNuwz2HSNGn94etRAXO4koCOqFUZN0oLiF4yKRwWpC4r4HtL/5kITOYcFwl3F0l1UkxiIZsCobOjSfKhFG4oUkYwX+D3ti/3InK9nFD3CxOabTmHsJVAjjpSlyXiwnlNK3ZUzCNfgU49li0hMc0Fgo19lohYrz+1NQuLQ1wIWHgzCc5Jib0/IJpgGlk34LGMxquaT8cmvjacds4mG9xUKVLGpcl8cTK/oVLrAX7opqJOKCorOq6mPir+/NQdFVkFvwDsMl36RjaTVDaE5P2NAk8cbxzQMB8jhPoRaBEvkfYR0WSz7ilI+g6r3mme9KdBO+os7SH380dbMLUqIE5l9M2G4U7rmbBOVGKU+g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6486002)(66556008)(66946007)(36756003)(2906002)(316002)(6916009)(4326008)(8676002)(83380400001)(86362001)(508600001)(38100700002)(5660300002)(8936002)(26005)(6506007)(186003)(6666004)(2616005)(107886003)(6512007)(1076003)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +HT98XlJwLte6STIzU8nXVPFIKrpHxSKAKj+5kh2z/egZXOX8eWXo/3Bigw6sMWUeflGmlkQpa/pSFOBlX/N0kgYchKucVsEc2P1MN0P9r9UgQhnjGhjMQ70gNQ7qRkDCNpy+sYOFfBxAyytnAALyhVJRwAy0hfwCgSiLA7+oBJEON/dEqDLAQZATN8FFDcdMN44PDLI+sPdj1d6td18WWVbRYIBUXWiJhSfUbllIIrStwDXlcWb7u0CA7qfpJ86iAPt+oPl3WQz8sGpx6RGDTLuMK93kDcSWuPEBqKH8AxtOvUHA6pEZVw8ZaTlvMx3HzbWy9rzkzVtNVsuGXk6mSQ/j7YXaBDE36tC9m5f/iyudG/AzhhAnTMBcD1teF1sSYI8ZmBLjSkaISa//ynD6yodWl5bZLjtDXFq1Gfmj0G9NgjwaK55WHvGPqaxd0J1mRb0JkXus7RbGx4jaXHylM1hdfsP4WYqlZkkM5Ui6v4TxjU8vNTw63NJrHc1TmfaWeZyO1Hd6mCG9UVfWdyt6LKSZWBng4zy1sb/XlnetJBvxsgZthTOHlMPV1tqlWb/r6mtX080UAf9WD9CjlyWT+HipnpjEtGzTosXLpjB78bD++82kzOaatQvNvAV6usKZOi6xUaKiIccLgNkgFiE9p4T+kI6EnMDWfDZKgVW4sx+lfJPACusWIHwmCesZeUYeqdtT162v3qkciNjIgIY9BrnUJpPFVwTVsAvquab114rQsYCl1H7gY6HAJ0REo4bMyWrC92KIXrem5fwdxg62UYQ0kT3nBIdiEpii0bBdY6lithGOJR8mMSXZnpwnxwL5LlIfEgjMxMCh/TDukHbg2FCSW69H2bOI3f5llA/GZS5cGmJVo4Q33NZK8SrW67AHR+gkPsIjIUdXVM4QY440c3SvXXo7HUd85SASLYfmPQRrJ6YAmBYWP527806+ukHU2beuZlRD+/2KdO+1TlIzwHeMt59vLsk4kzW9MCDPFj7Kf0DJiifFjRo3XCVQ3eNigbzTYXpZXujePyZpCzH6oyRd/1VpcsMYJR4B8gUKkUZTP6GaZJTs+JtMcSqVEkN14zgZ0sZWrHnZrS3LiqzgkVZWQDGTK9nyve+KRRx2JHMwNilKLTo41d7QFAoQc8ePnJUTGPwIMVmisiGDHbV4I9dUXmwFmEq1OYYM/ag7FLkieMiQGKjwBi6gw4wOL0B2mO77R3F4eJxPFtbekH9GEC8qfKMzQ1ymgjcPLQ9r89dAHqZOyMT8RtfkyNAMH5+0EUsGmH/BKETuwSc4io4TWd1Jrty/VIly/Ll3EYTdbtQ0d2mYqND/k3DKSbEDp8nKGCmTO3oYQXcQrGEXk644feaNm9Ic+ATI8qxAgo5xaWyjStpbBTfqF9MF1uWumJostS/UwP1r/En29wRi7iCaVSOOMOFvvrXx08wSCNeH1xP4UqmWCJxVVz+tjflIhKjQgWL3xr2db7rBabzYAqfyKiI5/Uty2BzZQDvkPHCSMfsSafJ0CrFr4WelqorjhicML7vyS/OMYSPwNfqMPc9c0xxPbQDVKjAb6ycAcdJYVGOqixAM3unmOHDbB8OQAqPW4vIZS9z1g3Pq/w32avxNWkbEockovxYhT4NZiAFVfseFmxV02RNfWoA6rX7uzUqw4rsncbinUrd7o+Ltl8y7Jg5mitPcouVgAV3abX9+jtSGKksllMbBRhkdmBTXE8GSLlF6C6pwyaQwDLnb63EWQ== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26c649a3-327f-4460-d0d5-08da1d60e489 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 15:18:41.6680 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jRp4z7I8LyAW3yPtVzauQfScOaFXUkRDF5tuqxR7Mt9l2xvVzN+BY9ad/W6sNNmfHGUlZ5IkKSovpR/EQW1DtQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3885 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vadim Pasternak Add 'slot' parameter to 'mlxsw_hwmon_dev' structure. Use this parameter in mlxsw_reg_mtmp_pack(), mlxsw_reg_mtbr_pack(), mlxsw_reg_mgpir_pack() and mlxsw_reg_mtmp_slot_index_set() routines. For main board it'll always be zero, for line cards it'll be set to the physical slot number in modular systems. Signed-off-by: Vadim Pasternak Reviewed-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/core_hwmon.c | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c index d35aa135beed..fff6f248d6f7 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c @@ -50,6 +50,7 @@ struct mlxsw_hwmon_dev { unsigned int attrs_count; u8 sensor_count; u8 module_sensor_max; + u8 slot_index; }; struct mlxsw_hwmon { @@ -72,7 +73,8 @@ static ssize_t mlxsw_hwmon_temp_show(struct device *dev, index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, mlxsw_hwmon_dev->module_sensor_max); - mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false); + mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, index, false, + false); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); if (err) { dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n"); @@ -96,7 +98,8 @@ static ssize_t mlxsw_hwmon_temp_max_show(struct device *dev, index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, mlxsw_hwmon_dev->module_sensor_max); - mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false); + mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, index, false, + false); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); if (err) { dev_err(mlxsw_hwmon->bus_info->dev, "Failed to query temp sensor\n"); @@ -128,6 +131,7 @@ static ssize_t mlxsw_hwmon_temp_rst_store(struct device *dev, index = mlxsw_hwmon_get_attr_index(mlxsw_hwmon_attr->type_index, mlxsw_hwmon_dev->module_sensor_max); + mlxsw_reg_mtmp_slot_index_set(mtmp_pl, mlxsw_hwmon_dev->slot_index); mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, index); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); if (err) @@ -245,7 +249,7 @@ static int mlxsw_hwmon_module_temp_get(struct device *dev, int err; module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; - mlxsw_reg_mtmp_pack(mtmp_pl, 0, + mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module, false, false); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); @@ -285,8 +289,8 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev, int err; module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; - mlxsw_reg_mtbr_pack(mtbr_pl, 0, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, - 1); + mlxsw_reg_mtbr_pack(mtbr_pl, mlxsw_hwmon_dev->slot_index, + MLXSW_REG_MTBR_BASE_MODULE_INDEX + module, 1); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl); if (err) { dev_err(dev, "Failed to query module temperature sensor\n"); @@ -326,7 +330,8 @@ static int mlxsw_hwmon_module_temp_critical_get(struct device *dev, int err; module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; - err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0, + err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, + mlxsw_hwmon_dev->slot_index, module, SFP_TEMP_HIGH_WARN, p_temp); if (err) { @@ -362,7 +367,8 @@ static int mlxsw_hwmon_module_temp_emergency_get(struct device *dev, int err; module = mlxsw_hwmon_attr->type_index - mlxsw_hwmon_dev->sensor_count; - err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, 0, + err = mlxsw_env_module_temp_thresholds_get(mlxsw_hwmon->core, + mlxsw_hwmon_dev->slot_index, module, SFP_TEMP_HIGH_ALARM, p_temp); if (err) { @@ -609,6 +615,8 @@ static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) for (i = 0; i < mlxsw_hwmon_dev->sensor_count; i++) { char mtmp_pl[MLXSW_REG_MTMP_LEN] = {0}; + mlxsw_reg_mtmp_slot_index_set(mtmp_pl, + mlxsw_hwmon_dev->slot_index); mlxsw_reg_mtmp_sensor_index_set(mtmp_pl, i); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); @@ -678,7 +686,7 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) u8 module_sensor_max; int i, err; - mlxsw_reg_mgpir_pack(mgpir_pl, 0); + mlxsw_reg_mgpir_pack(mgpir_pl, mlxsw_hwmon_dev->slot_index); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl); if (err) return err; @@ -730,7 +738,7 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) u8 gbox_num; int err; - mlxsw_reg_mgpir_pack(mgpir_pl, 0); + mlxsw_reg_mgpir_pack(mgpir_pl, mlxsw_hwmon_dev->slot_index); err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mgpir), mgpir_pl); if (err) return err; @@ -746,7 +754,8 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon_dev *mlxsw_hwmon_dev) while (index < max_index) { sensor_index = index % mlxsw_hwmon_dev->module_sensor_max + MLXSW_REG_MTMP_GBOX_INDEX_MIN; - mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, true, true); + mlxsw_reg_mtmp_pack(mtmp_pl, mlxsw_hwmon_dev->slot_index, + sensor_index, true, true); err = mlxsw_reg_write(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl); if (err) { @@ -797,6 +806,7 @@ int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core, mlxsw_hwmon->core = mlxsw_core; mlxsw_hwmon->bus_info = mlxsw_bus_info; mlxsw_hwmon->line_cards[0].hwmon = mlxsw_hwmon; + mlxsw_hwmon->line_cards[0].slot_index = 0; err = mlxsw_hwmon_temp_init(&mlxsw_hwmon->line_cards[0]); if (err) From patchwork Wed Apr 13 15:17:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12812122 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB22FC433FE for ; Wed, 13 Apr 2022 15:18:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236317AbiDMPVT (ORCPT ); Wed, 13 Apr 2022 11:21:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235799AbiDMPVR (ORCPT ); Wed, 13 Apr 2022 11:21:17 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2077.outbound.protection.outlook.com [40.107.96.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CA8A2E6A2 for ; Wed, 13 Apr 2022 08:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dcM4ygpRyxGUdLe7KUk6MNGI2hbnhLKxpSgIp1BHj7aq8+PlFmrNF5P8VVK9kJbboPlaAHMdaEzhWO624FQwl5oYiazl59kWofd4opPusL27VKc9hxpykmmkPj09NeompacBnhojO/liSfM35dcOG39jtqtsZYLiWEObHoQcQEn8wd7mb+YMD3tZoYs/LLBJFQ2AaEDojzRa8I+1n1rvHk7CzUD7NvsSLxwt0qsjZMOtxgT31FBUP+vqDCzfLhCFjcF7DMCL9LMjKSiH+dwYkOHfSYMUIwJeuMyd3SO7KHGpZR2OtiHSAPZh6kIX5cok4/Wy3xPz3h/l/U5RrWFinA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KUFQwuJeqdh7HGNSMtFUU5npvvrMekhfV2jbn2ZtVo4=; b=j8uvsHWKOK/fl7F56M3Mj6TkjYd9oa2zTV1FCD66uDDMPlEgGZmHMwQMymDNOLwzD0xZG03lZ3Iee/cgXAr3NOjo2QOcl3ujNSGJFzKnuVI6wmwZxVXo9RLUDZou0LfY2QMHlGFNms2Lvyu1tgVHFLOWDBzp9lG21EUs9Y8jN6fHVsbuSlo/q83sSq52F9dFCnuGO4kVJ4tLZH4TDQK20pB/5x8AVS8yRvn1H6F+1v7FuOzv0aWPbVWDOU3h5txIvdrLBUVgkbkj7hsZhUH9eocQiCGZkJlHXrH/RLG72ge0pnygZ2A04Zhbh9NySfeWg/OYjOh5Zo1KCvdS1Ckfbg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=KUFQwuJeqdh7HGNSMtFUU5npvvrMekhfV2jbn2ZtVo4=; b=AUkcRxSDLoYmyruU+tSc5vNTw3in6wg9lv2Gj/3heaqjoBmVsubRa8R4aVUTLsUalVgzZjl4WDgaC0AyTE6LG62iad4d9Pcai0VvCEUkGoqjwV6NhwjA4zo00Ol8STrmaRqcuEWMdIHqtLEJ0lB3acda18E/VVK0Ax5n2VEwk3DoNrmC8Zk3gXLglFMYxGBKiJPa9CzGDlnkgg/6ypR2nVa7yOAClIFUCHroTsaGri+42brrdZHnpAv0m6mxB6icvq1DbXGP/734cLJ/2T9U2PBbmoG3FB4/DprP+ZjobrlxSM5MrgO+CwpPLnF2Dlax+WYleN1wpFXe9bBRhgSYiA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by BN6PR1201MB2530.namprd12.prod.outlook.com (2603:10b6:404:b0::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.30; Wed, 13 Apr 2022 15:18:49 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402%5]) with mapi id 15.20.5144.029; Wed, 13 Apr 2022 15:18:49 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, petrm@nvidia.com, vadimp@nvidia.com, jiri@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 6/9] mlxsw: core_thermal: Extend internal structures to support multi thermal areas Date: Wed, 13 Apr 2022 18:17:30 +0300 Message-Id: <20220413151733.2738867-7-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220413151733.2738867-1-idosch@nvidia.com> References: <20220413151733.2738867-1-idosch@nvidia.com> X-ClientProxiedBy: VE1PR03CA0005.eurprd03.prod.outlook.com (2603:10a6:802:a0::17) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8038d879-e5a6-479c-a072-08da1d60e8ef X-MS-TrafficTypeDiagnostic: BN6PR1201MB2530:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +rHHbarayl0vjqnw+HrMB9XpBE/+V8hpPCtvKymxT1ljR6bLabJAN6C8V1BKkzgIZrjhYPS6Wo/gf17sMkceD7sQ/hiVwCBvBxTCLOMDg2mS1dJcBXJc/Q28uh2O3/g2JA4SwTGFQRgJSx6AB3k9cd3CefiG4icPfs67cWCIadAzrwX1ziy3vF2nmnVIBR9xmMm9mV3YfdXLENz5uP3NJsaneulUYoRrMN5It+IK2/rbfSWEtSaWMhsM/WTpSD3VlMzL07au9EhDQ/6ZNDuuUoql1Wle8IY3gjGxgASLB8rXPiMXVCegX2UIeLa1kFZI70DjRW6jPZg043HtQcBA2uk0DfUKBWS7ZffWA9zk1Br4YHVVoyvdSBJAuQH4DE4Pun2wsXfuMy36hgKM2YbDFFpd+HqbZ7osUahfWxWlnChlFLLHVqjn2yWSoXvGl0+Ve+/ckld7mUHM67EwQg5Z5XdijUBSEJYBpGCApCuG7q2ZF9j4C0F3eHSBzNc6DLQ6sqb/gquTjI/fe6TjiwpcTgZl+m6/K2ALu9sWP5F0JS+00Op89sHJ1RUNLAVPOcfmJ9PX4ee1cvymIV9M1wnJ5EvG9ILMULWrqPto2XsQGXxCUi2lnJ05BfOpW+Ux4rLo1Y/6hJ6yW34GiOv1tTLHlg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(107886003)(316002)(6666004)(36756003)(2616005)(6916009)(1076003)(6506007)(86362001)(2906002)(186003)(66556008)(6486002)(6512007)(508600001)(4326008)(38100700002)(66476007)(26005)(83380400001)(66946007)(30864003)(8936002)(5660300002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Nj6tpwMx9I8WXCn5VEnVrmnDWVyvXOxEkJEALHOdtztpTTuN9OzGoOY4qoR3NXxWtJMgKCfVBz+tWg/UqDB9+fp6M1n5S+D5eAikqf0WM/u9XCDtNtOnXvVzgwpYwlZaia5Cfn4W771UMUjwoRSxeuxpaAPolErPd9K6fPqXhD+bhdPqV5505LYlq3cHCT81wzV8LpfLwbcycLTVY4wp6f8quWAnTa4ik9G68UtVoDxwipYKZK17wVcYY48gLop4qPwXPGt2dnUdRIYFNEjXdGw4pW71uQzRGJb/vlFodKeGd1yHqA08emjjR3dJBhTY+bxhjavtg7WWVhPHoU2GG6ajPXuUkAnbEtfd/cQNrX0KGG6OBQaQIJUezo22T1qLoCiwkSQQguAbuLjm4hk2/FWTLLUCLDsATxNmuA0/DkB6QrfYW3bePMJWsHR+bBxLT2Cjgxt/2RcO2r7WVgWGYoX/z6PjkrWGnqqO4jVOCy+mP2BPt8s7EAe3szaUuFmQ3nBJsjkV52i3xz2S04fBrK/Pl+G41u3GoGrUcy/hruuIRCbjiZQ/EwyPZE/4scj31JSiOks7NWp6vUrGcuzfWqZIquFvmjkTmwS4z22F5853pYXIZfhI4q/g3LDr35R68Uc/NC/kcvLnNTMAvxeHwHiwEzf9mLuqJFR+8OQ5LNNG7G7KmyjdO0lmwA1ysWXd9RTCPJjCt+hEkpPfyScT1otwN5ZJo2/pp6fug48zex5ijJT43tBKHMb1Sh1xQeDvBGhNR1sHicAAQlKWD2qckbkMcCf65eGJFhNCV2zJBxGnvm3ipIV8MjvkQuMtoFGVLxrS4DL+B+o076K/vWugx0MV/0OYOLP6b4laRgvlRZLkxNetmCWmOwdf+A9NBelYGz9/QcNzF8z5+eXtcjDOKl4nBVAI+h6aMdZw8ylmM4RDx4fdiKPwBveH1cvrgTw1rfFrUsbniCqbL5M43qAC6V7a1RC5W6ltPTXG9fdUEytHX4gAgZ4gegt0fAhvzvw2aO1tydwG33aalcnraC1FTd1eMptLpKn0wv/PrKTgOtBD7OaBM0074G4fkNyuz8b9paVX6uhNw9cINFWH6rCuzHnBG10/bboYgkyoAcSyXqEhtN9s3UgaHiV5NohwtXqy0hk0r6I0Vwk138rjTMRJHonFdeKdtZ1L68q33jZjm6T4byYcwsPTEt2lTvzJZ5xBLM4XoCuS1/WCuVJFsg5zT9K/jYD8krbx1nymc42e43MdSrnpBcGA7yf3XqJHAOxJWLigSvL/mArDtPtMWqiHzlPDiyLDzWJS/oCDcesN1HoARCgq/4tUNlYwgNfTMO0bLxPNkmceA4qfCb8K0flwOANNiDjvZlvNY8Ew4kKEY/JeQyIrBWretmyXenVP022QOe+imrOPWRY+K+a38VUQXfAKO30BwoxmWiQ875NoKkp8ugphIrFhbJnGbHCCdSXSxoULEWDmDrG+WOh61siFKvHUdKWdFGAlfbmx8Ue1WZEOW31BjROvLp5F7Ob8WmvWbFC/YMGEfizAHzJzLLChj0DBTaTYaGt9jaA6Xywfm/p3ybQ9b81Iu4DM0dC3Ms7XRXCF1IyIOrMSDW7iWUTRFHexTkgq169sPlmGdc+xkfaZEeDXHtS/ASdKqX0OqGqgjge99sRoM6tYl3aJuY5kBYT8fnadcCI5gzRYFCSvYSTCMHLB73JWK7wHAc9s4fVKOP2P4vGUknQ8wmvOHY/IJg== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8038d879-e5a6-479c-a072-08da1d60e8ef X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 15:18:48.9524 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TKDRgFIxT9GpYGSvsFN8smx9EG/i9PNOKF3zV77a14XXobrrwExGa4oi03NkQelCFhQy5YZUVZjuRaFwNcyVrA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1201MB2530 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vadim Pasternak Introduce intermediate level for thermal zones areas. Currently all thermal zones are associated with thermal objects located within the main board. Such objects are created during driver initialization and removed during driver de-initialization. For line cards in modular system the thermal zones are to be associated with the specific line card. They should be created whenever new line card is available (inserted, validated, powered and enabled) and removed, when line card is getting unavailable. The thermal objects found on the line card #n are accessed by setting slot index to #n, while for access to objects found on the main board slot index should be set to default value zero. Each thermal area contains the set of thermal zones associated with particular slot index. Thus introduction of thermal zone areas allows to use the same APIs for the main board and line cards, by adding slot index argument. Signed-off-by: Vadim Pasternak Signed-off-by: Ido Schimmel --- .../ethernet/mellanox/mlxsw/core_thermal.c | 148 +++++++++++------- 1 file changed, 91 insertions(+), 57 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c index d64af27e5bac..6d186cc74df3 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -82,6 +82,15 @@ struct mlxsw_thermal_module { struct thermal_zone_device *tzdev; struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS]; int module; /* Module or gearbox number */ + u8 slot_index; +}; + +struct mlxsw_thermal_area { + struct mlxsw_thermal_module *tz_module_arr; + u8 tz_module_num; + struct mlxsw_thermal_module *tz_gearbox_arr; + u8 tz_gearbox_num; + u8 slot_index; }; struct mlxsw_thermal { @@ -92,12 +101,9 @@ struct mlxsw_thermal { struct thermal_cooling_device *cdevs[MLXSW_MFCR_PWMS_MAX]; u8 cooling_levels[MLXSW_THERMAL_MAX_STATE + 1]; struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS]; - struct mlxsw_thermal_module *tz_module_arr; - u8 tz_module_num; - struct mlxsw_thermal_module *tz_gearbox_arr; - u8 tz_gearbox_num; unsigned int tz_highest_score; struct thermal_zone_device *tz_highest_dev; + struct mlxsw_thermal_area line_cards[]; }; static inline u8 mlxsw_state_to_duty(int state) @@ -150,13 +156,15 @@ mlxsw_thermal_module_trips_update(struct device *dev, struct mlxsw_core *core, * EEPROM if we got valid thresholds from MTMP. */ if (!emerg_temp || !crit_temp) { - err = mlxsw_env_module_temp_thresholds_get(core, 0, tz->module, + err = mlxsw_env_module_temp_thresholds_get(core, tz->slot_index, + tz->module, SFP_TEMP_HIGH_WARN, &crit_temp); if (err) return err; - err = mlxsw_env_module_temp_thresholds_get(core, 0, tz->module, + err = mlxsw_env_module_temp_thresholds_get(core, tz->slot_index, + tz->module, SFP_TEMP_HIGH_ALARM, &emerg_temp); if (err) @@ -423,15 +431,16 @@ static int mlxsw_thermal_module_unbind(struct thermal_zone_device *tzdev, static void mlxsw_thermal_module_temp_and_thresholds_get(struct mlxsw_core *core, - u16 sensor_index, int *p_temp, - int *p_crit_temp, + u8 slot_index, u16 sensor_index, + int *p_temp, int *p_crit_temp, int *p_emerg_temp) { char mtmp_pl[MLXSW_REG_MTMP_LEN]; int err; /* Read module temperature and thresholds. */ - mlxsw_reg_mtmp_pack(mtmp_pl, 0, sensor_index, false, false); + mlxsw_reg_mtmp_pack(mtmp_pl, slot_index, sensor_index, + false, false); err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl); if (err) { /* Set temperature and thresholds to zero to avoid passing @@ -462,6 +471,7 @@ static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev, /* Read module temperature and thresholds. */ mlxsw_thermal_module_temp_and_thresholds_get(thermal->core, + tz->slot_index, sensor_index, &temp, &crit_temp, &emerg_temp); *p_temp = temp; @@ -576,7 +586,7 @@ static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev, int err; index = MLXSW_REG_MTMP_GBOX_INDEX_MIN + tz->module; - mlxsw_reg_mtmp_pack(mtmp_pl, 0, index, false, false); + mlxsw_reg_mtmp_pack(mtmp_pl, tz->slot_index, index, false, false); err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl); if (err) @@ -704,25 +714,28 @@ static void mlxsw_thermal_module_tz_fini(struct thermal_zone_device *tzdev) static int mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core, - struct mlxsw_thermal *thermal, u8 module) + struct mlxsw_thermal *thermal, + struct mlxsw_thermal_area *area, u8 module) { struct mlxsw_thermal_module *module_tz; int dummy_temp, crit_temp, emerg_temp; u16 sensor_index; sensor_index = MLXSW_REG_MTMP_MODULE_INDEX_MIN + module; - module_tz = &thermal->tz_module_arr[module]; + module_tz = &area->tz_module_arr[module]; /* Skip if parent is already set (case of port split). */ if (module_tz->parent) return 0; module_tz->module = module; + module_tz->slot_index = area->slot_index; module_tz->parent = thermal; memcpy(module_tz->trips, default_thermal_trips, sizeof(thermal->trips)); /* Initialize all trip point. */ mlxsw_thermal_module_trips_reset(module_tz); /* Read module temperature and thresholds. */ - mlxsw_thermal_module_temp_and_thresholds_get(core, sensor_index, &dummy_temp, + mlxsw_thermal_module_temp_and_thresholds_get(core, area->slot_index, + sensor_index, &dummy_temp, &crit_temp, &emerg_temp); /* Update trip point according to the module data. */ return mlxsw_thermal_module_trips_update(dev, core, module_tz, @@ -740,34 +753,39 @@ static void mlxsw_thermal_module_fini(struct mlxsw_thermal_module *module_tz) static int mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, - struct mlxsw_thermal *thermal) + struct mlxsw_thermal *thermal, + struct mlxsw_thermal_area *area) { struct mlxsw_thermal_module *module_tz; char mgpir_pl[MLXSW_REG_MGPIR_LEN]; int i, err; - mlxsw_reg_mgpir_pack(mgpir_pl, 0); + mlxsw_reg_mgpir_pack(mgpir_pl, area->slot_index); err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl); if (err) return err; mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, - &thermal->tz_module_num, NULL); + &area->tz_module_num, NULL); - thermal->tz_module_arr = kcalloc(thermal->tz_module_num, - sizeof(*thermal->tz_module_arr), - GFP_KERNEL); - if (!thermal->tz_module_arr) + /* For modular system module counter could be zero. */ + if (!area->tz_module_num) + return 0; + + area->tz_module_arr = kcalloc(area->tz_module_num, + sizeof(*area->tz_module_arr), + GFP_KERNEL); + if (!area->tz_module_arr) return -ENOMEM; - for (i = 0; i < thermal->tz_module_num; i++) { - err = mlxsw_thermal_module_init(dev, core, thermal, i); + for (i = 0; i < area->tz_module_num; i++) { + err = mlxsw_thermal_module_init(dev, core, thermal, area, i); if (err) goto err_thermal_module_init; } - for (i = 0; i < thermal->tz_module_num; i++) { - module_tz = &thermal->tz_module_arr[i]; + for (i = 0; i < area->tz_module_num; i++) { + module_tz = &area->tz_module_arr[i]; if (!module_tz->parent) continue; err = mlxsw_thermal_module_tz_init(module_tz); @@ -779,20 +797,21 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, err_thermal_module_tz_init: err_thermal_module_init: - for (i = thermal->tz_module_num - 1; i >= 0; i--) - mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]); - kfree(thermal->tz_module_arr); + for (i = area->tz_module_num - 1; i >= 0; i--) + mlxsw_thermal_module_fini(&area->tz_module_arr[i]); + kfree(area->tz_module_arr); return err; } static void -mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal) +mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal, + struct mlxsw_thermal_area *area) { int i; - for (i = thermal->tz_module_num - 1; i >= 0; i--) - mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]); - kfree(thermal->tz_module_arr); + for (i = area->tz_module_num - 1; i >= 0; i--) + mlxsw_thermal_module_fini(&area->tz_module_arr[i]); + kfree(area->tz_module_arr); } static int @@ -828,7 +847,8 @@ mlxsw_thermal_gearbox_tz_fini(struct mlxsw_thermal_module *gearbox_tz) static int mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, - struct mlxsw_thermal *thermal) + struct mlxsw_thermal *thermal, + struct mlxsw_thermal_area *area) { enum mlxsw_reg_mgpir_device_type device_type; struct mlxsw_thermal_module *gearbox_tz; @@ -837,7 +857,7 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, int i; int err; - mlxsw_reg_mgpir_pack(mgpir_pl, 0); + mlxsw_reg_mgpir_pack(mgpir_pl, area->slot_index); err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl); if (err) return err; @@ -848,19 +868,20 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, !gbox_num) return 0; - thermal->tz_gearbox_num = gbox_num; - thermal->tz_gearbox_arr = kcalloc(thermal->tz_gearbox_num, - sizeof(*thermal->tz_gearbox_arr), - GFP_KERNEL); - if (!thermal->tz_gearbox_arr) + area->tz_gearbox_num = gbox_num; + area->tz_gearbox_arr = kcalloc(area->tz_gearbox_num, + sizeof(*area->tz_gearbox_arr), + GFP_KERNEL); + if (!area->tz_gearbox_arr) return -ENOMEM; - for (i = 0; i < thermal->tz_gearbox_num; i++) { - gearbox_tz = &thermal->tz_gearbox_arr[i]; + for (i = 0; i < area->tz_gearbox_num; i++) { + gearbox_tz = &area->tz_gearbox_arr[i]; memcpy(gearbox_tz->trips, default_thermal_trips, sizeof(thermal->trips)); gearbox_tz->module = i; gearbox_tz->parent = thermal; + gearbox_tz->slot_index = area->slot_index; err = mlxsw_thermal_gearbox_tz_init(gearbox_tz); if (err) goto err_thermal_gearbox_tz_init; @@ -870,19 +891,20 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, err_thermal_gearbox_tz_init: for (i--; i >= 0; i--) - mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]); - kfree(thermal->tz_gearbox_arr); + mlxsw_thermal_gearbox_tz_fini(&area->tz_gearbox_arr[i]); + kfree(area->tz_gearbox_arr); return err; } static void -mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal) +mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal, + struct mlxsw_thermal_area *area) { int i; - for (i = thermal->tz_gearbox_num - 1; i >= 0; i--) - mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]); - kfree(thermal->tz_gearbox_arr); + for (i = area->tz_gearbox_num - 1; i >= 0; i--) + mlxsw_thermal_gearbox_tz_fini(&area->tz_gearbox_arr[i]); + kfree(area->tz_gearbox_arr); } int mlxsw_thermal_init(struct mlxsw_core *core, @@ -892,19 +914,29 @@ int mlxsw_thermal_init(struct mlxsw_core *core, char mfcr_pl[MLXSW_REG_MFCR_LEN] = { 0 }; enum mlxsw_reg_mfcr_pwm_frequency freq; struct device *dev = bus_info->dev; + char mgpir_pl[MLXSW_REG_MGPIR_LEN]; struct mlxsw_thermal *thermal; + u8 pwm_active, num_of_slots; u16 tacho_active; - u8 pwm_active; int err, i; - thermal = devm_kzalloc(dev, sizeof(*thermal), - GFP_KERNEL); + mlxsw_reg_mgpir_pack(mgpir_pl, 0); + err = mlxsw_reg_query(core, MLXSW_REG(mgpir), mgpir_pl); + if (err) + return err; + + mlxsw_reg_mgpir_unpack(mgpir_pl, NULL, NULL, NULL, NULL, + &num_of_slots); + + thermal = kzalloc(struct_size(thermal, line_cards, num_of_slots + 1), + GFP_KERNEL); if (!thermal) return -ENOMEM; thermal->core = core; thermal->bus_info = bus_info; memcpy(thermal->trips, default_thermal_trips, sizeof(thermal->trips)); + thermal->line_cards[0].slot_index = 0; err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfcr), mfcr_pl); if (err) { @@ -970,11 +1002,13 @@ int mlxsw_thermal_init(struct mlxsw_core *core, goto err_thermal_zone_device_register; } - err = mlxsw_thermal_modules_init(dev, core, thermal); + err = mlxsw_thermal_modules_init(dev, core, thermal, + &thermal->line_cards[0]); if (err) goto err_thermal_modules_init; - err = mlxsw_thermal_gearboxes_init(dev, core, thermal); + err = mlxsw_thermal_gearboxes_init(dev, core, thermal, + &thermal->line_cards[0]); if (err) goto err_thermal_gearboxes_init; @@ -986,9 +1020,9 @@ int mlxsw_thermal_init(struct mlxsw_core *core, return 0; err_thermal_zone_device_enable: - mlxsw_thermal_gearboxes_fini(thermal); + mlxsw_thermal_gearboxes_fini(thermal, &thermal->line_cards[0]); err_thermal_gearboxes_init: - mlxsw_thermal_modules_fini(thermal); + mlxsw_thermal_modules_fini(thermal, &thermal->line_cards[0]); err_thermal_modules_init: if (thermal->tzdev) { thermal_zone_device_unregister(thermal->tzdev); @@ -1001,7 +1035,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core, thermal_cooling_device_unregister(thermal->cdevs[i]); err_reg_write: err_reg_query: - devm_kfree(dev, thermal); + kfree(thermal); return err; } @@ -1009,8 +1043,8 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal) { int i; - mlxsw_thermal_gearboxes_fini(thermal); - mlxsw_thermal_modules_fini(thermal); + mlxsw_thermal_gearboxes_fini(thermal, &thermal->line_cards[0]); + mlxsw_thermal_modules_fini(thermal, &thermal->line_cards[0]); if (thermal->tzdev) { thermal_zone_device_unregister(thermal->tzdev); thermal->tzdev = NULL; @@ -1023,5 +1057,5 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal) } } - devm_kfree(thermal->bus_info->dev, thermal); + kfree(thermal); } From patchwork Wed Apr 13 15:17:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12812123 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B02BDC433FE for ; Wed, 13 Apr 2022 15:19:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236394AbiDMPVb (ORCPT ); Wed, 13 Apr 2022 11:21:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236366AbiDMPV3 (ORCPT ); Wed, 13 Apr 2022 11:21:29 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2077.outbound.protection.outlook.com [40.107.96.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 374F43524C for ; Wed, 13 Apr 2022 08:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JfXXXErMa4QrAkf5WteNoTdjq/z/VhCSFfj0WBAqAtKERiprsiBwSuAatULpiko8NKZ8NuGKrgTIOksrNgMy9HbrGIvzQddDcF9lrEssWmUnOzVy7IuSRjPGh/EUGOb4FlwhLv03egsPWUGj6YmFyU99JYlcugdzkEF34aBQgTccVzs15/g8UhrBG/yIQqsnyVmYk2LFms38OebgLiUH1DF+YsC6wBFDC3h3iR/jWqjFF76oPUTQ1pDNgsggyK6uMIABEmfT1MOUugfWKFu77SlA32ea/m6vCAx9it3TYu/sbHRg46l/F9ThuBj7LkRuv8lw7CCDoQ6FVxndgyYUUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VX5DNTo0AfgyL5Us2wyXIYmQuVE2fa0AE0Zb/Bi34UY=; b=QOsQIMUlQtfDpcKV8+08miWmdlDV1lnZtr+a/H+DEPXWc9O9wLyraLhyp1HJIr4rMWHjAz8lVGFRdIxAbgvGfl7J9F4wk2cH8bKnUPV9dLoy2msp8QiYxxNK/lG+eletWXu6BnyiDpAZpLohmlnF675wFl/sf2VrXNnCJ1pGgX/yEIpbOqoN4v/HBCSmeaD8vlvbqFcXk9rdM2ZRIe57yWLeDXW58XvdsVczsLtN/wkUc+sifFsa5HjwdF+rvkg2zJLQTu6m26XKaIQFaKidj13OLXFzvX7zg3Md6+g0R480hRMuX+aIcXG9AXS0mgBza7SD+u0nW4YIQC6Xt8VpEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=VX5DNTo0AfgyL5Us2wyXIYmQuVE2fa0AE0Zb/Bi34UY=; b=qKz6OoovUOxqUvBqk1pVFeb3lD3BHd1XrRBKmA8Qfh6AC6dZPpE0LHTBtsPzyMWQN7DzavVlLPufA+Ynxqu3gCalzHFndzxy1L/JrMmnafHpId2VCDPCb3IzCXq5sSzqSynZrEcihacMu37Z88JNMpGHOCxlV+5QH7uS9QbssTIRMRijQae5fO/ZC1wIWeZeTUwV1weFMTADjOroGH41k/v4Q1IsV6aCvZ1aPnhqNZ/1gS14s9z230bahGY3pV8f87m0MeK+Ug/gTiUEBVfR1KURDgHE+Ox+9z8ySpXqooJ0/JBBof8NDaUCg/FTkwvbCqmCq45Y5cJmzPpmi3guHw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by BN6PR1201MB2530.namprd12.prod.outlook.com (2603:10b6:404:b0::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.30; Wed, 13 Apr 2022 15:18:55 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402%5]) with mapi id 15.20.5144.029; Wed, 13 Apr 2022 15:18:55 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, petrm@nvidia.com, vadimp@nvidia.com, jiri@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 7/9] mlxsw: core_thermal: Add line card id prefix to line card thermal zone name Date: Wed, 13 Apr 2022 18:17:31 +0300 Message-Id: <20220413151733.2738867-8-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220413151733.2738867-1-idosch@nvidia.com> References: <20220413151733.2738867-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR06CA0095.eurprd06.prod.outlook.com (2603:10a6:803:8c::24) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f765e1c8-2295-4983-7d8c-08da1d60eca3 X-MS-TrafficTypeDiagnostic: BN6PR1201MB2530:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QqkWfTj6IYMmAoHrDJ5xFa5Q1/UEU1w+xErpWTH5fcgWcA9ZVHURL7Id8ImGQs1i1Jp2xvgWu1lJlwPo3nD39r+gQvBWjGx6+VpUGMFZxrbH07BdPRGyp7ymBfJOxaYr+MtkJ7vDVkcZZ70vGSWeVlCRKR6ibRGBCgzw78zv0cKQtpjSo5Qp0T/2sawBBT52i247sUKlZnQ2+Saq4ByXAwqbz09xPYwfc48SoX1qS8skIDeEGnfpf+ffgSVtYk+Mp97RkCW7jJvKmBkXoAIxHuXIH90q6kVJm4v94MWJikuLBKluvfwNgFk6uHy3vmydwmmER9zLbG3WbWQYX2hurSfqjyBlsP0p5tZNDh9p9rO1BKwXt8tnHqoxdAanlDcFAXzp0/2ly4hbtVQYs9ojLsoOcBX0/9qSe3BWjEVvIL0gQxkkTuP7pbCpSAtQycoE7BQDlLuKeTQKseQV2qwRiZiA4NY/XpZtoD7EJUajmDSVPrlHnDsAf2RN4ZLhP6pULn0zXwQDM/nfGBE/TdYZWMmzbg08Fd23NZ70deWFAY+q1Yz7WxlVPqGhGFZksWsH+/MkL2hz/npYBSB8DsPd1ui3/UAHHUEgdIfHP7cyh+ZDPsXG8ui4WIpR5QMbri4xQSlrzofzsifry8qE+nGr6w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(107886003)(316002)(6666004)(36756003)(2616005)(6916009)(1076003)(6506007)(86362001)(2906002)(186003)(66556008)(6486002)(6512007)(508600001)(4326008)(38100700002)(66476007)(26005)(83380400001)(66946007)(8936002)(5660300002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: t8xf39EmFerk0XUNSqzWt2WnfsR2JXbcZ9XlAh0didggOqd5D3dIwcdNdXQ9EqioiXFJEzPhkohtsxscifYVBTMCIEACa9E7FDc1jYODukGPkhUrJ8Zlk0tcew1mw7apvchsxpYzNFmpyRAFS7cc0WoAr3Gzyg4Kkm+8Qh84TdyLefzPHc7QzunvczKth83hcfNxiitRvP3CCPB09Ia6nCQNVg0yzbmmWctmiO40SAVL33eI6wVa20M0oGKqiG9fTWrJhG0sSpqItccbo7Me9BnlW0szoRYRroj06BoE/Py+Fb/KU4AeOpwADCR5jwRz9kIXZAp+VOE9wfJDN3kiZ9Uph6RKplJUAMFQeMmfyOYxun6YF84U3EY6WTZZP/OOa7tJH9FTM35TR8Qk273sXLcUJbmBYQYFtRkRxV69Gw9tCZDrZUlokJbGPdKklu9kBS6AXcKlUJq3V3WR0iizP+SuN4HXj9NnEn1uWeNwZ9yybGdRztV6pozbMPVG9YToRZzBfPeFNSguVtapAaRbpJJXfe8hDIjgdheBhrwz/kMz3/j8gv3KWNTg/5Bo4IT0E956vBGL0yLEMAWtaTijTOAZy2eYmn8XjMbYqW8mvpIdg8GMYRRR9YXbDRdMzWlMtAqNov9CqdTeMxW6lqtvOfu+ohrAgJTIZqq8j85pQ6AxRbInaXUOY7B8Qa5WdFBLnW3gqXY8oGVAXWyPNbfQ/e12qarEztLGRzk+9Z/eWuVpM0edUa2TgOGaknTYOS6BzvGcIhbtQ41XnJBgxnVGhP4y3Rf72LzV3pdIWVutqmrDNS1eWqmqxoiU32C3THoya9Ov5XOat8nHblTLg/Ad8CLZkO89vfzUxYNzQOwq3eT6ZpPTvw+QHo/DhAybiiIw+UzU5SyZzwEm0OXfs16JV3GRWv2lIfUnLPRMBED9DaImeoWJkjolDvgqUNtumrd7Z2jH13n7fZmBgAQThybVar52B/dXqA7evr/9pwEha16+Kwb0RX0dl36yEILHFGU5BauHMzhc+DobD4RLImTQwOFi32xarxJokJQZ9yrd9MJ6QLmu4UQxRq+SJPgeCRoiIONE3Ct3TdFd8Xgug9pqOlwhuAwwbj8YP8IPLJpdyy0e7fqgf7pkEUUhVuUrYld4HGnl25OZtj+KoHBzRPwUtiMc/SlupsTW+wvFb3ZaYq9q738zuYitAc/ivs1X8O4FWqgpPS5FuqZgUgwWhXHpASOPHWkBGGRYoLCOA9lU4a4hoxxbtFbeD8K+dpCwTISM77i5ZWr7ymgnllsVrP0/BQchl96n0jLEWTfJSVQ7UEvXsC1vqW8LC35FSVIHsCmumfpGIw9G/kEr5ZL07AyskQzSqDeKDJNIMLZJFm3olAC/TyltfyiVRWH+jwNvB19hUhFcba1rTRd1aDEpj6/EE2MrbUaHZtLP8N3C7uL3Jw+VYquvvR/3jvmG8z6nKYQL3eGTRG9WGMRLAl6egc9OwzQxERTaoE7TmUWTEtbA8PjcZgmSybNNREgcTmes8ScjWaViFosK1TN6XdrTWS4M4Hf0RUfwyTBwAsbY0NWJiclV0UWvnu6JsXjYDDxAAnzspqMTVilRpuBx82Gg1Yt5ftsUNdMQ1ri+LtQbOailzvE4bcOCRRRxU/kJ9MLzsJ/W5Fxie7sCEDej8fphcp136Oz4scVxAsxtnfBKFlraqV+JBNx3oax7zb8u98aB8dBrezUCZUd4mWB4W+4S707bpQ== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f765e1c8-2295-4983-7d8c-08da1d60eca3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 15:18:55.1643 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /lpo/1/szfwp4LRUC4niZh0koQ3BP6N/VfAX8vq1H4/kQF2KBrt49Y4AtFo8y6Cw1nhF8AYRz6Wcyac9V8KUnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1201MB2530 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vadim Pasternak Add prefix "lc#n" to thermal zones associated with the thermal objects found on line cards. For example thermal zone for module #9 located at line card #7 will have type: mlxsw-lc7-module9. And thermal zone for gearbox #3 located at line card #5 will have type: mlxsw-lc5-gearbox3. Signed-off-by: Vadim Pasternak Reviewed-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/core_thermal.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c index 6d186cc74df3..23ff214367d3 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -685,8 +685,12 @@ mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz) char tz_name[MLXSW_THERMAL_ZONE_MAX_NAME]; int err; - snprintf(tz_name, sizeof(tz_name), "mlxsw-module%d", - module_tz->module + 1); + if (module_tz->slot_index) + snprintf(tz_name, sizeof(tz_name), "mlxsw-lc%d-module%d", + module_tz->slot_index, module_tz->module + 1); + else + snprintf(tz_name, sizeof(tz_name), "mlxsw-module%d", + module_tz->module + 1); module_tz->tzdev = thermal_zone_device_register(tz_name, MLXSW_THERMAL_NUM_TRIPS, MLXSW_THERMAL_TRIP_MASK, @@ -820,8 +824,12 @@ mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz) char tz_name[MLXSW_THERMAL_ZONE_MAX_NAME]; int ret; - snprintf(tz_name, sizeof(tz_name), "mlxsw-gearbox%d", - gearbox_tz->module + 1); + if (gearbox_tz->slot_index) + snprintf(tz_name, sizeof(tz_name), "mlxsw-lc%d-gearbox%d", + gearbox_tz->slot_index, gearbox_tz->module + 1); + else + snprintf(tz_name, sizeof(tz_name), "mlxsw-gearbox%d", + gearbox_tz->module + 1); gearbox_tz->tzdev = thermal_zone_device_register(tz_name, MLXSW_THERMAL_NUM_TRIPS, MLXSW_THERMAL_TRIP_MASK, From patchwork Wed Apr 13 15:17:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12812124 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD179C4332F for ; Wed, 13 Apr 2022 15:19:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236366AbiDMPVc (ORCPT ); Wed, 13 Apr 2022 11:21:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236398AbiDMPVa (ORCPT ); Wed, 13 Apr 2022 11:21:30 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2088.outbound.protection.outlook.com [40.107.243.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DAC439B80 for ; Wed, 13 Apr 2022 08:19:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nj43vggwSD3rjmJsc2nvcuxZ1DwQMiSmj+fUmbO077snA++QHtEG09TBHzFFv+qTawkxG1/SzdU+nLuhjAnhwJHftXa71xmx+Om982+GEQMsIcwvsi/hTNJ5o5mtmc6I0LYuP+Uz1xF2J8A721eY903cMrLzJFvl+QHFB9dmQSIsvS9/JH8lvVm2QKeo96wmIms+yq+/5UpMQvwowGL+33+cOCA4Rfr+cLavroGTTp2cSDJACum4pnS+S33l+C12sfYnrFq2fnXBdwJd4HyVzFM9+mXsp6jxxifM1XNwkMO09UkZomUJQZSfhOv/uRMR/bKKxI1ykJDpGg64Jy5Vrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bELZQPi3CxouDaEj3ffFIRf7ZoRdABasrG9GhfqIryQ=; b=mfVMsrZkY9EO/HUB8+2H3O0/+9ofkeBwju1ItOwkbyIYkf6cJfqyzOxcLCjj1zBD4dx3sULtkOcDx3q3D1sw/DOxTP1AU2MVZvdpcTOrIxdtQLD7NHYZQFqtqN8KU3bisXzxtgXVcwDgNIzz+hIMXXzgEPP+4/HYK8cTQpnmQyp6c/RmC8VH/H8qzLaCTkLdeCf3FI21XJ1VJxHKcjz9e0aF2di8byPl1le4sZkTwtaSqnrS4SIbrEM23kIArXNKp/CEG5oP2jKmnehWLVEGabs9JOVWhmm49LOehel84QuzAtPEW59SyU5F7LSZRzChKUPtuQnG782xGBVXy/qFOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=bELZQPi3CxouDaEj3ffFIRf7ZoRdABasrG9GhfqIryQ=; b=apIBL0QcO37U990IfWf6vXWYtWmfxefCJBroLG3sPbFoX/D9Ta/U0twojZN8wfcKZZ2nte/KNW64vWcEn/E2FMGj70nntkbzzHDPIqiBo8GQk1XdxKqz3wr/oq8Et1Cla+pffOEiYuy6kly7F9XSpFhhP+yNU0HACN+eMSHJco7j9aFOmjz+6kjmRwkaGYyAvpyBBKFKuI4CRIZlNjJtSNYqmWpU7YLiTWPRsz+cn8kJY3g7Q2hQS1VIxtnCmFpGVHpLrYfKQx3xJhqRJctbvAJvOYDamGbw2jk1BNxZG1OyVghGQ5haG3SxB6CIkFRRav6BLb5+igIn6fR9hv5eKw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MN2PR12MB3885.namprd12.prod.outlook.com (2603:10b6:208:16c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29; Wed, 13 Apr 2022 15:19:01 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402%5]) with mapi id 15.20.5144.029; Wed, 13 Apr 2022 15:19:01 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, petrm@nvidia.com, vadimp@nvidia.com, jiri@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 8/9] mlxsw: core_thermal: Use exact name of cooling devices for binding Date: Wed, 13 Apr 2022 18:17:32 +0300 Message-Id: <20220413151733.2738867-9-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220413151733.2738867-1-idosch@nvidia.com> References: <20220413151733.2738867-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR07CA0252.eurprd07.prod.outlook.com (2603:10a6:803:b4::19) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 44360c7a-4a60-40e6-979a-08da1d60f069 X-MS-TrafficTypeDiagnostic: MN2PR12MB3885:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nFi4xYnaG7JxcSb8JBLuDea+DzJzeIPGlrqO4OK63jegH1lYoloxZA2AdESw5le3gwCq2sJcnrzzvg0SaejTXxYQ9zKAOqNlJRcErHGDVR7SSv14nKCKA3hnE+o0Va0CQuEajlGE/U2iRG+454HC4tGObkpsVKqfyg0TiWTN0Ll+nmVhq+XQj9BzipVFv2kTZ9NGtd7L6QmOkuGMB8YieD4JP9EjD83OpKYPr1uHGML39GCy8rxurMoWs7NUBVPv5OLQXZbOf/u+LJNktTPRsgs9HhQC6740l/Mx9+cX4qG6uRtH8UR37HUGT24Y1+JvM24vAyyv3clZ/jqLdKTf2Qe79LqaqEuGEG110s/NN8Pk1goC2oc5RWUmV4kljNej9mkX8htp80lfkRTMz1S+SFOKy/vHM+VOFGKrqaQ7clq4LUDRw1zguNNGAjzKh0JKCj7JmVdff6hQHE7smOQjBlDesWGidJ3ILM44ahx/+FO7x1F2ZLPCbe/RAhr2XojNJIDAaY3lToFjWIfouMLe4g6vfzI2q/4LF/272ZEWuu3/bwankmyRaCSlgVfiIEgpdOHfg+zWe2UBcx4Egzg286Y+ih0v1P6EiIaE1/dE7iSTp2z2QBjPodYjlsjrN0i/aWEAGZ9g8PWMcDmQbi+Rpw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6486002)(66556008)(66946007)(36756003)(2906002)(316002)(6916009)(4326008)(8676002)(83380400001)(86362001)(508600001)(38100700002)(5660300002)(8936002)(26005)(6506007)(186003)(6666004)(2616005)(107886003)(6512007)(1076003)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qSIGnNaNLJZkyjErFj3YqhMEAFLQNISITaSST+n1T6V60ap5YB+S3zhnBnpb+vm072L2ANV3Flxp8OW9nlATt1uRP1N5Tb03GlxB/nt+l6m0hRfONmyaLtwU29aplSPLZ5a85RgWqSWvt6ZL82z1FSQCrA8kk0vgnDKalobiAdxQqILwDyFKxK0VEqwzfcRZn1RyVYkX7IOIUzsHCHW2E/d4HXMry33GZoSx+Mp956Yp9MO7ywmAPC/r56FEgiH8lv1LYNec6SNHE2fhRlGrZG0YvSUPAKI2iy8M6w0Iv8sBavKSpUo35wQ+zdMRoRRPTnp59FibrfKKdpol4TIbqhDk2y8/AvNxzI9VP4lowxZKd2vJIWiHh9Yc0cdZAN8u0QdWGTfKRiOWuvF4MjYu0d2KuOx2vntapwqFb6Vf5jrkIfzkjwHa7uuleDPN2Klogw5f8R9JviCrRvNlv8BGNnL0eHCyV0eHk4Oa15zm8D9FLJRmy2sP6NI5zcC1Ky8o1YdxyFNrWzc3vLnQERaQakIP8MpucfNAQ+io/4Fe2n09Lk2NmwKc9jANddpibYc7xxaz/BEvRivPnPgV4wzBxHYcJd4S1gT+hdLEQjrc/XbJLrKEKGbhs3ruMk5IP+SHhFnHq0ijrA29ExuIs6SN6Vvb22UVbVOaPfzQoNDp/Xyp8vmeMK4lJrM6rHsQmeTa6L/Woompw/r+Tqi4fB4cmjrDhkOt55r8lZsMBuHQDSTHd5UYFW+iHXmulg0+9IA/kyKxqXRttwrKzHJ12+4UAw3PDB+pdkaOb2Ek+oGNmBrT46ScerBWADxlIEoZa4dA7DHABqR+1b/oSzNgeeiwnI7mxtglbal+69g1BVOmR18LMIowvuKXwAUpxpAXfWWv21Dre5oPu2xUxFLQDM5OQxrbO+XS9zY+/KqTridoOZcPbA5BvNi6HRCVzRVchL+vsSjG0l2el/BBmCiWvZl47s8ZmbTACh+cswgQCE67LQuYfVoE2HyQIIJNrGp1KRgrZuDxvjdJ89wfj71/57YVmEtI/EXvZkSKDWZQfDLeohQDGZOcKOS7YfaAmMrgHf6GLesOBdYdBcRZSQ2iZxZO8XaNzbF2gT7TV64ZyqikNhtDc9B/ScLwccVoQNDdzsUTe7xlnjiO3HeJUHnNmkVumtWdebKpqKKV4LhtishDqnPfNvSM11S6Zgi+PWT2ueSxJbCSblOd39f6a+U6+PKT+U6Fg76qYNr6DNG5WJgsd6fYPXAykeZGw3rlSv51YlFsu3Q7TG29wTYgvG8cY2aLK97GOW0pNSRpYgmEU4zVyLx7MlZGTzRgmzEXBbT5ri772EtqU9F5v22CAG+Ho7er7O5FtUkDmQ6Ch3vWDWDXc3D/sxlxPy6Jyp8DF/pXPrkAZ2P6eAgHRAHTSEXROb00szVqCg7Qg2Dr2ExJ+XAw+Ur3RcCcBhK+VPim8KSwo5ogXc7YHWv6qN1h8v6JxkRQNarU+kpUAMkXOieKTd3RzCVl31gFE6Q0cai6QHmy7dp9/FcsD23jW/VVrde7iVxA8kPqjyVkqXo8+GuNsHkFXcQqb0yrbyRbha6DM1Vk3GjtLOWrEf6tnvWod5CjY2os2eQIkzV6ENqvgysyoQpCevQUMNP3Y1ZTqUdjLaHKlduwR6Q3UsuhmEQgYadcRJGyEmWTeNlYsnzbuIpvSTqTW4us8o7xhs4qndUFFphLsYMFWa4JovtWmg8mI0kiDKr8Sg== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44360c7a-4a60-40e6-979a-08da1d60f069 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 15:19:01.4801 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3TWm7R/rEGuu4+MgioRpfT1FDlvI3DNPFfhuIH2IYWWRxxgBt8/osMpzdO7uKSQ38u14lmOaCzTcMULJ/WqFvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3885 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vadim Pasternak Modular system supports additional cooling devices "mlxreg_fan1", "mlxreg_fan2", etcetera. Thermal zones in "mlxsw" driver should be bound to the same device as before called "mlxreg_fan". Used exact match for cooling device name to avoid binding to new additional cooling devices. Signed-off-by: Vadim Pasternak Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c index 23ff214367d3..49ea32457703 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -129,8 +129,7 @@ static int mlxsw_get_cooling_device_idx(struct mlxsw_thermal *thermal, /* Allow mlxsw thermal zone binding to an external cooling device */ for (i = 0; i < ARRAY_SIZE(mlxsw_thermal_external_allowed_cdev); i++) { - if (strnstr(cdev->type, mlxsw_thermal_external_allowed_cdev[i], - strlen(cdev->type))) + if (!strcmp(cdev->type, mlxsw_thermal_external_allowed_cdev[i])) return 0; } From patchwork Wed Apr 13 15:17:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12812125 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22CA7C433FE for ; Wed, 13 Apr 2022 15:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236401AbiDMPVe (ORCPT ); Wed, 13 Apr 2022 11:21:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236354AbiDMPVb (ORCPT ); Wed, 13 Apr 2022 11:21:31 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2078.outbound.protection.outlook.com [40.107.93.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C214E33A14 for ; Wed, 13 Apr 2022 08:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hnKW6vx4U9rwP2jo/kBPovg01WcXOzyt1YWMVYfATMRzGpffN5FtgiupiPUXK3WiHmRI8HNfskSiv0C/gdC87e30FQCw75TFVj9s5fDXvDOkRqz/TDdrBTgzBmvjusQ7BgMwQ+XrCMb+LP1NX6KF4umR3RWBEICJA15Rbm8jngM3aBsn59E4OlBZ1d9sKZi5x1wQRf3W3AEd5D94rLefKJ2jjVFkJwAA50Gysounl5jLXhgyFdZ0Y38WHhLDxjPvEGcz2VlyNCMAJLjubATdRPlfly/qaY2MfpPHFS3EhChSlv3WQ5OgqKQM+63Pm3tWkCUg/gdLXcCLip+/WFqt4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gIQcj/P47cFzkdRNDG2mSPwAMYrEPBEA0r48IvQVPI0=; b=dIWG6QZ1s5ZzyOyH90jI7NNOsmNCe8H2Rd9YF3Yb3+BSGrGPfOcYRsQ0Y2X5x6W9o3IuXLUv5zW6by6OV8qQGSN1qJHIOfj46mCxAjRCPd1wRBAzqnKo/bh/FiJ1OattyQjIG7FW/YhqrgaJPfKSukWTYRSVULeUevTq5yid+rI17KdZAZuCIy83mPTAlU6zyBIt+oPx5ug1VTExiNEgbKPBqD/SM/yETW6LC66t0cIFQ2rEkvv+oPfw7Q6yZrBLFwaB0BBnw18m5QzXFtsvQbqxhLq5a+LWsEUqpwpI8QvipJNWXmeim0nMtek7F2DdSbEcaIPH1EtVh97dlIAh9Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=gIQcj/P47cFzkdRNDG2mSPwAMYrEPBEA0r48IvQVPI0=; b=f+CAKLDgaTSlWC/UVeMqOYGJIEZppnpVacP8UBKF28QLs+38EbvyGe574VlwaBZz1CXPX9GNVDLXZPBnIclEDWV6+rPYdcSQ3JfCdWwXp86PUHg6buDkwfjXCOKnLOdkK8sfj7+Nu8Wp3yqprHl6/xvktvZ1gtJc+KE3FyIkHKPniNDqLUpzwJP7X7SOxYZzZnmXgf4u7iyJ9rDHaYlx6RZONhmGQkR1uTmrOa11HX7+QxTxwTBsGkv9rrsN5mNn1pzi6tYCAiSAm5QMuck7brNQ0Hll/D6638BjwvLaNnh7PbAcBJdTDsQNlfDzp/C/DNmPuWg7utUuMAxUEpZjBg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MN2PR12MB3885.namprd12.prod.outlook.com (2603:10b6:208:16c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29; Wed, 13 Apr 2022 15:19:08 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::6131:18cc:19ae:2402%5]) with mapi id 15.20.5144.029; Wed, 13 Apr 2022 15:19:08 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, petrm@nvidia.com, vadimp@nvidia.com, jiri@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 9/9] mlxsw: core_thermal: Use common define for thermal zone name length Date: Wed, 13 Apr 2022 18:17:33 +0300 Message-Id: <20220413151733.2738867-10-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220413151733.2738867-1-idosch@nvidia.com> References: <20220413151733.2738867-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR06CA0198.eurprd06.prod.outlook.com (2603:10a6:802:2c::19) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8e3d1ca4-2844-4896-2b46-08da1d60f47e X-MS-TrafficTypeDiagnostic: MN2PR12MB3885:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xcdxYjXJiF0w3uvoYePRt96b4+nt5mkSNlhG2dwLDHhrU/BfsypNzUKyxw5HzkvsYop4ttIujZA7FFGTggRFcHjiqXITJQsP+B8NsYTqkrO94u6bs+nTbVsG+gARfc2oAEZl1ume3ezN9QvGm2nRAmbZ+8QMKn1tKRXwMKV80AcgqzuvO5uRQlLg8F4U8hDyFhnS3a+DXktVB8uBrAQQPTXLGQ2Pm/LYzhscFXcUL56n2kGG5FTUzvfjZ/QkIVDtPq/mU1U4PVWiANBxBotNGF9V8OnQZK+LM/Gylv629zQSHNy94rjHT4bUYeuS+kQ05PeB4noooavWvWc2Pv34niBxtALLTOgrFP6nglEOlYuiPayQ5y+UZYSLRzauxR4nz1+Cr4lgvlyMwgMEx+CBdThuB1LU47nqK2dPsDXPMrl/eUOuyNzncYE+Ap4+C5QuJCfaynWL77aze5qzw0kVb5WnDObc98hK/t+entK4jgcaYx85Trzt3N9oXe4XqdDx1s37GC5pZJlZc+jqh/fdeng6QKqyu/jcIL8P+LPkvUASeeGesKf8RY9hRk5b2vLXd/79k7KpE7uboc8sxhwdgWU37tLm4r7DGzJUfabHnvbvLztOnXVQ1MCJ+hIKZ7iIry5FOhsOEc3WX7/SRxHDQg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6486002)(66556008)(66946007)(36756003)(2906002)(316002)(6916009)(4326008)(8676002)(83380400001)(86362001)(508600001)(38100700002)(5660300002)(8936002)(26005)(6506007)(186003)(6666004)(2616005)(107886003)(6512007)(1076003)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jcbqwcBZyXHxW22GUHOmtuce976EQh7uaBjMx4UKeCJ6EFIpP3eXyqUPTyhqVZate+fnPq3FvRUA2n9hhoFABxwUnXXnd7JVxaCiDlg8XcbAu9gqkkfnZ3YPuIb9oTG3/NabQMAV4zBBsK6Sxb24Oud7ULwidTtK1wsXEMWP9CSto5fNmX0JpBcrPivoKWSdTxfT1mbhGL60ehw1u8sBcpMbQARatarXV6oqwCFnkSAeEJ4ZJjhdEM/djkGdz7WVXeUbfe0w59NDKDowxEOx0HXNsO1n+iiMTxbL5vnx3y8xStECVETAg5KBNCI+6cjy0V5O+oXyQckVqJDphNS0eiMkZC9AsMoSYx9TDmNwedAQIbhF1Uag2GoMd2yKlWGnbzGGBwvBNic8MqIOELqKRbBn/GOI6ajZ9P2dUOPQi2RV11PQVu8FkvXMirHu86VeYAHOtg2bfFdDOJUgEAnYIBqJcU6Wd0vC9gR7SZfgenYuOxsWUCbKa5QH9p1m0EGR1fDYoL+/Hs/7kziihh/qjjHOA45rpa6daLmO/bb9ByfQb0N3UX4L0/feKRTJTmy25JM2MQSHJo1vQuGWAHhXsaThYyA1Tsn14U49yKH/A0PlxHuQ8Pr8m2mQB9lkfHZsRcVVQ0xuyGRmY4fWKEllHdhCFkLq4BSqmecbOYTyza0MjQ4y9fcfa6SGWSTM4rbH/sH6zk3/bmZEtTB97PzSA16GDnWUbPnvOn8nmNw+8yV+ioOrgaBRvrrprfzFGJmJtLjg5YTmFFuznriVaNgSt1g3r3SXr75n2KBK3t3p/wqebotM5p5J7AqUINJqtfpelCpvdebbsnd03+YjVznuGxG/705B/9ExPJX8KnaeEZAs7QiZ4jQbTxzt92pfBmz0g0sMk7sLL7md/CKkaC42uvEeAZoQBcHtGAPCA4vTuBPyHaLMLeTIQF+WsCPw8GfhKCqX+qDDGh2/TS+PJyTzS6snL3K5p6/VuXRKfkqQXdraLGW2H7DgPmallXWqHDs8dk2JwldoX+bym+bo8eJ522u323tx2tjSPLA30RQGqmhZ55CovQAmgMcs8lwYU2684U3f/t50D0EUQFcbKPH9iV5JR/IHYzEx1jDzH6JNtjzl3icwX3p0Y8AQp98c8Y0swtoeeMPLYBO0GqrF1vJYn1C5Pc/FmbS9ErAls9VBE9pQVej5ifzNNuPBuF5Ma78+dtV+xjYoTtT9RMuJWEACdeAascEYYqDD8hQczo5UMI+WS+etZSJBlNZHNCqGZsMgfniC3a4NQJ1Swwd8XrPZI/UHEyRoIfO7k7TNsFYzAOV+CekUSuOmff/+LntNgbqX5VWok0u86TYM9lAt3psl+f8gMev946AsvY4fkKkNF/GUU4mP+4CHZUBcPAHVQMP555ij6o2GCPR5Ta2GbSPFFmdUFq/GNuk/c1RgPLydSpEKMjBhdA8n87Qu4FdUcrKC7QD/5yhGwfDvf1AaV3cr2f/9myheZKtL77AQyui+p5yRQEJW3/DEZkkbxHD9ymToMPsb4rcGYEGq5cGY9Q75aHC4dLitceyFagAh/XWIVD3wkkVlxMjCkD0P/yzPDQN5JYcHUCLTc7XQFn5G53hAwhn5L2bV4+b8MQ8jVwhycH8HvZHEsA9rlwhC/4A1oiAOiE4RyDL327OGaUzNYDh6lGqnCzh8ej4xYIFUYXcAfizpLhQEt2rhSWeusXp6lHzhd+3LfSd+hYPiihjbz1mfdQ== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e3d1ca4-2844-4896-2b46-08da1d60f47e X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 15:19:08.3102 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GaO+V5xhFGlmrxDGG7fIvZ5u7Mj/UF41m2ADjlUTgK0OR+plwkKoP1FagQk4gjuhG/n1bhOfJewH+UVovThA+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3885 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vadim Pasternak Replace internal define 'MLXSW_THERMAL_ZONE_MAX_NAME' by common 'THERMAL_NAME_LENGTH'. Signed-off-by: Vadim Pasternak Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c index 49ea32457703..e8ce26a1d483 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -21,7 +21,6 @@ #define MLXSW_THERMAL_ASIC_TEMP_HOT 105000 /* 105C */ #define MLXSW_THERMAL_HYSTERESIS_TEMP 5000 /* 5C */ #define MLXSW_THERMAL_MODULE_TEMP_SHIFT (MLXSW_THERMAL_HYSTERESIS_TEMP * 2) -#define MLXSW_THERMAL_ZONE_MAX_NAME 16 #define MLXSW_THERMAL_TEMP_SCORE_MAX GENMASK(31, 0) #define MLXSW_THERMAL_MAX_STATE 10 #define MLXSW_THERMAL_MIN_STATE 2 @@ -681,7 +680,7 @@ static const struct thermal_cooling_device_ops mlxsw_cooling_ops = { static int mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz) { - char tz_name[MLXSW_THERMAL_ZONE_MAX_NAME]; + char tz_name[THERMAL_NAME_LENGTH]; int err; if (module_tz->slot_index) @@ -820,7 +819,7 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal, static int mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz) { - char tz_name[MLXSW_THERMAL_ZONE_MAX_NAME]; + char tz_name[THERMAL_NAME_LENGTH]; int ret; if (gearbox_tz->slot_index)