Re: [PATCH net-next v3 8/9] net: sparx5/lan969x: scale the TAS guard band with the MTU
From: Daniel Machon
Date: Tue Nov 24 2026 - 06:11:30 EST
> Thank you for your contribution! Sashiko AI review found 2 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 1
>
> 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] sparx5_tas_gb_update()
> (drivers/net/ethernet/microchip/sparx5/sparx5_tas.c) takes the largest…
> - [Low] In sparx5_tas_gb_update()
> (drivers/net/ethernet/microchip/sparx5/sparx5_tas.c:738) the guard…
>
> --
>
> net: sparx5/lan969x: scale the TAS guard band with the MTU
>
> This commit programs the TAS guard band (HSCH_TAS_QMAXSDU_CFG) for all
> ports and traffic classes. The value comes from the largest MTU of all
> ports, plus the Ethernet header, FCS and two VLAN tags, rounded up to
> 64 bytes. It adds sparx5_tas_gb_update(), calls it from sparx5_tas_init(),
> and makes it available for use when the MTU changes.
>
> > diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tas.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tas.c
> > index ec80bc69371ab..32e502bc4f18f 100644
> > --- a/drivers/net/ethernet/microchip/sparx5/sparx5_tas.c
> > +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tas.c
>
> [ ... ]
>
> > @@ -718,6 +721,40 @@ int sparx5_tas_disable(struct sparx5_port *port)
> > return err;
> > }
> >
> > +/* Size the guard band of all ports for a frame of the largest MTU of all
> > + * ports, as a port can transmit frames forwarded from any port.
> > + */
> > +void sparx5_tas_gb_update(struct sparx5 *sparx5)
> > +{
> > + u32 max_mtu = 0, gb;
> > + int i, tc;
> > +
> > + for (i = 0; i < sparx5->data->consts->n_ports; i++) {
> > + if (sparx5->ports[i])
> > + max_mtu = max_t(u32, max_mtu,
> > + READ_ONCE(sparx5->ports[i]->ndev->mtu));
> > + }
> > +
> > + gb = DIV_ROUND_UP(SPX5_HW_MTU(max_mtu) + 2 * VLAN_HLEN,
> > + TAS_QMAXSDU_UNIT);
>
> [Severity: Low]
> Should the 8 byte preamble/SFD be counted here?
>
> The guard band is sized from the L2 frame only, F = mtu + 26, rounded up
> to 64 bytes. A frame of F bytes that starts just before the guard band
> needs F + 8 byte-times on the wire to finish.
>
> When F mod 64 is 0 or 57..63, the rounding leaves less than 8 bytes of
> slack. For example, mtu=2022 gives F=2048 and mtu=9190 gives F=9216, both
> with no slack. mtu=4000 gives F=4026, with 6 bytes of slack.
>
> Suppose the HSCH turns QMAXSDU_VAL * 64 directly into time at LINK_SPEED,
> without adding L1 overhead itself. Could a maximum size double tagged
> frame then overrun the gate close by up to 8 byte-times? The default MTU
> of 1500 is fine (1526 vs 1536).
>
> For comparison, felix/vsc9959 adds L1 overhead explicitly when it
> calculates the guard band. The tree doesn't show whether the
> sparx5/lan969x hardware adds the preamble time internally.
>
> > +
> > + mutex_lock(&sparx5->tas_lock);
> > +
> > + /* Each port uses the TAS profile of its own number */
> > + for (i = 0; i < sparx5->data->consts->n_ports; i++) {
> > + if (!sparx5->ports[i])
> > + continue;
> > +
> > + for (tc = 0; tc < SPX5_PRIOS; tc++)
> > + spx5_rmw(HSCH_TAS_QMAXSDU_CFG_QMAXSDU_VAL_SET(gb),
> > + HSCH_TAS_QMAXSDU_CFG_QMAXSDU_VAL,
> > + sparx5,
> > + HSCH_TAS_QMAXSDU_CFG(i, tc));
>
> [Severity: Medium]
> What happens to taprio schedules already offloaded on other ports when
> this loop rewrites the guard band?
>
> The loop writes the new guard band into every port's profile for all 8
> traffic classes. That includes ports whose lists are already pending or
> operating. sparx5_tas_init() sets ALWAYS_GUARD_BAND_SCH_Q, so the guard
> band applies to every class:
>
> sparx5_tas_init() {
> ...
> spx5_rmw(HSCH_TAS_CFG_CTRL_LIST_NUM_MAX_SET(list_num_max) |
> HSCH_TAS_CFG_CTRL_ALWAYS_GUARD_BAND_SCH_Q_SET(1),
> ...
> }
>
> Later in this series, "net: sparx5/lan969x: add support for changing the
> MTU" calls sparx5_tas_gb_update() from sparx5_port_change_mtu(). After
> that, "ip link set dev ethB mtu 9000" raises the guard band on every port
> from 1536 to 142 * 64 = 9088 bytes. That is about 72.7 us at 1 Gbps and
> 727 us at 100 Mbps. At the maximum MTU it reaches 219 * 64 = 14016 bytes.
>
> Take a schedule on ethA with a 20-50 us window at 1G. It works with the
> 1536 byte guard band (about 12.3 us). The commit message notes that the
> scheduler starts no frame inside the guard band.
>
> After the MTU change on ethB, wouldn't that window never open? The queue
> would then fill and tail-drop, and no error would be reported.
>
> sparx5_tas_gb_update() returns void and doesn't recheck the programmed
> lists. sparx5_tas_enable() checks intervals only against
> TAS_MIN_CYCLE_TIME_NS and TAS_MAX_CYCLE_TIME_NS, not against the guard
> band, so such schedules are also accepted without a warning:
>
> sparx5_tas_enable() {
> ...
> if (interval < TAS_MIN_CYCLE_TIME_NS) {
> ...
> }
>
> The taprio max_sdu[] values, which correspond to this register, are also
> ignored. So the guard band can't be limited per class.
>
> felix/vsc9959 handles this in vsc9959_tas_guard_bands_update(). It
> recomputes the per-TC QMAXSDU from the schedule's minimum gate lengths
> whenever the MTU or the schedule changes. It also enables oversize
> dropping, so short windows can still carry smaller frames.
>
> Using the switch-wide maximum MTU seems reasonable, since ports forward
> and mirror frames from each other. The concern is only that running
> schedules can stop transmitting without any error.
This was already dismissed on v2 [1].
[1] https://lore.kernel.org/netdev/20261113081058.onqbnzydftlc4jeu@xxxxxxxxxxxxxxxxxxxxxxxxxxx/
>
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-sparx5-mtu-change-v3-0-55c272fe1acc%40microchip.com