diff options
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 8 | ||||
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 18 | ||||
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c | 183 | ||||
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.h | 12 | ||||
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 539 | ||||
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h | 29 |
6 files changed, 614 insertions, 175 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 52f38b480669..63e50877796b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c | |||
| @@ -4542,8 +4542,12 @@ static int mlxsw_sp_netdevice_event(struct notifier_block *nb, | |||
| 4542 | int err = 0; | 4542 | int err = 0; |
| 4543 | 4543 | ||
| 4544 | mlxsw_sp = container_of(nb, struct mlxsw_sp, netdevice_nb); | 4544 | mlxsw_sp = container_of(nb, struct mlxsw_sp, netdevice_nb); |
| 4545 | if (mlxsw_sp_netdev_is_ipip(mlxsw_sp, dev)) | 4545 | if (mlxsw_sp_netdev_is_ipip_ol(mlxsw_sp, dev)) |
| 4546 | err = mlxsw_sp_netdevice_ipip_event(mlxsw_sp, dev, event, ptr); | 4546 | err = mlxsw_sp_netdevice_ipip_ol_event(mlxsw_sp, dev, |
| 4547 | event, ptr); | ||
| 4548 | else if (mlxsw_sp_netdev_is_ipip_ul(mlxsw_sp, dev)) | ||
| 4549 | err = mlxsw_sp_netdevice_ipip_ul_event(mlxsw_sp, dev, | ||
| 4550 | event, ptr); | ||
| 4547 | else if (event == NETDEV_CHANGEADDR || event == NETDEV_CHANGEMTU) | 4551 | else if (event == NETDEV_CHANGEADDR || event == NETDEV_CHANGEMTU) |
| 4548 | err = mlxsw_sp_netdevice_router_port_event(dev); | 4552 | err = mlxsw_sp_netdevice_router_port_event(dev); |
| 4549 | else if (mlxsw_sp_is_vrf_event(event, ptr)) | 4553 | else if (mlxsw_sp_is_vrf_event(event, ptr)) |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index b2393bb8cef9..47dd7e06fd29 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h | |||
| @@ -396,13 +396,19 @@ int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused, | |||
| 396 | unsigned long event, void *ptr); | 396 | unsigned long event, void *ptr); |
| 397 | int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event, | 397 | int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event, |
| 398 | struct netdev_notifier_changeupper_info *info); | 398 | struct netdev_notifier_changeupper_info *info); |
| 399 | bool mlxsw_sp_netdev_is_ipip(const struct mlxsw_sp *mlxsw_sp, | 399 | bool mlxsw_sp_netdev_is_ipip_ol(const struct mlxsw_sp *mlxsw_sp, |
| 400 | const struct net_device *dev); | 400 | const struct net_device *dev); |
| 401 | bool mlxsw_sp_netdev_is_ipip_ul(const struct mlxsw_sp *mlxsw_sp, | ||
| 402 | const struct net_device *dev); | ||
| 403 | int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp, | ||
| 404 | struct net_device *l3_dev, | ||
| 405 | unsigned long event, | ||
| 406 | struct netdev_notifier_info *info); | ||
| 401 | int | 407 | int |
| 402 | mlxsw_sp_netdevice_ipip_event(struct mlxsw_sp *mlxsw_sp, | 408 | mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp, |
| 403 | struct net_device *l3_dev, | 409 | struct net_device *l3_dev, |
| 404 | unsigned long event, | 410 | unsigned long event, |
| 405 | struct netdev_notifier_changeupper_info *info); | 411 | struct netdev_notifier_info *info); |
| 406 | void | 412 | void |
| 407 | mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); | 413 | mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); |
| 408 | void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif); | 414 | void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif); |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c index 702fe945227c..7502e53447bd 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c | |||
| @@ -36,36 +36,123 @@ | |||
| 36 | 36 | ||
| 37 | #include "spectrum_ipip.h" | 37 | #include "spectrum_ipip.h" |
| 38 | 38 | ||
| 39 | static bool | 39 | struct ip_tunnel_parm |
| 40 | mlxsw_sp_ipip_netdev_has_ikey(const struct net_device *ol_dev) | 40 | mlxsw_sp_ipip_netdev_parms(const struct net_device *ol_dev) |
| 41 | { | 41 | { |
| 42 | struct ip_tunnel *tun = netdev_priv(ol_dev); | 42 | struct ip_tunnel *tun = netdev_priv(ol_dev); |
| 43 | 43 | ||
| 44 | return !!(tun->parms.i_flags & TUNNEL_KEY); | 44 | return tun->parms; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | static bool | 47 | static bool mlxsw_sp_ipip_parms_has_ikey(struct ip_tunnel_parm parms) |
| 48 | mlxsw_sp_ipip_netdev_has_okey(const struct net_device *ol_dev) | ||
| 49 | { | 48 | { |
| 50 | struct ip_tunnel *tun = netdev_priv(ol_dev); | 49 | return !!(parms.i_flags & TUNNEL_KEY); |
| 50 | } | ||
| 51 | 51 | ||
| 52 | return !!(tun->parms.o_flags & TUNNEL_KEY); | 52 | static bool mlxsw_sp_ipip_parms_has_okey(struct ip_tunnel_parm parms) |
| 53 | { | ||
| 54 | return !!(parms.o_flags & TUNNEL_KEY); | ||
| 53 | } | 55 | } |
| 54 | 56 | ||
| 55 | static u32 mlxsw_sp_ipip_netdev_ikey(const struct net_device *ol_dev) | 57 | static u32 mlxsw_sp_ipip_parms_ikey(struct ip_tunnel_parm parms) |
| 56 | { | 58 | { |
| 57 | struct ip_tunnel *tun = netdev_priv(ol_dev); | 59 | return mlxsw_sp_ipip_parms_has_ikey(parms) ? |
| 60 | be32_to_cpu(parms.i_key) : 0; | ||
| 61 | } | ||
| 62 | |||
| 63 | static u32 mlxsw_sp_ipip_parms_okey(struct ip_tunnel_parm parms) | ||
| 64 | { | ||
| 65 | return mlxsw_sp_ipip_parms_has_okey(parms) ? | ||
| 66 | be32_to_cpu(parms.o_key) : 0; | ||
| 67 | } | ||
| 58 | 68 | ||
| 59 | return mlxsw_sp_ipip_netdev_has_ikey(ol_dev) ? | 69 | static __be32 mlxsw_sp_ipip_parms_saddr4(struct ip_tunnel_parm parms) |
| 60 | be32_to_cpu(tun->parms.i_key) : 0; | 70 | { |
| 71 | return parms.iph.saddr; | ||
| 72 | } | ||
| 73 | |||
| 74 | static union mlxsw_sp_l3addr | ||
| 75 | mlxsw_sp_ipip_parms_saddr(enum mlxsw_sp_l3proto proto, | ||
| 76 | struct ip_tunnel_parm parms) | ||
| 77 | { | ||
| 78 | switch (proto) { | ||
| 79 | case MLXSW_SP_L3_PROTO_IPV4: | ||
| 80 | return (union mlxsw_sp_l3addr) { | ||
| 81 | .addr4 = mlxsw_sp_ipip_parms_saddr4(parms), | ||
| 82 | }; | ||
| 83 | case MLXSW_SP_L3_PROTO_IPV6: | ||
| 84 | break; | ||
| 85 | } | ||
| 86 | |||
| 87 | WARN_ON(1); | ||
| 88 | return (union mlxsw_sp_l3addr) { | ||
| 89 | .addr4 = 0, | ||
| 90 | }; | ||
| 91 | } | ||
| 92 | |||
| 93 | static __be32 mlxsw_sp_ipip_parms_daddr4(struct ip_tunnel_parm parms) | ||
| 94 | { | ||
| 95 | return parms.iph.daddr; | ||
| 96 | } | ||
| 97 | |||
| 98 | static union mlxsw_sp_l3addr | ||
| 99 | mlxsw_sp_ipip_parms_daddr(enum mlxsw_sp_l3proto proto, | ||
| 100 | struct ip_tunnel_parm parms) | ||
| 101 | { | ||
| 102 | switch (proto) { | ||
| 103 | case MLXSW_SP_L3_PROTO_IPV4: | ||
| 104 | return (union mlxsw_sp_l3addr) { | ||
| 105 | .addr4 = mlxsw_sp_ipip_parms_daddr4(parms), | ||
| 106 | }; | ||
| 107 | case MLXSW_SP_L3_PROTO_IPV6: | ||
| 108 | break; | ||
| 109 | } | ||
| 110 | |||
| 111 | WARN_ON(1); | ||
| 112 | return (union mlxsw_sp_l3addr) { | ||
| 113 | .addr4 = 0, | ||
| 114 | }; | ||
| 115 | } | ||
| 116 | |||
| 117 | static bool mlxsw_sp_ipip_netdev_has_ikey(const struct net_device *ol_dev) | ||
| 118 | { | ||
| 119 | return mlxsw_sp_ipip_parms_has_ikey(mlxsw_sp_ipip_netdev_parms(ol_dev)); | ||
| 120 | } | ||
| 121 | |||
| 122 | static bool mlxsw_sp_ipip_netdev_has_okey(const struct net_device *ol_dev) | ||
| 123 | { | ||
| 124 | return mlxsw_sp_ipip_parms_has_okey(mlxsw_sp_ipip_netdev_parms(ol_dev)); | ||
| 125 | } | ||
| 126 | |||
| 127 | static u32 mlxsw_sp_ipip_netdev_ikey(const struct net_device *ol_dev) | ||
| 128 | { | ||
| 129 | return mlxsw_sp_ipip_parms_ikey(mlxsw_sp_ipip_netdev_parms(ol_dev)); | ||
| 61 | } | 130 | } |
| 62 | 131 | ||
| 63 | static u32 mlxsw_sp_ipip_netdev_okey(const struct net_device *ol_dev) | 132 | static u32 mlxsw_sp_ipip_netdev_okey(const struct net_device *ol_dev) |
| 64 | { | 133 | { |
| 65 | struct ip_tunnel *tun = netdev_priv(ol_dev); | 134 | return mlxsw_sp_ipip_parms_okey(mlxsw_sp_ipip_netdev_parms(ol_dev)); |
| 135 | } | ||
| 136 | |||
| 137 | union mlxsw_sp_l3addr | ||
| 138 | mlxsw_sp_ipip_netdev_saddr(enum mlxsw_sp_l3proto proto, | ||
| 139 | const struct net_device *ol_dev) | ||
| 140 | { | ||
| 141 | return mlxsw_sp_ipip_parms_saddr(proto, | ||
| 142 | mlxsw_sp_ipip_netdev_parms(ol_dev)); | ||
| 143 | } | ||
| 144 | |||
| 145 | static __be32 mlxsw_sp_ipip_netdev_daddr4(const struct net_device *ol_dev) | ||
| 146 | { | ||
| 147 | return mlxsw_sp_ipip_parms_daddr4(mlxsw_sp_ipip_netdev_parms(ol_dev)); | ||
| 148 | } | ||
| 66 | 149 | ||
| 67 | return mlxsw_sp_ipip_netdev_has_okey(ol_dev) ? | 150 | static union mlxsw_sp_l3addr |
