Skip to content

Commit 5085380

Browse files
committed
Merge branch 'mlxsw-Prepare-for-VLAN-aware-bridge-w-VxLAN'
Ido Schimmel says: ==================== mlxsw: Prepare for VLAN-aware bridge w/VxLAN The driver is using 802.1Q filtering identifiers (FIDs) to represent the different VLANs in the VLAN-aware bridge (only one is supported). However, the device cannot assign a VNI to such FIDs, which prevents the driver from supporting the enslavement of VxLAN devices to the VLAN-aware bridge. This patchset works around this limitation by emulating 802.1Q FIDs using 802.1D FIDs, which can be assigned a VNI and so far have only been used in conjunction with VLAN-unaware bridges. The downside of this approach is that multiple {Port,VID}->FID entries are required, whereas a single VID->FID entry is required with "true" 802.1Q FIDs. First four patches introduce the new FID family of emulated 802.1Q FIDs and the associated type of router interfaces (RIFs). Last patch flips the driver to use this new FID family. The diff is relatively small because the internal implementation of each FID family is contained and hidden in spectrum_fid.c. Different internal users (e.g., bridge, router) are aware of the different FID types, but do not care about their internal implementation. This makes it trivial to swap the current implementation of 802.1Q FIDs with the new one, using 802.1D FIDs. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 4e3c7c0 + c2e7490 commit 5085380

File tree

5 files changed

+63
-10
lines changed

5 files changed

+63
-10
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4111,16 +4111,20 @@ static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core)
41114111
mlxsw_sp_kvdl_fini(mlxsw_sp);
41124112
}
41134113

4114+
/* Per-FID flood tables are used for both "true" 802.1D FIDs and emulated
4115+
* 802.1Q FIDs
4116+
*/
4117+
#define MLXSW_SP_FID_FLOOD_TABLE_SIZE (MLXSW_SP_FID_8021D_MAX + \
4118+
VLAN_VID_MASK - 1)
4119+
41144120
static const struct mlxsw_config_profile mlxsw_sp1_config_profile = {
41154121
.used_max_mid = 1,
41164122
.max_mid = MLXSW_SP_MID_MAX,
41174123
.used_flood_tables = 1,
41184124
.used_flood_mode = 1,
41194125
.flood_mode = 3,
4120-
.max_fid_offset_flood_tables = 3,
4121-
.fid_offset_flood_table_size = VLAN_N_VID - 1,
41224126
.max_fid_flood_tables = 3,
4123-
.fid_flood_table_size = MLXSW_SP_FID_8021D_MAX,
4127+
.fid_flood_table_size = MLXSW_SP_FID_FLOOD_TABLE_SIZE,
41244128
.used_max_ib_mc = 1,
41254129
.max_ib_mc = 0,
41264130
.used_max_pkey = 1,
@@ -4143,10 +4147,8 @@ static const struct mlxsw_config_profile mlxsw_sp2_config_profile = {
41434147
.used_flood_tables = 1,
41444148
.used_flood_mode = 1,
41454149
.flood_mode = 3,
4146-
.max_fid_offset_flood_tables = 3,
4147-
.fid_offset_flood_table_size = VLAN_N_VID - 1,
41484150
.max_fid_flood_tables = 3,
4149-
.fid_flood_table_size = MLXSW_SP_FID_8021D_MAX,
4151+
.fid_flood_table_size = MLXSW_SP_FID_FLOOD_TABLE_SIZE,
41504152
.used_max_ib_mc = 1,
41514153
.max_ib_mc = 0,
41524154
.used_max_pkey = 1,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ int mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port,
721721
struct tc_prio_qopt_offload *p);
722722

723723
/* spectrum_fid.c */
724+
bool mlxsw_sp_fid_lag_vid_valid(const struct mlxsw_sp_fid *fid);
724725
struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index(struct mlxsw_sp *mlxsw_sp,
725726
u16 fid_index);
726727
int mlxsw_sp_fid_nve_ifindex(const struct mlxsw_sp_fid *fid, int *nve_ifindex);

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

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct mlxsw_sp_fid_family {
9898
enum mlxsw_sp_rif_type rif_type;
9999
const struct mlxsw_sp_fid_ops *ops;
100100
struct mlxsw_sp *mlxsw_sp;
101+
u8 lag_vid_valid:1;
101102
};
102103

103104
static const int mlxsw_sp_sfgc_uc_packet_types[MLXSW_REG_SFGC_TYPE_MAX] = {
@@ -122,6 +123,11 @@ static const int *mlxsw_sp_packet_type_sfgc_types[] = {
122123
[MLXSW_SP_FLOOD_TYPE_MC] = mlxsw_sp_sfgc_mc_packet_types,
123124
};
124125

126+
bool mlxsw_sp_fid_lag_vid_valid(const struct mlxsw_sp_fid *fid)
127+
{
128+
return fid->fid_family->lag_vid_valid;
129+
}
130+
125131
struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index(struct mlxsw_sp *mlxsw_sp,
126132
u16 fid_index)
127133
{
@@ -601,7 +607,7 @@ mlxsw_sp_fid_8021d_compare(const struct mlxsw_sp_fid *fid, const void *arg)
601607

602608
static u16 mlxsw_sp_fid_8021d_flood_index(const struct mlxsw_sp_fid *fid)
603609
{
604-
return fid->fid_index - fid->fid_family->start_index;
610+
return fid->fid_index - VLAN_N_VID;
605611
}
606612

607613
static int mlxsw_sp_port_vp_mode_trans(struct mlxsw_sp_port *mlxsw_sp_port)
@@ -792,6 +798,40 @@ static const struct mlxsw_sp_fid_family mlxsw_sp_fid_8021d_family = {
792798
.nr_flood_tables = ARRAY_SIZE(mlxsw_sp_fid_8021d_flood_tables),
793799
.rif_type = MLXSW_SP_RIF_TYPE_FID,
794800
.ops = &mlxsw_sp_fid_8021d_ops,
801+
.lag_vid_valid = 1,
802+
};
803+
804+
static const struct mlxsw_sp_fid_ops mlxsw_sp_fid_8021q_emu_ops = {
805+
.setup = mlxsw_sp_fid_8021q_setup,
806+
.configure = mlxsw_sp_fid_8021d_configure,
807+
.deconfigure = mlxsw_sp_fid_8021d_deconfigure,
808+
.index_alloc = mlxsw_sp_fid_8021d_index_alloc,
809+
.compare = mlxsw_sp_fid_8021q_compare,
810+
.flood_index = mlxsw_sp_fid_8021d_flood_index,
811+
.port_vid_map = mlxsw_sp_fid_8021d_port_vid_map,
812+
.port_vid_unmap = mlxsw_sp_fid_8021d_port_vid_unmap,
813+
.vni_set = mlxsw_sp_fid_8021d_vni_set,
814+
.vni_clear = mlxsw_sp_fid_8021d_vni_clear,
815+
.nve_flood_index_set = mlxsw_sp_fid_8021d_nve_flood_index_set,
816+
.nve_flood_index_clear = mlxsw_sp_fid_8021d_nve_flood_index_clear,
817+
};
818+
819+
/* There are 4K-2 emulated 802.1Q FIDs, starting right after the 802.1D FIDs */
820+
#define MLXSW_SP_FID_8021Q_EMU_START (VLAN_N_VID + MLXSW_SP_FID_8021D_MAX)
821+
#define MLXSW_SP_FID_8021Q_EMU_END (MLXSW_SP_FID_8021Q_EMU_START + \
822+
VLAN_VID_MASK - 2)
823+
824+
/* Range and flood configuration must match mlxsw_config_profile */
825+
static const struct mlxsw_sp_fid_family mlxsw_sp_fid_8021q_emu_family = {
826+
.type = MLXSW_SP_FID_TYPE_8021Q,
827+
.fid_size = sizeof(struct mlxsw_sp_fid_8021q),
828+
.start_index = MLXSW_SP_FID_8021Q_EMU_START,
829+
.end_index = MLXSW_SP_FID_8021Q_EMU_END,
830+
.flood_tables = mlxsw_sp_fid_8021d_flood_tables,
831+
.nr_flood_tables = ARRAY_SIZE(mlxsw_sp_fid_8021d_flood_tables),
832+
.rif_type = MLXSW_SP_RIF_TYPE_VLAN,
833+
.ops = &mlxsw_sp_fid_8021q_emu_ops,
834+
.lag_vid_valid = 1,
795835
};
796836

797837
static int mlxsw_sp_fid_rfid_configure(struct mlxsw_sp_fid *fid)
@@ -921,7 +961,7 @@ static const struct mlxsw_sp_fid_family mlxsw_sp_fid_dummy_family = {
921961
};
922962

923963
static const struct mlxsw_sp_fid_family *mlxsw_sp_fid_family_arr[] = {
924-
[MLXSW_SP_FID_TYPE_8021Q] = &mlxsw_sp_fid_8021q_family,
964+
[MLXSW_SP_FID_TYPE_8021Q] = &mlxsw_sp_fid_8021q_emu_family,
925965
[MLXSW_SP_FID_TYPE_8021D] = &mlxsw_sp_fid_8021d_family,
926966
[MLXSW_SP_FID_TYPE_RFID] = &mlxsw_sp_fid_rfid_family,
927967
[MLXSW_SP_FID_TYPE_DUMMY] = &mlxsw_sp_fid_dummy_family,

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7296,6 +7296,15 @@ static const struct mlxsw_sp_rif_ops mlxsw_sp_rif_fid_ops = {
72967296
.fdb_del = mlxsw_sp_rif_fid_fdb_del,
72977297
};
72987298

7299+
static const struct mlxsw_sp_rif_ops mlxsw_sp_rif_vlan_emu_ops = {
7300+
.type = MLXSW_SP_RIF_TYPE_VLAN,
7301+
.rif_size = sizeof(struct mlxsw_sp_rif),
7302+
.configure = mlxsw_sp_rif_fid_configure,
7303+
.deconfigure = mlxsw_sp_rif_fid_deconfigure,
7304+
.fid_get = mlxsw_sp_rif_vlan_fid_get,
7305+
.fdb_del = mlxsw_sp_rif_vlan_fdb_del,
7306+
};
7307+
72997308
static struct mlxsw_sp_rif_ipip_lb *
73007309
mlxsw_sp_rif_ipip_lb_rif(struct mlxsw_sp_rif *rif)
73017310
{
@@ -7364,7 +7373,7 @@ static const struct mlxsw_sp_rif_ops mlxsw_sp_rif_ipip_lb_ops = {
73647373

73657374
static const struct mlxsw_sp_rif_ops *mlxsw_sp_rif_ops_arr[] = {
73667375
[MLXSW_SP_RIF_TYPE_SUBPORT] = &mlxsw_sp_rif_subport_ops,
7367-
[MLXSW_SP_RIF_TYPE_VLAN] = &mlxsw_sp_rif_vlan_ops,
7376+
[MLXSW_SP_RIF_TYPE_VLAN] = &mlxsw_sp_rif_vlan_emu_ops,
73687377
[MLXSW_SP_RIF_TYPE_FID] = &mlxsw_sp_rif_fid_ops,
73697378
[MLXSW_SP_RIF_TYPE_IPIP_LB] = &mlxsw_sp_rif_ipip_lb_ops,
73707379
};

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2482,7 +2482,8 @@ static void mlxsw_sp_fdb_notify_mac_lag_process(struct mlxsw_sp *mlxsw_sp,
24822482

24832483
bridge_device = bridge_port->bridge_device;
24842484
vid = bridge_device->vlan_enabled ? mlxsw_sp_port_vlan->vid : 0;
2485-
lag_vid = mlxsw_sp_port_vlan->vid;
2485+
lag_vid = mlxsw_sp_fid_lag_vid_valid(mlxsw_sp_port_vlan->fid) ?
2486+
mlxsw_sp_port_vlan->vid : 0;
24862487

24872488
do_fdb_op:
24882489
err = mlxsw_sp_port_fdb_uc_lag_op(mlxsw_sp, lag_id, mac, fid, lag_vid,

0 commit comments

Comments
 (0)