Thread (9 messages) flat view 9 messages, 3 authors, 2021-01-19

Re: [PATCH net-next] net: mdio: access c22 registers via debugfs

From: Tobias Waldekranz <tobias@waldekranz.com>
Date: 2021-01-18 23:28:10

On Sat, Jan 16, 2021 at 22:19, Pavel Šimerda [off-list ref] wrote:
Provide a debugging interface to read and write MDIO registers directly
without the need for a device driver.

This is extremely useful when debugging switch hardware and phy hardware
issues. The interface provides proper locking for communication that
consists of a sequence of MDIO read/write commands.

The interface binds directly to the MDIO bus abstraction in order to
provide support for all devices whether there's a hardware driver for
them or not. Registers are written by writing address, offset, and
value in hex, separated by colon. Registeres are read by writing only
address and offset, then reading the value.

It can be easily tested using `socat`:

    # socat - /sys/kernel/debug/mdio/f802c000.ethernet-ffffffff/control

Example: Reading address 0x00 offset 0x00, value is 0x3000

    Input: 00:00
    Output: 3000

Example: Writing address 0x00 offset 0x00, value 0x2100

    Input: 00:00:2100

Signed-off-by: Pavel Šimerda <redacted>
Hi Pavel,

I also tried my luck at adding an MDIO debug interface to the kernel a
while back:

https://lore.kernel.org/netdev/C42DZQLTPHM5.2THDSRK84BI3T@wkz-x280 (local)

The conclusion was that, while nice to have, it makes it too easy for
shady vendors to write out-of-tree drivers.

You might want to have a look at https://github.com/wkz/mdio-tools. It
solves the same issue that your debugfs interface does, and also some
other nice things like clause 45 addressing and atomic read/mask/write
operations.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help