From: Daniel Golle Date: Fri, 5 Jul 2024 18:15:10 +0000 (+0100) Subject: system-linux: re-apply ethtool on phy attachment X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=68c8a4f94cd3cfd654a52cbc8b57c5c9d99640dd;p=project%2Fnetifd.git system-linux: re-apply ethtool on phy attachment ethtool settings applied before the interface is in IFF_UP state are going to be lost when phylink is being used. This is the case with many modern NICs as well as when using SFP modules, resulting in the speed, duplex, *pause and autoneg settings not having any effect. Reapply ethtool settings once the PHY is attached. Signed-off-by: Daniel Golle --- diff --git a/system-linux.c b/system-linux.c index 4463a2a..58c7373 100644 --- a/system-linux.c +++ b/system-linux.c @@ -701,6 +701,9 @@ static int system_get_arp_accept(struct device *dev, char *buf, const size_t buf #define IFF_LOWER_UP 0x10000 #endif +static void +system_set_ethtool_settings(struct device *dev, struct device_settings *s); + static void system_device_update_state(struct device *dev, unsigned int flags, unsigned int ifindex) { @@ -711,6 +714,9 @@ system_device_update_state(struct device *dev, unsigned int flags, unsigned int device_set_present(dev, ifindex > 0); } device_set_link(dev, flags & IFF_LOWER_UP ? true : false); + + if ((flags & IFF_UP) && !(flags & IFF_LOWER_UP)) + system_set_ethtool_settings(dev, &dev->settings); } /* Evaluate netlink messages */