blob: a7893a1ac98bd1f0addfd1138fb289bd8663ef51 [file] [log] [blame]
Jiri Bencf0706e82007-05-05 11:45:53 -07001/*
2 * Copyright 2006, Johannes Berg <johannes@sipsolutions.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/list.h>
10#include <linux/spinlock.h>
11#include <linux/leds.h>
12#include "ieee80211_i.h"
13
Johannes Berg8d5c2582015-04-23 12:19:22 +020014#define MAC80211_BLINK_DELAY 50 /* ms */
15
16static inline void ieee80211_led_rx(struct ieee80211_local *local)
17{
Jiri Bencf0706e82007-05-05 11:45:53 -070018#ifdef CONFIG_MAC80211_LEDS
Johannes Berg8d5c2582015-04-23 12:19:22 +020019 unsigned long led_delay = MAC80211_BLINK_DELAY;
20
21 if (!atomic_read(&local->rx_led_active))
22 return;
23 led_trigger_blink_oneshot(&local->rx_led, &led_delay, &led_delay, 0);
24#endif
25}
26
27static inline void ieee80211_led_tx(struct ieee80211_local *local)
28{
29#ifdef CONFIG_MAC80211_LEDS
30 unsigned long led_delay = MAC80211_BLINK_DELAY;
31
32 if (!atomic_read(&local->tx_led_active))
33 return;
34 led_trigger_blink_oneshot(&local->tx_led, &led_delay, &led_delay, 0);
35#endif
36}
37
38#ifdef CONFIG_MAC80211_LEDS
Johannes Berge1e54062010-11-30 08:58:45 +010039void ieee80211_led_assoc(struct ieee80211_local *local,
40 bool associated);
41void ieee80211_led_radio(struct ieee80211_local *local,
42 bool enabled);
Johannes Berg8d5c2582015-04-23 12:19:22 +020043void ieee80211_alloc_led_names(struct ieee80211_local *local);
44void ieee80211_free_led_names(struct ieee80211_local *local);
Johannes Berge1e54062010-11-30 08:58:45 +010045void ieee80211_led_init(struct ieee80211_local *local);
46void ieee80211_led_exit(struct ieee80211_local *local);
Johannes Berg67408c82010-11-30 08:59:23 +010047void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
48 unsigned int types_on, unsigned int types_off);
Jiri Bencf0706e82007-05-05 11:45:53 -070049#else
Michael Buesch47f0c502007-09-27 15:10:44 +020050static inline void ieee80211_led_assoc(struct ieee80211_local *local,
51 bool associated)
52{
53}
Ivo van Doorncdcb0062008-01-07 19:45:24 +010054static inline void ieee80211_led_radio(struct ieee80211_local *local,
55 bool enabled)
56{
57}
Johannes Berg8d5c2582015-04-23 12:19:22 +020058static inline void ieee80211_alloc_led_names(struct ieee80211_local *local)
59{
60}
61static inline void ieee80211_free_led_names(struct ieee80211_local *local)
Johannes Bergfe67c912010-11-27 20:02:59 +010062{
63}
Jiri Bencf0706e82007-05-05 11:45:53 -070064static inline void ieee80211_led_init(struct ieee80211_local *local)
65{
66}
67static inline void ieee80211_led_exit(struct ieee80211_local *local)
68{
69}
Johannes Berg67408c82010-11-30 08:59:23 +010070static inline void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
71 unsigned int types_on,
72 unsigned int types_off)
Johannes Berge1e54062010-11-30 08:58:45 +010073{
74}
Jiri Bencf0706e82007-05-05 11:45:53 -070075#endif
Johannes Berge1e54062010-11-30 08:58:45 +010076
77static inline void
78ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, __le16 fc, int bytes)
79{
80#ifdef CONFIG_MAC80211_LEDS
Johannes Berg8d5c2582015-04-23 12:19:22 +020081 if (ieee80211_is_data(fc) && atomic_read(&local->tpt_led_active))
Johannes Berge1e54062010-11-30 08:58:45 +010082 local->tpt_led_trigger->tx_bytes += bytes;
83#endif
84}
85
86static inline void
87ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, __le16 fc, int bytes)
88{
89#ifdef CONFIG_MAC80211_LEDS
Johannes Berg8d5c2582015-04-23 12:19:22 +020090 if (ieee80211_is_data(fc) && atomic_read(&local->tpt_led_active))
Johannes Berge1e54062010-11-30 08:58:45 +010091 local->tpt_led_trigger->rx_bytes += bytes;
92#endif
93}