mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: o.rempel@pengutronix.de
Cc: woojung.huh@microchip.com, UNGLinuxDriver@microchip.com,
	andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, arun.ramadoss@microchip.com, jiri@resnulli.us,
	linusw@kernel.org, f.fainelli@gmail.com,
	vivien.didelot@gmail.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel@pengutronix.de,
	jensemil.schulzostergaard@microchip.com
Subject: Re: [PATCH net-next v2 1/3] net: dsa: microchip: ksz9477: apply a shorter ageing time at once
Date: Mon, 16 Nov 2026 11:00:35 +0000	[thread overview]
Message-ID: <179482683512.3136.850497985215218789@kernel.org> (raw)
In-Reply-To: <20261115-ksz-stp-ageing-v2-1-7af27320033e@pengutronix.de>

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] In ksz9477_set_ageing_time()
  (drivers/net/dsa/microchip/ksz9477.c:1361-1371), the new Fast Aging…
- [Low] The Fast Aging pulse in ksz9477_set_ageing_time() is a fixed
  blind sleep: KSZ9477_FAST_AGE_PULSE_US = 2 ms (ksz9477.c:1293),…

--

net: dsa: microchip: ksz9477: apply a shorter ageing time at once

This patch makes ksz9477_set_ageing_time() pulse the Fast Aging bit in
REG_SW_LUE_CTRL_1 for a fixed 2 ms. It does this whenever the programmed
ageing time gets shorter or the Age Count gets smaller. The goal is that
stale entries no longer outlive an STP topology change on a KSZ9893.

> diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
> index 8d4647e23cda1..a9d701f0404a7 100644
> --- a/drivers/net/dsa/microchip/ksz9477.c
> +++ b/drivers/net/dsa/microchip/ksz9477.c

[ ... ]

> @@ -1336,8 +1343,32 @@ static int ksz9477_set_ageing_time(struct dsa_switch *ds, unsigned int msecs)
>  			return ret;
>  	}
>  
> -	value = DIV_ROUND_UP(secs, data);
> -	return ksz_write8(dev, REG_SW_LUE_CTRL_3, value);
> +	new_period = DIV_ROUND_UP(secs, data);
> +	ret = ksz_write8(dev, REG_SW_LUE_CTRL_3, new_period);
> +	if (ret < 0)
> +		return ret;
> +
> +	/* data is the new Age Count and mult is the old one. An entry
> +	 * stores the Age Count when it is updated. The datasheet does not
> +	 * say when a new Age Period applies. On a KSZ9893, entries outlived
> +	 * the new ageing time after it got shorter, and after the Age Count
> +	 * got smaller. Pulse Fast Aging in both cases. On a KSZ9893 the
> +	 * pulse removes the dynamic entries (checked on one user port) and
> +	 * starts the new period.
> +	 */
> +	old_secs = mult * old_period;
> +	new_secs = data * new_period;
> +	if (new_secs >= old_secs && data >= mult)
> +		return 0;
> +
> +	ret = ksz_rmw8(dev, REG_SW_LUE_CTRL_1, SW_FAST_AGING, SW_FAST_AGING);

[Severity: Medium]
Does this flush the dynamic FDB entries of every port on the switch?

SW_FAST_AGING is BIT(1) of REG_SW_LUE_CTRL_1 in ksz9477_reg.h. That
register holds only switch-wide lookup engine controls, next to
SW_AGING_ENABLE and SW_LINK_AUTO_AGING. Fast Aging has no port or FID
selector, so each pulse removes dynamic entries on all ports. That
includes ports in other bridges that had no topology change.

When the software bridge shortens its ageing time, it only expires
entries that were not refreshed within the new time. This pulse also
drops entries that are still in use. Unicast traffic to those addresses
then floods until the hosts transmit again, and a host that only
receives can be flooded to for a long time.

The pulse can also fire when the ageing time grows. From the reset value
of 4 x 75 s, a request for 301 s gives:

    max_val = 255   (76 * 4 != 301)
    data = DIV_ROUND_UP(301, 255) = 2
    new_period = DIV_ROUND_UP(301, 2) = 151

data (2) < mult (4), so the switch-wide flush runs although the ageing
time went up from 300 s to 302 s.

Neither the subject nor the body says the flush covers the whole switch.
The commit message only says:

    On a KSZ9893 the pulse removed the dynamic entries on the one user port
    I tested.

The driver already has a per-port flush, ksz9477_flush_dyn_mac_table(),
which is wired up as .port_fast_age. Could that be used here, or could
the commit message at least say that all ports are flushed?

> +	if (!ret)
> +		fsleep(KSZ9477_FAST_AGE_PULSE_US);
> +
> +	/* Clear the bit even after an error. */
> +	err = ksz_rmw8(dev, REG_SW_LUE_CTRL_1, SW_FAST_AGING, 0);

[Severity: Low]
Is a fixed 2 ms sleep long enough on all chips that use this function?

The new define comes with this comment:

    /* The datasheet gives no pulse length. A 2 ms pulse worked on a KSZ9893. */

Nothing checks that the dynamic entries are gone before SW_FAST_AGING is
cleared. ksz9477_set_ageing_time() is installed through ksz9477_switch_ops.
That covers many chip_data entries in ksz_common.c, including the 7-port
KSZ9477/KSZ9897/KSZ9567 parts, but it was only tested on a KSZ9893 with
one user port.

The other Fast Aging user in this driver suggests the timing depends on
the chip:

drivers/net/dsa/microchip/ksz8.c:ksz8_flush_dyn_mac_table() {
    ...
	if (ksz_is_ksz8995xa(dev)) {
		/* Allow the 800 us fast-age cycle to finish before restoring
		 * normal ageing and port learning.
		 */
    ...
}

Some untested chips may count each entry's stored Age Count down at a
fast tick, or may need more time to sweep the ALU. If so, could the pulse
end before every entry has expired, so that stale entries still outlive
the topology change?

> +
> +	return ret ?: err;
>  }

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115-ksz-stp-ageing-v2-0-7af27320033e%40pengutronix.de

  parent reply	other threads:[~2026-11-16 11:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15 10:59 [PATCH net-next v2 0/3] net: dsa: make a shorter bridge ageing time take effect Oleksij Rempel
2026-11-15 10:59 ` [PATCH net-next v2 1/3] net: dsa: microchip: ksz9477: apply a shorter ageing time at once Oleksij Rempel
2026-11-15 15:38   ` Andrew Lunn
2026-11-16 11:00   ` netdev-bot+sashiko [this message]
2026-11-15 10:59 ` [PATCH net-next v2 2/3] net: dsa: ignore the old ageing time of the port being changed Oleksij Rempel
2026-11-15 15:40   ` Andrew Lunn
2026-11-15 10:59 ` [PATCH net-next v2 3/3] net: dsa: forget the port ageing time when the port leaves the bridge Oleksij Rempel
2026-11-15 15:40   ` Andrew Lunn
2026-11-16 11:00   ` 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=179482683512.3136.850497985215218789@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=arun.ramadoss@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=horms@kernel.org \
    --cc=jensemil.schulzostergaard@microchip.com \
    --cc=jiri@resnulli.us \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=vivien.didelot@gmail.com \
    --cc=woojung.huh@microchip.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

all inboxes | Powered by JetHome®