Skip to content

Commit e61011b

Browse files
idoschdavem330
authored andcommitted
mlxsw: Make system port to local port mapping explicit
System ports are unique identifiers in a multi-ASIC environment that represent all the available ports in the system. Local ports on the other hand, are unique only within the local ASIC. Since system port to local port mapping is not part of the HW-SW contract and since only single-ASIC configurations are currently supported, set an explicit 1:1 mapping by configuring the Switch System Port Record (SSPR) register. Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 26a80f6 commit e61011b

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,64 @@ static inline void mlxsw_reg_smid_pack(char *payload, u16 mid)
150150
mlxsw_reg_smid_port_mask_set(payload, MLXSW_PORT_CPU_PORT, 1);
151151
}
152152

153+
/* SSPR - Switch System Port Record Register
154+
* -----------------------------------------
155+
* Configures the system port to local port mapping.
156+
*/
157+
#define MLXSW_REG_SSPR_ID 0x2008
158+
#define MLXSW_REG_SSPR_LEN 0x8
159+
160+
static const struct mlxsw_reg_info mlxsw_reg_sspr = {
161+
.id = MLXSW_REG_SSPR_ID,
162+
.len = MLXSW_REG_SSPR_LEN,
163+
};
164+
165+
/* reg_sspr_m
166+
* Master - if set, then the record describes the master system port.
167+
* This is needed in case a local port is mapped into several system ports
168+
* (for multipathing). That number will be reported as the source system
169+
* port when packets are forwarded to the CPU. Only one master port is allowed
170+
* per local port.
171+
*
172+
* Note: Must be set for Spectrum.
173+
* Access: RW
174+
*/
175+
MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1);
176+
177+
/* reg_sspr_local_port
178+
* Local port number.
179+
*
180+
* Access: RW
181+
*/
182+
MLXSW_ITEM32(reg, sspr, local_port, 0x00, 16, 8);
183+
184+
/* reg_sspr_sub_port
185+
* Virtual port within the physical port.
186+
* Should be set to 0 when virtual ports are not enabled on the port.
187+
*
188+
* Access: RW
189+
*/
190+
MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8);
191+
192+
/* reg_sspr_system_port
193+
* Unique identifier within the stacking domain that represents all the ports
194+
* that are available in the system (external ports).
195+
*
196+
* Currently, only single-ASIC configurations are supported, so we default to
197+
* 1:1 mapping between system ports and local ports.
198+
* Access: Index
199+
*/
200+
MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
201+
202+
static inline void mlxsw_reg_sspr_pack(char *payload, u8 local_port)
203+
{
204+
MLXSW_REG_ZERO(sspr, payload);
205+
mlxsw_reg_sspr_m_set(payload, 1);
206+
mlxsw_reg_sspr_local_port_set(payload, local_port);
207+
mlxsw_reg_sspr_sub_port_set(payload, 0);
208+
mlxsw_reg_sspr_system_port_set(payload, local_port);
209+
}
210+
153211
/* SPMS - Switch Port MSTP/RSTP State Register
154212
* -------------------------------------------
155213
* Configures the spanning tree state of a physical port.
@@ -1216,6 +1274,8 @@ static inline const char *mlxsw_reg_id_str(u16 reg_id)
12161274
return "SPAD";
12171275
case MLXSW_REG_SMID_ID:
12181276
return "SMID";
1277+
case MLXSW_REG_SSPR_ID:
1278+
return "SSPR";
12191279
case MLXSW_REG_SPMS_ID:
12201280
return "SPMS";
12211281
case MLXSW_REG_SFGC_ID:

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,16 @@ static int mlxsw_sx_port_swid_set(struct mlxsw_sx_port *mlxsw_sx_port, u8 swid)
245245
return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(pspa), pspa_pl);
246246
}
247247

248+
static int
249+
mlxsw_sx_port_system_port_mapping_set(struct mlxsw_sx_port *mlxsw_sx_port)
250+
{
251+
struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx;
252+
char sspr_pl[MLXSW_REG_SSPR_LEN];
253+
254+
mlxsw_reg_sspr_pack(sspr_pl, mlxsw_sx_port->local_port);
255+
return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sspr), sspr_pl);
256+
}
257+
248258
static int mlxsw_sx_port_module_check(struct mlxsw_sx_port *mlxsw_sx_port,
249259
bool *p_usable)
250260
{
@@ -1001,6 +1011,13 @@ static int mlxsw_sx_port_create(struct mlxsw_sx *mlxsw_sx, u8 local_port)
10011011
goto port_not_usable;
10021012
}
10031013

1014+
err = mlxsw_sx_port_system_port_mapping_set(mlxsw_sx_port);
1015+
if (err) {
1016+
dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set system port mapping\n",
1017+
mlxsw_sx_port->local_port);
1018+
goto err_port_system_port_mapping_set;
1019+
}
1020+
10041021
err = mlxsw_sx_port_swid_set(mlxsw_sx_port, 0);
10051022
if (err) {
10061023
dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set SWID\n",
@@ -1061,6 +1078,7 @@ static int mlxsw_sx_port_create(struct mlxsw_sx *mlxsw_sx, u8 local_port)
10611078
err_port_mtu_set:
10621079
err_port_speed_set:
10631080
err_port_swid_set:
1081+
err_port_system_port_mapping_set:
10641082
port_not_usable:
10651083
err_port_module_check:
10661084
err_dev_addr_get:

0 commit comments

Comments
 (0)