Re: [net-next PATCH v2 5/8] net: dsa: realtek: rtl8365mb: add VLAN support

From: Linus Walleij

Date: Tue May 05 2026 - 08:26:09 EST


On Sun, May 3, 2026 at 8:19 AM Luiz Angelo Daros de Luca
<luizluca@xxxxxxxxx> wrote:

> From: Alvin Šipraga <alsi@xxxxxxxxxxxxxxx>
>
> Realtek RTL8365MB switches (a.k.a. RTL8367C family) use two different
> structures for VLANs:
>
> - VLAN4K: A full table with 4096 entries defining port membership and
> tagging.
> - VLANMC: A smaller table with 32 entries used primarily for PVID
> assignment.
>
> In this hardware, a port's PVID must point to an index in the VLANMC
> table rather than a VID directly. Since the VLANMC table is limited to
> 32 entries, the driver implements a dynamic allocation scheme to
> maximize resource usage:
>
> - VLAN4K is treated by the driver as the source of truth for membership.
> - A VLANMC entry is only allocated when a port is configured to use a
> specific VID as its PVID.
> - VLANMC entries are deleted when no longer needed as a PVID by any port.
>
> Although VLANMC has a members field, the switch only checks membership
> in the VLAN4K table. However, when a corresponding VLAN entry also exists
> in VLANMC, this driver keeps both membership configurations in sync.
>
> VLANMC index 0, although a valid entry, is reserved in this driver as a
> neutral PVID value for ports not using a specific PVID.
>
> In the subsequent RTL8367D switch family, VLANMC table was
> removed and PVID assignment was delegated to a dedicated set of
> registers.
>
> All ports start isolated, forwarding exclusively to CPU ports, and
> with VLAN transparent, ignoring VLAN membership. Once a member in a
> bridge, the port isolation is expanded to include the bridge members.
> When that bridge enables VLAN filtering, the VLAN transparent feature is
> disabled, letting the switch filter based on VLAN setup.
>
> The use of FIELD_PREP for reconstructing LO/HI values was suggested by
> Yury Norov.
>
> Fix for vlan_setup and vlan_filtering was suggested by Abdulkader
> Alrezej.
>
> Suggested-by: Yury Norov <ynorov@xxxxxxxxxx>
> Suggested-by: Abdulkader Alrezej <abdulkader.alrezej@xxxxxxxxx>
> Co-developed-by: Alvin Šipraga <alsi@xxxxxxxxxxxxxxx>
> Signed-off-by: Alvin Šipraga <alsi@xxxxxxxxxxxxxxx>
> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@xxxxxxxxx>

Allright go ahead like this. Mental not to move the RTL8366RB
VLAN handling down into the driver.
Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>

Yours,
Linus Walleij