linux icon indicating copy to clipboard operation
linux copied to clipboard

r8169: Add support for customising status LEDs via sysfs

Open ZakKemble opened this issue 3 years ago • 2 comments

CM4 router boards often use Realtek NICs for their second network interface. This change allows customising the status LEDs by writing a 16-bit hex value to the sysfs attribute /sys/class/net/INTERFACE/leds.

signed-off-by: Zak Kemble [email protected]

ZakKemble avatar Aug 16 '22 20:08 ZakKemble

Maybe someone doesn't want a bunch of blinkin' lights on their desk all day :P Tested and working on various RTL8111 NICs.

What each bit does (on a RTL8111 NIC):

0  = LED0 on when 10Mbps
1  = LED0 on when 100Mbps
2  = LED0 on when 1000Mbps
3  = LED0 blink when RX/TX activity
4  = LED1 on when 10Mbps
5  = LED1 on when 100Mbps
6  = LED1 on when 1000Mbps
7  = LED1 blink when RX/TX activity
8  = LED2 on when 10Mbps
9  = LED2 on when 100Mbps
10 = LED2 on when 1000Mbps
11 = LED2 blink when RX/TX activity
12 = LED0 invert
13 = LED1 invert
14 = LED2 invert
15 = N/A

Most NICs only have LED 0 and 2 connected.

$echo xxxx | sudo tee /sys/class/net/INTERFACE/leds

Examples:

0000:
 LED0: Off
 LED1: Off
 LED2: Off
f000:
 LED0: On
 LED1: On
 LED2: On
70c:
 LED0: On when 1000M & RX/TX blink
 LED1: Off
 LED2: On when 10/100/1000M
40f:
 LED0: RX/TX blink
 LED1: Off
 LED2: On when 1000M
1808:
 LED0: RX/TX blink (inverted)
 LED1: Off
 LED2: RX/TX blink

Similar upstream requests for this have been made before, but were rejected for reasons that don't apply to the Pi (and probably many other things) - https://bugzilla.kernel.org/show_bug.cgi?id=202447

ZakKemble avatar Aug 16 '22 20:08 ZakKemble

The patch looks reasonable - simple, and not far off the kernel coding standards - but it's not likely to be accepted. We are attempting to minimise downstream patches, and the thought of taking on a new one for an as-yet-untouched upstream file that will only benefit a small number of users is unappealing.

pelwell avatar Aug 17 '22 12:08 pelwell

It looks like upstream got user controllable LED support a few weeks ago :D https://github.com/torvalds/linux/commit/18764b883e157e28126b54e7d4ba9dd487d5bf54

ZakKemble avatar Jan 14 '24 14:01 ZakKemble

See https://github.com/raspberrypi/linux/pull/5854.

pelwell avatar Jan 16 '24 17:01 pelwell

See https://github.com/raspberrypi/linux/pull/5854.

Or don't - it doesn't build, and it's not worth fixing with an official 6.6 kernel just around the corner.

pelwell avatar Jan 16 '24 17:01 pelwell