From: Florian Fainelli <f.fainelli@gmail.com>
To: Tobias Waldekranz <tobias@waldekranz.com>, netdev@vger.kernel.org
Cc: andrew@lunn.ch, hkallweit1@gmail.com,
Vladimir Oltean <olteanv@gmail.com>
Subject: Re: MDIO Debug Interface
Date: Thu, 9 Jul 2020 15:36:19 -0700 [thread overview]
Message-ID: <9dd495d7-e663-ce37-b53e-ffebd075c495@gmail.com> (raw)
In-Reply-To: <C42DZQLTPHM5.2THDSRK84BI3T@wkz-x280>
On 7/9/2020 1:47 PM, Tobias Waldekranz wrote:
> Hi netdev,
>
> TL;DR: Is something like https://github.com/wkz/mdio-tools a good
> idea?
>
> The kernel does not, as far as I know, have a low-level debug
> interface to MDIO devices. I.e. something equivalent to i2c-dev or
> spi-dev for example. The closest thing I've found are the
> SIOCG/SMIIREG ioctls, but they have several drawbacks:
>
> 1. "Write register" is not always exactly that. The kernel will try to
> be extra helpful and do things behind the scenes if it detects a
> write to the reset bit of a PHY for example.
>
> 2. Only one op per syscall. This means that is impossible to implement
> many operations in a safe manner. Something as simple as a
> read/mask/write cycle can race against an in-kernel driver.
>
> 3. Addressing is awkward since you don't address the MDIO bus
> directly, rather "the MDIO bus to which this netdev's PHY is
> connected". This makes it hard to talk to devices on buses to which
> no PHYs are connected, the typical case being Ethernet switches.
>
> The kernel side of mdio-tools, mdio-netlink, tries to address these
> problems by adding a GENL interface with which a user can interact
> with an MDIO bus directly.
>
> The user sends a program that the mdio-netlink module executes,
> possibly emitting data back to the user. I.e. it implements a very
> simple VM. Read/mask/write operations could be implemented by
> dedicated commands, but when you start looking at more advanced things
> like reading out the VLAN database of a switch you need to state and
> branching.
>
> FAQ:
>
> - A VM just for MDIO, that seems ridiculous, no?
>
> It does. But if you want to support the complex kinds of operations
> that I'm looking for, without the kernel module having to be aware
> of every kind of MDIO device in the world, I haven't found an easier
> way.
>
> - Why not use BPF?
>
> That could absolutely be one way forward, but the GENL approach was
> easy to build out-of-tree to prove the idea. Its not obvious how it
> would work though as BPF programs typically run async on some event
> (probe hit, packet received etc.) whereas this is a single execution
> on behalf of a user. So to what would the program be attached? The
> output path is also not straight forward, but it could be done with
> perf events i suppose.
>
> My question is thus; do you think mdio-netlink, or something like it,
> is a candidate for mainline?
Certainly, the current interface clearly has deficiencies and since
mdio_device instances were introduced, we should have an interface to
debug those from user-space ala i2c-dev or spidev.
Can you post the kernel code for review? Would you entertain having mdio
as an user-space command being part of ethtool for instance (just to
ease the distribution)?
--
Florian
next prev parent reply other threads:[~2020-07-09 22:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-09 20:47 MDIO Debug Interface Tobias Waldekranz
2020-07-09 22:18 ` Vladimir Oltean
2020-07-09 22:48 ` Andrew Lunn
2020-07-10 7:51 ` Tobias Waldekranz
2020-07-09 22:36 ` Florian Fainelli [this message]
2020-07-10 8:29 ` Tobias Waldekranz
2020-07-09 22:39 ` Andrew Lunn
2020-07-09 22:57 ` Vladimir Oltean
2020-07-09 23:20 ` Andrew Lunn
2020-07-09 23:33 ` Vladimir Oltean
2020-07-10 9:30 ` Tobias Waldekranz
2020-07-10 9:45 ` Vladimir Oltean
2020-07-10 13:35 ` Andrew Lunn
2020-07-10 15:47 ` Ioana Ciornei
2020-07-10 8:51 ` Tobias Waldekranz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9dd495d7-e663-ce37-b53e-ffebd075c495@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=hkallweit1@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=tobias@waldekranz.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.