From: Robert Hancock <hancock@sedsystems.ca>
To: netdev@vger.kernel.org
Cc: linux@armlinux.org.uk, Robert Hancock <hancock@sedsystems.ca>
Subject: [PATCH net-next] net: phy: phylink: add fallback from SGMII to 1000BaseX
Date: Fri, 31 May 2019 13:18:04 -0600 [thread overview]
Message-ID: <1559330285-30246-4-git-send-email-hancock@sedsystems.ca> (raw)
In-Reply-To: <1559330285-30246-1-git-send-email-hancock@sedsystems.ca>
Some copper SFP modules support both SGMII and 1000BaseX, but some
drivers/devices only support the 1000BaseX mode. Currently SGMII mode is
always being selected as the desired mode for such modules, and this
fails if the controller doesn't support SGMII. Add a fallback for this
case by trying 1000BaseX instead if the controller rejects SGMII mode.
Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
---
drivers/net/phy/phylink.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 68d0a89..4fd72c2 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1626,6 +1626,7 @@ static int phylink_sfp_module_insert(void *upstream,
{
struct phylink *pl = upstream;
__ETHTOOL_DECLARE_LINK_MODE_MASK(support) = { 0, };
+ __ETHTOOL_DECLARE_LINK_MODE_MASK(orig_support) = { 0, };
struct phylink_link_state config;
phy_interface_t iface;
int ret = 0;
@@ -1635,6 +1636,7 @@ static int phylink_sfp_module_insert(void *upstream,
ASSERT_RTNL();
sfp_parse_support(pl->sfp_bus, id, support);
+ linkmode_copy(orig_support, support);
port = sfp_parse_port(pl->sfp_bus, id, support);
memset(&config, 0, sizeof(config));
@@ -1663,6 +1665,25 @@ static int phylink_sfp_module_insert(void *upstream,
config.interface = iface;
ret = phylink_validate(pl, support, &config);
+
+ if (ret && iface == PHY_INTERFACE_MODE_SGMII &&
+ phylink_test(orig_support, 1000baseX_Full)) {
+ /* Copper modules may select SGMII but the interface may not
+ * support that mode, try 1000BaseX if supported.
+ */
+
+ netdev_warn(pl->netdev, "validation of %s/%s with support %*pb "
+ "failed: %d, trying 1000BaseX\n",
+ phylink_an_mode_str(MLO_AN_INBAND),
+ phy_modes(config.interface),
+ __ETHTOOL_LINK_MODE_MASK_NBITS, orig_support, ret);
+ iface = PHY_INTERFACE_MODE_1000BASEX;
+ config.interface = iface;
+ linkmode_copy(config.advertising, orig_support);
+ linkmode_copy(support, orig_support);
+ ret = phylink_validate(pl, support, &config);
+ }
+
if (ret) {
phylink_err(pl, "validation of %s/%s with support %*pb failed: %d\n",
phylink_an_mode_str(MLO_AN_INBAND),
--
1.8.3.1
next prev parent reply other threads:[~2019-05-31 19:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-31 19:18 [PATCH net-next] net: sfp: Set 1000BaseX support flag for 1000BaseT modules Robert Hancock
2019-05-31 19:18 ` [PATCH net-next] net: sfp: Stop SFP polling during shutdown Robert Hancock
2019-05-31 20:12 ` Russell King - ARM Linux admin
2019-05-31 22:40 ` Robert Hancock
2019-05-31 19:18 ` [PATCH net-next] net: sfp: Use smaller chunk size when reading I2C data Robert Hancock
2019-05-31 20:13 ` Russell King - ARM Linux admin
2019-05-31 19:18 ` Robert Hancock [this message]
2019-05-31 20:18 ` [PATCH net-next] net: phy: phylink: add fallback from SGMII to 1000BaseX Russell King - ARM Linux admin
2019-06-01 0:17 ` Robert Hancock
2019-06-02 15:15 ` Russell King - ARM Linux admin
2019-06-07 18:10 ` Robert Hancock
2019-06-07 18:34 ` Russell King - ARM Linux admin
2019-06-01 9:46 ` Sergei Shtylyov
2019-05-31 19:18 ` [PATCH net-next] net: phy: phylink: support using device PHY in fixed or 802.3z mode Robert Hancock
2019-05-31 19:29 ` David Miller
2019-05-31 19:41 ` Robert Hancock
2019-05-31 19:42 ` David Miller
2019-05-31 20:31 ` Russell King - ARM Linux admin
2019-06-01 0:33 ` Robert Hancock
2019-06-01 20:10 ` Russell King - ARM Linux admin
2019-06-07 18:15 ` Robert Hancock
2019-05-31 20:11 ` [PATCH net-next] net: sfp: Set 1000BaseX support flag for 1000BaseT modules Russell King - ARM Linux admin
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=1559330285-30246-4-git-send-email-hancock@sedsystems.ca \
--to=hancock@sedsystems.ca \
--cc=linux@armlinux.org.uk \
--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).