Commit c3a64b51 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

mlxsw: spectrum: Fix base port get for split count 4 and 8

The current code considers only split by 2 or 4. Make the base port
getting generic and allow split by 8 to be handled correctly. Generalize
the used port checks as well.
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Reviewed-by: default avatarShalom Toledo <shalomt@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 013da297
...@@ -4233,19 +4233,21 @@ static int mlxsw_sp_port_split(struct mlxsw_core *mlxsw_core, u8 local_port, ...@@ -4233,19 +4233,21 @@ static int mlxsw_sp_port_split(struct mlxsw_core *mlxsw_core, u8 local_port,
return -EINVAL; return -EINVAL;
} }
/* Make sure we have enough slave (even) ports for the split. */ /* Only in case max split is being done, the local port and
if (count == 2) { * base port may differ.
base_port = local_port; */
if (mlxsw_sp->ports[base_port + offset]) { base_port = count == max_width ?
netdev_err(mlxsw_sp_port->dev, "Invalid split configuration\n"); mlxsw_sp_cluster_base_port_get(local_port, max_width) :
NL_SET_ERR_MSG_MOD(extack, "Invalid split configuration"); local_port;
return -EINVAL;
} for (i = 0; i < count * offset; i++) {
} else { /* Expect base port to exist and also the one in the middle in
base_port = mlxsw_sp_cluster_base_port_get(local_port, * case of maximal split count.
max_width); */
if (mlxsw_sp->ports[base_port + 1] || if (i == 0 || (count == max_width && i == count / 2))
mlxsw_sp->ports[base_port + 3]) { continue;
if (mlxsw_sp_port_created(mlxsw_sp, base_port + i)) {
netdev_err(mlxsw_sp_port->dev, "Invalid split configuration\n"); netdev_err(mlxsw_sp_port->dev, "Invalid split configuration\n");
NL_SET_ERR_MSG_MOD(extack, "Invalid split configuration"); NL_SET_ERR_MSG_MOD(extack, "Invalid split configuration");
return -EINVAL; return -EINVAL;
......
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