]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: dsa: mxl862xx: add CRC for MDIO communication
authorDaniel Golle <daniel@makrotopia.org>
Sun, 22 Mar 2026 13:27:20 +0000 (13:27 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 25 Mar 2026 03:47:21 +0000 (20:47 -0700)
commita319d0c8c8cede3b63538c9f111f84651d078bf6
treec5da8958db33e73f0ff87b44c2110ff09b41e5e1
parent10171b938330f6e625e7dc8dd24a15cc96218172
net: dsa: mxl862xx: add CRC for MDIO communication

Enable the firmware's opt-in CRC validation on the MDIO/MMD command
interface to detect bit errors on the bus. The firmware bundles CRC-6
and CRC-16 under a single enable flag, so both are implemented
together.

CRC-6 protects the ctrl and len_ret command registers using a table-
driven 3GPP algorithm. It is applied to every command exchange
including SET_DATA/GET_DATA batch transfers. With CRC enabled, the
firmware encodes its return value as a signed 11-bit integer within
the CRC- protected register fields, replacing the previous 16-bit
interpretation.

CRC-16 protects the data payload using the kernel's crc16() library.
The driver appends a CRC-16 checksum to outgoing data and verifies the
firmware-appended checksum on responses. The checksum is placed at the
exact byte offset where the struct data ends, correctly handling
packed structs with odd sizes by splitting the checksum across word
boundaries. SET_DATA/GET_DATA sub-commands carry only CRC-6.

Upon detection of a CRC error on either side all conduit interfaces
are taken down, triggering all user ports to go down as well. This is
the most feasible option: CRC errors are likely caused either by
broken hardware, or are symptom of overheating. In either case, trying
to resume normal operation isn't reasonable.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/620453b9a150bbe5b7ea4224331cb5dc5e57263b.1774185953.git.daniel@makrotopia.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/mxl862xx/Kconfig
drivers/net/dsa/mxl862xx/mxl862xx-host.c
drivers/net/dsa/mxl862xx/mxl862xx-host.h
drivers/net/dsa/mxl862xx/mxl862xx.c
drivers/net/dsa/mxl862xx/mxl862xx.h