[PATCH net-next 1/2] net/mlx5e: Reduce branches in napi poll

From: Tariq Toukan

Date: Thu May 14 2026 - 07:12:26 EST


Reduce the number of branches in napi poll, based on the following list
of dependencies:

1. xsk_open=t only if c->xdp and c->async_icosq.
2. c->xdpsq only if c->xdp.
3. c->xdp implies c->async_icosq.
4. ktls_rx_was_enabled implies c->async_icosq.

Signed-off-by: Tariq Toukan <tariqt@xxxxxxxxxx>
Reviewed-by: Dragos Tatulea <dtatulea@xxxxxxxxxx>
---
.../net/ethernet/mellanox/mlx5/core/en_txrx.c | 30 +++++++++----------
1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
index b31f689fe271..8df5bc5d0537 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
@@ -166,14 +166,13 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
if (unlikely(!budget))
goto out;

- if (c->xdpsq)
- busy |= mlx5e_poll_xdpsq_cq(&c->xdpsq->cq);
-
- if (c->xdp)
+ if (c->xdp) {
+ if (c->xdpsq)
+ busy |= mlx5e_poll_xdpsq_cq(&c->xdpsq->cq);
busy |= mlx5e_poll_xdpsq_cq(&c->rq_xdpsq.cq);
-
- if (xsk_open)
- work_done = mlx5e_poll_rx_cq(&xskrq->cq, budget);
+ if (xsk_open)
+ work_done += mlx5e_poll_rx_cq(&xskrq->cq, budget);
+ }

if (likely(budget - work_done))
work_done += mlx5e_poll_rx_cq(&rq->cq, budget - work_done);
@@ -192,18 +191,19 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
/* Keep after async ICOSQ CQ poll */
if (unlikely(mlx5e_ktls_rx_pending_resync_list(c, budget)))
busy |= mlx5e_ktls_rx_handle_resync_list(c, budget);
+
+ if (xsk_open) {
+ busy |= mlx5e_poll_xdpsq_cq(&xsksq->cq);
+ busy_xsk |= mlx5e_napi_xsk_post(xsksq, xskrq);
+
+ busy |= busy_xsk;
+ }
}

busy |= INDIRECT_CALL_2(rq->post_wqes,
mlx5e_post_rx_mpwqes,
mlx5e_post_rx_wqes,
rq);
- if (xsk_open) {
- busy |= mlx5e_poll_xdpsq_cq(&xsksq->cq);
- busy_xsk |= mlx5e_napi_xsk_post(xsksq, xskrq);
- }
-
- busy |= busy_xsk;

if (busy) {
if (likely(mlx5e_channel_no_affinity_change(c))) {
@@ -247,9 +247,9 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
mlx5e_cq_arm(&xsksq->cq);
mlx5e_cq_arm(&xskrq->cq);
}
+ if (c->xdpsq)
+ mlx5e_cq_arm(&c->xdpsq->cq);
}
- if (c->xdpsq)
- mlx5e_cq_arm(&c->xdpsq->cq);

if (unlikely(aff_change && busy_xsk)) {
mlx5e_trigger_irq(&c->icosq);
--
2.44.0