Skip to content

Commit e7e0004

Browse files
Maxim MikityanskiySaeed Mahameed
authored andcommitted
net/mlx5e: Don't trigger IRQ multiple times on XSK wakeup to avoid WQ overruns
XSK wakeup function triggers NAPI by posting a NOP WQE to a special XSK ICOSQ. When the application floods the driver with wakeup requests by calling sendto() in a certain pattern that ends up in mlx5e_trigger_irq, the XSK ICOSQ may overflow. Multiple NOPs are not required and won't accelerate the process, so avoid posting a second NOP if there is one already on the way. This way we also avoid increasing the queue size (which might not help anyway). Fixes: db05815 ("net/mlx5e: Add XSK zero-copy support") Signed-off-by: Maxim Mikityanskiy <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 70840b6 commit e7e0004

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ enum {
367367
MLX5E_SQ_STATE_AM,
368368
MLX5E_SQ_STATE_TLS,
369369
MLX5E_SQ_STATE_VLAN_NEED_L2_INLINE,
370+
MLX5E_SQ_STATE_PENDING_XSK_TX,
370371
};
371372

372373
struct mlx5e_sq_wqe_info {
@@ -960,7 +961,7 @@ void mlx5e_page_release_dynamic(struct mlx5e_rq *rq,
960961
void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
961962
void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
962963
bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq);
963-
void mlx5e_poll_ico_cq(struct mlx5e_cq *cq);
964+
int mlx5e_poll_ico_cq(struct mlx5e_cq *cq);
964965
bool mlx5e_post_rx_mpwqes(struct mlx5e_rq *rq);
965966
void mlx5e_dealloc_rx_wqe(struct mlx5e_rq *rq, u16 ix);
966967
void mlx5e_dealloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix);

drivers/net/ethernet/mellanox/mlx5/core/en/xsk/tx.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ int mlx5e_xsk_wakeup(struct net_device *dev, u32 qid, u32 flags)
3333
if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &c->xskicosq.state)))
3434
return 0;
3535

36+
if (test_and_set_bit(MLX5E_SQ_STATE_PENDING_XSK_TX, &c->xskicosq.state))
37+
return 0;
38+
3639
spin_lock(&c->xskicosq_lock);
3740
mlx5e_trigger_irq(&c->xskicosq);
3841
spin_unlock(&c->xskicosq_lock);

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,19 +589,19 @@ bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq)
589589
return !!err;
590590
}
591591

592-
void mlx5e_poll_ico_cq(struct mlx5e_cq *cq)
592+
int mlx5e_poll_ico_cq(struct mlx5e_cq *cq)
593593
{
594594
struct mlx5e_icosq *sq = container_of(cq, struct mlx5e_icosq, cq);
595595
struct mlx5_cqe64 *cqe;
596596
u16 sqcc;
597597
int i;
598598

599599
if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &sq->state)))
600-
return;
600+
return 0;
601601

602602
cqe = mlx5_cqwq_get_cqe(&cq->wq);
603603
if (likely(!cqe))
604-
return;
604+
return 0;
605605

606606
/* sq->cc must be updated only after mlx5_cqwq_update_db_record(),
607607
* otherwise a cq overrun may occur
@@ -650,6 +650,8 @@ void mlx5e_poll_ico_cq(struct mlx5e_cq *cq)
650650
sq->cc = sqcc;
651651

652652
mlx5_cqwq_update_db_record(&cq->wq);
653+
654+
return i;
653655
}
654656

655657
bool mlx5e_post_rx_mpwqes(struct mlx5e_rq *rq)

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
152152
mlx5e_post_rx_wqes,
153153
rq);
154154
if (xsk_open) {
155-
mlx5e_poll_ico_cq(&c->xskicosq.cq);
155+
if (mlx5e_poll_ico_cq(&c->xskicosq.cq))
156+
/* Don't clear the flag if nothing was polled to prevent
157+
* queueing more WQEs and overflowing XSKICOSQ.
158+
*/
159+
clear_bit(MLX5E_SQ_STATE_PENDING_XSK_TX, &c->xskicosq.state);
156160
busy |= mlx5e_poll_xdpsq_cq(&xsksq->cq);
157161
busy_xsk |= mlx5e_napi_xsk_post(xsksq, xskrq);
158162
}

0 commit comments

Comments
 (0)