diff options
author | Ido Schimmel <idosch@nvidia.com> | 2021-05-19 14:08:22 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-05-19 21:47:47 +0200 |
commit | b7b8f435ea3b33ba7067f992c5b85a62f24d19ed (patch) | |
tree | 20a316c8c0ff2829cfe04f1a51e38740970fc615 /drivers/net/ethernet/mellanox | |
parent | mlxsw: reg: Add inner packet fields to RECRv2 register (diff) | |
download | linux-b7b8f435ea3b33ba7067f992c5b85a62f24d19ed.tar.xz linux-b7b8f435ea3b33ba7067f992c5b85a62f24d19ed.zip |
mlxsw: spectrum_outer: Factor out helper for common outer fields
Outer IPv4 and IPv6 addresses are used by multiple multipath hash
policies. Factor out helpers that set these fields to increase code
sharing between different policies.
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mellanox')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 3f896c5e50c7..605515137636 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -9613,6 +9613,17 @@ struct mlxsw_sp_mp_hash_config { #define MLXSW_SP_MP_HASH_FIELD_RANGE_SET(_fields, _field, _nr) \ bitmap_set(_fields, MLXSW_REG_RECR2_##_field, _nr) +static void mlxsw_sp_mp4_hash_outer_addr(struct mlxsw_sp_mp_hash_config *config) +{ + unsigned long *headers = config->headers; + unsigned long *fields = config->fields; + + MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV4_EN_NOT_TCP_NOT_UDP); + MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV4_EN_TCP_UDP); + MLXSW_SP_MP_HASH_FIELD_RANGE_SET(fields, IPV4_SIP0, 4); + MLXSW_SP_MP_HASH_FIELD_RANGE_SET(fields, IPV4_DIP0, 4); +} + static void mlxsw_sp_mp4_hash_init(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_mp_hash_config *config) { @@ -9622,17 +9633,11 @@ static void mlxsw_sp_mp4_hash_init(struct mlxsw_sp *mlxsw_sp, switch (net->ipv4.sysctl_fib_multipath_hash_policy) { case 0: - MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV4_EN_NOT_TCP_NOT_UDP); - MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV4_EN_TCP_UDP); - MLXSW_SP_MP_HASH_FIELD_RANGE_SET(fields, IPV4_SIP0, 4); - MLXSW_SP_MP_HASH_FIELD_RANGE_SET(fields, IPV4_DIP0, 4); + mlxsw_sp_mp4_hash_outer_addr(config); break; case 1: - MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV4_EN_NOT_TCP_NOT_UDP); - MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV4_EN_TCP_UDP); + mlxsw_sp_mp4_hash_outer_addr(config); MLXSW_SP_MP_HASH_HEADER_SET(headers, TCP_UDP_EN_IPV4); - MLXSW_SP_MP_HASH_FIELD_RANGE_SET(fields, IPV4_SIP0, 4); - MLXSW_SP_MP_HASH_FIELD_RANGE_SET(fields, IPV4_DIP0, 4); MLXSW_SP_MP_HASH_FIELD_SET(fields, IPV4_PROTOCOL); MLXSW_SP_MP_HASH_FIELD_SET(fields, TCP_UDP_SPORT); MLXSW_SP_MP_HASH_FIELD_SET(fields, TCP_UDP_DPORT); @@ -9640,6 +9645,19 @@ static void mlxsw_sp_mp4_hash_init(struct mlxsw_sp *mlxsw_sp, } } +static void mlxsw_sp_mp6_hash_outer_addr(struct mlxsw_sp_mp_hash_config *config) +{ + unsigned long *headers = config->headers; + unsigned long *fields = config->fields; + + MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV6_EN_NOT_TCP_NOT_UDP); + MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV6_EN_TCP_UDP); + MLXSW_SP_MP_HASH_FIELD_SET(fields, IPV6_SIP0_7); + MLXSW_SP_MP_HASH_FIELD_RANGE_SET(fields, IPV6_SIP8, 8); + MLXSW_SP_MP_HASH_FIELD_SET(fields, IPV6_DIP0_7); + MLXSW_SP_MP_HASH_FIELD_RANGE_SET(fields, IPV6_DIP8, 8); +} + static void mlxsw_sp_mp6_hash_init(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_mp_hash_config *config) { @@ -9648,23 +9666,13 @@ static void mlxsw_sp_mp6_hash_init(struct mlxsw_sp *mlxsw_sp, switch (ip6_multipath_hash_policy(mlxsw_sp_net(mlxsw_sp))) { case 0: - MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV6_EN_NOT_TCP_NOT_UDP); - MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV6_EN_TCP_UDP); - MLXSW_SP_MP_HASH_FIELD_SET(fields, IPV6_SIP0_7); - MLXSW_SP_MP_HASH_FIELD_RANGE_SET(fields, IPV6_SIP8, 8); - MLXSW_SP_MP_HASH_FIELD_SET(fields, IPV6_DIP0_7); - MLXSW_SP_MP_HASH_FIELD_RANGE_SET(fields, IPV6_DIP8, 8); + mlxsw_sp_mp6_hash_outer_addr(config); MLXSW_SP_MP_HASH_FIELD_SET(fields, IPV6_NEXT_HEADER); MLXSW_SP_MP_HASH_FIELD_SET(fields, IPV6_FLOW_LABEL); break; case 1: - MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV6_EN_NOT_TCP_NOT_UDP); - MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV6_EN_TCP_UDP); + mlxsw_sp_mp6_hash_outer_addr(config); MLXSW_SP_MP_HASH_HEADER_SET(headers, TCP_UDP_EN_IPV6); - MLXSW_SP_MP_HASH_FIELD_SET(fields, IPV6_SIP0_7); - MLXSW_SP_MP_HASH_FIELD_RANGE_SET(fields, IPV6_SIP8, 8); - MLXSW_SP_MP_HASH_FIELD_SET(fields, IPV6_DIP0_7); - MLXSW_SP_MP_HASH_FIELD_RANGE_SET(fields, IPV6_DIP8, 8); MLXSW_SP_MP_HASH_FIELD_SET(fields, IPV6_NEXT_HEADER); MLXSW_SP_MP_HASH_FIELD_SET(fields, TCP_UDP_SPORT); MLXSW_SP_MP_HASH_FIELD_SET(fields, TCP_UDP_DPORT); |