From patchwork Thu Sep 3 13:41:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 261578 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5A93C2BC11 for ; Thu, 3 Sep 2020 14:59:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC62920658 for ; Thu, 3 Sep 2020 14:59:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="mIg2ZoQR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729438AbgICO75 (ORCPT ); Thu, 3 Sep 2020 10:59:57 -0400 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:47471 "EHLO new2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728877AbgICOGa (ORCPT ); Thu, 3 Sep 2020 10:06:30 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 9660F580571; Thu, 3 Sep 2020 09:42:30 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 03 Sep 2020 09:42:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=nsL9vwsAlYQbc2fPQQk4f0FA2ka9eiIMrA/dba1uV4c=; b=mIg2ZoQR OYjgGU/mibRm5DFZX4tagD6aXGPX4Duu4vvvKH/uyIjzfLVsKu9ijdGDnoTKLRhJ DFGXM9sS2oZIT9nnHftjDgHkE7oP5w8vOPrzL+xLop9bpSdC+jquO2+oNeb5Qoha /GX+zZzj0Q6h8cTmMOG5mgBlgDH/6fX5i7CNrdrSI0r5EZNojcx0vG/KC1rF4YJR df2fpC7GCeGbxTiZaYAIF+9c4/zV6knqxnCfZQqvh+BsDdup4CYsKjKayhurReVc TxljxBnTanIZMhRXBRopaB/cbyWqPy3wOLucfg6yD0QqTKJ4MHKw/an0gYGhBl9E 6jmtQ/50KOdCxQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudeguddgieelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefkughoucfu tghhihhmmhgvlhcuoehiughoshgthhesihguohhstghhrdhorhhgqeenucggtffrrghtth gvrhhnpeduteeiveffffevleekleejffekhfekhefgtdfftefhledvjefggfehgfevjeek hfenucfkphepkeegrddvvdelrdefiedrjedunecuvehluhhsthgvrhfuihiivgepudenuc frrghrrghmpehmrghilhhfrhhomhepihguohhstghhsehiughoshgthhdrohhrgh X-ME-Proxy: Received: from shredder.mtl.com (igld-84-229-36-71.inter.net.il [84.229.36.71]) by mail.messagingengine.com (Postfix) with ESMTPA id 1CA1B3280060; Thu, 3 Sep 2020 09:42:27 -0400 (EDT) From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, jiri@nvidia.com, amcohen@nvidia.com, petrm@nvidia.com, vadimp@nvidia.com, andrew@lunn.ch, mlxsw@nvidia.com, Amit Cohen , Ido Schimmel Subject: [PATCH net-next 2/3] mlxsw: core_hwmon: Calculate MLXSW_HWMON_ATTR_COUNT more accurately Date: Thu, 3 Sep 2020 16:41:45 +0300 Message-Id: <20200903134146.2166437-3-idosch@idosch.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903134146.2166437-1-idosch@idosch.org> References: <20200903134146.2166437-1-idosch@idosch.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Amit Cohen Currently the value of MLXSW_HWMON_ATTR_COUNT is calculated not really accurate. Add several defines to make the calculation clearer and easier to change. Calculate the precise high bound of number of attributes that may be needed. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c index 3f1822535bc6..f1b0c176eaeb 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c @@ -12,8 +12,17 @@ #include "core.h" #include "core_env.h" -#define MLXSW_HWMON_TEMP_SENSOR_MAX_COUNT 127 -#define MLXSW_HWMON_ATTR_COUNT (MLXSW_HWMON_TEMP_SENSOR_MAX_COUNT * 4 + \ +#define MLXSW_HWMON_SENSORS_MAX_COUNT 64 +#define MLXSW_HWMON_MODULES_MAX_COUNT 64 +#define MLXSW_HWMON_GEARBOXES_MAX_COUNT 32 + +#define MLXSW_HWMON_ATTR_PER_SENSOR 3 +#define MLXSW_HWMON_ATTR_PER_MODULE 5 +#define MLXSW_HWMON_ATTR_PER_GEARBOX 4 + +#define MLXSW_HWMON_ATTR_COUNT (MLXSW_HWMON_SENSORS_MAX_COUNT * MLXSW_HWMON_ATTR_PER_SENSOR + \ + MLXSW_HWMON_MODULES_MAX_COUNT * MLXSW_HWMON_ATTR_PER_MODULE + \ + MLXSW_HWMON_GEARBOXES_MAX_COUNT * MLXSW_HWMON_ATTR_PER_GEARBOX + \ MLXSW_MFCR_TACHOS_MAX + MLXSW_MFCR_PWMS_MAX) struct mlxsw_hwmon_attr {