* [PATCH net-next v2] net/mlx5e: kTLS, Simplify error unwind in mlx5e_ktls_set_feature_rx()
@ 2026-11-18 2:58 Xuanqiang Luo
2026-11-18 9:55 ` Tariq Toukan
0 siblings, 1 reply; 2+ messages in thread
From: Xuanqiang Luo @ 2026-11-18 2:58 UTC (permalink / raw)
To: netdev, tariqt
Cc: horms, saeedm, leon, mbloch, borisp, witu, andrew+netdev, davem,
edumazet, kuba, pabeni, linux-rdma, linux-kernel, Xuanqiang Luo
From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
mlx5e_ktls_set_feature_rx() has become harder to follow: the error
handling is nested in the conditions and the main flow is conditional.
Handle the disable case first, handle the error cases in conditionals,
and keep the main flow unconditional. Use goto to unlock on the early
returns.
No functional change intended.
Suggested-by: Simon Horman <horms@kernel.org>
Suggested-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/all/20261029134019.GG257209@horms.kernel.org/
Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
---
Changes:
v2:
- Handle the disable case first and keep the enable argument unchanged,
instead of reusing it as a flag to destroy the tables. (Suggested by
Tariq.)
v1: https://lore.kernel.org/all/20261116110830.2850785-1-xuanqiang.luo@linux.dev/
.../mellanox/mlx5/core/en_accel/ktls.c | 27 ++++++++++---------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
index 3cc1213c2f68..2358ad1f2331 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
@@ -135,21 +135,24 @@ int mlx5e_ktls_set_feature_rx(struct net_device *netdev, bool enable)
int err = 0;
mutex_lock(&priv->state_lock);
- if (enable) {
- err = mlx5e_accel_fs_tcp_create(priv->fs);
- if (!err && !priv->ktls_rx_was_enabled) {
- priv->ktls_rx_was_enabled = true;
- err = mlx5e_safe_reopen_channels(priv);
- if (err) {
- priv->ktls_rx_was_enabled = false;
- mlx5e_accel_fs_tcp_destroy(priv->fs);
- }
- }
- } else {
+ if (!enable) {
mlx5e_accel_fs_tcp_destroy(priv->fs);
+ goto out_unlock;
}
- mutex_unlock(&priv->state_lock);
+ err = mlx5e_accel_fs_tcp_create(priv->fs);
+ if (err || priv->ktls_rx_was_enabled)
+ goto out_unlock;
+
+ priv->ktls_rx_was_enabled = true;
+ err = mlx5e_safe_reopen_channels(priv);
+ if (err) {
+ priv->ktls_rx_was_enabled = false;
+ mlx5e_accel_fs_tcp_destroy(priv->fs);
+ }
+
+out_unlock:
+ mutex_unlock(&priv->state_lock);
return err;
}
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH net-next v2] net/mlx5e: kTLS, Simplify error unwind in mlx5e_ktls_set_feature_rx()
2026-11-18 2:58 [PATCH net-next v2] net/mlx5e: kTLS, Simplify error unwind in mlx5e_ktls_set_feature_rx() Xuanqiang Luo
@ 2026-11-18 9:55 ` Tariq Toukan
0 siblings, 0 replies; 2+ messages in thread
From: Tariq Toukan @ 2026-11-18 9:55 UTC (permalink / raw)
To: Xuanqiang Luo, netdev, tariqt
Cc: horms, saeedm, leon, mbloch, borisp, witu, andrew+netdev, davem,
edumazet, kuba, pabeni, linux-rdma, linux-kernel, Xuanqiang Luo
On 18/11/2026 4:58, Xuanqiang Luo wrote:
> From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
>
> mlx5e_ktls_set_feature_rx() has become harder to follow: the error
> handling is nested in the conditions and the main flow is conditional.
>
> Handle the disable case first, handle the error cases in conditionals,
> and keep the main flow unconditional. Use goto to unlock on the early
> returns.
>
> No functional change intended.
>
> Suggested-by: Simon Horman <horms@kernel.org>
> Suggested-by: Tariq Toukan <tariqt@nvidia.com>
> Link: https://lore.kernel.org/all/20261029134019.GG257209@horms.kernel.org/
> Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
> ---
> Changes:
> v2:
> - Handle the disable case first and keep the enable argument unchanged,
> instead of reusing it as a flag to destroy the tables. (Suggested by
> Tariq.)
>
> v1: https://lore.kernel.org/all/20261116110830.2850785-1-xuanqiang.luo@linux.dev/
>
Thanks for the update, this is what I had in mind.
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-18 9:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 2:58 [PATCH net-next v2] net/mlx5e: kTLS, Simplify error unwind in mlx5e_ktls_set_feature_rx() Xuanqiang Luo
2026-11-18 9:55 ` Tariq Toukan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®