Re: [PATCH net-next v12 12/13] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D

From: Mieczyslaw Nalewaj

Date: Sat Nov 21 2026 - 04:33:51 EST


Subject: Re: [PATCH net-next v12 12/13] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D

> +void rtl8365mb_d_l2_data_to_mc(const u16 *data,
> + struct rtl8365mb_l2_mc *mc)
> +{
> + rtl8365mb_l2_data_to_mac(data, mc->key.mac_addr);
> + mc->key.vid = FIELD_GET(RTL8365MB_D_L2_MC_D3_VID_MSK, data[3]);
> + mc->key.ivl = FIELD_GET(RTL8365MB_D_L2_MC_D3_IVL_MSK, data[3]);

I noticed that, unlike rtl8365mb_d_l2_data_to_uc(), this does not clear
key.vid when IVL is 0, so the FID could be taken for a VID.

I do not think this is a bug, so I am not changing the logic. I will
add a comment here in the next revision, so that it is not mistaken for
an omission.

In struct rtl8365mb_l2_mc_key, vid and fid share storage. Reading the
field into key.vid therefore also sets key.fid, and with IVL=0 the
field holds the FID. Nothing is reinterpreted: it is the same value.

For unicast, vid and fid are separate members, which is why
rtl8365mb_d_l2_data_to_uc() has to split the shared hardware field by
IVL. For multicast there is nothing to split.

Keeping the field as read also makes a read-modify-write go back to the
same key through rtl8365mb_d_l2_mc_to_data(), which uses
ivl = key.ivl && key.vid and writes key.vid as the id. Clearing it for
IVL=0, as for unicast, would write a different key for an entry that
has a non-zero FID.

The driver only writes FID 0 (VID 0 gives IVL=0, FID=0), so there is no
functional difference today. The comment will say that vid and fid share
storage and why the value is kept as read.

Best regards,
Mieczyslaw Nalewaj