Re: [PATCH net-next v7 1/3] net: macb: cache ENST config across link down/up
From: Théo Lebrun
Date: Mon Nov 23 2026 - 13:50:43 EST
Hello Théo,
On Mon Nov 23, 2026 at 6:51 PM CET, Théo Lebrun wrote:
> On Fri Nov 20, 2026 at 7:44 AM CET, Vineeth Karumanchi wrote:
>> 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.
>
> The more I think about it, the more I feel it is fine to drop the TAPRIO
> schedule as is being done by this patch.
>
> Really, EnST on an unstable link that got downgraded to a lower speed
> makes no sense. It is used on Time Sensitive Networks and the link down
> is the major issue in that case, not the EnST schedule being off.
> Userspace must give us a new schedule that is computed from the link
> speed. It is just a bit sad we cannot report the qdisc got dropped.
>
> Anyway, this patch is way better than the current situation, and we
> don't have an easy way to a perfect solution. So I say we go with this
> and improve if we feel like it is needed later on.
>
>>
>>>>> + 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.
>
> Now that I have the patch I'll iterate on it! Thanks for the quick
> feedback; I'll make sure to CC you from now on.
I just want to bounce back on the "after generic struct/api" you said.
Your proposal was of the sort:
struct macb_tc_queue {
struct {
u32 idleslope; /* kbps */
} cbs;
struct {
u32 start_time; /* ENST_START_TIME register value */
u32 on_time_ns; /* gate open interval */
u64 off_time_ns; /* gate closed interval */
} enst;
};
struct macb_tc {
struct macb_tc_queue queues[MACB_MAX_QUEUES];
u32 enst_queue_mask;
// ... etc ...
};
struct macb {
// ... what already exists in struct macb ...
struct macb_tc tc;
};
But actually I will keep my patch as-is, because I would much prefer:
// same for cbs, etc.
struct macb_queue_enst_config {
u32 start_time_mask;
u32 on_time_bytes;
u32 off_time_bytes;
};
// same for cbs, etc.
struct macb_enst {
struct macb_queue_enst_config queues[MACB_MAX_QUEUES];
u32 speed_mbps;
u32 queue_mask;
};
struct macb {
// ... what already exists in struct macb ...
struct macb_enst enst;
struct macb_cbs cbs;
// ... etc ...
};
The benefit of the latter strategy is two-fold:
- The structs are independent: less patch conflicts and each part can
be added one after the other.
- We can memset/memcpy a state; it is used quite a lot in the current
patch version. With your proposal, it requires iterating over the
queue loop to partially memset/memcpy (or equivalent) each queue.
I wanted this decision to be documented here before I send the next
revision.
Thanks,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com