generic: net: phy: use all SerDes MAC interface modes
authorDaniel Golle <daniel@makrotopia.org>
Tue, 8 Oct 2024 23:23:53 +0000 (00:23 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Wed, 9 Oct 2024 01:38:25 +0000 (02:38 +0100)
Instead of forcing 2.5G PHYs into rate-adapter mode which results higher
energy consumption, lack of support for half-duplex modes and typically
worse performance when linked at speeds less than 2.5G, use SGMII mode
which allows the MAC to follow the PHY speed.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
target/linux/generic/pending-6.6/706-net-phy-populate-host_interfaces-when-attaching-PHY.patch [new file with mode: 0644]

diff --git a/target/linux/generic/pending-6.6/706-net-phy-populate-host_interfaces-when-attaching-PHY.patch b/target/linux/generic/pending-6.6/706-net-phy-populate-host_interfaces-when-attaching-PHY.patch
new file mode 100644 (file)
index 0000000..bd2d015
--- /dev/null
@@ -0,0 +1,36 @@
+From 9e1a0d2006bc108b239b5bc00b42c2a8cc651217 Mon Sep 17 00:00:00 2001
+From: Daniel Golle <daniel@makrotopia.org>
+Date: Tue, 8 Oct 2024 23:58:41 +0100
+Subject: [PATCH] net: phy: populate host_interfaces when attaching PHY
+
+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 them.
+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@makrotopia.org>
+---
+ drivers/net/phy/phylink.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/drivers/net/phy/phylink.c
++++ b/drivers/net/phy/phylink.c
+@@ -2044,6 +2044,13 @@ int phylink_fwnode_phy_connect(struct ph
+               pl->link_config.interface = pl->link_interface;
+       }
++      /* Assume SerDes interface modes share the same lanes and allow
++       * the PHY to switch between them
++       */
++      if (test_bit(pl->link_interface, phylink_sfp_interfaces))
++              phy_interface_and(phy_dev->host_interfaces, phylink_sfp_interfaces,
++                                pl->config->supported_interfaces);
++
+       ret = phy_attach_direct(pl->netdev, phy_dev, flags,
+                               pl->link_interface);
+       phy_device_free(phy_dev);