]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/mlx5e: Reduce branches in napi poll
authorTariq Toukan <tariqt@nvidia.com>
Thu, 14 May 2026 11:10:37 +0000 (14:10 +0300)
committerJakub Kicinski <kuba@kernel.org>
Tue, 19 May 2026 01:45:49 +0000 (18:45 -0700)
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@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Link: https://patch.msgid.link/20260514111038.338251-2-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c

index b31f689fe271ccbb5ea792840cc5821248ab15bb..8df5bc5d0537de1087a59f5af1c10fdd0b36959d 100644 (file)
@@ -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);