Skip to content

Commit 49e6c93

Browse files
cjubrankuba-moo
authored andcommitted
net/mlx5e: RSS, Block XOR hash with over 128 channels
When supporting more than 128 channels, the RQT size is calculated by multiplying the number of channels by 2 and rounding up to the nearest power of 2. The index of the RQT is derived from the RSS hash calculations. If XOR8 is used as the RSS hash function, there are only 256 possible hash results, and therefore, only 256 indexes can be reached in the RQT. Block setting the RSS hash function to XOR when the number of channels exceeds 128. Fixes: 74a8dad ("net/mlx5e: Preparations for supporting larger number of channels") Signed-off-by: Carolina Jubran <cjubran@nvidia.com> Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Link: https://lore.kernel.org/r/20240409190820.227554-11-tariqt@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 86b0ca5 commit 49e6c93

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

drivers/net/ethernet/mellanox/mlx5/core/en/rqt.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ u32 mlx5e_rqt_size(struct mlx5_core_dev *mdev, unsigned int num_channels)
179179
return min_t(u32, rqt_size, max_cap_rqt_size);
180180
}
181181

182+
#define MLX5E_MAX_RQT_SIZE_ALLOWED_WITH_XOR8_HASH 256
183+
184+
unsigned int mlx5e_rqt_max_num_channels_allowed_for_xor8(void)
185+
{
186+
return MLX5E_MAX_RQT_SIZE_ALLOWED_WITH_XOR8_HASH / MLX5E_UNIFORM_SPREAD_RQT_FACTOR;
187+
}
188+
182189
void mlx5e_rqt_destroy(struct mlx5e_rqt *rqt)
183190
{
184191
mlx5_core_destroy_rqt(rqt->mdev, rqt->rqtn);

drivers/net/ethernet/mellanox/mlx5/core/en/rqt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static inline u32 mlx5e_rqt_get_rqtn(struct mlx5e_rqt *rqt)
3838
}
3939

4040
u32 mlx5e_rqt_size(struct mlx5_core_dev *mdev, unsigned int num_channels);
41+
unsigned int mlx5e_rqt_max_num_channels_allowed_for_xor8(void);
4142
int mlx5e_rqt_redirect_direct(struct mlx5e_rqt *rqt, u32 rqn, u32 *vhca_id);
4243
int mlx5e_rqt_redirect_indir(struct mlx5e_rqt *rqt, u32 *rqns, u32 *vhca_ids,
4344
unsigned int num_rqns,

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,17 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
451451

452452
mutex_lock(&priv->state_lock);
453453

454+
if (mlx5e_rx_res_get_current_hash(priv->rx_res).hfunc == ETH_RSS_HASH_XOR) {
455+
unsigned int xor8_max_channels = mlx5e_rqt_max_num_channels_allowed_for_xor8();
456+
457+
if (count > xor8_max_channels) {
458+
err = -EINVAL;
459+
netdev_err(priv->netdev, "%s: Requested number of channels (%d) exceeds the maximum allowed by the XOR8 RSS hfunc (%d)\n",
460+
__func__, count, xor8_max_channels);
461+
goto out;
462+
}
463+
}
464+
454465
/* If RXFH is configured, changing the channels number is allowed only if
455466
* it does not require resizing the RSS table. This is because the previous
456467
* configuration may no longer be compatible with the new RSS table.
@@ -1298,17 +1309,30 @@ int mlx5e_set_rxfh(struct net_device *dev, struct ethtool_rxfh_param *rxfh,
12981309
struct mlx5e_priv *priv = netdev_priv(dev);
12991310
u32 *rss_context = &rxfh->rss_context;
13001311
u8 hfunc = rxfh->hfunc;
1312+
unsigned int count;
13011313
int err;
13021314

13031315
mutex_lock(&priv->state_lock);
1316+
1317+
count = priv->channels.params.num_channels;
1318+
1319+
if (hfunc == ETH_RSS_HASH_XOR) {
1320+
unsigned int xor8_max_channels = mlx5e_rqt_max_num_channels_allowed_for_xor8();
1321+
1322+
if (count > xor8_max_channels) {
1323+
err = -EINVAL;
1324+
netdev_err(priv->netdev, "%s: Cannot set RSS hash function to XOR, current number of channels (%d) exceeds the maximum allowed for XOR8 RSS hfunc (%d)\n",
1325+
__func__, count, xor8_max_channels);
1326+
goto unlock;
1327+
}
1328+
}
1329+
13041330
if (*rss_context && rxfh->rss_delete) {
13051331
err = mlx5e_rx_res_rss_destroy(priv->rx_res, *rss_context);
13061332
goto unlock;
13071333
}
13081334

13091335
if (*rss_context == ETH_RXFH_CONTEXT_ALLOC) {
1310-
unsigned int count = priv->channels.params.num_channels;
1311-
13121336
err = mlx5e_rx_res_rss_init(priv->rx_res, rss_context, count);
13131337
if (err)
13141338
goto unlock;

0 commit comments

Comments
 (0)