blob: ba5287397c42ef403aecc81f7e3ca308c3043ff3 [file] [log] [blame]
developerf2cf4ce2023-07-13 08:38:02 +08001From 29de32dac9d97caf3e40cdae58b78a18d6277cf1 Mon Sep 17 00:00:00 2001
2From: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com>
3Date: Thu, 13 Jul 2023 08:27:37 +0800
4Subject: [PATCH] mac80211: mtk: export ieee80211_tpt_led_trig_tx/rx for driver
5
6Whenever the H/W path is enabled and traffic is in the binding state,
7mac80211 is not aware of the traffic. Consequently, the LED does not
8blink for that reason.
9
10The ieee80211_tpt_led_trig_tx/rx functions are exported for the driver
11so that we can report the tx and rx bytes from the driver when
12the H/W path is being used.
13
14Signed-off-by: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com>
15---
16 include/net/mac80211.h | 17 +++++++++++++++++
17 net/mac80211/led.c | 16 ++++++++++++++++
18 net/mac80211/led.h | 17 -----------------
19 net/mac80211/rx.c | 2 +-
20 net/mac80211/tx.c | 4 ++--
21 5 files changed, 36 insertions(+), 20 deletions(-)
22
23diff --git a/include/net/mac80211.h b/include/net/mac80211.h
24index 28ec7e8..644ea36 100644
25--- a/include/net/mac80211.h
26+++ b/include/net/mac80211.h
27@@ -4404,6 +4404,8 @@ __ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
28 unsigned int flags,
29 const struct ieee80211_tpt_blink *blink_table,
30 unsigned int blink_table_len);
31+void __ieee80211_tpt_led_trig_tx(struct ieee80211_hw *hw, int bytes);
32+void __ieee80211_tpt_led_trig_rx(struct ieee80211_hw *hw, int bytes);
33 #endif
34 /**
35 * ieee80211_get_tx_led_name - get name of TX LED
36@@ -4514,6 +4516,21 @@ ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw, unsigned int flags,
37 #endif
38 }
39
40+static inline void
41+ieee80211_tpt_led_trig_tx(struct ieee80211_hw *hw, int bytes)
42+{
43+#ifdef CPTCFG_MAC80211_LEDS
44+ __ieee80211_tpt_led_trig_tx(hw, bytes);
45+#endif
46+}
47+
48+static inline void
49+ieee80211_tpt_led_trig_rx(struct ieee80211_hw *hw, int bytes)
50+{
51+#ifdef CPTCFG_MAC80211_LEDS
52+ __ieee80211_tpt_led_trig_rx(hw, bytes);
53+#endif
54+}
55 /**
56 * ieee80211_unregister_hw - Unregister a hardware device
57 *
58diff --git a/net/mac80211/led.c b/net/mac80211/led.c
59index a28ba6d..219bde6 100644
60--- a/net/mac80211/led.c
61+++ b/net/mac80211/led.c
62@@ -364,6 +364,22 @@ __ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
63 }
64 EXPORT_SYMBOL(__ieee80211_create_tpt_led_trigger);
65
66+void __ieee80211_tpt_led_trig_tx(struct ieee80211_hw *hw, int bytes)
67+{
68+ struct ieee80211_local *local = hw_to_local(hw);
69+ if (atomic_read(&local->tpt_led_active))
70+ local->tpt_led_trigger->tx_bytes += bytes;
71+}
72+EXPORT_SYMBOL(__ieee80211_tpt_led_trig_tx);
73+
74+void __ieee80211_tpt_led_trig_rx(struct ieee80211_hw *hw, int bytes)
75+{
76+ struct ieee80211_local *local = hw_to_local(hw);
77+ if (atomic_read(&local->tpt_led_active))
78+ local->tpt_led_trigger->rx_bytes += bytes;
79+}
80+EXPORT_SYMBOL(__ieee80211_tpt_led_trig_rx);
81+
82 static void ieee80211_start_tpt_led_trig(struct ieee80211_local *local)
83 {
84 struct tpt_led_trigger *tpt_trig = local->tpt_led_trigger;
85diff --git a/net/mac80211/led.h b/net/mac80211/led.h
86index 2abb1d0..b18ae9d 100644
87--- a/net/mac80211/led.h
88+++ b/net/mac80211/led.h
89@@ -69,22 +69,5 @@ static inline void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
90 unsigned int types_off)
91 {
92 }
93-#endif
94
95-static inline void
96-ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, int bytes)
97-{
98-#ifdef CPTCFG_MAC80211_LEDS
99- if (atomic_read(&local->tpt_led_active))
100- local->tpt_led_trigger->tx_bytes += bytes;
101 #endif
102-}
103-
104-static inline void
105-ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, int bytes)
106-{
107-#ifdef CPTCFG_MAC80211_LEDS
108- if (atomic_read(&local->tpt_led_active))
109- local->tpt_led_trigger->rx_bytes += bytes;
110-#endif
111-}
112diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
113index 838085f..492f389 100644
114--- a/net/mac80211/rx.c
115+++ b/net/mac80211/rx.c
116@@ -5047,7 +5047,7 @@ void ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *pubsta,
117 if (skb) {
118 if ((status->flag & RX_FLAG_8023) ||
119 ieee80211_is_data_present(hdr->frame_control))
120- ieee80211_tpt_led_trig_rx(local, skb->len);
121+ ieee80211_tpt_led_trig_rx(&local->hw, skb->len);
122
123 if (status->flag & RX_FLAG_8023)
124 __ieee80211_rx_handle_8023(hw, pubsta, skb, list);
125diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
126index 9b66cc0..50ba10c 100644
127--- a/net/mac80211/tx.c
128+++ b/net/mac80211/tx.c
129@@ -4229,7 +4229,7 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb,
130 len = 0;
131 out:
132 if (len)
133- ieee80211_tpt_led_trig_tx(local, len);
134+ ieee80211_tpt_led_trig_tx(&local->hw, len);
135 rcu_read_unlock();
136 }
137
138@@ -4501,7 +4501,7 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata,
139 sta->tx_stats.packets[queue] += skbs;
140 sta->tx_stats.bytes[queue] += len;
141
142- ieee80211_tpt_led_trig_tx(local, len);
143+ ieee80211_tpt_led_trig_tx(&local->hw, len);
144
145 ieee80211_tx_8023(sdata, skb, sta, false);
146
147--
1482.39.0
149