Skip to content

Commit d79b70d

Browse files
pmachatakuba-moo
authored andcommitted
mlxsw: spectrum_fid: Initialize flood profiles in CFF mode
In CFF flood mode, the way flood vectors are looked up changes: there's a per-FID PGT base, to which a small offset is added depending on type of traffic. Thus each FID occupies a small contiguous block of PGT memory, whereas in the controlled flood mode, flood vectors for a given FID were spread across the PGT. Each FID is associated with one of a handful of profiles. The profile and the traffic type are then used as keys to look up the PGT offset. This offset is then added to the per-FID PGT base. The profile / type / offset mapping needs to be configured by the driver, and is only relevant in CFF flood mode. In this patch, add the SFFP initialization code. Only initialize the one profile currently explicitly used. As follow-up patch add more profiles, this code will pick them up and initialize as well. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://lore.kernel.org/r/2c4733ed72d439444218969c032acad22cd4ed88.1701183892.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent af1e696 commit d79b70d

File tree

1 file changed

+122
-1
lines changed

1 file changed

+122
-1
lines changed

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

Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,9 @@ static const struct mlxsw_sp_fid_family *mlxsw_sp2_fid_family_arr_ctl[] = {
16331633
[MLXSW_SP_FID_TYPE_RFID] = &mlxsw_sp_fid_rfid_family_ctl,
16341634
};
16351635

1636+
static const struct mlxsw_sp_fid_family *mlxsw_sp2_fid_family_arr_cff[] = {
1637+
};
1638+
16361639
static struct mlxsw_sp_fid *mlxsw_sp_fid_lookup(struct mlxsw_sp *mlxsw_sp,
16371640
enum mlxsw_sp_fid_type type,
16381641
const void *arg)
@@ -2008,12 +2011,130 @@ const struct mlxsw_sp_fid_core_ops mlxsw_sp1_fid_core_ops = {
20082011
.fini = mlxsw_sp_fids_fini,
20092012
};
20102013

2014+
static int mlxsw_sp_fid_check_flood_profile_id(struct mlxsw_sp *mlxsw_sp,
2015+
int profile_id)
2016+
{
2017+
u32 max_profiles;
2018+
2019+
if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_NVE_FLOOD_PRF))
2020+
return -EIO;
2021+
2022+
max_profiles = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_NVE_FLOOD_PRF);
2023+
if (WARN_ON_ONCE(!profile_id) ||
2024+
WARN_ON_ONCE(profile_id >= max_profiles))
2025+
return -EINVAL;
2026+
2027+
return 0;
2028+
}
2029+
2030+
static int
2031+
mlxsw_sp2_fids_init_flood_table(struct mlxsw_sp *mlxsw_sp,
2032+
enum mlxsw_sp_fid_flood_profile_id profile_id,
2033+
const struct mlxsw_sp_flood_table *flood_table)
2034+
{
2035+
enum mlxsw_sp_flood_type packet_type = flood_table->packet_type;
2036+
const int *sfgc_packet_types;
2037+
int err;
2038+
int i;
2039+
2040+
sfgc_packet_types = mlxsw_sp_packet_type_sfgc_types[packet_type];
2041+
for (i = 0; i < MLXSW_REG_SFGC_TYPE_MAX; i++) {
2042+
char sffp_pl[MLXSW_REG_SFFP_LEN];
2043+
2044+
if (!sfgc_packet_types[i])
2045+
continue;
2046+
2047+
mlxsw_reg_sffp_pack(sffp_pl, profile_id, i,
2048+
flood_table->table_index);
2049+
err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sffp), sffp_pl);
2050+
if (err)
2051+
return err;
2052+
}
2053+
2054+
return 0;
2055+
}
2056+
2057+
static int
2058+
mlxsw_sp2_fids_init_flood_profile(struct mlxsw_sp *mlxsw_sp,
2059+
const struct mlxsw_sp_fid_flood_profile *
2060+
flood_profile)
2061+
{
2062+
int err;
2063+
int i;
2064+
2065+
err = mlxsw_sp_fid_check_flood_profile_id(mlxsw_sp,
2066+
flood_profile->profile_id);
2067+
if (err)
2068+
return err;
2069+
2070+
for (i = 0; i < flood_profile->nr_flood_tables; i++) {
2071+
const struct mlxsw_sp_flood_table *flood_table;
2072+
2073+
flood_table = &flood_profile->flood_tables[i];
2074+
err = mlxsw_sp2_fids_init_flood_table(mlxsw_sp,
2075+
flood_profile->profile_id,
2076+
flood_table);
2077+
if (err)
2078+
return err;
2079+
}
2080+
2081+
return 0;
2082+
}
2083+
2084+
static const
2085+
struct mlxsw_sp_fid_flood_profile *mlxsw_sp_fid_flood_profiles[] = {
2086+
&mlxsw_sp_fid_8021d_flood_profile,
2087+
};
2088+
2089+
static int
2090+
mlxsw_sp2_fids_init_flood_profiles(struct mlxsw_sp *mlxsw_sp)
2091+
{
2092+
int err;
2093+
int i;
2094+
2095+
for (i = 0; i < ARRAY_SIZE(mlxsw_sp_fid_flood_profiles); i++) {
2096+
const struct mlxsw_sp_fid_flood_profile *flood_profile;
2097+
2098+
flood_profile = mlxsw_sp_fid_flood_profiles[i];
2099+
err = mlxsw_sp2_fids_init_flood_profile(mlxsw_sp,
2100+
flood_profile);
2101+
if (err)
2102+
return err;
2103+
}
2104+
2105+
return 0;
2106+
}
2107+
20112108
static int mlxsw_sp2_fids_init_ctl(struct mlxsw_sp *mlxsw_sp)
20122109
{
20132110
return mlxsw_sp_fids_init(mlxsw_sp, mlxsw_sp2_fid_family_arr_ctl);
20142111
}
20152112

2113+
static int mlxsw_sp2_fids_init_cff(struct mlxsw_sp *mlxsw_sp)
2114+
{
2115+
int err;
2116+
2117+
err = mlxsw_sp2_fids_init_flood_profiles(mlxsw_sp);
2118+
if (err)
2119+
return err;
2120+
2121+
return mlxsw_sp_fids_init(mlxsw_sp, mlxsw_sp2_fid_family_arr_cff);
2122+
}
2123+
2124+
static int mlxsw_sp2_fids_init(struct mlxsw_sp *mlxsw_sp)
2125+
{
2126+
switch (mlxsw_core_flood_mode(mlxsw_sp->core)) {
2127+
case MLXSW_CMD_MBOX_CONFIG_PROFILE_FLOOD_MODE_CONTROLLED:
2128+
return mlxsw_sp2_fids_init_ctl(mlxsw_sp);
2129+
case MLXSW_CMD_MBOX_CONFIG_PROFILE_FLOOD_MODE_CFF:
2130+
return mlxsw_sp2_fids_init_cff(mlxsw_sp);
2131+
default:
2132+
WARN_ON_ONCE(1);
2133+
return -EINVAL;
2134+
}
2135+
}
2136+
20162137
const struct mlxsw_sp_fid_core_ops mlxsw_sp2_fid_core_ops = {
2017-
.init = mlxsw_sp2_fids_init_ctl,
2138+
.init = mlxsw_sp2_fids_init,
20182139
.fini = mlxsw_sp_fids_fini,
20192140
};

0 commit comments

Comments
 (0)