net/mlx5e: Use preactivate hook to set the indirection table
authorMaxim Mikityanskiy <maximmi@mellanox.com>
Mon, 4 Nov 2019 10:02:14 +0000 (12:02 +0200)
committerSaeed Mahameed <saeedm@mellanox.com>
Wed, 26 Feb 2020 01:05:51 +0000 (17:05 -0800)
mlx5e_ethtool_set_channels updates the indirection table before
switching to the new channels. If the switch fails, the indirection
table is new, but the channels are old, which is wrong. Fix it by using
the preactivate hook of mlx5e_safe_switch_channels to update the
indirection table at the stage when nothing can fail anymore.

As the code that updates the indirection table is now encapsulated into
a new function, use that function in the attach flow when the driver has
to reduce the number of channels, and prepare the code for the next
commit.

Fixes: 85082dba0a ("net/mlx5e: Correctly handle RSS indirection table when changing number of channels")
Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
drivers/net/ethernet/mellanox/mlx5/core/en_main.c

index bc2c96b34de17868549d5a6e47bd720bceb97ae8..4ddccab02a4be9a46d5746fbbbafe700b8a1792d 100644 (file)
@@ -1043,6 +1043,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);
+int mlx5e_num_channels_changed(struct mlx5e_priv *priv);
 void mlx5e_activate_priv_channels(struct mlx5e_priv *priv);
 void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv);
 
index 68b520df07e4694aabdac2bd679fa23a8d73afec..ff7f5a93152017ab41cdfcbb31b4dcb3e3c27621 100644 (file)
@@ -432,9 +432,7 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
 
        if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
                *cur_params = new_channels.params;
-               if (!netif_is_rxfh_configured(priv->netdev))
-                       mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt,
-                                                     MLX5E_INDIR_RQT_SIZE, count);
+               mlx5e_num_channels_changed(priv);
                goto out;
        }
 
@@ -442,12 +440,8 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
        if (arfs_enabled)
                mlx5e_arfs_disable(priv);
 
-       if (!netif_is_rxfh_configured(priv->netdev))
-               mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt,
-                                             MLX5E_INDIR_RQT_SIZE, count);
-
        /* Switch to new channels, set new parameters and close old ones */
-       err = mlx5e_safe_switch_channels(priv, &new_channels, NULL);
+       err = mlx5e_safe_switch_channels(priv, &new_channels, mlx5e_num_channels_changed);
 
        if (arfs_enabled) {
                int err2 = mlx5e_arfs_enable(priv);
index 152aa5d7df79a64f690fdc946ce0ad2be0b08c97..bbe8c32fb4237e697ecc529bf6b0e488d04222f1 100644 (file)
@@ -2880,6 +2880,17 @@ static void mlx5e_update_netdev_queues(struct mlx5e_priv *priv)
        netif_set_real_num_rx_queues(netdev, num_rxqs);
 }
 
+int mlx5e_num_channels_changed(struct mlx5e_priv *priv)
+{
+       u16 count = priv->channels.params.num_channels;
+
+       if (!netif_is_rxfh_configured(priv->netdev))
+               mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt,
+                                             MLX5E_INDIR_RQT_SIZE, count);
+
+       return 0;
+}
+
 static void mlx5e_build_txq_maps(struct mlx5e_priv *priv)
 {
        int i, ch;
@@ -5288,9 +5299,10 @@ int mlx5e_attach_netdev(struct mlx5e_priv *priv)
        max_nch = mlx5e_get_max_num_channels(priv->mdev);
        if (priv->channels.params.num_channels > max_nch) {
                mlx5_core_warn(priv->mdev, "MLX5E: Reducing number of channels to %d\n", max_nch);
+               /* Reducing the number of channels - RXFH has to be reset. */
+               priv->netdev->priv_flags &= ~IFF_RXFH_CONFIGURED;
                priv->channels.params.num_channels = max_nch;
-               mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt,
-                                             MLX5E_INDIR_RQT_SIZE, max_nch);
+               mlx5e_num_channels_changed(priv);
        }
 
        err = profile->init_tx(priv);