Commit c7ea08ba authored by Vadim Pasternak's avatar Vadim Pasternak Committed by Jakub Kicinski

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: default avatarVadim Pasternak <vadimp@nvidia.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 33fa6909
...@@ -39,6 +39,7 @@ struct mlxsw_m_port { ...@@ -39,6 +39,7 @@ struct mlxsw_m_port {
struct net_device *dev; struct net_device *dev;
struct mlxsw_m *mlxsw_m; struct mlxsw_m *mlxsw_m;
u16 local_port; u16 local_port;
u8 slot_index;
u8 module; u8 module;
}; };
...@@ -111,8 +112,9 @@ static int mlxsw_m_get_module_info(struct net_device *netdev, ...@@ -111,8 +112,9 @@ static int mlxsw_m_get_module_info(struct net_device *netdev,
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
return mlxsw_env_get_module_info(netdev, core, 0, mlxsw_m_port->module, return mlxsw_env_get_module_info(netdev, core,
modinfo); mlxsw_m_port->slot_index,
mlxsw_m_port->module, modinfo);
} }
static int static int
...@@ -122,7 +124,8 @@ mlxsw_m_get_module_eeprom(struct net_device *netdev, struct ethtool_eeprom *ee, ...@@ -122,7 +124,8 @@ mlxsw_m_get_module_eeprom(struct net_device *netdev, struct ethtool_eeprom *ee,
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
return mlxsw_env_get_module_eeprom(netdev, core, 0, return mlxsw_env_get_module_eeprom(netdev, core,
mlxsw_m_port->slot_index,
mlxsw_m_port->module, ee, data); mlxsw_m_port->module, ee, data);
} }
...@@ -134,7 +137,8 @@ mlxsw_m_get_module_eeprom_by_page(struct net_device *netdev, ...@@ -134,7 +137,8 @@ mlxsw_m_get_module_eeprom_by_page(struct net_device *netdev,
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
return mlxsw_env_get_module_eeprom_by_page(core, 0, return mlxsw_env_get_module_eeprom_by_page(core,
mlxsw_m_port->slot_index,
mlxsw_m_port->module, mlxsw_m_port->module,
page, extack); page, extack);
} }
...@@ -144,7 +148,8 @@ static int mlxsw_m_reset(struct net_device *netdev, u32 *flags) ...@@ -144,7 +148,8 @@ static int mlxsw_m_reset(struct net_device *netdev, u32 *flags)
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
return mlxsw_env_reset_module(netdev, core, 0, mlxsw_m_port->module, return mlxsw_env_reset_module(netdev, core, mlxsw_m_port->slot_index,
mlxsw_m_port->module,
flags); flags);
} }
...@@ -156,7 +161,8 @@ mlxsw_m_get_module_power_mode(struct net_device *netdev, ...@@ -156,7 +161,8 @@ mlxsw_m_get_module_power_mode(struct net_device *netdev,
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
return mlxsw_env_get_module_power_mode(core, 0, mlxsw_m_port->module, return mlxsw_env_get_module_power_mode(core, mlxsw_m_port->slot_index,
mlxsw_m_port->module,
params, extack); params, extack);
} }
...@@ -168,7 +174,8 @@ mlxsw_m_set_module_power_mode(struct net_device *netdev, ...@@ -168,7 +174,8 @@ mlxsw_m_set_module_power_mode(struct net_device *netdev,
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev); struct mlxsw_m_port *mlxsw_m_port = netdev_priv(netdev);
struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core; struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
return mlxsw_env_set_module_power_mode(core, 0, mlxsw_m_port->module, return mlxsw_env_set_module_power_mode(core, mlxsw_m_port->slot_index,
mlxsw_m_port->module,
params->policy, extack); params->policy, extack);
} }
...@@ -217,13 +224,14 @@ mlxsw_m_port_dev_addr_get(struct mlxsw_m_port *mlxsw_m_port) ...@@ -217,13 +224,14 @@ mlxsw_m_port_dev_addr_get(struct mlxsw_m_port *mlxsw_m_port)
} }
static int static int
mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u16 local_port, u8 module) mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u16 local_port, u8 slot_index,
u8 module)
{ {
struct mlxsw_m_port *mlxsw_m_port; struct mlxsw_m_port *mlxsw_m_port;
struct net_device *dev; struct net_device *dev;
int err; int err;
err = mlxsw_core_port_init(mlxsw_m->core, local_port, 0, err = mlxsw_core_port_init(mlxsw_m->core, local_port, slot_index,
module + 1, false, 0, false, module + 1, false, 0, false,
0, mlxsw_m->base_mac, 0, mlxsw_m->base_mac,
sizeof(mlxsw_m->base_mac)); sizeof(mlxsw_m->base_mac));
...@@ -246,6 +254,7 @@ mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u16 local_port, u8 module) ...@@ -246,6 +254,7 @@ mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u16 local_port, u8 module)
mlxsw_m_port->mlxsw_m = mlxsw_m; mlxsw_m_port->mlxsw_m = mlxsw_m;
mlxsw_m_port->local_port = local_port; mlxsw_m_port->local_port = local_port;
mlxsw_m_port->module = module; mlxsw_m_port->module = module;
mlxsw_m_port->slot_index = slot_index;
dev->netdev_ops = &mlxsw_m_port_netdev_ops; dev->netdev_ops = &mlxsw_m_port_netdev_ops;
dev->ethtool_ops = &mlxsw_m_port_ethtool_ops; 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, ...@@ -319,10 +328,11 @@ static int mlxsw_m_port_module_map(struct mlxsw_m *mlxsw_m, u16 local_port,
return 0; return 0;
} }
static void mlxsw_m_port_module_unmap(struct mlxsw_m *mlxsw_m, u8 module) static void
mlxsw_m_port_module_unmap(struct mlxsw_m *mlxsw_m, u8 slot_index, u8 module)
{ {
mlxsw_m->module_to_port[module] = -1; mlxsw_m->module_to_port[module] = -1;
mlxsw_env_module_port_unmap(mlxsw_m->core, 0, module); mlxsw_env_module_port_unmap(mlxsw_m->core, slot_index, module);
} }
static int mlxsw_m_ports_create(struct mlxsw_m *mlxsw_m) 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) ...@@ -360,7 +370,7 @@ static int mlxsw_m_ports_create(struct mlxsw_m *mlxsw_m)
if (mlxsw_m->module_to_port[i] > 0) { if (mlxsw_m->module_to_port[i] > 0) {
err = mlxsw_m_port_create(mlxsw_m, err = mlxsw_m_port_create(mlxsw_m,
mlxsw_m->module_to_port[i], mlxsw_m->module_to_port[i],
i); 0, i);
if (err) if (err)
goto err_module_to_port_create; goto err_module_to_port_create;
} }
...@@ -377,7 +387,7 @@ static int mlxsw_m_ports_create(struct mlxsw_m *mlxsw_m) ...@@ -377,7 +387,7 @@ static int mlxsw_m_ports_create(struct mlxsw_m *mlxsw_m)
i = max_ports; i = max_ports;
err_module_to_port_map: err_module_to_port_map:
for (i--; i > 0; i--) for (i--; i > 0; i--)
mlxsw_m_port_module_unmap(mlxsw_m, i); mlxsw_m_port_module_unmap(mlxsw_m, 0, i);
kfree(mlxsw_m->module_to_port); kfree(mlxsw_m->module_to_port);
err_module_to_port_alloc: err_module_to_port_alloc:
kfree(mlxsw_m->ports); kfree(mlxsw_m->ports);
...@@ -392,7 +402,7 @@ static void mlxsw_m_ports_remove(struct mlxsw_m *mlxsw_m) ...@@ -392,7 +402,7 @@ static void mlxsw_m_ports_remove(struct mlxsw_m *mlxsw_m)
if (mlxsw_m->module_to_port[i] > 0) { if (mlxsw_m->module_to_port[i] > 0) {
mlxsw_m_port_remove(mlxsw_m, mlxsw_m_port_remove(mlxsw_m,
mlxsw_m->module_to_port[i]); mlxsw_m->module_to_port[i]);
mlxsw_m_port_module_unmap(mlxsw_m, i); mlxsw_m_port_module_unmap(mlxsw_m, 0, i);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment