Skip to content

Commit 44fb6fb

Browse files
edumazetdavem330
authored andcommitted
mlx5: support napi_complete_done()
A NAPI poll handler should return number of RX packets processed, instead of 0 / budget. This allows proper busy poll accounting through LINUX_MIB_BUSYPOLLRXPACKETS SNMP counter. napi_complete_done() allows /sys/class/net/ethX/gro_flush_timeout to be used for finer GRO aggregation control. Tested: Enabled busy polling, and checked TcpExtBusyPollRxPackets counter is increasing. echo 70 >/proc/sys/net/core/busy_read nstat >/dev/null netperf -H target -t TCP_RR >/dev/null nstat | grep TcpExtBusyPollRxPackets TcpExtBusyPollRxPackets 490958 0.0 Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Eli Cohen <eli@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7ae92ae commit 44fb6fb

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ void mlx5e_completion_event(struct mlx5_core_cq *mcq);
564564
void mlx5e_cq_error_event(struct mlx5_core_cq *mcq, enum mlx5_event event);
565565
int mlx5e_napi_poll(struct napi_struct *napi, int budget);
566566
bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq);
567-
bool mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget);
567+
int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget);
568568
bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq);
569569
struct mlx5_cqe64 *mlx5e_get_cqe(struct mlx5e_cq *cq);
570570

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,16 @@ static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe,
216216
be16_to_cpu(cqe->vlan_info));
217217
}
218218

219-
bool mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
219+
int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
220220
{
221221
struct mlx5e_rq *rq = container_of(cq, struct mlx5e_rq, cq);
222-
int i;
222+
int work_done;
223223

224224
/* avoid accessing cq (dma coherent memory) if not needed */
225225
if (!test_and_clear_bit(MLX5E_CQ_HAS_CQES, &cq->flags))
226-
return false;
226+
return 0;
227227

228-
for (i = 0; i < budget; i++) {
228+
for (work_done = 0; work_done < budget; work_done++) {
229229
struct mlx5e_rx_wqe *wqe;
230230
struct mlx5_cqe64 *cqe;
231231
struct sk_buff *skb;
@@ -271,10 +271,8 @@ bool mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
271271
/* ensure cq space is freed before enabling more cqes */
272272
wmb();
273273

274-
if (i == budget) {
274+
if (work_done == budget)
275275
set_bit(MLX5E_CQ_HAS_CQES, &cq->flags);
276-
return true;
277-
}
278276

279-
return false;
277+
return work_done;
280278
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,34 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
5454
struct mlx5e_channel *c = container_of(napi, struct mlx5e_channel,
5555
napi);
5656
bool busy = false;
57+
int work_done;
5758
int i;
5859

5960
clear_bit(MLX5E_CHANNEL_NAPI_SCHED, &c->flags);
6061

6162
for (i = 0; i < c->num_tc; i++)
6263
busy |= mlx5e_poll_tx_cq(&c->sq[i].cq);
6364

64-
busy |= mlx5e_poll_rx_cq(&c->rq.cq, budget);
65-
65+
work_done = mlx5e_poll_rx_cq(&c->rq.cq, budget);
66+
busy |= work_done == budget;
6667
busy |= mlx5e_post_rx_wqes(&c->rq);
6768

6869
if (busy)
6970
return budget;
7071

71-
napi_complete(napi);
72+
napi_complete_done(napi, work_done);
7273

7374
/* avoid losing completion event during/after polling cqs */
7475
if (test_bit(MLX5E_CHANNEL_NAPI_SCHED, &c->flags)) {
7576
napi_schedule(napi);
76-
return 0;
77+
return work_done;
7778
}
7879

7980
for (i = 0; i < c->num_tc; i++)
8081
mlx5e_cq_arm(&c->sq[i].cq);
8182
mlx5e_cq_arm(&c->rq.cq);
8283

83-
return 0;
84+
return work_done;
8485
}
8586

8687
void mlx5e_completion_event(struct mlx5_core_cq *mcq)

0 commit comments

Comments
 (0)