Commit b03fa9e7 authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

mlxsw: spectrum_switchdev: Unify VxLAN leave function

The function mlxsw_sp_bridge_vxlan_leave() is currently split between
VLAN-aware and VLAN-unaware bridges, but actually both types can use the
same function.

The function needs to resolve the FID that corresponds to the VxLAN
device and disable NVE encapsulation on it. Instead of looking up the
FID differently for VLAN-aware and VLAN-unaware bridges, we can always
use the VxLAN's device VNI.
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Reviewed-by: default avatarPetr Machata <petrm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5a8fb370
...@@ -5174,7 +5174,7 @@ static int mlxsw_sp_netdevice_vxlan_event(struct mlxsw_sp *mlxsw_sp, ...@@ -5174,7 +5174,7 @@ static int mlxsw_sp_netdevice_vxlan_event(struct mlxsw_sp *mlxsw_sp,
return mlxsw_sp_bridge_vxlan_join(mlxsw_sp, upper_dev, return mlxsw_sp_bridge_vxlan_join(mlxsw_sp, upper_dev,
dev, extack); dev, extack);
} else { } else {
mlxsw_sp_bridge_vxlan_leave(mlxsw_sp, upper_dev, dev); mlxsw_sp_bridge_vxlan_leave(mlxsw_sp, dev);
} }
break; break;
case NETDEV_PRE_UP: case NETDEV_PRE_UP:
...@@ -5195,7 +5195,7 @@ static int mlxsw_sp_netdevice_vxlan_event(struct mlxsw_sp *mlxsw_sp, ...@@ -5195,7 +5195,7 @@ static int mlxsw_sp_netdevice_vxlan_event(struct mlxsw_sp *mlxsw_sp,
return 0; return 0;
if (!mlxsw_sp_lower_get(upper_dev)) if (!mlxsw_sp_lower_get(upper_dev))
return 0; return 0;
mlxsw_sp_bridge_vxlan_leave(mlxsw_sp, upper_dev, dev); mlxsw_sp_bridge_vxlan_leave(mlxsw_sp, dev);
break; break;
} }
......
...@@ -361,7 +361,6 @@ int mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp, ...@@ -361,7 +361,6 @@ int mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp,
const struct net_device *vxlan_dev, const struct net_device *vxlan_dev,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack);
void mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp, void mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp,
const struct net_device *br_dev,
const struct net_device *vxlan_dev); const struct net_device *vxlan_dev);
/* spectrum.c */ /* spectrum.c */
......
...@@ -87,8 +87,6 @@ struct mlxsw_sp_bridge_ops { ...@@ -87,8 +87,6 @@ struct mlxsw_sp_bridge_ops {
int (*vxlan_join)(struct mlxsw_sp_bridge_device *bridge_device, int (*vxlan_join)(struct mlxsw_sp_bridge_device *bridge_device,
const struct net_device *vxlan_dev, const struct net_device *vxlan_dev,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack);
void (*vxlan_leave)(struct mlxsw_sp_bridge_device *bridge_device,
const struct net_device *vxlan_dev);
struct mlxsw_sp_fid * struct mlxsw_sp_fid *
(*fid_get)(struct mlxsw_sp_bridge_device *bridge_device, (*fid_get)(struct mlxsw_sp_bridge_device *bridge_device,
u16 vid); u16 vid);
...@@ -2012,12 +2010,6 @@ mlxsw_sp_bridge_8021q_vxlan_join(struct mlxsw_sp_bridge_device *bridge_device, ...@@ -2012,12 +2010,6 @@ mlxsw_sp_bridge_8021q_vxlan_join(struct mlxsw_sp_bridge_device *bridge_device,
return -EINVAL; return -EINVAL;
} }
static void
mlxsw_sp_bridge_8021q_vxlan_leave(struct mlxsw_sp_bridge_device *bridge_device,
const struct net_device *vxlan_dev)
{
}
static struct mlxsw_sp_fid * static struct mlxsw_sp_fid *
mlxsw_sp_bridge_8021q_fid_get(struct mlxsw_sp_bridge_device *bridge_device, mlxsw_sp_bridge_8021q_fid_get(struct mlxsw_sp_bridge_device *bridge_device,
u16 vid) u16 vid)
...@@ -2047,7 +2039,6 @@ static const struct mlxsw_sp_bridge_ops mlxsw_sp_bridge_8021q_ops = { ...@@ -2047,7 +2039,6 @@ static const struct mlxsw_sp_bridge_ops mlxsw_sp_bridge_8021q_ops = {
.port_join = mlxsw_sp_bridge_8021q_port_join, .port_join = mlxsw_sp_bridge_8021q_port_join,
.port_leave = mlxsw_sp_bridge_8021q_port_leave, .port_leave = mlxsw_sp_bridge_8021q_port_leave,
.vxlan_join = mlxsw_sp_bridge_8021q_vxlan_join, .vxlan_join = mlxsw_sp_bridge_8021q_vxlan_join,
.vxlan_leave = mlxsw_sp_bridge_8021q_vxlan_leave,
.fid_get = mlxsw_sp_bridge_8021q_fid_get, .fid_get = mlxsw_sp_bridge_8021q_fid_get,
.fid_lookup = mlxsw_sp_bridge_8021q_fid_lookup, .fid_lookup = mlxsw_sp_bridge_8021q_fid_lookup,
.fid_vid = mlxsw_sp_bridge_8021q_fid_vid, .fid_vid = mlxsw_sp_bridge_8021q_fid_vid,
...@@ -2152,26 +2143,6 @@ mlxsw_sp_bridge_8021d_vxlan_join(struct mlxsw_sp_bridge_device *bridge_device, ...@@ -2152,26 +2143,6 @@ mlxsw_sp_bridge_8021d_vxlan_join(struct mlxsw_sp_bridge_device *bridge_device,
return err; return err;
} }
static void
mlxsw_sp_bridge_8021d_vxlan_leave(struct mlxsw_sp_bridge_device *bridge_device,
const struct net_device *vxlan_dev)
{
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(bridge_device->dev);
struct mlxsw_sp_fid *fid;
fid = mlxsw_sp_fid_8021d_lookup(mlxsw_sp, bridge_device->dev->ifindex);
if (WARN_ON(!fid))
return;
/* If the VxLAN device is down, then the FID does not have a VNI */
if (!mlxsw_sp_fid_vni_is_set(fid))
goto out;
mlxsw_sp_nve_fid_disable(mlxsw_sp, fid);
out:
mlxsw_sp_fid_put(fid);
}
static struct mlxsw_sp_fid * static struct mlxsw_sp_fid *
mlxsw_sp_bridge_8021d_fid_get(struct mlxsw_sp_bridge_device *bridge_device, mlxsw_sp_bridge_8021d_fid_get(struct mlxsw_sp_bridge_device *bridge_device,
u16 vid) u16 vid)
...@@ -2230,7 +2201,6 @@ static const struct mlxsw_sp_bridge_ops mlxsw_sp_bridge_8021d_ops = { ...@@ -2230,7 +2201,6 @@ static const struct mlxsw_sp_bridge_ops mlxsw_sp_bridge_8021d_ops = {
.port_join = mlxsw_sp_bridge_8021d_port_join, .port_join = mlxsw_sp_bridge_8021d_port_join,
.port_leave = mlxsw_sp_bridge_8021d_port_leave, .port_leave = mlxsw_sp_bridge_8021d_port_leave,
.vxlan_join = mlxsw_sp_bridge_8021d_vxlan_join, .vxlan_join = mlxsw_sp_bridge_8021d_vxlan_join,
.vxlan_leave = mlxsw_sp_bridge_8021d_vxlan_leave,
.fid_get = mlxsw_sp_bridge_8021d_fid_get, .fid_get = mlxsw_sp_bridge_8021d_fid_get,
.fid_lookup = mlxsw_sp_bridge_8021d_fid_lookup, .fid_lookup = mlxsw_sp_bridge_8021d_fid_lookup,
.fid_vid = mlxsw_sp_bridge_8021d_fid_vid, .fid_vid = mlxsw_sp_bridge_8021d_fid_vid,
...@@ -2298,16 +2268,18 @@ int mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp, ...@@ -2298,16 +2268,18 @@ int mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp,
} }
void mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp, void mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp,
const struct net_device *br_dev,
const struct net_device *vxlan_dev) const struct net_device *vxlan_dev)
{ {
struct mlxsw_sp_bridge_device *bridge_device; struct vxlan_dev *vxlan = netdev_priv(vxlan_dev);
struct mlxsw_sp_fid *fid;
bridge_device = mlxsw_sp_bridge_device_find(mlxsw_sp->bridge, br_dev); /* If the VxLAN device is down, then the FID does not have a VNI */
if (WARN_ON(!bridge_device)) fid = mlxsw_sp_fid_lookup_by_vni(mlxsw_sp, vxlan->cfg.vni);
if (!fid)
return; return;
bridge_device->ops->vxlan_leave(bridge_device, vxlan_dev); mlxsw_sp_nve_fid_disable(mlxsw_sp, fid);
mlxsw_sp_fid_put(fid);
} }
static void static void
......
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