Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net/mlx5e: simplify and optimize napi poll flow
@ 2026-05-14 11:10 Tariq Toukan
  2026-05-14 11:10 ` [PATCH net-next 1/2] net/mlx5e: Reduce branches in napi poll Tariq Toukan
  2026-05-14 11:10 ` [PATCH net-next 2/2] net/mlx5e: Let kTLS RX get async ICOSQ param " Tariq Toukan
  0 siblings, 2 replies; 3+ messages in thread
From: Tariq Toukan @ 2026-05-14 11:10 UTC (permalink / raw)
  To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
	David S. Miller
  Cc: Boris Pismenny, Saeed Mahameed, Leon Romanovsky, Tariq Toukan,
	Mark Bloch, Alexei Starovoitov, Daniel Borkmann,
	Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
	Shahar Shitrit, William Tu, Kuniyuki Iwashima, Dragos Tatulea,
	Sabrina Dubroca, Kees Cook, netdev, linux-rdma, linux-kernel, bpf,
	Gal Pressman

Hi,

This series simplifies the mlx5e napi poll flow and reduces branching in
hot paths by leveraging existing dependencies between channel features.

Patch 1 avoids passing the full channel object to kTLS RX code paths
when only the async ICOSQ is needed, and slightly optimizes the common
flow in the pending resync handling logic.

Patch 2 further reduces branches in napi poll by relying on established
feature dependencies between XDP, async ICOSQ, XSK, and kTLS RX state.

Regards,
Tariq

Tariq Toukan (2):
  net/mlx5e: Reduce branches in napi poll
  net/mlx5e: Let kTLS RX get async ICOSQ param in napi poll

 .../mellanox/mlx5/core/en_accel/ktls_rx.c     |  5 +--
 .../mellanox/mlx5/core/en_accel/ktls_txrx.h   | 12 +++----
 .../net/ethernet/mellanox/mlx5/core/en_txrx.c | 35 ++++++++++---------
 3 files changed, 25 insertions(+), 27 deletions(-)


base-commit: 18dc8e6d15d7a30888beec46a1e01ca0f98508fa
-- 
2.44.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH net-next 1/2] net/mlx5e: Reduce branches in napi poll
  2026-05-14 11:10 [PATCH net-next 0/2] net/mlx5e: simplify and optimize napi poll flow Tariq Toukan
@ 2026-05-14 11:10 ` Tariq Toukan
  2026-05-14 11:10 ` [PATCH net-next 2/2] net/mlx5e: Let kTLS RX get async ICOSQ param " Tariq Toukan
  1 sibling, 0 replies; 3+ messages in thread
From: Tariq Toukan @ 2026-05-14 11:10 UTC (permalink / raw)
  To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
	David S. Miller
  Cc: Boris Pismenny, Saeed Mahameed, Leon Romanovsky, Tariq Toukan,
	Mark Bloch, Alexei Starovoitov, Daniel Borkmann,
	Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
	Shahar Shitrit, William Tu, Kuniyuki Iwashima, Dragos Tatulea,
	Sabrina Dubroca, Kees Cook, netdev, linux-rdma, linux-kernel, bpf,
	Gal Pressman

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>
---
 .../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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH net-next 2/2] net/mlx5e: Let kTLS RX get async ICOSQ param in napi poll
  2026-05-14 11:10 [PATCH net-next 0/2] net/mlx5e: simplify and optimize napi poll flow Tariq Toukan
  2026-05-14 11:10 ` [PATCH net-next 1/2] net/mlx5e: Reduce branches in napi poll Tariq Toukan
@ 2026-05-14 11:10 ` Tariq Toukan
  1 sibling, 0 replies; 3+ messages in thread
From: Tariq Toukan @ 2026-05-14 11:10 UTC (permalink / raw)
  To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
	David S. Miller
  Cc: Boris Pismenny, Saeed Mahameed, Leon Romanovsky, Tariq Toukan,
	Mark Bloch, Alexei Starovoitov, Daniel Borkmann,
	Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
	Shahar Shitrit, William Tu, Kuniyuki Iwashima, Dragos Tatulea,
	Sabrina Dubroca, Kees Cook, netdev, linux-rdma, linux-kernel, bpf,
	Gal Pressman

Do not pass channel just to extract the async ICOSQ.
It's already extracted, pass it.

Re-order the checks in mlx5e_ktls_rx_pending_resync_list to optimize the
common flow.

Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
---
 .../ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c   |  5 +----
 .../ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h | 12 ++++++------
 drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c    |  5 +++--
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c
index ac8168ebb38c..bca45679e201 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c
@@ -744,17 +744,14 @@ void mlx5e_ktls_del_rx(struct net_device *netdev, struct tls_context *tls_ctx)
 	mlx5e_ktls_priv_rx_put(priv_rx);
 }
 
-bool mlx5e_ktls_rx_handle_resync_list(struct mlx5e_channel *c, int budget)
+bool mlx5e_ktls_rx_handle_resync_list(struct mlx5e_icosq *sq, int budget)
 {
 	struct mlx5e_ktls_offload_context_rx *priv_rx, *tmp;
 	struct mlx5e_ktls_resync_resp *ktls_resync;
 	struct mlx5_wqe_ctrl_seg *db_cseg;
-	struct mlx5e_icosq *sq;
 	LIST_HEAD(local_list);
 	int i, j;
 
-	sq = c->async_icosq;
-
 	if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &sq->state)))
 		return false;
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h
index 4022c7e78a2e..93bd383a23d8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h
@@ -45,13 +45,13 @@ mlx5e_ktls_tx_try_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
 	return false;
 }
 
-bool mlx5e_ktls_rx_handle_resync_list(struct mlx5e_channel *c, int budget);
+bool mlx5e_ktls_rx_handle_resync_list(struct mlx5e_icosq *sq, int budget);
 
 static inline bool
-mlx5e_ktls_rx_pending_resync_list(struct mlx5e_channel *c, int budget)
+mlx5e_ktls_rx_pending_resync_list(struct mlx5e_icosq *sq, int budget)
 {
-	return budget && test_bit(MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC,
-				  &c->async_icosq->state);
+	return test_bit(MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC, &sq->state) &&
+		budget;
 }
 
 static inline void
@@ -70,13 +70,13 @@ mlx5e_ktls_tx_try_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
 }
 
 static inline bool
-mlx5e_ktls_rx_handle_resync_list(struct mlx5e_channel *c, int budget)
+mlx5e_ktls_rx_handle_resync_list(struct mlx5e_icosq *sq, int budget)
 {
 	return false;
 }
 
 static inline bool
-mlx5e_ktls_rx_pending_resync_list(struct mlx5e_channel *c, int budget)
+mlx5e_ktls_rx_pending_resync_list(struct mlx5e_icosq *sq, int budget)
 {
 	return false;
 }
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
index 8df5bc5d0537..143890af516a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
@@ -189,8 +189,9 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
 				  &aicosq->state);
 
 		/* 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 (unlikely(mlx5e_ktls_rx_pending_resync_list(aicosq, budget)))
+			busy |= mlx5e_ktls_rx_handle_resync_list(aicosq,
+								 budget);
 
 		if (xsk_open) {
 			busy |= mlx5e_poll_xdpsq_cq(&xsksq->cq);
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-14 11:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-14 11:10 [PATCH net-next 0/2] net/mlx5e: simplify and optimize napi poll flow Tariq Toukan
2026-05-14 11:10 ` [PATCH net-next 1/2] net/mlx5e: Reduce branches in napi poll Tariq Toukan
2026-05-14 11:10 ` [PATCH net-next 2/2] net/mlx5e: Let kTLS RX get async ICOSQ param " Tariq Toukan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox