]> www.infradead.org Git - users/dwmw2/linux.git/commit
net: dsa: bcm_sf2: fix crossbar port bitwidth logic
authorSam Edwards <cfsworks@gmail.com>
Thu, 3 Oct 2024 21:23:01 +0000 (14:23 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 4 Oct 2024 23:16:15 +0000 (16:16 -0700)
commit41378cfdc47fdbfbf4358b85546f7c2f5f671534
tree3e7564b3c3f129ebee4425eeb68e66dd8944af59
parent0da7fb3bcae036be9d2da5f0d216db1572139615
net: dsa: bcm_sf2: fix crossbar port bitwidth logic

The SF2 crossbar register is a packed bitfield, giving the index of the
external port selected for each of the internal ports. On BCM4908 (the
only currently-supported switch family with a crossbar), there are 2
internal ports and 3 external ports, so there are 2 bits per internal
port.

The driver currently conflates the "bits per port" and "number of ports"
concepts, lumping both into the `num_crossbar_int_ports` field. Since it
is currently only possible for either of these counts to have a value of
2, there is no behavioral error resulting from this situation for now.

Make the code more readable (and support the future possibility of
larger crossbars) by adding a `num_crossbar_ext_bits` field to represent
the "bits per port" count and relying on this where appropriate instead.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20241003212301.1339647-1-CFSworks@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/bcm_sf2.c
drivers/net/dsa/bcm_sf2.h