xref: /openbmc/linux/net/mac80211/led.h (revision e298d8a3)
1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
22c8dccc7SJohannes Berg /*
32c8dccc7SJohannes Berg  * Copyright 2006, Johannes Berg <johannes@sipsolutions.net>
42c8dccc7SJohannes Berg  */
52c8dccc7SJohannes Berg 
62c8dccc7SJohannes Berg #include <linux/list.h>
72c8dccc7SJohannes Berg #include <linux/spinlock.h>
82c8dccc7SJohannes Berg #include <linux/leds.h>
92c8dccc7SJohannes Berg #include "ieee80211_i.h"
102c8dccc7SJohannes Berg 
118d5c2585SJohannes Berg #define MAC80211_BLINK_DELAY 50 /* ms */
128d5c2585SJohannes Berg 
ieee80211_led_rx(struct ieee80211_local * local)138d5c2585SJohannes Berg static inline void ieee80211_led_rx(struct ieee80211_local *local)
148d5c2585SJohannes Berg {
152c8dccc7SJohannes Berg #ifdef CONFIG_MAC80211_LEDS
168d5c2585SJohannes Berg 	if (!atomic_read(&local->rx_led_active))
178d5c2585SJohannes Berg 		return;
18*e298d8a3SHans de Goede 	led_trigger_blink_oneshot(&local->rx_led, MAC80211_BLINK_DELAY, MAC80211_BLINK_DELAY, 0);
198d5c2585SJohannes Berg #endif
208d5c2585SJohannes Berg }
218d5c2585SJohannes Berg 
ieee80211_led_tx(struct ieee80211_local * local)228d5c2585SJohannes Berg static inline void ieee80211_led_tx(struct ieee80211_local *local)
238d5c2585SJohannes Berg {
248d5c2585SJohannes Berg #ifdef CONFIG_MAC80211_LEDS
258d5c2585SJohannes Berg 	if (!atomic_read(&local->tx_led_active))
268d5c2585SJohannes Berg 		return;
27*e298d8a3SHans de Goede 	led_trigger_blink_oneshot(&local->tx_led, MAC80211_BLINK_DELAY, MAC80211_BLINK_DELAY, 0);
288d5c2585SJohannes Berg #endif
298d5c2585SJohannes Berg }
308d5c2585SJohannes Berg 
318d5c2585SJohannes Berg #ifdef CONFIG_MAC80211_LEDS
32e1e54068SJohannes Berg void ieee80211_led_assoc(struct ieee80211_local *local,
332c8dccc7SJohannes Berg 			 bool associated);
34e1e54068SJohannes Berg void ieee80211_led_radio(struct ieee80211_local *local,
352c8dccc7SJohannes Berg 			 bool enabled);
368d5c2585SJohannes Berg void ieee80211_alloc_led_names(struct ieee80211_local *local);
378d5c2585SJohannes Berg void ieee80211_free_led_names(struct ieee80211_local *local);
38e1e54068SJohannes Berg void ieee80211_led_init(struct ieee80211_local *local);
39e1e54068SJohannes Berg void ieee80211_led_exit(struct ieee80211_local *local);
4067408c8cSJohannes Berg void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
4167408c8cSJohannes Berg 				unsigned int types_on, unsigned int types_off);
422c8dccc7SJohannes Berg #else
ieee80211_led_assoc(struct ieee80211_local * local,bool associated)432c8dccc7SJohannes Berg static inline void ieee80211_led_assoc(struct ieee80211_local *local,
442c8dccc7SJohannes Berg 				       bool associated)
452c8dccc7SJohannes Berg {
462c8dccc7SJohannes Berg }
ieee80211_led_radio(struct ieee80211_local * local,bool enabled)472c8dccc7SJohannes Berg static inline void ieee80211_led_radio(struct ieee80211_local *local,
482c8dccc7SJohannes Berg 				       bool enabled)
492c8dccc7SJohannes Berg {
502c8dccc7SJohannes Berg }
ieee80211_alloc_led_names(struct ieee80211_local * local)518d5c2585SJohannes Berg static inline void ieee80211_alloc_led_names(struct ieee80211_local *local)
528d5c2585SJohannes Berg {
538d5c2585SJohannes Berg }
ieee80211_free_led_names(struct ieee80211_local * local)548d5c2585SJohannes Berg static inline void ieee80211_free_led_names(struct ieee80211_local *local)
55fe67c913SJohannes Berg {
56fe67c913SJohannes Berg }
ieee80211_led_init(struct ieee80211_local * local)572c8dccc7SJohannes Berg static inline void ieee80211_led_init(struct ieee80211_local *local)
582c8dccc7SJohannes Berg {
592c8dccc7SJohannes Berg }
ieee80211_led_exit(struct ieee80211_local * local)602c8dccc7SJohannes Berg static inline void ieee80211_led_exit(struct ieee80211_local *local)
612c8dccc7SJohannes Berg {
622c8dccc7SJohannes Berg }
ieee80211_mod_tpt_led_trig(struct ieee80211_local * local,unsigned int types_on,unsigned int types_off)6367408c8cSJohannes Berg static inline void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
6467408c8cSJohannes Berg 					      unsigned int types_on,
6567408c8cSJohannes Berg 					      unsigned int types_off)
66e1e54068SJohannes Berg {
67e1e54068SJohannes Berg }
682c8dccc7SJohannes Berg #endif
69e1e54068SJohannes Berg 
70e1e54068SJohannes Berg static inline void
ieee80211_tpt_led_trig_tx(struct ieee80211_local * local,int bytes)7130f6cf96SFelix Fietkau ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, int bytes)
72e1e54068SJohannes Berg {
73e1e54068SJohannes Berg #ifdef CONFIG_MAC80211_LEDS
7430f6cf96SFelix Fietkau 	if (atomic_read(&local->tpt_led_active))
75e1e54068SJohannes Berg 		local->tpt_led_trigger->tx_bytes += bytes;
76e1e54068SJohannes Berg #endif
77e1e54068SJohannes Berg }
78e1e54068SJohannes Berg 
79e1e54068SJohannes Berg static inline void
ieee80211_tpt_led_trig_rx(struct ieee80211_local * local,int bytes)8030f6cf96SFelix Fietkau ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, int bytes)
81e1e54068SJohannes Berg {
82e1e54068SJohannes Berg #ifdef CONFIG_MAC80211_LEDS
8330f6cf96SFelix Fietkau 	if (atomic_read(&local->tpt_led_active))
84e1e54068SJohannes Berg 		local->tpt_led_trigger->rx_bytes += bytes;
85e1e54068SJohannes Berg #endif
86e1e54068SJohannes Berg }
87