Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee8a2b95 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'mlxsw-Two-port-module-fixes'



Ido Schimmel says:

====================
mlxsw: Two port module fixes

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.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents ba95e5df f1436c80
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -122,6 +122,12 @@ void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core)
}
}
EXPORT_SYMBOL(mlxsw_core_driver_priv);
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 mlxsw_rx_listener_item {
	struct list_head list;
	struct list_head list;
	struct mlxsw_rx_listener rxl;
	struct mlxsw_rx_listener rxl;
+2 −0
Original line number Original line Diff line number Diff line
@@ -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);
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);
int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver);
void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver);
void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver);


+16 −2
Original line number Original line Diff line number Diff line
@@ -3,6 +3,7 @@


#include <linux/kernel.h>
#include <linux/kernel.h>
#include <linux/err.h>
#include <linux/err.h>
#include <linux/sfp.h>


#include "core.h"
#include "core.h"
#include "core_env.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];
	u8 module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE];
	u16 offset = 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;
	unsigned int read_size;
	int err;
	int err;


@@ -195,8 +196,21 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
		}
		}
		break;
		break;
	case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP:
	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->type       = ETH_MODULE_SFF_8472;
		if (diag_mon)
			modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
			modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
		else
			modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN / 2;
		break;
		break;
	default:
	default:
		return -EINVAL;
		return -EINVAL;
+3 −0
Original line number Original line Diff line number Diff line
@@ -518,6 +518,9 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
	u8 width;
	u8 width;
	int err;
	int err;


	if (!mlxsw_core_res_query_enabled(mlxsw_hwmon->core))
		return 0;

	/* Add extra attributes for module temperature. Sensor index is
	/* Add extra attributes for module temperature. Sensor index is
	 * assigned to sensor_count value, while all indexed before
	 * assigned to sensor_count value, while all indexed before
	 * sensor_count are already utilized by the sensors connected through
	 * sensor_count are already utilized by the sensors connected through
+6 −0
Original line number Original line Diff line number Diff line
@@ -740,6 +740,9 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
	struct mlxsw_thermal_module *module_tz;
	struct mlxsw_thermal_module *module_tz;
	int i, err;
	int i, err;


	if (!mlxsw_core_res_query_enabled(core))
		return 0;

	thermal->tz_module_arr = kcalloc(module_count,
	thermal->tz_module_arr = kcalloc(module_count,
					 sizeof(*thermal->tz_module_arr),
					 sizeof(*thermal->tz_module_arr),
					 GFP_KERNEL);
					 GFP_KERNEL);
@@ -776,6 +779,9 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal)
	unsigned int module_count = mlxsw_core_max_ports(thermal->core);
	unsigned int module_count = mlxsw_core_max_ports(thermal->core);
	int i;
	int i;


	if (!mlxsw_core_res_query_enabled(thermal->core))
		return;

	for (i = module_count - 1; i >= 0; i--)
	for (i = module_count - 1; i >= 0; i--)
		mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]);
		mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]);
	kfree(thermal->tz_module_arr);
	kfree(thermal->tz_module_arr);