[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1559330285-30246-5-git-send-email-hancock@sedsystems.ca>
Date: Fri, 31 May 2019 13:18:05 -0600
From: Robert Hancock <hancock@...systems.ca>
To: netdev@...r.kernel.org
Cc: linux@...linux.org.uk, Robert Hancock <hancock@...systems.ca>
Subject: [PATCH net-next] net: phy: phylink: support using device PHY in fixed or 802.3z mode
The Xilinx AXI Ethernet controller supports SFP modules in 1000BaseX
mode in a somewhat unusual manner: it still exposes a PHY device which
needs some PHY-level initialization for the PCS/PMA layer to work properly,
and which provides some link status/control information.
In this case, we want to use the phylink layer to support proper
communication with the SFP module, but in most other respects we want to
use the PHY attached to the controller.
Currently the phylink driver does not initialize or use a controller PHY
even if it exists for fixed-link or 802.3z PHY modes, and doesn't
support SFP module attachment in those modes. This change allows it to
utilize a controller PHY if it is defined, and allows SFP module
attachment/initialization but does not connect the PHY device to the
controller (to allow the controller PHY to be used for link state
tracking).
Fully supporting this setup would probably require initializing and
tracking the state of both PHYs, which is a much more complex change and
doesn't appear to be required for this use case.
Signed-off-by: Robert Hancock <hancock@...systems.ca>
---
drivers/net/phy/phylink.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 4fd72c2..9362aca 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -819,12 +819,6 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn,
struct phy_device *phy_dev;
int ret;
- /* 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_INBAND &&
- phy_interface_mode_is_8023z(pl->link_interface)))
- return 0;
-
phy_node = of_parse_phandle(dn, "phy-handle", 0);
if (!phy_node)
phy_node = of_parse_phandle(dn, "phy", 0);
@@ -1697,9 +1691,6 @@ static int phylink_sfp_module_insert(void *upstream,
phy_modes(config.interface),
__ETHTOOL_LINK_MODE_MASK_NBITS, support);
- if (phy_interface_mode_is_8023z(iface) && pl->phydev)
- return -EINVAL;
-
changed = !bitmap_equal(pl->supported, support,
__ETHTOOL_LINK_MODE_MASK_NBITS);
if (changed) {
@@ -1751,12 +1742,30 @@ static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy)
{
struct phylink *pl = upstream;
+ /* In fixed mode, or in in-band mode with 802.3z PHY interface mode,
+ * ignore the SFP PHY and just use the PHY attached to the MAC.
+ */
+ if (pl->link_an_mode == MLO_AN_FIXED ||
+ (pl->link_an_mode == MLO_AN_INBAND &&
+ phy_interface_mode_is_8023z(pl->link_config.interface)))
+ return 0;
+
return __phylink_connect_phy(upstream, phy, pl->link_config.interface);
}
static void phylink_sfp_disconnect_phy(void *upstream)
{
- phylink_disconnect_phy(upstream);
+ struct phylink *pl = upstream;
+
+ /* In fixed mode, or in in-band mode with 802.3z PHY interface mode,
+ * ignore the SFP PHY and just use the PHY attached to the MAC.
+ */
+ if (pl->link_an_mode == MLO_AN_FIXED ||
+ (pl->link_an_mode == MLO_AN_INBAND &&
+ phy_interface_mode_is_8023z(pl->link_config.interface)))
+ return;
+
+ phylink_disconnect_phy(pl);
}
static const struct sfp_upstream_ops sfp_phylink_ops = {
--
1.8.3.1
Powered by blists - more mailing lists