Re: [PATCH net-next v1 7/8] net: dsa: realtek: rtl8365mb: offload DCB apptrust
From: Linus Walleij
Date: Mon Oct 05 2026 - 19:39:25 EST
Hi Oleksij,
thanks for your patch!
Again some potential to share code here, not going to
repeat myself from patch 0.
On Fri, Oct 2, 2026 at 1:59 PM Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx> wrote:
> +/* rtl8365mb_apptrust_weight() gives the first entry the top weight,
> + * RTL8365MB_QOS_WEIGHT_PORT + ARRAY_SIZE(rtl8365mb_apptrust_map); fail the
> + * build if adding a selector would raise it past the decision weight range.
(...)
> +/* Trusted sources outrank the port default, and earlier entries in
> + * rtl8365mb_apptrust_map[] outrank later ones. Deriving the weight from the
> + * entry's position makes the table order the sole expression of precedence,
> + * so the order and the hardware weights cannot drift apart.
> + */
> +static u8 rtl8365mb_apptrust_weight(unsigned int entry)
> +{
> + return RTL8365MB_QOS_WEIGHT_PORT +
> + ARRAY_SIZE(rtl8365mb_apptrust_map) - entry;
> +}
RTL8365MB_QOS_WEIGHT_PORT is 1.
The returned weights
will be 1 (default), 2 (DSCP), 3 (PCP)
if I understand correctly.
The RTL8370 source has some other opionions about this,
it writes a power-of-two value here, would be something like:
return BIT(ARRAY_SIZE(rtl8365mb_apptrust_map) - entry);
returning the weigths 1 (default), 2 (DSCP), 4 (PCP).
So for RTL8365MB this value lands in register 0x0886
for example if both sources are trusted as the value
0x0302. But for the RTL8370 (which uses another register)
the value is instead 0x0402 for both sources trusted.
Can you check this in the RTL8365MB manual because
the register usage overall seem very similar to
RTL8370.
Yours,
Linus Walleij