Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 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] On family D (RTL8367S-VB), rtl8365mb_port_set_efid() (drivers/net/dsa/realtek/rtl8365mb_main.c) treats any non-zero bridge… -- net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D This commit teaches the rtl8365mb table and L2 code about the family D (RTL8367S-VB) LUT layout and table access interface. It also uses port-based FID 1 for offloaded VLAN-unaware bridge ports, enables the lookup-hit isolation fallback and sets max_num_bridges to 1 on family D. Closes: https://github.com/openwrt/openwrt/pull/19644#issuecomment-6708118180
> diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c > index 45c1f0d90eae9..fc38bd12b62b7 100644 > --- a/drivers/net/dsa/realtek/rtl8365mb_main.c > +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c
[ ... ]
> @@ -2736,6 +2818,46 @@ 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 (0x0A32 is RTL8365MB_D_LUT_CFG2_REG). Instead, > + * assign port-based FID 1 to offloaded VLAN-unaware bridge ports > + * (efid != 0 and !vlan_filtering) so their SVL entries do not collide > + * with standalone ports in FID 0. > + */ > + if (rtl8365mb_is_d(priv)) { > + struct dsa_port *dp = dsa_to_port(&priv->ds, port); > + bool enable = efid && !dsa_port_is_vlan_filtering(dp); > + u8 fid = enable ? RTL8365MB_D_UNAWARE_BRIDGE_FID : 0;
[Severity: Medium] Can two different offloaded bridges end up sharing FID 1 here? Every non-zero efid is mapped to RTL8365MB_D_UNAWARE_BRIDGE_FID. The family D L2 key built by rtl8365mb_d_l2_uc_to_data() and rtl8365mb_d_l2_mc_to_data() also has no per-bridge part. Setting max_num_bridges = 1 does not seem to stop a second bridge from being offloaded. dsa_bridge_num_get() returns an existing system-wide number without comparing it to max: net/dsa/dsa.c:dsa_bridge_num_get() { unsigned int bridge_num = dsa_bridge_num_find(bridge_dev); ... if (!bridge_num) { ... if (bridge_num > max) return 0; ... } return bridge_num; } dsa_port_bridge_create() only rejects a zero result. Suppose a bridge already got number 2 from a switch in another DSA tree. It is accepted here, and this call gives the port PBFID 1: rtl83xx_port_bridge_join()->rtl8365mb_port_set_efid(priv, port, 2) The local bridge with number 1 uses that same FID. In that setup, a host on bridge B can send frames with the source MAC of a host M on bridge A. Would that move M's learned entry in FID 1 to B's port? Static entries for the same MAC in both bridges would also overwrite each other. rtl8365mb_d_lut_init() sets RTL8365MB_D_LUT_LOOKUP_HIT_ISO_ACT. Traffic from A's ports to M would then hit a port outside A's isolation mask. It would be flooded to A's whole isolation mask, including the CPU, instead of going to a single port. The commit message and the comment in rtl8365mb_setup() call this a known limitation. Could the driver refuse the offload instead, for example by returning -EOPNOTSUPP from the bridge join path when another bridge on this switch already uses PBFID 1? Another option is distinct PBFIDs, since RTL8365MB_D_PORT_PBFID_MASK is 2 bits wide. Either way, software forwarding would keep the bridges isolated.
> + int ret; > + > + /* PBFID is ignored while PBFIDEN is clear, so write them in > + * the order that leaves the port usable if the second write > + * fails: PBFID first when enabling, PBFIDEN first when > + * disabling. > + */
[ ... ]
> @@ -3705,9 +3874,25 @@ 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; FID 0 is used by standalone ports and FID 1 by the > + * offloaded VLAN-unaware bridge via port-based FID, so allow > + * at most one offloaded bridge. The bridge number it gets is > + * what rtl8365mb_port_set_efid() takes as "offloaded" to > + * enable port-based FID, so max_num_bridges must not be 0. > + * Bridge numbers are allocated system-wide by DSA, so this > + * does not stop a bridge that already has a number from > + * another switch from being offloaded here as well; such > + * bridges share FID 1 (known limitation). If bridge number 1 > + * is already used elsewhere, a new local bridge remains > + * software-forwarded. > + */ > + ds->max_num_bridges = 1; > + }
[ ... ]
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/aebc…%40yahoo.com