mbox series

[net-next,RFC,v1,0/4] Add per port devlink regions

Message ID 20200919144332.3665538-1-andrew@lunn.ch
Headers show
Series Add per port devlink regions | expand

Message

Andrew Lunn Sept. 19, 2020, 2:43 p.m. UTC
This patchset extends devlink regions to support per port regions, and
them makes use of them to support the ports of the mv88e6xxx switches.

root@rap:~# devlink region show
mdio_bus/gpio-0:00/global1: size 64 snapshot []
mdio_bus/gpio-0:00/global2: size 64 snapshot []
mdio_bus/gpio-0:00/atu: size 49152 snapshot []
mdio_bus/gpio-0:00/1/port: size 64 snapshot []
mdio_bus/gpio-0:00/2/port: size 64 snapshot []
mdio_bus/gpio-0:00/3/port: size 64 snapshot []
mdio_bus/gpio-0:00/4/port: size 64 snapshot []
mdio_bus/gpio-0:00/8/port: size 64 snapshot []

root@rap:~# devlink region new mdio_bus/gpio-0:00/1/port snapshot 42
root@rap:~# devlink region dump mdio_bus/gpio-0:00/1/port snapshot 42
0000000000000000 4f 1e 3e 20 00 01 01 39 3f 05 00 00 fd 07 00 00
0000000000000010 80 00 01 00 00 00 00 00 00 00 00 00 00 00 00 91
0000000000000020 00 00 00 00 00 00 00 00 00 00 00 00 22 00 00 00
0000000000000030 07 3e 00 00 00 00 00 80 00 00 00 00 00 00 5b 00

DSA only instantiates devlink ports for switch ports which are used.
For this hardware, only 4 user ports and the CPU port have devlink
ports, which explains the discontinuous port regions.

Andrew Lunn (4):
  net: devlink: Add support for port regions
  net: dsa: Add devlink port regions support to DSA
  net: dsa: Add helper for converting devlink port to ds and port
  net: dsa: mv88e6xxx: Add per port devlink regions

 drivers/net/dsa/mv88e6xxx/chip.c    |   8 +
 drivers/net/dsa/mv88e6xxx/devlink.c |  61 +++++++
 drivers/net/dsa/mv88e6xxx/devlink.h |   6 +-
 include/net/devlink.h               |  27 +++
 include/net/dsa.h                   |  19 +++
 net/core/devlink.c                  | 250 +++++++++++++++++++++++++---
 net/dsa/dsa.c                       |  14 ++
 7 files changed, 358 insertions(+), 27 deletions(-)

Comments

Vladimir Oltean Sept. 20, 2020, 11:33 p.m. UTC | #1
On Sat, Sep 19, 2020 at 04:43:28PM +0200, Andrew Lunn wrote:
>
> DSA only instantiates devlink ports for switch ports which are used.
> For this hardware, only 4 user ports and the CPU port have devlink
> ports, which explains the discontinuous port regions.

This is not so much a choice, as it is a workaround of the fact that
dsa_port_setup(), which registers devlink ports with devlink, is called
after ds->ops->setup(), so you can't register your port regions from
the same place as the global regions now.

So you're doing it from ds->ops->port_enable(), which is the DSA wrapper
for .ndo_open(). So, consequently, your port regions will only be
registered when the port is up, and will be unregistered when it goes
down. Is that what you want? I understand that users probably think they
want to debug only the ports that they actively use, but I've heard of
at least one problem in the past which was caused by invalid settings
(flooding in that case) on a port that was down. Sure, this is probably
a rare situation, but as I said, somebody trying to use port regions to
debug something like that is probably going to have a hard time, because
it isn't an easy surgery to figure the probe ordering out.

Thanks,
-Vladimir
Florian Fainelli Sept. 20, 2020, 11:44 p.m. UTC | #2
On 9/20/2020 4:33 PM, Vladimir Oltean wrote:
> On Sat, Sep 19, 2020 at 04:43:28PM +0200, Andrew Lunn wrote:
>>
>> DSA only instantiates devlink ports for switch ports which are used.
>> For this hardware, only 4 user ports and the CPU port have devlink
>> ports, which explains the discontinuous port regions.
> 
> This is not so much a choice, as it is a workaround of the fact that
> dsa_port_setup(), which registers devlink ports with devlink, is called
> after ds->ops->setup(), so you can't register your port regions from
> the same place as the global regions now.
> 
> So you're doing it from ds->ops->port_enable(), which is the DSA wrapper
> for .ndo_open(). So, consequently, your port regions will only be
> registered when the port is up, and will be unregistered when it goes
> down. Is that what you want? I understand that users probably think they
> want to debug only the ports that they actively use, but I've heard of
> at least one problem in the past which was caused by invalid settings
> (flooding in that case) on a port that was down. Sure, this is probably
> a rare situation, but as I said, somebody trying to use port regions to
> debug something like that is probably going to have a hard time, because
> it isn't an easy surgery to figure the probe ordering out.

Being able to debug the switch configuration as soon as it gets 
registered with DSA all the way through enabling an user port has 
definitively a lot of value so we should aim to support that use case.
Andrew Lunn Sept. 21, 2020, 2:50 a.m. UTC | #3
On Sun, Sep 20, 2020 at 11:33:41PM +0000, Vladimir Oltean wrote:
> On Sat, Sep 19, 2020 at 04:43:28PM +0200, Andrew Lunn wrote:
> >
> > DSA only instantiates devlink ports for switch ports which are used.
> > For this hardware, only 4 user ports and the CPU port have devlink
> > ports, which explains the discontinuous port regions.
> 
> This is not so much a choice, as it is a workaround of the fact that
> dsa_port_setup(), which registers devlink ports with devlink, is called
> after ds->ops->setup(), so you can't register your port regions from
> the same place as the global regions now.

Correct.

> So you're doing it from ds->ops->port_enable(), which is the DSA wrapper
> for .ndo_open(). So, consequently, your port regions will only be
> registered when the port is up, and will be unregistered when it goes
> down. Is that what you want? I understand that users probably think they
> want to debug only the ports that they actively use, but I've heard of
> at least one problem in the past which was caused by invalid settings
> (flooding in that case) on a port that was down. Sure, this is probably
> a rare situation, but as I said, somebody trying to use port regions to
> debug something like that is probably going to have a hard time, because
> it isn't an easy surgery to figure the probe ordering out.

I did intially create the port instances at the same time as the
global ones, and it died a horrible death. And i was aiming to
register a region for each port, not just those which are used.

This splits into two problems.

1) Devlink has no concept of a port which is unused. We simply don't
register unused ports. So we need to add a new devlink_port_flavour:
DEVLINK_PORT_FLAVOUR_UNUSED. That seems easy enough.

2) We need to rearrange the order the core sets stuff up, such that it
registers devlink ports before calling the DSA driver setup()
method. I think that is possible after a quick look at the code.

	Andrew