diff options
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/core.c | 6 | ||||
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/core.h | 2 | ||||
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/core_env.c | 18 | ||||
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 3 | ||||
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 6 |
5 files changed, 33 insertions, 2 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c index bcbe07ec22be..6ee6de7f0160 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c | |||
| @@ -122,6 +122,12 @@ void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core) | |||
| 122 | } | 122 | } |
| 123 | EXPORT_SYMBOL(mlxsw_core_driver_priv); | 123 | EXPORT_SYMBOL(mlxsw_core_driver_priv); |
| 124 | 124 | ||
| 125 | bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core) | ||
| 126 | { | ||
| 127 | return mlxsw_core->driver->res_query_enabled; | ||
| 128 | } | ||
| 129 | EXPORT_SYMBOL(mlxsw_core_res_query_enabled); | ||
| 130 | |||
| 125 | struct mlxsw_rx_listener_item { | 131 | struct mlxsw_rx_listener_item { |
| 126 | struct list_head list; | 132 | struct list_head list; |
| 127 | struct mlxsw_rx_listener rxl; | 133 | struct mlxsw_rx_listener rxl; |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h index 917be621c904..e3832cb5bdda 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core.h | |||
| @@ -28,6 +28,8 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core); | |||
| 28 | 28 | ||
| 29 | void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core); | 29 | void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core); |
| 30 | 30 | ||
| 31 | bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core); | ||
| 32 | |||
| 31 | int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver); | 33 | int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver); |
| 32 | void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver); | 34 | void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver); |
| 33 | 35 | ||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c index c1c1965d7acc..72539a9a3847 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include <linux/kernel.h> | 4 | #include <linux/kernel.h> |
| 5 | #include <linux/err.h> | 5 | #include <linux/err.h> |
| 6 | #include <linux/sfp.h> | ||
| 6 | 7 | ||
| 7 | #include "core.h" | 8 | #include "core.h" |
| 8 | #include "core_env.h" | 9 | #include "core_env.h" |
| @@ -162,7 +163,7 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module, | |||
| 162 | { | 163 | { |
| 163 | u8 module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE]; | 164 | u8 module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE]; |
| 164 | u16 offset = MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE; | 165 | u16 offset = MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE; |
| 165 | u8 module_rev_id, module_id; | 166 | u8 module_rev_id, module_id, diag_mon; |
| 166 | unsigned int read_size; | 167 | unsigned int read_size; |
| 167 | int err; | 168 | int err; |
| 168 | 169 | ||
| @@ -195,8 +196,21 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module, | |||
| 195 | } | 196 | } |
| 196 | break; | 197 | break; |
| 197 | case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP: | 198 | case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP: |
| 199 | /* Verify if transceiver provides diagnostic monitoring page */ | ||
| 200 | err = mlxsw_env_query_module_eeprom(mlxsw_core, module, | ||
| 201 | SFP_DIAGMON, 1, &diag_mon, | ||
| 202 | &read_size); | ||
| 203 | if (err) | ||
| 204 | return err; | ||
| 205 | |||
| 206 | if (read_size < 1) | ||
| 207 | return -EIO; | ||
| 208 | |||
| 198 | modinfo->type = ETH_MODULE_SFF_8472; | 209 | modinfo->type = ETH_MODULE_SFF_8472; |
| 199 | modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; | 210 | if (diag_mon) |
| 211 | modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; | ||
| 212 | else | ||
| 213 | modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN / 2; | ||
| 200 | break; | 214 | break; |
| 201 | default: | 215 | default: |
| 202 | return -EINVAL; | 216 | return -EINVAL; |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c index 6956bbebe2f1..496dc904c5ed 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | |||
| @@ -518,6 +518,9 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) | |||
| 518 | u8 width; | 518 | u8 width; |
| 519 | int err; | 519 | int err; |
| 520 | 520 | ||
| 521 | if (!mlxsw_core_res_query_enabled(mlxsw_hwmon->core)) | ||
| 522 | return 0; | ||
| 523 | |||
| 521 | /* Add extra attributes for module temperature. Sensor index is | 524 | /* Add extra attributes for module temperature. Sensor index is |
| 522 | * assigned to sensor_count value, while all indexed before | 525 | * assigned to sensor_count value, while all indexed before |
| 523 | * sensor_count are already utilized by the sensors connected through | 526 | * sensor_count are already utilized by the sensors connected through |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c index 472f63f9fac5..d3e851e7ca72 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | |||
| @@ -740,6 +740,9 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, | |||
| 740 | struct mlxsw_thermal_module *module_tz; | 740 | struct mlxsw_thermal_module *module_tz; |
| 741 | int i, err; | 741 | int i, err; |
| 742 | 742 | ||
| 743 | if (!mlxsw_core_res_query_enabled(core)) | ||
| 744 | return 0; | ||
| 745 | |||
| 743 | thermal->tz_module_arr = kcalloc(module_count, | 746 | thermal->tz_module_arr = kcalloc(module_count, |
| 744 | sizeof(*thermal->tz_module_arr), | 747 | sizeof(*thermal->tz_module_arr), |
| 745 | GFP_KERNEL); | 748 | GFP_KERNEL); |
| @@ -776,6 +779,9 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal) | |||
| 776 | unsigned int module_count = mlxsw_core_max_ports(thermal->core); | 779 | unsigned int module_count = mlxsw_core_max_ports(thermal->core); |
| 777 | int i; | 780 | int i; |
| 778 | 781 | ||
| 782 | if (!mlxsw_core_res_query_enabled(thermal->core)) | ||
| 783 | return; | ||
| 784 | |||
| 779 | for (i = module_count - 1; i >= 0; i--) | 785 | for (i = module_count - 1; i >= 0; i--) |
| 780 | mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]); | 786 | mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]); |
| 781 | kfree(thermal->tz_module_arr); | 787 | kfree(thermal->tz_module_arr); |
