[PATCH net-next] net: phy: populate host_interfaces when attaching PHY

From: Daniel Golle
Date: Tue Oct 08 2024 - 21:57:39 EST


Use bitmask of interfaces supported by the MAC for the PHY to choose
from if the declared interface mode is among those using a single pair
of SerDes lanes.
This will allow 2500Base-T PHYs to switch to SGMII on most hosts, which
results in half-duplex being supported in case the MAC supports that.
Without this change, 2500Base-T PHYs will always operate in 2500Base-X
mode with rate-matching, which is not only wasteful in terms of energy
consumption, but also limits the supported interface modes to
full-duplex only.

Signed-off-by: Daniel Golle <daniel@xxxxxxxxxxxxxx>
---
drivers/net/phy/phylink.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 4309317de3d1..5d043c47a727 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -2111,6 +2111,13 @@ int phylink_fwnode_phy_connect(struct phylink *pl,
pl->link_config.interface = pl->link_interface;
}

+ /* Assume SerDes interface modes share the same lanes and allow
+ * the PHY to switch between the
+ */
+ if (test_bit(pl->link_interface, phylink_sfp_interfaces))
+ phy_interface_and(phy_dev->host_interfaces, phylink_sfp_interfaces,
+ pl->config->supported_interfaces);
+
if (pl->config->mac_requires_rxc)
flags |= PHY_F_RXC_ALWAYS_ON;

--
2.47.0