mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: daniel.machon@microchip.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, Steen.Hegelund@microchip.com,
	UNGLinuxDriver@microchip.com, richardcochran@gmail.com,
	linux@armlinux.org.uk, netdev@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, robert.marko@sartura.hr,
	horatiu.vultur@microchip.com,
	jensemil.schulzostergaard@microchip.com, horms@kernel.org
Subject: Re: [PATCH net-next v3 8/9] net: sparx5/lan969x: scale the TAS guard band with the MTU
Date: Mon, 23 Nov 2026 14:58:21 +0000	[thread overview]
Message-ID: <179544590174.3135.13752120910636082921@kernel.org> (raw)
In-Reply-To: <20261120-sparx5-mtu-change-v3-8-55c272fe1acc@microchip.com>

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.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-sparx5-mtu-change-v3-0-55c272fe1acc%40microchip.com

  reply	other threads:[~2026-11-23 14:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 11:56 [PATCH net-next v3 0/9] net: sparx5/lan969x: add support for changing " Daniel Machon
2026-11-20 11:56 ` [PATCH net-next v3 1/9] net: sparx5/lan969x: stop the FDMA channels properly Daniel Machon
2026-11-23 14:58   ` netdev-bot+sashiko
2026-11-20 11:56 ` [PATCH net-next v3 2/9] net: sparx5/lan969x: free the FDMA buffers on init errors and deinit Daniel Machon
2026-11-23 14:58   ` netdev-bot+sashiko
2026-11-20 11:57 ` [PATCH net-next v3 3/9] net: sparx5/lan969x: add a helper for setting the MAC max frame length Daniel Machon
2026-11-20 11:57 ` [PATCH net-next v3 4/9] net: sparx5/lan969x: pass the FDMA rings to the init and alloc functions Daniel Machon
2026-11-20 11:57 ` [PATCH net-next v3 5/9] net: sparx5/lan969x: size the FDMA buffers from the port MTUs Daniel Machon
2026-11-23 14:58   ` netdev-bot+sashiko
2026-11-20 11:57 ` [PATCH net-next v3 6/9] net: sparx5/lan969x: add support for resizing the FDMA buffers Daniel Machon
2026-11-23 14:58   ` netdev-bot+sashiko
2026-11-20 11:57 ` [PATCH net-next v3 7/9] net: sparx5/lan969x: scale the queue watermarks with the MTU Daniel Machon
2026-11-23 14:58   ` netdev-bot+sashiko
2026-11-20 11:57 ` [PATCH net-next v3 8/9] net: sparx5/lan969x: scale the TAS guard band " Daniel Machon
2026-11-23 14:58   ` netdev-bot+sashiko [this message]
2026-11-20 11:57 ` [PATCH net-next v3 9/9] net: sparx5/lan969x: add support for changing " Daniel Machon
2026-11-23 14:58   ` netdev-bot+sashiko

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=179544590174.3135.13752120910636082921@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=Steen.Hegelund@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=daniel.machon@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horatiu.vultur@microchip.com \
    --cc=horms@kernel.org \
    --cc=jensemil.schulzostergaard@microchip.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=robert.marko@sartura.hr \
    /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

all inboxes | Powered by JetHome®