Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: tariqt@nvidia.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com,
	sd@queasysnail.net, willemb@google.com,
	aleksandr.loktionov@intel.com, parri.andrea@gmail.com,
	borisp@nvidia.com, cjubran@nvidia.com, lcy8047@gmail.com,
	cratiu@nvidia.com, daniel.zahka@gmail.com,
	davem@davem-thinkpadp1gen8.ibmlond.csb, doruk@0sec.ai,
	dtatulea@nvidia.com, gal@nvidia.com, jianbol@nvidia.com,
	joasantonio108@gmail.com, leon@kernel.org,
	linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org,
	mbloch@nvidia.com, phaddad@nvidia.com, ralf@mandelbit.com,
	saeedm@nvidia.com, horms@kernel.org
Subject: Re: [PATCH net-next V5 4/7] net/mlx5e: macsec: Block TC offload when MACsec is enabled
Date: Mon, 30 Nov 2026 12:07:34 +0000	[thread overview]
Message-ID: <179604045496.3146.10459707437454849888@kernel.org> (raw)
In-Reply-To: <20261129120331.1910180-5-tariqt@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] This patch makes every installed MACsec RX decrypt rule take a
  device-wide TC block.

--

net/mlx5e: macsec: Block TC offload when MACsec is enabled

This patch makes each installed MACsec RX decrypt rule hold a device-wide
TC offload block. The block is taken in mlx5e_macsec_init_sa_fs() and
released in mlx5e_macsec_cleanup_sa_fs(). macsec_upd_secy_hw_address()
also keeps TC blocked while it rebuilds the RX rules.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
> index 13896e9c1d331..146f1036dba42 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c

[ ... ]

> @@ -325,6 +326,8 @@ static void mlx5e_macsec_cleanup_sa_fs(struct mlx5e_macsec *macsec,
>  	mlx5_macsec_fs_del_rule(macsec->mdev->macsec_fs, sa->macsec_rule, action, netdev,
>  				fs_id);
>  	sa->macsec_rule = NULL;
> +	if (!is_tx)
> +		mlx5e_accel_unblock_tc_offload(macsec->mdev);
>  }

[ ... ]

> @@ -354,13 +358,26 @@ static int mlx5e_macsec_init_sa_fs(struct macsec_context *ctx,
>  	rule_attrs.action = (is_tx) ? MLX5_ACCEL_MACSEC_ACTION_ENCRYPT :
>  				      MLX5_ACCEL_MACSEC_ACTION_DECRYPT;
>  
> +	if (!is_tx) {
> +		err = mlx5e_accel_block_tc_offload(priv->mdev);
> +		if (err)
> +			return err;
> +	}
> +

[Severity: Medium]
Can mdev->offload_block.num_block_tc leak here when the NIC profile is
torn down while RX SAs are still installed?

The only place this block is released is mlx5e_macsec_cleanup_sa_fs().
When the eswitch moves from legacy to switchdev, the path is:

mlx5e_vport_uplink_rep_load()
  mlx5e_netdev_change_profile()
    priv->profile->cleanup(priv) == mlx5e_nic_cleanup()
      mlx5e_macsec_cleanup()

mlx5e_macsec_cleanup() tears everything down without walking the RX SAs:

	mlx5_notifier_unregister(mdev, &macsec->nb);
	mlx5_macsec_fs_cleanup(mdev->macsec_fs);
	destroy_workqueue(macsec->wq);
	mlx5e_macsec_aso_cleanup(&macsec->aso, mdev);
	mutex_destroy(&macsec->lock);
	kfree(macsec);

The netdev stays registered during a profile change. The MACsec core
(macsec_notify() in drivers/net/macsec.c) only deletes secys on
NETDEV_UNREGISTER, so mdo_del_secy is never called either.

Unlike IPsec, MACsec does not call mlx5_eswitch_block_mode(), so nothing
prevents this mode change.

After the switch, num_block_tc stays above zero in struct mlx5_core_dev.
It is only initialized at mdev init and is never reset. The uplink
representor reuses the same netdev, and is_tc_accel_check_needed()
returns true for it. Every mlx5e_configure_flower() on the uplink would
then fail in mlx5e_tc_block_accel_offload():

	if (mdev->offload_block.num_block_tc)
		ret = -EBUSY;

Going back to legacy mode doesn't seem to recover either.
mlx5e_macsec_init() allocates a fresh, empty context, so a later
mdo_del_secy can't find the device and never unblocks. TC offload on the
uplink/NIC netdev would stay disabled until the mlx5_core_dev is
re-probed.

Dropping SA rules during profile teardown is an older problem. The
persistent device-level TC block is what turns it into a lasting TC
offload outage. Later patches in the series don't seem to touch
mlx5e_macsec_cleanup() or the profile-change path.

Should mlx5e_macsec_cleanup() release the TC blocks held by installed RX
rules? Alternatively, should MACsec RX offload block the eswitch mode
change?

>  	macsec_rule = mlx5_macsec_fs_add_rule(macsec_fs, ctx, &rule_attrs, fs_id);
> -	if (!macsec_rule)
> -		return -ENOMEM;
> +	if (!macsec_rule) {
> +		err = -ENOMEM;
> +		goto out_unblock_tc;
> +	}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129120331.1910180-1-tariqt%40nvidia.com

  reply	other threads:[~2026-11-30 12:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 12:03 [PATCH net-next V5 0/7] net/mlx5e: Prepare for PSP decapsulation Tariq Toukan
2026-11-29 12:03 ` [PATCH net-next V5 1/7] net/mlx5e: Generalize TC <-> IPsec mutual exclusion Tariq Toukan
2026-11-30 12:07   ` netdev-bot+sashiko
2026-11-29 12:03 ` [PATCH net-next V5 2/7] net/mlx5e: ipsec: Block TC offload when IPsec is enabled Tariq Toukan
2026-11-29 12:03 ` [PATCH net-next V5 3/7] net/mlx5e: psp: Block TC offload when PSP " Tariq Toukan
2026-11-29 12:03 ` [PATCH net-next V5 4/7] net/mlx5e: macsec: Block TC offload when MACsec " Tariq Toukan
2026-11-30 12:07   ` netdev-bot+sashiko [this message]
2026-11-29 12:03 ` [PATCH net-next V5 5/7] net/mlx5e: psp: Move RX marker from ft_metadata to flow_tag Tariq Toukan
2026-11-30 12:07   ` netdev-bot+sashiko
2026-11-29 12:03 ` [PATCH net-next V5 6/7] net/mlx5e: ipsec: " Tariq Toukan
2026-11-29 12:03 ` [PATCH net-next V5 7/7] net/mlx5e: macsec: " Tariq Toukan

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=179604045496.3146.10459707437454849888@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=aleksandr.loktionov@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=borisp@nvidia.com \
    --cc=cjubran@nvidia.com \
    --cc=cratiu@nvidia.com \
    --cc=daniel.zahka@gmail.com \
    --cc=davem@davem-thinkpadp1gen8.ibmlond.csb \
    --cc=davem@davemloft.net \
    --cc=doruk@0sec.ai \
    --cc=dtatulea@nvidia.com \
    --cc=edumazet@kernel.org \
    --cc=gal@nvidia.com \
    --cc=horms@kernel.org \
    --cc=jianbol@nvidia.com \
    --cc=joasantonio108@gmail.com \
    --cc=kuba@kernel.org \
    --cc=lcy8047@gmail.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=parri.andrea@gmail.com \
    --cc=phaddad@nvidia.com \
    --cc=ralf@mandelbit.com \
    --cc=saeedm@nvidia.com \
    --cc=sd@queasysnail.net \
    --cc=tariqt@nvidia.com \
    --cc=willemb@google.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