Re: [PATCH net-next] net: dsa: tag_rtl8_4: add support for RTL9607C tag variant

From: netdev-bot+sashiko

Date: Mon Nov 23 2026 - 13:00:24 EST


Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 2

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] This patch adds a new DSA tag protocol, DSA_TAG_PROTO_RTL8_4AP
(value 38), and the tagger rtl8_4ap_netdev_ops.
- [Medium] rtl8_4ap_read_tag() (net/dsa/tag_rtl8_4.c, lines 296-306) uses
a deny-list to decide whether the switch already forwarded a received…
- [Low] The patch makes tag_rtl8_4.c cover a second chip family, but some
existing documentation was not updated and the new comment contradicts…
- [Low] The comment and the code in net/dsa/tag_rtl8_4.c disagree on what
REASON means for the rtl8_4ap tagger.

--

net: dsa: tag_rtl8_4: add support for RTL9607C tag variant

This commit adds a new DSA tag protocol, rtl8_4ap (DSA_TAG_PROTO_RTL8_4AP),
for the variant of the 8 byte Realtek protocol 4 tag used by the switch
embedded in RTL9607C SoCs. The tag sits after the source MAC, as with
rtl8_4, but the fields are laid out differently and the TX and RX layouts
differ from each other.

> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index 09f3043d57f06..6f86c76253043 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -63,6 +63,7 @@ struct tc_action;
> #define DSA_TAG_PROTO_MT7628_VALUE 35
> #define DSA_TAG_PROTO_KS8995_VALUE 36
> #define DSA_TAG_PROTO_LAN9645X_VALUE 37
> +#define DSA_TAG_PROTO_RTL8_4AP_VALUE 38

[Severity: Medium]
Which switch driver is expected to select DSA_TAG_PROTO_RTL8_4AP?

The only in-tree user of the protocol 4 taggers is rtl8365mb. It only
returns the two existing values:

drivers/net/dsa/realtek/rtl8365mb_main.c:rtl8365mb_get_tag_protocol() {
...
if (cpu->position == RTL8365MB_CPU_POS_BEFORE_CRC)
return DSA_TAG_PROTO_RTL8_4T;

return DSA_TAG_PROTO_RTL8_4;
}

Likewise, rtl8365mb_change_tag_protocol() only accepts DSA_TAG_PROTO_RTL8_4
and DSA_TAG_PROTO_RTL8_4T.

So nothing in mainline can reach rtl8_4ap_tag_xmit() or rtl8_4ap_tag_rcv().
The patch still permanently reserves protocol ID 38 and adds the module
aliases "id-38" and "rtl8_4ap".

The commit message says:

Add basic necessities for this cpu tag variant to function.

However, the RTL9607C switch driver that would use this tagger is not part
of the submission. The only testing mentioned was on an out-of-tree OpenWrt
6.18 kernel.

Could this be resubmitted together with the switch driver that consumes it?

[ ... ]

> diff --git a/net/dsa/tag_rtl8_4.c b/net/dsa/tag_rtl8_4.c
> index 4da3beebef75e..c934c232d330e 100644
> --- a/net/dsa/tag_rtl8_4.c
> +++ b/net/dsa/tag_rtl8_4.c
> @@ -74,6 +74,54 @@

[ ... ]

> + * On CPU->Switch however the byte 3 is also different:
> + *
> + * |-----------------------------------+-----------------------------------|
> + * | (8-bit) | (8-bit) |
> + * | Protocol [0x04] | TX_PORTMASK_LOW |
> + * |-----------------------------------+-----------------------------------|
> + * | (3-bit) |(1)| (1) | (3) |(1) |(1)| (1) |(1) |(2)| (1) |1|
> + * |TX_PORTMASK_HIGH| X | PRI_EN | PRI |KEEP| X |LEARN_DIS|PSEL| X |DIRTX|X|

[Severity: Low]
This isn't a bug, but the CPU->switch diagram calls the forwarding port
mask TX_PORTMASK_LOW and TX_PORTMASK_HIGH. The glossary earlier in the file
says "RX (CPU->switch): forwarding port mask", and the code names the same
fields RTL8_4AP_RX_LO and RTL8_4AP_RX_HI. Should the diagram say RX to
match?

The new macros also mix two prefixes: RTL9607C_RX_HI_MSK sits next to
RTL8_4AP_RX_LO and RTL8_4AP_RX_HI.

A few existing descriptions were not updated for the new variant. The file
header still says:

* NOTE: Currently only supports protocol "4" found in the RTL8365MB, hence
* named tag_rtl8_4.

The tag placement text only mentions "rtl8_4" and "rtl8_4t". The
NET_DSA_TAG_RTL8_4 help text in net/dsa/Kconfig only mentions the
RTL8365MB-VC:

switches with 8 byte protocol 4 tags, such as the Realtek RTL8365MB-VC.

Could these be updated to cover RTL9607C and rtl8_4ap?

[ ... ]

> @@ -97,13 +146,63 @@
> #define RTL8_4_REASON GENMASK(7, 0)
> #define RTL8_4_REASON_FORWARD 0
> #define RTL8_4_REASON_TRAP 80
> +#define RTL8_4AP_REASON_BCAST_TRAP 203
> +#define RTL8_4AP_REASON_RESV_TRAP 215
> +#define RTL8_4AP_REASON_IGMP 219
> +#define RTL8_4AP_REASON_RMA 220
> +#define RTL8_4AP_REASON_ACL 227

[Severity: Low]
The only REASON documentation in this file is the shared table:

* REASON | reason for forwarding packet to CPU
* | 0: packet was forwarded or flooded to CPU
* | 80: packet was trapped to CPU

The new RTL9607C section says only bytes 4-7 differ on switch->CPU. That
suggests REASON means the same thing on this SoC.

However, rtl8_4ap_read_tag() treats 203, 215, 219, 220 and 227 as traps,
and none of these codes appear in the comment. It also treats 80 as
forwarded, which is the opposite of the documented meaning.

The new FBI description ("Only relevant when REASON is FB (aka < 64)") also
implies that 0..63 are flow based reasons. That conflicts with "0: packet
was forwarded or flooded to CPU".

Could the RTL9607C REASON codes be documented, and the existing table
marked as RTL8365MB specific?

[ ... ]

> @@ -153,6 +252,84 @@ static struct sk_buff *rtl8_4t_tag_xmit(struct sk_buff *skb,

[ ... ]

> + /* Parse REASON */
> + reason = FIELD_GET(RTL8_4_REASON, ntohs(tag16[1]));

[ ... ]

> + switch (reason) {
> + case RTL8_4AP_REASON_BCAST_TRAP:
> + case RTL8_4AP_REASON_RESV_TRAP:
> + case RTL8_4AP_REASON_IGMP:
> + case RTL8_4AP_REASON_RMA:
> + case RTL8_4AP_REASON_ACL:
> + break;
> + default:
> + dsa_default_offload_fwd_mark(skb);
> + break;
> + }

[Severity: Medium]
Is a deny-list safe here? Every REASON value except these five ends up in
dsa_default_offload_fwd_mark():

net/dsa/tag.h:dsa_default_offload_fwd_mark() {
struct dsa_port *dp = dsa_user_to_port(skb->dev);

skb->offload_fwd_mark = !!(dp->bridge);
}

That covers the flow based reasons (< 64) from the FBI description, code
80, and any other trap reason the RTL9607C can emit.

Suppose the switch traps a frame to the CPU on a bridged port for one of
those unlisted reasons. Wouldn't the bridge then treat the frame as already
forwarded in hardware, and skip software forwarding to the other ports in
the same hardware domain? That frame would be silently lost.

Whether this happens depends on which reason codes the hardware emits and
how the switch driver configures trapping. Neither is visible in the tree.

Would it be safer to set offload_fwd_mark only for reasons that are known
to mean the switch already forwarded or flooded the frame?

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119165129.26693-1-adilov%40disroot.org