Re: [PATCH net-next v11 08/13] net: dsa: realtek: rtl8365mb: refactor PVID handling
From: Linus Walleij
Date: Tue Nov 17 2026 - 03:34:54 EST
On Tue, Nov 17, 2026 at 8:39 AM Mieczyslaw Nalewaj <namiltd@xxxxxxxxx> wrote:
> The PVID helpers (rtl8365mb_vlan_port_get_pvid(),
> rtl8365mb_vlan_pvid_port_set() and rtl8365mb_vlan_pvid_port_clear())
> work on a VLAN MC table index, which only family C has. Family D stores
> a raw VID in a per-port register, so it needs its own implementation.
>
> Move the helpers behind struct rtl8365mb_family_info, as already done
> for the VLAN 4k accessors: the existing code becomes the family C
> implementation (rtl8365mb_c_vlan_port_get_pvid() and the like), and
> the three functions above only call it through the vlan_port_get_pvid,
> vlan_pvid_port_set and vlan_pvid_port_clear pointers in the family
> info. The callers are not changed. The following patch adds the family D
> implementation without any is_d() check in the shared code.
>
> No functional change.
>
> The family C functions are not static because they are referenced from
> the family C info in rtl8365mb_main.c.
>
> Signed-off-by: Mieczyslaw Nalewaj <namiltd@xxxxxxxxx>
What about:
int rtl8366_set_pvid() which is shared in realtek.h
and implemented in rtl8366-core.c.
It is currently only called from rtl8366_vlan_add() which
is only used by rtl8366rb.c.
realtek.h also have these as pointed out earlier to another
patch set:
struct realtek_ops {
(...)
int (*get_vlan_mc)(struct realtek_priv *priv, u32 index,
struct rtl8366_vlan_mc *vlanmc);
int (*set_vlan_mc)(struct realtek_priv *priv, u32 index,
const struct rtl8366_vlan_mc *vlanmc);
int (*get_vlan_4k)(struct realtek_priv *priv, u32 vid,
struct rtl8366_vlan_4k *vlan4k);
int (*set_vlan_4k)(struct realtek_priv *priv,
const struct rtl8366_vlan_4k *vlan4k);
int (*get_mc_index)(struct realtek_priv *priv, int port, int *val);
int (*set_mc_index)(struct realtek_priv *priv, int port, int index);
bool (*is_vlan_valid)(struct realtek_priv *priv, unsigned int vlan);
int (*enable_vlan)(struct realtek_priv *priv, bool enable);
int (*enable_vlan4k)(struct realtek_priv *priv, bool enable);
(...)
I *think* we agreed to push all of this into the RTL8366RB driver because
the way the RTL8366RB and RTL8365MB were dealing with VLANs
were just too different to share the abstraction.
If you can confirm that this is the case also for PVID I can send
a patch to push this into the RTL8366RB driver.
Yours,
Linus Walleij