net/mlx5e: Save per-channel async ICOSQ in default
Subsystems (6)
Tariq Toukan
maintainerv2 cover net/mlx5e: Save per-channel async ICOSQ in default
Hi,
This is V2, find V1 here:
https://lore.kernel.org/all/[email protected]/
This series by William reduces the default number of SQs in a channel from 3 down to 2, by not creating the async ICOSQ (asynchronous internal-communication-operations send-queue).
This significantly improves the latency of channel configuration operations, like interface up (create channels), interface down (destroy channels), and channels reconfiguration (create new set, destroy old one).
This reduces the per-channel memory usage, saves hardware resources, in addition to the improved latency.
This significantly speeds up the setup/config stage on systems with high number of channels or many netdevs, in particular systems with hundreds or K's of SFs.
The two remaining default SQs per channel after this series:
1 TXQ SQ (for traffic), and 1 ICOSQ (for internal communication operations with the device).
Perf numbers:
NIC: Connect-X7.
Test: Latency of interface up + down operations.
Measured 20% speedup.
Saving ~0.36 sec for 248 channels (~1.45 msec per channel).
Regards,
Tariq
V2:
- Drop accepted parts (patches 5-6).
- Patch 2:
Add conditional locking justification in commit message. Remove in_softirq() optimization.
- Patch 4:
Simple code enhancements.
Update commit message.
William Tu (4):
net/mlx5e: Move async ICOSQ lock into ICOSQ struct net/mlx5e: Use regular ICOSQ for triggering NAPI net/mlx5e: Move async ICOSQ to dynamic allocation net/mlx5e: Conditionally create async ICOSQ
drivers/net/ethernet/mellanox/mlx5/core/en.h | 26 ++++- .../mellanox/mlx5/core/en/reporter_tx.c | 1 + .../ethernet/mellanox/mlx5/core/en/xsk/rx.c | 3 + .../ethernet/mellanox/mlx5/core/en/xsk/tx.c | 6 +- .../mellanox/mlx5/core/en_accel/ktls.c | 10 +- .../mellanox/mlx5/core/en_accel/ktls_rx.c | 26 ++--- .../mellanox/mlx5/core/en_accel/ktls_txrx.h | 3 +- .../net/ethernet/mellanox/mlx5/core/en_main.c | 100 +++++++++++++----- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 4 + .../net/ethernet/mellanox/mlx5/core/en_txrx.c | 37 ++++--- 10 files changed, 154 insertions(+), 62 deletions(-)
base-commit: 3b194343c25084a8d2fa0c0f2c9e80f3080fd732
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH v2 1/4 net/mlx5e: Move async ICOSQ lock into ICOSQ struct
From: William Tu <[email protected]>
Move the async_icosq spinlock from the mlx5e_channel structure into the mlx5e_icosq structure itself for better encapsulation and for later patch to also use it for other icosq use cases.
Changes:
- Add spinlock_t lock field to struct mlx5e_icosq
- Remove async_icosq_lock field from struct mlx5e_channel
- Initialize the new lock in mlx5e_open_icosq()
- Update all lock usage in ktls_rx.c and en_main.c to use sq->lock instead of c->async_icosq_lock
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 4 ++-- .../mellanox/mlx5/core/en_accel/ktls_rx.c | 18 +++++++++--------- .../net/ethernet/mellanox/mlx5/core/en_main.c | 12 +++++++----- 3 files changed, 18 insertions(+), 16 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +2 -2
@@ -545,6 +545,8 @@ struct mlx5e_icosq {u32 sqn;u16 reserved_room;unsigned long state; +/* icosq can be accessed from any CPU - the spinlock protects it. */ +spinlock_t lock;struct mlx5e_ktls_resync_resp *ktls_resync;/* control path */
@@ -777,8 +779,6 @@ struct mlx5e_channel {/* Async ICOSQ */ struct mlx5e_icosq async_icosq; -/* async_icosq can be accessed from any CPU - the spinlock protects it. */ -spinlock_t async_icosq_lock;/* data path - accessed per napi poll */ const struct cpumask *aff_mask;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +9 -9
@@ -203,7 +203,7 @@ static int post_rx_param_wqes(struct mlx5e_channel *c, err =0 ; sq = &c->async_icosq; -spin_lock_bh (&c->async_icosq_lock); +spin_lock_bh (&sq->lock); cseg =post_static_params (sq, priv_rx);if (IS_ERR (cseg))
@@ -214,7 +214,7 @@ static int post_rx_param_wqes(struct mlx5e_channel *c,mlx5e_notify_hw (&sq->wq, sq->pc, sq->uar_map, cseg); unlock: -spin_unlock_bh (&c->async_icosq_lock); +spin_unlock_bh (&sq->lock);return err;
@@ -277,10 +277,10 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq, buf->priv_rx = priv_rx; -spin_lock_bh (&sq->channel->async_icosq_lock); +spin_lock_bh (&sq->lock);if (unlikely (!mlx5e_icosq_can_post_wqe (sq,MLX5E_KTLS_GET_PROGRESS_WQEBBS ))) { -spin_unlock_bh (&sq->channel->async_icosq_lock); +spin_unlock_bh (&sq->lock); err = -ENOSPC ; goto err_dma_unmap; }
@@ -311,7 +311,7 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq,icosq_fill_wi (sq, pi, &wi); sq->pc++;mlx5e_notify_hw (&sq->wq, sq->pc, sq->uar_map, cseg); -spin_unlock_bh (&sq->channel->async_icosq_lock); +spin_unlock_bh (&sq->lock);return 0 ;
@@ -413,9 +413,9 @@ static void resync_handle_seq_match(struct mlx5e_ktls_offload_context_rx *priv_rreturn ;if (!napi_if_scheduled_mark_missed (&c->napi)) { -spin_lock_bh (&c->async_icosq_lock); +spin_lock_bh (&sq->lock);mlx5e_trigger_irq (sq); -spin_unlock_bh (&c->async_icosq_lock); +spin_unlock_bh (&sq->lock); } }
@@ -772,7 +772,7 @@ bool mlx5e_ktls_rx_handle_resync_list(struct mlx5e_channel *c, int budget)clear_bit (MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC , &sq->state);spin_unlock (&ktls_resync->lock); -spin_lock (&c->async_icosq_lock); +spin_lock (&sq->lock);for (j =0 ; j < i; j++) {struct mlx5_wqe_ctrl_seg *cseg;
@@ -791,7 +791,7 @@ bool mlx5e_ktls_rx_handle_resync_list(struct mlx5e_channel *c, int budget) }if (db_cseg)mlx5e_notify_hw (&sq->wq, sq->pc, sq->uar_map, db_cseg); -spin_unlock (&c->async_icosq_lock); +spin_unlock (&sq->lock); priv_rx->rq_stats->tls_resync_res_ok += j;
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +7 -5
@@ -2075,6 +2075,8 @@ static int mlx5e_open_icosq(struct mlx5e_channel *c, struct mlx5e_params *paramsif (err) goto err_free_icosq; +spin_lock_init (&sq->lock); +if (param->is_tls) { sq->ktls_resync =mlx5e_ktls_rx_resync_create_resp_list ();if (IS_ERR (sq->ktls_resync)) {
@@ -2630,8 +2632,6 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,if (err) goto err_close_rx_cq; -spin_lock_init (&c->async_icosq_lock); - err =mlx5e_open_icosq (c, params, &cparam->async_icosq, &c->async_icosq, mlx5e_async_icosq_err_cqe_work);if (err)
@@ -2750,9 +2750,11 @@ static int mlx5e_channel_stats_alloc(struct mlx5e_priv *priv, int ix, int cpu)void mlx5e_trigger_napi_icosq (struct mlx5e_channel *c) { -spin_lock_bh (&c->async_icosq_lock); -mlx5e_trigger_irq (&c->async_icosq); -spin_unlock_bh (&c->async_icosq_lock); +struct mlx5e_icosq *async_icosq = &c->async_icosq; + +spin_lock_bh (&async_icosq->lock); +mlx5e_trigger_irq (async_icosq); +spin_unlock_bh (&async_icosq->lock); }void mlx5e_trigger_napi_sched (struct napi_struct *napi)
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH v2 2/4 net/mlx5e: Use regular ICOSQ for triggering NAPI
In reply to Tariq ToukanFrom: William Tu <[email protected]>
Before the cited commit, ICOSQ is used to post NOP WQE to trigger hardware interrupt and start NAPI, but this mechanism suffers from a race condition: mlx5e_alloc_rx_mpwqe may post UMR WQEs to ICOSQ _before_ NOP WQE is posted. The cited commit fixes the issue by replacing ICOSQ with async ICOSQ, as a new way to post the NOP WQE to trigger the hardware interrupt and NAPI.
The patch changes it back by replacing async ICOSQ with regular ICOSQ, for the purpose of saving memory in later patches, and solves the issue by adding a new SQ state, MLX5E_SQ_STATE_LOCK_NEEDED for syncing the start of NAPI.
What it does:
- Switch trigger path from async ICOSQ to regular ICOSQ to reduce need for async SQ.
- Introduce MLX5E_SQ_STATE_LOCK_NEEDED and mlx5e_icosq_sync_lock(), unlock() to prevent the race where UMR WQEs could be posted before the NOP WQE used to trigger NAPI.
- Use synchronize_net() once per trigger cycle to quiesce in-flight softirqs before serializing the NOP WQE and any UMR postings via the ICOSQ lock.
- Wrap ICOSQ UMR posting in en_rx.c and xsk/rx.c with the new conditional lock.
The conditional locking approach is critical for performance: always locking would impose unnecessary overhead. Synchronization is not needed between regular NAPI cycles once the channel is activated and running. The lock is only required to protect against the race during channel activation—specifically, when the very first NOP WQE is posted to trigger NAPI. After that initial trigger, normal NAPI polling handles subsequent work without contention. The MLX5E_SQ_STATE_LOCK_NEEDED flag ensures we pay the synchronization cost only when necessary.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 21 ++++++++++++++++++- .../mellanox/mlx5/core/en/reporter_tx.c | 1 + .../ethernet/mellanox/mlx5/core/en/xsk/rx.c | 3 +++ .../net/ethernet/mellanox/mlx5/core/en_main.c | 13 ++++++++---- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 4 ++++ 5 files changed, 37 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +20 -1
@@ -388,6 +388,7 @@ enum {MLX5E_SQ_STATE_DIM ,MLX5E_SQ_STATE_PENDING_XSK_TX ,MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC , +MLX5E_SQ_STATE_LOCK_NEEDED , MLX5E_NUM_SQ_STATES, /* Must be kept last */ };
@@ -545,7 +546,10 @@ struct mlx5e_icosq {u32 sqn;u16 reserved_room;unsigned long state; -/* icosq can be accessed from any CPU - the spinlock protects it. */ +/* icosq can be accessed from any CPU and from different contexts +* (NAPI softirq or process/workqueue). Always use spin_lock_bh for +* simplicity and correctness across all contexts. +*/ spinlock_t lock;struct mlx5e_ktls_resync_resp *ktls_resync;
@@ -801,6 +805,21 @@ struct mlx5e_channel {struct dim_cq_moder tx_cq_moder; }; +static inline bool mlx5e_icosq_sync_lock (struct mlx5e_icosq *sq) +{ +if (likely (!test_bit (MLX5E_SQ_STATE_LOCK_NEEDED , &sq->state))) +return false; + +spin_lock_bh (&sq->lock); +return true; +} + +static inline void mlx5e_icosq_sync_unlock (struct mlx5e_icosq *sq,bool locked) +{ +if (unlikely (locked)) +spin_unlock_bh (&sq->lock); +} +struct mlx5e_ptp ;struct mlx5e_channels {
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c +1 -0
@@ -15,6 +15,7 @@ static const char * const sq_sw_state_type_name[] = { [MLX5E_SQ_STATE_DIM] = "dim", [MLX5E_SQ_STATE_PENDING_XSK_TX] = "pending_xsk_tx", [MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC] = "pending_tls_rx_resync", + [MLX5E_SQ_STATE_LOCK_NEEDED] = "lock_needed", };static int mlx5e_wait_for_sq_flush (struct mlx5e_txqsq *sq)
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c +3 -0
@@ -23,6 +23,7 @@ int mlx5e_xsk_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix)struct mlx5_wq_cyc *wq = &icosq->wq;struct mlx5e_umr_wqe *umr_wqe;struct xdp_buff **xsk_buffs; +bool sync_locked;int batch, i;u32 offset;/* 17-bit value with MTT. */ u16 pi;
@@ -47,6 +48,7 @@ int mlx5e_xsk_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix) goto err_reuse_batch; } + sync_locked =mlx5e_icosq_sync_lock (icosq); pi =mlx5e_icosq_get_next_pi (icosq, rq->mpwqe.umr_wqebbs); umr_wqe =mlx5_wq_cyc_get_wqe (wq, pi);memcpy (umr_wqe, &rq->mpwqe.umr_wqe,sizeof (struct mlx5e_umr_wqe ));
@@ -143,6 +145,7 @@ int mlx5e_xsk_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix) }; icosq->pc += rq->mpwqe.umr_wqebbs; +mlx5e_icosq_sync_unlock (icosq, sync_locked); icosq->doorbell_cseg = &umr_wqe->hdr.ctrl;
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +9 -4
@@ -2750,11 +2750,16 @@ static int mlx5e_channel_stats_alloc(struct mlx5e_priv *priv, int ix, int cpu)void mlx5e_trigger_napi_icosq (struct mlx5e_channel *c) { -struct mlx5e_icosq *async_icosq = &c->async_icosq; +bool locked; -spin_lock_bh (&async_icosq->lock); -mlx5e_trigger_irq (async_icosq); -spin_unlock_bh (&async_icosq->lock); +if (!test_and_set_bit (MLX5E_SQ_STATE_LOCK_NEEDED , &c->icosq.state)) +synchronize_net (); + + locked =mlx5e_icosq_sync_lock (&c->icosq); +mlx5e_trigger_irq (&c->icosq); +mlx5e_icosq_sync_unlock (&c->icosq, locked); + +clear_bit (MLX5E_SQ_STATE_LOCK_NEEDED , &c->icosq.state); }void mlx5e_trigger_napi_sched (struct napi_struct *napi)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +4 -0
@@ -778,6 +778,7 @@ static int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix)struct mlx5_wq_cyc *wq = &sq->wq;struct mlx5e_umr_wqe *umr_wqe;u32 offset;/* 17-bit value with MTT. */ +bool sync_locked;u16 pi;int err;int i;
@@ -788,6 +789,7 @@ static int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix) goto err; } + sync_locked =mlx5e_icosq_sync_lock (sq); pi =mlx5e_icosq_get_next_pi (sq, rq->mpwqe.umr_wqebbs); umr_wqe =mlx5_wq_cyc_get_wqe (wq, pi);memcpy (umr_wqe, &rq->mpwqe.umr_wqe,sizeof (struct mlx5e_umr_wqe ));
@@ -835,12 +837,14 @@ static int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix) }; sq->pc += rq->mpwqe.umr_wqebbs; +mlx5e_icosq_sync_unlock (sq, sync_locked); sq->doorbell_cseg = &umr_wqe->hdr.ctrl;return 0 ; err_unmap: +mlx5e_icosq_sync_unlock (sq, sync_locked);while (--i >=0 ) { frag_page--;mlx5e_page_release_fragmented (rq->page_pool, frag_page);
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH v2 3/4 net/mlx5e: Move async ICOSQ to dynamic allocation
In reply to Tariq ToukanFrom: William Tu <[email protected]>
Dynamically allocate async ICOSQ. ICO (Internal Communication Operations) is for driver to communicate with the HW, and it's not used for traffic. Currently mlx5 driver has sync and async ICO send queues. The async ICOSQ means that it's not necessarily under NAPI context protection. The patch is in preparation for the later patch to detect its usage and enable it when necessary.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +- .../ethernet/mellanox/mlx5/core/en/xsk/tx.c | 6 +- .../mellanox/mlx5/core/en_accel/ktls_rx.c | 8 +-- .../mellanox/mlx5/core/en_accel/ktls_txrx.h | 3 +- .../net/ethernet/mellanox/mlx5/core/en_main.c | 67 ++++++++++++++----- .../net/ethernet/mellanox/mlx5/core/en_txrx.c | 7 +- 6 files changed, 65 insertions(+), 28 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -1
@@ -782,7 +782,7 @@ struct mlx5e_channel {struct mlx5e_xdpsq xsksq;/* Async ICOSQ */ -struct mlx5e_icosq async_icosq; +struct mlx5e_icosq *async_icosq;/* data path - accessed per napi poll */ const struct cpumask *aff_mask;
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/tx.c +4 -2
@@ -26,10 +26,12 @@ int mlx5e_xsk_wakeup(struct net_device *dev, u32 qid, u32 flags)* active and not polled by NAPI. Return 0, because the upcoming * activate will trigger the IRQ for us. */ -if (unlikely (!test_bit (MLX5E_SQ_STATE_ENABLED , &c->async_icosq.state))) +if (unlikely (!test_bit (MLX5E_SQ_STATE_ENABLED , + &c->async_icosq->state)))return 0 ; -if (test_and_set_bit (MLX5E_SQ_STATE_PENDING_XSK_TX , &c->async_icosq.state)) +if (test_and_set_bit (MLX5E_SQ_STATE_PENDING_XSK_TX , + &c->async_icosq->state))return 0 ;mlx5e_trigger_napi_icosq (c);
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +4 -4
@@ -202,7 +202,7 @@ static int post_rx_param_wqes(struct mlx5e_channel *c,int err; err =0 ; - sq = &c->async_icosq; + sq = c->async_icosq;spin_lock_bh (&sq->lock); cseg =post_static_params (sq, priv_rx);
@@ -344,7 +344,7 @@ static void resync_handle_work(struct work_struct *work) } c = resync->priv->channels.c[priv_rx->rxq]; - sq = &c->async_icosq; + sq = c->async_icosq;if (resync_post_get_progress_params (sq, priv_rx)) { priv_rx->rq_stats->tls_resync_req_skip++;
@@ -371,7 +371,7 @@ static void resync_handle_seq_match(struct mlx5e_ktls_offload_context_rx *priv_rstruct mlx5e_icosq *sq;bool trigger_poll; - sq = &c->async_icosq; + sq = c->async_icosq; ktls_resync = sq->ktls_resync; trigger_poll = false;
@@ -753,7 +753,7 @@ bool mlx5e_ktls_rx_handle_resync_list(struct mlx5e_channel *c, int budget)LIST_HEAD (local_list);int i, j; - sq = &c->async_icosq; + 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 +2 -1
@@ -50,7 +50,8 @@ bool mlx5e_ktls_rx_handle_resync_list(struct mlx5e_channel *c, int budget);static inline bool mlx5e_ktls_rx_pending_resync_list (struct mlx5e_channel *c,int budget) { -return budget &&test_bit (MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC , &c->async_icosq.state); +return budget &&test_bit (MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC , + &c->async_icosq->state); } static inline void
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +50 -17
125 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +4 -3
@@ -180,11 +180,12 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget) busy |= work_done == budget;mlx5e_poll_ico_cq (&c->icosq.cq); -if (mlx5e_poll_ico_cq (&c->async_icosq.cq)) +if (mlx5e_poll_ico_cq (&c->async_icosq->cq))/* Don't clear the flag if nothing was polled to prevent * queueing more WQEs and overflowing the async ICOSQ. */ -clear_bit (MLX5E_SQ_STATE_PENDING_XSK_TX , &c->async_icosq.state); +clear_bit (MLX5E_SQ_STATE_PENDING_XSK_TX , + &c->async_icosq->state);/* Keep after async ICOSQ CQ poll */ if (unlikely (mlx5e_ktls_rx_pending_resync_list (c, budget)))
@@ -236,7 +237,7 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)mlx5e_cq_arm (&rq->cq);mlx5e_cq_arm (&c->icosq.cq); -mlx5e_cq_arm (&c->async_icosq.cq); +mlx5e_cq_arm (&c->async_icosq->cq);if (c->xdpsq)mlx5e_cq_arm (&c->xdpsq->cq);
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH v2 4/4 net/mlx5e: Conditionally create async ICOSQ
In reply to Tariq ToukanFrom: William Tu <[email protected]>
The async ICOSQ is only required by TLS RX (for re-sync flow) and XSK TX. Create it only when these features are enabled instead of always allocating it. This reduces per-channel memory usage, saves hardware resources, improves latency, and decreases the default number of SQs (from 3 to 2) and CQs (from 4 to 3). It also speeds up channel open/close operations for a netdev when async ICOSQ is not needed.
Currently when TLS RX is enabled, there is no channel reset triggered. As a result, async ICOSQ allocation is not triggered, causing a NULL pointer crash. One solution is to do channel reset every time when toggling TLS RX. However, it's not straightforward as the offload state matters only on connection creation, and can go on beyond the channels reset.
Instead, introduce a new field 'ktls_rx_was_enabled': if TLS RX is enabled for the first time: reset channels, create async ICOSQ, set the field. From that point on, no need to reset channels for any TLS RX enable/disable. Async ICOSQ will always be needed.
For XSK TX, async ICOSQ is used in wakeup control and is guaranteed to have async ICOSQ allocated.
This improves the latency of interface up/down operations when it applies.
Perf numbers:
NIC: Connect-X7.
Test: Latency of interface up + down operations.
Measured 20% speedup.
Saving ~0.36 sec for 248 channels (~1.45 msec per channel).
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + .../mellanox/mlx5/core/en_accel/ktls.c | 10 ++++- .../net/ethernet/mellanox/mlx5/core/en_main.c | 30 ++++++++++----- .../net/ethernet/mellanox/mlx5/core/en_txrx.c | 38 ++++++++++--------- 4 files changed, 50 insertions(+), 29 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -0
@@ -939,6 +939,7 @@ struct mlx5e_priv {u8 max_opened_tc;bool tx_ptp_opened;bool rx_ptp_opened; +bool ktls_rx_was_enabled;struct kernel_hwtstamp_config hwtstamp_config;u16 q_counter[MLX5_SD_MAX_GROUP_SZ ];u16 drop_rq_q_counter;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c +8 -2
@@ -135,10 +135,15 @@ int mlx5e_ktls_set_feature_rx(struct net_device *netdev, bool enable)int err =0 ;mutex_lock (&priv->state_lock); -if (enable) +if (enable) { err =mlx5e_accel_fs_tcp_create (priv->fs); -else +if (!err && !priv->ktls_rx_was_enabled) { + priv->ktls_rx_was_enabled = true; +mlx5e_safe_reopen_channels (priv); + } + }else {mlx5e_accel_fs_tcp_destroy (priv->fs); + }mutex_unlock (&priv->state_lock);return err;
@@ -161,6 +166,7 @@ int mlx5e_ktls_init_rx(struct mlx5e_priv *priv)destroy_workqueue (priv->tls->rx_wq);return err; } + priv->ktls_rx_was_enabled = true; }return 0 ;
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +20 -10
@@ -2632,7 +2632,8 @@ static void mlx5e_close_async_icosq(struct mlx5e_icosq *async_icosq)static int mlx5e_open_queues (struct mlx5e_channel *c,struct mlx5e_params *params, -struct mlx5e_channel_param *cparam) +struct mlx5e_channel_param *cparam, +bool async_icosq_needed) {const struct net_device_ops *netdev_ops = c->netdev->netdev_ops;struct dim_cq_moder icocq_moder = {0 ,0 };
@@ -2668,10 +2669,13 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,if (err) goto err_close_rx_cq; - c->async_icosq =mlx5e_open_async_icosq (c, params, cparam, &ccp); -if (IS_ERR (c->async_icosq)) { - err =PTR_ERR (c->async_icosq); - goto err_close_rq_xdpsq_cq; +if (async_icosq_needed) { + c->async_icosq =mlx5e_open_async_icosq (c, params, cparam, + &ccp); +if (IS_ERR (c->async_icosq)) { + err =PTR_ERR (c->async_icosq); + goto err_close_rq_xdpsq_cq; + } }mutex_init (&c->icosq_recovery_lock);
@@ -2708,7 +2712,8 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,mlx5e_close_icosq (&c->icosq); err_close_async_icosq: -mlx5e_close_async_icosq (c->async_icosq); +if (c->async_icosq) +mlx5e_close_async_icosq (c->async_icosq); err_close_rq_xdpsq_cq:if (c->xdp)
@@ -2740,7 +2745,8 @@ static void mlx5e_close_queues(struct mlx5e_channel *c)mlx5e_close_sqs (c);mlx5e_close_icosq (&c->icosq);mutex_destroy (&c->icosq_recovery_lock); -mlx5e_close_async_icosq (c->async_icosq); +if (c->async_icosq) +mlx5e_close_async_icosq (c->async_icosq);if (c->xdp)mlx5e_close_cq (&c->rq_xdpsq.cq);mlx5e_close_cq (&c->rq.cq);
@@ -2825,6 +2831,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,struct mlx5e_channel_param *cparam;struct mlx5_core_dev *mdev;struct mlx5e_xsk_param xsk; +bool async_icosq_needed;struct mlx5e_channel *c;unsigned int irq;int vec_ix;
@@ -2874,7 +2881,8 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,netif_napi_add_config_locked (netdev, &c->napi, mlx5e_napi_poll, ix);netif_napi_set_irq_locked (&c->napi, irq); - err =mlx5e_open_queues (c, params, cparam); + async_icosq_needed = !!xsk_pool || priv->ktls_rx_was_enabled; + err =mlx5e_open_queues (c, params, cparam, async_icosq_needed);if (unlikely (err)) goto err_napi_del;
@@ -2912,7 +2920,8 @@ static void mlx5e_activate_channel(struct mlx5e_channel *c)for (tc =0 ; tc < c->num_tc; tc++)mlx5e_activate_txqsq (&c->sq[tc]);mlx5e_activate_icosq (&c->icosq); -mlx5e_activate_icosq (c->async_icosq); +if (c->async_icosq) +mlx5e_activate_icosq (c->async_icosq);if (test_bit (MLX5E_CHANNEL_STATE_XSK , c->state))mlx5e_activate_xsk (c);
@@ -2933,7 +2942,8 @@ static void mlx5e_deactivate_channel(struct mlx5e_channel *c)else mlx5e_deactivate_rq (&c->rq); -mlx5e_deactivate_icosq (c->async_icosq); +if (c->async_icosq) +mlx5e_deactivate_icosq (c->async_icosq);mlx5e_deactivate_icosq (&c->icosq);for (tc =0 ; tc < c->num_tc; tc++)mlx5e_deactivate_txqsq (&c->sq[tc]);
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +21 -17
@@ -125,6 +125,7 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget) { struct mlx5e_channel *c = container_of(napi, struct mlx5e_channel, napi); +struct mlx5e_icosq *aicosq = c->async_icosq;struct mlx5e_ch_stats *ch_stats = c->stats;struct mlx5e_xdpsq *xsksq = &c->xsksq;struct mlx5e_txqsq __rcu **qos_sqs;
@@ -180,16 +181,18 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget) busy |= work_done == budget;mlx5e_poll_ico_cq (&c->icosq.cq); -if (mlx5e_poll_ico_cq (&c->async_icosq->cq)) -/* Don't clear the flag if nothing was polled to prevent -* queueing more WQEs and overflowing the async ICOSQ. -*/ -clear_bit (MLX5E_SQ_STATE_PENDING_XSK_TX , - &c->async_icosq->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 (aicosq) { +if (mlx5e_poll_ico_cq (&aicosq->cq)) +/* Don't clear the flag if nothing was polled to prevent +* queueing more WQEs and overflowing the async ICOSQ. +*/ +clear_bit (MLX5E_SQ_STATE_PENDING_XSK_TX , + &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); + } busy |= INDIRECT_CALL_2(rq->post_wqes, mlx5e_post_rx_mpwqes,
@@ -237,16 +240,17 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)mlx5e_cq_arm (&rq->cq);mlx5e_cq_arm (&c->icosq.cq); -mlx5e_cq_arm (&c->async_icosq->cq); +if (aicosq) { +mlx5e_cq_arm (&aicosq->cq); +if (xsk_open) { +mlx5e_handle_rx_dim (xskrq); +mlx5e_cq_arm (&xsksq->cq); +mlx5e_cq_arm (&xskrq->cq); + } + }if (c->xdpsq)mlx5e_cq_arm (&c->xdpsq->cq); -if (xsk_open) { -mlx5e_handle_rx_dim (xskrq); -mlx5e_cq_arm (&xsksq->cq); -mlx5e_cq_arm (&xskrq->cq); - } -if (unlikely (aff_change && busy_xsk)) {mlx5e_trigger_irq (&c->icosq); ch_stats->force_irq++;
Signature · 1 line
2.31.1
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 Wed, 14 Jan 2026 09:46:36 +0200 you wrote:
Hi,
This is V2, find V1 here:
https://lore.kernel.org/all/[email protected]/This series by William reduces the default number of SQs in a channel from 3 down to 2, by not creating the async ICOSQ (asynchronous internal-communication-operations send-queue).
[...]
Here is the summary with links:
- [net-next,V2,1/4] net/mlx5e: Move async ICOSQ lock into ICOSQ struct
https://git.kernel.org/netdev/net-next/c/ea945f4f3991 - [net-next,V2,2/4] net/mlx5e: Use regular ICOSQ for triggering NAPI https://git.kernel.org/netdev/net-next/c/56aca3e0f730 - [net-next,V2,3/4] net/mlx5e: Move async ICOSQ to dynamic allocation https://git.kernel.org/netdev/net-next/c/1b080bd74840 - [net-next,V2,4/4] net/mlx5e: Conditionally create async ICOSQ https://git.kernel.org/netdev/net-next/c/abed42f9cd80
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html