Skip to content

Commit d521bc0

Browse files
author
Paolo Abeni
committed
Merge branch 'mlxsw-unified-bridge-conversion-part-4-6'
Ido Schimmel says: ==================== mlxsw: Unified bridge conversion - part 4/6 This is the fourth part of the conversion of mlxsw to the unified bridge model. Unlike previous parts that prepared mlxsw for the conversion, this part actually starts the conversion. It focuses on flooding configuration and converts mlxsw to the more "raw" APIs of the unified bridge model. The patches configure the different stages of the flooding pipeline in Spectrum that looks as follows (at a high-level): +------------+ +----------+ +-------+ {FID, | | {Packet type, | | | | MID DMAC} | FDB lookup | Bridge type} | SFGC | MID base | | Index +--------> (miss) +----------------> register +-----------> Adder +-------> | | | | | | | | | | | | +------------+ +----+-----+ +---^---+ | | Table | | type | | Offset | +-------+ | | | | | | | | | +----->+ Mux +------+ | | | | +-^---^-+ | | FID| |FID | |offset + + The multicast identifier (MID) index is used as an index to the port group table (PGT) that contains a bitmap of ports via which a packet needs to be replicated. From the PGT table, the packet continues to the multicast port egress (MPE) table that determines the packet's egress VLAN. This is a two-dimensional table that is indexed by port and switch multicast port to egress (SMPE) index. The latter can be thought of as a FID. Without it, all the packets replicated via a certain port would get the same VLAN, regardless of the bridge domain (FID). Logically, these two steps look as follows: PGT table MPE table +-----------------------+ +---------------+ | | {Local port, | | Egress MID index | Local ports bitmap #1 | SMPE index} | | VID +------------> ... +---------------> +--------> | Local ports bitmap #N | | | | | SMPE | | +-----------------------+ +---------------+ Local port Patchset overview: Patch #1 adds a variable to guard against mixed model configuration. Will be removed in part 6 when mlxsw is fully converted to the unified model. Patches #2-#5 introduce two new FID attributes required for flooding configuration in the new model: 1. 'flood_rsp': Instructs the firmware to handle flooding configuration for this FID. Only set for router FIDs (rFIDs) which are used to connect a {Port, VLAN} to the router block. 2. 'bridge_type': Allows the device to determine the flood table (i.e., base index to the PGT table) for the FID. The first type will be used for FIDs in a VLAN-aware bridge and the second for FIDs representing VLAN-unaware bridges. Patch #6 configures the MPE table that determines the egress VLAN of a packet that is forwarded according to L2 multicast / flood. Patches #7-#11 add the PGT table and related APIs to allocate entries and set / clear ports in them. Patches #12-#13 convert the flooding configuration to use the new PGT APIs. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 778964f + fe94df6 commit d521bc0

File tree

8 files changed

+572
-40
lines changed

8 files changed

+572
-40
lines changed

drivers/net/ethernet/mellanox/mlxsw/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ mlxsw_spectrum-objs := spectrum.o spectrum_buffers.o \
2828
spectrum_qdisc.o spectrum_span.o \
2929
spectrum_nve.o spectrum_nve_vxlan.o \
3030
spectrum_dpipe.o spectrum_trap.o \
31-
spectrum_ethtool.o spectrum_policer.o
31+
spectrum_ethtool.o spectrum_policer.o \
32+
spectrum_pgt.o
3233
mlxsw_spectrum-$(CONFIG_MLXSW_SPECTRUM_DCB) += spectrum_dcb.o
3334
mlxsw_spectrum-$(CONFIG_PTP_1588_CLOCK) += spectrum_ptp.o
3435
obj-$(CONFIG_MLXSW_MINIMAL) += mlxsw_minimal.o

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,9 +1054,10 @@ enum mlxsw_reg_sfgc_type {
10541054
*/
10551055
MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
10561056

1057-
enum mlxsw_reg_sfgc_bridge_type {
1058-
MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0,
1059-
MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1,
1057+
/* bridge_type is used in SFGC and SFMR. */
1058+
enum mlxsw_reg_bridge_type {
1059+
MLXSW_REG_BRIDGE_TYPE_0 = 0, /* Used for .1q FIDs. */
1060+
MLXSW_REG_BRIDGE_TYPE_1 = 1, /* Used for .1d FIDs. */
10601061
};
10611062

10621063
/* reg_sfgc_bridge_type
@@ -1111,15 +1112,16 @@ MLXSW_ITEM32(reg, sfgc, mid_base, 0x10, 0, 16);
11111112

11121113
static inline void
11131114
mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
1114-
enum mlxsw_reg_sfgc_bridge_type bridge_type,
1115+
enum mlxsw_reg_bridge_type bridge_type,
11151116
enum mlxsw_flood_table_type table_type,
1116-
unsigned int flood_table)
1117+
unsigned int flood_table, u16 mid_base)
11171118
{
11181119
MLXSW_REG_ZERO(sfgc, payload);
11191120
mlxsw_reg_sfgc_type_set(payload, type);
11201121
mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
11211122
mlxsw_reg_sfgc_table_type_set(payload, table_type);
11221123
mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
1124+
mlxsw_reg_sfgc_mid_base_set(payload, mid_base);
11231125
}
11241126

11251127
/* SFDF - Switch Filtering DB Flush
@@ -1960,14 +1962,17 @@ MLXSW_ITEM32(reg, sfmr, smpe, 0x28, 0, 16);
19601962

19611963
static inline void mlxsw_reg_sfmr_pack(char *payload,
19621964
enum mlxsw_reg_sfmr_op op, u16 fid,
1963-
u16 fid_offset)
1965+
u16 fid_offset, bool flood_rsp,
1966+
enum mlxsw_reg_bridge_type bridge_type)
19641967
{
19651968
MLXSW_REG_ZERO(sfmr, payload);
19661969
mlxsw_reg_sfmr_op_set(payload, op);
19671970
mlxsw_reg_sfmr_fid_set(payload, fid);
19681971
mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset);
19691972
mlxsw_reg_sfmr_vtfp_set(payload, false);
19701973
mlxsw_reg_sfmr_vv_set(payload, false);
1974+
mlxsw_reg_sfmr_flood_rsp_set(payload, flood_rsp);
1975+
mlxsw_reg_sfmr_flood_bridge_type_set(payload, bridge_type);
19711976
}
19721977

19731978
/* SPVMLR - Switch Port VLAN MAC Learning Register

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ enum mlxsw_res_id {
1111
MLXSW_RES_ID_KVD_SIZE,
1212
MLXSW_RES_ID_KVD_SINGLE_MIN_SIZE,
1313
MLXSW_RES_ID_KVD_DOUBLE_MIN_SIZE,
14+
MLXSW_RES_ID_PGT_SIZE,
1415
MLXSW_RES_ID_MAX_KVD_LINEAR_RANGE,
1516
MLXSW_RES_ID_MAX_KVD_ACTION_SETS,
1617
MLXSW_RES_ID_MAX_TRAP_GROUPS,
@@ -69,6 +70,7 @@ static u16 mlxsw_res_ids[] = {
6970
[MLXSW_RES_ID_KVD_SIZE] = 0x1001,
7071
[MLXSW_RES_ID_KVD_SINGLE_MIN_SIZE] = 0x1002,
7172
[MLXSW_RES_ID_KVD_DOUBLE_MIN_SIZE] = 0x1003,
73+
[MLXSW_RES_ID_PGT_SIZE] = 0x1004,
7274
[MLXSW_RES_ID_MAX_KVD_LINEAR_RANGE] = 0x1005,
7375
[MLXSW_RES_ID_MAX_KVD_ACTION_SETS] = 0x1007,
7476
[MLXSW_RES_ID_MAX_TRAP_GROUPS] = 0x2201,

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,6 +3010,12 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
30103010
return err;
30113011
}
30123012

3013+
err = mlxsw_sp_pgt_init(mlxsw_sp);
3014+
if (err) {
3015+
dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize PGT\n");
3016+
goto err_pgt_init;
3017+
}
3018+
30133019
err = mlxsw_sp_fids_init(mlxsw_sp);
30143020
if (err) {
30153021
dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize FIDs\n");
@@ -3155,6 +3161,7 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
31553161
goto err_ports_create;
31563162
}
31573163

3164+
mlxsw_sp->ubridge = false;
31583165
return 0;
31593166

31603167
err_ports_create:
@@ -3201,6 +3208,8 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
32013208
err_policers_init:
32023209
mlxsw_sp_fids_fini(mlxsw_sp);
32033210
err_fids_init:
3211+
mlxsw_sp_pgt_fini(mlxsw_sp);
3212+
err_pgt_init:
32043213
mlxsw_sp_kvdl_fini(mlxsw_sp);
32053214
mlxsw_sp_parsing_fini(mlxsw_sp);
32063215
return err;
@@ -3234,6 +3243,7 @@ static int mlxsw_sp1_init(struct mlxsw_core *mlxsw_core,
32343243
mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp1_listener);
32353244
mlxsw_sp->fid_family_arr = mlxsw_sp1_fid_family_arr;
32363245
mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1;
3246+
mlxsw_sp->pgt_smpe_index_valid = true;
32373247

32383248
return mlxsw_sp_init(mlxsw_core, mlxsw_bus_info, extack);
32393249
}
@@ -3267,6 +3277,7 @@ static int mlxsw_sp2_init(struct mlxsw_core *mlxsw_core,
32673277
mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp2_listener);
32683278
mlxsw_sp->fid_family_arr = mlxsw_sp2_fid_family_arr;
32693279
mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2;
3280+
mlxsw_sp->pgt_smpe_index_valid = false;
32703281

32713282
return mlxsw_sp_init(mlxsw_core, mlxsw_bus_info, extack);
32723283
}
@@ -3300,6 +3311,7 @@ static int mlxsw_sp3_init(struct mlxsw_core *mlxsw_core,
33003311
mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp2_listener);
33013312
mlxsw_sp->fid_family_arr = mlxsw_sp2_fid_family_arr;
33023313
mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3;
3314+
mlxsw_sp->pgt_smpe_index_valid = false;
33033315

33043316
return mlxsw_sp_init(mlxsw_core, mlxsw_bus_info, extack);
33053317
}
@@ -3333,6 +3345,7 @@ static int mlxsw_sp4_init(struct mlxsw_core *mlxsw_core,
33333345
mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp2_listener);
33343346
mlxsw_sp->fid_family_arr = mlxsw_sp2_fid_family_arr;
33353347
mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP4;
3348+
mlxsw_sp->pgt_smpe_index_valid = false;
33363349

33373350
return mlxsw_sp_init(mlxsw_core, mlxsw_bus_info, extack);
33383351
}
@@ -3365,6 +3378,7 @@ static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core)
33653378
mlxsw_sp_traps_fini(mlxsw_sp);
33663379
mlxsw_sp_policers_fini(mlxsw_sp);
33673380
mlxsw_sp_fids_fini(mlxsw_sp);
3381+
mlxsw_sp_pgt_fini(mlxsw_sp);
33683382
mlxsw_sp_kvdl_fini(mlxsw_sp);
33693383
mlxsw_sp_parsing_fini(mlxsw_sp);
33703384
}

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ struct mlxsw_sp_ptp_ops;
143143
struct mlxsw_sp_span_ops;
144144
struct mlxsw_sp_qdisc_state;
145145
struct mlxsw_sp_mall_entry;
146+
struct mlxsw_sp_pgt;
146147

147148
struct mlxsw_sp_port_mapping {
148149
u8 module;
@@ -216,6 +217,9 @@ struct mlxsw_sp {
216217
u32 lowest_shaper_bs;
217218
struct rhashtable ipv6_addr_ht;
218219
struct mutex ipv6_addr_ht_lock; /* Protects ipv6_addr_ht */
220+
bool ubridge;
221+
struct mlxsw_sp_pgt *pgt;
222+
bool pgt_smpe_index_valid;
219223
};
220224

221225
struct mlxsw_sp_ptp_ops {
@@ -391,6 +395,31 @@ struct mlxsw_sp_port_type_speed_ops {
391395
u32 (*ptys_proto_cap_masked_get)(u32 eth_proto_cap);
392396
};
393397

398+
struct mlxsw_sp_ports_bitmap {
399+
unsigned long *bitmap;
400+
unsigned int nbits;
401+
};
402+
403+
static inline int
404+
mlxsw_sp_port_bitmap_init(struct mlxsw_sp *mlxsw_sp,
405+
struct mlxsw_sp_ports_bitmap *ports_bm)
406+
{
407+
unsigned int nbits = mlxsw_core_max_ports(mlxsw_sp->core);
408+
409+
ports_bm->nbits = nbits;
410+
ports_bm->bitmap = bitmap_zalloc(nbits, GFP_KERNEL);
411+
if (!ports_bm->bitmap)
412+
return -ENOMEM;
413+
414+
return 0;
415+
}
416+
417+
static inline void
418+
mlxsw_sp_port_bitmap_fini(struct mlxsw_sp_ports_bitmap *ports_bm)
419+
{
420+
bitmap_free(ports_bm->bitmap);
421+
}
422+
394423
static inline u8 mlxsw_sp_tunnel_ecn_decap(u8 outer_ecn, u8 inner_ecn,
395424
bool *trap_en)
396425
{
@@ -1447,4 +1476,16 @@ int mlxsw_sp_policers_init(struct mlxsw_sp *mlxsw_sp);
14471476
void mlxsw_sp_policers_fini(struct mlxsw_sp *mlxsw_sp);
14481477
int mlxsw_sp_policer_resources_register(struct mlxsw_core *mlxsw_core);
14491478

1479+
/* spectrum_pgt.c */
1480+
int mlxsw_sp_pgt_mid_alloc(struct mlxsw_sp *mlxsw_sp, u16 *p_mid);
1481+
void mlxsw_sp_pgt_mid_free(struct mlxsw_sp *mlxsw_sp, u16 mid_base);
1482+
int mlxsw_sp_pgt_mid_alloc_range(struct mlxsw_sp *mlxsw_sp, u16 mid_base,
1483+
u16 count);
1484+
void mlxsw_sp_pgt_mid_free_range(struct mlxsw_sp *mlxsw_sp, u16 mid_base,
1485+
u16 count);
1486+
int mlxsw_sp_pgt_entry_port_set(struct mlxsw_sp *mlxsw_sp, u16 mid,
1487+
u16 smpe, u16 local_port, bool member);
1488+
int mlxsw_sp_pgt_init(struct mlxsw_sp *mlxsw_sp);
1489+
void mlxsw_sp_pgt_fini(struct mlxsw_sp *mlxsw_sp);
1490+
14501491
#endif

0 commit comments

Comments
 (0)