Re: [PATCH net-next v2 04/10] net: ieee8021q: add tt_to_pcp()
From: Luiz Angelo Daros de Luca
Date: Sat Nov 14 2026 - 15:00:04 EST
> Add ieee8021q_tt_to_pcp(), the inverse of ieee8021q_pcp_to_tt(): it
> encodes an 802.1Q traffic type back to its Priority Code Point, and
> completes the pcp/tt helper family.
>
> A driver that reseeds its PCP classifier through ieee8021q_pcp_to_tt()
> stores traffic types in the hardware tables, while the dcbnl priority
> ops exchange 802.1p priorities across the DSA boundary. Reading such a
> table back therefore needs the reverse mapping to restore the 802.1p
> value, which no existing helper provides. Because pcp_to_tt only
> transposes Best Effort and Background and is the identity elsewhere the
> two directions are numerically equal; provide tt_to_pcp as its own named
> function so the read path does not decode a traffic type as if it were a
> PCP.
>
> The first user is the Realtek rtl8365mb DSA driver, whose dcbnl
> get_default_prio and get_dscp_prio paths read back traffic types and
> must return 802.1p priorities.
>
> Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
> Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>
> ---
> Changes in v2:
> - look the PCP up in the pcp_to_tt() table instead of a switch, so the
> two helpers cannot disagree (Luiz)
> - check at build time that the table has one entry per traffic type
> - kernel-doc: cite the encoding table, Table 6-2 (6.9.3), not the
> decoding Table I-7, and name the IEEE 802.1Q-2022 edition
> - kernel-doc: refer to the enum doc for the Best Effort/Background
> order, and document each return value, including the stub's
> - keep Linus's Reviewed-by: the mapping is unchanged
Reviewed-by: Luiz Angelo Daros de Luca <luizluca@xxxxxxxxx>