From: Russell King <rmk+kernel@armlinux.org.uk>
Date: Fri, 1 Dec 2017 10:24:21 +0000
Subject: phylink: merge SGMII and 802.3z handling
Patch-mainline: v4.16-rc1
Git-commit: cf4f267534e29c53cfdd92d8811168d5d34af80f
References: bsc#1119113 FATE#326472
The code handling SGMII and 802.3z is essentially the same, except that
we assume 802.3z has no PHY. Re-organise the code such that these cases
are merged, and exclude 802.3z mode from having a PHY attached. This
results in the same link handling behaviour as before.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
drivers/net/phy/phylink.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -423,6 +423,7 @@ static void phylink_resolve(struct work_
break;
case MLO_AN_SGMII:
+ case MLO_AN_8023Z:
phylink_get_mac_state(pl, &link_state);
if (pl->phydev) {
bool changed = false;
@@ -448,10 +449,6 @@ static void phylink_resolve(struct work_
}
}
break;
-
- case MLO_AN_8023Z:
- phylink_get_mac_state(pl, &link_state);
- break;
}
}
@@ -657,6 +654,10 @@ int phylink_connect_phy(struct phylink *
{
int ret;
+ if (WARN_ON(pl->link_an_mode == MLO_AN_FIXED ||
+ pl->link_an_mode == MLO_AN_8023Z))
+ return -EINVAL;
+
ret = phy_attach_direct(pl->netdev, phy, 0, pl->link_interface);
if (ret)
return ret;
@@ -675,8 +676,9 @@ int phylink_of_phy_connect(struct phylin
struct phy_device *phy_dev;
int ret;
- /* Fixed links are handled without needing a PHY */
- if (pl->link_an_mode == MLO_AN_FIXED)
+ /* Fixed links and 802.3z are handled without needing a PHY */
+ if (pl->link_an_mode == MLO_AN_FIXED ||
+ pl->link_an_mode == MLO_AN_8023Z)
return 0;
phy_node = of_parse_phandle(dn, "phy-handle", 0);
@@ -851,13 +853,13 @@ int phylink_ethtool_ksettings_get(struct
break;
case MLO_AN_SGMII:
+ case MLO_AN_8023Z:
/* If there is a phy attached, then use the reported
* settings from the phy with no modification.
*/
if (pl->phydev)
break;
- case MLO_AN_8023Z:
phylink_get_mac_state(pl, &link_state);
/* The MAC is reporting the link results from its own PCS