generic: swconfig: add mode led attribute
Add sysfs 'mode' attribute to swconfig controlled LEDs.
swconfig 'link state' LEDs blink in the presence of port traffic. This
behaviour becomes more obvious as switches start to support
get_port_stats() e.g. commits
0369e358916ef092a1644334f5dd1412051b68a4,
3056d09b4046e0eb0f6de0f3f5432cd9fa86fc51,
4ddbc43cc15c2fa128a2f169964ef7eb508cf2c5,
4d8a66d9346373c2a7fcac5bdae3f662a9dbd9df.
This blinking can be confusing/distracting if the switch has other LEDs
used to indicate traffic. Provide a 'mode' sysfs attribute that
controls the blink on traffic behaviour.
mode - either "none" (LED is off) or a space separated list of one or more:
link: LED's normal state reflects whether the link is up (has carrier) or not
tx: LED blinks on transmitted data
rx: LED blinks on receive data
Note that 'link' considers any port speed mask that may be applicable.
e.g. if an LED is configured to indicate 1Gbit link speed and mode is
set to 'link rx tx' but the port is connected at 100Mbit then the LED
will not light or blink. A mode of 'tx rx' will blink in the presence of
traffic only if the port matches the rate (if configured)
This maintains compatibility with existing behaviour.
Attribute is 'link tx rx' by default for backwards compatible behaviour.
Many thanks to Thibaut Varene for providing a more sensible led_event
routine after I had mangled the original, and other coding style hints.
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Acked-by: Thibaut VARENE <hacks@slashdirt.org>