net/mlx5e: simplify and optimize napi poll flow
Subsystems (7)
Tariq Toukan
maintainercover net/mlx5e: simplify and optimize napi poll flow
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
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 1/2 net/mlx5e: Reduce branches in napi poll
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.
--- .../net/ethernet/mellanox/mlx5/core/en_txrx.c | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +15 -15
@@ -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);
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 2/2 net/mlx5e: Let kTLS RX get async ICOSQ param in napi poll
In reply to Tariq ToukanDo 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.
--- .../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(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +1 -4
@@ -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;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h +6 -6
@@ -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; }
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +3 -2
@@ -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);
Signature · 1 line
2.44.0
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Thu, 14 May 2026 14:10:36 +0300 you wrote:
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.
[...]
Here is the summary with links:
- [net-next,1/2] net/mlx5e: Reduce branches in napi poll
https://git.kernel.org/netdev/net-next/c/cc199cd1b912 - [net-next,2/2] net/mlx5e: Let kTLS RX get async ICOSQ param in napi poll https://git.kernel.org/netdev/net-next/c/425d0e2df5c2
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html