Skip to content

Commit ffd3018

Browse files
committed
Merge branch 'mlxsw-unified-bridge-conversion-part-2'
Ido Schimmel says: ==================== mlxsw: Unified bridge conversion - part 2/6 This is the second part of the conversion of mlxsw to the unified bridge model. Part 1 was merged in commit 4336487 ("Merge branch 'mlxsw-unified-bridge-conversion-part-1'") which includes details about the new model and the motivation behind the conversion. This patchset does not begin the conversion, but rather prepares the code base for it. Patchset overview: Patch #1 removes an unnecessary field from one of the FID families. Patches #2-#7 make various improvements in the layer 2 multicast code, making it more receptive towards upcoming changes. Patches #8-#10 prepare the CONFIG_PROFILE command for the unified bridge model. This command will be used to enable the new model in the last patchset. Patches #11-#13 perform small changes in the FID code, preparing it for upcoming changes. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents a80d8fb + 048fcbb commit ffd3018

File tree

6 files changed

+240
-74
lines changed

6 files changed

+240
-74
lines changed

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -713,16 +713,25 @@ MLXSW_ITEM32(cmd_mbox, config_profile, max_flood_tables, 0x30, 16, 4);
713713
*/
714714
MLXSW_ITEM32(cmd_mbox, config_profile, max_vid_flood_tables, 0x30, 8, 4);
715715

716+
enum mlxsw_cmd_mbox_config_profile_flood_mode {
717+
/* Mixed mode, where:
718+
* max_flood_tables indicates the number of single-entry tables.
719+
* max_vid_flood_tables indicates the number of per-VID tables.
720+
* max_fid_offset_flood_tables indicates the number of FID-offset
721+
* tables. max_fid_flood_tables indicates the number of per-FID tables.
722+
* Reserved when unified bridge model is used.
723+
*/
724+
MLXSW_CMD_MBOX_CONFIG_PROFILE_FLOOD_MODE_MIXED = 3,
725+
/* Controlled flood tables. Reserved when legacy bridge model is
726+
* used.
727+
*/
728+
MLXSW_CMD_MBOX_CONFIG_PROFILE_FLOOD_MODE_CONTROLLED = 4,
729+
};
730+
716731
/* cmd_mbox_config_profile_flood_mode
717732
* Flooding mode to use.
718-
* 0-2 - Backward compatible modes for SwitchX devices.
719-
* 3 - Mixed mode, where:
720-
* max_flood_tables indicates the number of single-entry tables.
721-
* max_vid_flood_tables indicates the number of per-VID tables.
722-
* max_fid_offset_flood_tables indicates the number of FID-offset tables.
723-
* max_fid_flood_tables indicates the number of per-FID tables.
724-
*/
725-
MLXSW_ITEM32(cmd_mbox, config_profile, flood_mode, 0x30, 0, 2);
733+
*/
734+
MLXSW_ITEM32(cmd_mbox, config_profile, flood_mode, 0x30, 0, 3);
726735

727736
/* cmd_mbox_config_profile_max_fid_offset_flood_tables
728737
* Maximum number of FID-offset flooding tables.

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,14 @@ static int mlxsw_pci_init(void *bus_priv, struct mlxsw_core *mlxsw_core,
15511551
if (err)
15521552
goto err_config_profile;
15531553

1554+
/* Some resources depend on unified bridge model, which is configured
1555+
* as part of config_profile. Query the resources again to get correct
1556+
* values.
1557+
*/
1558+
err = mlxsw_core_resources_query(mlxsw_core, mbox, res);
1559+
if (err)
1560+
goto err_requery_resources;
1561+
15541562
err = mlxsw_pci_aqs_init(mlxsw_pci, mbox);
15551563
if (err)
15561564
goto err_aqs_init;
@@ -1568,6 +1576,7 @@ static int mlxsw_pci_init(void *bus_priv, struct mlxsw_core *mlxsw_core,
15681576
err_request_eq_irq:
15691577
mlxsw_pci_aqs_fini(mlxsw_pci);
15701578
err_aqs_init:
1579+
err_requery_resources:
15711580
err_config_profile:
15721581
err_cqe_v_check:
15731582
err_query_resources:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,7 +3376,7 @@ static const struct mlxsw_config_profile mlxsw_sp1_config_profile = {
33763376
.max_mid = MLXSW_SP_MID_MAX,
33773377
.used_flood_tables = 1,
33783378
.used_flood_mode = 1,
3379-
.flood_mode = 3,
3379+
.flood_mode = MLXSW_CMD_MBOX_CONFIG_PROFILE_FLOOD_MODE_MIXED,
33803380
.max_fid_flood_tables = 3,
33813381
.fid_flood_table_size = MLXSW_SP_FID_FLOOD_TABLE_SIZE,
33823382
.used_max_ib_mc = 1,
@@ -3400,7 +3400,7 @@ static const struct mlxsw_config_profile mlxsw_sp2_config_profile = {
34003400
.max_mid = MLXSW_SP_MID_MAX,
34013401
.used_flood_tables = 1,
34023402
.used_flood_mode = 1,
3403-
.flood_mode = 3,
3403+
.flood_mode = MLXSW_CMD_MBOX_CONFIG_PROFILE_FLOOD_MODE_MIXED,
34043404
.max_fid_flood_tables = 3,
34053405
.fid_flood_table_size = MLXSW_SP_FID_FLOOD_TABLE_SIZE,
34063406
.used_max_ib_mc = 1,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,6 @@ int mlxsw_sp_setup_tc_block_qevent_mark(struct mlxsw_sp_port *mlxsw_sp_port,
12371237

12381238
/* spectrum_fid.c */
12391239
bool mlxsw_sp_fid_is_dummy(struct mlxsw_sp *mlxsw_sp, u16 fid_index);
1240-
bool mlxsw_sp_fid_lag_vid_valid(const struct mlxsw_sp_fid *fid);
12411240
struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index(struct mlxsw_sp *mlxsw_sp,
12421241
u16 fid_index);
12431242
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: 91 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct mlxsw_sp_fid {
2727
struct mlxsw_sp_rif *rif;
2828
refcount_t ref_count;
2929
u16 fid_index;
30+
u16 fid_offset;
3031
struct mlxsw_sp_fid_family *fid_family;
3132
struct rhash_head ht_node;
3233

@@ -102,7 +103,6 @@ struct mlxsw_sp_fid_family {
102103
enum mlxsw_sp_rif_type rif_type;
103104
const struct mlxsw_sp_fid_ops *ops;
104105
struct mlxsw_sp *mlxsw_sp;
105-
u8 lag_vid_valid:1;
106106
};
107107

108108
static const int mlxsw_sp_sfgc_uc_packet_types[MLXSW_REG_SFGC_TYPE_MAX] = {
@@ -137,11 +137,6 @@ bool mlxsw_sp_fid_is_dummy(struct mlxsw_sp *mlxsw_sp, u16 fid_index)
137137
return fid_family->start_index == fid_index;
138138
}
139139

140-
bool mlxsw_sp_fid_lag_vid_valid(const struct mlxsw_sp_fid *fid)
141-
{
142-
return fid->fid_family->lag_vid_valid;
143-
}
144-
145140
struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index(struct mlxsw_sp *mlxsw_sp,
146141
u16 fid_index)
147142
{
@@ -206,7 +201,7 @@ int mlxsw_sp_fid_nve_flood_index_set(struct mlxsw_sp_fid *fid,
206201
const struct mlxsw_sp_fid_ops *ops = fid_family->ops;
207202
int err;
208203

209-
if (WARN_ON(!ops->nve_flood_index_set || fid->nve_flood_index_valid))
204+
if (WARN_ON(fid->nve_flood_index_valid))
210205
return -EINVAL;
211206

212207
err = ops->nve_flood_index_set(fid, nve_flood_index);
@@ -224,7 +219,7 @@ void mlxsw_sp_fid_nve_flood_index_clear(struct mlxsw_sp_fid *fid)
224219
struct mlxsw_sp_fid_family *fid_family = fid->fid_family;
225220
const struct mlxsw_sp_fid_ops *ops = fid_family->ops;
226221

227-
if (WARN_ON(!ops->nve_flood_index_clear || !fid->nve_flood_index_valid))
222+
if (WARN_ON(!fid->nve_flood_index_valid))
228223
return;
229224

230225
fid->nve_flood_index_valid = false;
@@ -244,7 +239,7 @@ int mlxsw_sp_fid_vni_set(struct mlxsw_sp_fid *fid, enum mlxsw_sp_nve_type type,
244239
struct mlxsw_sp *mlxsw_sp = fid_family->mlxsw_sp;
245240
int err;
246241

247-
if (WARN_ON(!ops->vni_set || fid->vni_valid))
242+
if (WARN_ON(fid->vni_valid))
248243
return -EINVAL;
249244

250245
fid->nve_type = type;
@@ -276,7 +271,7 @@ void mlxsw_sp_fid_vni_clear(struct mlxsw_sp_fid *fid)
276271
const struct mlxsw_sp_fid_ops *ops = fid_family->ops;
277272
struct mlxsw_sp *mlxsw_sp = fid_family->mlxsw_sp;
278273

279-
if (WARN_ON(!ops->vni_clear || !fid->vni_valid))
274+
if (WARN_ON(!fid->vni_valid))
280275
return;
281276

282277
fid->vni_valid = false;
@@ -405,6 +400,7 @@ static void mlxsw_sp_fid_8021q_setup(struct mlxsw_sp_fid *fid, const void *arg)
405400
u16 vid = *(u16 *) arg;
406401

407402
mlxsw_sp_fid_8021q_fid(fid)->vid = vid;
403+
fid->fid_offset = 0;
408404
}
409405

410406
static enum mlxsw_reg_sfmr_op mlxsw_sp_sfmr_op(bool valid)
@@ -424,13 +420,13 @@ static int mlxsw_sp_fid_op(struct mlxsw_sp *mlxsw_sp, u16 fid_index,
424420
}
425421

426422
static int mlxsw_sp_fid_vni_op(struct mlxsw_sp *mlxsw_sp, u16 fid_index,
427-
__be32 vni, bool vni_valid, u32 nve_flood_index,
428-
bool nve_flood_index_valid)
423+
u16 fid_offset, __be32 vni, bool vni_valid,
424+
u32 nve_flood_index, bool nve_flood_index_valid)
429425
{
430426
char sfmr_pl[MLXSW_REG_SFMR_LEN];
431427

432428
mlxsw_reg_sfmr_pack(sfmr_pl, MLXSW_REG_SFMR_OP_CREATE_FID, fid_index,
433-
0);
429+
fid_offset);
434430
mlxsw_reg_sfmr_vv_set(sfmr_pl, vni_valid);
435431
mlxsw_reg_sfmr_vni_set(sfmr_pl, be32_to_cpu(vni));
436432
mlxsw_reg_sfmr_vtfp_set(sfmr_pl, nve_flood_index_valid);
@@ -459,20 +455,23 @@ static void mlxsw_sp_fid_8021d_setup(struct mlxsw_sp_fid *fid, const void *arg)
459455
int br_ifindex = *(int *) arg;
460456

461457
mlxsw_sp_fid_8021d_fid(fid)->br_ifindex = br_ifindex;
458+
fid->fid_offset = 0;
462459
}
463460

464461
static int mlxsw_sp_fid_8021d_configure(struct mlxsw_sp_fid *fid)
465462
{
466463
struct mlxsw_sp_fid_family *fid_family = fid->fid_family;
467464

468-
return mlxsw_sp_fid_op(fid_family->mlxsw_sp, fid->fid_index, 0, true);
465+
return mlxsw_sp_fid_op(fid_family->mlxsw_sp, fid->fid_index,
466+
fid->fid_offset, true);
469467
}
470468

471469
static void mlxsw_sp_fid_8021d_deconfigure(struct mlxsw_sp_fid *fid)
472470
{
473471
if (fid->vni_valid)
474472
mlxsw_sp_nve_fid_disable(fid->fid_family->mlxsw_sp, fid);
475-
mlxsw_sp_fid_op(fid->fid_family->mlxsw_sp, fid->fid_index, 0, false);
473+
mlxsw_sp_fid_op(fid->fid_family->mlxsw_sp, fid->fid_index,
474+
fid->fid_offset, false);
476475
}
477476

478477
static int mlxsw_sp_fid_8021d_index_alloc(struct mlxsw_sp_fid *fid,
@@ -614,17 +613,19 @@ static int mlxsw_sp_fid_8021d_vni_set(struct mlxsw_sp_fid *fid, __be32 vni)
614613
{
615614
struct mlxsw_sp_fid_family *fid_family = fid->fid_family;
616615

617-
return mlxsw_sp_fid_vni_op(fid_family->mlxsw_sp, fid->fid_index, vni,
618-
true, fid->nve_flood_index,
616+
return mlxsw_sp_fid_vni_op(fid_family->mlxsw_sp, fid->fid_index,
617+
fid->fid_offset, vni, true,
618+
fid->nve_flood_index,
619619
fid->nve_flood_index_valid);
620620
}
621621

622622
static void mlxsw_sp_fid_8021d_vni_clear(struct mlxsw_sp_fid *fid)
623623
{
624624
struct mlxsw_sp_fid_family *fid_family = fid->fid_family;
625625

626-
mlxsw_sp_fid_vni_op(fid_family->mlxsw_sp, fid->fid_index, 0, false,
627-
fid->nve_flood_index, fid->nve_flood_index_valid);
626+
mlxsw_sp_fid_vni_op(fid_family->mlxsw_sp, fid->fid_index,
627+
fid->fid_offset, 0, false, fid->nve_flood_index,
628+
fid->nve_flood_index_valid);
628629
}
629630

630631
static int mlxsw_sp_fid_8021d_nve_flood_index_set(struct mlxsw_sp_fid *fid,
@@ -633,16 +634,17 @@ static int mlxsw_sp_fid_8021d_nve_flood_index_set(struct mlxsw_sp_fid *fid,
633634
struct mlxsw_sp_fid_family *fid_family = fid->fid_family;
634635

635636
return mlxsw_sp_fid_vni_op(fid_family->mlxsw_sp, fid->fid_index,
636-
fid->vni, fid->vni_valid, nve_flood_index,
637-
true);
637+
fid->fid_offset, fid->vni, fid->vni_valid,
638+
nve_flood_index, true);
638639
}
639640

640641
static void mlxsw_sp_fid_8021d_nve_flood_index_clear(struct mlxsw_sp_fid *fid)
641642
{
642643
struct mlxsw_sp_fid_family *fid_family = fid->fid_family;
643644

644-
mlxsw_sp_fid_vni_op(fid_family->mlxsw_sp, fid->fid_index, fid->vni,
645-
fid->vni_valid, 0, false);
645+
mlxsw_sp_fid_vni_op(fid_family->mlxsw_sp, fid->fid_index,
646+
fid->fid_offset, fid->vni, fid->vni_valid, 0,
647+
false);
646648
}
647649

648650
static void
@@ -699,7 +701,6 @@ static const struct mlxsw_sp_fid_family mlxsw_sp_fid_8021d_family = {
699701
.nr_flood_tables = ARRAY_SIZE(mlxsw_sp_fid_8021d_flood_tables),
700702
.rif_type = MLXSW_SP_RIF_TYPE_FID,
701703
.ops = &mlxsw_sp_fid_8021d_ops,
702-
.lag_vid_valid = 1,
703704
};
704705

705706
static bool
@@ -748,9 +749,13 @@ static const struct mlxsw_sp_fid_family mlxsw_sp_fid_8021q_emu_family = {
748749
.nr_flood_tables = ARRAY_SIZE(mlxsw_sp_fid_8021d_flood_tables),
749750
.rif_type = MLXSW_SP_RIF_TYPE_VLAN,
750751
.ops = &mlxsw_sp_fid_8021q_emu_ops,
751-
.lag_vid_valid = 1,
752752
};
753753

754+
static void mlxsw_sp_fid_rfid_setup(struct mlxsw_sp_fid *fid, const void *arg)
755+
{
756+
fid->fid_offset = 0;
757+
}
758+
754759
static int mlxsw_sp_fid_rfid_configure(struct mlxsw_sp_fid *fid)
755760
{
756761
/* rFIDs are allocated by the device during init */
@@ -815,13 +820,39 @@ mlxsw_sp_fid_rfid_port_vid_unmap(struct mlxsw_sp_fid *fid,
815820
mlxsw_sp->fid_core->port_fid_mappings[local_port]--;
816821
}
817822

823+
static int mlxsw_sp_fid_rfid_vni_set(struct mlxsw_sp_fid *fid, __be32 vni)
824+
{
825+
return -EOPNOTSUPP;
826+
}
827+
828+
static void mlxsw_sp_fid_rfid_vni_clear(struct mlxsw_sp_fid *fid)
829+
{
830+
WARN_ON_ONCE(1);
831+
}
832+
833+
static int mlxsw_sp_fid_rfid_nve_flood_index_set(struct mlxsw_sp_fid *fid,
834+
u32 nve_flood_index)
835+
{
836+
return -EOPNOTSUPP;
837+
}
838+
839+
static void mlxsw_sp_fid_rfid_nve_flood_index_clear(struct mlxsw_sp_fid *fid)
840+
{
841+
WARN_ON_ONCE(1);
842+
}
843+
818844
static const struct mlxsw_sp_fid_ops mlxsw_sp_fid_rfid_ops = {
845+
.setup = mlxsw_sp_fid_rfid_setup,
819846
.configure = mlxsw_sp_fid_rfid_configure,
820847
.deconfigure = mlxsw_sp_fid_rfid_deconfigure,
821848
.index_alloc = mlxsw_sp_fid_rfid_index_alloc,
822849
.compare = mlxsw_sp_fid_rfid_compare,
823850
.port_vid_map = mlxsw_sp_fid_rfid_port_vid_map,
824851
.port_vid_unmap = mlxsw_sp_fid_rfid_port_vid_unmap,
852+
.vni_set = mlxsw_sp_fid_rfid_vni_set,
853+
.vni_clear = mlxsw_sp_fid_rfid_vni_clear,
854+
.nve_flood_index_set = mlxsw_sp_fid_rfid_nve_flood_index_set,
855+
.nve_flood_index_clear = mlxsw_sp_fid_rfid_nve_flood_index_clear,
825856
};
826857

827858
#define MLXSW_SP_RFID_BASE (15 * 1024)
@@ -836,16 +867,22 @@ static const struct mlxsw_sp_fid_family mlxsw_sp_fid_rfid_family = {
836867
.ops = &mlxsw_sp_fid_rfid_ops,
837868
};
838869

870+
static void mlxsw_sp_fid_dummy_setup(struct mlxsw_sp_fid *fid, const void *arg)
871+
{
872+
fid->fid_offset = 0;
873+
}
874+
839875
static int mlxsw_sp_fid_dummy_configure(struct mlxsw_sp_fid *fid)
840876
{
841877
struct mlxsw_sp *mlxsw_sp = fid->fid_family->mlxsw_sp;
842878

843-
return mlxsw_sp_fid_op(mlxsw_sp, fid->fid_index, 0, true);
879+
return mlxsw_sp_fid_op(mlxsw_sp, fid->fid_index, fid->fid_offset, true);
844880
}
845881

846882
static void mlxsw_sp_fid_dummy_deconfigure(struct mlxsw_sp_fid *fid)
847883
{
848-
mlxsw_sp_fid_op(fid->fid_family->mlxsw_sp, fid->fid_index, 0, false);
884+
mlxsw_sp_fid_op(fid->fid_family->mlxsw_sp, fid->fid_index,
885+
fid->fid_offset, false);
849886
}
850887

851888
static int mlxsw_sp_fid_dummy_index_alloc(struct mlxsw_sp_fid *fid,
@@ -862,11 +899,37 @@ static bool mlxsw_sp_fid_dummy_compare(const struct mlxsw_sp_fid *fid,
862899
return true;
863900
}
864901

902+
static int mlxsw_sp_fid_dummy_vni_set(struct mlxsw_sp_fid *fid, __be32 vni)
903+
{
904+
return -EOPNOTSUPP;
905+
}
906+
907+
static void mlxsw_sp_fid_dummy_vni_clear(struct mlxsw_sp_fid *fid)
908+
{
909+
WARN_ON_ONCE(1);
910+
}
911+
912+
static int mlxsw_sp_fid_dummy_nve_flood_index_set(struct mlxsw_sp_fid *fid,
913+
u32 nve_flood_index)
914+
{
915+
return -EOPNOTSUPP;
916+
}
917+
918+
static void mlxsw_sp_fid_dummy_nve_flood_index_clear(struct mlxsw_sp_fid *fid)
919+
{
920+
WARN_ON_ONCE(1);
921+
}
922+
865923
static const struct mlxsw_sp_fid_ops mlxsw_sp_fid_dummy_ops = {
924+
.setup = mlxsw_sp_fid_dummy_setup,
866925
.configure = mlxsw_sp_fid_dummy_configure,
867926
.deconfigure = mlxsw_sp_fid_dummy_deconfigure,
868927
.index_alloc = mlxsw_sp_fid_dummy_index_alloc,
869928
.compare = mlxsw_sp_fid_dummy_compare,
929+
.vni_set = mlxsw_sp_fid_dummy_vni_set,
930+
.vni_clear = mlxsw_sp_fid_dummy_vni_clear,
931+
.nve_flood_index_set = mlxsw_sp_fid_dummy_nve_flood_index_set,
932+
.nve_flood_index_clear = mlxsw_sp_fid_dummy_nve_flood_index_clear,
870933
};
871934

872935
static const struct mlxsw_sp_fid_family mlxsw_sp_fid_dummy_family = {
@@ -927,8 +990,7 @@ static struct mlxsw_sp_fid *mlxsw_sp_fid_get(struct mlxsw_sp *mlxsw_sp,
927990
fid->fid_index = fid_index;
928991
__set_bit(fid_index - fid_family->start_index, fid_family->fids_bitmap);
929992

930-
if (fid->fid_family->ops->setup)
931-
fid->fid_family->ops->setup(fid, arg);
993+
fid->fid_family->ops->setup(fid, arg);
932994

933995
err = fid->fid_family->ops->configure(fid);
934996
if (err)

0 commit comments

Comments
 (0)