diff options
author | Saeed Mahameed <saeedm@mellanox.com> | 2017-10-31 18:34:00 -0400 |
---|---|---|
committer | Saeed Mahameed <saeedm@mellanox.com> | 2017-11-10 01:39:20 -0500 |
commit | 2a8d6065e7b90ad9d5540650944d802b0f86bdfe (patch) | |
tree | 1986cbf86d179ac840942b2baad28333f76b463c | |
parent | d2aa060d40fa060e963f9a356d43481e43ba3dac (diff) |
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: 4b7dfc992514 ("net/mlx5e: Early-return on empty completion queues")
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Reported-by: Martin KaFai Lau <kafai@fb.com>
Tested-by: Martin KaFai Lau <kafai@fb.com>
Cc: kernel-team@fb.com
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c index e906b754415c..ab92298eafc3 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | |||
@@ -49,7 +49,7 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget) | |||
49 | struct mlx5e_channel *c = container_of(napi, struct mlx5e_channel, | 49 | struct mlx5e_channel *c = container_of(napi, struct mlx5e_channel, |
50 | napi); | 50 | napi); |
51 | bool busy = false; | 51 | bool busy = false; |
52 | int work_done; | 52 | int work_done = 0; |
53 | int i; | 53 | int i; |
54 | 54 | ||
55 | for (i = 0; i < c->num_tc; i++) | 55 | for (i = 0; i < c->num_tc; i++) |
@@ -58,15 +58,17 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget) | |||
58 | if (c->xdp) | 58 | if (c->xdp) |
59 | busy |= mlx5e_poll_xdpsq_cq(&c->rq.xdpsq.cq); | 59 | busy |= mlx5e_poll_xdpsq_cq(&c->rq.xdpsq.cq); |
60 | 60 | ||
61 | work_done = mlx5e_poll_rx_cq(&c->rq.cq, budget); | 61 | if (likely(budget)) { /* budget=0 means: don't poll rx rings */ |
62 | busy |= work_done == budget; | 62 | work_done = mlx5e_poll_rx_cq(&c->rq.cq, budget); |
63 | busy |= work_done == budget; | ||
64 | } | ||
63 | 65 | ||
64 | busy |= c->rq.post_wqes(&c->rq); | 66 | busy |= c->rq.post_wqes(&c->rq); |
65 | 67 | ||
66 | if (busy) { | 68 | if (busy) { |
67 | if (likely(mlx5e_channel_no_affinity_change(c))) | 69 | if (likely(mlx5e_channel_no_affinity_change(c))) |
68 | return budget; | 70 | return budget; |
69 | if (work_done == budget) | 71 | if (budget && work_done == budget) |
70 | work_done--; | 72 | work_done--; |
71 | } | 73 | } |
72 | 74 | ||