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@xxxxxxxxxxxx> Signed-off-by: Money Wang <Money.Wang@xxxxxxxxxxxx> Signed-off-by: Evelyn Tsai <evelyn.tsai@xxxxxxxxxxxx> Signed-off-by: Ryder Lee <ryder.lee@xxxxxxxxxxxx> --- v2: split series --- v3: retitle, keep the original API and combine double-underscore functions --- v4: export ieee80211_tpt_led_trig_trx and make double-underscore function inline --- include/net/mac80211.h | 10 ++++++++++ net/mac80211/led.c | 7 +++++++ net/mac80211/led.h | 29 +++++++++++------------------ net/mac80211/rx.c | 2 +- net/mac80211/tx.c | 4 ++-- 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 72375eceb786..de37020ee845 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -4853,6 +4853,16 @@ ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw, unsigned int flags, #endif } +/** + * ieee80211_tpt_led_trig_trx - report traffic to throughput LED + * + * @hw: the hardware to count bytes for tpt_led + * @tx_bytes: bytes to add to tx + * @rx_bytes: bytes to add to rx + */ +void ieee80211_tpt_led_trig_trx(struct ieee80211_hw *hw, + int tx_bytes, int rx_bytes); + /** * ieee80211_unregister_hw - Unregister a hardware device * diff --git a/net/mac80211/led.c b/net/mac80211/led.c index 2dc732147e85..89fd5da21423 100644 --- a/net/mac80211/led.c +++ b/net/mac80211/led.c @@ -319,6 +319,13 @@ __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) +{ + __ieee80211_tpt_led_trig_trx(hw_to_local(hw), tx_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..8368564d205f 100644 --- a/net/mac80211/led.h +++ b/net/mac80211/led.h @@ -28,6 +28,17 @@ static inline void ieee80211_led_tx(struct ieee80211_local *local) #endif } +static inline void __ieee80211_tpt_led_trig_trx(struct ieee80211_local *local, + int tx_bytes, int rx_bytes) +{ +#ifdef CONFIG_MAC80211_LEDS + if (atomic_read(&local->tpt_led_active)) { + local->tpt_led_trigger->tx_bytes += tx_bytes; + local->tpt_led_trigger->rx_bytes += rx_bytes; + } +#endif +} + #ifdef CONFIG_MAC80211_LEDS void ieee80211_led_assoc(struct ieee80211_local *local, bool associated); @@ -66,21 +77,3 @@ static inline void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local, { } #endif - -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; -#endif -} - -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; -#endif -} diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 051db97a92b4..c6d67e62d866 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -5383,7 +5383,7 @@ void ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *pubsta, if (skb) { if ((status->flag & RX_FLAG_8023) || ieee80211_is_data_present(hdr->frame_control)) - ieee80211_tpt_led_trig_rx(local, skb->len); + ieee80211_tpt_led_trig_trx(&local->hw, 0, skb->len); if (status->flag & RX_FLAG_8023) __ieee80211_rx_handle_8023(hw, pubsta, skb, list); diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index a984fc54644e..0cffd3a94830 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -4334,7 +4334,7 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb, len = 0; out: if (len) - ieee80211_tpt_led_trig_tx(local, len); + ieee80211_tpt_led_trig_trx(&local->hw, len, 0); rcu_read_unlock(); } @@ -4665,7 +4665,7 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata, sta->deflink.tx_stats.packets[queue] += skbs; sta->deflink.tx_stats.bytes[queue] += len; - ieee80211_tpt_led_trig_tx(local, len); + ieee80211_tpt_led_trig_trx(&local->hw, len, 0); ieee80211_tx_8023(sdata, skb, sta, false); -- 2.39.0