From patchwork Tue Apr 19 14:54: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: 12818659 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 88167C433F5 for ; Tue, 19 Apr 2022 14:56:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344346AbiDSO6q (ORCPT ); Tue, 19 Apr 2022 10:58:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345537AbiDSO6L (ORCPT ); Tue, 19 Apr 2022 10:58:11 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2049.outbound.protection.outlook.com [40.107.223.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A3332B18F for ; Tue, 19 Apr 2022 07:55:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LndxSzjgypgo3BLkz5SAvPxXKDB7+GBXjUhHM+Aa5neO479WK5DUL1rRunS0tSGPU0WJgbzt9Xs7QWQAtpud4bumwrOdNKXSoQVS9NQErynFSlKeF1wFqAFs4biwt15+kGFJxw6ayiUYbGDGC87h6hw5E5tqOPmJZOYTvlVxnkZ2KfAgoOl58Iy1sPxqd0kSIGhkuHVCUU8fnC/VwKffpUKVtRIpFEqPkEHzNdtG/ogfeD3zkScMkj1/ic4J4ZIoFmeo/RlRI5G6tj6NE35MDkYfxPWfkM1QrtMWQwNQAXfUBrppkIRoqV1IUrZ/Vri8Puyf9R3Y3R+VwieiOnrj3g== 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=RSeG+9ZUpsM8RNgrsINGSocUUTzfLVC2YVttiCyhcY0=; b=luvRVGLPq+JW8DdqLQKN4ywUMbzUAzo+/knStaD4GR8l0Nad+ql7WNuHBy38ulmrnMq1QXyGgpfEwXEe35l1mDZyeuuebTVdMxv/JQhFHsbyDIV0/xQH4EdNI8RLprPie4eT3wvF7nPfhogzWiFLko3/604mnxyH6/EF/iV54FhCG+hNlX3j0xBx55s2P7RipHc7Hk70WGvN1KJWBi/usTEixc9GDkDFHTPOn+oo1Xdl4oSAvW+hAt4BaXQ4mhDm7b1qFRQvybq/kBFetxhpQOQLViyQcIWmgfwUbMEPTUx7PgPMM6hROXeEYenMO40/fo4IyoWATU6wWJZost2eQQ== 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=RSeG+9ZUpsM8RNgrsINGSocUUTzfLVC2YVttiCyhcY0=; b=qLr/4l1iOd6di+thcTGYh0WPClLraS8kYdnI0Fjba+2+a42m4GRDktJnuo87QFdRZr5cug115PYgaWBPO/eq3CJQUgkwY6iQSFCGhkpg3qWXzndiFOaBW5gDrLDw/lOXAj3bDxRKhHJIDodIb4NzYKe8oah4r1tOP6F0KV7sEHhhkY0KcKoEO79cXXt88HTIIjUsFtBKSURM+yg9P7C+MYxBCD5HdIYtrSTBWJO02riDhaWcqD6pYRXIq0mobUnw6aTo2ho1Uj7WURRC6z1RAwcc6JOo+v+J1xNHol/hpkJEIzj7K0JHmQ6fTtc3f3hsh/S/Ph4aYr3K5Yf+Yyf0WA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MW3PR12MB4347.namprd12.prod.outlook.com (2603:10b6:303:2e::10) by BN6PR12MB1378.namprd12.prod.outlook.com (2603:10b6:404:1e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.13; Tue, 19 Apr 2022 14:55:26 +0000 Received: from MW3PR12MB4347.namprd12.prod.outlook.com ([fe80::9196:55b8:5355:f64d]) by MW3PR12MB4347.namprd12.prod.outlook.com ([fe80::9196:55b8:5355:f64d%2]) with mapi id 15.20.5186.013; Tue, 19 Apr 2022 14:55:26 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, petrm@nvidia.com, jiri@nvidia.com, vadimp@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 3/6] mlxsw: core_env: Split module power mode setting to a separate function Date: Tue, 19 Apr 2022 17:54:28 +0300 Message-Id: <20220419145431.2991382-4-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220419145431.2991382-1-idosch@nvidia.com> References: <20220419145431.2991382-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR08CA0222.eurprd08.prod.outlook.com (2603:10a6:802:15::31) To MW3PR12MB4347.namprd12.prod.outlook.com (2603:10b6:303:2e::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 050e8050-0c5b-4b98-0cc8-08da2214a363 X-MS-TrafficTypeDiagnostic: BN6PR12MB1378: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: Er9+6RBECRJH9wDIEONsC90no4yTW+8Gze0MZ0WqQD39qsWPcFMQBaaTIVJN2FN7g9mITHVMcaWafoyMKNe8GGJ423x6qSqrGGLQ38wR8Qmovk0TkOcjWAHu7FSueS3WN99RHKAfZFnE/VABm8nHJCezrRjYR2whg8zkTmWiu7mjYlyJUw8kTgOQQcBSMAiIsSRkGvZWOGeF5mngJWOYuiogRC1d/L4e/uCyIcyasoh+R8FPZkXU6D0E6HPk4hpzz4zNoCNOzDMOIX797wHros2OczcQ3A63jaEZbFFmfK6KfotrZh6Em+nbeGM/Z8xO9kt1c2dGsff+TcQlAKvAVjzbNBXOj5l7uIuxvJ/EOEmCN6J8hvtbL9fjkBRqXsPOWlsK98xc3AYLiceuCE8dG1x6uS1x6NCokTCogWTB1UfrxbCW7hZStei37B3vZgsC7+617YbZnpCay7ILmJq5NPU81qCuKee5yCR8SbK1sPZ4rRD4MS1UDEtsVoG2jH7c8Tnm9YzmSjNl8+3VKCr3rNYmqeg97d9DXOWtxZJilVsyTgW0T83lUOor7PqHGavxkzZOQgjqgQUSZ2W4UtMwdELcfHCV6V75GAKuvBBorD58V8mxszzrWyj2q2imgh3JHDQP4WSF++k9ZCGxTEAeUw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR12MB4347.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(86362001)(38100700002)(6486002)(508600001)(8936002)(5660300002)(316002)(26005)(6512007)(8676002)(4326008)(66946007)(66556008)(83380400001)(186003)(66476007)(2906002)(6506007)(6916009)(2616005)(1076003)(107886003)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: coMbJexW9hGpzJPoiQ8Lo/LBP6oF2RsaPJurUNl7TADL3TLvMM4K8h4tbYvWQFg2j0Zi2gC3LxgE7E17FArqt0HO+Z3Vru1M8GI/WfnqV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jKRnzP6bVUy84/zJFF8Xr0Vc9nRRVUalbs4qqceELCKMqFCNuUjLmCi5hsbEjxy+/Hw5NG6IdlMUTNto1n+1B3vRM6f/Ba6hSttoomX0n/siaz+tRkg3320MykFkepmwYicCd9AgyUBveynM27Vc40IHt6ih1DH/eouBZ6C3UUsqft8aNqhxw0Iza/9bapLwz8DwQHPZf89fds5Qx1UiVXp8ZQMQBtOiJ48ii/PWOcTi0J+OaWXEjCl7wbbl2h0DR2hFbS6N6SPBzOeVGti6sR+4vZZi+Q3XY2hroZr58tCcOwQpWLJzAK/WL5AG+PvkCeaEkM6hEOCj9UglIwY2sf8+dA4jzDXHGQd6c+5bv4pl5PGcpUcphaGM+fJUInlvkguhZJSmeUWPf9cfT1lBNPKVsJ8nnhx1jald/KGcMT2R1o1625BW0A972YWVJoT+BZyQUcxZXw4dRmsuc6ku6rP/A3JWAO7T7nhMuoZjGM/8K90QUF42bsH7hfYut7C4zu5aSmDolXi2UvRoFuZJmN6NUGAC6m1dNSkag9G2faTLljM6CX0ETaCa7m7g== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 050e8050-0c5b-4b98-0cc8-08da2214a363 X-MS-Exchange-CrossTenant-AuthSource: MW3PR12MB4347.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2022 14:55:26.3932 (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: nCxep65DIsCuXM1k0DPyeyRLtBN2Ras1MfmkaoHrccwozs1kXNfkTfIJOaySZfh6Vj38oYhPfDNShb5jCWAWiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1378 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vadim Pasternak Move the code that applies the module power mode to the device to a separate function. This function will be invoked by the next patch to set the power mode on transceiver modules found on a line card when the line card becomes active. Signed-off-by: Vadim Pasternak Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/core_env.c | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c index abb54177485c..a9b133d6c2fc 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c @@ -648,25 +648,16 @@ static int __mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, return err; } -int -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) +static int +mlxsw_env_set_module_power_mode_apply(struct mlxsw_core *mlxsw_core, + u8 slot_index, u8 module, + enum ethtool_module_power_mode_policy policy, + 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; - if (policy != ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH && - policy != ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) { - NL_SET_ERR_MSG_MOD(extack, "Unsupported power mode policy"); - return -EOPNOTSUPP; - } - - mutex_lock(&mlxsw_env->line_cards_lock); - err = __mlxsw_env_validate_module_type(mlxsw_core, slot_index, module); if (err) { NL_SET_ERR_MSG_MOD(extack, @@ -691,7 +682,29 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index, out_set_policy: module_info->power_mode_policy = policy; out: + return err; +} + +int +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) +{ + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core); + int err; + + if (policy != ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH && + policy != ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) { + NL_SET_ERR_MSG_MOD(extack, "Unsupported power mode policy"); + return -EOPNOTSUPP; + } + + mutex_lock(&mlxsw_env->line_cards_lock); + err = mlxsw_env_set_module_power_mode_apply(mlxsw_core, slot_index, + module, policy, extack); mutex_unlock(&mlxsw_env->line_cards_lock); + return err; } EXPORT_SYMBOL(mlxsw_env_set_module_power_mode);