Skip to content

Commit c7fce56

Browse files
committed
Merge branch 'mlxsw-Various-fixes'
Ido Schimmel says: ==================== mlxsw: Various fixes Patch #1 fixes the recently introduced QSFP thermal zones to correctly work with split ports, where several ports are mapped to the same module. Patch #2 initializes the base MAC in the minimal driver. The driver is using the base MAC as its parent ID and without initializing it, it is reported as all zeroes to user space. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 4ec850e + 426aa1f commit c7fce56

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

drivers/net/ethernet/mellanox/mlxsw/core_thermal.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ struct mlxsw_thermal {
111111
struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS];
112112
enum thermal_device_mode mode;
113113
struct mlxsw_thermal_module *tz_module_arr;
114-
unsigned int tz_module_num;
115114
};
116115

117116
static inline u8 mlxsw_state_to_duty(int state)
@@ -711,27 +710,25 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
711710

712711
module = mlxsw_reg_pmlp_module_get(pmlp_pl, 0);
713712
module_tz = &thermal->tz_module_arr[module];
713+
/* Skip if parent is already set (case of port split). */
714+
if (module_tz->parent)
715+
return 0;
714716
module_tz->module = module;
715717
module_tz->parent = thermal;
716718
memcpy(module_tz->trips, default_thermal_trips,
717719
sizeof(thermal->trips));
718720
/* Initialize all trip point. */
719721
mlxsw_thermal_module_trips_reset(module_tz);
720722
/* Update trip point according to the module data. */
721-
err = mlxsw_thermal_module_trips_update(dev, core, module_tz);
722-
if (err)
723-
return err;
724-
725-
thermal->tz_module_num++;
726-
727-
return 0;
723+
return mlxsw_thermal_module_trips_update(dev, core, module_tz);
728724
}
729725

730726
static void mlxsw_thermal_module_fini(struct mlxsw_thermal_module *module_tz)
731727
{
732728
if (module_tz && module_tz->tzdev) {
733729
mlxsw_thermal_module_tz_fini(module_tz->tzdev);
734730
module_tz->tzdev = NULL;
731+
module_tz->parent = NULL;
735732
}
736733
}
737734

@@ -740,6 +737,7 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
740737
struct mlxsw_thermal *thermal)
741738
{
742739
unsigned int module_count = mlxsw_core_max_ports(core);
740+
struct mlxsw_thermal_module *module_tz;
743741
int i, err;
744742

745743
thermal->tz_module_arr = kcalloc(module_count,
@@ -754,8 +752,11 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
754752
goto err_unreg_tz_module_arr;
755753
}
756754

757-
for (i = 0; i < thermal->tz_module_num; i++) {
758-
err = mlxsw_thermal_module_tz_init(&thermal->tz_module_arr[i]);
755+
for (i = 0; i < module_count - 1; i++) {
756+
module_tz = &thermal->tz_module_arr[i];
757+
if (!module_tz->parent)
758+
continue;
759+
err = mlxsw_thermal_module_tz_init(module_tz);
759760
if (err)
760761
goto err_unreg_tz_module_arr;
761762
}

drivers/net/ethernet/mellanox/mlxsw/minimal.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ struct mlxsw_m_port {
3434
u8 module;
3535
};
3636

37+
static int mlxsw_m_base_mac_get(struct mlxsw_m *mlxsw_m)
38+
{
39+
char spad_pl[MLXSW_REG_SPAD_LEN] = {0};
40+
int err;
41+
42+
err = mlxsw_reg_query(mlxsw_m->core, MLXSW_REG(spad), spad_pl);
43+
if (err)
44+
return err;
45+
mlxsw_reg_spad_base_mac_memcpy_from(spad_pl, mlxsw_m->base_mac);
46+
return 0;
47+
}
48+
3749
static int mlxsw_m_port_dummy_open_stop(struct net_device *dev)
3850
{
3951
return 0;
@@ -314,6 +326,12 @@ static int mlxsw_m_init(struct mlxsw_core *mlxsw_core,
314326
mlxsw_m->core = mlxsw_core;
315327
mlxsw_m->bus_info = mlxsw_bus_info;
316328

329+
err = mlxsw_m_base_mac_get(mlxsw_m);
330+
if (err) {
331+
dev_err(mlxsw_m->bus_info->dev, "Failed to get base mac\n");
332+
return err;
333+
}
334+
317335
err = mlxsw_m_ports_create(mlxsw_m);
318336
if (err) {
319337
dev_err(mlxsw_m->bus_info->dev, "Failed to create ports\n");

0 commit comments

Comments
 (0)