]> git.baikalelectronics.ru Git - kernel.git/commit
net/mlx5e: Add an underflow warning comment
authorMaxim Mikityanskiy <maximmi@mellanox.com>
Wed, 27 Mar 2019 11:39:21 +0000 (13:39 +0200)
committerSaeed Mahameed <saeedm@mellanox.com>
Tue, 23 Apr 2019 19:09:21 +0000 (12:09 -0700)
commit347780e33b796c39d7d7cbc6a6d59cf00a512f01
tree93c95eef33aeeb91957d179fb28f62cf935ed9b4
parent1a9bf5b4ffe3d18c5c0b319e3639d25e62a98f9b
net/mlx5e: Add an underflow warning comment

mlx5e_mpwqe_get_log_rq_size calculates the number of WQEs (N) based on
the requested number of frames in the RQ (F) and the number of packets
per WQE (P). It ensures that N is not less than the minimum number of
WQEs in an RQ (N_min). Arithmetically, it means that F / P >= N_min
should be true. This function deals with logarithms, so it should check
that log(F) - log(P) >= log(N_min). However, if F < P, this expression
will cause an unsigned underflow. Check log(F) >= log(P) + log(N_min)
instead.

Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en/params.c