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>
This commit is contained in:
Jakub Kicinski 2026-05-18 18:45:52 -07:00
commit f79a0466a4
3 changed files with 25 additions and 27 deletions

View File

@ -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;

View File

@ -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;
}

View 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);
@ -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);