From: Russell King <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Heiner Kallweit <hkallweit1@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Subject: [PATCH net-next v3 08/14] net: phylink: support Clause 45 PHYs on SFP+ modules
Date: Wed, 11 Dec 2019 10:56:30 +0000 [thread overview]
Message-ID: <E1iezfS-0002yR-Al@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20191211104821.GB25745@shell.armlinux.org.uk>
Some SFP+ modules have Clause 45 PHYs embedded on them, which need a
little more handling in order to ensure that they are correctly setup,
as they switch the PHY link mode according to the negotiated speed.
With Clause 22 PHYs, we assumed that they would operate in SGMII mode,
but this assumption is now false. Adapt phylink to support Clause 45
PHYs on SFP+ modules.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/phylink.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index e6157534d3bd..370c9fcb0cda 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -711,7 +711,8 @@ static void phylink_phy_change(struct phy_device *phydev, bool up,
phy_duplex_to_str(phydev->duplex));
}
-static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy)
+static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy,
+ phy_interface_t interface)
{
struct phylink_link_state config;
__ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
@@ -729,7 +730,7 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy)
memset(&config, 0, sizeof(config));
linkmode_copy(supported, phy->supported);
linkmode_copy(config.advertising, phy->advertising);
- config.interface = pl->link_config.interface;
+ config.interface = interface;
ret = phylink_validate(pl, supported, &config);
if (ret)
@@ -745,6 +746,7 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy)
mutex_lock(&phy->lock);
mutex_lock(&pl->state_mutex);
pl->phydev = phy;
+ pl->phy_state.interface = interface;
linkmode_copy(pl->supported, supported);
linkmode_copy(pl->link_config.advertising, config.advertising);
@@ -807,7 +809,7 @@ int phylink_connect_phy(struct phylink *pl, struct phy_device *phy)
if (ret < 0)
return ret;
- ret = phylink_bringup_phy(pl, phy);
+ ret = phylink_bringup_phy(pl, phy, pl->link_config.interface);
if (ret)
phy_detach(phy);
@@ -860,7 +862,7 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn,
if (!phy_dev)
return -ENODEV;
- ret = phylink_bringup_phy(pl, phy_dev);
+ ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface);
if (ret)
phy_detach(phy_dev);
@@ -1812,13 +1814,22 @@ static void phylink_sfp_link_up(void *upstream)
static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy)
{
struct phylink *pl = upstream;
+ phy_interface_t interface = pl->link_config.interface;
int ret;
ret = phylink_attach_phy(pl, phy, pl->link_config.interface);
if (ret < 0)
return ret;
- ret = phylink_bringup_phy(pl, phy);
+ /* Clause 45 PHYs switch their Serdes lane between several different
+ * modes, normally 10GBASE-R, SGMII. Some use 2500BASE-X for 2.5G
+ * speeds. We really need to know which interface modes the PHY and
+ * MAC supports to properly work out which linkmodes can be supported.
+ */
+ if (phy->is_c45)
+ interface = PHY_INTERFACE_MODE_NA;
+
+ ret = phylink_bringup_phy(pl, phy, interface);
if (ret)
phy_detach(phy);
--
2.20.1
next prev parent reply other threads:[~2019-12-11 10:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-11 10:48 [PATCH net-next v3 00/14] Add support for SFP+ copper modules Russell King - ARM Linux admin
2019-12-11 10:55 ` [PATCH net-next v3 01/14] net: sfp: remove incomplete 100BASE-FX and 100BASE-LX support Russell King
2019-12-11 10:55 ` [PATCH net-next v3 02/14] net: sfp: derive interface mode from ethtool link modes Russell King
2019-12-11 10:56 ` [PATCH net-next v3 03/14] net: sfp: add more extended compliance codes Russell King
2019-12-11 10:56 ` [PATCH net-next v3 04/14] net: sfp: add module start/stop upstream notifications Russell King
2019-12-11 10:56 ` [PATCH net-next v3 05/14] net: sfp: move phy_start()/phy_stop() to phylink Russell King
2019-12-11 10:56 ` [PATCH net-next v3 06/14] net: mdio-i2c: add support for Clause 45 accesses Russell King
2019-12-11 10:56 ` [PATCH net-next v3 07/14] net: phylink: re-split __phylink_connect_phy() Russell King
2019-12-11 10:56 ` Russell King [this message]
2019-12-11 10:56 ` [PATCH net-next v3 09/14] net: phylink: split link_an_mode configured and current settings Russell King
2019-12-11 10:56 ` [PATCH net-next v3 10/14] net: phylink: split phylink_sfp_module_insert() Russell King
2019-12-11 10:56 ` [PATCH net-next v3 11/14] net: phylink: delay MAC configuration for copper SFP modules Russell King
2019-12-11 10:56 ` [PATCH net-next v3 12/14] net: phylink: make Broadcom BCM84881 based SFPs work Russell King
2019-12-11 10:56 ` [PATCH net-next v3 13/14] net: phy: add Broadcom BCM84881 PHY driver Russell King
2019-12-11 10:57 ` [PATCH net-next v3 14/14] net: sfp: add support for Clause 45 PHYs Russell King
2019-12-11 19:53 ` [PATCH net-next v3 00/14] Add support for SFP+ copper modules David Miller
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=E1iezfS-0002yR-Al@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=netdev@vger.kernel.org \
/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).