0
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2025-05-22 06:07:54 +00:00
Files
openwrt/target/linux/generic/pending-6.12/706-net-phy-populate-host_interfaces-when-attaching-PHY.patch
Mieczyslaw Nalewaj be6753dda0 generic: 6.12: manually rebuild pending patches
Manually rebuild pending patches:
 - 103-kbuild-export-SUBARCH.patch
 - 141-jffs2-add-RENAME_EXCHANGE-support.patch
 - 200-ARM-9404-1-arm32-fix-boot-hang-with-HAVE_LD_DEAD_COD.patch
 - 203-kallsyms_uncompressed.patch
 - 270-platform-mikrotik-build-bits.patch
 - 308-mips32r2_tune.patch
 - 330-MIPS-kexec-Accept-command-line-parameters-from-users.patch
 - 402-mtd-spi-nor-write-support-for-minor-aligned-partitions.patch
 - 451-block-partitions-populate-fwnode.patch
 - 476-mtd-spi-nor-add-eon-en25q128.patch
 - 477-mtd-spi-nor-add-eon-en25qx128a.patch
 - 479-mtd-spi-nor-add-xtx-xt25f128b.patch
 - 481-mtd-spi-nor-add-support-for-Gigadevice-GD25D05.patch
 - 482-mtd-spi-nor-add-gd25q512.patch
 - 484-mtd-spi-nor-add-esmt-f25l16pa.patch
 - 485-mtd-spi-nor-add-xmc-xm25qh128c.patch
 - 488-mtd-spi-nor-add-xmc-xm25qh64c.patch
 - 490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch
 - 497-mtd-mtdconcat-add-dt-driver-for-concat-devices.patch
 - 498-mtd-spi-nor-locking-support-for-MX25L6405D.patch
 - 510-block-add-uImage.FIT-subimage-block-driver.patch
 - 530-jffs2_make_lzma_available.patch
 - 630-packet_socket_type.patch
 - 666-Add-support-for-MAP-E-FMRs-mesh-mode.patch
 - 681-net-remove-NETIF_F_GSO_FRAGLIST-from-NETIF_F_GSO_SOF.patch
 - 700-netfilter-nft_flow_offload-handle-netdevice-events-f.patch
 - 702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch
 - 706-net-phy-populate-host_interfaces-when-attaching-PHY.patch
 - 711-03-net-dsa-qca8k-add-support-for-port_change_master.patch
 - 734-net-ethernet-mediatek-enlarge-DMA-reserve-buffer.patch
 - 736-03-net-ethernet-mtk_eth_soc-improve-keeping-track-of-of.patch
 - 737-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch
 - 739-03-net-pcs-pcs-mtk-lynxi-add-platform-driver-for-MT7988.patch
 - 801-gpio-gpio-cascade-add-generic-GPIO-cascade.patch
 - 809-01-nvmem-core-generalize-mac-base-cells-handling.patch
 - 811-pci_disable_usb_common_quirks.patch
 - 834-ledtrig-libata.patch
 - 892-leds-Add-LED1202-I2C-driver.patch
 - 920-mangle_bootargs.patch

Co-authored-by: Aditya Nugraha <vortexilation@gmail.com>
Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
[ improve commit title + minor fixes ]
Link: https://github.com/openwrt/openwrt/pull/16547
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2025-04-30 16:26:31 +02:00

58 lines
2.1 KiB
Diff

From 4e432e530db0056450fbc4a3cee793f16adc39a7 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 | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -2086,7 +2086,7 @@ int phylink_fwnode_phy_connect(struct ph
{
struct fwnode_handle *phy_fwnode;
struct phy_device *phy_dev;
- int ret;
+ int i, ret;
/* Fixed links and 802.3z are handled without needing a PHY */
if (pl->cfg_link_an_mode == MLO_AN_FIXED ||
@@ -2116,6 +2116,25 @@ int phylink_fwnode_phy_connect(struct ph
if (pl->config->mac_requires_rxc)
flags |= PHY_F_RXC_ALWAYS_ON;
+ /* Assume single-lane SerDes interface modes share the same
+ * lanes and allow the PHY to switch to slower also supported modes
+ */
+ for (i = ARRAY_SIZE(phylink_sfp_interface_preference) - 1; i >= 0; i--) {
+ /* skip unsupported modes */
+ if (!test_bit(phylink_sfp_interface_preference[i], pl->config->supported_interfaces))
+ continue;
+
+ __set_bit(phylink_sfp_interface_preference[i], phy_dev->host_interfaces);
+
+ /* skip all faster modes */
+ if (phylink_sfp_interface_preference[i] == pl->link_interface)
+ break;
+ }
+
+ 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);