Commit dddb6c2f authored by David S. Miller's avatar David S. Miller

Merge branch 'mlxsw-refactor-parser'

Ido Schimmel says:

====================
mlxsw: Refactor parsing configuration

The Spectrum ASIC has a configurable limit on how deep into the packet
it parses. By default, the limit is 96 bytes.

There are several cases where this parsing depth is not enough and there
is a need to increase it: Decapsulation of VxLAN packets and
timestamping of PTP packets.

Currently, parsing depth API is maintained as part of VxLAN module,
because the MPRS register which configures parsing depth also configures
UDP destination port number used for VxLAN encapsulation and
decapsulation.

However, in addition to two above mentioned users of this API, the
multipath hash code also needs to invoke it in order to correctly hash
based on inner fields of IPv6-in-IPv6 packets.

Upcoming support for IPv6-in-IPv6 tunneling will add another user, as
without increasing the parsing depth such packets cannot be properly
decapsulated.

Therefore, this patchset refactors the parsing configuration API and
moves it out of the VxLAN module to the main driver code.

Tested using existing selftests.

Patch set overview:

Patch #1 adds the new parsing configuration infrastructure.
Patch #2 converts existing users to the new infrastructure.
Patch #3 deletes the old infrastructure.
Patch #4 calls the new infrastructure from the multipath hash code.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 809159ee 43c1b833
...@@ -2717,6 +2717,22 @@ mlxsw_sp_sample_trigger_params_unset(struct mlxsw_sp *mlxsw_sp, ...@@ -2717,6 +2717,22 @@ mlxsw_sp_sample_trigger_params_unset(struct mlxsw_sp *mlxsw_sp,
static int mlxsw_sp_netdevice_event(struct notifier_block *unused, static int mlxsw_sp_netdevice_event(struct notifier_block *unused,
unsigned long event, void *ptr); unsigned long event, void *ptr);
#define MLXSW_SP_DEFAULT_PARSING_DEPTH 96
#define MLXSW_SP_INCREASED_PARSING_DEPTH 128
#define MLXSW_SP_DEFAULT_VXLAN_UDP_DPORT 4789
static void mlxsw_sp_parsing_init(struct mlxsw_sp *mlxsw_sp)
{
mlxsw_sp->parsing.parsing_depth = MLXSW_SP_DEFAULT_PARSING_DEPTH;
mlxsw_sp->parsing.vxlan_udp_dport = MLXSW_SP_DEFAULT_VXLAN_UDP_DPORT;
mutex_init(&mlxsw_sp->parsing.lock);
}
static void mlxsw_sp_parsing_fini(struct mlxsw_sp *mlxsw_sp)
{
mutex_destroy(&mlxsw_sp->parsing.lock);
}
static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
const struct mlxsw_bus_info *mlxsw_bus_info, const struct mlxsw_bus_info *mlxsw_bus_info,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
...@@ -2727,6 +2743,7 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, ...@@ -2727,6 +2743,7 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
mlxsw_sp->core = mlxsw_core; mlxsw_sp->core = mlxsw_core;
mlxsw_sp->bus_info = mlxsw_bus_info; mlxsw_sp->bus_info = mlxsw_bus_info;
mlxsw_sp_parsing_init(mlxsw_sp);
mlxsw_core_emad_string_tlv_enable(mlxsw_core); mlxsw_core_emad_string_tlv_enable(mlxsw_core);
err = mlxsw_sp_base_mac_get(mlxsw_sp); err = mlxsw_sp_base_mac_get(mlxsw_sp);
...@@ -2926,6 +2943,7 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, ...@@ -2926,6 +2943,7 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
mlxsw_sp_fids_fini(mlxsw_sp); mlxsw_sp_fids_fini(mlxsw_sp);
err_fids_init: err_fids_init:
mlxsw_sp_kvdl_fini(mlxsw_sp); mlxsw_sp_kvdl_fini(mlxsw_sp);
mlxsw_sp_parsing_fini(mlxsw_sp);
return err; return err;
} }
...@@ -3046,6 +3064,7 @@ static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core) ...@@ -3046,6 +3064,7 @@ static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core)
mlxsw_sp_policers_fini(mlxsw_sp); mlxsw_sp_policers_fini(mlxsw_sp);
mlxsw_sp_fids_fini(mlxsw_sp); mlxsw_sp_fids_fini(mlxsw_sp);
mlxsw_sp_kvdl_fini(mlxsw_sp); mlxsw_sp_kvdl_fini(mlxsw_sp);
mlxsw_sp_parsing_fini(mlxsw_sp);
} }
/* Per-FID flood tables are used for both "true" 802.1D FIDs and emulated /* Per-FID flood tables are used for both "true" 802.1D FIDs and emulated
...@@ -3611,6 +3630,69 @@ void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port) ...@@ -3611,6 +3630,69 @@ void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port)
dev_put(mlxsw_sp_port->dev); dev_put(mlxsw_sp_port->dev);
} }
int mlxsw_sp_parsing_depth_inc(struct mlxsw_sp *mlxsw_sp)
{
char mprs_pl[MLXSW_REG_MPRS_LEN];
int err = 0;
mutex_lock(&mlxsw_sp->parsing.lock);
if (refcount_inc_not_zero(&mlxsw_sp->parsing.parsing_depth_ref))
goto out_unlock;
mlxsw_reg_mprs_pack(mprs_pl, MLXSW_SP_INCREASED_PARSING_DEPTH,
mlxsw_sp->parsing.vxlan_udp_dport);
err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mprs), mprs_pl);
if (err)
goto out_unlock;
mlxsw_sp->parsing.parsing_depth = MLXSW_SP_INCREASED_PARSING_DEPTH;
refcount_set(&mlxsw_sp->parsing.parsing_depth_ref, 1);
out_unlock:
mutex_unlock(&mlxsw_sp->parsing.lock);
return err;
}
void mlxsw_sp_parsing_depth_dec(struct mlxsw_sp *mlxsw_sp)
{
char mprs_pl[MLXSW_REG_MPRS_LEN];
mutex_lock(&mlxsw_sp->parsing.lock);
if (!refcount_dec_and_test(&mlxsw_sp->parsing.parsing_depth_ref))
goto out_unlock;
mlxsw_reg_mprs_pack(mprs_pl, MLXSW_SP_DEFAULT_PARSING_DEPTH,
mlxsw_sp->parsing.vxlan_udp_dport);
mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mprs), mprs_pl);
mlxsw_sp->parsing.parsing_depth = MLXSW_SP_DEFAULT_PARSING_DEPTH;
out_unlock:
mutex_unlock(&mlxsw_sp->parsing.lock);
}
int mlxsw_sp_parsing_vxlan_udp_dport_set(struct mlxsw_sp *mlxsw_sp,
__be16 udp_dport)
{
char mprs_pl[MLXSW_REG_MPRS_LEN];
int err;
mutex_lock(&mlxsw_sp->parsing.lock);
mlxsw_reg_mprs_pack(mprs_pl, mlxsw_sp->parsing.parsing_depth,
be16_to_cpu(udp_dport));
err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mprs), mprs_pl);
if (err)
goto out_unlock;
mlxsw_sp->parsing.vxlan_udp_dport = be16_to_cpu(udp_dport);
out_unlock:
mutex_unlock(&mlxsw_sp->parsing.lock);
return err;
}
static void static void
mlxsw_sp_port_lag_uppers_cleanup(struct mlxsw_sp_port *mlxsw_sp_port, mlxsw_sp_port_lag_uppers_cleanup(struct mlxsw_sp_port *mlxsw_sp_port,
struct net_device *lag_dev) struct net_device *lag_dev)
......
...@@ -148,6 +148,13 @@ struct mlxsw_sp_port_mapping { ...@@ -148,6 +148,13 @@ struct mlxsw_sp_port_mapping {
u8 lane; u8 lane;
}; };
struct mlxsw_sp_parsing {
refcount_t parsing_depth_ref;
u16 parsing_depth;
u16 vxlan_udp_dport;
struct mutex lock; /* Protects parsing configuration */
};
struct mlxsw_sp { struct mlxsw_sp {
struct mlxsw_sp_port **ports; struct mlxsw_sp_port **ports;
struct mlxsw_core *core; struct mlxsw_core *core;
...@@ -173,6 +180,7 @@ struct mlxsw_sp { ...@@ -173,6 +180,7 @@ struct mlxsw_sp {
struct mlxsw_sp_counter_pool *counter_pool; struct mlxsw_sp_counter_pool *counter_pool;
struct mlxsw_sp_span *span; struct mlxsw_sp_span *span;
struct mlxsw_sp_trap *trap; struct mlxsw_sp_trap *trap;
struct mlxsw_sp_parsing parsing;
const struct mlxsw_sp_switchdev_ops *switchdev_ops; const struct mlxsw_sp_switchdev_ops *switchdev_ops;
const struct mlxsw_sp_kvdl_ops *kvdl_ops; const struct mlxsw_sp_kvdl_ops *kvdl_ops;
const struct mlxsw_afa_ops *afa_ops; const struct mlxsw_afa_ops *afa_ops;
...@@ -652,6 +660,10 @@ struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev); ...@@ -652,6 +660,10 @@ struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev);
struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev); struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev);
void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port); void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port);
struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev); struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev);
int mlxsw_sp_parsing_depth_inc(struct mlxsw_sp *mlxsw_sp);
void mlxsw_sp_parsing_depth_dec(struct mlxsw_sp *mlxsw_sp);
int mlxsw_sp_parsing_vxlan_udp_dport_set(struct mlxsw_sp *mlxsw_sp,
__be16 udp_dport);
/* spectrum_dcb.c */ /* spectrum_dcb.c */
#ifdef CONFIG_MLXSW_SPECTRUM_DCB #ifdef CONFIG_MLXSW_SPECTRUM_DCB
......
...@@ -29,7 +29,6 @@ struct mlxsw_sp_nve { ...@@ -29,7 +29,6 @@ struct mlxsw_sp_nve {
unsigned int num_max_mc_entries[MLXSW_SP_L3_PROTO_MAX]; unsigned int num_max_mc_entries[MLXSW_SP_L3_PROTO_MAX];
u32 tunnel_index; u32 tunnel_index;
u16 ul_rif_index; /* Reserved for Spectrum */ u16 ul_rif_index; /* Reserved for Spectrum */
unsigned int inc_parsing_depth_refs;
}; };
struct mlxsw_sp_nve_ops { struct mlxsw_sp_nve_ops {
......
...@@ -10,14 +10,6 @@ ...@@ -10,14 +10,6 @@
#include "spectrum.h" #include "spectrum.h"
#include "spectrum_nve.h" #include "spectrum_nve.h"
/* Eth (18B) | IPv6 (40B) | UDP (8B) | VxLAN (8B) | Eth (14B) | IPv6 (40B)
*
* In the worst case - where we have a VLAN tag on the outer Ethernet
* header and IPv6 in overlay and underlay - we need to parse 128 bytes
*/
#define MLXSW_SP_NVE_VXLAN_PARSING_DEPTH 128
#define MLXSW_SP_NVE_DEFAULT_PARSING_DEPTH 96
#define MLXSW_SP_NVE_VXLAN_SUPPORTED_FLAGS (VXLAN_F_UDP_ZERO_CSUM_TX | \ #define MLXSW_SP_NVE_VXLAN_SUPPORTED_FLAGS (VXLAN_F_UDP_ZERO_CSUM_TX | \
VXLAN_F_LEARN) VXLAN_F_LEARN)
...@@ -115,66 +107,6 @@ static void mlxsw_sp_nve_vxlan_config(const struct mlxsw_sp_nve *nve, ...@@ -115,66 +107,6 @@ static void mlxsw_sp_nve_vxlan_config(const struct mlxsw_sp_nve *nve,
config->udp_dport = cfg->dst_port; config->udp_dport = cfg->dst_port;
} }
static int __mlxsw_sp_nve_parsing_set(struct mlxsw_sp *mlxsw_sp,
unsigned int parsing_depth,
__be16 udp_dport)
{
char mprs_pl[MLXSW_REG_MPRS_LEN];
mlxsw_reg_mprs_pack(mprs_pl, parsing_depth, be16_to_cpu(udp_dport));
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mprs), mprs_pl);
}
static int mlxsw_sp_nve_parsing_set(struct mlxsw_sp *mlxsw_sp,
__be16 udp_dport)
{
int parsing_depth = mlxsw_sp->nve->inc_parsing_depth_refs ?
MLXSW_SP_NVE_VXLAN_PARSING_DEPTH :
MLXSW_SP_NVE_DEFAULT_PARSING_DEPTH;
return __mlxsw_sp_nve_parsing_set(mlxsw_sp, parsing_depth, udp_dport);
}
static int
__mlxsw_sp_nve_inc_parsing_depth_get(struct mlxsw_sp *mlxsw_sp,
__be16 udp_dport)
{
int err;
mlxsw_sp->nve->inc_parsing_depth_refs++;
err = mlxsw_sp_nve_parsing_set(mlxsw_sp, udp_dport);
if (err)
goto err_nve_parsing_set;
return 0;
err_nve_parsing_set:
mlxsw_sp->nve->inc_parsing_depth_refs--;
return err;
}
static void
__mlxsw_sp_nve_inc_parsing_depth_put(struct mlxsw_sp *mlxsw_sp,
__be16 udp_dport)
{
mlxsw_sp->nve->inc_parsing_depth_refs--;
mlxsw_sp_nve_parsing_set(mlxsw_sp, udp_dport);
}
int mlxsw_sp_nve_inc_parsing_depth_get(struct mlxsw_sp *mlxsw_sp)
{
__be16 udp_dport = mlxsw_sp->nve->config.udp_dport;
return __mlxsw_sp_nve_inc_parsing_depth_get(mlxsw_sp, udp_dport);
}
void mlxsw_sp_nve_inc_parsing_depth_put(struct mlxsw_sp *mlxsw_sp)
{
__be16 udp_dport = mlxsw_sp->nve->config.udp_dport;
__mlxsw_sp_nve_inc_parsing_depth_put(mlxsw_sp, udp_dport);
}
static void static void
mlxsw_sp_nve_vxlan_config_prepare(char *tngcr_pl, mlxsw_sp_nve_vxlan_config_prepare(char *tngcr_pl,
const struct mlxsw_sp_nve_config *config) const struct mlxsw_sp_nve_config *config)
...@@ -238,10 +170,14 @@ static int mlxsw_sp1_nve_vxlan_init(struct mlxsw_sp_nve *nve, ...@@ -238,10 +170,14 @@ static int mlxsw_sp1_nve_vxlan_init(struct mlxsw_sp_nve *nve,
struct mlxsw_sp *mlxsw_sp = nve->mlxsw_sp; struct mlxsw_sp *mlxsw_sp = nve->mlxsw_sp;
int err; int err;
err = __mlxsw_sp_nve_inc_parsing_depth_get(mlxsw_sp, config->udp_dport); err = mlxsw_sp_parsing_vxlan_udp_dport_set(mlxsw_sp, config->udp_dport);
if (err) if (err)
return err; return err;
err = mlxsw_sp_parsing_depth_inc(mlxsw_sp);
if (err)
goto err_parsing_depth_inc;
err = mlxsw_sp1_nve_vxlan_config_set(mlxsw_sp, config); err = mlxsw_sp1_nve_vxlan_config_set(mlxsw_sp, config);
if (err) if (err)
goto err_config_set; goto err_config_set;
...@@ -263,7 +199,9 @@ static int mlxsw_sp1_nve_vxlan_init(struct mlxsw_sp_nve *nve, ...@@ -263,7 +199,9 @@ static int mlxsw_sp1_nve_vxlan_init(struct mlxsw_sp_nve *nve,
err_rtdp_set: err_rtdp_set:
mlxsw_sp1_nve_vxlan_config_clear(mlxsw_sp); mlxsw_sp1_nve_vxlan_config_clear(mlxsw_sp);
err_config_set: err_config_set:
__mlxsw_sp_nve_inc_parsing_depth_put(mlxsw_sp, 0); mlxsw_sp_parsing_depth_dec(mlxsw_sp);
err_parsing_depth_inc:
mlxsw_sp_parsing_vxlan_udp_dport_set(mlxsw_sp, 0);
return err; return err;
} }
...@@ -275,7 +213,8 @@ static void mlxsw_sp1_nve_vxlan_fini(struct mlxsw_sp_nve *nve) ...@@ -275,7 +213,8 @@ static void mlxsw_sp1_nve_vxlan_fini(struct mlxsw_sp_nve *nve)
mlxsw_sp_router_nve_demote_decap(mlxsw_sp, config->ul_tb_id, mlxsw_sp_router_nve_demote_decap(mlxsw_sp, config->ul_tb_id,
config->ul_proto, &config->ul_sip); config->ul_proto, &config->ul_sip);
mlxsw_sp1_nve_vxlan_config_clear(mlxsw_sp); mlxsw_sp1_nve_vxlan_config_clear(mlxsw_sp);
__mlxsw_sp_nve_inc_parsing_depth_put(mlxsw_sp, 0); mlxsw_sp_parsing_depth_dec(mlxsw_sp);
mlxsw_sp_parsing_vxlan_udp_dport_set(mlxsw_sp, 0);
} }
static int static int
...@@ -412,10 +351,14 @@ static int mlxsw_sp2_nve_vxlan_init(struct mlxsw_sp_nve *nve, ...@@ -412,10 +351,14 @@ static int mlxsw_sp2_nve_vxlan_init(struct mlxsw_sp_nve *nve,
struct mlxsw_sp *mlxsw_sp = nve->mlxsw_sp; struct mlxsw_sp *mlxsw_sp = nve->mlxsw_sp;
int err; int err;
err = __mlxsw_sp_nve_inc_parsing_depth_get(mlxsw_sp, config->udp_dport); err = mlxsw_sp_parsing_vxlan_udp_dport_set(mlxsw_sp, config->udp_dport);
if (err) if (err)
return err; return err;
err = mlxsw_sp_parsing_depth_inc(mlxsw_sp);
if (err)
goto err_parsing_depth_inc;
err = mlxsw_sp2_nve_vxlan_config_set(mlxsw_sp, config); err = mlxsw_sp2_nve_vxlan_config_set(mlxsw_sp, config);
if (err) if (err)
goto err_config_set; goto err_config_set;
...@@ -438,7 +381,9 @@ static int mlxsw_sp2_nve_vxlan_init(struct mlxsw_sp_nve *nve, ...@@ -438,7 +381,9 @@ static int mlxsw_sp2_nve_vxlan_init(struct mlxsw_sp_nve *nve,
err_rtdp_set: err_rtdp_set:
mlxsw_sp2_nve_vxlan_config_clear(mlxsw_sp); mlxsw_sp2_nve_vxlan_config_clear(mlxsw_sp);
err_config_set: err_config_set:
__mlxsw_sp_nve_inc_parsing_depth_put(mlxsw_sp, 0); mlxsw_sp_parsing_depth_dec(mlxsw_sp);
err_parsing_depth_inc:
mlxsw_sp_parsing_vxlan_udp_dport_set(mlxsw_sp, 0);
return err; return err;
} }
...@@ -450,7 +395,8 @@ static void mlxsw_sp2_nve_vxlan_fini(struct mlxsw_sp_nve *nve) ...@@ -450,7 +395,8 @@ static void mlxsw_sp2_nve_vxlan_fini(struct mlxsw_sp_nve *nve)
mlxsw_sp_router_nve_demote_decap(mlxsw_sp, config->ul_tb_id, mlxsw_sp_router_nve_demote_decap(mlxsw_sp, config->ul_tb_id,
config->ul_proto, &config->ul_sip); config->ul_proto, &config->ul_sip);
mlxsw_sp2_nve_vxlan_config_clear(mlxsw_sp); mlxsw_sp2_nve_vxlan_config_clear(mlxsw_sp);
__mlxsw_sp_nve_inc_parsing_depth_put(mlxsw_sp, 0); mlxsw_sp_parsing_depth_dec(mlxsw_sp);
mlxsw_sp_parsing_vxlan_udp_dport_set(mlxsw_sp, 0);
} }
const struct mlxsw_sp_nve_ops mlxsw_sp2_nve_vxlan_ops = { const struct mlxsw_sp_nve_ops mlxsw_sp2_nve_vxlan_ops = {
......
...@@ -975,14 +975,14 @@ static int mlxsw_sp1_ptp_mtpppc_update(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -975,14 +975,14 @@ static int mlxsw_sp1_ptp_mtpppc_update(struct mlxsw_sp_port *mlxsw_sp_port,
} }
if ((ing_types || egr_types) && !(orig_ing_types || orig_egr_types)) { if ((ing_types || egr_types) && !(orig_ing_types || orig_egr_types)) {
err = mlxsw_sp_nve_inc_parsing_depth_get(mlxsw_sp); err = mlxsw_sp_parsing_depth_inc(mlxsw_sp);
if (err) { if (err) {
netdev_err(mlxsw_sp_port->dev, "Failed to increase parsing depth"); netdev_err(mlxsw_sp_port->dev, "Failed to increase parsing depth");
return err; return err;
} }
} }
if (!(ing_types || egr_types) && (orig_ing_types || orig_egr_types)) if (!(ing_types || egr_types) && (orig_ing_types || orig_egr_types))
mlxsw_sp_nve_inc_parsing_depth_put(mlxsw_sp); mlxsw_sp_parsing_depth_dec(mlxsw_sp);
return mlxsw_sp1_ptp_mtpppc_set(mlxsw_sp_port->mlxsw_sp, return mlxsw_sp1_ptp_mtpppc_set(mlxsw_sp_port->mlxsw_sp,
ing_types, egr_types); ing_types, egr_types);
......
...@@ -9484,6 +9484,7 @@ struct mlxsw_sp_mp_hash_config { ...@@ -9484,6 +9484,7 @@ struct mlxsw_sp_mp_hash_config {
DECLARE_BITMAP(fields, __MLXSW_REG_RECR2_FIELD_CNT); DECLARE_BITMAP(fields, __MLXSW_REG_RECR2_FIELD_CNT);
DECLARE_BITMAP(inner_headers, __MLXSW_REG_RECR2_HEADER_CNT); DECLARE_BITMAP(inner_headers, __MLXSW_REG_RECR2_HEADER_CNT);
DECLARE_BITMAP(inner_fields, __MLXSW_REG_RECR2_INNER_FIELD_CNT); DECLARE_BITMAP(inner_fields, __MLXSW_REG_RECR2_INNER_FIELD_CNT);
bool inc_parsing_depth;
}; };
#define MLXSW_SP_MP_HASH_HEADER_SET(_headers, _header) \ #define MLXSW_SP_MP_HASH_HEADER_SET(_headers, _header) \
...@@ -9654,6 +9655,7 @@ static void mlxsw_sp_mp6_hash_init(struct mlxsw_sp *mlxsw_sp, ...@@ -9654,6 +9655,7 @@ static void mlxsw_sp_mp6_hash_init(struct mlxsw_sp *mlxsw_sp,
MLXSW_SP_MP_HASH_FIELD_SET(fields, IPV6_FLOW_LABEL); MLXSW_SP_MP_HASH_FIELD_SET(fields, IPV6_FLOW_LABEL);
/* Inner */ /* Inner */
mlxsw_sp_mp_hash_inner_l3(config); mlxsw_sp_mp_hash_inner_l3(config);
config->inc_parsing_depth = true;
break; break;
case 3: case 3:
/* Outer */ /* Outer */
...@@ -9678,22 +9680,53 @@ static void mlxsw_sp_mp6_hash_init(struct mlxsw_sp *mlxsw_sp, ...@@ -9678,22 +9680,53 @@ static void mlxsw_sp_mp6_hash_init(struct mlxsw_sp *mlxsw_sp,
MLXSW_SP_MP_HASH_FIELD_SET(fields, TCP_UDP_DPORT); MLXSW_SP_MP_HASH_FIELD_SET(fields, TCP_UDP_DPORT);
/* Inner */ /* Inner */
mlxsw_sp_mp_hash_inner_custom(config, hash_fields); mlxsw_sp_mp_hash_inner_custom(config, hash_fields);
if (hash_fields & FIB_MULTIPATH_HASH_FIELD_INNER_MASK)
config->inc_parsing_depth = true;
break; break;
} }
} }
static int mlxsw_sp_mp_hash_parsing_depth_adjust(struct mlxsw_sp *mlxsw_sp,
bool old_inc_parsing_depth,
bool new_inc_parsing_depth)
{
int err;
if (!old_inc_parsing_depth && new_inc_parsing_depth) {
err = mlxsw_sp_parsing_depth_inc(mlxsw_sp);
if (err)
return err;
mlxsw_sp->router->inc_parsing_depth = true;
} else if (old_inc_parsing_depth && !new_inc_parsing_depth) {
mlxsw_sp_parsing_depth_dec(mlxsw_sp);
mlxsw_sp->router->inc_parsing_depth = false;
}
return 0;
}
static int mlxsw_sp_mp_hash_init(struct mlxsw_sp *mlxsw_sp) static int mlxsw_sp_mp_hash_init(struct mlxsw_sp *mlxsw_sp)
{ {
bool old_inc_parsing_depth, new_inc_parsing_depth;
struct mlxsw_sp_mp_hash_config config = {}; struct mlxsw_sp_mp_hash_config config = {};
char recr2_pl[MLXSW_REG_RECR2_LEN]; char recr2_pl[MLXSW_REG_RECR2_LEN];
unsigned long bit; unsigned long bit;
u32 seed; u32 seed;
int err;
seed = jhash(mlxsw_sp->base_mac, sizeof(mlxsw_sp->base_mac), 0); seed = jhash(mlxsw_sp->base_mac, sizeof(mlxsw_sp->base_mac), 0);
mlxsw_reg_recr2_pack(recr2_pl, seed); mlxsw_reg_recr2_pack(recr2_pl, seed);
mlxsw_sp_mp4_hash_init(mlxsw_sp, &config); mlxsw_sp_mp4_hash_init(mlxsw_sp, &config);
mlxsw_sp_mp6_hash_init(mlxsw_sp, &config); mlxsw_sp_mp6_hash_init(mlxsw_sp, &config);
old_inc_parsing_depth = mlxsw_sp->router->inc_parsing_depth;
new_inc_parsing_depth = config.inc_parsing_depth;
err = mlxsw_sp_mp_hash_parsing_depth_adjust(mlxsw_sp,
old_inc_parsing_depth,
new_inc_parsing_depth);
if (err)
return err;
for_each_set_bit(bit, config.headers, __MLXSW_REG_RECR2_HEADER_CNT) for_each_set_bit(bit, config.headers, __MLXSW_REG_RECR2_HEADER_CNT)
mlxsw_reg_recr2_outer_header_enables_set(recr2_pl, bit, 1); mlxsw_reg_recr2_outer_header_enables_set(recr2_pl, bit, 1);
for_each_set_bit(bit, config.fields, __MLXSW_REG_RECR2_FIELD_CNT) for_each_set_bit(bit, config.fields, __MLXSW_REG_RECR2_FIELD_CNT)
...@@ -9703,7 +9736,16 @@ static int mlxsw_sp_mp_hash_init(struct mlxsw_sp *mlxsw_sp) ...@@ -9703,7 +9736,16 @@ static int mlxsw_sp_mp_hash_init(struct mlxsw_sp *mlxsw_sp)
for_each_set_bit(bit, config.inner_fields, __MLXSW_REG_RECR2_INNER_FIELD_CNT) for_each_set_bit(bit, config.inner_fields, __MLXSW_REG_RECR2_INNER_FIELD_CNT)
mlxsw_reg_recr2_inner_header_fields_enable_set(recr2_pl, bit, 1); mlxsw_reg_recr2_inner_header_fields_enable_set(recr2_pl, bit, 1);
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(recr2), recr2_pl); err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(recr2), recr2_pl);
if (err)
goto err_reg_write;
return 0;
err_reg_write:
mlxsw_sp_mp_hash_parsing_depth_adjust(mlxsw_sp, new_inc_parsing_depth,
old_inc_parsing_depth);
return err;
} }
#else #else
static int mlxsw_sp_mp_hash_init(struct mlxsw_sp *mlxsw_sp) static int mlxsw_sp_mp_hash_init(struct mlxsw_sp *mlxsw_sp)
......
...@@ -81,6 +81,7 @@ struct mlxsw_sp_router { ...@@ -81,6 +81,7 @@ struct mlxsw_sp_router {
size_t adj_grp_size_ranges_count; size_t adj_grp_size_ranges_count;
struct delayed_work nh_grp_activity_dw; struct delayed_work nh_grp_activity_dw;
struct list_head nh_res_grp_list; struct list_head nh_res_grp_list;
bool inc_parsing_depth;
}; };
struct mlxsw_sp_fib_entry_priv { struct mlxsw_sp_fib_entry_priv {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment