mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: namiltd@yahoo.com
Cc: linusw@kernel.org, andrew@lunn.ch, olteanv@gmail.com,
	kuba@kernel.org, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, linux@armlinux.org.uk, luizluca@gmail.com,
	maxime.chevallier@bootlin.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, alvin.sipraga@analog.com,
	gusfmora@gmail.com, kuncy7@gmail.com, fabianotassotti@gmail.com,
	gabonpivovich@gmail.com, contact@c127.dev
Subject: Re: [PATCH net-next v10 11/12] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D
Date: Mon, 16 Nov 2026 18:55:59 +0000	[thread overview]
Message-ID: <179485535983.3136.18038505829775887634@kernel.org> (raw)
In-Reply-To: <ddc3b324-fe93-4c1d-a4da-558c0d6e88f1@yahoo.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 2 · Medium: 0 · 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).

- [High] On family D, the new L2 serializers pick the LUT key with a rule
  that does not match the hardware.
- [High] On family D this patch makes rtl8365mb_port_set_efid() a no-op
  (rtl8365mb_main.c:2666), leaves ds->fdb_isolation false, and still…
- [Low] On family D, rtl8365mb_setup() sets ds->max_num_bridges = 1 to
  cap offload at one bridge, and the in-tree comment says "offload only…

--

net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D

This adds family D (RTL8367S-VB) L2 entry serializers and table access
differences, and makes the per-port EFID write a no-op on family D. It
also adds a LUT init step and limits family D to one offloaded bridge
without fdb_isolation.

Closes: https://github.com/openwrt/openwrt/pull/19644#issuecomment-6708118180

> diff --git a/drivers/net/dsa/realtek/rtl8365mb_l2.c b/drivers/net/dsa/realtek/rtl8365mb_l2.c
> index cd5b333932bee..14acc84d35211 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_l2.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_l2.c

[ ... ]

> @@ -240,6 +255,76 @@ void rtl8365mb_c_l2_mc_to_data(const struct rtl8365mb_l2_mc *mc,

[ ... ]

> +void rtl8365mb_d_l2_uc_to_data(const struct rtl8365mb_l2_uc *uc,
> +			       u16 *data)
> +{
> +	/* A VLAN-unaware bridge reaches us with VID 0. The chip learns such
> +	 * traffic in SVL (IVL=0, FID=0), so use the same key here, otherwise
> +	 * the static entry never matches the learned one. Only a real VID
> +	 * selects IVL.
> +	 */
> +	bool ivl = uc->key.ivl && uc->key.vid;

[Severity: High]
Does this rule match the key the chip uses when it learns? The chip
picks IVL or SVL from the IVL_EN bit of the classified VID's VLAN4K
entry. On family D that bit is only written in
rtl8365mb_vlan_4k_port_set():

	} else {
		struct dsa_port *dp;

		vlan4k.ivl_en = false;
		dsa_switch_for_each_user_port(dp, ds)
			if (dsa_port_is_vlan_filtering(dp))
				vlan4k.ivl_en = true;
	}

That value is a snapshot from the last time the VID's membership was
written. rtl8365mb_port_vlan_filtering() does not rewrite existing VLAN4K
entries, so IVL_EN and the vid != 0 rule used here can drift apart.

Three cases where they seem to disagree:

(a) The bridge is VLAN-aware and then vlan_filtering is set to 0. VID 1
keeps IVL_EN=1, so the chip keeps learning untagged traffic as IVL/VID 1.
DSA now passes vid 0, which is serialized here as SVL/FID 0. Static FDB
entries, host and assisted-learning entries on the CPU port, and MDB
entries then get a different key than the learned one. That is the same
VLAN-unaware bridge failure the commit message says is fixed.

(b) The bridge is VLAN-unaware and then vlan_filtering is set to 1. VID 1
stays SVL/FID 0, but DSA programs vid 1 with IVL set.

(c) A port joins a bridge that is already VLAN-aware.
dsa_port_bridge_join() replays VLANs through
switchdev_bridge_port_offload() before dsa_port_switchdev_sync_attrs()
sets dp->vlan_filtering. If no other user port is filtering yet, those
VIDs are written with IVL_EN=0. With a single switch port in the bridge,
nothing rewrites them later.

In each case static, host and MDB entries would be ignored. Traffic to
the bridge MAC floods, MDB entries do not limit flooding, and fdb_dump
reports wrong VIDs.

The earlier "set and get vlan 4k for family D" patch already says IVL_EN
"is refreshed on the next port_vlan_add/del for the VID, not on a
vlan_filtering change".

Could the key be derived from the VID's VLAN4K IVL_EN/FID, or could
IVL_EN be refreshed on every vlan_filtering change?

> +	u16 id = ivl ? uc->key.vid : uc->key.fid;

[ ... ]

> +void rtl8365mb_d_l2_mc_to_data(const struct rtl8365mb_l2_mc *mc,
> +			       u16 *data)
> +{
> +	/* Same as for unicast: VID 0 means a VLAN-unaware bridge, use SVL. */
> +	bool ivl = mc->key.ivl && mc->key.vid;

The same question applies here. MDB entries use the same vid != 0 rule,
so they would also miss whenever IVL_EN for the VID does not match.

[ ... ]

> diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
> index bcddad0c25a24..ebc7d19fedd0a 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_main.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c

[ ... ]

> @@ -2650,6 +2662,10 @@ static int rtl8365mb_port_pre_bridge_flags(struct dsa_switch *ds, int port,
>  static int rtl8365mb_port_set_efid(struct realtek_priv *priv, int port,
>  				   u32 efid)
>  {
> +	/* Family D has no EFID; see RTL8365MB_D_LUT_CFG2_REG. */
> +	if (rtl8365mb_is_d(priv))
> +		return 0;
> +

[Severity: High]
Without EFID and without fdb_isolation, one bridge is still offloaded
with hardware learning. Standalone ports, ports of software-bridged
bridges and the offloaded VLAN-unaware bridge then all share SVL FID 0.
Can a MAC learned on a bridge port take over DA lookups for frames that
enter a standalone port?

  frame with SA=X enters a LAN bridge port
    -> X is learned in FID 0 on that LAN port
  frame with DA=X enters a standalone port (e.g. WAN)
    -> LUT hit points at the LAN port
    -> the standalone port's isolation mask (CPU only) drops it

The commit message describes this mechanism, and the tester saw it.

Since fdb_isolation is false, DSA installs no host entries for the MACs
of standalone ports. So nothing pins, for example, a distinct WAN
interface MAC to the CPU port.

Any host on an offloaded LAN port could forge a source MAC, such as the
router's WAN MAC or the MAC of a host behind a standalone port, and keep
refreshing it. Traffic for that MAC arriving on the standalone port would
then be dropped until the entry ages out.

Documentation/networking/dsa/dsa.rst expects standalone ports to behave
like independent NICs. It only lets them share a database because their
entries always point to the CPU port.

Would it work to give the offloaded bridge's VLANs a private FID (the
family D VLAN4K entry has a FID field)? Disabling hardware learning on
family D bridge ports, or not offloading VLAN-unaware bridges, would be
other options.

[ ... ]

> @@ -3600,9 +3642,16 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
>  		goto out_teardown_irq;
>  
>  	ds->assisted_learning_on_cpu_port = true;
> -	ds->fdb_isolation = true;
> -	/* The EFID is 3 bits, but EFID 0 is reserved for standalone ports */
> -	ds->max_num_bridges = FIELD_MAX(RTL8365MB_EFID_MASK);
> +	if (!rtl8365mb_is_d(priv)) {
> +		ds->fdb_isolation = true;
> +		/* The EFID is 3 bits, but EFID 0 is reserved for standalone */
> +		ds->max_num_bridges = FIELD_MAX(RTL8365MB_EFID_MASK);
> +	} else {
> +		/* No EFID, so bridges cannot be told apart in the LUT: offload
> +		 * only one, others fall back to software forwarding.
> +		 */
> +		ds->max_num_bridges = 1;

[Severity: Low]
Does max_num_bridges = 1 really guarantee that one bridge is offloaded on
this switch? DSA takes bridge numbers from a system-wide bitmap, not a
per-switch one. In dsa_bridge_num_get():

		bridge_num = find_next_zero_bit(&dsa_fwd_offloading_bridges,
						DSA_MAX_NUM_OFFLOADING_BRIDGES,
						1);
		if (bridge_num > max)
			return 0;

and in dsa_port_bridge_create():

	bridge->num = dsa_bridge_num_get(br, ds->max_num_bridges);
	if (ds->max_num_bridges && !bridge->num) {
		NL_SET_ERR_MSG_MOD(extack,
				   "Range of offloadable bridges exceeded");
		kfree(bridge);
		return -EOPNOTSUPP;
	}

If another DSA switch in the system already holds bridge number 1, the
first and only bridge on this family D switch gets number 2. It would
then not be offloaded at all and would fall back to software forwarding.

Since fdb_isolation is false, db.bridge.num is zeroed in FDB/MDB
notifications anyway, so the number only acts as this cap. Should the
comment be reworded, or is a different way of limiting offload needed?

> +	}
>  
>  	ds->configure_vlan_while_not_filtering = true;
>

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/d9da17af-f49e-4878-a8dd-59a8919e6930%40yahoo.com

  reply	other threads:[~2026-11-16 18:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <d9da17af-f49e-4878-a8dd-59a8919e6930.ref@yahoo.com>
2026-11-12 17:31 ` [PATCH net-next v10 00/12] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-11-12 17:32   ` [PATCH net-next v10 01/12] dt-bindings: net: dsa: realtek: add RTL8367S-VB Mieczyslaw Nalewaj
2026-11-12 17:33   ` [PATCH net-next v10 02/12] net: dsa: realtek: rtl8365mb: add chip family infrastructure Mieczyslaw Nalewaj
2026-11-12 17:33   ` [PATCH net-next v10 03/12] net: dsa: realtek: rtl8365mb: refactor forcemode handling Mieczyslaw Nalewaj
2026-11-12 20:23     ` Linus Walleij
2026-11-12 17:34   ` [PATCH net-next v10 04/12] net: dsa: realtek: rtl8365mb: set speed for family D Mieczyslaw Nalewaj
2026-11-12 17:35   ` [PATCH net-next v10 05/12] net: dsa: realtek: rtl8365mb: set RGMII mode " Mieczyslaw Nalewaj
2026-11-12 17:36   ` [PATCH net-next v10 06/12] net: dsa: realtek: rtl8365mb: refactor VLAN 4k handling Mieczyslaw Nalewaj
2026-11-12 20:24     ` Linus Walleij
2026-11-12 17:37   ` [PATCH net-next v10 07/12] net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D Mieczyslaw Nalewaj
2026-11-12 20:25     ` Linus Walleij
2026-11-16 18:55     ` netdev-bot+sashiko
2026-11-12 17:38   ` [PATCH net-next v10 08/12] net: dsa: realtek: rtl8365mb: use raw VID for PVID on " Mieczyslaw Nalewaj
2026-11-16 18:55     ` netdev-bot+sashiko
2026-11-12 17:39   ` [PATCH net-next v10 09/12] net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support Mieczyslaw Nalewaj
2026-11-16 18:55     ` netdev-bot+sashiko
2026-11-12 17:40   ` [PATCH net-next v10 10/12] net: dsa: realtek: rtl8365mb: refactor L2 MAC handling Mieczyslaw Nalewaj
2026-11-12 20:26     ` Linus Walleij
2026-11-12 17:41   ` [PATCH net-next v10 11/12] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D Mieczyslaw Nalewaj
2026-11-16 18:55     ` netdev-bot+sashiko [this message]
2026-11-12 17:42   ` [PATCH net-next v10 12/12] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-11-16 18:56     ` 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=179485535983.3136.18038505829775887634@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alvin.sipraga@analog.com \
    --cc=andrew@lunn.ch \
    --cc=contact@c127.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fabianotassotti@gmail.com \
    --cc=gabonpivovich@gmail.com \
    --cc=gusfmora@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kuncy7@gmail.com \
    --cc=linusw@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=luizluca@gmail.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=namiltd@yahoo.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.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®