diff mbox series

[v3] wifi: mac80211: add exported tpt_led_trig function for softmac driver

Message ID 038706d9bbf434642013e880300d4f597f13b514.1695329290.git.yi-chia.hsieh@mediatek.com (mailing list archive)
State New, archived
Headers show
Series [v3] wifi: mac80211: add exported tpt_led_trig function for softmac driver | expand

Commit Message

Yi-Chia Hsieh Sept. 21, 2023, 9:04 p.m. UTC
Add a new function __ieee80211_tpt_led_trig_trx. It is exported and
takes ieee80211_hw as argument so that softmac driver can use. This
can be helpful when traffic runs in HW path and mac80211 is not
aware of the traffic.

Signed-off-by: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com>
Signed-off-by: Money Wang <Money.Wang@mediatek.com>
Signed-off-by: Evelyn Tsai <evelyn.tsai@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
---
v2: split series
---
v3: retitle, keep the original API and combine double-underscore functions
---
 include/net/mac80211.h |  2 ++
 net/mac80211/led.c     | 12 ++++++++++++
 net/mac80211/led.h     |  6 ++----
 3 files changed, 16 insertions(+), 4 deletions(-)

Comments

Johannes Berg Sept. 25, 2023, 6:38 a.m. UTC | #1
> +++ b/include/net/mac80211.h
> @@ -4733,6 +4733,8 @@ __ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
>  				   unsigned int flags,
>  				   const struct ieee80211_tpt_blink *blink_table,
>  				   unsigned int blink_table_len);
> +void __ieee80211_tpt_led_trig_trx(struct ieee80211_hw *hw,
> +				  int tx_bytes, int rx_bytes);

Hm, I think you misunderstood what I said.

I still think you need to have a well-documented function or two here,
but now you can make the exported versions of this be inlines calling
this new function.

But also this now fails the build if !CONFIG_MAC80211_LEDS, you need to
have an ifdef somewhere.

> +void __ieee80211_tpt_led_trig_trx(struct ieee80211_hw *hw,
> +				  int tx_bytes, int rx_bytes)
> +{
> +	struct ieee80211_local *local = hw_to_local(hw);
> +
> +	if (atomic_read(&local->tpt_led_active)) {
> +		local->tpt_led_trigger->tx_bytes += tx_bytes;
> +		local->tpt_led_trigger->rx_bytes += rx_bytes;
> +	}
> +}
> +EXPORT_SYMBOL(__ieee80211_tpt_led_trig_trx);

Even that won't build.

> --- a/net/mac80211/led.h
> +++ b/net/mac80211/led.h
> @@ -71,8 +71,7 @@ static inline void
>  ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, int bytes)
>  {
>  #ifdef CONFIG_MAC80211_LEDS
> -	if (atomic_read(&local->tpt_led_active))
> -		local->tpt_led_trigger->tx_bytes += bytes;
> +	__ieee80211_tpt_led_trig_trx(&local->hw, bytes, 0);
>  #endif

Ah. Actually what I was thinking is that __ieee80211_tpt_led_trig_trx is
still an inline, and then the ieee80211_tpt_led_trig_trx() exported to
drivers can call this alongside these inlines - that way mac80211 still
gets the (trivial) code inlined.

johannes
diff mbox series

Patch

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 8d993f6ab919..c32f614acb3d 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -4733,6 +4733,8 @@  __ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
 				   unsigned int flags,
 				   const struct ieee80211_tpt_blink *blink_table,
 				   unsigned int blink_table_len);
+void __ieee80211_tpt_led_trig_trx(struct ieee80211_hw *hw,
+				  int tx_bytes, int rx_bytes);
 #endif
 /**
  * ieee80211_get_tx_led_name - get name of TX LED
diff --git a/net/mac80211/led.c b/net/mac80211/led.c
index 2dc732147e85..1c18ebcaac20 100644
--- a/net/mac80211/led.c
+++ b/net/mac80211/led.c
@@ -319,6 +319,18 @@  __ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
 }
 EXPORT_SYMBOL(__ieee80211_create_tpt_led_trigger);
 
+void __ieee80211_tpt_led_trig_trx(struct ieee80211_hw *hw,
+				  int tx_bytes, int rx_bytes)
+{
+	struct ieee80211_local *local = hw_to_local(hw);
+
+	if (atomic_read(&local->tpt_led_active)) {
+		local->tpt_led_trigger->tx_bytes += tx_bytes;
+		local->tpt_led_trigger->rx_bytes += rx_bytes;
+	}
+}
+EXPORT_SYMBOL(__ieee80211_tpt_led_trig_trx);
+
 static void ieee80211_start_tpt_led_trig(struct ieee80211_local *local)
 {
 	struct tpt_led_trigger *tpt_trig = local->tpt_led_trigger;
diff --git a/net/mac80211/led.h b/net/mac80211/led.h
index d25f13346b82..6d3212443d35 100644
--- a/net/mac80211/led.h
+++ b/net/mac80211/led.h
@@ -71,8 +71,7 @@  static inline void
 ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, int bytes)
 {
 #ifdef CONFIG_MAC80211_LEDS
-	if (atomic_read(&local->tpt_led_active))
-		local->tpt_led_trigger->tx_bytes += bytes;
+	__ieee80211_tpt_led_trig_trx(&local->hw, bytes, 0);
 #endif
 }
 
@@ -80,7 +79,6 @@  static inline void
 ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, int bytes)
 {
 #ifdef CONFIG_MAC80211_LEDS
-	if (atomic_read(&local->tpt_led_active))
-		local->tpt_led_trigger->rx_bytes += bytes;
+	__ieee80211_tpt_led_trig_trx(&local->hw, 0, bytes);
 #endif
 }