net/mlx5: Steering misc enhancements
Subsystems (4)
Tariq Toukan
maintainercover net/mlx5: Steering misc enhancements
Hi,
This small series by Yevgeny contains a few steering enhancements / cleanups.
Regards,
Tariq
Yevgeny Kliteynik (3):
net/mlx5: HWS, Check if device is down while polling for completion net/mlx5: HWS, Handle destroying table that has a miss table net/mlx5: DR, Remove unused field of struct mlx5dr_matcher_rx_tx
.../ethernet/mellanox/mlx5/core/steering/hws/bwc.c | 12 ++++++++++++ .../ethernet/mellanox/mlx5/core/steering/hws/table.c | 3 +++ .../mellanox/mlx5/core/steering/sws/dr_types.h | 1 - 3 files changed, 15 insertions(+), 1 deletion(-)
base-commit: dacf281771a9aed1a723b196120a0de8637910b9
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 1/3 net/mlx5: HWS, Check if device is down while polling for completion
From: Yevgeny Kliteynik <[email protected]>
In case the device is down for any reason (e.g. FLR), the HW will no longer generate completions - no point polling and waiting for timeout.
--- .../ethernet/mellanox/mlx5/core/steering/hws/bwc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c +12 -0
@@ -422,6 +422,18 @@ int mlx5hws_bwc_queue_poll(struct mlx5hws_context *ctx,if (!got_comp && !drain)return 0 ; +if (unlikely (ctx->mdev->state ==MLX5_DEVICE_STATE_INTERNAL_ERROR )) { +/* If the device is down for any reason (e.g. FLR), the HW will +* no longer generate completions. +* Note that ETIMEDOUT is returned here because the BWC layer +* already has a special handling for timeouts - it breaks the +* rehash / resize / shrink loops to avoid chain of timeouts. +*/ +mlx5_core_warn_once (ctx->mdev, +"BWC poll: device is down, polling for completion aborted\n" ); +return -ETIMEDOUT ; + } + queue_full =mlx5hws_send_engine_full (&ctx->send_queue[queue_id]);while (queue_full || ((got_comp || drain) && *pending_rules)) { ret =mlx5hws_send_queue_poll (ctx, queue_id, comp, burst_th);
Signature · 1 line
2.44.0
Simon Horman
reviewerRe: [PATCH net-next 1/3] net/mlx5: HWS, Check if device is down while polling for completion
From: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
net/mlx5: HWS, Check if device is down while polling for completion
This commit adds a check to abort polling for hardware completions if the device state indicates an internal error. This returns -ETIMEDOUT early to avoid long timeouts when the hardware stops generating completions.
Quoted 12 lines
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c +4
-0@@ -422,6 +422,18 @@ int mlx5hws_bwc_queue_poll(struct mlx5hws_context *ctx,if (!got_comp && !drain)return 0 ; +if (unlikely (ctx->mdev->state ==MLX5_DEVICE_STATE_INTERNAL_ERROR )) { +/* If the device is down for any reason (e.g. FLR), the HW will +* no longer generate completions. +* Note that ETIMEDOUT is returned here because the BWC layer
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c int mlx5hws_bwc_queue_poll(struct mlx5hws_context *ctx, · line 438
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c +8
-0+* already has a special handling for timeouts - it breaks the +* rehash / resize / shrink loops to avoid chain of timeouts. +*/ +mlx5_core_warn_once (ctx->mdev, +"BWC poll: device is down, polling for completion aborted\n" ); +return -ETIMEDOUT ; + } + queue_full =mlx5hws_send_engine_full (&ctx->send_queue[queue_id]);while (queue_full || ((got_comp || drain) && *pending_rules)) {
Could this lead to a CPU stall if the device goes down during the polling loop?
The hardware state check is placed outside the while loop. The loop has a 60-second timeout (MLX5HWS_BWC_POLLING_TIMEOUT) and lacks cond_resched(), meaning it can peg the CPU while spinning.
If the hardware fails and stops generating completions while we are already inside the loop, the driver's health thread on another CPU might detect the failure and set ctx->mdev->state to MLX5_DEVICE_STATE_INTERNAL_ERROR.
Since the check is outside the loop, we would fail to detect the state change and continue to spin uselessly for the remainder of the 60 seconds, which could trigger a soft lockup panic.
Should the state check be moved inside the polling loop, perhaps using READ_ONCE() on ctx->mdev->state to ensure the compiler does not hoist the lockless read?
Quoted 1 line
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c +0
-0ret =mlx5hws_send_queue_poll (ctx, queue_id, comp, burst_th);
Re: [PATCH net-next 1/3] net/mlx5: HWS, Check if device is down while polling for completion
Quoted 20 lines · Simon Horman
From: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
net/mlx5: HWS, Check if device is down while polling for completionThis commit adds a check to abort polling for hardware completions if the device state indicates an internal error. This returns
-ETIMEDOUTearly to avoid long timeouts when the hardware stops generating completions.Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c +0
-0@@ -422,6 +422,18 @@ int mlx5hws_bwc_queue_poll(struct mlx5hws_context *ctx,if (!got_comp && !drain)return 0 ;
Quoted 16 lines
Quoted 4 lines
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c +4
-0+if (unlikely (ctx->mdev->state ==MLX5_DEVICE_STATE_INTERNAL_ERROR )) { +/* If the device is down for any reason (e.g. FLR), the HW will +* no longer generate completions. +* Note that ETIMEDOUT is returned here because the BWC layer drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c int mlx5hws_bwc_queue_poll(struct mlx5hws_context *ctx, · line 438
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c +8
-0+* already has a special handling for timeouts - it breaks the +* rehash / resize / shrink loops to avoid chain of timeouts. +*/ +mlx5_core_warn_once (ctx->mdev, +"BWC poll: device is down, polling for completion aborted\n" ); +return -ETIMEDOUT ; + } + queue_full =mlx5hws_send_engine_full (&ctx->send_queue[queue_id]);while (queue_full || ((got_comp || drain) && *pending_rules)) {Could this lead to a CPU stall if the device goes down during the polling loop?
That is correct.
There is the possibility that the device goes down while we're already inside the polling loop, in which case the looping will continue till it reaches the timeout.
But what we're trying to optimize is the "normal" flow. We prefer not to add additional 'if' into the polling loop, which should be as efficient as possible - it affects rules insertion/deletion rate.
So this patch aims to prevent chain of timeouts when device is in error state, which is happening during deletion of all the flows, and during shrinking of the matchers, while it still leaves some probability to see a single initial timeout.
Quoted 17 lines
The hardware state check is placed outside the while loop. The loop has a 60-second timeout (
MLX5HWS_BWC_POLLING_TIMEOUT) and lackscond_resched(), meaning it can peg the CPU while spinning.If the hardware fails and stops generating completions while we are already inside the loop, the driver's health thread on another CPU might detect the failure and set
ctx->mdev->statetoMLX5_DEVICE_STATE_INTERNAL_ERROR.Since the check is outside the loop, we would fail to detect the state change and continue to spin uselessly for the remainder of the 60 seconds, which could trigger a soft lockup panic.
Should the state check be moved inside the polling loop, perhaps using
READ_ONCE()onctx->mdev->stateto ensure the compiler does not hoist the lockless read?Quoted 1 line
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c +0
-0ret =mlx5hws_send_queue_poll (ctx, queue_id, comp, burst_th);
Tariq Toukan
maintainerPATCH 2/3 net/mlx5: HWS, Handle destroying table that has a miss table
In reply to Tariq ToukanFrom: Yevgeny Kliteynik <[email protected]>
If a table has a miss table that was created by 'mlx5hws_table_set_default_miss' API function, its miss_tbl keeps the table that points to it in a list.
If such table is deleted, we need to also remove it from the miss_tbl list, otherwise the node in miss_tbl list will contain garbage.
--- drivers/net/ethernet/mellanox/mlx5/core/steering/hws/table.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/table.c +3 -0
@@ -282,6 +282,9 @@ int mlx5hws_table_destroy(struct mlx5hws_table *tbl) goto unlock_err; } +if (tbl->default_miss.miss_tbl) +list_del_init (&tbl->default_miss.next); +list_del_init (&tbl->tbl_list_node);mutex_unlock (&ctx->ctrl_lock);
Signature · 1 line
2.44.0
Re: [PATCH net-next 2/3] net/mlx5: HWS, Handle destroying table that has a miss table
Quoted 9 lines · Tariq Toukan
From: Yevgeny Kliteynik <[email protected]>
If a table has a miss table that was created by '
mlx5hws_table_set_default_miss' API function, itsmiss_tblkeeps the table that points to it in a list.
If such table is deleted, we need to also remove it from themiss_tbllist, otherwise the node inmiss_tbllist will contain garbage.
Quoted 4 lines
Signed-off-by Erez Shitrit <[email protected]>Signed-off-by Yevgeny Kliteynik <[email protected]>Reviewed-by Moshe Shemesh <[email protected]>Signed-off-by Tariq Toukan <[email protected]>
Tariq Toukan
maintainerPATCH 3/3 net/mlx5: DR, Remove unused field of struct mlx5dr_matcher_rx_tx
In reply to Tariq ToukanFrom: Yevgeny Kliteynik <[email protected]>
Remove a field that was never used.
--- drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_types.h | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_types.h +0 -1
@@ -986,7 +986,6 @@ struct mlx5dr_matcher_rx_tx { [DR_RULE_MAX_STES ];u8 num_of_builders;u8 num_of_builders_arr[DR_RULE_IPV_MAX ][DR_RULE_IPV_MAX ]; -u64 default_icm_addr;struct mlx5dr_table_rx_tx *nic_tbl;u32 prio;struct list_head list_node;
Signature · 1 line
2.44.0
Re: [PATCH net-next 3/3] net/mlx5: DR, Remove unused field of struct mlx5dr_matcher_rx_tx
Quoted 7 lines · Tariq Toukan
From: Yevgeny Kliteynik <[email protected]>
Remove a field that was never used.
Signed-off-by Yevgeny Kliteynik <[email protected]>Reviewed-by Erez Shitrit <[email protected]>Signed-off-by Tariq Toukan <[email protected]>
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 9 lines · On Thu, 7 May 2026 20:34:40 +0300 you wrote:
Hi,
This small series by Yevgeny contains a few steering enhancements / cleanups.
Regards,
Tariq[...]
Here is the summary with links:
- [net-next,1/3] net/mlx5: HWS, Check if device is down while polling for completion
https://git.kernel.org/netdev/net-next/c/e3ec1570895b - [net-next,2/3] net/mlx5: HWS, Handle destroying table that has a miss table https://git.kernel.org/netdev/net-next/c/60e9e82f162a - [net-next,3/3] net/mlx5: DR, Remove unused field of struct mlx5dr_matcher_rx_tx https://git.kernel.org/netdev/net-next/c/6316d40b8509
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html