leds: add "network" LED trigger (lan/wan/wlan)

LED trigger for network interfaces.

 - Aggregated per-family (lan/wan/wlan).
 - Family and flags are taken from device tree properties:
   - "family" : simple family string "lan" | "wan" | "wlan"
   - "mode"   : any combination of "link", "tx", "rx" flags
  Priority/combination:
   * If "mode" present: flags come from "mode" and take precedence.
     Family is taken from "family" if present, otherwise from the LED name.
   * If only "family" present: use its family and default flags = link+tx+rx.
   * If neither present: fall back to LED device name parsing.

 - Suffix "-online" is valid ONLY in the LED name (label),
   e.g. "green:wlan-online". It indicates the online variant but is applied
   only when DT "mode" is absent.

Behaviour:
 - wlan (normal): blink/solid driven by throughput table
 - lan/wan (normal): one-shot blink on TX/RX packet change
 - *-online variants: steady ON while any interface of the family has carrier

 Interfaces are auto-tracked by name match (lan0, wan1, wlan2, phy0, wl1,
 ath0, ra0...). Up to MAX_IFACES (16) interfaces per family

This trigger is intended for board/device authors and drivers to provide simple
network-activity LED behaviour without per-interface wiring in userspace.

Refresh bcm27xx patches in the same commit to account for line shifts in
drivers/leds/trigger/Kconfig and Makefile, ensuring clean applies for
bisectability.

Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Link: https://github.com/openwrt/openwrt/pull/19903
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
Mieczyslaw Nalewaj
2025-11-27 13:17:50 +01:00
committed by Robert Marko
parent 848c54b5f4
commit 2aa1185fb0
7 changed files with 1286 additions and 3 deletions
+16
View File
@@ -70,6 +70,22 @@ endef
$(eval $(call KernelPackage,ledtrig-gpio))
define KernelPackage/ledtrig-network
SUBMENU:=$(LEDS_MENU)
TITLE:=LED Network Trigger
KCONFIG:=CONFIG_LEDS_TRIGGER_NETWORK
FILES:=$(LED_TRIGGER_DIR)/ledtrig-network.ko
AUTOLOAD:=$(call AutoLoad,50,ledtrig-network)
endef
define KernelPackage/ledtrig-network/description
Kernel module that allows LEDs to be controlled by network interfaces
aggregated by family (lan/wan/wlan), with an optional per-LED '-online' mode.
endef
$(eval $(call KernelPackage,ledtrig-network))
define KernelPackage/ledtrig-transient
SUBMENU:=$(LEDS_MENU)
TITLE:=LED Transient Trigger
@@ -17,7 +17,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.com>
--- a/drivers/leds/trigger/Kconfig
+++ b/drivers/leds/trigger/Kconfig
@@ -168,4 +168,15 @@ config LEDS_TRIGGER_INPUT_EVENTS
@@ -177,4 +177,15 @@ config LEDS_TRIGGER_INPUT_EVENTS
When build as a module this driver will be called ledtrig-input-events.
@@ -35,10 +35,10 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.com>
endif # LEDS_TRIGGERS
--- a/drivers/leds/trigger/Makefile
+++ b/drivers/leds/trigger/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += led
obj-$(CONFIG_LEDS_TRIGGER_PATTERN) += ledtrig-pattern.o
@@ -18,3 +18,4 @@ obj-$(CONFIG_LEDS_TRIGGER_PATTERN) += le
obj-$(CONFIG_LEDS_TRIGGER_TTY) += ledtrig-tty.o
obj-$(CONFIG_LEDS_TRIGGER_INPUT_EVENTS) += ledtrig-input-events.o
obj-$(CONFIG_LEDS_TRIGGER_NETWORK) += ledtrig-network.o
+obj-$(CONFIG_LEDS_TRIGGER_ACTPWR) += ledtrig-actpwr.o
--- /dev/null
+++ b/drivers/leds/trigger/ledtrig-actpwr.c
+1
View File
@@ -3216,6 +3216,7 @@ CONFIG_LEDS_TRIGGER_HEARTBEAT=y
# CONFIG_LEDS_TRIGGER_INPUT_EVENTS is not set
# CONFIG_LEDS_TRIGGER_MTD is not set
CONFIG_LEDS_TRIGGER_NETDEV=y
# CONFIG_LEDS_TRIGGER_NETWORK is not set
# CONFIG_LEDS_TRIGGER_ONESHOT is not set
# CONFIG_LEDS_TRIGGER_PANIC is not set
# CONFIG_LEDS_TRIGGER_PATTERN is not set
+1
View File
@@ -3343,6 +3343,7 @@ CONFIG_LEDS_TRIGGER_HEARTBEAT=y
# CONFIG_LEDS_TRIGGER_INPUT_EVENTS is not set
# CONFIG_LEDS_TRIGGER_MTD is not set
CONFIG_LEDS_TRIGGER_NETDEV=y
# CONFIG_LEDS_TRIGGER_NETWORK is not set
# CONFIG_LEDS_TRIGGER_ONESHOT is not set
# CONFIG_LEDS_TRIGGER_PANIC is not set
# CONFIG_LEDS_TRIGGER_PATTERN is not set
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,58 @@
From: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Date: Thu, 27 Nov 2025 13:17:50 +0100
Subject: leds: add "network" LED trigger (lan/wan/wlan)
LED trigger for network interfaces.
- Aggregated per-family (lan/wan/wlan).
- Family and flags are taken from device tree properties:
- "family" : simple family string "lan" | "wan" | "wlan"
- "mode" : any combination of "link", "tx", "rx" flags
Priority/combination:
* If "mode" present: flags come from "mode" and take precedence.
Family is taken from "family" if present, otherwise from the LED name.
* If only "family" present: use its family and default flags = link+tx+rx.
* If neither present: fall back to LED device name parsing.
- Suffix "-online" is valid ONLY in the LED name (label),
e.g. "green:wlan-online". It indicates the online variant but is applied
only when DT "mode" is absent.
Behaviour:
- wlan (normal): blink/solid driven by throughput table
- lan/wan (normal): one-shot blink on TX/RX packet change
- *-online variants: steady ON while any interface of the family has carrier
Interfaces are auto-tracked by name match (lan0, wan1, wlan2, phy0, wl1,
ath0, ra0...). Up to MAX_IFACES (16) interfaces per family
This trigger is intended for board/device authors and drivers to provide simple
network-activity LED behaviour without per-interface wiring in userspace.
Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
---
--- a/drivers/leds/trigger/Kconfig
+++ b/drivers/leds/trigger/Kconfig
@@ -129,6 +129,15 @@ config LEDS_TRIGGER_NETDEV
This allows LEDs to be controlled by network device activity.
If unsure, say Y.
+config LEDS_TRIGGER_NETWORK
+ tristate "LED trigger for network interfaces"
+ depends on NET
+ help
+ Per-family network LED trigger: aggregates lan/wan/wlan stats;
+ family from DT 'family' or name; flags from DT 'mode';
+ '-online' - online-only if mode absent.
+ If unsure, say Y.
+
config LEDS_TRIGGER_PATTERN
tristate "LED Pattern Trigger"
help
--- a/drivers/leds/trigger/Makefile
+++ b/drivers/leds/trigger/Makefile
@@ -16,3 +16,4 @@ obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += led
obj-$(CONFIG_LEDS_TRIGGER_PATTERN) += ledtrig-pattern.o
obj-$(CONFIG_LEDS_TRIGGER_TTY) += ledtrig-tty.o
obj-$(CONFIG_LEDS_TRIGGER_INPUT_EVENTS) += ledtrig-input-events.o
+obj-$(CONFIG_LEDS_TRIGGER_NETWORK) += ledtrig-network.o
@@ -0,0 +1,58 @@
From: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Date: Thu, 27 Nov 2025 13:17:50 +0100
Subject: leds: add "network" LED trigger (lan/wan/wlan)
LED trigger for network interfaces.
- Aggregated per-family (lan/wan/wlan).
- Family and flags are taken from device tree properties:
- "family" : simple family string "lan" | "wan" | "wlan"
- "mode" : any combination of "link", "tx", "rx" flags
Priority/combination:
* If "mode" present: flags come from "mode" and take precedence.
Family is taken from "family" if present, otherwise from the LED name.
* If only "family" present: use its family and default flags = link+tx+rx.
* If neither present: fall back to LED device name parsing.
- Suffix "-online" is valid ONLY in the LED name (label),
e.g. "green:wlan-online". It indicates the online variant but is applied
only when DT "mode" is absent.
Behaviour:
- wlan (normal): blink/solid driven by throughput table
- lan/wan (normal): one-shot blink on TX/RX packet change
- *-online variants: steady ON while any interface of the family has carrier
Interfaces are auto-tracked by name match (lan0, wan1, wlan2, phy0, wl1,
ath0, ra0...). Up to MAX_IFACES (16) interfaces per family
This trigger is intended for board/device authors and drivers to provide simple
network-activity LED behaviour without per-interface wiring in userspace.
Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
---
--- a/drivers/leds/trigger/Kconfig
+++ b/drivers/leds/trigger/Kconfig
@@ -129,6 +129,15 @@ config LEDS_TRIGGER_NETDEV
This allows LEDs to be controlled by network device activity.
If unsure, say Y.
+config LEDS_TRIGGER_NETWORK
+ tristate "LED trigger for network interfaces"
+ depends on NET
+ help
+ Per-family network LED trigger: aggregates lan/wan/wlan stats;
+ family from DT 'family' or name; flags from DT 'mode';
+ '-online' - online-only if mode absent.
+ If unsure, say Y.
+
config LEDS_TRIGGER_PATTERN
tristate "LED Pattern Trigger"
help
--- a/drivers/leds/trigger/Makefile
+++ b/drivers/leds/trigger/Makefile
@@ -16,3 +16,4 @@ obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += led
obj-$(CONFIG_LEDS_TRIGGER_PATTERN) += ledtrig-pattern.o
obj-$(CONFIG_LEDS_TRIGGER_TTY) += ledtrig-tty.o
obj-$(CONFIG_LEDS_TRIGGER_INPUT_EVENTS) += ledtrig-input-events.o
+obj-$(CONFIG_LEDS_TRIGGER_NETWORK) += ledtrig-network.o