All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@idosch.org>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, jiri@nvidia.com,
	petrm@nvidia.com, amcohen@nvidia.com, vadimp@nvidia.com,
	c_mykolak@nvidia.com, mlxsw@nvidia.com,
	Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH net-next 6/8] mlxsw: core_env: Read module temperature thresholds using MTMP register
Date: Tue,  8 Jun 2021 15:44:12 +0300	[thread overview]
Message-ID: <20210608124414.1664294-7-idosch@idosch.org> (raw)
In-Reply-To: <20210608124414.1664294-1-idosch@idosch.org>

From: Mykola Kostenok <c_mykolak@nvidia.com>

Currently, module temperature thresholds are obtained from Management
Cable Info Access (MCIA) register by specifying the thresholds offsets
within module EEPROM layout. This data does not pass validation and in
some cases can be unreliable. For example, due to some problem with the
module.

Add support for a new feature provided by Management Temperature (MTMP)
register for sanitization of temperature thresholds values.

Extend mlxsw_env_module_temp_thresholds_get() to get temperature
thresholds through MTMP field 'max_operational_temperature' - if it is
not zero, feature is supported. Otherwise fallback to old method and get
the thresholds through MCIA.

Signed-off-by: Mykola Kostenok <c_mykolak@nvidia.com>
Acked-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_env.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
index bcad1327d861..b3ca5bd33a7f 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
@@ -125,6 +125,7 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module,
 int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
 					 int off, int *temp)
 {
+	unsigned int module_temp, module_crit, module_emerg;
 	char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
 	union {
 		u8 buf[MLXSW_REG_MCIA_TH_ITEM_SIZE];
@@ -132,7 +133,6 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
 	} temp_thresh;
 	char mcia_pl[MLXSW_REG_MCIA_LEN] = {0};
 	char mtmp_pl[MLXSW_REG_MTMP_LEN];
-	unsigned int module_temp;
 	bool qsfp, cmis;
 	int page;
 	int err;
@@ -142,12 +142,21 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
 	err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl);
 	if (err)
 		return err;
-	mlxsw_reg_mtmp_unpack(mtmp_pl, &module_temp, NULL, NULL, NULL, NULL);
+	mlxsw_reg_mtmp_unpack(mtmp_pl, &module_temp, NULL, &module_crit,
+			      &module_emerg, NULL);
 	if (!module_temp) {
 		*temp = 0;
 		return 0;
 	}
 
+	/* Validate if threshold reading is available through MTMP register,
+	 * otherwise fallback to read through MCIA.
+	 */
+	if (module_emerg) {
+		*temp = off == SFP_TEMP_HIGH_WARN ? module_crit : module_emerg;
+		return 0;
+	}
+
 	/* Read Free Side Device Temperature Thresholds from page 03h
 	 * (MSB at lower byte address).
 	 * Bytes:
-- 
2.31.1


  parent reply	other threads:[~2021-06-08 12:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08 12:44 [PATCH net-next 0/8] mlxsw: Various updates Ido Schimmel
2021-06-08 12:44 ` [PATCH net-next 1/8] mlxsw: spectrum_router: Remove abort mechanism Ido Schimmel
2021-06-08 12:44 ` [PATCH net-next 2/8] selftests: router_scale: Do not count failed routes Ido Schimmel
2021-06-08 12:44 ` [PATCH net-next 3/8] selftests: Clean forgotten resources as part of cleanup() Ido Schimmel
2021-06-08 12:44 ` [PATCH net-next 4/8] selftests: devlink_lib: Fix bouncing of netdevsim DEVLINK_DEV Ido Schimmel
2021-06-08 12:44 ` [PATCH net-next 5/8] mlxsw: reg: Extend MTMP register with new threshold field Ido Schimmel
2021-06-08 12:44 ` Ido Schimmel [this message]
2021-06-08 12:44 ` [PATCH net-next 7/8] mlxsw: thermal: Add function for reading module temperature and thresholds Ido Schimmel
2021-06-08 12:44 ` [PATCH net-next 8/8] mlxsw: thermal: Read module temperature thresholds using MTMP register Ido Schimmel
2021-06-08 21:50 ` [PATCH net-next 0/8] mlxsw: Various updates patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210608124414.1664294-7-idosch@idosch.org \
    --to=idosch@idosch.org \
    --cc=amcohen@nvidia.com \
    --cc=c_mykolak@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=idosch@nvidia.com \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=mlxsw@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=petrm@nvidia.com \
    --cc=vadimp@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.