Netdev List
 help / color / mirror / Atom feed
From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: <netdev-bot+sashiko@kernel.org>
Cc: <conor.dooley@microchip.com>, <andrew+netdev@lunn.ch>,
	<davem@davemloft.net>, <edumazet@kernel.org>, <kuba@kernel.org>,
	<pabeni@redhat.com>, <linux@armlinux.org.uk>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<nb@tipi-net.de>, <pvalerio@redhat.com>,
	<vladimir.kondratiev@mobileye.com>, <gregory.clement@bootlin.com>,
	<benoit.monin@bootlin.com>, <tawfik.bayouk@mobileye.com>,
	<thomas.petazzoni@bootlin.com>, <vineeth.karumanchi@amd.com>
Subject: Re: [PATCH net-next v8 1/3] net: macb: cache ENST config across link down/up
Date: Fri, 27 Nov 2026 17:51:19 +0100	[thread overview]
Message-ID: <DN65D0SH90VI.2OD8UAD9HSLHI@bootlin.com> (raw)
In-Reply-To: <179571152363.3135.15940503307792785015@kernel.org>

Hello netdev-bot+sashiko,

On Thu Nov 26, 2026 at 5:45 PM CET,  wrote:
> 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] In macb_mac_link_up()
>   (drivers/net/ethernet/cadence/macb_main.c), when the link comes back…
>
> --
>
> net: macb: cache ENST config across link down/up
>
> The macb driver now keeps the ENST (taprio offload) config in bp->enst
> and writes it again on every link-up. If the link speed has changed, the
> cached config is dropped with a warning. The commit also caches the link
> speed in bp->speed_mbps, serialises the taprio paths with
> bp->mac_cfg_lock, and removes the pm_runtime_suspended() check.
>
>> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
>> index 9f6111661b40d..1e06666921160 100644
>> --- a/drivers/net/ethernet/cadence/macb_main.c
>> +++ b/drivers/net/ethernet/cadence/macb_main.c
>
> [ ... ]
>
>> @@ -1009,6 +1048,15 @@ static void macb_mac_link_up(struct phylink_config *config,
>>  
>>  	spin_unlock_irqrestore(&bp->lock, flags);
>>  
>> +	if (bp->enst.speed_mbps && speed != bp->enst.speed_mbps) {
>> +		netdev_warn(bp->netdev,
>> +			    "TAPRIO dropped because link speed changed\n");
>> +
>> +		memset(&bp->enst, 0, sizeof(bp->enst));
>> +	}
>> +
>> +	macb_apply_enst_config(bp);
>> +
>
> [Severity: Medium]
> After the link comes back at a different speed, the cache is zeroed.
> macb_apply_enst_config() then sets the disable bits for every queue and
> writes 0 to the per-queue timing registers. ENST_CONTROL is not enabled
> again, because of this check:
>
> 	if (bp->enst.queue_mask)
> 		gem_writel(bp, ENST_CONTROL, bp->enst.queue_mask);
>
> From then on the MAC applies no gate control at all. Only a netdev_warn()
> reports this.
>
> Does the taprio qdisc still report a fully offloaded schedule in this
> state? netdev->num_tc and tc_to_txq are left as they were, since only
> macb_taprio_destroy() calls netdev_reset_tc(). In offload mode the taprio
> core does not call ndo_setup_tc again on link changes, so nothing
> reprograms the hardware.
>
> Can the schedule ever come back without the user reinstalling the qdisc?
> struct macb_enst stores only on/off times already converted to bytes for
> one speed:
>
> 	config.queues[queue_id].on_time_bytes =
> 		enst_ns_to_hw_units(entry->interval, bp->speed_mbps);
> 	config.queues[queue_id].off_time_bytes =
> 		enst_ns_to_hw_units(off, bp->speed_mbps);
>
> macb_taprio_setup_replace() discards the nanosecond intervals from
> tc_taprio_qopt_offload. Because of that, macb_mac_link_up() cannot
> recompute or re-check the schedule for the new speed. It also cannot
> restore it if the link later comes back at the original speed, for
> example after a temporary PHY downshift or a cable swap.
>
> Would it work to keep the ns intervals in bp->enst, then re-validate and
> recompute the byte values on each link-up? The schedule would then
> survive whenever it still fits the new speed.

This has been discussed; read the thread under [PATCH net-next v7 1/3].
https://lore.kernel.org/lkml/20261118-macb-set-channels-v7-1-2dbc00f686af@bootlin.com/#r

Conclusion is:

 - If the link speed changes, then an ENST schedule makes little sense
   and userspace should give us a new one. The idea is that a schedule
   is scaled based on the workload to know what is emittable in each
   timeslot. Once you change the link speed, all timeslots now can
   contain more/less the previous amount.

 - Also, ENST is about Time Sensitive Networks. The link down caused by
   the link speed change is already massive trouble for such usecases.

 - It'd be nice if we could drop the qdisc from driver code.

 - I do not want to store µs in the cached state and compute register
   values from the current link speed. This is more code and many risks
   of bugs (rounding is critical to avoid ENST timeslot overlaps and
   such).

However, I would be okay to keep the existing schedule around even if
the current link speed isn't matching. It would allow:

 - 1G link => userspace assigns ENST schedule
 - 100M degraded link => delete ENST schedule and warn
 - 1G link => our cached schedule is valid, reapply it

I will respin for this and for a low prio finding on patch 2;
the one about locking bp->mac_cfg_lock to read bp->enst in
macb_set_channels().

Thanks,

--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


  reply	other threads:[~2026-11-27 16:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 16:45 [PATCH net-next v8 0/3] net: macb: implement ethtool set channels count operation Théo Lebrun
2026-11-24 16:45 ` [PATCH net-next v8 1/3] net: macb: cache ENST config across link down/up Théo Lebrun
2026-11-26 16:45   ` netdev-bot+sashiko
2026-11-27 16:51     ` Théo Lebrun [this message]
2026-11-24 16:45 ` [PATCH net-next v8 2/3] net: macb: implement ethtool_ops.get|set_channels() Théo Lebrun
2026-11-26 16:45   ` netdev-bot+sashiko
2026-11-27 17:14     ` Théo Lebrun
2026-11-24 16:45 ` [PATCH net-next v8 3/3] net: macb: distribute evenly Tx SRAM segments Théo Lebrun
2026-11-26 16:45   ` netdev-bot+sashiko
2026-11-27 17:15     ` Théo Lebrun

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=DN65D0SH90VI.2OD8UAD9HSLHI@bootlin.com \
    --to=theo.lebrun@bootlin.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=benoit.monin@bootlin.com \
    --cc=conor.dooley@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=gregory.clement@bootlin.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=nb@tipi-net.de \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pvalerio@redhat.com \
    --cc=tawfik.bayouk@mobileye.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=vineeth.karumanchi@amd.com \
    --cc=vladimir.kondratiev@mobileye.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