Skip to content

Commit 558c2d5

Browse files
idoschdavem330
authored andcommitted
mlxsw: spectrum: Store local port to module mapping during init
The port netdevs are each associated with a different local port number in the device. These local ports are grouped into groups of 4 (e.g. (1-4), (5-8)) called clusters. The cluster constitutes the one of two possible modules they can be mapped to. This mapping is board-specific and done by the device's firmware during init. When splitting a port by 4, the device requires us to first unmap all the ports in the cluster and then map each to a single lane in the module associated with the port netdev used as the handle for the operation. This means that two port netdevs will disappear, as only 100Gb/s (4 lanes) ports can be split and we are guaranteed to have two of these ((1, 3), (5, 7) etc.) in a cluster. When unsplit occurs we need to reinstantiate the two original 100Gb/s ports and map each to its origianl module. Therefore, during driver init store the initial local port to module mapping, so it can be used later during unsplitting. Note that a by 2 split doesn't require us to store the mapping, as we only need to reinstantiate one port whose module is known. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3e9b27b commit 558c2d5

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

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

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -305,18 +305,19 @@ mlxsw_sp_port_system_port_mapping_set(struct mlxsw_sp_port *mlxsw_sp_port)
305305
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sspr), sspr_pl);
306306
}
307307

308-
static int mlxsw_sp_port_module_check(struct mlxsw_sp_port *mlxsw_sp_port,
309-
bool *p_usable)
308+
static int mlxsw_sp_port_module_info_get(struct mlxsw_sp *mlxsw_sp,
309+
u8 local_port, u8 *p_module,
310+
u8 *p_width)
310311
{
311-
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
312312
char pmlp_pl[MLXSW_REG_PMLP_LEN];
313313
int err;
314314

315-
mlxsw_reg_pmlp_pack(pmlp_pl, mlxsw_sp_port->local_port);
315+
mlxsw_reg_pmlp_pack(pmlp_pl, local_port);
316316
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl);
317317
if (err)
318318
return err;
319-
*p_usable = mlxsw_reg_pmlp_width_get(pmlp_pl) ? true : false;
319+
*p_module = mlxsw_reg_pmlp_module_get(pmlp_pl, 0);
320+
*p_width = mlxsw_reg_pmlp_width_get(pmlp_pl);
320321
return 0;
321322
}
322323

@@ -1365,7 +1366,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port)
13651366
struct mlxsw_sp_port *mlxsw_sp_port;
13661367
struct devlink_port *devlink_port;
13671368
struct net_device *dev;
1368-
bool usable;
13691369
size_t bytes;
13701370
int err;
13711371

@@ -1416,19 +1416,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port)
14161416
*/
14171417
dev->hard_header_len += MLXSW_TXHDR_LEN;
14181418

1419-
err = mlxsw_sp_port_module_check(mlxsw_sp_port, &usable);
1420-
if (err) {
1421-
dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to check module\n",
1422-
mlxsw_sp_port->local_port);
1423-
goto err_port_module_check;
1424-
}
1425-
1426-
if (!usable) {
1427-
dev_dbg(mlxsw_sp->bus_info->dev, "Port %d: Not usable, skipping initialization\n",
1428-
mlxsw_sp_port->local_port);
1429-
goto port_not_usable;
1430-
}
1431-
14321419
devlink_port = &mlxsw_sp_port->devlink_port;
14331420
err = devlink_port_register(devlink, devlink_port, local_port);
14341421
if (err) {
@@ -1496,8 +1483,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port)
14961483
err_port_system_port_mapping_set:
14971484
devlink_port_unregister(&mlxsw_sp_port->devlink_port);
14981485
err_devlink_port_register:
1499-
port_not_usable:
1500-
err_port_module_check:
15011486
err_dev_addr_init:
15021487
free_percpu(mlxsw_sp_port->pcpu_stats);
15031488
err_alloc_stats:
@@ -1559,6 +1544,7 @@ static void mlxsw_sp_ports_remove(struct mlxsw_sp *mlxsw_sp)
15591544
static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
15601545
{
15611546
size_t alloc_size;
1547+
u8 module, width;
15621548
int i;
15631549
int err;
15641550

@@ -1568,13 +1554,21 @@ static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
15681554
return -ENOMEM;
15691555

15701556
for (i = 1; i < MLXSW_PORT_MAX_PORTS; i++) {
1557+
err = mlxsw_sp_port_module_info_get(mlxsw_sp, i, &module,
1558+
&width);
1559+
if (err)
1560+
goto err_port_module_info_get;
1561+
if (!width)
1562+
continue;
1563+
mlxsw_sp->port_to_module[i] = module;
15711564
err = mlxsw_sp_port_create(mlxsw_sp, i);
15721565
if (err)
15731566
goto err_port_create;
15741567
}
15751568
return 0;
15761569

15771570
err_port_create:
1571+
err_port_module_info_get:
15781572
for (i--; i >= 1; i--)
15791573
mlxsw_sp_port_remove(mlxsw_sp, i);
15801574
kfree(mlxsw_sp->ports);

drivers/net/ethernet/mellanox/mlxsw/spectrum.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ struct mlxsw_sp {
123123
u32 ageing_time;
124124
struct mlxsw_sp_upper master_bridge;
125125
struct mlxsw_sp_upper lags[MLXSW_SP_LAG_MAX];
126+
u8 port_to_module[MLXSW_PORT_MAX_PORTS];
126127
};
127128

128129
static inline struct mlxsw_sp_upper *

0 commit comments

Comments
 (0)