Skip to content

Commit a4feea7

Browse files
idoschdavem330
authored andcommitted
mlxsw: reg: Add Switch Port VLAN MAC Learning register definition
Since we currently do not support the offloading of 802.1D bridges, we need to be able to let the device know it should not learn MAC addresses on specific {Port, VID} pairs. Add the SPVMLR register, which controls the learning enablement of {Port, VID} pairs. 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 e534a56 commit a4feea7

File tree

1 file changed

+67
-0
lines changed
  • drivers/net/ethernet/mellanox/mlxsw

1 file changed

+67
-0
lines changed

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

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,71 @@ static inline void mlxsw_reg_sfmr_pack(char *payload,
11321132
mlxsw_reg_sfmr_vv_set(payload, false);
11331133
}
11341134

1135+
/* SPVMLR - Switch Port VLAN MAC Learning Register
1136+
* -----------------------------------------------
1137+
* Controls the switch MAC learning policy per {Port, VID}.
1138+
*/
1139+
#define MLXSW_REG_SPVMLR_ID 0x2020
1140+
#define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */
1141+
#define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */
1142+
#define MLXSW_REG_SPVMLR_REC_MAX_COUNT 256
1143+
#define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \
1144+
MLXSW_REG_SPVMLR_REC_LEN * \
1145+
MLXSW_REG_SPVMLR_REC_MAX_COUNT)
1146+
1147+
static const struct mlxsw_reg_info mlxsw_reg_spvmlr = {
1148+
.id = MLXSW_REG_SPVMLR_ID,
1149+
.len = MLXSW_REG_SPVMLR_LEN,
1150+
};
1151+
1152+
/* reg_spvmlr_local_port
1153+
* Local ingress port.
1154+
* Access: Index
1155+
*
1156+
* Note: CPU port is not supported.
1157+
*/
1158+
MLXSW_ITEM32(reg, spvmlr, local_port, 0x00, 16, 8);
1159+
1160+
/* reg_spvmlr_num_rec
1161+
* Number of records to update.
1162+
* Access: OP
1163+
*/
1164+
MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8);
1165+
1166+
/* reg_spvmlr_rec_learn_enable
1167+
* 0 - Disable learning for {Port, VID}.
1168+
* 1 - Enable learning for {Port, VID}.
1169+
* Access: RW
1170+
*/
1171+
MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
1172+
31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1173+
1174+
/* reg_spvmlr_rec_vid
1175+
* VLAN ID to be added/removed from port or for querying.
1176+
* Access: Index
1177+
*/
1178+
MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
1179+
MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1180+
1181+
static inline void mlxsw_reg_spvmlr_pack(char *payload, u8 local_port,
1182+
u16 vid_begin, u16 vid_end,
1183+
bool learn_enable)
1184+
{
1185+
int num_rec = vid_end - vid_begin + 1;
1186+
int i;
1187+
1188+
WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT);
1189+
1190+
MLXSW_REG_ZERO(spvmlr, payload);
1191+
mlxsw_reg_spvmlr_local_port_set(payload, local_port);
1192+
mlxsw_reg_spvmlr_num_rec_set(payload, num_rec);
1193+
1194+
for (i = 0; i < num_rec; i++) {
1195+
mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable);
1196+
mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i);
1197+
}
1198+
}
1199+
11351200
/* PMLP - Ports Module to Local Port Register
11361201
* ------------------------------------------
11371202
* Configures the assignment of modules to local ports.
@@ -2318,6 +2383,8 @@ static inline const char *mlxsw_reg_id_str(u16 reg_id)
23182383
return "SVPE";
23192384
case MLXSW_REG_SFMR_ID:
23202385
return "SFMR";
2386+
case MLXSW_REG_SPVMLR_ID:
2387+
return "SPVMLR";
23212388
case MLXSW_REG_PMLP_ID:
23222389
return "PMLP";
23232390
case MLXSW_REG_PMTU_ID:

0 commit comments

Comments
 (0)