Skip to content

Commit c7ea08b

Browse files
vadimp-nvidiakuba-moo
authored andcommitted
mlxsw: minimal: Extend APIs with slot index for modular system support
Add 'slot_index' field to port structure. Replace zero slot_index argument with 'slot_index' in 'ethtool' related APIs. Add 'slot_index' argument to port initialization and de-initialization related APIs. Motivation is to prepare minimal driver for modular system support. Signed-off-by: Vadim Pasternak <vadimp@nvidia.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Petr Machata <petrm@nvidia.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 33fa690 commit c7ea08b

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

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

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct mlxsw_m_port {
3939
struct net_device *dev;
4040
struct mlxsw_m *mlxsw_m;
4141
u16 local_port;
42+
u8 slot_index;
4243
u8 module;
4344
};
4445

@@ -111,8 +112,9 @@ static int mlxsw_m_get_module_info(struct net_device *netdev,
111112
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
112113
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
113114

114-
return mlxsw_env_get_module_info(netdev, core, 0, mlxsw_m_port->module,
115-
modinfo);
115+
return mlxsw_env_get_module_info(netdev, core,
116+
mlxsw_m_port->slot_index,
117+
mlxsw_m_port->module, modinfo);
116118
}
117119

118120
static int
@@ -122,7 +124,8 @@ mlxsw_m_get_module_eeprom(struct net_device *netdev, struct ethtool_eeprom *ee,
122124
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
123125
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
124126

125-
return mlxsw_env_get_module_eeprom(netdev, core, 0,
127+
return mlxsw_env_get_module_eeprom(netdev, core,
128+
mlxsw_m_port->slot_index,
126129
mlxsw_m_port->module, ee, data);
127130
}
128131

@@ -134,7 +137,8 @@ mlxsw_m_get_module_eeprom_by_page(struct net_device *netdev,
134137
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
135138
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
136139

137-
return mlxsw_env_get_module_eeprom_by_page(core, 0,
140+
return mlxsw_env_get_module_eeprom_by_page(core,
141+
mlxsw_m_port->slot_index,
138142
mlxsw_m_port->module,
139143
page, extack);
140144
}
@@ -144,7 +148,8 @@ static int mlxsw_m_reset(struct net_device *netdev, u32 *flags)
144148
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
145149
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
146150

147-
return mlxsw_env_reset_module(netdev, core, 0, mlxsw_m_port->module,
151+
return mlxsw_env_reset_module(netdev, core, mlxsw_m_port->slot_index,
152+
mlxsw_m_port->module,
148153
flags);
149154
}
150155

@@ -156,7 +161,8 @@ mlxsw_m_get_module_power_mode(struct net_device *netdev,
156161
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
157162
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
158163

159-
return mlxsw_env_get_module_power_mode(core, 0, mlxsw_m_port->module,
164+
return mlxsw_env_get_module_power_mode(core, mlxsw_m_port->slot_index,
165+
mlxsw_m_port->module,
160166
params, extack);
161167
}
162168

@@ -168,7 +174,8 @@ mlxsw_m_set_module_power_mode(struct net_device *netdev,
168174
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
169175
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
170176

171-
return mlxsw_env_set_module_power_mode(core, 0, mlxsw_m_port->module,
177+
return mlxsw_env_set_module_power_mode(core, mlxsw_m_port->slot_index,
178+
mlxsw_m_port->module,
172179
params->policy, extack);
173180
}
174181

@@ -217,13 +224,14 @@ mlxsw_m_port_dev_addr_get(struct mlxsw_m_port *mlxsw_m_port)
217224
}
218225

219226
static int
220-
mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u16 local_port, u8 module)
227+
mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u16 local_port, u8 slot_index,
228+
u8 module)
221229
{
222230
struct mlxsw_m_port *mlxsw_m_port;
223231
struct net_device *dev;
224232
int err;
225233

226-
err = mlxsw_core_port_init(mlxsw_m->core, local_port, 0,
234+
err = mlxsw_core_port_init(mlxsw_m->core, local_port, slot_index,
227235
module + 1, false, 0, false,
228236
0, mlxsw_m->base_mac,
229237
sizeof(mlxsw_m->base_mac));
@@ -246,6 +254,7 @@ mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u16 local_port, u8 module)
246254
mlxsw_m_port->mlxsw_m = mlxsw_m;
247255
mlxsw_m_port->local_port = local_port;
248256
mlxsw_m_port->module = module;
257+
mlxsw_m_port->slot_index = slot_index;
249258

250259
dev->netdev_ops = &mlxsw_m_port_netdev_ops;
251260
dev->ethtool_ops = &mlxsw_m_port_ethtool_ops;
@@ -319,10 +328,11 @@ static int mlxsw_m_port_module_map(struct mlxsw_m *mlxsw_m, u16 local_port,
319328
return 0;
320329
}
321330

322-
static void mlxsw_m_port_module_unmap(struct mlxsw_m *mlxsw_m, u8 module)
331+
static void
332+
mlxsw_m_port_module_unmap(struct mlxsw_m *mlxsw_m, u8 slot_index, u8 module)
323333
{
324334
mlxsw_m->module_to_port[module] = -1;
325-
mlxsw_env_module_port_unmap(mlxsw_m->core, 0, module);
335+
mlxsw_env_module_port_unmap(mlxsw_m->core, slot_index, module);
326336
}
327337

328338
static int mlxsw_m_ports_create(struct mlxsw_m *mlxsw_m)
@@ -360,7 +370,7 @@ static int mlxsw_m_ports_create(struct mlxsw_m *mlxsw_m)
360370
if (mlxsw_m->module_to_port[i] > 0) {
361371
err = mlxsw_m_port_create(mlxsw_m,
362372
mlxsw_m->module_to_port[i],
363-
i);
373+
0, i);
364374
if (err)
365375
goto err_module_to_port_create;
366376
}
@@ -377,7 +387,7 @@ static int mlxsw_m_ports_create(struct mlxsw_m *mlxsw_m)
377387
i = max_ports;
378388
err_module_to_port_map:
379389
for (i--; i > 0; i--)
380-
mlxsw_m_port_module_unmap(mlxsw_m, i);
390+
mlxsw_m_port_module_unmap(mlxsw_m, 0, i);
381391
kfree(mlxsw_m->module_to_port);
382392
err_module_to_port_alloc:
383393
kfree(mlxsw_m->ports);
@@ -392,7 +402,7 @@ static void mlxsw_m_ports_remove(struct mlxsw_m *mlxsw_m)
392402
if (mlxsw_m->module_to_port[i] > 0) {
393403
mlxsw_m_port_remove(mlxsw_m,
394404
mlxsw_m->module_to_port[i]);
395-
mlxsw_m_port_module_unmap(mlxsw_m, i);
405+
mlxsw_m_port_module_unmap(mlxsw_m, 0, i);
396406
}
397407
}
398408

0 commit comments

Comments
 (0)