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] On family D the driver infers the switch-wide IVL state actually programmed in the 4K table from software flags:… - [Low] Concern: after the switch-wide IVL_EN flip in rtl8365mb_d_vlan_4k_set_ivl(), only dynamic entries are flushed… -- net: dsa: realtek: rtl8365mb: add VLAN 4k/IVL for family D This adds two-word CVLAN pack/unpack helpers for the family D chips. It also makes IVL_EN in the 4K VLAN table follow a switch-wide policy: IVL while any user port is VLAN filtering, SVL otherwise. A vlan_filtering change that flips the policy rewrites IVL_EN on the VIDs tracked in a new vlan_4k_used bitmap, then flushes dynamic L2 entries on all user ports.
> diff --git a/drivers/net/dsa/realtek/rtl8365mb_vlan.c b/drivers/net/dsa/realtek/rtl8365mb_vlan.c > index 566c6bc1449af..ca2815bc42bbd 100644 > --- a/drivers/net/dsa/realtek/rtl8365mb_vlan.c > +++ b/drivers/net/dsa/realtek/rtl8365mb_vlan.c
[ ... ]
> +/* Set IVL_EN of every 4K entry in use to @want_ivl. Callers must use it only > + * for a change of the switch-wide state (see > + * rtl8365mb_d_vlan_4k_refresh_ivl()), so that every entry in use holds > + * …@want_ivl on entry. Must be called with &priv->vlan_lock held. > + */ > +static int rtl8365mb_d_vlan_4k_set_ivl(struct dsa_switch *ds, bool want_ivl) > +{
[ ... ]
> + for_each_set_bit(vid, priv->vlan_4k_used, VLAN_N_VID) { > + ret = fi->vlan_4k_read(priv, vid, &vlan4k); > + if (ret) > + goto rollback; > + if (!vlan4k.member || vlan4k.ivl_en == want_ivl) > + continue; > + > + vlan4k.ivl_en = want_ivl; > + ret = fi->vlan_4k_write(priv, &vlan4k); > + if (ret) > + goto rollback; > + } > + > + dsa_switch_for_each_user_port(dp, ds) > + rtl83xx_port_fast_age(ds, dp->index);
[Severity: Low] This isn't a bug, but rtl83xx_port_fast_age() goes through rtl8365mb_l2_flush(), which only removes dynamic entries (RTL8365MB_L2_FLUSH_CTRL2_TYPE_DYNAMIC). Static FDB/MDB entries survive the IVL_EN flip. In the family D L2 helpers later in the series, the static key comes from the VID and not from the switch-wide policy: rtl8365mb_d_l2_uc_to_data() { ... bool ivl = uc->key.ivl && uc->key.vid; ... } So VID 0 entries stay SVL with FID 1, VID N entries stay IVL, and this matches the software bridge lookup across a toggle. Someone reading this code could take it for a missing static flush. Could a short comment here say that static entries are kept on purpose?
> + > + return 0; > + > +rollback: > + /* Best effort: restore IVL_EN on the entries rewritten so far (without > + * flushing L2 entries). IVL_EN is switch-wide, so before the scan > + * every entry in use had the old value (!want_ivl) and every entry > + * below @failed that now has want_ivl was rewritten above. The entry > + * that failed is included: its write may have reached the chip before > + * the error was reported. > + */ > + failed = vid + 1; > + for_each_set_bit(vid, priv->vlan_4k_used, failed) { > + if (fi->vlan_4k_read(priv, vid, &vlan4k)) { > + dev_warn(priv->dev, "VID %u: IVL_EN rollback read failed\n", > + vid); > + continue; > + } > + if (!vlan4k.member || vlan4k.ivl_en != want_ivl) > + continue; > + vlan4k.ivl_en = !want_ivl; > + if (fi->vlan_4k_write(priv, &vlan4k)) > + dev_warn(priv->dev, "VID %u: IVL_EN rollback failed\n", > + vid); > + } > + return ret; > +} > + > +/* Must be called with &priv->vlan_lock held. */ > +int rtl8365mb_d_vlan_4k_refresh_ivl(struct dsa_switch *ds, int port, > + bool filtering) > +{ > + bool want_ivl = rtl8365mb_d_want_ivl(ds, port, filtering); > + > + /* The scan visits every entry in use, so do it only if this > + * change flips the switch-wide state, not for each port of a bridge. > + */ > + if (want_ivl == rtl8365mb_d_want_ivl(ds, -1, false)) > + return 0;
[Severity: Medium] Can the IVL_EN state in the 4K table drift away from what rtl8365mb_d_want_ivl(ds, -1, false) reports here? The current state is derived from dsa_port_is_vlan_filtering() on each user port. It is not taken from what was actually written to the table. dsa_port_vlan_filtering() in net/dsa/port.c can succeed in port_vlan_filtering(new), which flips all used entries, and then fail in dsa_user_manage_vlan_filtering(). When that happens it does: restore: ds->ops->port_vlan_filtering(ds, dp->index, old_vlan_filtering, NULL); if (ds->vlan_filtering_is_global) ds->vlan_filtering = old_vlan_filtering; else dp->vlan_filtering = old_vlan_filtering; The return value of the restore call is ignored. The restore call can fail in two ways: - rtl8365mb_port_vlan_filtering(old) fails before it reaches rtl8365mb_d_vlan_4k_refresh_ivl(), for example on the framefilter, PVID or egress mode register accesses. - set_ivl(old) fails part way and its rollback puts the entries back to the new value. In both cases the table keeps the new IVL_EN while dp->vlan_filtering goes back to the old value. The rollback loop above can also leave single entries at want_ivl when one of its reads or writes fails. It only warns in that case. After that, rtl8365mb_vlan_4k_port_set() writes new and changed entries with: vlan4k.ivl_en = vlan4k.member && rtl8365mb_d_want_ivl(ds, -1, false); Wouldn't the table then hold a mix of SVL and IVL entries? For some VLANs, the key the chip learns with would no longer match the VID-derived static FDB/MDB key that the family D L2 helpers use. The invariant in the rtl8365mb_d_vlan_4k_set_ivl() comment, "every entry in use holds …@want_ivl on entry", would also stop holding. The table seems to recover only after a later successful toggle in the same direction flips the remaining entries. Would it make sense to record the IVL_EN state that was last programmed successfully, and compare against that instead?
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/9efc…%40yahoo.com