From: Vladimir Oltean <vladimir.oltean@nxp.com> Date: 2021-09-02 23:17:55
Commit 86f8b1c01a0a ("net: dsa: Do not make user port errors fatal")
decided it was fine to ignore errors on certain ports that fail to
probe, and go on with the ports that do probe fine.
Commit fb6ec87f7229 ("net: dsa: Fix type was not set for devlink port")
noticed that devlink_port_type_eth_set(dlp, dp->slave); does not get
called, and devlink notices after a timeout of 3700 seconds and prints a
WARN_ON. So it went ahead to unregister the devlink port. And because
there exists an UNUSED port flavour, we actually re-register the devlink
port as UNUSED.
Commit 08156ba430b4 ("net: dsa: Add devlink port regions support to
DSA") added devlink port regions, which are set up by the driver and not
by DSA.
When we trigger the devlink port deregistration and reregistration as
unused, devlink now prints another WARN_ON, from here:
devlink_port_unregister:
WARN_ON(!list_empty(&devlink_port->region_list));
So the port still has regions, which makes sense, because they were set
up by the driver, and the driver doesn't know we're unregistering the
devlink port.
Somebody needs to tear them down, and optionally (actually it would be
nice, to be consistent) set them up again for the new devlink port.
But DSA's layering stays in our way quite badly here.
The options I've considered are:
1. Introduce a function in devlink to just change a port's type and
flavour. No dice, devlink keeps a lot of state, it really wants the
port to not be registered when you set its parameters, so changing
anything can only be done by destroying what we currently have and
recreating it.
2. Make DSA cache the parameters passed to dsa_devlink_port_region_create,
and the region returned, keep those in a list, then when the devlink
port unregister needs to take place, the existing devlink regions are
destroyed by DSA, and we replay the creation of new regions using the
cached parameters. Problem: mv88e6xxx keeps the region pointers in
chip->ports[port].region, and these will remain stale after DSA frees
them. There are many things DSA can do, but updating mv88e6xxx's
private pointers is not one of them.
3. Just let the driver do it. It's pretty horrible, but the other
methods just don't seem to work.
Fixes: 08156ba430b4 ("net: dsa: Add devlink port regions support to DSA")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/dsa/mv88e6xxx/chip.c | 1 +
drivers/net/dsa/mv88e6xxx/devlink.c | 16 ++++++++++++++++
drivers/net/dsa/mv88e6xxx/devlink.h | 1 +
include/net/dsa.h | 9 +++++++++
net/dsa/dsa.c | 6 ++++++
net/dsa/dsa2.c | 22 +++++++++++++++++-----
6 files changed, 50 insertions(+), 5 deletions(-)
@@ -846,6 +846,12 @@ struct dsa_switch_ops {enumdevlink_sb_pool_typepool_type,u32*p_cur,u32*p_max);+/* Hook for drivers to tear down their port devlink regions when a+*portfailedtoregisteranditsdevlinkportmustbetorndownand+*reinitializedbyDSAasunused.+*/+int(*port_reinit_as_unused)(structdsa_switch*ds,intport);+/**MTUchangefunctionality.SwitchescanalsoadjusttheirMRUthrough*thismethod.ByMTU,oneunderstandstheSDU(L2payload)length.
@@ -961,6 +967,9 @@ static inline int dsa_devlink_port_to_port(struct devlink_port *port)returnport->index;}+intdsa_port_devlink_setup(structdsa_port*dp);+voiddsa_port_devlink_teardown(structdsa_port*dp);+structdsa_switch_driver{structlist_headlist;conststructdsa_switch_ops*ops;
@@ -440,6 +440,12 @@ dsa_devlink_port_region_create(struct dsa_switch *ds,{structdsa_port*dp=dsa_to_port(ds,port);+/* Make sure drivers provide the method for cleaning this up when the+*portmightneedtobetorndownatruntime.+*/+if(WARN_ON(!ds->ops->port_reinit_as_unused))+returnNULL;+returndevlink_port_region_create(&dp->devlink_port,ops,region_max_snapshots,region_size);
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-05 07:08:06
On Fri, Sep 03, 2021 at 02:17:38AM +0300, Vladimir Oltean wrote:
Commit 86f8b1c01a0a ("net: dsa: Do not make user port errors fatal")
decided it was fine to ignore errors on certain ports that fail to
probe, and go on with the ports that do probe fine.
Commit fb6ec87f7229 ("net: dsa: Fix type was not set for devlink port")
noticed that devlink_port_type_eth_set(dlp, dp->slave); does not get
called, and devlink notices after a timeout of 3700 seconds and prints a
WARN_ON. So it went ahead to unregister the devlink port. And because
there exists an UNUSED port flavour, we actually re-register the devlink
port as UNUSED.
Commit 08156ba430b4 ("net: dsa: Add devlink port regions support to
DSA") added devlink port regions, which are set up by the driver and not
by DSA.
When we trigger the devlink port deregistration and reregistration as
unused, devlink now prints another WARN_ON, from here:
devlink_port_unregister:
WARN_ON(!list_empty(&devlink_port->region_list));
So the port still has regions, which makes sense, because they were set
up by the driver, and the driver doesn't know we're unregistering the
devlink port.
Somebody needs to tear them down, and optionally (actually it would be
nice, to be consistent) set them up again for the new devlink port.
But DSA's layering stays in our way quite badly here.
I don't know anything about DSA and what led to the decision to ignore
devlink registration errors, but devlink core is relying on the simple
assumption that everything is initialized correctly.
So if DSA needs to have not-initialized port, it should do all the needed
hacks internally.
Thanks
From: Vladimir Oltean <olteanv@gmail.com> Date: 2021-09-05 08:49:50
On Sun, Sep 05, 2021 at 10:07:45AM +0300, Leon Romanovsky wrote:
On Fri, Sep 03, 2021 at 02:17:38AM +0300, Vladimir Oltean wrote:
quoted
Commit 86f8b1c01a0a ("net: dsa: Do not make user port errors fatal")
decided it was fine to ignore errors on certain ports that fail to
probe, and go on with the ports that do probe fine.
Commit fb6ec87f7229 ("net: dsa: Fix type was not set for devlink port")
noticed that devlink_port_type_eth_set(dlp, dp->slave); does not get
called, and devlink notices after a timeout of 3700 seconds and prints a
WARN_ON. So it went ahead to unregister the devlink port. And because
there exists an UNUSED port flavour, we actually re-register the devlink
port as UNUSED.
Commit 08156ba430b4 ("net: dsa: Add devlink port regions support to
DSA") added devlink port regions, which are set up by the driver and not
by DSA.
When we trigger the devlink port deregistration and reregistration as
unused, devlink now prints another WARN_ON, from here:
devlink_port_unregister:
WARN_ON(!list_empty(&devlink_port->region_list));
So the port still has regions, which makes sense, because they were set
up by the driver, and the driver doesn't know we're unregistering the
devlink port.
Somebody needs to tear them down, and optionally (actually it would be
nice, to be consistent) set them up again for the new devlink port.
But DSA's layering stays in our way quite badly here.
I don't know anything about DSA
It is sufficient to know in this case that it is a multi-port networking
driver.
and what led to the decision to ignore devlink registration errors,
But we are not ignoring devlink registration errors...
The devlink_port must be initialized prior to initializing the net_device.
Initializing a certain net_device may fail due to reasons such as "PHY
not found". It is desirable in certain cases for a net_device
initialization failure to not fail the entire switch probe.
So at the very least, rollback of the registration of that port must be
performed before continuing => the devlink_port needs to be unregistered
when the net_device initialization has failed.
but devlink core is relying on the simple assumption that everything
is initialized correctly.
So if DSA needs to have not-initialized port, it should do all the needed
hacks internally.
So the current problem is that the DSA framework does not ask the hardware
driver whether it has devlink port regions which need to be torn down
before unregistering the devlink port.
I was expecting the feedback to be "we need to introduce new methods in
struct dsa_switch_ops which do .port_setup and .port_teardown, similar
to the already existing per-switch .setup and .teardown, and drivers
which set up devlink port regions should set these up from the port
methods, so that DSA can simply call those when it needs to tear down a
devlink port without tearing down the entire switch and devlink instance".
The proposed patch is horrible and I agree, but not for the reasons you
might think it is.
Either way, "all the needed hacks" are already done internally, and from
devlink's perspective everything is initialized correctly, not sure what
this comment is about. I am really not changing anything in DSA's
interaction with the devlink core, other than ensuring we do not
unregister a devlink port with regions on it.
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-05 10:25:08
On Sun, Sep 05, 2021 at 11:45:18AM +0300, Vladimir Oltean wrote:
On Sun, Sep 05, 2021 at 10:07:45AM +0300, Leon Romanovsky wrote:
quoted
On Fri, Sep 03, 2021 at 02:17:38AM +0300, Vladimir Oltean wrote:
quoted
Commit 86f8b1c01a0a ("net: dsa: Do not make user port errors fatal")
decided it was fine to ignore errors on certain ports that fail to
probe, and go on with the ports that do probe fine.
Commit fb6ec87f7229 ("net: dsa: Fix type was not set for devlink port")
noticed that devlink_port_type_eth_set(dlp, dp->slave); does not get
called, and devlink notices after a timeout of 3700 seconds and prints a
WARN_ON. So it went ahead to unregister the devlink port. And because
there exists an UNUSED port flavour, we actually re-register the devlink
port as UNUSED.
Commit 08156ba430b4 ("net: dsa: Add devlink port regions support to
DSA") added devlink port regions, which are set up by the driver and not
by DSA.
When we trigger the devlink port deregistration and reregistration as
unused, devlink now prints another WARN_ON, from here:
devlink_port_unregister:
WARN_ON(!list_empty(&devlink_port->region_list));
So the port still has regions, which makes sense, because they were set
up by the driver, and the driver doesn't know we're unregistering the
devlink port.
Somebody needs to tear them down, and optionally (actually it would be
nice, to be consistent) set them up again for the new devlink port.
But DSA's layering stays in our way quite badly here.
I don't know anything about DSA
It is sufficient to know in this case that it is a multi-port networking
driver.
quoted
and what led to the decision to ignore devlink registration errors,
But we are not ignoring devlink registration errors...
The devlink_port must be initialized prior to initializing the net_device.
Initializing a certain net_device may fail due to reasons such as "PHY
not found". It is desirable in certain cases for a net_device
initialization failure to not fail the entire switch probe.
So at the very least, rollback of the registration of that port must be
performed before continuing => the devlink_port needs to be unregistered
when the net_device initialization has failed.
quoted
but devlink core is relying on the simple assumption that everything
is initialized correctly.
So if DSA needs to have not-initialized port, it should do all the needed
hacks internally.
So the current problem is that the DSA framework does not ask the hardware
driver whether it has devlink port regions which need to be torn down
before unregistering the devlink port.
I was expecting the feedback to be "we need to introduce new methods in
struct dsa_switch_ops which do .port_setup and .port_teardown, similar
to the already existing per-switch .setup and .teardown, and drivers
which set up devlink port regions should set these up from the port
methods, so that DSA can simply call those when it needs to tear down a
devlink port without tearing down the entire switch and devlink instance".
The proposed patch is horrible and I agree, but not for the reasons you
might think it is.
Either way, "all the needed hacks" are already done internally, and from
devlink's perspective everything is initialized correctly, not sure what
this comment is about. I am really not changing anything in DSA's
interaction with the devlink core, other than ensuring we do not
unregister a devlink port with regions on it.
That sentence means that your change is OK and you did it right by not
changing devlink port to hold not-working ports.
Thanks
From: Vladimir Oltean <olteanv@gmail.com> Date: 2021-09-05 10:31:30
On Sun, Sep 05, 2021 at 01:25:03PM +0300, Leon Romanovsky wrote:
On Sun, Sep 05, 2021 at 11:45:18AM +0300, Vladimir Oltean wrote:
quoted
On Sun, Sep 05, 2021 at 10:07:45AM +0300, Leon Romanovsky wrote:
quoted
On Fri, Sep 03, 2021 at 02:17:38AM +0300, Vladimir Oltean wrote:
quoted
Commit 86f8b1c01a0a ("net: dsa: Do not make user port errors fatal")
decided it was fine to ignore errors on certain ports that fail to
probe, and go on with the ports that do probe fine.
Commit fb6ec87f7229 ("net: dsa: Fix type was not set for devlink port")
noticed that devlink_port_type_eth_set(dlp, dp->slave); does not get
called, and devlink notices after a timeout of 3700 seconds and prints a
WARN_ON. So it went ahead to unregister the devlink port. And because
there exists an UNUSED port flavour, we actually re-register the devlink
port as UNUSED.
Commit 08156ba430b4 ("net: dsa: Add devlink port regions support to
DSA") added devlink port regions, which are set up by the driver and not
by DSA.
When we trigger the devlink port deregistration and reregistration as
unused, devlink now prints another WARN_ON, from here:
devlink_port_unregister:
WARN_ON(!list_empty(&devlink_port->region_list));
So the port still has regions, which makes sense, because they were set
up by the driver, and the driver doesn't know we're unregistering the
devlink port.
Somebody needs to tear them down, and optionally (actually it would be
nice, to be consistent) set them up again for the new devlink port.
But DSA's layering stays in our way quite badly here.
I don't know anything about DSA
It is sufficient to know in this case that it is a multi-port networking
driver.
quoted
and what led to the decision to ignore devlink registration errors,
But we are not ignoring devlink registration errors...
The devlink_port must be initialized prior to initializing the net_device.
Initializing a certain net_device may fail due to reasons such as "PHY
not found". It is desirable in certain cases for a net_device
initialization failure to not fail the entire switch probe.
So at the very least, rollback of the registration of that port must be
performed before continuing => the devlink_port needs to be unregistered
when the net_device initialization has failed.
quoted
but devlink core is relying on the simple assumption that everything
is initialized correctly.
So if DSA needs to have not-initialized port, it should do all the needed
hacks internally.
So the current problem is that the DSA framework does not ask the hardware
driver whether it has devlink port regions which need to be torn down
before unregistering the devlink port.
I was expecting the feedback to be "we need to introduce new methods in
struct dsa_switch_ops which do .port_setup and .port_teardown, similar
to the already existing per-switch .setup and .teardown, and drivers
which set up devlink port regions should set these up from the port
methods, so that DSA can simply call those when it needs to tear down a
devlink port without tearing down the entire switch and devlink instance".
The proposed patch is horrible and I agree, but not for the reasons you
might think it is.
Either way, "all the needed hacks" are already done internally, and from
devlink's perspective everything is initialized correctly, not sure what
this comment is about. I am really not changing anything in DSA's
interaction with the devlink core, other than ensuring we do not
unregister a devlink port with regions on it.
That sentence means that your change is OK and you did it right by not
changing devlink port to hold not-working ports.
You're with me so far.
There is a second part. The ports with 'status = "disabled"' in the
device tree still get devlink ports registered, but with the
DEVLINK_PORT_FLAVOUR_UNUSED flavour and no netdev. These devlink ports
still have things like port regions exported.
What we do for ports that have failed to probe is to reinit their
devlink ports as DEVLINK_PORT_FLAVOUR_UNUSED, and their port regions, so
they effectively behave as though they were disabled in the device tree.
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-05 10:47:57
On Sun, Sep 05, 2021 at 01:31:25PM +0300, Vladimir Oltean wrote:
On Sun, Sep 05, 2021 at 01:25:03PM +0300, Leon Romanovsky wrote:
quoted
On Sun, Sep 05, 2021 at 11:45:18AM +0300, Vladimir Oltean wrote:
quoted
On Sun, Sep 05, 2021 at 10:07:45AM +0300, Leon Romanovsky wrote:
quoted
On Fri, Sep 03, 2021 at 02:17:38AM +0300, Vladimir Oltean wrote:
<...>
quoted
That sentence means that your change is OK and you did it right by not
changing devlink port to hold not-working ports.
You're with me so far.
There is a second part. The ports with 'status = "disabled"' in the
device tree still get devlink ports registered, but with the
DEVLINK_PORT_FLAVOUR_UNUSED flavour and no netdev. These devlink ports
still have things like port regions exported.
What we do for ports that have failed to probe is to reinit their
devlink ports as DEVLINK_PORT_FLAVOUR_UNUSED, and their port regions, so
they effectively behave as though they were disabled in the device tree.
Yes, and this part require DSA knowledge that I don't have, because you
suggest fallback for any error during devlink port register, which can
fail for reasons that require proper unwind instead of reinit.
Thanks
From: Vladimir Oltean <olteanv@gmail.com> Date: 2021-09-05 11:07:41
On Sun, Sep 05, 2021 at 01:47:51PM +0300, Leon Romanovsky wrote:
On Sun, Sep 05, 2021 at 01:31:25PM +0300, Vladimir Oltean wrote:
quoted
On Sun, Sep 05, 2021 at 01:25:03PM +0300, Leon Romanovsky wrote:
quoted
On Sun, Sep 05, 2021 at 11:45:18AM +0300, Vladimir Oltean wrote:
quoted
On Sun, Sep 05, 2021 at 10:07:45AM +0300, Leon Romanovsky wrote:
quoted
On Fri, Sep 03, 2021 at 02:17:38AM +0300, Vladimir Oltean wrote:
<...>
quoted
quoted
That sentence means that your change is OK and you did it right by not
changing devlink port to hold not-working ports.
You're with me so far.
There is a second part. The ports with 'status = "disabled"' in the
device tree still get devlink ports registered, but with the
DEVLINK_PORT_FLAVOUR_UNUSED flavour and no netdev. These devlink ports
still have things like port regions exported.
What we do for ports that have failed to probe is to reinit their
devlink ports as DEVLINK_PORT_FLAVOUR_UNUSED, and their port regions, so
they effectively behave as though they were disabled in the device tree.
Yes, and this part require DSA knowledge that I don't have, because you
suggest fallback for any error during devlink port register,
Again, fallback but not during devlink port register. The devlink port
was registered just fine, but our plans changed midway. If you want to
create a net device with an associated devlink port, first you need to
create the devlink port and then the net device, then you need to link
the two using devlink_port_type_eth_set, at least according to my
understanding.
So the failure is during the creation of the **net device**, we now have a
devlink port which was originally intended to be of the Ethernet type
and have a physical flavour, but it will not be backed by any net device,
because the creation of that just failed. So the question is simply what
to do with that devlink port.
The only thing I said about the devlink API in the commit description is
that it would have been nice to just flip the type and flavour of a
devlink port, post registration. That would avoid a lot of complications
in DSA. But that is obviously not possible, and my patch does not even
attempt to do it. What DSA does today, and will still do after the patch
we are discussing on, is to unregister that initial devlink port, and
create another one with the unused flavour, and register that one.
The reason why we even bother to re-register a devlink port a second
time for a port that failed to create and initialize its net_device is
basically for consistency with the ports that are statically disabled in
the device tree. Since devlink is a mechanism through which we gain
insight into the hardware, and disabled ports are still physically
present, just, you know, disabled and not used, their devlink ports
still exist and can be used for things like dumping port regions.
We treat ports that fail to find their PHY during probing as
'dynamically disabled', and the expectation is for them to behave just
the same as ports that were statically disabled through the device tree.
My change is entirely about how to properly structure the code such that
we unregister the port regions that a devlink port might have, before
unregistering the devlink port itself, and how to re-register those port
regions then, after the new devlink port was registered.
which can fail for reasons that require proper unwind instead of
reinit.
Thanks
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-05 13:01:41
On Sun, Sep 05, 2021 at 02:07:35PM +0300, Vladimir Oltean wrote:
On Sun, Sep 05, 2021 at 01:47:51PM +0300, Leon Romanovsky wrote:
quoted
On Sun, Sep 05, 2021 at 01:31:25PM +0300, Vladimir Oltean wrote:
quoted
On Sun, Sep 05, 2021 at 01:25:03PM +0300, Leon Romanovsky wrote:
quoted
On Sun, Sep 05, 2021 at 11:45:18AM +0300, Vladimir Oltean wrote:
quoted
On Sun, Sep 05, 2021 at 10:07:45AM +0300, Leon Romanovsky wrote:
quoted
On Fri, Sep 03, 2021 at 02:17:38AM +0300, Vladimir Oltean wrote:
<...>
quoted
quoted
That sentence means that your change is OK and you did it right by not
changing devlink port to hold not-working ports.
You're with me so far.
There is a second part. The ports with 'status = "disabled"' in the
device tree still get devlink ports registered, but with the
DEVLINK_PORT_FLAVOUR_UNUSED flavour and no netdev. These devlink ports
still have things like port regions exported.
What we do for ports that have failed to probe is to reinit their
devlink ports as DEVLINK_PORT_FLAVOUR_UNUSED, and their port regions, so
they effectively behave as though they were disabled in the device tree.
Yes, and this part require DSA knowledge that I don't have, because you
suggest fallback for any error during devlink port register,
Again, fallback but not during devlink port register. The devlink port
was registered just fine, but our plans changed midway. If you want to
create a net device with an associated devlink port, first you need to
create the devlink port and then the net device, then you need to link
the two using devlink_port_type_eth_set, at least according to my
understanding.
So the failure is during the creation of the **net device**, we now have a
devlink port which was originally intended to be of the Ethernet type
and have a physical flavour, but it will not be backed by any net device,
because the creation of that just failed. So the question is simply what
to do with that devlink port.
I lost you here, from known to me from the NIC, the **net devices** are
created with devlink_alloc() API call and devlink_port_register comes
later. It means that net device is created (or not) before devlink port
code.
Anyway, it is really not important to me as long as changes won't touch
net/core/devlink.c.
Thanks
From: Vladimir Oltean <olteanv@gmail.com> Date: 2021-09-05 15:01:24
On Sun, Sep 05, 2021 at 04:01:32PM +0300, Leon Romanovsky wrote:
On Sun, Sep 05, 2021 at 02:07:35PM +0300, Vladimir Oltean wrote:
quoted
On Sun, Sep 05, 2021 at 01:47:51PM +0300, Leon Romanovsky wrote:
quoted
On Sun, Sep 05, 2021 at 01:31:25PM +0300, Vladimir Oltean wrote:
quoted
On Sun, Sep 05, 2021 at 01:25:03PM +0300, Leon Romanovsky wrote:
quoted
On Sun, Sep 05, 2021 at 11:45:18AM +0300, Vladimir Oltean wrote:
quoted
On Sun, Sep 05, 2021 at 10:07:45AM +0300, Leon Romanovsky wrote:
quoted
On Fri, Sep 03, 2021 at 02:17:38AM +0300, Vladimir Oltean wrote:
<...>
quoted
quoted
That sentence means that your change is OK and you did it right by not
changing devlink port to hold not-working ports.
You're with me so far.
There is a second part. The ports with 'status = "disabled"' in the
device tree still get devlink ports registered, but with the
DEVLINK_PORT_FLAVOUR_UNUSED flavour and no netdev. These devlink ports
still have things like port regions exported.
What we do for ports that have failed to probe is to reinit their
devlink ports as DEVLINK_PORT_FLAVOUR_UNUSED, and their port regions, so
they effectively behave as though they were disabled in the device tree.
Yes, and this part require DSA knowledge that I don't have, because you
suggest fallback for any error during devlink port register,
Again, fallback but not during devlink port register. The devlink port
was registered just fine, but our plans changed midway. If you want to
create a net device with an associated devlink port, first you need to
create the devlink port and then the net device, then you need to link
the two using devlink_port_type_eth_set, at least according to my
understanding.
So the failure is during the creation of the **net device**, we now have a
devlink port which was originally intended to be of the Ethernet type
and have a physical flavour, but it will not be backed by any net device,
because the creation of that just failed. So the question is simply what
to do with that devlink port.
I lost you here, from known to me from the NIC, the **net devices** are
created with devlink_alloc() API call and devlink_port_register comes
later. It means that net device is created (or not) before devlink port
code.
Anyway, it is really not important to me as long as changes won't touch
net/core/devlink.c.
Unless I am mistaken, there is a DEVLINK_PORT_TYPE_WARN_TIMEOUT of 3600
seconds until you can associate the devlink_port with the net_device via
devlink_port_type_eth_set, _after_ you've registered the net_device.
Is that incorrect, or is that not what the timeout is for?
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-09-07 15:44:35
On Sun, 5 Sep 2021 14:07:35 +0300 Vladimir Oltean wrote:
Again, fallback but not during devlink port register. The devlink port
was registered just fine, but our plans changed midway. If you want to
create a net device with an associated devlink port, first you need to
create the devlink port and then the net device, then you need to link
the two using devlink_port_type_eth_set, at least according to my
understanding.
So the failure is during the creation of the **net device**, we now have a
devlink port which was originally intended to be of the Ethernet type
and have a physical flavour, but it will not be backed by any net device,
because the creation of that just failed. So the question is simply what
to do with that devlink port.
Is the failure you're referring to discovered inside the
register_netdevice() call?
The only thing I said about the devlink API in the commit description is
that it would have been nice to just flip the type and flavour of a
devlink port, post registration. That would avoid a lot of complications
in DSA. But that is obviously not possible, and my patch does not even
attempt to do it. What DSA does today, and will still do after the patch
we are discussing on, is to unregister that initial devlink port, and
create another one with the unused flavour, and register that one.
The reason why we even bother to re-register a devlink port a second
time for a port that failed to create and initialize its net_device is
basically for consistency with the ports that are statically disabled in
the device tree. Since devlink is a mechanism through which we gain
insight into the hardware, and disabled ports are still physically
present, just, you know, disabled and not used, their devlink ports
still exist and can be used for things like dumping port regions.
We treat ports that fail to find their PHY during probing as
'dynamically disabled', and the expectation is for them to behave just
the same as ports that were statically disabled through the device tree.
My change is entirely about how to properly structure the code such that
we unregister the port regions that a devlink port might have, before
unregistering the devlink port itself, and how to re-register those port
regions then, after the new devlink port was registered.
On Sun, 5 Sep 2021 14:07:35 +0300 Vladimir Oltean wrote:
quoted
Again, fallback but not during devlink port register. The devlink port
was registered just fine, but our plans changed midway. If you want to
create a net device with an associated devlink port, first you need to
create the devlink port and then the net device, then you need to link
the two using devlink_port_type_eth_set, at least according to my
understanding.
So the failure is during the creation of the **net device**, we now have a
devlink port which was originally intended to be of the Ethernet type
and have a physical flavour, but it will not be backed by any net device,
because the creation of that just failed. So the question is simply what
to do with that devlink port.
Is the failure you're referring to discovered inside the
register_netdevice() call?
It is before, at the time we attempt to connect to the PHY device, prior
to registering the netdev, we may fail that PHY connection, tearing down
the entire switch because of that is highly undesirable.
Maybe we should re-order things a little bit and try to register devlink
ports only after we successfully registered with the PHY/SFP and prior
to registering the netdev?
--
Florian
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-09-07 16:43:12
On Tue, Sep 07, 2021 at 08:47:35AM -0700, Florian Fainelli wrote:
On 9/7/2021 8:44 AM, Jakub Kicinski wrote:
quoted
On Sun, 5 Sep 2021 14:07:35 +0300 Vladimir Oltean wrote:
quoted
Again, fallback but not during devlink port register. The devlink port
was registered just fine, but our plans changed midway. If you want to
create a net device with an associated devlink port, first you need to
create the devlink port and then the net device, then you need to link
the two using devlink_port_type_eth_set, at least according to my
understanding.
So the failure is during the creation of the **net device**, we now have a
devlink port which was originally intended to be of the Ethernet type
and have a physical flavour, but it will not be backed by any net device,
because the creation of that just failed. So the question is simply what
to do with that devlink port.
Is the failure you're referring to discovered inside the
register_netdevice() call?
It is before, at the time we attempt to connect to the PHY device, prior to
registering the netdev, we may fail that PHY connection, tearing down the
entire switch because of that is highly undesirable.
Maybe we should re-order things a little bit and try to register devlink
ports only after we successfully registered with the PHY/SFP and prior to
registering the netdev?
Maybe, but it should not really matter. EPROBE_DEFER exists, and can
happen. The probe can fail for other reasons. All core code should be
cleanly undoable. Maybe we are pushing it a little by only wanting to
undo a single port, rather than the whole switch, but still, i would
make the core handle this, not rearrange the driver. It is not robust
otherwise.
Andrew
On Tue, Sep 07, 2021 at 08:47:35AM -0700, Florian Fainelli wrote:
quoted
On 9/7/2021 8:44 AM, Jakub Kicinski wrote:
quoted
On Sun, 5 Sep 2021 14:07:35 +0300 Vladimir Oltean wrote:
quoted
Again, fallback but not during devlink port register. The devlink port
was registered just fine, but our plans changed midway. If you want to
create a net device with an associated devlink port, first you need to
create the devlink port and then the net device, then you need to link
the two using devlink_port_type_eth_set, at least according to my
understanding.
So the failure is during the creation of the **net device**, we now have a
devlink port which was originally intended to be of the Ethernet type
and have a physical flavour, but it will not be backed by any net device,
because the creation of that just failed. So the question is simply what
to do with that devlink port.
Is the failure you're referring to discovered inside the
register_netdevice() call?
It is before, at the time we attempt to connect to the PHY device, prior to
registering the netdev, we may fail that PHY connection, tearing down the
entire switch because of that is highly undesirable.
Maybe we should re-order things a little bit and try to register devlink
ports only after we successfully registered with the PHY/SFP and prior to
registering the netdev?
Maybe, but it should not really matter. EPROBE_DEFER exists, and can
happen. The probe can fail for other reasons. All core code should be
cleanly undoable. Maybe we are pushing it a little by only wanting to
undo a single port, rather than the whole switch, but still, i would
make the core handle this, not rearrange the driver. It is not robust
otherwise.
Well yes, in case my comment was not clear, I was referring to the way
that DSA register devlink ports, not how the mv88e6xxx driver does it.
That is assuming that it is possible and there was not a reason for
configuring the devlink ports ahead of the switch driver coming up.
--
Florian
From: Leon Romanovsky <leon@kernel.org> Date: 2021-09-07 22:59:38
On Tue, Sep 07, 2021 at 09:49:48AM -0700, Florian Fainelli wrote:
On 9/7/2021 9:43 AM, Andrew Lunn wrote:
quoted
On Tue, Sep 07, 2021 at 08:47:35AM -0700, Florian Fainelli wrote:
quoted
On 9/7/2021 8:44 AM, Jakub Kicinski wrote:
quoted
On Sun, 5 Sep 2021 14:07:35 +0300 Vladimir Oltean wrote:
quoted
Again, fallback but not during devlink port register. The devlink port
was registered just fine, but our plans changed midway. If you want to
create a net device with an associated devlink port, first you need to
create the devlink port and then the net device, then you need to link
the two using devlink_port_type_eth_set, at least according to my
understanding.
So the failure is during the creation of the **net device**, we now have a
devlink port which was originally intended to be of the Ethernet type
and have a physical flavour, but it will not be backed by any net device,
because the creation of that just failed. So the question is simply what
to do with that devlink port.
Is the failure you're referring to discovered inside the
register_netdevice() call?
It is before, at the time we attempt to connect to the PHY device, prior to
registering the netdev, we may fail that PHY connection, tearing down the
entire switch because of that is highly undesirable.
Maybe we should re-order things a little bit and try to register devlink
ports only after we successfully registered with the PHY/SFP and prior to
registering the netdev?
Maybe, but it should not really matter. EPROBE_DEFER exists, and can
happen. The probe can fail for other reasons. All core code should be
cleanly undoable. Maybe we are pushing it a little by only wanting to
undo a single port, rather than the whole switch, but still, i would
make the core handle this, not rearrange the driver. It is not robust
otherwise.
Well yes, in case my comment was not clear, I was referring to the way that
DSA register devlink ports, not how the mv88e6xxx driver does it. That is
assuming that it is possible and there was not a reason for configuring the
devlink ports ahead of the switch driver coming up.
This is the best arrangement. It is responsibility of the caller (DSA
core) to ensure that calls are valid prior to the devlink core.
Thanks
From: Vladimir Oltean <olteanv@gmail.com> Date: 2021-09-08 20:21:11
On Tue, Sep 07, 2021 at 09:49:48AM -0700, Florian Fainelli wrote:
On 9/7/2021 9:43 AM, Andrew Lunn wrote:
quoted
On Tue, Sep 07, 2021 at 08:47:35AM -0700, Florian Fainelli wrote:
quoted
On 9/7/2021 8:44 AM, Jakub Kicinski wrote:
quoted
On Sun, 5 Sep 2021 14:07:35 +0300 Vladimir Oltean wrote:
quoted
Again, fallback but not during devlink port register. The devlink port
was registered just fine, but our plans changed midway. If you want to
create a net device with an associated devlink port, first you need to
create the devlink port and then the net device, then you need to link
the two using devlink_port_type_eth_set, at least according to my
understanding.
So the failure is during the creation of the **net device**, we now have a
devlink port which was originally intended to be of the Ethernet type
and have a physical flavour, but it will not be backed by any net device,
because the creation of that just failed. So the question is simply what
to do with that devlink port.
Is the failure you're referring to discovered inside the
register_netdevice() call?
It is before, at the time we attempt to connect to the PHY device, prior to
registering the netdev, we may fail that PHY connection, tearing down the
entire switch because of that is highly undesirable.
Maybe we should re-order things a little bit and try to register devlink
ports only after we successfully registered with the PHY/SFP and prior to
registering the netdev?
Maybe, but it should not really matter. EPROBE_DEFER exists, and can
happen. The probe can fail for other reasons. All core code should be
cleanly undoable. Maybe we are pushing it a little by only wanting to
undo a single port, rather than the whole switch, but still, i would
make the core handle this, not rearrange the driver. It is not robust
otherwise.
Well yes, in case my comment was not clear, I was referring to the way that
DSA register devlink ports, not how the mv88e6xxx driver does it. That is
assuming that it is possible and there was not a reason for configuring the
devlink ports ahead of the switch driver coming up.
There is a comment in dsa_switch_setup:
/* Setup devlink port instances now, so that the switch
* setup() can register regions etc, against the ports
*/
The fact of the matter is that in the current driver-facing API, there
is no better place to register devlink port regions than .setup: we have
no .port_setup and .port_teardown. This also forces us to register the
devlink ports earlier than we register the net devices.
In one of my previous replies to Leon I did indicate the introduction of
these two methods as a possibly less horrible way of packaging what we
have now in this patch as .port_reinit_as_unused, which is basically a
.port_teardown followed immediately by a .port_setup, as it would be
implemented by mv88e6xxx.
With the introduction of .port_setup and .port_teardown as an immediate
bug fix, reordering the devlink port registration vs the netdev connection
to the PHY could be done as further work, but it would sort of be a moot
point, since it would not solve any problem anymore.