Skip to content

Commit 5e6146e

Browse files
pmachatakuba-moo
authored andcommitted
mlxsw: spectrum_fid: Add an object to keep flood profiles
A flood profile is a mapping from traffic type to an offset at which a flood vector should be looked up. In mlxsw so far, a flood profile was somewhat implicitly represented by flood table array. When the CFF flood mode will be introduced, the flood profile will become more explicit: each will get a number and the profile ID / traffic-type / offset mapping will actually need to be initialized in the hardware. Therefore it is going to be handy to have a structure that keeps all the components that compose a flood profile. Add this structure, currently with just the flood table array bits. In the FID families that flood at all, reference the flood profile instead of just the table array. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://lore.kernel.org/r/15e113de114d3f41ce3fd2a14a2fa6a1b1d7e8f2.1701183892.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 315702e commit 5e6146e

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

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

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,19 @@ struct mlxsw_sp_fid_ops {
113113
const struct mlxsw_sp_port *mlxsw_sp_port);
114114
};
115115

116+
struct mlxsw_sp_fid_flood_profile {
117+
const struct mlxsw_sp_flood_table *flood_tables;
118+
int nr_flood_tables;
119+
};
120+
116121
struct mlxsw_sp_fid_family {
117122
enum mlxsw_sp_fid_type type;
118123
size_t fid_size;
119124
u16 start_index;
120125
u16 end_index;
121126
struct list_head fids_list;
122127
unsigned long *fids_bitmap;
123-
const struct mlxsw_sp_flood_table *flood_tables;
124-
int nr_flood_tables;
128+
const struct mlxsw_sp_fid_flood_profile *flood_profile;
125129
enum mlxsw_sp_rif_type rif_type;
126130
const struct mlxsw_sp_fid_ops *ops;
127131
struct mlxsw_sp *mlxsw_sp;
@@ -331,10 +335,13 @@ mlxsw_sp_fid_flood_table_lookup(const struct mlxsw_sp_fid *fid,
331335
struct mlxsw_sp_fid_family *fid_family = fid->fid_family;
332336
int i;
333337

334-
for (i = 0; i < fid_family->nr_flood_tables; i++) {
335-
if (fid_family->flood_tables[i].packet_type != packet_type)
338+
for (i = 0; i < fid_family->flood_profile->nr_flood_tables; i++) {
339+
const struct mlxsw_sp_flood_table *flood_table;
340+
341+
flood_table = &fid_family->flood_profile->flood_tables[i];
342+
if (flood_table->packet_type != packet_type)
336343
continue;
337-
return &fid_family->flood_tables[i];
344+
return flood_table;
338345
}
339346

340347
return NULL;
@@ -352,7 +359,7 @@ mlxsw_sp_fid_8021d_pgt_size(const struct mlxsw_sp_fid_family *fid_family,
352359
{
353360
u16 num_fids = mlxsw_sp_fid_family_num_fids(fid_family);
354361

355-
*p_pgt_size = num_fids * fid_family->nr_flood_tables;
362+
*p_pgt_size = num_fids * fid_family->flood_profile->nr_flood_tables;
356363
return 0;
357364
}
358365

@@ -382,7 +389,7 @@ int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid,
382389
const struct mlxsw_sp_flood_table *flood_table;
383390
u16 mid_index;
384391

385-
if (WARN_ON(!fid_family->flood_tables))
392+
if (WARN_ON(!fid_family->flood_profile))
386393
return -EINVAL;
387394

388395
flood_table = mlxsw_sp_fid_flood_table_lookup(fid, packet_type);
@@ -1177,6 +1184,12 @@ static const struct mlxsw_sp_flood_table mlxsw_sp_fid_8021d_flood_tables[] = {
11771184
},
11781185
};
11791186

1187+
static const
1188+
struct mlxsw_sp_fid_flood_profile mlxsw_sp_fid_8021d_flood_profile = {
1189+
.flood_tables = mlxsw_sp_fid_8021d_flood_tables,
1190+
.nr_flood_tables = ARRAY_SIZE(mlxsw_sp_fid_8021d_flood_tables),
1191+
};
1192+
11801193
static bool
11811194
mlxsw_sp_fid_8021q_compare(const struct mlxsw_sp_fid *fid, const void *arg)
11821195
{
@@ -1526,8 +1539,7 @@ static const struct mlxsw_sp_fid_family mlxsw_sp1_fid_8021q_family = {
15261539
.fid_size = sizeof(struct mlxsw_sp_fid_8021q),
15271540
.start_index = MLXSW_SP_FID_8021Q_START,
15281541
.end_index = MLXSW_SP_FID_8021Q_END,
1529-
.flood_tables = mlxsw_sp_fid_8021d_flood_tables,
1530-
.nr_flood_tables = ARRAY_SIZE(mlxsw_sp_fid_8021d_flood_tables),
1542+
.flood_profile = &mlxsw_sp_fid_8021d_flood_profile,
15311543
.rif_type = MLXSW_SP_RIF_TYPE_VLAN,
15321544
.ops = &mlxsw_sp_fid_8021q_ops_ctl,
15331545
.flood_rsp = false,
@@ -1540,8 +1552,7 @@ static const struct mlxsw_sp_fid_family mlxsw_sp1_fid_8021d_family = {
15401552
.fid_size = sizeof(struct mlxsw_sp_fid_8021d),
15411553
.start_index = MLXSW_SP_FID_8021D_START,
15421554
.end_index = MLXSW_SP_FID_8021D_END,
1543-
.flood_tables = mlxsw_sp_fid_8021d_flood_tables,
1544-
.nr_flood_tables = ARRAY_SIZE(mlxsw_sp_fid_8021d_flood_tables),
1555+
.flood_profile = &mlxsw_sp_fid_8021d_flood_profile,
15451556
.rif_type = MLXSW_SP_RIF_TYPE_FID,
15461557
.ops = &mlxsw_sp_fid_8021d_ops_ctl,
15471558
.bridge_type = MLXSW_REG_BRIDGE_TYPE_1,
@@ -1580,8 +1591,7 @@ static const struct mlxsw_sp_fid_family mlxsw_sp2_fid_8021q_family_ctl = {
15801591
.fid_size = sizeof(struct mlxsw_sp_fid_8021q),
15811592
.start_index = MLXSW_SP_FID_8021Q_START,
15821593
.end_index = MLXSW_SP_FID_8021Q_END,
1583-
.flood_tables = mlxsw_sp_fid_8021d_flood_tables,
1584-
.nr_flood_tables = ARRAY_SIZE(mlxsw_sp_fid_8021d_flood_tables),
1594+
.flood_profile = &mlxsw_sp_fid_8021d_flood_profile,
15851595
.rif_type = MLXSW_SP_RIF_TYPE_VLAN,
15861596
.ops = &mlxsw_sp_fid_8021q_ops_ctl,
15871597
.flood_rsp = false,
@@ -1594,8 +1604,7 @@ static const struct mlxsw_sp_fid_family mlxsw_sp2_fid_8021d_family_ctl = {
15941604
.fid_size = sizeof(struct mlxsw_sp_fid_8021d),
15951605
.start_index = MLXSW_SP_FID_8021D_START,
15961606
.end_index = MLXSW_SP_FID_8021D_END,
1597-
.flood_tables = mlxsw_sp_fid_8021d_flood_tables,
1598-
.nr_flood_tables = ARRAY_SIZE(mlxsw_sp_fid_8021d_flood_tables),
1607+
.flood_profile = &mlxsw_sp_fid_8021d_flood_profile,
15991608
.rif_type = MLXSW_SP_RIF_TYPE_FID,
16001609
.ops = &mlxsw_sp_fid_8021d_ops_ctl,
16011610
.bridge_type = MLXSW_REG_BRIDGE_TYPE_1,
@@ -1761,10 +1770,13 @@ mlxsw_sp_fid_flood_tables_init(struct mlxsw_sp_fid_family *fid_family)
17611770
if (err)
17621771
return err;
17631772

1764-
for (i = 0; i < fid_family->nr_flood_tables; i++) {
1773+
if (!fid_family->flood_profile)
1774+
return 0;
1775+
1776+
for (i = 0; i < fid_family->flood_profile->nr_flood_tables; i++) {
17651777
const struct mlxsw_sp_flood_table *flood_table;
17661778

1767-
flood_table = &fid_family->flood_tables[i];
1779+
flood_table = &fid_family->flood_profile->flood_tables[i];
17681780
if (fid_family->ops->flood_table_init) {
17691781
err = fid_family->ops->flood_table_init(fid_family,
17701782
flood_table);
@@ -1813,7 +1825,7 @@ static int mlxsw_sp_fid_family_register(struct mlxsw_sp *mlxsw_sp,
18131825
goto err_alloc_fids_bitmap;
18141826
}
18151827

1816-
if (fid_family->flood_tables) {
1828+
if (fid_family->flood_profile) {
18171829
err = mlxsw_sp_fid_flood_tables_init(fid_family);
18181830
if (err)
18191831
goto err_fid_flood_tables_init;
@@ -1836,7 +1848,7 @@ mlxsw_sp_fid_family_unregister(struct mlxsw_sp *mlxsw_sp,
18361848
{
18371849
mlxsw_sp->fid_core->fid_family_arr[fid_family->type] = NULL;
18381850

1839-
if (fid_family->flood_tables)
1851+
if (fid_family->flood_profile)
18401852
mlxsw_sp_fid_flood_tables_fini(fid_family);
18411853

18421854
bitmap_free(fid_family->fids_bitmap);

0 commit comments

Comments
 (0)