Skip to contentSkip to conversation

mlxsw: Two port module fixes

PATCH In review Ido Schimmel 2 participants 4 messages May 18, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover mlxsw: Two port module fixes

From: Ido Schimmel <[email protected]>

Patch #1 fixes driver initialization failure on old ASICs due to unsupported register access. This is fixed by first testing if the register is supported.

Patch #2 fixes reading of certain modules' EEPROM. The problem and solution are explained in detail in the commit message.

Please consider both patches for stable.

Vadim Pasternak (2):
mlxsw: core: Prevent QSFP module initialization for old hardware
mlxsw: core: Prevent reading unsupported slave address from SFP EEPROM

 drivers/net/ethernet/mellanox/mlxsw/core.c     |  6 ++++++
 drivers/net/ethernet/mellanox/mlxsw/core.h     |  2 ++
 drivers/net/ethernet/mellanox/mlxsw/core_env.c | 18 ++++++++++++++++--
 .../net/ethernet/mellanox/mlxsw/core_hwmon.c   |  3 +++
 .../net/ethernet/mellanox/mlxsw/core_thermal.c |  6 ++++++
 5 files changed, 33 insertions(+), 2 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 mlxsw: core: Prevent QSFP module initialization for old hardware

From: Vadim Pasternak <[email protected]>

Old Mellanox silicons, like switchx-2, switch-ib do not support reading QSFP modules temperature through MTMP register. Attempt to access this register on systems equipped with the this kind of silicon will cause initialization flow failure.
Test for hardware resource capability is added in order to distinct between old and new silicon - old silicons do not have such capability.

Fixes 6a79507cfe94 ("mlxsw: core: Extend thermal module with per QSFP module thermal zones")
Fixes 5c42eaa07bd0 ("mlxsw: core: Extend hwmon interface with QSFP module temperature attributes")
---
 drivers/net/ethernet/mellanox/mlxsw/core.c         | 6 ++++++
 drivers/net/ethernet/mellanox/mlxsw/core.h         | 2 ++
 drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c   | 3 +++
 drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 6 ++++++
 4 files changed, 17 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/core.c +6 -0
index bcbe07ec22be..6ee6de7f0160 100644
@@ -122,6 +122,12 @@ void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core)
 }
 EXPORT_SYMBOL(mlxsw_core_driver_priv);
 
+bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core)
+{
+	return mlxsw_core->driver->res_query_enabled;
+}
+EXPORT_SYMBOL(mlxsw_core_res_query_enabled);
+
 struct mlxsw_rx_listener_item {
 	struct list_head list;
 	struct mlxsw_rx_listener rxl;
drivers/net/ethernet/mellanox/mlxsw/core.h +2 -0
index 917be621c904..e3832cb5bdda 100644
@@ -28,6 +28,8 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);
 
 void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core);
 
+bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core);
+
 int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver);
 void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver);
 
drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +3 -0
index 6956bbebe2f1..496dc904c5ed 100644
@@ -518,6 +518,9 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
 	u8 width;
 	int err;
 
+	if (!mlxsw_core_res_query_enabled(mlxsw_hwmon->core))
+		return 0;
+
 	/* Add extra attributes for module temperature. Sensor index is
 	 * assigned to sensor_count value, while all indexed before
 	 * sensor_count are already utilized by the sensors connected through
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +6 -0
index 472f63f9fac5..d3e851e7ca72 100644
@@ -740,6 +740,9 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
 	struct mlxsw_thermal_module *module_tz;
 	int i, err;
 
+	if (!mlxsw_core_res_query_enabled(core))
+		return 0;
+
 	thermal->tz_module_arr = kcalloc(module_count,
 					 sizeof(*thermal->tz_module_arr),
 					 GFP_KERNEL);
@@ -776,6 +779,9 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal)
 	unsigned int module_count = mlxsw_core_max_ports(thermal->core);
 	int i;
 
+	if (!mlxsw_core_res_query_enabled(thermal->core))
+		return;
+
 	for (i = module_count - 1; i >= 0; i--)
 		mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]);
 	kfree(thermal->tz_module_arr);
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/2 mlxsw: core: Prevent reading unsupported slave address from SFP EEPROM

In reply to Ido Schimmel

From: Vadim Pasternak <[email protected]>

Prevent reading unsupported slave address from SFP EEPROM by testing Diagnostic Monitoring Type byte in EEPROM. Read only page zero of EEPROM, in case this byte is zero.

If some SFP transceiver does not support Digital Optical Monitoring (DOM), reading SFP EEPROM slave address 0x51 could return an error. Availability of DOM support is verified by reading from zero page Diagnostic Monitoring Type byte describing how diagnostic monitoring is implemented by transceiver. If bit 6 of this byte is set, it indicates that digital diagnostic monitoring has been implemented. Otherwise it is not and transceiver could fail to reply to transaction for slave address 0x51 [1010001X (A2h)], which is used to access measurements page.

Such issue has been observed when reading cable MCP2M00-xxxx, MCP7F00-xxxx, and few others.

Fixes 2ea109039cd3 ("mlxsw: spectrum: Add support for access cable info via ethtool")
Fixes 4400081b631a ("mlxsw: spectrum: Fix EEPROM access in case of SFP/SFP+")
---
 drivers/net/ethernet/mellanox/mlxsw/core_env.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/core_env.c +16 -2
index c1c1965d7acc..72539a9a3847 100644
@@ -3,6 +3,7 @@
 
 #include <linux/kernel.h>
 #include <linux/err.h>
+#include <linux/sfp.h>
 
 #include "core.h"
 #include "core_env.h"
@@ -162,7 +163,7 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
 {
 	u8 module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE];
 	u16 offset = MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE;
-	u8 module_rev_id, module_id;
+	u8 module_rev_id, module_id, diag_mon;
 	unsigned int read_size;
 	int err;
 
@@ -195,8 +196,21 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
 		}
 		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,
+						    &read_size);
+		if (err)
+			return err;
+
+		if (read_size < 1)
+			return -EIO;
+
 		modinfo->type       = ETH_MODULE_SFF_8472;
-		modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
+		if (diag_mon)
+			modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
+		else
+			modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN / 2;
 		break;
 	default:
 		return -EINVAL;
Signature · 1 line
2.20.1
maintainer
#3 lore raw
In reply to Ido Schimmel

From: Ido Schimmel <[email protected]>
Date: Sat, 18 May 2019 18:58:27 +0300

Quoted 8 lines

From: Ido Schimmel <[email protected]>

Patch #1 fixes driver initialization failure on old ASICs due to unsupported register access. This is fixed by first testing if the register is supported.

Patch #2 fixes reading of certain modules' EEPROM. The problem and solution are explained in detail in the commit message.

Series applied.

Quoted 1 line

Please consider both patches for stable.

Queued up.

Thanks!