Re: [PATCH net-next v3 1/2] net: dsa: mt7530: factor out bridge join/leave logic

From: Arınç ÜNAL
Date: Tue Jun 18 2024 - 15:46:02 EST


On 18/06/2024 10.17, Matthias Schiffer wrote:
As preparation for implementing bridge port isolation, move the logic to
add and remove bits in the port matrix into a new helper
mt7530_update_port_member(), which is called from
mt7530_port_bridge_join() and mt7530_port_bridge_leave().

Another part of the preparation is using dsa_port_offloads_bridge_dev()
instead of dsa_port_offloads_bridge() to check for bridge membership, as
we don't have a struct dsa_bridge in mt7530_port_bridge_flags().

The port matrix setting is slightly streamlined, now always first setting
the mt7530_port's pm field and then writing the port matrix from that
field into the hardware register, instead of duplicating the bit
manipulation for both the struct field and the register.

mt7530_port_bridge_join() was previously using |= to update the port
matrix with the port bitmap, which was unnecessary, as pm would only
have the CPU port set before joining a bridge; a simple assignment can
be used for both joining and leaving (and will also work when individual
bits are added/removed in port_bitmap with regard to the previous port
matrix, which is what happens with port isolation).

No functional change intended.

Signed-off-by: Matthias Schiffer <mschiffer@xxxxxxxxxxxxxxxxxxxx>

Great explanation, thanks a lot!

Reviewed-by: Arınç ÜNAL <arinc.unal@xxxxxxxxxx>
Tested-by: Arınç ÜNAL <arinc.unal@xxxxxxxxxx>

---

v2: no changes
v3: addressed overlooked review comments:
- Ran clang-format on the patch
- Restored code comment
- Extended commit message

Thanks for the clang-format pointer - last time I tried that on kernel
code (years ago), it was rather underwhelming, but it seems it has
improved a lot.

Cheers.
Arınç