Skip to content

Commit 1686b8d

Browse files
pmachatakuba-moo
authored andcommitted
mlxsw: spectrum_fid: Add an op to get PGT allocation size
In the CFF flood mode, the PGT allocation size of RFID family will not depend on number of FIDs, but rather number of ports and LAGs. Therefore introduce a FID family operation to calculate the PGT allocation size. The way that size is calculated in the CFF mode depends on calling fallible functions. Thus express the op as returning an int, with the size returned via a pointer argument. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Amit Cohen <amcohen@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://lore.kernel.org/r/1174651b7160fcedbef50010ae4b68201112fe6f.1701183892.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 80638da commit 1686b8d

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ struct mlxsw_sp_fid_ops {
9797
const struct mlxsw_sp_rif *rif);
9898
int (*flood_table_init)(struct mlxsw_sp_fid_family *fid_family,
9999
const struct mlxsw_sp_flood_table *flood_table);
100+
int (*pgt_size)(const struct mlxsw_sp_fid_family *fid_family,
101+
u16 *p_pgt_size);
100102
};
101103

102104
struct mlxsw_sp_fid_family {
@@ -322,12 +324,14 @@ mlxsw_sp_fid_family_num_fids(const struct mlxsw_sp_fid_family *fid_family)
322324
return fid_family->end_index - fid_family->start_index + 1;
323325
}
324326

325-
static u16
326-
mlxsw_sp_fid_family_pgt_size(const struct mlxsw_sp_fid_family *fid_family)
327+
static int
328+
mlxsw_sp_fid_8021d_pgt_size(const struct mlxsw_sp_fid_family *fid_family,
329+
u16 *p_pgt_size)
327330
{
328331
u16 num_fids = mlxsw_sp_fid_family_num_fids(fid_family);
329332

330-
return num_fids * fid_family->nr_flood_tables;
333+
*p_pgt_size = num_fids * fid_family->nr_flood_tables;
334+
return 0;
331335
}
332336

333337
static u16
@@ -1124,6 +1128,7 @@ static const struct mlxsw_sp_fid_ops mlxsw_sp_fid_8021d_ops_ctl = {
11241128
.fdb_clear_offload = mlxsw_sp_fid_8021d_fdb_clear_offload,
11251129
.vid_to_fid_rif_update = mlxsw_sp_fid_8021d_vid_to_fid_rif_update,
11261130
.flood_table_init = mlxsw_sp_fid_flood_table_init_ctl,
1131+
.pgt_size = mlxsw_sp_fid_8021d_pgt_size,
11271132
};
11281133

11291134
#define MLXSW_SP_FID_8021Q_MAX (VLAN_N_VID - 2)
@@ -1466,6 +1471,7 @@ static const struct mlxsw_sp_fid_ops mlxsw_sp_fid_8021q_ops_ctl = {
14661471
.fdb_clear_offload = mlxsw_sp_fid_8021q_fdb_clear_offload,
14671472
.vid_to_fid_rif_update = mlxsw_sp_fid_8021q_vid_to_fid_rif_update,
14681473
.flood_table_init = mlxsw_sp_fid_flood_table_init_ctl,
1474+
.pgt_size = mlxsw_sp_fid_8021d_pgt_size,
14691475
};
14701476

14711477
/* There are 4K-2 802.1Q FIDs */
@@ -1717,7 +1723,10 @@ mlxsw_sp_fid_flood_tables_init(struct mlxsw_sp_fid_family *fid_family)
17171723
int err;
17181724
int i;
17191725

1720-
pgt_size = mlxsw_sp_fid_family_pgt_size(fid_family);
1726+
err = fid_family->ops->pgt_size(fid_family, &pgt_size);
1727+
if (err)
1728+
return err;
1729+
17211730
err = mlxsw_sp_pgt_mid_alloc_range(mlxsw_sp, &fid_family->pgt_base,
17221731
pgt_size);
17231732
if (err)
@@ -1747,8 +1756,12 @@ mlxsw_sp_fid_flood_tables_fini(struct mlxsw_sp_fid_family *fid_family)
17471756
{
17481757
struct mlxsw_sp *mlxsw_sp = fid_family->mlxsw_sp;
17491758
u16 pgt_size;
1759+
int err;
1760+
1761+
err = fid_family->ops->pgt_size(fid_family, &pgt_size);
1762+
if (WARN_ON_ONCE(err))
1763+
return;
17501764

1751-
pgt_size = mlxsw_sp_fid_family_pgt_size(fid_family);
17521765
mlxsw_sp_pgt_mid_free_range(mlxsw_sp, fid_family->pgt_base, pgt_size);
17531766
}
17541767

0 commit comments

Comments
 (0)