mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
net/mlx5e: resize configured default RSS context table on channel change
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 ee3572409f ("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>
This commit is contained in:
parent
6bf1c27586
commit
4f59c22f26
|
|
@ -1,6 +1,7 @@
|
|||
// 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, ...) \
|
||||
|
|
@ -85,6 +86,11 @@ bool mlx5e_rss_get_inner_ft_support(struct mlx5e_rss *rss)
|
|||
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;
|
||||
|
|
@ -102,6 +108,13 @@ void mlx5e_rss_ctx_resize(struct mlx5e_rss *rss, u32 new_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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ int mlx5e_rss_params_indir_init(struct mlx5e_rss_params_indir *indir,
|
|||
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,
|
||||
|
|
@ -46,6 +48,7 @@ void mlx5e_rss_refcnt_dec(struct mlx5e_rss *rss);
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -40,15 +40,31 @@ static u32 *get_vhca_ids(struct mlx5e_rx_res *res, int offset)
|
|||
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++) {
|
||||
|
|
@ -218,13 +234,6 @@ static void mlx5e_rx_res_rss_disable(struct mlx5e_rx_res *res)
|
|||
}
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ void mlx5e_rx_res_xsk_update(struct mlx5e_rx_res *res, struct mlx5e_channels *ch
|
|||
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);
|
||||
|
|
@ -68,7 +67,8 @@ int mlx5e_rx_res_rss_destroy(struct mlx5e_rx_res *res, u32 rss_idx);
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -501,6 +501,7 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
|
|||
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;
|
||||
|
|
@ -538,19 +539,16 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
|
|||
}
|
||||
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -3296,12 +3296,9 @@ static int mlx5e_num_channels_changed(struct mlx5e_priv *priv)
|
|||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user