On Thu, Apr 10, 2025 at 09:40:58AM +0200, Wolfram Sang wrote: > > > You should then find that you gain an LED directory per LED in sysfs, > > trigger has [netdev] and there are additional files you can use to > > configure when the LED lights/blinks for different link speeds, RX and > > TX etc. > > Again thanks for the pointer, yet I get weird results. After booting, > with the interface up: > > === > # cd /sys/class/leds/stmmac-0:08:green:lan/ > # ls -l > total 0 > -rw-r--r-- 1 root root 4096 May 5 10:13 brightness > lrwxrwxrwx 1 root root 0 May 5 10:13 device -> ../../../stmmac-0:08 > -rw-r--r-- 1 root root 4096 May 5 10:13 device_name > -rw-r--r-- 1 root root 4096 May 5 10:13 full_duplex > -rw-r--r-- 1 root root 4096 May 5 10:13 half_duplex > -rw-r--r-- 1 root root 4096 May 5 10:13 interval > -rw-r--r-- 1 root root 4096 May 5 10:13 link > -r--r--r-- 1 root root 4096 May 5 10:13 max_brightness > -r--r--r-- 1 root root 4096 May 5 10:13 offloaded > drwxr-xr-x 2 root root 0 May 5 10:13 power > -rw-r--r-- 1 root root 4096 May 5 10:13 rx > -rw-r--r-- 1 root root 4096 May 5 10:13 rx_err > lrwxrwxrwx 1 root root 0 May 5 10:13 subsystem -> ../../../../../../../../../class/leds > -rw-r--r-- 1 root root 0 May 5 10:13 trigger > -rw-r--r-- 1 root root 4096 May 5 10:13 tx > -rw-r--r-- 1 root root 4096 May 5 10:13 tx_err > -rw-r--r-- 1 root root 4096 May 5 10:13 uevent > # cat trigger device_name offloaded > none kbd-scrolllock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock [netdev] mmc0 > > 0 > === > > This shows that 'netdev' trigger is selected, alas the device name is > empty and offloading is disabled despite the driver using those > callbacks. The only thing that works is setting 'brightness' manually. There is a weak relationship between the MAC, in this case, stmmac, and the PHY. They get created at different times, and have different life cycles. The LEDs get created when the PHY is probed. This is generally before the MAC is created. At that point, you can use the LED as just another LED. However, due to the default trigger, the netdev trigger will be assigned to the LED. But at this stage it is useless. Sometime later the MAC will get created. Generally, at this point, the MAC and PHY are still not linked together. When you open the device, i.e. configure it admin up, then the MAC driver goes and finds its PHY and connects to it. It is only at this point can the LED get the MAC device name, know what speeds are supported etc, which is the subset of what the MAC and PHY support etc. > If I now select the 'netdev' trigger _again_, things change: That was how the code was initially developed, and the most tested scenario. Using DT to set the trigger came a lot later. Due to the weak link between the MAC and the PHY, the LED trigger firsts asks the PHY what MAC are you connected to when the trigger is activated. This can return indicating it is not connected, and this is likely with DT configuration. The trigger also links into the netdev notifier chain. It gets called when the MAC registers, changes its name, unregisters, or is configured up. The admin up notifier is the one which normally links the LED to the MAC. So if you have time to debug this further, i would start from netdev_trig_notify(). > The 'link_*' files appeared, 'device_name' and 'offloaded' have the > expected values. But now the LED is blinking like crazy despite all the > rx/tx/whatnot triggers still set to 0. So that is odd. If offloaded indicates the hardware is doing the blinking, that means we have a problem with the PHY configuration. What model of Marvell PHY is it? There are some differences between the models. Andrew