mlx5e_ethtool_set_channels() rejected channel count changes that
required a different RQT size when the default context indirection
table was user-configured. This restriction was introduced by
commit
ee3572409f74 ("net/mlx5e: RSS, Block changing channels number
when RXFH is configured").
Lift the restriction. Validate the resize upfront with
ethtool_rxfh_indir_can_resize(), then fold or unfold the table
in-place via ethtool_rxfh_indir_resize() inside state_lock, before
mlx5e_safe_switch_params(), so the preactivate callback sees the
correct table content when it programs the HW.
Signed-off-by: Yael Chemla <ychemla@nvidia.com>
Reviewed-by: Nimrod Oren <noren@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260511172719.330490-5-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
// Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES.
+#include <linux/ethtool.h>
#include "rss.h"
#define mlx5e_rss_warn(__dev, format, ...) \
return rss->params.inner_ft_support;
}
+u32 *mlx5e_rss_get_indir_table(struct mlx5e_rss *rss)
+{
+ return rss->indir.table;
+}
+
void mlx5e_rss_set_indir_actual_size(struct mlx5e_rss *rss, u32 size)
{
rss->indir.actual_table_size = size;
rss->indir.table[i] = rss->indir.table[i % old_size];
}
+void mlx5e_rss_indir_resize(struct mlx5e_rss *rss, struct net_device *netdev,
+ u32 new_size)
+{
+ ethtool_rxfh_indir_resize(netdev, rss->indir.table,
+ rss->indir.actual_table_size, new_size);
+}
+
int mlx5e_rss_params_indir_init(struct mlx5e_rss_params_indir *indir,
u32 actual_table_size, u32 max_table_size)
{
u32 actual_table_size, u32 max_table_size);
void mlx5e_rss_params_indir_cleanup(struct mlx5e_rss_params_indir *indir);
void mlx5e_rss_ctx_resize(struct mlx5e_rss *rss, u32 new_size);
+void mlx5e_rss_indir_resize(struct mlx5e_rss *rss, struct net_device *netdev,
+ u32 new_size);
struct mlx5e_rss *
mlx5e_rss_init(struct mlx5_core_dev *mdev,
const struct mlx5e_rss_params *params,
unsigned int mlx5e_rss_refcnt_read(struct mlx5e_rss *rss);
bool mlx5e_rss_get_inner_ft_support(struct mlx5e_rss *rss);
+u32 *mlx5e_rss_get_indir_table(struct mlx5e_rss *rss);
void mlx5e_rss_set_indir_actual_size(struct mlx5e_rss *rss, u32 size);
u32 mlx5e_rss_get_tirn(struct mlx5e_rss *rss, enum mlx5_traffic_types tt,
bool inner);
return multi_vhca ? res->rss_vhca_ids + offset : NULL;
}
-void mlx5e_rx_res_rss_update_num_channels(struct mlx5e_rx_res *res, u32 nch)
+/* Updates the indirection table SW shadow, does not update the HW resources yet
+ */
+void mlx5e_rx_res_rss_update_num_channels(struct mlx5e_rx_res *res, u32 nch,
+ struct net_device *netdev)
{
u32 new_size = mlx5e_rqt_size(res->mdev, nch);
int i;
WARN_ON_ONCE(res->rss_active);
- /* Default context */
+ /* Default context: fold/unfold user-configured table, then update size
+ * and reset to uniform when unconfigured.
+ */
+ mlx5e_rss_indir_resize(res->rss[0], netdev, new_size);
+
+ /* mlx5e_rss_indir_resize() is a no-op when the table is not
+ * user-configured. actual_table_size is updated after the resize
+ * because ethtool_rxfh_indir_resize() uses it as the old size to
+ * replicate the pattern; updating it first would make the grow a no-op.
+ * It must be updated before mlx5e_rss_set_indir_uniform() so that
+ * the uniform fill covers all new entries, not just the old ones.
+ */
mlx5e_rss_set_indir_actual_size(res->rss[0], new_size);
+ if (!netif_is_rxfh_configured(netdev))
+ mlx5e_rss_set_indir_uniform(res->rss[0], nch);
/* Non-default contexts */
for (i = 1; i < MLX5E_MAX_NUM_RSS; i++) {
}
}
-/* Updates the indirection table SW shadow, does not update the HW resources yet */
-void mlx5e_rx_res_rss_set_indir_uniform(struct mlx5e_rx_res *res, unsigned int nch)
-{
- WARN_ON_ONCE(res->rss_active);
- mlx5e_rss_set_indir_uniform(res->rss[0], nch);
-}
-
void mlx5e_rx_res_rss_get_rxfh(struct mlx5e_rx_res *res, u32 rss_idx,
u32 *indir, u8 *key, u8 *hfunc, bool *symmetric)
{
unsigned int ix, bool xsk);
/* Configuration API */
-void mlx5e_rx_res_rss_set_indir_uniform(struct mlx5e_rx_res *res, unsigned int nch);
void mlx5e_rx_res_rss_get_rxfh(struct mlx5e_rx_res *res, u32 rss_idx,
u32 *indir, u8 *key, u8 *hfunc,
bool *symmetric);
int mlx5e_rx_res_rss_cnt(struct mlx5e_rx_res *res);
int mlx5e_rx_res_rss_index(struct mlx5e_rx_res *res, struct mlx5e_rss *rss);
struct mlx5e_rss *mlx5e_rx_res_rss_get(struct mlx5e_rx_res *res, u32 rss_idx);
-void mlx5e_rx_res_rss_update_num_channels(struct mlx5e_rx_res *res, u32 nch);
+void mlx5e_rx_res_rss_update_num_channels(struct mlx5e_rx_res *res, u32 nch,
+ struct net_device *netdev);
/* Workaround for hairpin */
struct mlx5e_rss_params_hash mlx5e_rx_res_get_current_hash(struct mlx5e_rx_res *res);
unsigned int count = ch->combined_count;
int new_rqt_size, cur_rqt_size;
struct mlx5e_params new_params;
+ struct mlx5e_rss *rss0;
bool arfs_enabled;
bool has_rss_ctxs;
bool opened;
}
cur_rqt_size = mlx5e_rqt_size(priv->mdev, cur_params->num_channels);
+ rss0 = mlx5e_rx_res_rss_get(priv->rx_res, 0);
- /* If RXFH is configured, changing the channels number is allowed only if
- * it does not require resizing the RSS table. This is because the previous
- * configuration may no longer be compatible with the new RSS table.
- */
- if (netif_is_rxfh_configured(priv->netdev)) {
- if (new_rqt_size != cur_rqt_size) {
- err = -EINVAL;
- netdev_err(priv->netdev,
- "%s: RXFH is configured, block changing channels number that affects RSS table size (new: %d, current: %d)\n",
- __func__, new_rqt_size, cur_rqt_size);
- goto out;
- }
+ if (!ethtool_rxfh_indir_can_resize(priv->netdev,
+ mlx5e_rss_get_indir_table(rss0),
+ cur_rqt_size, new_rqt_size)) {
+ netdev_err(priv->netdev,
+ "%s: cannot resize RSS table (%u -> %u); reset indirection table to allow this change\n",
+ __func__, cur_rqt_size, new_rqt_size);
+ err = -EINVAL;
+ goto out;
}
/* Don't allow changing the number of channels if HTB offload is active,
}
/* This function may be called on attach, before priv->rx_res is created. */
- if (priv->rx_res) {
- mlx5e_rx_res_rss_update_num_channels(priv->rx_res, count);
-
- if (!netif_is_rxfh_configured(priv->netdev))
- mlx5e_rx_res_rss_set_indir_uniform(priv->rx_res, count);
- }
+ if (priv->rx_res)
+ mlx5e_rx_res_rss_update_num_channels(priv->rx_res, count,
+ netdev);
return 0;
}