diff mbox series

[net-next,1/4] net: dsa: ocelot: populate supported_interfaces

Message ID E1nNdJV-00AsoS-Qi@rmk-PC.armlinux.org.uk (mailing list archive)
State Accepted
Commit 79fda660bdbba839f434cf8674ff4a20d88fbeb2
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: ocelot: phylink updates | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: linux@armlinux.org.uk
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Russell King (Oracle) Feb. 25, 2022, 4:19 p.m. UTC
Populate the supported interfaces bitmap for the Ocelot DSA switches.

Since all sub-drivers only support a single interface mode, defined by
ocelot_port->phy_mode, we can handle this in the main driver code
without reference to the sub-driver.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/dsa/ocelot/felix.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Vladimir Oltean Feb. 25, 2022, 4:25 p.m. UTC | #1
On Fri, Feb 25, 2022 at 04:19:25PM +0000, Russell King (Oracle) wrote:
> Populate the supported interfaces bitmap for the Ocelot DSA switches.
> 
> Since all sub-drivers only support a single interface mode, defined by
> ocelot_port->phy_mode, we can handle this in the main driver code
> without reference to the sub-driver.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Russell King (Oracle) Feb. 25, 2022, 4:31 p.m. UTC | #2
On Fri, Feb 25, 2022 at 04:25:30PM +0000, Vladimir Oltean wrote:
> On Fri, Feb 25, 2022 at 04:19:25PM +0000, Russell King (Oracle) wrote:
> > Populate the supported interfaces bitmap for the Ocelot DSA switches.
> > 
> > Since all sub-drivers only support a single interface mode, defined by
> > ocelot_port->phy_mode, we can handle this in the main driver code
> > without reference to the sub-driver.
> > 
> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> > ---
> 
> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Brilliant, thanks.

This is the final driver in net-next that was making use of
phylink_set_pcs(), so once this series is merged, that function will
only be used by phylink internally. The next patch I have in the queue
is to remove that function.

Marek Behún will be very happy to see phylink_set_pcs() gone.
Marek Behún Feb. 25, 2022, 5:16 p.m. UTC | #3
On Fri, 25 Feb 2022 16:31:52 +0000
"Russell King (Oracle)" <linux@armlinux.org.uk> wrote:

> On Fri, Feb 25, 2022 at 04:25:30PM +0000, Vladimir Oltean wrote:
> > On Fri, Feb 25, 2022 at 04:19:25PM +0000, Russell King (Oracle) wrote:  
> > > Populate the supported interfaces bitmap for the Ocelot DSA switches.
> > > 
> > > Since all sub-drivers only support a single interface mode, defined by
> > > ocelot_port->phy_mode, we can handle this in the main driver code
> > > without reference to the sub-driver.
> > > 
> > > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> > > ---  
> > 
> > Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> > Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>  
> 
> Brilliant, thanks.
> 
> This is the final driver in net-next that was making use of
> phylink_set_pcs(), so once this series is merged, that function will
> only be used by phylink internally. The next patch I have in the queue
> is to remove that function.
> 
> Marek Behún will be very happy to see phylink_set_pcs() gone.

Yes, finally we can convert mv88e6xxx fully :)
Russell King (Oracle) Feb. 25, 2022, 5:40 p.m. UTC | #4
On Fri, Feb 25, 2022 at 06:16:53PM +0100, Marek Behún wrote:
> On Fri, 25 Feb 2022 16:31:52 +0000
> "Russell King (Oracle)" <linux@armlinux.org.uk> wrote:
> 
> > On Fri, Feb 25, 2022 at 04:25:30PM +0000, Vladimir Oltean wrote:
> > > On Fri, Feb 25, 2022 at 04:19:25PM +0000, Russell King (Oracle) wrote:  
> > > > Populate the supported interfaces bitmap for the Ocelot DSA switches.
> > > > 
> > > > Since all sub-drivers only support a single interface mode, defined by
> > > > ocelot_port->phy_mode, we can handle this in the main driver code
> > > > without reference to the sub-driver.
> > > > 
> > > > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> > > > ---  
> > > 
> > > Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> > > Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>  
> > 
> > Brilliant, thanks.
> > 
> > This is the final driver in net-next that was making use of
> > phylink_set_pcs(), so once this series is merged, that function will
> > only be used by phylink internally. The next patch I have in the queue
> > is to remove that function.
> > 
> > Marek Behún will be very happy to see phylink_set_pcs() gone.
> 
> Yes, finally we can convert mv88e6xxx fully :)

... changing the subject line to show we've drifted off topic ...

Yes, once we've worked out what the PCS interface should look like in
order to deal with the 88E6393 errata workaround that needs to be run
each time the interface changes or whenever we "power up" the PCS.

I think that needs to be discussed, because I can see no clean and
clear solution that doesn't have some kind of down-side.

The existing pcs_enable/pcs_disable I have in my tree fits well with
the idea of changing a PCS, but not for being called every time we do
a major config when the PCS isn't being changed. To see what I mean,
would someone who didn't have the 6393 issue be happy with this
sequence on every major configuration, even when the PCS isn't being
changed:

	mac_prepare()
	pcs_disable()
	mac_config()
	pcs_enable()
	pcs_config()
	pcs_an_restart()
	mac_finish()

I thought about calling pcs_disable() pcs_prepare() but that then
throws out pcs_enable(), unless we do that after pcs_config() - but
what if pcs_enable() is used to clear the PDOWN bit of the PCS, or
other (possibly external) PCS power control that prevents its registers
being accessed.

I'm also thinking, having had another recent look at
mv88e6xxx_mac_config(), we would need to move this:

        if (mode != MLO_AN_PHY || !mv88e6xxx_phy_is_internal(ds, port)) {
                /* In inband mode, the link may come up at any time while the
                 * link is not forced down. Force the link down while we
                 * reconfigure the interface mode.
                 */
                if (mode == MLO_AN_INBAND &&
                    p->interface != state->interface &&
                    chip->info->ops->port_set_link)
                        chip->info->ops->port_set_link(chip, port,
                                                       LINK_FORCED_DOWN);

into a mac_prepare() callback so it still happens prior to the PCS
being called - which will need to happen between mac_prepare() and
mac_config() for the errata. That means extending the mac_prepare()
and mac_finish() methods into DSA as well.

I do have a patch to add those additional callbacks to DSA, but I
currently have no code that makes use of them (so haven't sent it
yet.) See "net: dsa: add support for new phylink calls".

I think I would prefer at this point - to get the mt7530 changes
settled, which will then allow the phylink_helper_basex_speed()
helper to be removed, do a few further phylink/sfp code cleanups
(using %pe consistently in that code to print errors) and then wait
until the next kernel cycle before tackling mv88e6xxx.
Andrew Lunn Feb. 25, 2022, 5:57 p.m. UTC | #5
> ... changing the subject line to show we've drifted off topic ...
> 
> Yes, once we've worked out what the PCS interface should look like in
> order to deal with the 88E6393 errata workaround that needs to be run
> each time the interface changes or whenever we "power up" the PCS.

Hi Russell

The erratas are not limited to 6393. For the 6390 there is an errata
where you need to "power up" the PCS before you change cmode,
otherwise TX works, but RX just drops frames rather than pass them to
the MAC.

I've not looked at the details of your proposal, and maybe it is a
none issue, i just wanted to make sure you are aware of this.

   Andrew
Russell King (Oracle) Feb. 25, 2022, 6:11 p.m. UTC | #6
On Fri, Feb 25, 2022 at 06:57:33PM +0100, Andrew Lunn wrote:
> > ... changing the subject line to show we've drifted off topic ...
> > 
> > Yes, once we've worked out what the PCS interface should look like in
> > order to deal with the 88E6393 errata workaround that needs to be run
> > each time the interface changes or whenever we "power up" the PCS.
> 
> Hi Russell
> 
> The erratas are not limited to 6393. For the 6390 there is an errata
> where you need to "power up" the PCS before you change cmode,
> otherwise TX works, but RX just drops frames rather than pass them to
> the MAC.
> 
> I've not looked at the details of your proposal, and maybe it is a
> none issue, i just wanted to make sure you are aware of this.

Thanks - Marek has been keeping me on the straight and narrow with
these issues, but it's good to know that it's not necessary for the
other Marvell variants. That's been at the back of my mind a bit as
we're getting closer to the point that we need to sort this out.

I should also mention - once the mt7530 and mv88e6xxx drivers are
sorted, I believe we will then be in a position to kill off all the
"legacy_pre_march2020" stuff in DSA since DSA will no longer need the
legacy phylink behaviour.

Sadly, though, that doesn't mean "legacy_pre_march2020" can be removed,
we still have mtk_eth_soc reliant on the old behaviour.
diff mbox series

Patch

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index 9959407fede8..a1a6ace39aab 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -778,6 +778,15 @@  static int felix_vlan_del(struct dsa_switch *ds, int port,
 	return ocelot_vlan_del(ocelot, port, vlan->vid);
 }
 
+static void felix_phylink_get_caps(struct dsa_switch *ds, int port,
+				   struct phylink_config *config)
+{
+	struct ocelot *ocelot = ds->priv;
+
+	__set_bit(ocelot->ports[port]->phy_mode,
+		  config->supported_interfaces);
+}
+
 static void felix_phylink_validate(struct dsa_switch *ds, int port,
 				   unsigned long *supported,
 				   struct phylink_link_state *state)
@@ -1587,6 +1596,7 @@  const struct dsa_switch_ops felix_switch_ops = {
 	.get_ethtool_stats		= felix_get_ethtool_stats,
 	.get_sset_count			= felix_get_sset_count,
 	.get_ts_info			= felix_get_ts_info,
+	.phylink_get_caps		= felix_phylink_get_caps,
 	.phylink_validate		= felix_phylink_validate,
 	.phylink_mac_config		= felix_phylink_mac_config,
 	.phylink_mac_link_down		= felix_phylink_mac_link_down,