summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2020-08-16 09:32:18 +0100
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2021-06-07 11:26:49 +0100
commit9aac19b6c38f3813d6f22ad21764afff3a60651f (patch)
tree2dbec57d1ace214e462b63a2a5a2897e26dbe90f
parent70c8ff56460967a4a814fc2dae17cf43e32170af (diff)
net: phy: pass supported PHY interface types to phylib
Pass the supported PHY interface types to phylib so that PHY drivers can select an appropriate host configuration mode for their interface according to the host capabilities. This is only done for SFP modules presently. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
-rw-r--r--drivers/net/phy/phylink.c18
-rw-r--r--include/linux/phy.h3
2 files changed, 21 insertions, 0 deletions
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 18541d9c9ed3..d6b877df4730 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -2022,6 +2022,8 @@ static void phylink_sfp_detach(void *upstream, struct sfp_bus *bus)
pl->netdev->sfp_bus = NULL;
}
+static DECLARE_PHY_INTERFACE_MASK(phylink_sfp_interfaces);
+
static const phy_interface_t phylink_sfp_interface_preference[] = {
PHY_INTERFACE_MODE_USXGMII,
PHY_INTERFACE_MODE_10GBASER,
@@ -2245,6 +2247,10 @@ static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy)
else
mode = MLO_AN_INBAND;
+ /* Set the PHY's host supported interfaces */
+ phy_interface_and(phy->host_interfaces, phylink_sfp_interfaces,
+ pl->config->supported_interfaces);
+
/* Do the initial configuration */
ret = phylink_sfp_config(pl, mode, phy->supported, phy->advertising);
if (ret < 0)
@@ -2628,4 +2634,16 @@ void phylink_mii_c45_pcs_get_state(struct mdio_device *pcs,
}
EXPORT_SYMBOL_GPL(phylink_mii_c45_pcs_get_state);
+static int __init phylink_init(void)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(phylink_sfp_interface_preference); i++)
+ set_bit(phylink_sfp_interface_preference[i],
+ phylink_sfp_interfaces);
+
+ return 0;
+}
+module_init(phylink_init);
+
MODULE_LICENSE("GPL v2");
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 26a263dd060a..19bdcf8bdce3 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -612,6 +612,9 @@ struct phy_device {
/* used with phy_speed_down */
__ETHTOOL_DECLARE_LINK_MODE_MASK(adv_old);
+ /* supported PHY interface types */
+ DECLARE_PHY_INTERFACE_MASK(host_interfaces);
+
/* Energy efficient ethernet modes which should be prohibited */
u32 eee_broken_modes;