Re: [PATCH net-next v7 1/3] net: macb: cache ENST config across link down/up

From: Vineeth Karumanchi

Date: Fri Nov 20 2026 - 01:44:39 EST


Hi Théo,

On 11/19/2026 9:10 PM, Théo Lebrun wrote:
<...>
>>> @@ -972,6 +1010,7 @@ static void macb_mac_link_up(struct phylink_config *config,
>>> spin_lock_irqsave(&bp->lock, flags);
>>>
>>> bp->link_up = true;
>>> + bp->speed_mbps = speed > 0 ? speed : 0;
>>>
>>> ctrl = macb_or_gem_readl(bp, NCFGR);
>>>
>>> @@ -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) {
>> Why drop the schedule on a speed change? The taprio qdisc stays
>> installed, so the user's configuration is still valid;
>> Could we instead recompute the ON/OFF times for the new speed on
>> link-up, and only disable (with a warning) the queues whose intervals no
>> longer fit the hardware range at that speed?
> See explanation above. It felt like a good local maximum: simple code
> that probably doesn't introduce rounding bugs and solves it for most
> usecases.
>
> In any case, we will sometimes have to drop the qdisc and warn about it.
>

yes agreed!.

I also looked at a few usage scenarios and at how other implementations
handle this (with some AI assistance). They lean towards recalculating
on link-up:

- taprio core: keeps the schedule on a speed change and recalculates its
speed dependent values (picos_per_byte, max frame durations) from its
NETDEV_UP/NETDEV_CHANGE notifier.

- felix / VSC9959 TAS: gates are in ns; on a speed change,
vsc9959_sched_speed_set() updates the TAS link speed and calls
vsc9959_tas_guard_bands_update() to recalculate the speed dependent parts.

Typical scenario:

- Autoneg downshift 1G -> 100M (damaged cable, 2-pair or M12 cabling,
PHY downshift): fairly common in the field. Users expect best-effort
traffic to keep flowing, a clear warning, and recovery once the cable is
fixed.

That said, I am fine with either approach.

>>> + netdev_warn(bp->netdev,
>>> + "TAPRIO dropped because link speed changed\n");
>>> +
>>> + memset(&bp->enst, 0, sizeof(bp->enst));
>>> + }
>>> +
>>> + macb_apply_enst_config(bp);
>>> +
>> Could this be a single macb_apply_tc_config() (or similar) that
>> reprograms every enabled tc offload? CBS needs exactly the same
>> handling, since idleslope is also relative to the link rate.
> Yes sure!
>
> Do you want to take over and handle this? You seem to be interested in
> those TC features. You can either copy the patch as-is or modify it
> under your own authorship, I don't mind.
>
> Or if you prefer, I keep it here and iterate. But if I keep it, I'll
> continue with ENST and then at a later stage we'll add CBS & co onto
> it. This patch looks like a good starting point to add more onto it.
>

Your changes look good to me (after generic struct/api), and I am happy
with either option. I can take over the patch and make any necessary
adjustments alongside the CBS changes, or add CBS support after this
series is merged.

Please let me know which you prefer.

Thanks,
--
🙏 Vineeth