Skip to content

Commit 2a8d606

Browse files
author
Saeed Mahameed
committed
net/mlx5e: Fix napi poll with zero budget
napi->poll can be called with budget 0, e.g. in netpoll scenarios where the caller only wants to poll TX rings (poll_one_napi@net/core/netpoll.c). The below commit changed RX polling from "while" loop to "do {} while", which caused to ignore the initial budget and handle at least one RX packet. This fixes the following warning: [ 2852.049194] mlx5e_napi_poll+0x0/0x260 [mlx5_core] exceeded budget in poll [ 2852.049195] ------------[ cut here ]------------ [ 2852.049195] WARNING: CPU: 0 PID: 25691 at net/core/netpoll.c:171 netpoll_poll_dev+0x18a/0x1a0 Fixes: 4b7dfc9 ("net/mlx5e: Early-return on empty completion queues") Signed-off-by: Saeed Mahameed <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Reported-by: Martin KaFai Lau <[email protected]> Tested-by: Martin KaFai Lau <[email protected]> Cc: [email protected] Signed-off-by: Saeed Mahameed <[email protected]>
1 parent d2aa060 commit 2a8d606

File tree

1 file changed

+6
-4
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
4949
struct mlx5e_channel *c = container_of(napi, struct mlx5e_channel,
5050
napi);
5151
bool busy = false;
52-
int work_done;
52+
int work_done = 0;
5353
int i;
5454

5555
for (i = 0; i < c->num_tc; i++)
@@ -58,15 +58,17 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
5858
if (c->xdp)
5959
busy |= mlx5e_poll_xdpsq_cq(&c->rq.xdpsq.cq);
6060

61-
work_done = mlx5e_poll_rx_cq(&c->rq.cq, budget);
62-
busy |= work_done == budget;
61+
if (likely(budget)) { /* budget=0 means: don't poll rx rings */
62+
work_done = mlx5e_poll_rx_cq(&c->rq.cq, budget);
63+
busy |= work_done == budget;
64+
}
6365

6466
busy |= c->rq.post_wqes(&c->rq);
6567

6668
if (busy) {
6769
if (likely(mlx5e_channel_no_affinity_change(c)))
6870
return budget;
69-
if (work_done == budget)
71+
if (budget && work_done == budget)
7072
work_done--;
7173
}
7274

0 commit comments

Comments
 (0)