Commit 8355060f authored by Maxim Mikityanskiy's avatar Maxim Mikityanskiy Committed by Saeed Mahameed

net/mlx5e: Revert parameters on errors when changing MTU and LRO state without reset

Sometimes, channel params are changed without recreating the channels.
It happens in two basic cases: when the channels are closed, and when
the parameter being changed doesn't affect how channels are configured.
Such changes invoke a hardware command that might fail. The whole
operation should be reverted in such cases, but the code that restores
the parameters' values in the driver was missing. This commit adds this
handling.

Fixes: 2e20a151 ("net/mlx5e: Fail safe mtu and lro setting")
Signed-off-by: default avatarMaxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 912c9b5f
...@@ -3764,7 +3764,7 @@ static int set_feature_lro(struct net_device *netdev, bool enable) ...@@ -3764,7 +3764,7 @@ static int set_feature_lro(struct net_device *netdev, bool enable)
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
struct mlx5e_channels new_channels = {}; struct mlx5e_channels new_channels = {};
struct mlx5e_params *old_params; struct mlx5e_params *cur_params;
int err = 0; int err = 0;
bool reset; bool reset;
...@@ -3777,8 +3777,8 @@ static int set_feature_lro(struct net_device *netdev, bool enable) ...@@ -3777,8 +3777,8 @@ static int set_feature_lro(struct net_device *netdev, bool enable)
goto out; goto out;
} }
old_params = &priv->channels.params; cur_params = &priv->channels.params;
if (enable && !MLX5E_GET_PFLAG(old_params, MLX5E_PFLAG_RX_STRIDING_RQ)) { if (enable && !MLX5E_GET_PFLAG(cur_params, MLX5E_PFLAG_RX_STRIDING_RQ)) {
netdev_warn(netdev, "can't set LRO with legacy RQ\n"); netdev_warn(netdev, "can't set LRO with legacy RQ\n");
err = -EINVAL; err = -EINVAL;
goto out; goto out;
...@@ -3786,18 +3786,23 @@ static int set_feature_lro(struct net_device *netdev, bool enable) ...@@ -3786,18 +3786,23 @@ static int set_feature_lro(struct net_device *netdev, bool enable)
reset = test_bit(MLX5E_STATE_OPENED, &priv->state); reset = test_bit(MLX5E_STATE_OPENED, &priv->state);
new_channels.params = *old_params; new_channels.params = *cur_params;
new_channels.params.lro_en = enable; new_channels.params.lro_en = enable;
if (old_params->rq_wq_type != MLX5_WQ_TYPE_CYCLIC) { if (cur_params->rq_wq_type != MLX5_WQ_TYPE_CYCLIC) {
if (mlx5e_rx_mpwqe_is_linear_skb(mdev, old_params, NULL) == if (mlx5e_rx_mpwqe_is_linear_skb(mdev, cur_params, NULL) ==
mlx5e_rx_mpwqe_is_linear_skb(mdev, &new_channels.params, NULL)) mlx5e_rx_mpwqe_is_linear_skb(mdev, &new_channels.params, NULL))
reset = false; reset = false;
} }
if (!reset) { if (!reset) {
*old_params = new_channels.params; struct mlx5e_params old_params;
old_params = *cur_params;
*cur_params = new_channels.params;
err = mlx5e_modify_tirs_lro(priv); err = mlx5e_modify_tirs_lro(priv);
if (err)
*cur_params = old_params;
goto out; goto out;
} }
...@@ -4074,9 +4079,16 @@ int mlx5e_change_mtu(struct net_device *netdev, int new_mtu, ...@@ -4074,9 +4079,16 @@ int mlx5e_change_mtu(struct net_device *netdev, int new_mtu,
} }
if (!reset) { if (!reset) {
unsigned int old_mtu = params->sw_mtu;
params->sw_mtu = new_mtu; params->sw_mtu = new_mtu;
if (preactivate) if (preactivate) {
preactivate(priv, NULL); err = preactivate(priv, NULL);
if (err) {
params->sw_mtu = old_mtu;
goto out;
}
}
netdev->mtu = params->sw_mtu; netdev->mtu = params->sw_mtu;
goto out; goto out;
} }
......
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