Skip to content

Commit 846d6da

Browse files
Maxim MikityanskiySaeed Mahameed
authored andcommitted
net/mlx5e: Fix division by 0 in mlx5e_select_queue
mlx5e_select_queue compares num_tc_x_num_ch to real_num_tx_queues to determine if HTB and/or PTP offloads are active. If they are, it calculates netdev_pick_tx() % num_tc_x_num_ch to prevent it from selecting HTB and PTP queues for regular traffic. However, before the channels are first activated, num_tc_x_num_ch is zero. If ndo_select_queue gets called at this point, the HTB/PTP check will pass, and mlx5e_select_queue will attempt to take a modulo by num_tc_x_num_ch, which equals to zero. This commit fixes the bug by assigning num_tc_x_num_ch to a non-zero value before registering the netdev. Fixes: 214baf2 ("net/mlx5e: Support HTB offload") Reported-by: Jesper Dangaard Brouer <[email protected]> Signed-off-by: Maxim Mikityanskiy <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 4eacfe7 commit 846d6da

File tree

1 file changed

+5
-0
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4979,6 +4979,11 @@ void mlx5e_build_nic_params(struct mlx5e_priv *priv, struct mlx5e_xsk *xsk, u16
49794979
priv->max_nch);
49804980
params->num_tc = 1;
49814981

4982+
/* Set an initial non-zero value, so that mlx5e_select_queue won't
4983+
* divide by zero if called before first activating channels.
4984+
*/
4985+
priv->num_tc_x_num_ch = params->num_channels * params->num_tc;
4986+
49824987
/* SQ */
49834988
params->log_sq_size = is_kdump_kernel() ?
49844989
MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE :

0 commit comments

Comments
 (0)