diff options
| author | Jakub Kicinski <kuba@kernel.org> | 2026-05-19 04:45:52 +0300 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-05-19 04:45:53 +0300 |
| commit | f79a0466a46f81e5b42458fcbec033280c841293 (patch) | |
| tree | 29d924f073188335239f100dd3f1e656f43391c8 | |
| parent | 086abf9da661e3da9a9ef40b36963b230ec58112 (diff) | |
| parent | 425d0e2df5c205db07b2b903ac575044ca948d5b (diff) | |
| download | linux-f79a0466a46f81e5b42458fcbec033280c841293.tar.xz | |
Merge branch 'net-mlx5e-simplify-and-optimize-napi-poll-flow'
Tariq Toukan says:
====================
net/mlx5e: simplify and optimize napi poll flow
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.
====================
Link: https://patch.msgid.link/20260514111038.338251-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 files changed, 25 insertions, 27 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 b31f689fe271..143890af516a 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); @@ -190,20 +189,22 @@ 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); + 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 +248,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); |
