@@ -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+
116121struct 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+
11801193static bool
11811194mlxsw_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