mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-04 12:10:24 -04:00
mlxsw: spectrum_router: Add a helper specifically for joining a LAG
Currently, joining a LAG very simply means that the LAG RIF should be joined by the subport representing untagged traffic. If the RIF does not exist, it does not have to be created: if the user wants there to be RIF for the LAG device, they are supposed to add an IP address, and they are supposed to do it after tha LAG becomes mlxsw upper. We can also assume that the LAG has no uppers, otherwise the enslavement is not allowed. In the future, these ordering dependencies should be removed. That means that joining LAG will be more complex operation, possibly involving a lazy RIF creation, and possibly joining / lazily creating RIFs for VLAN uppers of the LAG. It will be handy to have a dedicated function that handles all this. The new function mlxsw_sp_router_port_join_lag() is that. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Amit Cohen <amcohen@nvidia.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
committed by
Paolo Abeni
parent
e0db883b69
commit
76962b802e
@@ -4337,8 +4337,8 @@ static int mlxsw_sp_port_lag_join(struct mlxsw_sp_port *mlxsw_sp_port,
|
||||
mlxsw_sp_port_vlan_router_leave(mlxsw_sp_port->default_vlan);
|
||||
|
||||
/* Join a router interface configured on the LAG, if exists */
|
||||
err = mlxsw_sp_port_vlan_router_join(mlxsw_sp_port->default_vlan,
|
||||
lag_dev, extack);
|
||||
err = mlxsw_sp_router_port_join_lag(mlxsw_sp_port, lag_dev,
|
||||
extack);
|
||||
if (err)
|
||||
goto err_router_join;
|
||||
|
||||
|
||||
@@ -755,10 +755,6 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp,
|
||||
void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
|
||||
void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp,
|
||||
const struct net_device *macvlan_dev);
|
||||
int
|
||||
mlxsw_sp_port_vlan_router_join(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan,
|
||||
struct net_device *l3_dev,
|
||||
struct netlink_ext_ack *extack);
|
||||
void
|
||||
mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
|
||||
void mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp,
|
||||
|
||||
@@ -8578,22 +8578,6 @@ mlxsw_sp_port_vlan_router_join_existing(struct mlxsw_sp_port_vlan *mlxsw_sp_port
|
||||
extack);
|
||||
}
|
||||
|
||||
int
|
||||
mlxsw_sp_port_vlan_router_join(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan,
|
||||
struct net_device *l3_dev,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port_vlan->mlxsw_sp_port->mlxsw_sp;
|
||||
int err;
|
||||
|
||||
mutex_lock(&mlxsw_sp->router->lock);
|
||||
err = mlxsw_sp_port_vlan_router_join_existing(mlxsw_sp_port_vlan,
|
||||
l3_dev, extack);
|
||||
mutex_unlock(&mlxsw_sp->router->lock);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void
|
||||
mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan)
|
||||
{
|
||||
@@ -9278,6 +9262,46 @@ mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event,
|
||||
return err;
|
||||
}
|
||||
|
||||
static int
|
||||
mlxsw_sp_port_vid_router_join_existing(struct mlxsw_sp_port *mlxsw_sp_port,
|
||||
u16 vid, struct net_device *dev,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
|
||||
|
||||
mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_vid(mlxsw_sp_port,
|
||||
vid);
|
||||
if (WARN_ON(!mlxsw_sp_port_vlan))
|
||||
return -EINVAL;
|
||||
|
||||
return mlxsw_sp_port_vlan_router_join_existing(mlxsw_sp_port_vlan,
|
||||
dev, extack);
|
||||
}
|
||||
|
||||
static int __mlxsw_sp_router_port_join_lag(struct mlxsw_sp_port *mlxsw_sp_port,
|
||||
struct net_device *lag_dev,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
u16 default_vid = MLXSW_SP_DEFAULT_VID;
|
||||
|
||||
return mlxsw_sp_port_vid_router_join_existing(mlxsw_sp_port,
|
||||
default_vid, lag_dev,
|
||||
extack);
|
||||
}
|
||||
|
||||
int mlxsw_sp_router_port_join_lag(struct mlxsw_sp_port *mlxsw_sp_port,
|
||||
struct net_device *lag_dev,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
int err;
|
||||
|
||||
mutex_lock(&mlxsw_sp_port->mlxsw_sp->router->lock);
|
||||
err = __mlxsw_sp_router_port_join_lag(mlxsw_sp_port, lag_dev, extack);
|
||||
mutex_unlock(&mlxsw_sp_port->mlxsw_sp->router->lock);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int mlxsw_sp_router_netdevice_event(struct notifier_block *nb,
|
||||
unsigned long event, void *ptr)
|
||||
{
|
||||
|
||||
@@ -170,5 +170,8 @@ 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);
|
||||
int mlxsw_sp_router_port_join_lag(struct mlxsw_sp_port *mlxsw_sp_port,
|
||||
struct net_device *lag_dev,
|
||||
struct netlink_ext_ack *extack);
|
||||
|
||||
#endif /* _MLXSW_ROUTER_H_*/
|
||||
|
||||
Reference in New Issue
Block a user