diff --git a/drivers/net/ethernet/mellanox/mlxsw/Kconfig b/drivers/net/ethernet/mellanox/mlxsw/Kconfig index 93d97b4676eb..f4d9c9975ac3 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/Kconfig +++ b/drivers/net/ethernet/mellanox/mlxsw/Kconfig @@ -76,12 +76,10 @@ config MLXSW_SPECTRUM depends on PSAMPLE || PSAMPLE=n depends on BRIDGE || BRIDGE=n depends on IPV6 || IPV6=n + depends on NET_IPGRE || NET_IPGRE=n + depends on IPV6_GRE || IPV6_GRE=n select PARMAN select MLXFW - depends on NET_IPGRE - depends on !(MLXSW_CORE=y && NET_IPGRE=m) - depends on IPV6_GRE - depends on !(MLXSW_CORE=y && IPV6_GRE=m) default m ---help--- This driver supports Mellanox Technologies Spectrum Ethernet diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index a8a578610a7b..921bd1075edf 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -7031,7 +7031,7 @@ static void mlxsw_sp_mp4_hash_init(char *recr2_pl) static void mlxsw_sp_mp6_hash_init(char *recr2_pl) { - bool only_l3 = !init_net.ipv6.sysctl.multipath_hash_policy; + bool only_l3 = !ip6_multipath_hash_policy(&init_net); mlxsw_sp_mp_hash_header_set(recr2_pl, MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c index f537e1de11d9..ae22a3daffbf 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c @@ -133,39 +133,6 @@ struct mlxsw_sp_span_entry_ops mlxsw_sp_span_entry_ops_phys = { .deconfigure = mlxsw_sp_span_entry_phys_deconfigure, }; -static struct net_device * -mlxsw_sp_span_gretap4_route(const struct net_device *to_dev, - __be32 *saddrp, __be32 *daddrp) -{ - struct ip_tunnel *tun = netdev_priv(to_dev); - struct net_device *dev = NULL; - struct ip_tunnel_parm parms; - struct rtable *rt = NULL; - struct flowi4 fl4; - - /* We assume "dev" stays valid after rt is put. */ - ASSERT_RTNL(); - - parms = mlxsw_sp_ipip_netdev_parms4(to_dev); - ip_tunnel_init_flow(&fl4, parms.iph.protocol, *daddrp, *saddrp, - 0, 0, parms.link, tun->fwmark); - - rt = ip_route_output_key(tun->net, &fl4); - if (IS_ERR(rt)) - return NULL; - - if (rt->rt_type != RTN_UNICAST) - goto out; - - dev = rt->dst.dev; - *saddrp = fl4.saddr; - *daddrp = rt->rt_gateway; - -out: - ip_rt_put(rt); - return dev; -} - static int mlxsw_sp_span_dmac(struct neigh_table *tbl, const void *pkey, struct net_device *l3edev, @@ -200,7 +167,7 @@ mlxsw_sp_span_entry_unoffloadable(struct mlxsw_sp_span_parms *sparmsp) return 0; } -static int +static __maybe_unused int mlxsw_sp_span_entry_tunnel_parms_common(struct net_device *l3edev, union mlxsw_sp_l3addr saddr, union mlxsw_sp_l3addr daddr, @@ -227,6 +194,40 @@ mlxsw_sp_span_entry_tunnel_parms_common(struct net_device *l3edev, return 0; } +#if IS_ENABLED(CONFIG_NET_IPGRE) +static struct net_device * +mlxsw_sp_span_gretap4_route(const struct net_device *to_dev, + __be32 *saddrp, __be32 *daddrp) +{ + struct ip_tunnel *tun = netdev_priv(to_dev); + struct net_device *dev = NULL; + struct ip_tunnel_parm parms; + struct rtable *rt = NULL; + struct flowi4 fl4; + + /* We assume "dev" stays valid after rt is put. */ + ASSERT_RTNL(); + + parms = mlxsw_sp_ipip_netdev_parms4(to_dev); + ip_tunnel_init_flow(&fl4, parms.iph.protocol, *daddrp, *saddrp, + 0, 0, parms.link, tun->fwmark); + + rt = ip_route_output_key(tun->net, &fl4); + if (IS_ERR(rt)) + return NULL; + + if (rt->rt_type != RTN_UNICAST) + goto out; + + dev = rt->dst.dev; + *saddrp = fl4.saddr; + *daddrp = rt->rt_gateway; + +out: + ip_rt_put(rt); + return dev; +} + static int mlxsw_sp_span_entry_gretap4_parms(const struct net_device *to_dev, struct mlxsw_sp_span_parms *sparmsp) @@ -291,7 +292,9 @@ static const struct mlxsw_sp_span_entry_ops mlxsw_sp_span_entry_ops_gretap4 = { .configure = mlxsw_sp_span_entry_gretap4_configure, .deconfigure = mlxsw_sp_span_entry_gretap4_deconfigure, }; +#endif +#if IS_ENABLED(CONFIG_IPV6_GRE) static struct net_device * mlxsw_sp_span_gretap6_route(const struct net_device *to_dev, struct in6_addr *saddrp, @@ -389,12 +392,17 @@ struct mlxsw_sp_span_entry_ops mlxsw_sp_span_entry_ops_gretap6 = { .configure = mlxsw_sp_span_entry_gretap6_configure, .deconfigure = mlxsw_sp_span_entry_gretap6_deconfigure, }; +#endif static const struct mlxsw_sp_span_entry_ops *const mlxsw_sp_span_entry_types[] = { &mlxsw_sp_span_entry_ops_phys, +#if IS_ENABLED(CONFIG_NET_IPGRE) &mlxsw_sp_span_entry_ops_gretap4, +#endif +#if IS_ENABLED(CONFIG_IPV6_GRE) &mlxsw_sp_span_entry_ops_gretap6, +#endif }; static int diff --git a/include/net/ipv6.h b/include/net/ipv6.h index cabd3cdd4015..50a6f0ddb878 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -888,6 +888,17 @@ static inline int ip6_default_np_autolabel(struct net *net) } #endif +#if IS_ENABLED(CONFIG_IPV6) +static inline int ip6_multipath_hash_policy(const struct net *net) +{ + return net->ipv6.sysctl.multipath_hash_policy; +} +#else +static inline int ip6_multipath_hash_policy(const struct net *net) +{ + return 0; +} +#endif /* * Header manipulation