On Sun, Nov 29, 2026 at 4:07 PM Mieczyslaw Nalewaj <nami…@yahoo.com> wrote:
> The hardware structure of 4K VLAN table entries has changed between > silicon families. Family D's CVLAN entry is two 16-bit words rather > than three: there is no third word extending member/untag past bit 7, > and no priority/meter fields at all. The FID field is restricted to a > narrower 2-bit width. The chip itself supports both IVL and SVL. > > IVL_EN (bit 3, versus bit 14 on family C) follows vlan4k->ivl_en. On > family D, rtl8365mb_vlan_4k_port_set() enables it while any user port > has VLAN filtering enabled (dsa_port_is_vlan_filtering()), so that > static and learned FDB/MDB entries use the same key. Family C keeps IVL > always enabled, as before. > > When a vlan_filtering change flips this switch-wide state, > rtl8365mb_d_vlan_4k_refresh_ivl() updates IVL_EN across the active 4K > entries, so existing VLANs, including those programmed before filtering > was enabled, switch between SVL and IVL immediately. Changes that leave > the state as it is do not touch the table. > > After a successful switch-wide IVL_EN change, flush the dynamically > learned L2 entries on every user port, so that none learned with the > previous SVL/IVL key remains, whatever the chip does on its own. Such > entries must not occupy LUT slots or become visible again after a later > toggle. > > Do not advertise vlan_filtering_is_global: ingress and egress VLAN > filtering remain per-port, and only the learning key used by active VLAN > entries follows a switch-wide policy. VLAN-unaware traffic is meant to > use the SVL key with VID 0, which the L2 patch implements together with > port-based FID 1. Because the policy is switch-wide, if a VLAN-aware and > a VLAN-unaware bridge share the switch, the VLANs of both use IVL and the > learned entries of the VLAN-unaware one no longer match its static VID 0 > (SVL) entries. The L2 patch limits the switch to one new bridge number, > but a bridge numbered by another switch can still be offloaded here. This > is a known limitation. > > The update visits only the VIDs in use, tracked in the vlan_4k_used > bitmap in struct realtek_priv. rtl8365mb_vlan_4k_port_set() keeps it up > to date under vlan_lock, so a toggle does not read all 4094 entries over > the slow management bus (about 5 s per toggle on an RTL8367S-VB; 20-30 ms > with the bitmap). The bitmap covers the entries written by this driver: > an entry that was already in the table before the driver loaded is not > visited. An entry that loses its last member is written back with IVL_EN > cleared, as in its reset state, so that it is not left in IVL after it > drops out of the bitmap. The rewrite itself is a separate function, > rtl8365mb_d_vlan_4k_set_ivl(), so that an error path can restore the > previous state. > > Reusing the three-word family C layout on family D would read a third > word that does not exist as a distinct table word on family D's die. > Whatever data happens to be in that register would be folded into > member/untag bits [10:8] on read, and written back on every > read-modify-write cycle in rtl8365mb_vlan_4k_port_set(). Give family D > its own two-word pack/unpack instead, which matches the vendor switch API > for this chip family (it writes only 0x0510/0x0511 for a CVLAN entry): > add rtl8365mb_d_vlan_4k_read() and rtl8365mb_d_vlan_4k_write(). The > shared code reaches them through the vlan_4k_read and vlan_4k_write > pointers in struct rtl8365mb_family_info, so the pack/unpack code needs > no is_d() check. > > Nothing points to them until the family D info is added together with > the chip table entry in the last patch. Until then they are not static > and are declared in rtl8365mb_vlan.h, so that the build does not warn > about unused functions. > > Tested-by: Gustavo Foletto Mora <gusf…@gmail.com> > Signed-off-by: Mieczyslaw Nalewaj <nami…@yahoo.com>
Looks reasonable. Reviewed-by: Linus Walleij <linu…@kernel.org> Yours, Linus Walleij