Loading...
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright 2006, Johannes Berg <johannes@sipsolutions.net>
4 */
5
6#include <linux/list.h>
7#include <linux/spinlock.h>
8#include <linux/leds.h>
9#include "ieee80211_i.h"
10
11#define MAC80211_BLINK_DELAY 50 /* ms */
12
13static inline void ieee80211_led_rx(struct ieee80211_local *local)
14{
15#ifdef CONFIG_MAC80211_LEDS
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
24static 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
36void ieee80211_led_assoc(struct ieee80211_local *local,
37 bool associated);
38void ieee80211_led_radio(struct ieee80211_local *local,
39 bool enabled);
40void ieee80211_alloc_led_names(struct ieee80211_local *local);
41void ieee80211_free_led_names(struct ieee80211_local *local);
42void ieee80211_led_init(struct ieee80211_local *local);
43void ieee80211_led_exit(struct ieee80211_local *local);
44void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
45 unsigned int types_on, unsigned int types_off);
46#else
47static inline void ieee80211_led_assoc(struct ieee80211_local *local,
48 bool associated)
49{
50}
51static inline void ieee80211_led_radio(struct ieee80211_local *local,
52 bool enabled)
53{
54}
55static inline void ieee80211_alloc_led_names(struct ieee80211_local *local)
56{
57}
58static inline void ieee80211_free_led_names(struct ieee80211_local *local)
59{
60}
61static inline void ieee80211_led_init(struct ieee80211_local *local)
62{
63}
64static inline void ieee80211_led_exit(struct ieee80211_local *local)
65{
66}
67static inline void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
68 unsigned int types_on,
69 unsigned int types_off)
70{
71}
72#endif
73
74static inline void
75ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, __le16 fc, int bytes)
76{
77#ifdef CONFIG_MAC80211_LEDS
78 if (ieee80211_is_data(fc) && atomic_read(&local->tpt_led_active))
79 local->tpt_led_trigger->tx_bytes += bytes;
80#endif
81}
82
83static inline void
84ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, __le16 fc, int bytes)
85{
86#ifdef CONFIG_MAC80211_LEDS
87 if (ieee80211_is_data(fc) && atomic_read(&local->tpt_led_active))
88 local->tpt_led_trigger->rx_bytes += bytes;
89#endif
90}
1/*
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
14#ifdef CONFIG_MAC80211_LEDS
15void ieee80211_led_rx(struct ieee80211_local *local);
16void ieee80211_led_tx(struct ieee80211_local *local, int q);
17void ieee80211_led_assoc(struct ieee80211_local *local,
18 bool associated);
19void ieee80211_led_radio(struct ieee80211_local *local,
20 bool enabled);
21void ieee80211_led_names(struct ieee80211_local *local);
22void ieee80211_led_init(struct ieee80211_local *local);
23void ieee80211_led_exit(struct ieee80211_local *local);
24void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
25 unsigned int types_on, unsigned int types_off);
26#else
27static inline void ieee80211_led_rx(struct ieee80211_local *local)
28{
29}
30static inline void ieee80211_led_tx(struct ieee80211_local *local, int q)
31{
32}
33static inline void ieee80211_led_assoc(struct ieee80211_local *local,
34 bool associated)
35{
36}
37static inline void ieee80211_led_radio(struct ieee80211_local *local,
38 bool enabled)
39{
40}
41static inline void ieee80211_led_names(struct ieee80211_local *local)
42{
43}
44static inline void ieee80211_led_init(struct ieee80211_local *local)
45{
46}
47static inline void ieee80211_led_exit(struct ieee80211_local *local)
48{
49}
50static inline void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
51 unsigned int types_on,
52 unsigned int types_off)
53{
54}
55#endif
56
57static inline void
58ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, __le16 fc, int bytes)
59{
60#ifdef CONFIG_MAC80211_LEDS
61 if (local->tpt_led_trigger && ieee80211_is_data(fc))
62 local->tpt_led_trigger->tx_bytes += bytes;
63#endif
64}
65
66static inline void
67ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, __le16 fc, int bytes)
68{
69#ifdef CONFIG_MAC80211_LEDS
70 if (local->tpt_led_trigger && ieee80211_is_data(fc))
71 local->tpt_led_trigger->rx_bytes += bytes;
72#endif
73}