From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Florian Fainelli <f.fainelli@gmail.com>,
Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Tom Lendacky <thomas.lendacky@amd.com>
Cc: Vivien Didelot <vivien.didelot@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
George McCollister <george.mccollister@gmail.com>,
Hauke Mehrtens <hauke@hauke-m.de>,
Kurt Kanzenbach <kurt@linutronix.de>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Woojung Huh <woojung.huh@microchip.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, UNGLinuxDriver@microchip.com
Subject: Re: [PATCH RFC net-next 05/12] net: dsa: bcm_sf2: convert to phylink_generic_validate()
Date: Sat, 4 Dec 2021 14:42:40 +0000 [thread overview]
Message-ID: <Yat+YKhx9E5Xyad4@shell.armlinux.org.uk> (raw)
In-Reply-To: <Yast4PrQGGLxDrCy@shell.armlinux.org.uk>
On Sat, Dec 04, 2021 at 08:59:12AM +0000, Russell King (Oracle) wrote:
> On Fri, Dec 03, 2021 at 08:18:22PM -0800, Florian Fainelli wrote:
> > On 12/3/21 12:03 PM, Florian Fainelli wrote:
> > > On 11/24/21 9:52 AM, Russell King (Oracle) wrote:
> > > > Populate the supported interfaces and MAC capabilities for the bcm_sf2
> > > > DSA switch and remove the old validate implementation to allow DSA to
> > > > use phylink_generic_validate() for this switch driver.
> > > >
> > > > The exclusion of Gigabit linkmodes for MII and Reverse MII links is
> > > > handled within phylink_generic_validate() in phylink, so there is no
> > > > need to make them conditional on the interface mode in the driver.
> > > >
> > > > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> > >
> > > Tested-by: Florian Fainelli <f.fainelli@gmail.com>
> > >
> > > but it looks like the fixed link ports are reporting some pretty strange
> > > advertisement values one of my two platforms running the same kernel image:
> >
> > We would want to amend your patch with something that caters a bit more
> > towards how the ports have been configured:
> >
> > diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
> > index d6ef0fb0d943..88933c3feddd 100644
> > --- a/drivers/net/dsa/bcm_sf2.c
> > +++ b/drivers/net/dsa/bcm_sf2.c
> > @@ -675,12 +675,18 @@ static u32 bcm_sf2_sw_get_phy_flags(struct
> > dsa_switch *ds, int port)
> > static void bcm_sf2_sw_get_caps(struct dsa_switch *ds, int port,
> > struct phylink_config *config)
> > {
> > - __set_bit(PHY_INTERFACE_MODE_MII, config->supported_interfaces);
> > - __set_bit(PHY_INTERFACE_MODE_REVMII, config->supported_interfaces);
> > - __set_bit(PHY_INTERFACE_MODE_GMII, config->supported_interfaces);
> > - __set_bit(PHY_INTERFACE_MODE_INTERNAL,
> > config->supported_interfaces);
> > - __set_bit(PHY_INTERFACE_MODE_MOCA, config->supported_interfaces);
> > - phy_interface_set_rgmii(config->supported_interfaces);
> > + struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
> > +
> > + if (priv->int_phy_mask & BIT(port))
> > + __set_bit(PHY_INTERFACE_MODE_INTERNAL,
> > config->supported_interfaces);
> > + else if (priv->moca_port == port)
> > + __set_bit(PHY_INTERFACE_MODE_MOCA,
> > config->supported_interfaces);
> > + else {
> > + __set_bit(PHY_INTERFACE_MODE_MII,
> > config->supported_interfaces);
> > + __set_bit(PHY_INTERFACE_MODE_REVMII,
> > config->supported_interfaces);
> > + __set_bit(PHY_INTERFACE_MODE_GMII,
> > config->supported_interfaces);
> > + phy_interface_set_rgmii(config->supported_interfaces);
> > + }
> >
> > config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
> > MAC_10 | MAC_100 | MAC_1000;
>
> That's fine, thanks for the update.
Here's the resulting updated patch. I've changed it slightly to avoid
the wrapping, and updated the commit text - please let me know if you'd
like any attributations added. Thanks!
8<===
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Subject: [PATCH RFC v2 net-next] net: dsa: bcm_sf2: convert to
phylink_generic_validate()
Populate the supported interfaces and MAC capabilities for the bcm_sf2
DSA switch and remove the old validate implementation to allow DSA to
use phylink_generic_validate() for this switch driver.
The exclusion of Gigabit linkmodes for MII and Reverse MII links is
handled within phylink_generic_validate() in phylink, so there is no
need to make them conditional on the interface mode in the driver.
Thanks to Florian Fainelli for suggesting how to populate the supported
interfaces.
Link: https://lore.kernel.org/r/3b3fed98-0c82-99e9-dc72-09fe01c2bcf3@gmail.com
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/dsa/bcm_sf2.c | 54 +++++++++++----------------------------
1 file changed, 15 insertions(+), 39 deletions(-)
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 13aa43b5cffd..114d4ba7716f 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -672,49 +672,25 @@ static u32 bcm_sf2_sw_get_phy_flags(struct dsa_switch *ds, int port)
PHY_BRCM_IDDQ_SUSPEND;
}
-static void bcm_sf2_sw_validate(struct dsa_switch *ds, int port,
- unsigned long *supported,
- struct phylink_link_state *state)
+static void bcm_sf2_sw_get_caps(struct dsa_switch *ds, int port,
+ struct phylink_config *config)
{
+ unsigned long *interfaces = config->supported_interfaces;
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
- __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
-
- if (!phy_interface_mode_is_rgmii(state->interface) &&
- state->interface != PHY_INTERFACE_MODE_MII &&
- state->interface != PHY_INTERFACE_MODE_REVMII &&
- state->interface != PHY_INTERFACE_MODE_GMII &&
- state->interface != PHY_INTERFACE_MODE_INTERNAL &&
- state->interface != PHY_INTERFACE_MODE_MOCA) {
- linkmode_zero(supported);
- if (port != core_readl(priv, CORE_IMP0_PRT_ID))
- dev_err(ds->dev,
- "Unsupported interface: %d for port %d\n",
- state->interface, port);
- return;
- }
-
- /* Allow all the expected bits */
- phylink_set(mask, Autoneg);
- phylink_set_port_modes(mask);
- phylink_set(mask, Pause);
- phylink_set(mask, Asym_Pause);
- /* With the exclusion of MII and Reverse MII, we support Gigabit,
- * including Half duplex
- */
- if (state->interface != PHY_INTERFACE_MODE_MII &&
- state->interface != PHY_INTERFACE_MODE_REVMII) {
- phylink_set(mask, 1000baseT_Full);
- phylink_set(mask, 1000baseT_Half);
+ if (priv->int_phy_mask & BIT(port)) {
+ __set_bit(PHY_INTERFACE_MODE_INTERNAL, interfaces);
+ } else if (priv->moca_port == port) {
+ __set_bit(PHY_INTERFACE_MODE_MOCA, interfaces);
+ } else {
+ __set_bit(PHY_INTERFACE_MODE_MII, interfaces);
+ __set_bit(PHY_INTERFACE_MODE_REVMII, interfaces);
+ __set_bit(PHY_INTERFACE_MODE_GMII, interfaces);
+ phy_interface_set_rgmii(interfaces);
}
- phylink_set(mask, 10baseT_Half);
- phylink_set(mask, 10baseT_Full);
- phylink_set(mask, 100baseT_Half);
- phylink_set(mask, 100baseT_Full);
-
- linkmode_and(supported, supported, mask);
- linkmode_and(state->advertising, state->advertising, mask);
+ config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
+ MAC_10 | MAC_100 | MAC_1000;
}
static void bcm_sf2_sw_mac_config(struct dsa_switch *ds, int port,
@@ -1181,7 +1157,7 @@ static const struct dsa_switch_ops bcm_sf2_ops = {
.get_sset_count = bcm_sf2_sw_get_sset_count,
.get_ethtool_phy_stats = b53_get_ethtool_phy_stats,
.get_phy_flags = bcm_sf2_sw_get_phy_flags,
- .phylink_validate = bcm_sf2_sw_validate,
+ .phylink_get_caps = bcm_sf2_sw_get_caps,
.phylink_mac_config = bcm_sf2_sw_mac_config,
.phylink_mac_link_down = bcm_sf2_sw_mac_link_down,
.phylink_mac_link_up = bcm_sf2_sw_mac_link_up,
--
2.30.2
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2021-12-04 14:42 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-24 17:46 [PATCH RFC net-next 00/12] Allow DSA drivers to set all phylink capabilities Russell King (Oracle)
2021-11-24 17:52 ` [PATCH RFC net-next 01/12] net: dsa: consolidate phylink creation Russell King (Oracle)
2021-11-24 18:11 ` Vladimir Oltean
2021-11-24 23:25 ` Russell King (Oracle)
2021-11-24 17:52 ` [PATCH RFC net-next 02/12] net: dsa: support use of phylink_generic_validate() Russell King (Oracle)
2021-11-24 18:13 ` Vladimir Oltean
2021-11-24 17:52 ` [PATCH RFC net-next 03/12] net: dsa: replace phylink_get_interfaces() with phylink_get_caps() Russell King (Oracle)
2021-11-24 18:15 ` Vladimir Oltean
2021-11-24 18:26 ` Russell King (Oracle)
2021-11-24 19:10 ` Russell King (Oracle)
2021-11-24 20:26 ` Vladimir Oltean
2021-11-24 20:56 ` Russell King (Oracle)
2021-11-24 21:18 ` Vladimir Oltean
2021-11-24 17:52 ` [PATCH RFC net-next 04/12] net: dsa: ar9331: convert to phylink_generic_validate() Russell King (Oracle)
2021-11-24 17:52 ` [PATCH RFC net-next 05/12] net: dsa: bcm_sf2: " Russell King (Oracle)
2021-12-03 20:03 ` Florian Fainelli
2021-12-04 4:18 ` Florian Fainelli
2021-12-04 8:59 ` Russell King (Oracle)
2021-12-04 14:42 ` Russell King (Oracle) [this message]
2021-12-04 14:52 ` Russell King (Oracle)
2021-12-04 15:01 ` Andrew Lunn
2021-12-05 12:58 ` Russell King (Oracle)
2021-12-06 15:59 ` Tom Lendacky
2021-12-06 16:13 ` Russell King (Oracle)
2021-12-06 16:36 ` Tom Lendacky
2021-12-06 16:39 ` Russell King (Oracle)
2021-12-06 17:06 ` Florian Fainelli
2021-12-06 19:26 ` Russell King (Oracle)
2021-12-07 18:08 ` Russell King (Oracle)
2021-11-24 17:52 ` [PATCH RFC net-next 06/12] net: dsa: hellcreek: " Russell King (Oracle)
2021-11-25 8:49 ` Kurt Kanzenbach
2021-11-24 17:52 ` [PATCH RFC net-next 07/12] net: dsa: ksz8795: " Russell King (Oracle)
2021-11-24 17:53 ` [PATCH RFC net-next 08/12] net: dsa: lantiq: " Russell King (Oracle)
2021-11-28 18:49 ` Hauke Mehrtens
2021-11-24 17:53 ` [PATCH RFC net-next 09/12] net: dsa: ocelot: " Russell King (Oracle)
2021-11-24 20:07 ` Vladimir Oltean
2021-11-24 21:21 ` Russell King (Oracle)
2021-11-24 17:53 ` [PATCH RFC net-next 10/12] net: dsa: qca8k: " Russell King (Oracle)
2021-11-24 17:53 ` [PATCH RFC net-next 11/12] net: dsa: sja1105: " Russell King (Oracle)
2021-11-24 19:53 ` Vladimir Oltean
2021-11-24 21:08 ` Russell King (Oracle)
2021-11-24 22:34 ` Vladimir Oltean
2021-11-24 23:21 ` Russell King (Oracle)
2021-11-24 23:32 ` Vladimir Oltean
2021-11-25 12:56 ` Russell King (Oracle)
2021-11-25 16:18 ` Vladimir Oltean
2021-11-24 17:53 ` [PATCH RFC net-next 12/12] net: dsa: xrs700x: " Russell King (Oracle)
2021-12-03 16:15 ` [PATCH RFC net-next 00/12] Allow DSA drivers to set all phylink capabilities Russell King (Oracle)
2021-12-03 19:28 ` Florian Fainelli
2021-12-03 19:44 ` Florian Fainelli
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=Yat+YKhx9E5Xyad4@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=george.mccollister@gmail.com \
--cc=hauke@hauke-m.de \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=kurt@linutronix.de \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=thomas.lendacky@amd.com \
--cc=vivien.didelot@gmail.com \
--cc=vladimir.oltean@nxp.com \
--cc=woojung.huh@microchip.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).