Skip to content

Commit 3435ab5

Browse files
Achiad Shochatdavem330
authored andcommitted
net/mlx5e: Don't allow more than max supported channels
Consider MLX5E_MAX_NUM_CHANNELS @ethtool set/get_channels Signed-off-by: Achiad Shochat <[email protected]> Signed-off-by: Or Gerlitz <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 61d0e73 commit 3435ab5

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,5 +617,11 @@ static inline void mlx5e_cq_arm(struct mlx5e_cq *cq)
617617
mlx5_cq_arm(mcq, MLX5_CQ_DB_REQ_NOT, mcq->uar->map, NULL, cq->wq.cc);
618618
}
619619

620+
static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
621+
{
622+
return min_t(int, mdev->priv.eq_table.num_comp_vectors,
623+
MLX5E_MAX_NUM_CHANNELS);
624+
}
625+
620626
extern const struct ethtool_ops mlx5e_ethtool_ops;
621627
u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev);

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,16 @@ static void mlx5e_get_channels(struct net_device *dev,
345345
struct ethtool_channels *ch)
346346
{
347347
struct mlx5e_priv *priv = netdev_priv(dev);
348-
int ncv = priv->mdev->priv.eq_table.num_comp_vectors;
349348

350-
ch->max_combined = ncv;
349+
ch->max_combined = mlx5e_get_max_num_channels(priv->mdev);
351350
ch->combined_count = priv->params.num_channels;
352351
}
353352

354353
static int mlx5e_set_channels(struct net_device *dev,
355354
struct ethtool_channels *ch)
356355
{
357356
struct mlx5e_priv *priv = netdev_priv(dev);
358-
int ncv = priv->mdev->priv.eq_table.num_comp_vectors;
357+
int ncv = mlx5e_get_max_num_channels(priv->mdev);
359358
unsigned int count = ch->combined_count;
360359
bool was_opened;
361360
int err = 0;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,8 +2047,7 @@ static void *mlx5e_create_netdev(struct mlx5_core_dev *mdev)
20472047
{
20482048
struct net_device *netdev;
20492049
struct mlx5e_priv *priv;
2050-
int nch = min_t(int, mdev->priv.eq_table.num_comp_vectors,
2051-
MLX5E_MAX_NUM_CHANNELS);
2050+
int nch = mlx5e_get_max_num_channels(mdev);
20522051
int err;
20532052

20542053
if (mlx5e_check_required_hca_cap(mdev))

0 commit comments

Comments
 (0)