Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2006, Johannes Berg <johannes@sipsolutions.net> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <linux/list.h> |
| 7 | #include <linux/spinlock.h> |
| 8 | #include <linux/leds.h> |
| 9 | #include "ieee80211_i.h" |
| 10 | |
Johannes Berg | 8d5c258 | 2015-04-23 12:19:22 +0200 | [diff] [blame] | 11 | #define MAC80211_BLINK_DELAY 50 /* ms */ |
| 12 | |
| 13 | static inline void ieee80211_led_rx(struct ieee80211_local *local) |
| 14 | { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 15 | #ifdef CONFIG_MAC80211_LEDS |
Johannes Berg | 8d5c258 | 2015-04-23 12:19:22 +0200 | [diff] [blame] | 16 | unsigned long led_delay = MAC80211_BLINK_DELAY; |
| 17 | |
| 18 | if (!atomic_read(&local->rx_led_active)) |
| 19 | return; |
| 20 | led_trigger_blink_oneshot(&local->rx_led, &led_delay, &led_delay, 0); |
| 21 | #endif |
| 22 | } |
| 23 | |
| 24 | static inline void ieee80211_led_tx(struct ieee80211_local *local) |
| 25 | { |
| 26 | #ifdef CONFIG_MAC80211_LEDS |
| 27 | unsigned long led_delay = MAC80211_BLINK_DELAY; |
| 28 | |
| 29 | if (!atomic_read(&local->tx_led_active)) |
| 30 | return; |
| 31 | led_trigger_blink_oneshot(&local->tx_led, &led_delay, &led_delay, 0); |
| 32 | #endif |
| 33 | } |
| 34 | |
| 35 | #ifdef CONFIG_MAC80211_LEDS |
Johannes Berg | e1e5406 | 2010-11-30 08:58:45 +0100 | [diff] [blame] | 36 | void ieee80211_led_assoc(struct ieee80211_local *local, |
| 37 | bool associated); |
| 38 | void ieee80211_led_radio(struct ieee80211_local *local, |
| 39 | bool enabled); |
Johannes Berg | 8d5c258 | 2015-04-23 12:19:22 +0200 | [diff] [blame] | 40 | void ieee80211_alloc_led_names(struct ieee80211_local *local); |
| 41 | void ieee80211_free_led_names(struct ieee80211_local *local); |
Johannes Berg | e1e5406 | 2010-11-30 08:58:45 +0100 | [diff] [blame] | 42 | void ieee80211_led_init(struct ieee80211_local *local); |
| 43 | void ieee80211_led_exit(struct ieee80211_local *local); |
Johannes Berg | 67408c8 | 2010-11-30 08:59:23 +0100 | [diff] [blame] | 44 | void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local, |
| 45 | unsigned int types_on, unsigned int types_off); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 46 | #else |
Michael Buesch | 47f0c50 | 2007-09-27 15:10:44 +0200 | [diff] [blame] | 47 | static inline void ieee80211_led_assoc(struct ieee80211_local *local, |
| 48 | bool associated) |
| 49 | { |
| 50 | } |
Ivo van Doorn | cdcb006f | 2008-01-07 19:45:24 +0100 | [diff] [blame] | 51 | static inline void ieee80211_led_radio(struct ieee80211_local *local, |
| 52 | bool enabled) |
| 53 | { |
| 54 | } |
Johannes Berg | 8d5c258 | 2015-04-23 12:19:22 +0200 | [diff] [blame] | 55 | static inline void ieee80211_alloc_led_names(struct ieee80211_local *local) |
| 56 | { |
| 57 | } |
| 58 | static inline void ieee80211_free_led_names(struct ieee80211_local *local) |
Johannes Berg | fe67c91 | 2010-11-27 20:02:59 +0100 | [diff] [blame] | 59 | { |
| 60 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 61 | static inline void ieee80211_led_init(struct ieee80211_local *local) |
| 62 | { |
| 63 | } |
| 64 | static inline void ieee80211_led_exit(struct ieee80211_local *local) |
| 65 | { |
| 66 | } |
Johannes Berg | 67408c8 | 2010-11-30 08:59:23 +0100 | [diff] [blame] | 67 | static inline void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local, |
| 68 | unsigned int types_on, |
| 69 | unsigned int types_off) |
Johannes Berg | e1e5406 | 2010-11-30 08:58:45 +0100 | [diff] [blame] | 70 | { |
| 71 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 72 | #endif |
Johannes Berg | e1e5406 | 2010-11-30 08:58:45 +0100 | [diff] [blame] | 73 | |
| 74 | static inline void |
Felix Fietkau | 30f6cf9 | 2021-11-13 07:34:15 +0100 | [diff] [blame] | 75 | ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, int bytes) |
Johannes Berg | e1e5406 | 2010-11-30 08:58:45 +0100 | [diff] [blame] | 76 | { |
| 77 | #ifdef CONFIG_MAC80211_LEDS |
Felix Fietkau | 30f6cf9 | 2021-11-13 07:34:15 +0100 | [diff] [blame] | 78 | if (atomic_read(&local->tpt_led_active)) |
Johannes Berg | e1e5406 | 2010-11-30 08:58:45 +0100 | [diff] [blame] | 79 | local->tpt_led_trigger->tx_bytes += bytes; |
| 80 | #endif |
| 81 | } |
| 82 | |
| 83 | static inline void |
Felix Fietkau | 30f6cf9 | 2021-11-13 07:34:15 +0100 | [diff] [blame] | 84 | ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, int bytes) |
Johannes Berg | e1e5406 | 2010-11-30 08:58:45 +0100 | [diff] [blame] | 85 | { |
| 86 | #ifdef CONFIG_MAC80211_LEDS |
Felix Fietkau | 30f6cf9 | 2021-11-13 07:34:15 +0100 | [diff] [blame] | 87 | if (atomic_read(&local->tpt_led_active)) |
Johannes Berg | e1e5406 | 2010-11-30 08:58:45 +0100 | [diff] [blame] | 88 | local->tpt_led_trigger->rx_bytes += bytes; |
| 89 | #endif |
| 90 | } |