linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] wifi: mac80211: add exported tpt_led_trig function for softmac driver
@ 2023-09-21 21:04 Yi-Chia Hsieh
  2023-09-25  6:38 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Yi-Chia Hsieh @ 2023-09-21 21:04 UTC (permalink / raw)
  To: Felix Fietkau, Johannes Berg
  Cc: Lorenzo Bianconi, Ryder Lee, Shayne Chen, Evelyn Tsai,
	Money Wang, Peter Chiu, Benjamin Lin, linux-wireless,
	linux-mediatek, Yi-Chia Hsieh, Money Wang

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(-)

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
 }
-- 
2.39.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] wifi: mac80211: add exported tpt_led_trig function for softmac driver
  2023-09-21 21:04 [PATCH v3] wifi: mac80211: add exported tpt_led_trig function for softmac driver Yi-Chia Hsieh
@ 2023-09-25  6:38 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2023-09-25  6:38 UTC (permalink / raw)
  To: Yi-Chia Hsieh, Felix Fietkau
  Cc: Lorenzo Bianconi, Ryder Lee, Shayne Chen, Evelyn Tsai,
	Money Wang, Peter Chiu, Benjamin Lin, linux-wireless,
	linux-mediatek


> +++ 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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-25  6:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-21 21:04 [PATCH v3] wifi: mac80211: add exported tpt_led_trig function for softmac driver Yi-Chia Hsieh
2023-09-25  6:38 ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).