Re: [PATCH net-next v16 14/15] net: dsa: realtek: rtl8365mb: use PCP numbering on family D

From: Linus Walleij

Date: Sun Nov 29 2026 - 17:53:02 EST


On Sun, Nov 29, 2026 at 4:12 PM Mieczyslaw Nalewaj <namiltd@xxxxxxxxx> wrote:

> Family C has separate per-port registers for the 802.1p PCP given to
> untagged frames (0x0851-0x0852) and for the port's default internal
> priority (0x0877-0x0878). The shared QoS layer hands the backend internal
> priorities that are 802.1Q traffic types (Best Effort is 1, Background is
> 0) and writes the untagged PCP separately.
>
> Family D has no 0x0851-0x0852 registers: its per-port PVID register at
> 0x0700 + port holds only the 12-bit VID, and
> dal_rtl8367d_vlan_portPvid_set() rejects any priority != 0. On an
> RTL8367S-VB the PCP of a newly inserted 802.1Q tag follows the frame's
> internal priority, so writing the traffic type as is made untagged
> frames leave an egress-tagged port with PCP 1 (Background) instead of
> PCP 0 (Best Effort).
>
> The vendor API numbers family D internal priorities like PCP values:
> dal_rtl8367d_qos_init() maps each PCP to the same internal priority, sets
> the port priority to 0 and keeps 1p remarking disabled. Do the same.
> On family D, convert between traffic types and the chip's numbering at
> the register boundary: for the port priority, the PCP-to-priority and
> DSCP-to-priority tables, and the priority-to-queue table. The PCP of a
> newly inserted tag then matches the traffic type whichever source
> classified the frame, and each traffic type still lands in the same
> queue as before.
>
> Add the family D implementations of the qos_iprio_to_hw and
> qos_hw_to_iprio hooks introduced by the previous patch. Make the
> qos_set_untag_pcp hook optional and leave it unset on family D, which
> cannot assign a configurable PCP to untagged ingress frames. Use the
> absence of that capability to reject PCP trust, while keeping port-based
> default priority and DSCP trust supported. The family D hooks are wired
> up by the patch that adds the first family D chip, so this patch changes
> no behaviour yet.
>
> Gustavo Foletto Mora, who reported the issue, confirmed on a TP-Link
> EX511 v2 with the baseline QoS configuration (no CONFIG_DCB) that
> untagged frames leave tagged with PCP 0, tagged frames keep their PCP,
> and the QoS registers read back in PCP numbering. Neither the rejection
> of PCP trust nor DSCP trust was exercised on hardware, as both need
> CONFIG_DCB.
>
> Reported-by: Gustavo Foletto Mora <gusfmora@xxxxxxxxx>
> Closes: https://github.com/openwrt/openwrt/pull/19644#issuecomment-7067296792
> Signed-off-by: Mieczyslaw Nalewaj <namiltd@xxxxxxxxx>

Looks like a reasonable fix.
Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>

Yours,
Linus Walleij