mlxsw: Add support for IP-in-IP with IPv6 underlay
Subsystems (3)
cover mlxsw: Add support for IP-in-IP with IPv6 underlay
From: Ido Schimmel <[email protected]>
Currently, mlxsw only supports IP-in-IP with IPv4 underlay. Traffic routed through 'gre' netdevs is encapsulated with IPv4 and GRE headers. Similarly, incoming IPv4 GRE packets are decapsulated and routed in the overlay VRF (which can be the same as the underlay VRF).
This patchset adds support for IPv6 underlay using the 'ip6gre' netdev. Due to architectural differences between Spectrum-1 and later ASICs, this functionality is only supported on Spectrum-2 onwards (the software data path is used for Spectrum-1).
Patchset overview:
Patches #1-#5 are preparations.
Patches #6-#9 add and extend required device registers.
Patches #10-#14 gradually add IPv6 underlay support.
A follow-up patchset will add net/forwarding/ selftests.
Amit Cohen (14):
mlxsw: spectrum_router: Create common function for
fib_entry_type_unset() code
mlxsw: spectrum_ipip: Pass IP tunnel parameters by reference and as
'const'
mlxsw: spectrum_router: Fix arguments alignment
mlxsw: spectrum_ipip: Create common function for
mlxsw_sp_ipip_ol_netdev_change_gre()
mlxsw: Take tunnel's type into account when searching underlay device
mlxsw: reg: Add Router IP version Six Register
mlxsw: reg: Add support for rtdp_ipip6_pack()
mlxsw: reg: Add support for ratr_ipip6_entry_pack()
mlxsw: reg: Add support for ritr_loopback_ipip6_pack()
mlxsw: Create separate ipip_ops_arr for different ASICs
mlxsw: spectrum_ipip: Add mlxsw_sp_ipip_gre6_ops
mlxsw: Add IPV6_ADDRESS kvdl entry type
mlxsw: spectrum_router: Increase parsing depth for IPv6 decapsulation
mlxsw: Add support for IP-in-IP with IPv6 underlay for Spectrum-2 and
above
drivers/net/ethernet/mellanox/mlxsw/reg.h | 86 +++- .../net/ethernet/mellanox/mlxsw/spectrum.h | 2 + .../ethernet/mellanox/mlxsw/spectrum2_kvdl.c | 1 + .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 432 ++++++++++++++++-- .../ethernet/mellanox/mlxsw/spectrum_ipip.h | 27 +- .../ethernet/mellanox/mlxsw/spectrum_router.c | 186 ++++++-- .../ethernet/mellanox/mlxsw/spectrum_router.h | 2 + 7 files changed, 641 insertions(+), 95 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/14 mlxsw: spectrum_router: Create common function for fib_entry_type_unset() code
From: Amit Cohen <[email protected]>
mlxsw_sp_fib4_entry_type_unset() is not specific for IPv4 FIB entry, move the code to mlxsw_sp_fib_entry_type_unset(), and call this function from mlxsw_sp_fib4_entry_type_unset() so then it will be used for IPv6 also.
--- .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +10 -3
@@ -6069,8 +6069,8 @@ mlxsw_sp_fib4_entry_type_set(struct mlxsw_sp *mlxsw_sp, }static void -mlxsw_sp_fib4_entry_type_unset (struct mlxsw_sp *mlxsw_sp, -struct mlxsw_sp_fib_entry *fib_entry) +mlxsw_sp_fib_entry_type_unset (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_fib_entry *fib_entry) {switch (fib_entry->type) {case MLXSW_SP_FIB_ENTRY_TYPE_IPIP_DECAP :
@@ -6081,6 +6081,13 @@ mlxsw_sp_fib4_entry_type_unset(struct mlxsw_sp *mlxsw_sp, } } +static void +mlxsw_sp_fib4_entry_type_unset (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_fib4_entry *fib4_entry) +{ +mlxsw_sp_fib_entry_type_unset (mlxsw_sp, &fib4_entry->common); +} +static struct mlxsw_sp_fib4_entry * mlxsw_sp_fib4_entry_create(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fib_node *fib_node,
@@ -6141,7 +6148,7 @@ static void mlxsw_sp_fib4_entry_destroy(struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_fib_node *fib_node = fib4_entry->common.fib_node;fib_info_put (fib4_entry->fi); -mlxsw_sp_fib4_entry_type_unset (mlxsw_sp, &fib4_entry->common); +mlxsw_sp_fib4_entry_type_unset (mlxsw_sp, fib4_entry);mlxsw_sp_nexthop_group_vr_unlink (fib4_entry->common.nh_group, fib_node->fib);mlxsw_sp_nexthop4_group_put (mlxsw_sp, &fib4_entry->common);
Signature · 1 line
2.31.1
PATCH 2/14 mlxsw: spectrum_ipip: Pass IP tunnel parameters by reference and as 'const'
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
Currently, there are several functions that handle 'struct ip_tunnel_parm' and 'struct __ip6_tnl_parm'.
Change the mentioned functions to get IP tunnel parameters by reference and as 'const'.
--- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c +33 -33
@@ -24,50 +24,50 @@ mlxsw_sp_ipip_netdev_parms6(const struct net_device *ol_dev)return tun->parms; } -static bool mlxsw_sp_ipip_parms4_has_ikey (struct ip_tunnel_parm parms) +static bool mlxsw_sp_ipip_parms4_has_ikey (const struct ip_tunnel_parm *parms) { -return !!(parms.i_flags &TUNNEL_KEY ); +return !!(parms->i_flags &TUNNEL_KEY ); } -static bool mlxsw_sp_ipip_parms4_has_okey (struct ip_tunnel_parm parms) +static bool mlxsw_sp_ipip_parms4_has_okey (const struct ip_tunnel_parm *parms) { -return !!(parms.o_flags &TUNNEL_KEY ); +return !!(parms->o_flags &TUNNEL_KEY ); } -static u32 mlxsw_sp_ipip_parms4_ikey (struct ip_tunnel_parm parms) +static u32 mlxsw_sp_ipip_parms4_ikey (const struct ip_tunnel_parm *parms) {return mlxsw_sp_ipip_parms4_has_ikey (parms) ? -be32_to_cpu (parms.i_key) :0 ; +be32_to_cpu (parms->i_key) :0 ; } -static u32 mlxsw_sp_ipip_parms4_okey (struct ip_tunnel_parm parms) +static u32 mlxsw_sp_ipip_parms4_okey (const struct ip_tunnel_parm *parms) {return mlxsw_sp_ipip_parms4_has_okey (parms) ? -be32_to_cpu (parms.o_key) :0 ; +be32_to_cpu (parms->o_key) :0 ; }static union mlxsw_sp_l3addr -mlxsw_sp_ipip_parms4_saddr (struct ip_tunnel_parm parms) +mlxsw_sp_ipip_parms4_saddr (const struct ip_tunnel_parm *parms) { -return (union mlxsw_sp_l3addr ) { .addr4 = parms.iph.saddr }; +return (union mlxsw_sp_l3addr ) { .addr4 = parms->iph.saddr }; }static union mlxsw_sp_l3addr -mlxsw_sp_ipip_parms6_saddr (struct __ip6_tnl_parm parms) +mlxsw_sp_ipip_parms6_saddr (const struct __ip6_tnl_parm *parms) { -return (union mlxsw_sp_l3addr ) { .addr6 = parms.laddr }; +return (union mlxsw_sp_l3addr ) { .addr6 = parms->laddr }; }static union mlxsw_sp_l3addr -mlxsw_sp_ipip_parms4_daddr (struct ip_tunnel_parm parms) +mlxsw_sp_ipip_parms4_daddr (const struct ip_tunnel_parm *parms) { -return (union mlxsw_sp_l3addr ) { .addr4 = parms.iph.daddr }; +return (union mlxsw_sp_l3addr ) { .addr4 = parms->iph.daddr }; }static union mlxsw_sp_l3addr -mlxsw_sp_ipip_parms6_daddr (struct __ip6_tnl_parm parms) +mlxsw_sp_ipip_parms6_daddr (const struct __ip6_tnl_parm *parms) { -return (union mlxsw_sp_l3addr ) { .addr6 = parms.raddr }; +return (union mlxsw_sp_l3addr ) { .addr6 = parms->raddr }; }union mlxsw_sp_l3addr
@@ -80,10 +80,10 @@ mlxsw_sp_ipip_netdev_saddr(enum mlxsw_sp_l3proto proto,switch (proto) {case MLXSW_SP_L3_PROTO_IPV4 : parms4 =mlxsw_sp_ipip_netdev_parms4 (ol_dev); -return mlxsw_sp_ipip_parms4_saddr (parms4); +return mlxsw_sp_ipip_parms4_saddr (&parms4);case MLXSW_SP_L3_PROTO_IPV6 : parms6 =mlxsw_sp_ipip_netdev_parms6 (ol_dev); -return mlxsw_sp_ipip_parms6_saddr (parms6); +return mlxsw_sp_ipip_parms6_saddr (&parms6); }WARN_ON (1 );
@@ -95,7 +95,7 @@ static __be32 mlxsw_sp_ipip_netdev_daddr4(const struct net_device *ol_dev)struct ip_tunnel_parm parms4 =mlxsw_sp_ipip_netdev_parms4 (ol_dev); -return mlxsw_sp_ipip_parms4_daddr (parms4).addr4; +return mlxsw_sp_ipip_parms4_daddr (&parms4).addr4; } static union mlxsw_sp_l3addr
@@ -108,10 +108,10 @@ mlxsw_sp_ipip_netdev_daddr(enum mlxsw_sp_l3proto proto,switch (proto) {case MLXSW_SP_L3_PROTO_IPV4 : parms4 =mlxsw_sp_ipip_netdev_parms4 (ol_dev); -return mlxsw_sp_ipip_parms4_daddr (parms4); +return mlxsw_sp_ipip_parms4_daddr (&parms4);case MLXSW_SP_L3_PROTO_IPV6 : parms6 =mlxsw_sp_ipip_netdev_parms6 (ol_dev); -return mlxsw_sp_ipip_parms6_daddr (parms6); +return mlxsw_sp_ipip_parms6_daddr (&parms6); }WARN_ON (1 );
@@ -158,8 +158,8 @@ mlxsw_sp_ipip_decap_config_gre4(struct mlxsw_sp *mlxsw_sp,u32 ikey; parms =mlxsw_sp_ipip_netdev_parms4 (ipip_entry->ol_dev); - has_ikey =mlxsw_sp_ipip_parms4_has_ikey (parms); - ikey =mlxsw_sp_ipip_parms4_ikey (parms); + has_ikey =mlxsw_sp_ipip_parms4_has_ikey (&parms); + ikey =mlxsw_sp_ipip_parms4_ikey (&parms);mlxsw_reg_rtdp_pack (rtdp_pl,MLXSW_REG_RTDP_TYPE_IPIP , tunnel_index);mlxsw_reg_rtdp_egress_router_interface_set (rtdp_pl, ul_rif_id);
@@ -218,12 +218,12 @@ mlxsw_sp_ipip_ol_loopback_config_gre4(struct mlxsw_sp *mlxsw_sp,struct ip_tunnel_parm parms =mlxsw_sp_ipip_netdev_parms4 (ol_dev);enum mlxsw_reg_ritr_loopback_ipip_type lb_ipipt; - lb_ipipt =mlxsw_sp_ipip_parms4_has_okey (parms) ? + lb_ipipt =mlxsw_sp_ipip_parms4_has_okey (&parms) ?MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_KEY_IN_IP :MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_IN_IP ;return (struct mlxsw_sp_rif_ipip_lb_config ){ .lb_ipipt = lb_ipipt, - .okey =mlxsw_sp_ipip_parms4_okey (parms), + .okey =mlxsw_sp_ipip_parms4_okey (&parms), .ul_protocol =MLXSW_SP_L3_PROTO_IPV4 , .saddr =mlxsw_sp_ipip_netdev_saddr (MLXSW_SP_L3_PROTO_IPV4 , ol_dev),
@@ -245,10 +245,10 @@ mlxsw_sp_ipip_ol_netdev_change_gre4(struct mlxsw_sp *mlxsw_sp, new_parms =mlxsw_sp_ipip_netdev_parms4 (ipip_entry->ol_dev); - new_saddr =mlxsw_sp_ipip_parms4_saddr (new_parms); - old_saddr =mlxsw_sp_ipip_parms4_saddr (ipip_entry->parms4); - new_daddr =mlxsw_sp_ipip_parms4_daddr (new_parms); - old_daddr =mlxsw_sp_ipip_parms4_daddr (ipip_entry->parms4); + new_saddr =mlxsw_sp_ipip_parms4_saddr (&new_parms); + old_saddr =mlxsw_sp_ipip_parms4_saddr (&ipip_entry->parms4); + new_daddr =mlxsw_sp_ipip_parms4_daddr (&new_parms); + old_daddr =mlxsw_sp_ipip_parms4_daddr (&ipip_entry->parms4);if (!mlxsw_sp_l3addr_eq (&new_saddr, &old_saddr)) {u16 ul_tb_id =mlxsw_sp_ipip_dev_ul_tb_id (ipip_entry->ol_dev);
@@ -265,14 +265,14 @@ mlxsw_sp_ipip_ol_netdev_change_gre4(struct mlxsw_sp *mlxsw_sp, } update_tunnel = true; - }else if ((mlxsw_sp_ipip_parms4_okey (ipip_entry->parms4) != -mlxsw_sp_ipip_parms4_okey (new_parms)) || + }else if ((mlxsw_sp_ipip_parms4_okey (&ipip_entry->parms4) != +mlxsw_sp_ipip_parms4_okey (&new_parms)) || ipip_entry->parms4.link != new_parms.link) { update_tunnel = true; }else if (!mlxsw_sp_l3addr_eq (&new_daddr, &old_daddr)) { update_nhs = true; - }else if (mlxsw_sp_ipip_parms4_ikey (ipip_entry->parms4) != -mlxsw_sp_ipip_parms4_ikey (new_parms)) { + }else if (mlxsw_sp_ipip_parms4_ikey (&ipip_entry->parms4) != +mlxsw_sp_ipip_parms4_ikey (&new_parms)) { update_decap = true; }
Signature · 1 line
2.31.1
PATCH 3/14 mlxsw: spectrum_router: Fix arguments alignment
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
Suppress the following checkpatch.pl check [1] by adding a variable to store the IP-in-IP options. Noticed while adding equivalent IPv6 code in subsequent patches.
[1]
CHECK: Alignment should match open parenthesis
+ mlxsw_reg_ritr_loopback_ipip4_pack(ritr_pl, lb_cf.lb_ipipt,
+
+ MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +5 -2
@@ -1536,19 +1536,22 @@ mlxsw_sp_rif_ipip_lb_op(struct mlxsw_sp_rif_ipip_lb *lb_rif, u16 ul_vr_id, u16 ul_rif_id, bool enable) {struct mlxsw_sp_rif_ipip_lb_config lb_cf = lb_rif->lb_config; +enum mlxsw_reg_ritr_loopback_ipip_options ipip_options;struct mlxsw_sp_rif *rif = &lb_rif->common;struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp;char ritr_pl[MLXSW_REG_RITR_LEN ];u32 saddr4; + ipip_options =MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET ;switch (lb_cf.ul_protocol) {case MLXSW_SP_L3_PROTO_IPV4 : saddr4 =be32_to_cpu (lb_cf.saddr.addr4);mlxsw_reg_ritr_pack (ritr_pl, enable,MLXSW_REG_RITR_LOOPBACK_IF , rif->rif_index, rif->vr_id, rif->dev->mtu);mlxsw_reg_ritr_loopback_ipip4_pack (ritr_pl, lb_cf.lb_ipipt, -MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET , - ul_vr_id, ul_rif_id, saddr4, lb_cf.okey); + ipip_options, ul_vr_id, + ul_rif_id, saddr4, + lb_cf.okey);break ;case MLXSW_SP_L3_PROTO_IPV6 :
Signature · 1 line
2.31.1
PATCH 4/14 mlxsw: spectrum_ipip: Create common function for mlxsw_sp_ipip_ol_netdev_change_gre()
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
The function mlxsw_sp_ipip_ol_netdev_change_gre4() contains code that can be shared between IPv4 and IPv6.
The only difference is the way that arguments are taken from tunnel parameters, which are different between IPv4 and IPv6.
For that, add structure 'mlxsw_sp_ipip_parms' to hold all the required parameters for the function and save it as part of
'struct mlxsw_sp_ipip_entry' instead of the existing structure that is not shared between IPv4 and IPv6. Add new operation as part of 'mlxsw_sp_ipip_ops' to initialize the new structure.
Then mlxsw_sp_ipip_ol_netdev_change_gre{4,6}() will prepare the new structure and both will call the same function.
--- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 69 ++++++++++++------- .../ethernet/mellanox/mlxsw/spectrum_ipip.h | 16 ++++- .../ethernet/mellanox/mlxsw/spectrum_router.c | 11 +-- 3 files changed, 59 insertions(+), 37 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c +45 -24
@@ -125,6 +125,21 @@ bool mlxsw_sp_l3addr_is_zero(union mlxsw_sp_l3addr addr)return !memcmp (&addr, &naddr,sizeof (naddr)); } +static struct mlxsw_sp_ipip_parms +mlxsw_sp_ipip_netdev_parms_init_gre4 (const struct net_device *ol_dev) +{ +struct ip_tunnel_parm parms =mlxsw_sp_ipip_netdev_parms4 (ol_dev); + +return (struct mlxsw_sp_ipip_parms ) { + .proto =MLXSW_SP_L3_PROTO_IPV4 , + .saddr =mlxsw_sp_ipip_parms4_saddr (&parms), + .daddr =mlxsw_sp_ipip_parms4_daddr (&parms), + .link = parms.link, + .ikey =mlxsw_sp_ipip_parms4_ikey (&parms), + .okey =mlxsw_sp_ipip_parms4_okey (&parms), + }; +} + static int mlxsw_sp_ipip_nexthop_update_gre4(struct mlxsw_sp *mlxsw_sp, u32 adj_index, struct mlxsw_sp_ipip_entry *ipip_entry,
@@ -231,48 +246,39 @@ mlxsw_sp_ipip_ol_loopback_config_gre4(struct mlxsw_sp *mlxsw_sp, }static int -mlxsw_sp_ipip_ol_netdev_change_gre4 (struct mlxsw_sp *mlxsw_sp, -struct mlxsw_sp_ipip_entry *ipip_entry, -struct netlink_ext_ack *extack) +mlxsw_sp_ipip_ol_netdev_change_gre (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_ipip_entry *ipip_entry, +const struct mlxsw_sp_ipip_parms *new_parms, +struct netlink_ext_ack *extack) { -union mlxsw_sp_l3addr old_saddr, new_saddr; -union mlxsw_sp_l3addr old_daddr, new_daddr; -struct ip_tunnel_parm new_parms; +const struct mlxsw_sp_ipip_parms *old_parms = &ipip_entry->parms;bool update_tunnel = false;bool update_decap = false;bool update_nhs = false;int err =0 ; - new_parms =mlxsw_sp_ipip_netdev_parms4 (ipip_entry->ol_dev); - - new_saddr =mlxsw_sp_ipip_parms4_saddr (&new_parms); - old_saddr =mlxsw_sp_ipip_parms4_saddr (&ipip_entry->parms4); - new_daddr =mlxsw_sp_ipip_parms4_daddr (&new_parms); - old_daddr =mlxsw_sp_ipip_parms4_daddr (&ipip_entry->parms4); - -if (!mlxsw_sp_l3addr_eq (&new_saddr, &old_saddr)) { +if (!mlxsw_sp_l3addr_eq (&new_parms->saddr, &old_parms->saddr)) {u16 ul_tb_id =mlxsw_sp_ipip_dev_ul_tb_id (ipip_entry->ol_dev);/* Since the local address has changed, if there is another * tunnel with a matching saddr, both need to be demoted. */ if (mlxsw_sp_ipip_demote_tunnel_by_saddr (mlxsw_sp, -MLXSW_SP_L3_PROTO_IPV4 , - new_saddr, ul_tb_id, + new_parms->proto, + new_parms->saddr, + ul_tb_id, ipip_entry)) {mlxsw_sp_ipip_entry_demote_tunnel (mlxsw_sp, ipip_entry);return 0 ; } update_tunnel = true; - }else if ((mlxsw_sp_ipip_parms4_okey (&ipip_entry->parms4) != -mlxsw_sp_ipip_parms4_okey (&new_parms)) || - ipip_entry->parms4.link != new_parms.link) { + }else if (old_parms->okey != new_parms->okey || + old_parms->link != new_parms->link) { update_tunnel = true; - }else if (!mlxsw_sp_l3addr_eq (&new_daddr, &old_daddr)) { + }else if (!mlxsw_sp_l3addr_eq (&new_parms->daddr, &old_parms->daddr)) { update_nhs = true; - }else if (mlxsw_sp_ipip_parms4_ikey (&ipip_entry->parms4) != -mlxsw_sp_ipip_parms4_ikey (&new_parms)) { + }else if (old_parms->ikey != new_parms->ikey) { update_decap = true; }
@@ -288,14 +294,29 @@ mlxsw_sp_ipip_ol_netdev_change_gre4(struct mlxsw_sp *mlxsw_sp, err =__mlxsw_sp_ipip_entry_update_tunnel (mlxsw_sp, ipip_entry, false, false, false, extack); +if (err) +return err; + + ipip_entry->parms = *new_parms; +return 0 ; +} + +static int +mlxsw_sp_ipip_ol_netdev_change_gre4 (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_ipip_entry *ipip_entry, +struct netlink_ext_ack *extack) +{ +struct mlxsw_sp_ipip_parms new_parms; - ipip_entry->parms4 = new_parms; -return err; + new_parms =mlxsw_sp_ipip_netdev_parms_init_gre4 (ipip_entry->ol_dev); +return mlxsw_sp_ipip_ol_netdev_change_gre (mlxsw_sp, ipip_entry, + &new_parms, extack); }static const struct mlxsw_sp_ipip_ops mlxsw_sp_ipip_gre4_ops = { .dev_type =ARPHRD_IPGRE , .ul_proto =MLXSW_SP_L3_PROTO_IPV4 , + .parms_init = mlxsw_sp_ipip_netdev_parms_init_gre4, .nexthop_update = mlxsw_sp_ipip_nexthop_update_gre4, .decap_config = mlxsw_sp_ipip_decap_config_gre4, .can_offload = mlxsw_sp_ipip_can_offload_gre4,
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.h +13 -3
@@ -24,21 +24,31 @@ enum mlxsw_sp_ipip_type { MLXSW_SP_IPIP_TYPE_MAX, }; +struct mlxsw_sp_ipip_parms { +enum mlxsw_sp_l3proto proto; +union mlxsw_sp_l3addr saddr; +union mlxsw_sp_l3addr daddr; +int link; +u32 ikey; +u32 okey; +}; +struct mlxsw_sp_ipip_entry {enum mlxsw_sp_ipip_type ipipt;struct net_device *ol_dev;/* Overlay. */ struct mlxsw_sp_rif_ipip_lb *ol_lb;struct mlxsw_sp_fib_entry *decap_fib_entry;struct list_head ipip_list_node; -union { -struct ip_tunnel_parm parms4; - }; +struct mlxsw_sp_ipip_parms parms; };struct mlxsw_sp_ipip_ops {int dev_type;enum mlxsw_sp_l3proto ul_proto;/* Underlay. */ +struct mlxsw_sp_ipip_parms + (*parms_init)(const struct net_device *ol_dev); +int (*nexthop_update)(struct mlxsw_sp *mlxsw_sp,u32 adj_index,struct mlxsw_sp_ipip_entry *ipip_entry,bool force,char *ratr_pl);
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +1 -10
@@ -1131,16 +1131,7 @@ mlxsw_sp_ipip_entry_alloc(struct mlxsw_sp *mlxsw_sp, ipip_entry->ipipt = ipipt; ipip_entry->ol_dev = ol_dev; - -switch (ipip_ops->ul_proto) { -case MLXSW_SP_L3_PROTO_IPV4 : - ipip_entry->parms4 =mlxsw_sp_ipip_netdev_parms4 (ol_dev); -break ; -case MLXSW_SP_L3_PROTO_IPV6 : -WARN_ON (1 ); -break ; - } - + ipip_entry->parms = ipip_ops->parms_init (ol_dev);return ipip_entry; err_ol_ipip_lb_create:
Signature · 1 line
2.31.1
PATCH 5/14 mlxsw: Take tunnel's type into account when searching underlay device
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
The function __mlxsw_sp_ipip_netdev_ul_dev_get() returns the underlay device that corresponds to the overlay device that it gets. Currently, this function assumes that the tunnel is IPv4 GRE, because it is the only one that is supported by mlxsw driver.
This assumption will no longer be correct when IPv6 GRE support is added, resulting in wrong underlay device being returned.
Instead, check 'ol_dev->type' and return the underlay device accordingly.
Move the function to spectrum_ipip.c because spectrum_router.c should not be aware to tunnel type.
--- .../net/ethernet/mellanox/mlxsw/spectrum_ipip.c | 15 +++++++++++++++ .../ethernet/mellanox/mlxsw/spectrum_router.c | 17 ++++------------- .../ethernet/mellanox/mlxsw/spectrum_router.h | 2 ++ 3 files changed, 21 insertions(+), 13 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c +15 -0
@@ -384,3 +384,18 @@ int mlxsw_sp_ipip_ecn_decap_init(struct mlxsw_sp *mlxsw_sp)return 0 ; } + +struct net_device * +mlxsw_sp_ipip_netdev_ul_dev_get (const struct net_device *ol_dev) +{ +struct net *net =dev_net (ol_dev); +struct ip_tunnel *tun4; + +switch (ol_dev->type) { +case ARPHRD_IPGRE : + tun4 =netdev_priv (ol_dev); +return dev_get_by_index_rcu (net, tun4->parms.link); +default : +return NULL ; + } +}
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +4 -13
@@ -1055,22 +1055,13 @@ static void mlxsw_sp_vrs_fini(struct mlxsw_sp *mlxsw_sp)kfree (mlxsw_sp->router->vrs); } -static struct net_device * -__mlxsw_sp_ipip_netdev_ul_dev_get (const struct net_device *ol_dev) -{ -struct ip_tunnel *tun =netdev_priv (ol_dev); -struct net *net =dev_net (ol_dev); - -return dev_get_by_index_rcu (net, tun->parms.link); -} -u32 mlxsw_sp_ipip_dev_ul_tb_id (const struct net_device *ol_dev) {struct net_device *d;u32 tb_id;rcu_read_lock (); - d =__mlxsw_sp_ipip_netdev_ul_dev_get (ol_dev); + d =mlxsw_sp_ipip_netdev_ul_dev_get (ol_dev);if (d) tb_id =l3mdev_fib_table (d) ? :RT_TABLE_MAIN ;else
@@ -1441,7 +1432,7 @@ mlxsw_sp_ipip_entry_find_by_ul_dev(const struct mlxsw_sp *mlxsw_sp,struct net_device *ipip_ul_dev;rcu_read_lock (); - ipip_ul_dev =__mlxsw_sp_ipip_netdev_ul_dev_get (ol_dev); + ipip_ul_dev =mlxsw_sp_ipip_netdev_ul_dev_get (ol_dev);rcu_read_unlock ();if (ipip_ul_dev == ul_dev)
@@ -1821,7 +1812,7 @@ static void mlxsw_sp_ipip_demote_tunnel_by_ul_netdev(struct mlxsw_sp *mlxsw_sp,struct net_device *ipip_ul_dev;rcu_read_lock (); - ipip_ul_dev =__mlxsw_sp_ipip_netdev_ul_dev_get (ol_dev); + ipip_ul_dev =mlxsw_sp_ipip_netdev_ul_dev_get (ol_dev);rcu_read_unlock ();if (ipip_ul_dev == ul_dev)mlxsw_sp_ipip_entry_demote_tunnel (mlxsw_sp, ipip_entry);
@@ -4146,7 +4137,7 @@ static bool mlxsw_sp_ipip_netdev_ul_up(struct net_device *ol_dev)bool is_up;rcu_read_lock (); - ul_dev =__mlxsw_sp_ipip_netdev_ul_dev_get (ol_dev); + ul_dev =mlxsw_sp_ipip_netdev_ul_dev_get (ol_dev); is_up = ul_dev ? (ul_dev->flags &IFF_UP ) : true;rcu_read_unlock ();
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h +2 -0
@@ -226,6 +226,8 @@ static inline bool mlxsw_sp_l3addr_eq(const union mlxsw_sp_l3addr *addr1,int mlxsw_sp_ipip_ecn_encap_init (struct mlxsw_sp *mlxsw_sp);int mlxsw_sp_ipip_ecn_decap_init (struct mlxsw_sp *mlxsw_sp); +struct net_device * +mlxsw_sp_ipip_netdev_ul_dev_get (const struct net_device *ol_dev);extern const struct mlxsw_sp_router_ll_ops mlxsw_sp_router_ll_xm_ops;
Signature · 1 line
2.31.1
PATCH 6/14 mlxsw: reg: Add Router IP version Six Register
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
The RIPS register is used to store IPv6 addresses for use by the NVE and IP-in-IP.
For IPv6 underlay support, RATR register needs to hold a pointer to the remote IPv6 address for encapsulation and RTDP register needs to hold a pointer to the local IPv6 address for decapsulation check.
Add the required register for saving IPv6 addresses.
--- drivers/net/ethernet/mellanox/mlxsw/reg.h | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/reg.h +32 -0
@@ -8200,6 +8200,37 @@ mlxsw_reg_rtdp_ipip4_pack(char *payload, u16 irif,mlxsw_reg_rtdp_ipip_expected_gre_key_set (payload, expected_gre_key); } +/* RIPS - Router IP version Six Register +* ------------------------------------- +* The RIPS register is used to store IPv6 addresses for use by the NVE and +* IPinIP +*/ +#define MLXSW_REG_RIPS_ID 0x8021 +#define MLXSW_REG_RIPS_LEN 0x14 + +MLXSW_REG_DEFINE (rips,MLXSW_REG_RIPS_ID ,MLXSW_REG_RIPS_LEN ); + +/* reg_rips_index +* Index to IPv6 address. +* For Spectrum, the index is to the KVD linear. +* Access: Index +*/ +MLXSW_ITEM32 (reg, rips, index,0x00 ,0 ,24 ); + +/* reg_rips_ipv6 +* IPv6 address +* Access: RW +*/ +MLXSW_ITEM_BUF (reg, rips, ipv6,0x04 ,16 ); + +static inline void mlxsw_reg_rips_pack (char *payload,u32 index, +const struct in6_addr *ipv6) +{ +MLXSW_REG_ZERO (rips, payload); +mlxsw_reg_rips_index_set (payload, index); +mlxsw_reg_rips_ipv6_memcpy_to (payload, (const char *)ipv6); +} +/* RATRAD - Router Adjacency Table Activity Dump Register * ------------------------------------------------------ * The RATRAD register is used to dump and optionally clear activity bits of
@@ -12281,6 +12312,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {MLXSW_REG (rtar),MLXSW_REG (ratr),MLXSW_REG (rtdp), +MLXSW_REG (rips),MLXSW_REG (ratrad),MLXSW_REG (rdpm), MLXSW_REG(ricnt),
Signature · 1 line
2.31.1
PATCH 7/14 mlxsw: reg: Add support for rtdp_ipip6_pack()
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
The RTDP register is used for configuring the tunnel decapsulation properties of NVE and IP-in-IP.
Linux tunnels verify packets before decapsulation based on the packet's source IP, which must match tunnel remote IP.
RTDP is used to configure decapsulation so that it filters out packets that are not IPv6 or have the wrong source IP or wrong GRE key.
For IP-in-IP entry, source IPv4 is saved as part of this register and source IPv6 is saved by RIPS register and RTDP saves pointer to it.
Create common function for configuring both IPv4 and IPv6 and add dedicated functions for each protocol.
--- drivers/net/ethernet/mellanox/mlxsw/reg.h | 31 +++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/reg.h +26 -5
@@ -8187,19 +8187,40 @@ static inline void mlxsw_reg_rtdp_pack(char *payload, }static inline void -mlxsw_reg_rtdp_ipip4_pack (char *payload,u16 irif, -enum mlxsw_reg_rtdp_ipip_sip_check sip_check, -unsigned int type_check,bool gre_key_check, -u32 ipv4_usip,u32 expected_gre_key) +mlxsw_reg_rtdp_ipip_pack (char *payload,u16 irif, +enum mlxsw_reg_rtdp_ipip_sip_check sip_check, +unsigned int type_check,bool gre_key_check, +u32 expected_gre_key) {mlxsw_reg_rtdp_ipip_irif_set (payload, irif);mlxsw_reg_rtdp_ipip_sip_check_set (payload, sip_check);mlxsw_reg_rtdp_ipip_type_check_set (payload, type_check);mlxsw_reg_rtdp_ipip_gre_key_check_set (payload, gre_key_check); -mlxsw_reg_rtdp_ipip_ipv4_usip_set (payload, ipv4_usip);mlxsw_reg_rtdp_ipip_expected_gre_key_set (payload, expected_gre_key); } +static inline void +mlxsw_reg_rtdp_ipip4_pack (char *payload,u16 irif, +enum mlxsw_reg_rtdp_ipip_sip_check sip_check, +unsigned int type_check,bool gre_key_check, +u32 ipv4_usip,u32 expected_gre_key) +{ +mlxsw_reg_rtdp_ipip_pack (payload, irif, sip_check, type_check, + gre_key_check, expected_gre_key); +mlxsw_reg_rtdp_ipip_ipv4_usip_set (payload, ipv4_usip); +} + +static inline void +mlxsw_reg_rtdp_ipip6_pack (char *payload,u16 irif, +enum mlxsw_reg_rtdp_ipip_sip_check sip_check, +unsigned int type_check,bool gre_key_check, +u32 ipv6_usip_ptr,u32 expected_gre_key) +{ +mlxsw_reg_rtdp_ipip_pack (payload, irif, sip_check, type_check, + gre_key_check, expected_gre_key); +mlxsw_reg_rtdp_ipip_ipv6_usip_ptr_set (payload, ipv6_usip_ptr); +} +/* RIPS - Router IP version Six Register * ------------------------------------- * The RIPS register is used to store IPv6 addresses for use by the NVE and
Signature · 1 line
2.31.1
PATCH 8/14 mlxsw: reg: Add support for ratr_ipip6_entry_pack()
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
The RATR register is used to configure the Router Adjacency (next-hop) Table.
For IP-in-IP entry, underlay destination IPv4 is saved as part of this register and underlay destination IPv6 is saved by RIPS register and RATR saves pointer to it.
Add function for setting IPv6 IP-in-IP configuration.
--- drivers/net/ethernet/mellanox/mlxsw/reg.h | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/reg.h +6 -0
@@ -7002,6 +7002,12 @@ static inline void mlxsw_reg_ratr_ipip4_entry_pack(char *payload, u32 ipv4_udip)mlxsw_reg_ratr_ipip_ipv4_udip_set (payload, ipv4_udip); } +static inline void mlxsw_reg_ratr_ipip6_entry_pack (char *payload,u32 ipv6_ptr) +{ +mlxsw_reg_ratr_ipip_type_set (payload,MLXSW_REG_RATR_IPIP_TYPE_IPV6 ); +mlxsw_reg_ratr_ipip_ipv6_ptr_set (payload, ipv6_ptr); +} +static inline void mlxsw_reg_ratr_counter_pack (char *payload,u64 counter_index,bool counter_enable) {
Signature · 1 line
2.31.1
PATCH 9/14 mlxsw: reg: Add support for ritr_loopback_ipip6_pack()
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
The RITR register is used to configure the router interface table.
For IP-in-IP, it stores the underlay source IP address for encapsulation and also the ingress RIF for the underlay lookup.
Add support for IPv6 IP-in-IP configuration.
--- drivers/net/ethernet/mellanox/mlxsw/reg.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/reg.h +17 -0
@@ -6734,6 +6734,23 @@ mlxsw_reg_ritr_loopback_ipip4_pack(char *payload,mlxsw_reg_ritr_loopback_ipip_usip4_set (payload, usip); } +static inline void +mlxsw_reg_ritr_loopback_ipip6_pack (char *payload, +enum mlxsw_reg_ritr_loopback_ipip_type ipip_type, +enum mlxsw_reg_ritr_loopback_ipip_options options, +u16 uvr_id,u16 underlay_rif, +const struct in6_addr *usip,u32 gre_key) +{ +enum mlxsw_reg_ritr_loopback_protocol protocol = +MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6 ; + +mlxsw_reg_ritr_loopback_protocol_set (payload, protocol); +mlxsw_reg_ritr_loopback_ipip_common_pack (payload, ipip_type, options, + uvr_id, underlay_rif, gre_key); +mlxsw_reg_ritr_loopback_ipip_usip6_memcpy_to (payload, + (const char *)usip); +} +/* RTAR - Router TCAM Allocation Register * -------------------------------------- * This register is used for allocation of regions in the TCAM table.
Signature · 1 line
2.31.1
PATCH 10/14 mlxsw: Create separate ipip_ops_arr for different ASICs
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
Currently, there is support for IP-in-IP only with IPv4 underlay for all supported Spectrum ASICs.
The next patches will add support for IPv6 underlay only for Spectrum-2 and above.
Add infrastructure for splitting IP-in-IP support between different ASICs - create separate ipip_ops_arr and add ipips_init function to set the right ops.
--- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 6 +++++- .../ethernet/mellanox/mlxsw/spectrum_ipip.h | 3 ++- .../ethernet/mellanox/mlxsw/spectrum_router.c | 18 ++++++++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c +5 -1
@@ -324,7 +324,11 @@ static const struct mlxsw_sp_ipip_ops mlxsw_sp_ipip_gre4_ops = { .ol_netdev_change = mlxsw_sp_ipip_ol_netdev_change_gre4, }; -const struct mlxsw_sp_ipip_ops *mlxsw_sp_ipip_ops_arr[] = { +const struct mlxsw_sp_ipip_ops *mlxsw_sp1_ipip_ops_arr[] = { + [MLXSW_SP_IPIP_TYPE_GRE4 ] = &mlxsw_sp_ipip_gre4_ops, +}; + +const struct mlxsw_sp_ipip_ops *mlxsw_sp2_ipip_ops_arr[] = { [MLXSW_SP_IPIP_TYPE_GRE4 ] = &mlxsw_sp_ipip_gre4_ops, };
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.h +2 -1
@@ -70,6 +70,7 @@ struct mlxsw_sp_ipip_ops { struct netlink_ext_ack *extack); }; -extern const struct mlxsw_sp_ipip_ops *mlxsw_sp_ipip_ops_arr[]; +extern const struct mlxsw_sp_ipip_ops *mlxsw_sp1_ipip_ops_arr[]; +extern const struct mlxsw_sp_ipip_ops *mlxsw_sp2_ipip_ops_arr[];#endif /* _MLXSW_IPIP_H_*/
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +16 -2
@@ -115,6 +115,7 @@ struct mlxsw_sp_rif_ops {struct mlxsw_sp_router_ops {int (*init)(struct mlxsw_sp *mlxsw_sp); +int (*ipips_init)(struct mlxsw_sp *mlxsw_sp); }; static struct mlxsw_sp_rif *
@@ -9468,7 +9469,6 @@ static int mlxsw_sp_ipips_init(struct mlxsw_sp *mlxsw_sp) {int err; - mlxsw_sp->router->ipip_ops_arr = mlxsw_sp_ipip_ops_arr;INIT_LIST_HEAD (&mlxsw_sp->router->ipip_list); err =mlxsw_sp_ipip_ecn_encap_init (mlxsw_sp);
@@ -9481,6 +9481,18 @@ static int mlxsw_sp_ipips_init(struct mlxsw_sp *mlxsw_sp)return mlxsw_sp_ipip_config_tigcr (mlxsw_sp); } +static int mlxsw_sp1_ipips_init (struct mlxsw_sp *mlxsw_sp) +{ + mlxsw_sp->router->ipip_ops_arr = mlxsw_sp1_ipip_ops_arr; +return mlxsw_sp_ipips_init (mlxsw_sp); +} + +static int mlxsw_sp2_ipips_init (struct mlxsw_sp *mlxsw_sp) +{ + mlxsw_sp->router->ipip_ops_arr = mlxsw_sp2_ipip_ops_arr; +return mlxsw_sp_ipips_init (mlxsw_sp); +} +static void mlxsw_sp_ipips_fini (struct mlxsw_sp *mlxsw_sp) {WARN_ON (!list_empty (&mlxsw_sp->router->ipip_list));
@@ -9895,6 +9907,7 @@ static int mlxsw_sp1_router_init(struct mlxsw_sp *mlxsw_sp)const struct mlxsw_sp_router_ops mlxsw_sp1_router_ops = { .init = mlxsw_sp1_router_init, + .ipips_init = mlxsw_sp1_ipips_init, };static int mlxsw_sp2_router_init (struct mlxsw_sp *mlxsw_sp)
@@ -9910,6 +9923,7 @@ static int mlxsw_sp2_router_init(struct mlxsw_sp *mlxsw_sp)const struct mlxsw_sp_router_ops mlxsw_sp2_router_ops = { .init = mlxsw_sp2_router_init, + .ipips_init = mlxsw_sp2_ipips_init, }; int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp,
@@ -9955,7 +9969,7 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp,if (err) goto err_rifs_init; - err =mlxsw_sp_ipips_init (mlxsw_sp); + err = mlxsw_sp->router_ops->ipips_init (mlxsw_sp);if (err) goto err_ipips_init;
Signature · 1 line
2.31.1
PATCH 11/14 mlxsw: spectrum_ipip: Add mlxsw_sp_ipip_gre6_ops
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
Add operations for IP-in-IP GRE6. For now the function can_offload() returns false and the other functions warn as they should never be called.
A later patch will add dedicated operations for Spectrum-2 which will support IPv6 underlay, so use 'mlxsw_sp1_' prefix for the new operations.
--- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 65 +++++++++++++++++++ .../ethernet/mellanox/mlxsw/spectrum_ipip.h | 1 + 2 files changed, 66 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c +65 -0
@@ -324,12 +324,77 @@ static const struct mlxsw_sp_ipip_ops mlxsw_sp_ipip_gre4_ops = { .ol_netdev_change = mlxsw_sp_ipip_ol_netdev_change_gre4, }; +static struct mlxsw_sp_ipip_parms +mlxsw_sp1_ipip_netdev_parms_init_gre6 (const struct net_device *ol_dev) +{ +struct mlxsw_sp_ipip_parms parms = {0 }; + +WARN_ON_ONCE (1 ); +return parms; +} + +static int +mlxsw_sp1_ipip_nexthop_update_gre6 (struct mlxsw_sp *mlxsw_sp,u32 adj_index, +struct mlxsw_sp_ipip_entry *ipip_entry, +bool force,char *ratr_pl) +{ +WARN_ON_ONCE (1 ); +return -EINVAL ; +} + +static int +mlxsw_sp1_ipip_decap_config_gre6 (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_ipip_entry *ipip_entry, +u32 tunnel_index) +{ +WARN_ON_ONCE (1 ); +return -EINVAL ; +} + +static bool mlxsw_sp1_ipip_can_offload_gre6 (const struct mlxsw_sp *mlxsw_sp, +const struct net_device *ol_dev) +{ +return false; +} + +static struct mlxsw_sp_rif_ipip_lb_config +mlxsw_sp1_ipip_ol_loopback_config_gre6 (struct mlxsw_sp *mlxsw_sp, +const struct net_device *ol_dev) +{ +struct mlxsw_sp_rif_ipip_lb_config config = {0 }; + +WARN_ON_ONCE (1 ); +return config; +} + +static int +mlxsw_sp1_ipip_ol_netdev_change_gre6 (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_ipip_entry *ipip_entry, +struct netlink_ext_ack *extack) +{ +WARN_ON_ONCE (1 ); +return -EINVAL ; +} + +static const struct mlxsw_sp_ipip_ops mlxsw_sp1_ipip_gre6_ops = { + .dev_type =ARPHRD_IP6GRE , + .ul_proto =MLXSW_SP_L3_PROTO_IPV6 , + .parms_init = mlxsw_sp1_ipip_netdev_parms_init_gre6, + .nexthop_update = mlxsw_sp1_ipip_nexthop_update_gre6, + .decap_config = mlxsw_sp1_ipip_decap_config_gre6, + .can_offload = mlxsw_sp1_ipip_can_offload_gre6, + .ol_loopback_config = mlxsw_sp1_ipip_ol_loopback_config_gre6, + .ol_netdev_change = mlxsw_sp1_ipip_ol_netdev_change_gre6, +}; +const struct mlxsw_sp_ipip_ops *mlxsw_sp1_ipip_ops_arr[] = { [MLXSW_SP_IPIP_TYPE_GRE4 ] = &mlxsw_sp_ipip_gre4_ops, + [MLXSW_SP_IPIP_TYPE_GRE6 ] = &mlxsw_sp1_ipip_gre6_ops, };const struct mlxsw_sp_ipip_ops *mlxsw_sp2_ipip_ops_arr[] = { [MLXSW_SP_IPIP_TYPE_GRE4 ] = &mlxsw_sp_ipip_gre4_ops, + [MLXSW_SP_IPIP_TYPE_GRE6 ] = &mlxsw_sp1_ipip_gre6_ops, }; static int mlxsw_sp_ipip_ecn_encap_init_one(struct mlxsw_sp *mlxsw_sp,
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.h +1 -0
@@ -21,6 +21,7 @@ bool mlxsw_sp_l3addr_is_zero(union mlxsw_sp_l3addr addr);enum mlxsw_sp_ipip_type {MLXSW_SP_IPIP_TYPE_GRE4 , +MLXSW_SP_IPIP_TYPE_GRE6 ,MLXSW_SP_IPIP_TYPE_MAX , };
Signature · 1 line
2.31.1
PATCH 12/14 mlxsw: Add IPV6_ADDRESS kvdl entry type
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
Add support for allocating and freeing KVD entries for IPv6 addresses.
These addresses are programmed by the RIPS register and referenced by the RATR and RTDP registers for IPv6 underlay encapsulation and decapsulation, respectively.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 2 ++ drivers/net/ethernet/mellanox/mlxsw/spectrum2_kvdl.c | 1 + 2 files changed, 3 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +2 -0
@@ -747,6 +747,7 @@ enum mlxsw_sp_kvdl_entry_type {MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET ,MLXSW_SP_KVDL_ENTRY_TYPE_PBS ,MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR , +MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS , MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT, };
@@ -758,6 +759,7 @@ mlxsw_sp_kvdl_entry_size(enum mlxsw_sp_kvdl_entry_type type)case MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET :case MLXSW_SP_KVDL_ENTRY_TYPE_PBS :case MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR : +case MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS :case MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT :default :return 1 ;
drivers/net/ethernet/mellanox/mlxsw/spectrum2_kvdl.c +1 -0
@@ -35,6 +35,7 @@ static const struct mlxsw_sp2_kvdl_part_info mlxsw_sp2_kvdl_parts_info[] = { MAX_KVD_ACTION_SETS),MLXSW_SP2_KVDL_PART_INFO (PBS ,0x24 ,KVD_SIZE ,KVD_SIZE ),MLXSW_SP2_KVDL_PART_INFO (MCRIGR ,0x26 ,KVD_SIZE ,KVD_SIZE ), +MLXSW_SP2_KVDL_PART_INFO (IPV6_ADDRESS ,0x28 ,KVD_SIZE ,KVD_SIZE ), MLXSW_SP2_KVDL_PART_INFO(TNUMT, 0x29, KVD_SIZE, KVD_SIZE), };
Signature · 1 line
2.31.1
PATCH 13/14 mlxsw: spectrum_router: Increase parsing depth for IPv6 decapsulation
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
The Spectrum ASIC has a configurable limit on how deep into the packet it parses. By default, the limit is 96 bytes.
For IP-in-IP packets, with IPv6 outer and inner headers, the default parsing depth is not enough and without increasing it such packets cannot be properly decapsulated.
Use the existing API to set parsing depth, call it once for each decapsulation entry when it is created/destroyed.
There is no need to protect the code with new mutex because 'router->lock' is already taken in these code paths.
--- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 2 + .../ethernet/mellanox/mlxsw/spectrum_ipip.h | 1 + .../ethernet/mellanox/mlxsw/spectrum_router.c | 40 +++++++++++++++++++ 3 files changed, 43 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c +2 -0
@@ -316,6 +316,7 @@ mlxsw_sp_ipip_ol_netdev_change_gre4(struct mlxsw_sp *mlxsw_sp,static const struct mlxsw_sp_ipip_ops mlxsw_sp_ipip_gre4_ops = { .dev_type =ARPHRD_IPGRE , .ul_proto =MLXSW_SP_L3_PROTO_IPV4 , + .inc_parsing_depth = false, .parms_init = mlxsw_sp_ipip_netdev_parms_init_gre4, .nexthop_update = mlxsw_sp_ipip_nexthop_update_gre4, .decap_config = mlxsw_sp_ipip_decap_config_gre4,
@@ -379,6 +380,7 @@ mlxsw_sp1_ipip_ol_netdev_change_gre6(struct mlxsw_sp *mlxsw_sp,static const struct mlxsw_sp_ipip_ops mlxsw_sp1_ipip_gre6_ops = { .dev_type =ARPHRD_IP6GRE , .ul_proto =MLXSW_SP_L3_PROTO_IPV6 , + .inc_parsing_depth = true, .parms_init = mlxsw_sp1_ipip_netdev_parms_init_gre6, .nexthop_update = mlxsw_sp1_ipip_nexthop_update_gre6, .decap_config = mlxsw_sp1_ipip_decap_config_gre6,
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.h +1 -0
@@ -46,6 +46,7 @@ struct mlxsw_sp_ipip_entry {struct mlxsw_sp_ipip_ops {int dev_type;enum mlxsw_sp_l3proto ul_proto;/* Underlay. */ +bool inc_parsing_depth;struct mlxsw_sp_ipip_parms (*parms_init)(const struct net_device *ol_dev);
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +40 -0
@@ -1157,6 +1157,32 @@ mlxsw_sp_ipip_entry_saddr_matches(struct mlxsw_sp *mlxsw_sp,mlxsw_sp_l3addr_eq (&tun_saddr, &saddr); } +static int mlxsw_sp_ipip_decap_parsing_depth_inc (struct mlxsw_sp *mlxsw_sp, +enum mlxsw_sp_ipip_type ipipt) +{ +const struct mlxsw_sp_ipip_ops *ipip_ops; + + ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipipt]; + +/* Not all tunnels require to increase the default pasing depth +* (96 bytes). +*/ +if (ipip_ops->inc_parsing_depth) +return mlxsw_sp_parsing_depth_inc (mlxsw_sp); + +return 0 ; +} + +static void mlxsw_sp_ipip_decap_parsing_depth_dec (struct mlxsw_sp *mlxsw_sp, +enum mlxsw_sp_ipip_type ipipt) +{ +const struct mlxsw_sp_ipip_ops *ipip_ops = + mlxsw_sp->router->ipip_ops_arr[ipipt]; + +if (ipip_ops->inc_parsing_depth) +mlxsw_sp_parsing_depth_dec (mlxsw_sp); +} + static int mlxsw_sp_fib_entry_decap_init(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fib_entry *fib_entry,
@@ -1170,18 +1196,32 @@ mlxsw_sp_fib_entry_decap_init(struct mlxsw_sp *mlxsw_sp,if (err)return err; + err =mlxsw_sp_ipip_decap_parsing_depth_inc (mlxsw_sp, + ipip_entry->ipipt); +if (err) + goto err_parsing_depth_inc; + ipip_entry->decap_fib_entry = fib_entry; fib_entry->decap.ipip_entry = ipip_entry; fib_entry->decap.tunnel_index = tunnel_index; +return 0 ; + +err_parsing_depth_inc: +mlxsw_sp_kvdl_free (mlxsw_sp,MLXSW_SP_KVDL_ENTRY_TYPE_ADJ ,1 , + fib_entry->decap.tunnel_index); +return err; }static void mlxsw_sp_fib_entry_decap_fini (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_fib_entry *fib_entry) { +enum mlxsw_sp_ipip_type ipipt = fib_entry->decap.ipip_entry->ipipt; +/* Unlink this node from the IPIP entry that it's the decap entry of. */ fib_entry->decap.ipip_entry->decap_fib_entry =NULL ; fib_entry->decap.ipip_entry =NULL ; +mlxsw_sp_ipip_decap_parsing_depth_dec (mlxsw_sp, ipipt);mlxsw_sp_kvdl_free (mlxsw_sp,MLXSW_SP_KVDL_ENTRY_TYPE_ADJ ,1 , fib_entry->decap.tunnel_index); }
Signature · 1 line
2.31.1
PATCH 14/14 mlxsw: Add support for IP-in-IP with IPv6 underlay for Spectrum-2 and above
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
Currently, mlxsw driver supports IP-in-IP only with IPv4 underlay. Add support for IPv6 underlay for Spectrum-2 and above.
Most of the configurations are same to IPv4, the main difference between IPv4 and IPv6 is related to saving IP addresses.
IPv6 addresses are saved as part of KVD and the relevant registers hold pointer to them.
Add API for that as part of ipip_ops, so then only Spectrum-2 and above will save IPv6 addresses in this way.
--- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 227 +++++++++++++++++- .../ethernet/mellanox/mlxsw/spectrum_ipip.h | 6 + .../ethernet/mellanox/mlxsw/spectrum_router.c | 86 ++++++- 3 files changed, 309 insertions(+), 10 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c +226 -1
@@ -29,23 +29,45 @@ static bool mlxsw_sp_ipip_parms4_has_ikey(const struct ip_tunnel_parm *parms)return !!(parms->i_flags &TUNNEL_KEY ); } +static bool mlxsw_sp_ipip_parms6_has_ikey (const struct __ip6_tnl_parm *parms) +{ +return !!(parms->i_flags &TUNNEL_KEY ); +} +static bool mlxsw_sp_ipip_parms4_has_okey (const struct ip_tunnel_parm *parms) {return !!(parms->o_flags &TUNNEL_KEY ); } +static bool mlxsw_sp_ipip_parms6_has_okey (const struct __ip6_tnl_parm *parms) +{ +return !!(parms->o_flags &TUNNEL_KEY ); +} +static u32 mlxsw_sp_ipip_parms4_ikey (const struct ip_tunnel_parm *parms) {return mlxsw_sp_ipip_parms4_has_ikey (parms) ?be32_to_cpu (parms->i_key) :0 ; } +static u32 mlxsw_sp_ipip_parms6_ikey (const struct __ip6_tnl_parm *parms) +{ +return mlxsw_sp_ipip_parms6_has_ikey (parms) ? +be32_to_cpu (parms->i_key) :0 ; +} +static u32 mlxsw_sp_ipip_parms4_okey (const struct ip_tunnel_parm *parms) {return mlxsw_sp_ipip_parms4_has_okey (parms) ?be32_to_cpu (parms->o_key) :0 ; } +static u32 mlxsw_sp_ipip_parms6_okey (const struct __ip6_tnl_parm *parms) +{ +return mlxsw_sp_ipip_parms6_has_okey (parms) ? +be32_to_cpu (parms->o_key) :0 ; +} +static union mlxsw_sp_l3addr mlxsw_sp_ipip_parms4_saddr (const struct ip_tunnel_parm *parms) {
@@ -313,6 +335,19 @@ mlxsw_sp_ipip_ol_netdev_change_gre4(struct mlxsw_sp *mlxsw_sp, &new_parms, extack); } +static int +mlxsw_sp_ipip_rem_addr_set_gre4 (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_ipip_entry *ipip_entry) +{ +return 0 ; +} + +static void +mlxsw_sp_ipip_rem_addr_unset_gre4 (struct mlxsw_sp *mlxsw_sp, +const struct mlxsw_sp_ipip_entry *ipip_entry) +{ +} +static const struct mlxsw_sp_ipip_ops mlxsw_sp_ipip_gre4_ops = { .dev_type =ARPHRD_IPGRE , .ul_proto =MLXSW_SP_L3_PROTO_IPV4 ,
@@ -323,6 +358,8 @@ static const struct mlxsw_sp_ipip_ops mlxsw_sp_ipip_gre4_ops = { .can_offload = mlxsw_sp_ipip_can_offload_gre4, .ol_loopback_config = mlxsw_sp_ipip_ol_loopback_config_gre4, .ol_netdev_change = mlxsw_sp_ipip_ol_netdev_change_gre4, + .rem_ip_addr_set = mlxsw_sp_ipip_rem_addr_set_gre4, + .rem_ip_addr_unset = mlxsw_sp_ipip_rem_addr_unset_gre4, }; static struct mlxsw_sp_ipip_parms
@@ -377,6 +414,21 @@ mlxsw_sp1_ipip_ol_netdev_change_gre6(struct mlxsw_sp *mlxsw_sp,return -EINVAL ; } +static int +mlxsw_sp1_ipip_rem_addr_set_gre6 (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_ipip_entry *ipip_entry) +{ +WARN_ON_ONCE (1 ); +return -EINVAL ; +} + +static void +mlxsw_sp1_ipip_rem_addr_unset_gre6 (struct mlxsw_sp *mlxsw_sp, +const struct mlxsw_sp_ipip_entry *ipip_entry) +{ +WARN_ON_ONCE (1 ); +} +static const struct mlxsw_sp_ipip_ops mlxsw_sp1_ipip_gre6_ops = { .dev_type =ARPHRD_IP6GRE , .ul_proto =MLXSW_SP_L3_PROTO_IPV6 ,
@@ -387,6 +439,8 @@ static const struct mlxsw_sp_ipip_ops mlxsw_sp1_ipip_gre6_ops = { .can_offload = mlxsw_sp1_ipip_can_offload_gre6, .ol_loopback_config = mlxsw_sp1_ipip_ol_loopback_config_gre6, .ol_netdev_change = mlxsw_sp1_ipip_ol_netdev_change_gre6, + .rem_ip_addr_set = mlxsw_sp1_ipip_rem_addr_set_gre6, + .rem_ip_addr_unset = mlxsw_sp1_ipip_rem_addr_unset_gre6, };const struct mlxsw_sp_ipip_ops *mlxsw_sp1_ipip_ops_arr[] = {
@@ -394,9 +448,176 @@ const struct mlxsw_sp_ipip_ops *mlxsw_sp1_ipip_ops_arr[] = { [MLXSW_SP_IPIP_TYPE_GRE6] = &mlxsw_sp1_ipip_gre6_ops, }; +static struct mlxsw_sp_ipip_parms +mlxsw_sp2_ipip_netdev_parms_init_gre6 (const struct net_device *ol_dev) +{ +struct __ip6_tnl_parm parms =mlxsw_sp_ipip_netdev_parms6 (ol_dev); + +return (struct mlxsw_sp_ipip_parms ) { + .proto =MLXSW_SP_L3_PROTO_IPV6 , + .saddr =mlxsw_sp_ipip_parms6_saddr (&parms), + .daddr =mlxsw_sp_ipip_parms6_daddr (&parms), + .link = parms.link, + .ikey =mlxsw_sp_ipip_parms6_ikey (&parms), + .okey =mlxsw_sp_ipip_parms6_okey (&parms), + }; +} + +static int +mlxsw_sp2_ipip_nexthop_update_gre6 (struct mlxsw_sp *mlxsw_sp,u32 adj_index, +struct mlxsw_sp_ipip_entry *ipip_entry, +bool force,char *ratr_pl) +{ +u16 rif_index =mlxsw_sp_ipip_lb_rif_index (ipip_entry->ol_lb); +enum mlxsw_reg_ratr_op op; + + op = force ?MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY : +MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY ; +mlxsw_reg_ratr_pack (ratr_pl, op, true,MLXSW_REG_RATR_TYPE_IPIP , + adj_index, rif_index); +mlxsw_reg_ratr_ipip6_entry_pack (ratr_pl, + ipip_entry->dip_kvdl_index); + +return mlxsw_reg_write (mlxsw_sp->core,MLXSW_REG (ratr), ratr_pl); +} + +static int +mlxsw_sp2_ipip_decap_config_gre6 (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_ipip_entry *ipip_entry, +u32 tunnel_index) +{ +u16 rif_index =mlxsw_sp_ipip_lb_rif_index (ipip_entry->ol_lb); +u16 ul_rif_id =mlxsw_sp_ipip_lb_ul_rif_id (ipip_entry->ol_lb); +char rtdp_pl[MLXSW_REG_RTDP_LEN ]; +struct __ip6_tnl_parm parms; +unsigned int type_check; +bool has_ikey; +u32 ikey; + + parms =mlxsw_sp_ipip_netdev_parms6 (ipip_entry->ol_dev); + has_ikey =mlxsw_sp_ipip_parms6_has_ikey (&parms); + ikey =mlxsw_sp_ipip_parms6_ikey (&parms); + +mlxsw_reg_rtdp_pack (rtdp_pl,MLXSW_REG_RTDP_TYPE_IPIP , tunnel_index); +mlxsw_reg_rtdp_egress_router_interface_set (rtdp_pl, ul_rif_id); + + type_check = has_ikey ? +MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE_KEY : +MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE ; + +/* Linux demuxes tunnels based on packet SIP (which must match tunnel +* remote IP). Thus configure decap so that it filters out packets that +* are not IPv6 or have the wrong SIP. IPIP_DECAP_ERROR trap is +* generated for packets that fail this criterion. Linux then handles +* such packets in slow path and generates ICMP destination unreachable. +*/ +mlxsw_reg_rtdp_ipip6_pack (rtdp_pl, rif_index, +MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6 , + type_check, has_ikey, + ipip_entry->dip_kvdl_index, ikey); + +return mlxsw_reg_write (mlxsw_sp->core,MLXSW_REG (rtdp), rtdp_pl); +} + +static bool mlxsw_sp2_ipip_can_offload_gre6 (const struct mlxsw_sp *mlxsw_sp, +const struct net_device *ol_dev) +{ +struct __ip6_tnl_parm tparm =mlxsw_sp_ipip_netdev_parms6 (ol_dev); +bool inherit_tos = tparm.flags &IP6_TNL_F_USE_ORIG_TCLASS ; +bool inherit_ttl = tparm.hop_limit ==0 ; +__be16 okflags =TUNNEL_KEY ;/* We can't offload any other features. */ + +return (tparm.i_flags & ~okflags) ==0 && + (tparm.o_flags & ~okflags) ==0 && + inherit_ttl && inherit_tos && +mlxsw_sp_ipip_tunnel_complete (MLXSW_SP_L3_PROTO_IPV6 , ol_dev); +} + +static struct mlxsw_sp_rif_ipip_lb_config +mlxsw_sp2_ipip_ol_loopback_config_gre6 (struct mlxsw_sp *mlxsw_sp, +const struct net_device *ol_dev) +{ +struct __ip6_tnl_parm parms =mlxsw_sp_ipip_netdev_parms6 (ol_dev); +enum mlxsw_reg_ritr_loopback_ipip_type lb_ipipt; + + lb_ipipt =mlxsw_sp_ipip_parms6_has_okey (&parms) ? +MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_KEY_IN_IP : +MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_IN_IP ; +return (struct mlxsw_sp_rif_ipip_lb_config ){ + .lb_ipipt = lb_ipipt, + .okey =mlxsw_sp_ipip_parms6_okey (&parms), + .ul_protocol =MLXSW_SP_L3_PROTO_IPV6 , + .saddr =mlxsw_sp_ipip_netdev_saddr (MLXSW_SP_L3_PROTO_IPV6 , + ol_dev), + }; +} + +static int +mlxsw_sp2_ipip_ol_netdev_change_gre6 (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_ipip_entry *ipip_entry, +struct netlink_ext_ack *extack) +{ +struct mlxsw_sp_ipip_parms new_parms; + + new_parms =mlxsw_sp2_ipip_netdev_parms_init_gre6 (ipip_entry->ol_dev); +return mlxsw_sp_ipip_ol_netdev_change_gre (mlxsw_sp, ipip_entry, + &new_parms, extack); +} + +static int +mlxsw_sp2_ipip_rem_addr_set_gre6 (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_ipip_entry *ipip_entry) +{ +char rips_pl[MLXSW_REG_RIPS_LEN ]; +struct __ip6_tnl_parm parms6; +int err; + + err =mlxsw_sp_kvdl_alloc (mlxsw_sp, +MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS ,1 , + &ipip_entry->dip_kvdl_index); +if (err) +return err; + + parms6 =mlxsw_sp_ipip_netdev_parms6 (ipip_entry->ol_dev); +mlxsw_reg_rips_pack (rips_pl, ipip_entry->dip_kvdl_index, + &parms6.raddr); + err =mlxsw_reg_write (mlxsw_sp->core,MLXSW_REG (rips), rips_pl); +if (err) + goto err_rips_write; + +return 0 ; + +err_rips_write: +mlxsw_sp_kvdl_free (mlxsw_sp,MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS ,1 , + ipip_entry->dip_kvdl_index); +return err; +} + +static void +mlxsw_sp2_ipip_rem_addr_unset_gre6 (struct mlxsw_sp *mlxsw_sp, +const struct mlxsw_sp_ipip_entry *ipip_entry) +{ +mlxsw_sp_kvdl_free (mlxsw_sp,MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS ,1 , + ipip_entry->dip_kvdl_index); +} + +static const struct mlxsw_sp_ipip_ops mlxsw_sp2_ipip_gre6_ops = { + .dev_type =ARPHRD_IP6GRE , + .ul_proto =MLXSW_SP_L3_PROTO_IPV6 , + .inc_parsing_depth = true, + .parms_init = mlxsw_sp2_ipip_netdev_parms_init_gre6, + .nexthop_update = mlxsw_sp2_ipip_nexthop_update_gre6, + .decap_config = mlxsw_sp2_ipip_decap_config_gre6, + .can_offload = mlxsw_sp2_ipip_can_offload_gre6, + .ol_loopback_config = mlxsw_sp2_ipip_ol_loopback_config_gre6, + .ol_netdev_change = mlxsw_sp2_ipip_ol_netdev_change_gre6, + .rem_ip_addr_set = mlxsw_sp2_ipip_rem_addr_set_gre6, + .rem_ip_addr_unset = mlxsw_sp2_ipip_rem_addr_unset_gre6, +}; +const struct mlxsw_sp_ipip_ops *mlxsw_sp2_ipip_ops_arr[] = { [MLXSW_SP_IPIP_TYPE_GRE4 ] = &mlxsw_sp_ipip_gre4_ops, - [MLXSW_SP_IPIP_TYPE_GRE6 ] = &mlxsw_sp1_ipip_gre6_ops, + [MLXSW_SP_IPIP_TYPE_GRE6 ] = &mlxsw_sp2_ipip_gre6_ops, }; static int mlxsw_sp_ipip_ecn_encap_init_one(struct mlxsw_sp *mlxsw_sp,
@@ -461,11 +682,15 @@ mlxsw_sp_ipip_netdev_ul_dev_get(const struct net_device *ol_dev) {struct net *net =dev_net (ol_dev);struct ip_tunnel *tun4; +struct ip6_tnl *tun6;switch (ol_dev->type) {case ARPHRD_IPGRE : tun4 =netdev_priv (ol_dev);return dev_get_by_index_rcu (net, tun4->parms.link); +case ARPHRD_IP6GRE : + tun6 =netdev_priv (ol_dev); +return dev_get_by_index_rcu (net, tun6->parms.link);default :return NULL ; }
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.h +6 -0
@@ -7,6 +7,7 @@#include "spectrum_router.h" #include <net/ip_fib.h> #include <linux/if_tunnel.h> +#include <net/ip6_tunnel.h> struct ip_tunnel_parm mlxsw_sp_ipip_netdev_parms4 (const struct net_device *ol_dev);
@@ -41,6 +42,7 @@ struct mlxsw_sp_ipip_entry {struct mlxsw_sp_fib_entry *decap_fib_entry;struct list_head ipip_list_node;struct mlxsw_sp_ipip_parms parms; +u32 dip_kvdl_index; };struct mlxsw_sp_ipip_ops {
@@ -70,6 +72,10 @@ struct mlxsw_sp_ipip_ops {int (*ol_netdev_change)(struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_ipip_entry *ipip_entry,struct netlink_ext_ack *extack); +int (*rem_ip_addr_set)(struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_ipip_entry *ipip_entry); +void (*rem_ip_addr_unset)(struct mlxsw_sp *mlxsw_sp, +const struct mlxsw_sp_ipip_entry *ipip_entry); };extern const struct mlxsw_sp_ipip_ops *mlxsw_sp1_ipip_ops_arr[];
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +77 -9
165 lines not on this page · raw message
Signature · 1 line
2.31.1
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Thu, 23 Sep 2021 15:36:46 +0300 you wrote:
From: Ido Schimmel <[email protected]>
Currently, mlxsw only supports IP-in-IP with IPv4 underlay. Traffic routed through 'gre' netdevs is encapsulated with IPv4 and GRE headers. Similarly, incoming IPv4 GRE packets are decapsulated and routed in the overlay VRF (which can be the same as the underlay VRF).
[...]
Here is the summary with links:
- [net-next,01/14] mlxsw: spectrum_router: Create common function for fib_entry_type_unset() code
https://git.kernel.org/netdev/net-next/c/45bce5c99d46 - [net-next,02/14] mlxsw: spectrum_ipip: Pass IP tunnel parameters by reference and as 'const' https://git.kernel.org/netdev/net-next/c/aa6fd8f177d6 - [net-next,03/14] mlxsw: spectrum_router: Fix arguments alignment https://git.kernel.org/netdev/net-next/c/8aba32cea3f3 - [net-next,04/14] mlxsw: spectrum_ipip: Create common function for mlxsw_sp_ipip_ol_netdev_change_gre() https://git.kernel.org/netdev/net-next/c/80ef2abcddbc - [net-next,05/14] mlxsw: Take tunnel's type into account when searching underlay device https://git.kernel.org/netdev/net-next/c/59bf980dd90f - [net-next,06/14] mlxsw: reg: Add Router IP version Six Register https://git.kernel.org/netdev/net-next/c/dd8a9552d484 - [net-next,07/14] mlxsw: reg: Add support for rtdp_ipip6_pack() https://git.kernel.org/netdev/net-next/c/a917bb271d16 - [net-next,08/14] mlxsw: reg: Add support for ratr_ipip6_entry_pack() https://git.kernel.org/netdev/net-next/c/c729ae8d6cbc - [net-next,09/14] mlxsw: reg: Add support for ritr_loopback_ipip6_pack() https://git.kernel.org/netdev/net-next/c/36c2ab890b8f - [net-next,10/14] mlxsw: Create separate ipip_ops_arr for different ASICs https://git.kernel.org/netdev/net-next/c/a82feba686e8 - [net-next,11/14] mlxsw: spectrum_ipip: Add mlxsw_sp_ipip_gre6_ops https://git.kernel.org/netdev/net-next/c/713e8502fd3e - [net-next,12/14] mlxsw: Add IPV6_ADDRESS kvdl entry type https://git.kernel.org/netdev/net-next/c/53eedd61dea9 - [net-next,13/14] mlxsw: spectrum_router: Increase parsing depth for IPv6 decapsulation https://git.kernel.org/netdev/net-next/c/8d4f10463cd6 - [net-next,14/14] mlxsw: Add support for IP-in-IP with IPv6 underlay for Spectrum-2 and above https://git.kernel.org/netdev/net-next/c/ba1c71324bc2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html