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