Netdev List
 help / color / mirror / Atom feed
From: Xuanqiang Luo <xuanqiang.luo@linux.dev>
To: Tariq Toukan <tariqt@nvidia.com>
Cc: horms@kernel.org, saeedm@nvidia.com, leon@kernel.org,
	mbloch@nvidia.com, borisp@nvidia.com, witu@nvidia.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, linux-rdma@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Xuanqiang Luo <luoxuanqiang@kylinos.cn>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next] net/mlx5e: kTLS, Simplify error unwind in mlx5e_ktls_set_feature_rx()
Date: Tue, 17 Nov 2026 17:34:45 +0900	[thread overview]
Message-ID: <51c8a888-c0e7-4045-8395-380cda03ee2c@linux.dev> (raw)
In-Reply-To: <b0f73ee2-fdff-4b5f-b8d0-43cd293d3058@nvidia.com>

On 2026/11/17 at 6:27 Tariq Toukan wrote:
> 
> 
> On 16/11/2026 13:08, 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 error cases in conditionals, keep the main flow
>> unconditional, and destroy the accel TCP flow tables in a single
>> place. Use goto to unlock on the early return.
>>
>> No functional change intended.
>>
> 
> Thanks for following up on this.
> The change is correct, I see no functional change.
> 
> However, we can simplify the code further.
> See below suggestion where code is flat, the same size, and leaves the 
> enable argument alone.
> 

Thanks, that's cleaner.

I'll send v2 with this form.

Thanks!
Xuanqiang

>> Suggested-by: Simon Horman <horms@kernel.org>
>> Link: https://lore.kernel.org/ 
>> all/20261029134019.GG257209@horms.kernel.org/
>> Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
>> ---
>> Only compile-tested on top of net-next 7ccc5e05043b (arm64, W=1). I do
>> not have a crypto-enabled ConnectX NIC to run it on.
>>
>>   .../mellanox/mlx5/core/en_accel/ktls.c        | 23 +++++++++++--------
>>   1 file changed, 13 insertions(+), 10 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..0f5dcd1b822e 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
>> @@ -137,19 +137,22 @@ int mlx5e_ktls_set_feature_rx(struct net_device 
>> *netdev, bool enable)
>>       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);
>> -            }
>> +        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;
>> +            enable = false;
>>           }
>> -    } else {
>> -        mlx5e_accel_fs_tcp_destroy(priv->fs);
>>       }
>> -    mutex_unlock(&priv->state_lock);
>> +    if (!enable)
>> +        mlx5e_accel_fs_tcp_destroy(priv->fs);
>> +
>> +out_unlock:
>> +    mutex_unlock(&priv->state_lock);
>>       return err;
>>   }
> 
> Suggestion:
> 
>      mutex_lock(&priv->state_lock);
>      if (!enable) {
>          mlx5e_accel_fs_tcp_destroy(priv->fs);
>          goto out_unlock;
>      }
> 
>      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;


      reply	other threads:[~2026-11-17  8:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 11:08 [PATCH net-next] net/mlx5e: kTLS, Simplify error unwind in mlx5e_ktls_set_feature_rx() Xuanqiang Luo
2026-11-16 21:27 ` Tariq Toukan
2026-11-17  8:34   ` Xuanqiang Luo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51c8a888-c0e7-4045-8395-380cda03ee2c@linux.dev \
    --to=xuanqiang.luo@linux.dev \
    --cc=andrew+netdev@lunn.ch \
    --cc=borisp@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=luoxuanqiang@kylinos.cn \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    --cc=witu@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox