Skip to content

Commit 60bcfed

Browse files
pmachatakuba-moo
authored andcommitted
mlxsw: spectrum_router: Apply user-defined multipath hash seed
When Spectrum machines compute hash for the purposes of ECMP routing, they use a seed specified through RECR_v2 (Router ECMP Configuration Register). Up until now mlxsw computed the seed by hashing the machine's base MAC. Now that we can optionally have a user-provided seed, use that if possible. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org> Reviewed-by: David Ahern <dsahern@kernel.org> Link: https://lore.kernel.org/r/20240607151357.421181-4-petrm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 4ee2a8c commit 60bcfed

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11450,12 +11450,16 @@ static int mlxsw_sp_mp_hash_init(struct mlxsw_sp *mlxsw_sp)
1145011450
{
1145111451
bool old_inc_parsing_depth, new_inc_parsing_depth;
1145211452
struct mlxsw_sp_mp_hash_config config = {};
11453+
struct net *net = mlxsw_sp_net(mlxsw_sp);
1145311454
char recr2_pl[MLXSW_REG_RECR2_LEN];
1145411455
unsigned long bit;
1145511456
u32 seed;
1145611457
int err;
1145711458

11458-
seed = jhash(mlxsw_sp->base_mac, sizeof(mlxsw_sp->base_mac), 0);
11459+
seed = READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_seed).user_seed;
11460+
if (!seed)
11461+
seed = jhash(mlxsw_sp->base_mac, sizeof(mlxsw_sp->base_mac), 0);
11462+
1145911463
mlxsw_reg_recr2_pack(recr2_pl, seed);
1146011464
mlxsw_sp_mp4_hash_init(mlxsw_sp, &config);
1146111465
mlxsw_sp_mp6_hash_init(mlxsw_sp, &config);

0 commit comments

Comments
 (0)