Skip to content

Commit

Permalink
net/mlx5e: Refactor on-the-fly configuration changes
Browse files Browse the repository at this point in the history
This commit extends mlx5e_safe_switch_channels() to support on-the-fly
configuration changes, when the channels are open, but don't need to be
recreated. Such flows exist when a parameter being changed doesn't
affect how the queues are created, or when the queues can be modified
while remaining active.

Before this commit, such flows were handled as special cases on the
caller site. This commit adds this functionality to
mlx5e_safe_switch_channels(), allowing the caller to pass a boolean
indicating whether it's required to recreate the channels or it's
allowed to skip it. The logic of switching channel parameters is now
completely encapsulated into mlx5e_safe_switch_channels().

Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
Maxim Mikityanskiy authored and Saeed Mahameed committed Apr 16, 2021
1 parent 69cc418 commit b3b886c
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 113 deletions.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en.h
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ int mlx5e_safe_reopen_channels(struct mlx5e_priv *priv);
int mlx5e_safe_switch_channels(struct mlx5e_priv *priv,
struct mlx5e_channels *new_chs,
mlx5e_fp_preactivate preactivate,
void *context);
void *context, bool reset);
int mlx5e_update_tx_netdev_queues(struct mlx5e_priv *priv);
int mlx5e_num_channels_changed(struct mlx5e_priv *priv);
int mlx5e_num_channels_changed_ctx(struct mlx5e_priv *priv, void *context);
Expand Down
12 changes: 5 additions & 7 deletions drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,8 @@ static int mlx5e_update_trust_state_hw(struct mlx5e_priv *priv, void *context)
static int mlx5e_set_trust_state(struct mlx5e_priv *priv, u8 trust_state)
{
struct mlx5e_channels new_channels = {};
int err = 0;
bool reset = true;
int err;

mutex_lock(&priv->state_lock);

Expand All @@ -1160,16 +1161,13 @@ static int mlx5e_set_trust_state(struct mlx5e_priv *priv, u8 trust_state)

/* Skip if tx_min_inline is the same */
if (new_channels.params.tx_min_inline_mode ==
priv->channels.params.tx_min_inline_mode) {
err = mlx5e_update_trust_state_hw(priv, &trust_state);
goto out;
}
priv->channels.params.tx_min_inline_mode)
reset = false;

err = mlx5e_safe_switch_channels(priv, &new_channels,
mlx5e_update_trust_state_hw,
&trust_state);
&trust_state, reset);

out:
mutex_unlock(&priv->state_lock);

return err;
Expand Down
24 changes: 11 additions & 13 deletions drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ int mlx5e_ethtool_set_ringparam(struct mlx5e_priv *priv,
if (err)
goto unlock;

err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL);
err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL, true);

unlock:
mutex_unlock(&priv->state_lock);
Expand Down Expand Up @@ -466,7 +466,7 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,

/* Switch to new channels, set new parameters and close old ones */
err = mlx5e_safe_switch_channels(priv, &new_channels,
mlx5e_num_channels_changed_ctx, NULL);
mlx5e_num_channels_changed_ctx, NULL, true);

if (arfs_enabled) {
int err2 = mlx5e_arfs_enable(priv);
Expand Down Expand Up @@ -563,6 +563,7 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,
struct mlx5_core_dev *mdev = priv->mdev;
struct mlx5e_channels new_channels = {};
bool reset_rx, reset_tx;
bool reset = true;
int err = 0;

if (!MLX5_CAP_GEN(mdev, cq_moderation))
Expand Down Expand Up @@ -619,13 +620,11 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,
mlx5e_set_priv_channels_rx_coalesce(priv, coal);
if (!coal->use_adaptive_tx_coalesce)
mlx5e_set_priv_channels_tx_coalesce(priv, coal);
priv->channels.params = new_channels.params;
goto out;
reset = false;
}

err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL);
err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL, reset);

out:
mutex_unlock(&priv->state_lock);
return err;
}
Expand Down Expand Up @@ -1869,7 +1868,7 @@ static int set_pflag_cqe_based_moder(struct net_device *netdev, bool enable,
else
mlx5e_set_tx_cq_mode_params(&new_channels.params, cq_period_mode);

return mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL);
return mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL, true);
}

static int set_pflag_tx_cqe_based_moder(struct net_device *netdev, bool enable)
Expand Down Expand Up @@ -1899,12 +1898,11 @@ int mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool new_val
if (priv->tstamp.rx_filter != HWTSTAMP_FILTER_NONE)
new_channels.params.ptp_rx = new_val;


if (new_channels.params.ptp_rx == priv->channels.params.ptp_rx)
err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL);
err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL, true);
else
err = mlx5e_safe_switch_channels(priv, &new_channels, mlx5e_ptp_rx_manage_fs_ctx,
&new_channels.params.ptp_rx);
&new_channels.params.ptp_rx, true);
if (err)
return err;

Expand Down Expand Up @@ -1955,7 +1953,7 @@ static int set_pflag_rx_striding_rq(struct net_device *netdev, bool enable)
MLX5E_SET_PFLAG(&new_channels.params, MLX5E_PFLAG_RX_STRIDING_RQ, enable);
mlx5e_set_rq_type(mdev, &new_channels.params);

return mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL);
return mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL, true);
}

static int set_pflag_rx_no_csum_complete(struct net_device *netdev, bool enable)
Expand Down Expand Up @@ -1993,7 +1991,7 @@ static int set_pflag_tx_mpwqe_common(struct net_device *netdev, u32 flag, bool e

MLX5E_SET_PFLAG(&new_channels.params, flag, enable);

return mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL);
return mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL, true);
}

static int set_pflag_xdp_tx_mpwqe(struct net_device *netdev, bool enable)
Expand Down Expand Up @@ -2034,7 +2032,7 @@ static int set_pflag_tx_port_ts(struct net_device *netdev, bool enable)
*/

err = mlx5e_safe_switch_channels(priv, &new_channels,
mlx5e_num_channels_changed_ctx, NULL);
mlx5e_num_channels_changed_ctx, NULL, true);
if (!err)
priv->tx_ptp_opened = true;

Expand Down
Loading

0 comments on commit b3b886c

Please sign in to comment.