mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-21 08:37:37 +07:00
mlxsw: spectrum: Replace port_to_module array with array of structs
Store the initial PMLP register configuration into array of structures instead of just simple array of module numbers. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Reviewed-by: Shalom Toledo <shalomt@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
26a6befa5d
commit
4a7f970f12
@ -748,9 +748,9 @@ mlxsw_sp_port_system_port_mapping_set(struct mlxsw_sp_port *mlxsw_sp_port)
|
|||||||
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sspr), sspr_pl);
|
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sspr), sspr_pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mlxsw_sp_port_module_info_get(struct mlxsw_sp *mlxsw_sp,
|
static int
|
||||||
u8 local_port, u8 *p_module,
|
mlxsw_sp_port_module_info_get(struct mlxsw_sp *mlxsw_sp, u8 local_port,
|
||||||
u8 *p_width, u8 *p_lane)
|
struct mlxsw_sp_port_mapping *port_mapping)
|
||||||
{
|
{
|
||||||
char pmlp_pl[MLXSW_REG_PMLP_LEN];
|
char pmlp_pl[MLXSW_REG_PMLP_LEN];
|
||||||
int err;
|
int err;
|
||||||
@ -759,9 +759,9 @@ static int mlxsw_sp_port_module_info_get(struct mlxsw_sp *mlxsw_sp,
|
|||||||
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl);
|
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
*p_module = mlxsw_reg_pmlp_module_get(pmlp_pl, 0);
|
port_mapping->module = mlxsw_reg_pmlp_module_get(pmlp_pl, 0);
|
||||||
*p_width = mlxsw_reg_pmlp_width_get(pmlp_pl);
|
port_mapping->width = mlxsw_reg_pmlp_width_get(pmlp_pl);
|
||||||
*p_lane = mlxsw_reg_pmlp_tx_lane_get(pmlp_pl, 0);
|
port_mapping->lane = mlxsw_reg_pmlp_tx_lane_get(pmlp_pl, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3979,14 +3979,13 @@ static void mlxsw_sp_ports_remove(struct mlxsw_sp *mlxsw_sp)
|
|||||||
if (mlxsw_sp_port_created(mlxsw_sp, i))
|
if (mlxsw_sp_port_created(mlxsw_sp, i))
|
||||||
mlxsw_sp_port_remove(mlxsw_sp, i);
|
mlxsw_sp_port_remove(mlxsw_sp, i);
|
||||||
mlxsw_sp_cpu_port_remove(mlxsw_sp);
|
mlxsw_sp_cpu_port_remove(mlxsw_sp);
|
||||||
kfree(mlxsw_sp->port_to_module);
|
|
||||||
kfree(mlxsw_sp->ports);
|
kfree(mlxsw_sp->ports);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
|
static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
|
||||||
{
|
{
|
||||||
unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core);
|
unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core);
|
||||||
u8 module, width, lane;
|
struct mlxsw_sp_port_mapping *port_mapping;
|
||||||
size_t alloc_size;
|
size_t alloc_size;
|
||||||
int i;
|
int i;
|
||||||
int err;
|
int err;
|
||||||
@ -3996,48 +3995,78 @@ static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
|
|||||||
if (!mlxsw_sp->ports)
|
if (!mlxsw_sp->ports)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
mlxsw_sp->port_to_module = kmalloc_array(max_ports, sizeof(int),
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (!mlxsw_sp->port_to_module) {
|
|
||||||
err = -ENOMEM;
|
|
||||||
goto err_port_to_module_alloc;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = mlxsw_sp_cpu_port_create(mlxsw_sp);
|
err = mlxsw_sp_cpu_port_create(mlxsw_sp);
|
||||||
if (err)
|
if (err)
|
||||||
goto err_cpu_port_create;
|
goto err_cpu_port_create;
|
||||||
|
|
||||||
for (i = 1; i < max_ports; i++) {
|
for (i = 1; i < max_ports; i++) {
|
||||||
/* Mark as invalid */
|
port_mapping = mlxsw_sp->port_mapping[i];
|
||||||
mlxsw_sp->port_to_module[i] = -1;
|
if (!port_mapping)
|
||||||
|
|
||||||
err = mlxsw_sp_port_module_info_get(mlxsw_sp, i, &module,
|
|
||||||
&width, &lane);
|
|
||||||
if (err)
|
|
||||||
goto err_port_module_info_get;
|
|
||||||
if (!width)
|
|
||||||
continue;
|
continue;
|
||||||
mlxsw_sp->port_to_module[i] = module;
|
|
||||||
err = mlxsw_sp_port_create(mlxsw_sp, i, false,
|
err = mlxsw_sp_port_create(mlxsw_sp, i, false,
|
||||||
module, width, lane);
|
port_mapping->module,
|
||||||
|
port_mapping->width,
|
||||||
|
port_mapping->lane);
|
||||||
if (err)
|
if (err)
|
||||||
goto err_port_create;
|
goto err_port_create;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_port_create:
|
err_port_create:
|
||||||
err_port_module_info_get:
|
|
||||||
for (i--; i >= 1; i--)
|
for (i--; i >= 1; i--)
|
||||||
if (mlxsw_sp_port_created(mlxsw_sp, i))
|
if (mlxsw_sp_port_created(mlxsw_sp, i))
|
||||||
mlxsw_sp_port_remove(mlxsw_sp, i);
|
mlxsw_sp_port_remove(mlxsw_sp, i);
|
||||||
mlxsw_sp_cpu_port_remove(mlxsw_sp);
|
mlxsw_sp_cpu_port_remove(mlxsw_sp);
|
||||||
err_cpu_port_create:
|
err_cpu_port_create:
|
||||||
kfree(mlxsw_sp->port_to_module);
|
|
||||||
err_port_to_module_alloc:
|
|
||||||
kfree(mlxsw_sp->ports);
|
kfree(mlxsw_sp->ports);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int mlxsw_sp_port_module_info_init(struct mlxsw_sp *mlxsw_sp)
|
||||||
|
{
|
||||||
|
unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core);
|
||||||
|
struct mlxsw_sp_port_mapping port_mapping;
|
||||||
|
int i;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
mlxsw_sp->port_mapping = kcalloc(max_ports,
|
||||||
|
sizeof(struct mlxsw_sp_port_mapping *),
|
||||||
|
GFP_KERNEL);
|
||||||
|
if (!mlxsw_sp->port_mapping)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
for (i = 1; i < max_ports; i++) {
|
||||||
|
err = mlxsw_sp_port_module_info_get(mlxsw_sp, i, &port_mapping);
|
||||||
|
if (err)
|
||||||
|
goto err_port_module_info_get;
|
||||||
|
if (!port_mapping.width)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
mlxsw_sp->port_mapping[i] = kmemdup(&port_mapping,
|
||||||
|
sizeof(port_mapping),
|
||||||
|
GFP_KERNEL);
|
||||||
|
if (!mlxsw_sp->port_mapping[i])
|
||||||
|
goto err_port_module_info_dup;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err_port_module_info_get:
|
||||||
|
err_port_module_info_dup:
|
||||||
|
for (i--; i >= 1; i--)
|
||||||
|
kfree(mlxsw_sp->port_mapping[i]);
|
||||||
|
kfree(mlxsw_sp->port_mapping);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mlxsw_sp_port_module_info_fini(struct mlxsw_sp *mlxsw_sp)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 1; i < mlxsw_core_max_ports(mlxsw_sp->core); i++)
|
||||||
|
kfree(mlxsw_sp->port_mapping[i]);
|
||||||
|
kfree(mlxsw_sp->port_mapping);
|
||||||
|
}
|
||||||
|
|
||||||
static u8 mlxsw_sp_cluster_base_port_get(u8 local_port, unsigned int max_width)
|
static u8 mlxsw_sp_cluster_base_port_get(u8 local_port, unsigned int max_width)
|
||||||
{
|
{
|
||||||
u8 offset = (local_port - 1) % max_width;
|
u8 offset = (local_port - 1) % max_width;
|
||||||
@ -4072,7 +4101,8 @@ static void mlxsw_sp_port_unsplit_create(struct mlxsw_sp *mlxsw_sp,
|
|||||||
u8 base_port, unsigned int count,
|
u8 base_port, unsigned int count,
|
||||||
unsigned int max_width)
|
unsigned int max_width)
|
||||||
{
|
{
|
||||||
u8 local_port, module, width = max_width;
|
struct mlxsw_sp_port_mapping *port_mapping;
|
||||||
|
u8 local_port, width = max_width;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Split by four means we need to re-create two ports, otherwise
|
/* Split by four means we need to re-create two ports, otherwise
|
||||||
@ -4082,12 +4112,12 @@ static void mlxsw_sp_port_unsplit_create(struct mlxsw_sp *mlxsw_sp,
|
|||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
local_port = base_port + i * 2;
|
local_port = base_port + i * 2;
|
||||||
if (mlxsw_sp->port_to_module[local_port] < 0)
|
port_mapping = mlxsw_sp->port_mapping[local_port];
|
||||||
|
if (!port_mapping)
|
||||||
continue;
|
continue;
|
||||||
module = mlxsw_sp->port_to_module[local_port];
|
|
||||||
|
|
||||||
mlxsw_sp_port_create(mlxsw_sp, local_port, false, module,
|
mlxsw_sp_port_create(mlxsw_sp, local_port, false,
|
||||||
width, 0);
|
port_mapping->module, width, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4951,6 +4981,12 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
|
|||||||
goto err_dpipe_init;
|
goto err_dpipe_init;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = mlxsw_sp_port_module_info_init(mlxsw_sp);
|
||||||
|
if (err) {
|
||||||
|
dev_err(mlxsw_sp->bus_info->dev, "Failed to init port module info\n");
|
||||||
|
goto err_port_module_info_init;
|
||||||
|
}
|
||||||
|
|
||||||
err = mlxsw_sp_ports_create(mlxsw_sp);
|
err = mlxsw_sp_ports_create(mlxsw_sp);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(mlxsw_sp->bus_info->dev, "Failed to create ports\n");
|
dev_err(mlxsw_sp->bus_info->dev, "Failed to create ports\n");
|
||||||
@ -4960,6 +4996,8 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_ports_create:
|
err_ports_create:
|
||||||
|
mlxsw_sp_port_module_info_fini(mlxsw_sp);
|
||||||
|
err_port_module_info_init:
|
||||||
mlxsw_sp_dpipe_fini(mlxsw_sp);
|
mlxsw_sp_dpipe_fini(mlxsw_sp);
|
||||||
err_dpipe_init:
|
err_dpipe_init:
|
||||||
unregister_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp),
|
unregister_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp),
|
||||||
@ -5052,6 +5090,7 @@ static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core)
|
|||||||
struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core);
|
struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core);
|
||||||
|
|
||||||
mlxsw_sp_ports_remove(mlxsw_sp);
|
mlxsw_sp_ports_remove(mlxsw_sp);
|
||||||
|
mlxsw_sp_port_module_info_fini(mlxsw_sp);
|
||||||
mlxsw_sp_dpipe_fini(mlxsw_sp);
|
mlxsw_sp_dpipe_fini(mlxsw_sp);
|
||||||
unregister_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp),
|
unregister_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp),
|
||||||
&mlxsw_sp->netdevice_nb);
|
&mlxsw_sp->netdevice_nb);
|
||||||
|
@ -143,6 +143,12 @@ struct mlxsw_sp_port_type_speed_ops;
|
|||||||
struct mlxsw_sp_ptp_state;
|
struct mlxsw_sp_ptp_state;
|
||||||
struct mlxsw_sp_ptp_ops;
|
struct mlxsw_sp_ptp_ops;
|
||||||
|
|
||||||
|
struct mlxsw_sp_port_mapping {
|
||||||
|
u8 module;
|
||||||
|
u8 width;
|
||||||
|
u8 lane;
|
||||||
|
};
|
||||||
|
|
||||||
struct mlxsw_sp {
|
struct mlxsw_sp {
|
||||||
struct mlxsw_sp_port **ports;
|
struct mlxsw_sp_port **ports;
|
||||||
struct mlxsw_core *core;
|
struct mlxsw_core *core;
|
||||||
@ -150,7 +156,7 @@ struct mlxsw_sp {
|
|||||||
unsigned char base_mac[ETH_ALEN];
|
unsigned char base_mac[ETH_ALEN];
|
||||||
const unsigned char *mac_mask;
|
const unsigned char *mac_mask;
|
||||||
struct mlxsw_sp_upper *lags;
|
struct mlxsw_sp_upper *lags;
|
||||||
int *port_to_module;
|
struct mlxsw_sp_port_mapping **port_mapping;
|
||||||
struct mlxsw_sp_sb *sb;
|
struct mlxsw_sp_sb *sb;
|
||||||
struct mlxsw_sp_bridge *bridge;
|
struct mlxsw_sp_bridge *bridge;
|
||||||
struct mlxsw_sp_router *router;
|
struct mlxsw_sp_router *router;
|
||||||
@ -259,11 +265,11 @@ struct mlxsw_sp_port {
|
|||||||
struct ieee_pfc *pfc;
|
struct ieee_pfc *pfc;
|
||||||
enum mlxsw_reg_qpts_trust_state trust_state;
|
enum mlxsw_reg_qpts_trust_state trust_state;
|
||||||
} dcb;
|
} dcb;
|
||||||
struct {
|
struct mlxsw_sp_port_mapping mapping; /* mapping is constant during the
|
||||||
u8 module;
|
* mlxsw_sp_port lifetime, however
|
||||||
u8 width;
|
* the same localport can have
|
||||||
u8 lane;
|
* different mapping.
|
||||||
} mapping;
|
*/
|
||||||
/* TC handles */
|
/* TC handles */
|
||||||
struct list_head mall_tc_list;
|
struct list_head mall_tc_list;
|
||||||
struct {
|
struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user