Re: [net-next,v6,2/2] net: dsa: mv88e6xxx: Add partial support for TCAM entries

From: Jakub Kicinski

Date: Fri Mar 06 2026 - 20:12:07 EST


On Fri, 6 Mar 2026 17:07:12 -0800 Jakub Kicinski wrote:
> > + reg |= MV88E6XXX_PORT_PRI_OVERRIDE_TCAM_MODE_96_BYTE;
> ^^^
>
> Would ORing the TCAM mode work correctly if the firmware has already
> configured the port to 48-byte mode? The TCAM mode field (bits 1:0) in
> the Priority Override register is a 2-bit enumeration where 0=disabled,
> 1=48-byte, 2=96-byte, and 3=reserved.
>
> If bit 0 is already set (48-byte mode with value 0x0001), ORing with
> 0x0002 produces 0x0003 (reserved mode) instead of the intended 0x0002
> (96-byte mode). The standard pattern for setting an enumerated register
> field is clear-then-set:
>
> reg &= ~MV88E6XXX_PORT_PRI_OVERRIDE_TCAM_MODE_MASK;
> reg |= MV88E6XXX_PORT_PRI_OVERRIDE_TCAM_MODE_96_BYTE;
>
> In normal operation (hardware reset value 0x0000), the current OR
> produces the correct result. The issue only occurs if firmware or a
> bootloader has pre-configured 48-byte TCAM mode before the Linux driver
> initializes.

FWIW doesn't look possible from looking at the code (we seem to always
disable at init so field should be cleared?) But clearing the field
before setting it seems like a good practice, the rest of the driver
does follow the:

reg &= ~MASK;
reg |= val;

pattern. So consider this a stylistic nit pick, I guess..