Commit 8d8d33d4 authored by Amit Cohen's avatar Amit Cohen Committed by Paolo Abeni

mlxsw: spectrum: Search for free LAD ID once

Currently, the function mlxsw_sp_lag_index_get() is called twice - first
as part of NETDEV_PRECHANGEUPPER event and later as part of
NETDEV_CHANGEUPPER. This function will be changed in the next patch. To
simplify the code, call it only once as part of NETDEV_CHANGEUPPER
event and set an error message using 'extack' in case of failure.
Signed-off-by: default avatarAmit Cohen <amcohen@nvidia.com>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent c6ca2884
...@@ -4323,7 +4323,7 @@ static int mlxsw_sp_lag_col_port_disable(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -4323,7 +4323,7 @@ static int mlxsw_sp_lag_col_port_disable(struct mlxsw_sp_port *mlxsw_sp_port,
static int mlxsw_sp_lag_index_get(struct mlxsw_sp *mlxsw_sp, static int mlxsw_sp_lag_index_get(struct mlxsw_sp *mlxsw_sp,
struct net_device *lag_dev, struct net_device *lag_dev,
u16 *p_lag_id) u16 *p_lag_id, struct netlink_ext_ack *extack)
{ {
struct mlxsw_sp_lag *lag; struct mlxsw_sp_lag *lag;
int free_lag_id = -1; int free_lag_id = -1;
...@@ -4340,8 +4340,11 @@ static int mlxsw_sp_lag_index_get(struct mlxsw_sp *mlxsw_sp, ...@@ -4340,8 +4340,11 @@ static int mlxsw_sp_lag_index_get(struct mlxsw_sp *mlxsw_sp,
free_lag_id = i; free_lag_id = i;
} }
} }
if (free_lag_id < 0) if (free_lag_id < 0) {
NL_SET_ERR_MSG_MOD(extack,
"Exceeded number of supported LAG devices");
return -EBUSY; return -EBUSY;
}
*p_lag_id = free_lag_id; *p_lag_id = free_lag_id;
return 0; return 0;
} }
...@@ -4352,12 +4355,6 @@ mlxsw_sp_master_lag_check(struct mlxsw_sp *mlxsw_sp, ...@@ -4352,12 +4355,6 @@ mlxsw_sp_master_lag_check(struct mlxsw_sp *mlxsw_sp,
struct netdev_lag_upper_info *lag_upper_info, struct netdev_lag_upper_info *lag_upper_info,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
u16 lag_id;
if (mlxsw_sp_lag_index_get(mlxsw_sp, lag_dev, &lag_id) != 0) {
NL_SET_ERR_MSG_MOD(extack, "Exceeded number of supported LAG devices");
return false;
}
if (lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) { if (lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) {
NL_SET_ERR_MSG_MOD(extack, "LAG device using unsupported Tx type"); NL_SET_ERR_MSG_MOD(extack, "LAG device using unsupported Tx type");
return false; return false;
...@@ -4474,7 +4471,7 @@ static int mlxsw_sp_port_lag_join(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -4474,7 +4471,7 @@ static int mlxsw_sp_port_lag_join(struct mlxsw_sp_port *mlxsw_sp_port,
u8 port_index; u8 port_index;
int err; int err;
err = mlxsw_sp_lag_index_get(mlxsw_sp, lag_dev, &lag_id); err = mlxsw_sp_lag_index_get(mlxsw_sp, lag_dev, &lag_id, extack);
if (err) if (err)
return err; return err;
lag = &mlxsw_sp->lags[lag_id]; lag = &mlxsw_sp->lags[lag_id];
......
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