Add 2.5G, 5G and 10G as available speeds to the netdev LED trigger.
Signed-off-by: Daniel Golle <[email protected]>
---
drivers/leds/trigger/ledtrig-netdev.c | 29 ++++++++++++++++++++++++++-
include/linux/leds.h | 3 +++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
index e358e77e4b38f..612f214cd4f3c 100644
--- a/drivers/leds/trigger/ledtrig-netdev.c
+++ b/drivers/leds/trigger/ledtrig-netdev.c
@@ -99,6 +99,18 @@ static void set_baseline_state(struct led_netdev_data *trigger_data)
trigger_data->link_speed == SPEED_1000)
blink_on = true;
+ if (test_bit(TRIGGER_NETDEV_LINK_2500, &trigger_data->mode) &&
+ trigger_data->link_speed == SPEED_2500)
+ blink_on = true;
+
+ if (test_bit(TRIGGER_NETDEV_LINK_5000, &trigger_data->mode) &&
+ trigger_data->link_speed == SPEED_5000)
+ blink_on = true;
+
+ if (test_bit(TRIGGER_NETDEV_LINK_10000, &trigger_data->mode) &&
+ trigger_data->link_speed == SPEED_10000)
+ blink_on = true;
+
if (test_bit(TRIGGER_NETDEV_HALF_DUPLEX, &trigger_data->mode) &&
trigger_data->duplex == DUPLEX_HALF)
blink_on = true;
@@ -286,6 +298,9 @@ static ssize_t netdev_led_attr_show(struct device *dev, char *buf,
case TRIGGER_NETDEV_LINK_10:
case TRIGGER_NETDEV_LINK_100:
case TRIGGER_NETDEV_LINK_1000:
+ case TRIGGER_NETDEV_LINK_2500:
+ case TRIGGER_NETDEV_LINK_5000:
+ case TRIGGER_NETDEV_LINK_10000:
case TRIGGER_NETDEV_HALF_DUPLEX:
case TRIGGER_NETDEV_FULL_DUPLEX:
case TRIGGER_NETDEV_TX:
@@ -316,6 +331,9 @@ static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,
case TRIGGER_NETDEV_LINK_10:
case TRIGGER_NETDEV_LINK_100:
case TRIGGER_NETDEV_LINK_1000:
+ case TRIGGER_NETDEV_LINK_2500:
+ case TRIGGER_NETDEV_LINK_5000:
+ case TRIGGER_NETDEV_LINK_10000:
case TRIGGER_NETDEV_HALF_DUPLEX:
case TRIGGER_NETDEV_FULL_DUPLEX:
case TRIGGER_NETDEV_TX:
@@ -334,7 +352,10 @@ static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,
if (test_bit(TRIGGER_NETDEV_LINK, &mode) &&
(test_bit(TRIGGER_NETDEV_LINK_10, &mode) ||
test_bit(TRIGGER_NETDEV_LINK_100, &mode) ||
- test_bit(TRIGGER_NETDEV_LINK_1000, &mode)))
+ test_bit(TRIGGER_NETDEV_LINK_1000, &mode) ||
+ test_bit(TRIGGER_NETDEV_LINK_2500, &mode) ||
+ test_bit(TRIGGER_NETDEV_LINK_5000, &mode) ||
+ test_bit(TRIGGER_NETDEV_LINK_10000, &mode)))
return -EINVAL;
cancel_delayed_work_sync(&trigger_data->work);
@@ -364,6 +385,9 @@ DEFINE_NETDEV_TRIGGER(link, TRIGGER_NETDEV_LINK);
DEFINE_NETDEV_TRIGGER(link_10, TRIGGER_NETDEV_LINK_10);
DEFINE_NETDEV_TRIGGER(link_100, TRIGGER_NETDEV_LINK_100);
DEFINE_NETDEV_TRIGGER(link_1000, TRIGGER_NETDEV_LINK_1000);
+DEFINE_NETDEV_TRIGGER(link_2500, TRIGGER_NETDEV_LINK_2500);
+DEFINE_NETDEV_TRIGGER(link_5000, TRIGGER_NETDEV_LINK_5000);
+DEFINE_NETDEV_TRIGGER(link_10000, TRIGGER_NETDEV_LINK_10000);
DEFINE_NETDEV_TRIGGER(half_duplex, TRIGGER_NETDEV_HALF_DUPLEX);
DEFINE_NETDEV_TRIGGER(full_duplex, TRIGGER_NETDEV_FULL_DUPLEX);
DEFINE_NETDEV_TRIGGER(tx, TRIGGER_NETDEV_TX);
@@ -519,6 +543,9 @@ static void netdev_trig_work(struct work_struct *work)
test_bit(TRIGGER_NETDEV_LINK_10, &trigger_data->mode) ||
test_bit(TRIGGER_NETDEV_LINK_100, &trigger_data->mode) ||
test_bit(TRIGGER_NETDEV_LINK_1000, &trigger_data->mode) ||
+ test_bit(TRIGGER_NETDEV_LINK_2500, &trigger_data->mode) ||
+ test_bit(TRIGGER_NETDEV_LINK_5000, &trigger_data->mode) ||
+ test_bit(TRIGGER_NETDEV_LINK_10000, &trigger_data->mode) ||
test_bit(TRIGGER_NETDEV_HALF_DUPLEX, &trigger_data->mode) ||
test_bit(TRIGGER_NETDEV_FULL_DUPLEX, &trigger_data->mode);
interval = jiffies_to_msecs(
diff --git a/include/linux/leds.h b/include/linux/leds.h
index aa16dc2a8230f..1bdf7f5a0d7c0 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -588,6 +588,9 @@ enum led_trigger_netdev_modes {
TRIGGER_NETDEV_LINK_10,
TRIGGER_NETDEV_LINK_100,
TRIGGER_NETDEV_LINK_1000,
+ TRIGGER_NETDEV_LINK_2500,
+ TRIGGER_NETDEV_LINK_5000,
+ TRIGGER_NETDEV_LINK_10000,
TRIGGER_NETDEV_HALF_DUPLEX,
TRIGGER_NETDEV_FULL_DUPLEX,
TRIGGER_NETDEV_TX,
--
2.43.0
On Sun, Nov 26, 2023 at 08:17:03PM +0000, Daniel Golle wrote:
> Add 2.5G, 5G and 10G as available speeds to the netdev LED trigger.
>
> Signed-off-by: Daniel Golle <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
One thing to consider is how this get merged. I assume you will have a
PHY driver patch soon making use of this? We can either:
1) Get Lee to merge it into the LED tree and then create a stable
branch which gets pulled into netdev.
2) Merge into netdev, with Lees Acked-by:
It seems unlikely there will be any merge conflicts. So netdev does
seem like an O.K. way to go.
Andrew
Hi Andrew,
On Sun, Nov 26, 2023 at 10:04:22PM +0100, Andrew Lunn wrote:
> On Sun, Nov 26, 2023 at 08:17:03PM +0000, Daniel Golle wrote:
> > Add 2.5G, 5G and 10G as available speeds to the netdev LED trigger.
> >
> > Signed-off-by: Daniel Golle <[email protected]>
>
> Reviewed-by: Andrew Lunn <[email protected]>
>
> One thing to consider is how this get merged. I assume you will have a
> PHY driver patch soon making use of this?
Yes, exactly. I'm working on adding support for LEDs to MaxLinear and
RealTek PHY drivers.
> We can either:
>
> 1) Get Lee to merge it into the LED tree and then create a stable
> branch which gets pulled into netdev.
>
> 2) Merge into netdev, with Lees Acked-by:
>
> It seems unlikely there will be any merge conflicts. So netdev does
> seem like an O.K. way to go.
Via netdev (net-next) would be better imho as it would allow to add
changes to PHY drivers making use of the new constants without having
to wait for LED tree being merged.
Note that I've sent v2 which adds missing use of sysfs attributes.
Thank you!
Daniel
On Sun, 26 Nov 2023, Daniel Golle wrote:
> Hi Andrew,
>
> On Sun, Nov 26, 2023 at 10:04:22PM +0100, Andrew Lunn wrote:
> > On Sun, Nov 26, 2023 at 08:17:03PM +0000, Daniel Golle wrote:
> > > Add 2.5G, 5G and 10G as available speeds to the netdev LED trigger.
> > >
> > > Signed-off-by: Daniel Golle <[email protected]>
> >
> > Reviewed-by: Andrew Lunn <[email protected]>
> >
> > One thing to consider is how this get merged. I assume you will have a
> > PHY driver patch soon making use of this?
>
> Yes, exactly. I'm working on adding support for LEDs to MaxLinear and
> RealTek PHY drivers.
>
> > We can either:
> >
> > 1) Get Lee to merge it into the LED tree and then create a stable
> > branch which gets pulled into netdev.
I'll create an immutable branch.
> > 2) Merge into netdev, with Lees Acked-by:
> >
> > It seems unlikely there will be any merge conflicts. So netdev does
> > seem like an O.K. way to go.
>
> Via netdev (net-next) would be better imho as it would allow to add
> changes to PHY drivers making use of the new constants without having
> to wait for LED tree being merged.
The former solution does not prevent this.
> Note that I've sent v2 which adds missing use of sysfs attributes.
--
Lee Jones [李琼斯]