[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230427001541.18704-1-ansuelsmth@gmail.com>
Date: Thu, 27 Apr 2023 02:15:30 +0200
From: Christian Marangi <ansuelsmth@...il.com>
To: Jonathan Corbet <corbet@....net>, Pavel Machek <pavel@....cz>,
Lee Jones <lee@...nel.org>, Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Christian Marangi <ansuelsmth@...il.com>,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-leds@...r.kernel.org, netdev@...r.kernel.org
Subject: [PATCH 00/11] leds: introduce new LED hw control APIs
This is a continue of [1]. It was decided to take a more gradual
approach to implement LEDs support for switch and phy starting with
basic support and then implementing the hw control part when we have all
the prereq done.
This is the main part of the series, the one that actually implement the
hw control API.
Some history about this feature and why
=======================================
This proposal is highly requested by the entire net community but the API
is not strictly designed for net usage but for a more generic usage.
Initial version were very flexible and designed to try to support every
aspect of the LED driver with many complex function that served multiple
purpose. There was an idea to have sw only and hw only LEDs and sw only
and hw only LEDs.
With some heads up from Andrew from the net mailing list, it was suggested
to implement a more basic yet easy to implement system.
These API strictly work with a designated trigger to offload their
function.
This may be confused with hw blink offload but LED may have an even more
advanced configuration where the entire aspect of the trigger is
offloaded and completely handled by the hardware.
An example of this usage are PHY or switch port LEDs. Almost every of
these kind of device have multiple LED attached and provide info of the
current port state.
Currently we lack any support of them but these device always provide a
way to configure them, from basic feature like turning the LED off or no
(implemented in previous series related to this feature) or even entirely
driven by the hw and power on/off/blink based on some events, like tx/rx
traffic, ethernet cable attached, link speed of 10mbps, 100mbps, 1000mbps
or more. They can also support multiple logic like blink with traffic only
if a particular link speed is attached. (an example of this is when a LED
is designated to be turned on only with 100mbps link speed and configured
to blink on traffic and a secondary LED of a different color is present to
serve the same function but only when the link speed is 1000mbps)
These case are very common for a PHY or a switch but they were never
standardized so OEM support all kind of variant and configuration.
Again with Andrew we compared some feature and we reached a common set
of modes that are for sure present in every kind of devices.
And this concludes history and why.
What is present in this series
==============================
This patch contain the required API to support this feature, I decided on
the name of hw control to quickly describe this feature.
I documented each require API in the related Documentation for leds-class
so I think it might me redundant to expose them here. Feel free to tell me
how to improve it if anything is not clear.
On an abstract idea, this feature require this:
- The trigger needs to make use of it, this is currently implemented
for the netdev trigger but other trigger can be expanded if the
device expose these function. An idea might be a anything that
handle a storage disk and have the LED configurable to blink when
there is any activity to the disk.
- The LED driver needs to expose and implement these new API.
Currently a LED driver supports only a trigger. The trigger should use
the related helper to check if the LED can be driven hy hardware.
The different modes a trigger support are exposed in the kernel include
leds.h header and are used by the LED driver to understand what to do.
The LED driver expose a mask of the different modes supported and trigger
use this to validate the modes and decide what to enable.
>From a user standpoint, he should enable modes as usual from sysfs and if
anything is not supported warned.
Final words and missing piece from this series
==============================================
I honestly hope this feature can finally be implemented.
This series originally had also additional modes and logic to add to the
netdev trigger, but I decided to strip them and implement only the API
and support basic tx and rx. After this is merged, I will quickly propose
these additional modes.
Currently this is limited to tx and rx and this is what the current user
qca8k use. Marvell PHY support link and a generic blink with any kind of
traffic (both rx and tx). qca8k switch supports keeping the LED on based on
link speed.
The next series will add the concept of hw control only modes to the netdev
trigger and support for these additional modes:
- link_10
- link_100
- link_1000
- activity
The current implementation is voluntary basic and limited to put the ground
work and have something easy to implement and usable. 99% part of the logic
is done on the trigger side, leaving to the LED driver only the validating
and the apply part.
As shown for the PHY led binding, people are really intrested in this
feature as quickly after they were merged, people were already working on
adding support for it.
[1] https://lore.kernel.org/lkml/20230216013230.22978-1-ansuelsmth@gmail.com/
Changes from previous v8 series:
- Rewrite Documentation from scratch and move to separate commit
- Strip additional trigger modes (to propose in a different series)
- Strip from qca8k driver additional modes (to implement in the different
series)
- Split the netdev chages to smaller piece to permit easier review
Changelog in the previous v8 series: (stripped of unrelated changes)
v8:
- Improve the documentation of the new feature
- Rename to a more symbolic name
- Fix some bug in netdev trigger (not using BIT())
- Add more define for qca8k-leds driver
- Drop interval support
- Fix many bugs in the validate option in the netdev trigger
v7:
- Fix qca8k leds documentation warning
- Remove RFC tag
v6:
- Back to RFC.
- Drop additional trigger
- Rework netdev trigger to support common modes used by switch and
hardware only triggers
- Refresh qca8k leds logic and driver
v5:
- Move out of RFC. (no comments from Andrew this is the right path?)
- Fix more spelling mistake (thx Randy)
- Fix error reported by kernel test bot
- Drop the additional HW_CONTROL flag. It does simplify CONFIG
handling and hw control should be available anyway to support
triggers as module.
v4:
- Rework implementation and drop hw_configure logic.
We now expand blink_set.
- Address even more spelling mistake. (thx a lot Randy)
- Drop blink option and use blink_set delay.
v3:
- Rework start/stop as Andrew asked.
- Use test_bit API to check flag passed to hw_control_configure.
- Added a new cmd to hw_control_configure to reset any active blink_mode.
- Refactor all the patches to follow this new implementation.
v2:
- Fix spelling mistake (sorry)
- Drop patch 02 "permit to declare supported offload triggers".
Change the logic, now the LED driver declare support for them
using the configure_offload with the cmd TRIGGER_SUPPORTED.
- Rework code to follow this new implementation.
- Update Documentation to better describe how this offload
implementation work.
Christian Marangi (11):
leds: add binding for LEDs hw control
leds: add binding to check support for LED hw control
leds: add helper function to use trigger in hw blink mode
Documentation: leds: leds-class: Document new Hardware driven LEDs
APIs
leds: trigger: netdev: introduce validating requested mode
leds: trigger: netdev: add knob to set hw control possible
leds: trigger: netdev: reject interval and device store for hw_control
leds: trigger: netdev: add support for LED hw control
leds: trigger: netdev: init mode if hw control already active
leds: trigger: netdev: expose netdev trigger modes in linux include
net: dsa: qca8k: implement hw_control ops
Documentation/leds/leds-class.rst | 56 +++++++++
drivers/leds/trigger/ledtrig-netdev.c | 111 +++++++++++++++---
drivers/net/dsa/qca/qca8k-leds.c | 156 ++++++++++++++++++++++++++
include/linux/leds.h | 46 ++++++++
4 files changed, 355 insertions(+), 14 deletions(-)
--
2.39.2
Powered by blists - more mailing lists