[PATCH v2] wifi: mac80211: export ieee80211_tpt_led_trig_tx/rx for driver

Johannes Berg johannes at sipsolutions.net
Wed Sep 13 03:06:01 PDT 2023


> +++ b/net/mac80211/led.c
> @@ -319,6 +319,24 @@ __ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
>  }
>  EXPORT_SYMBOL(__ieee80211_create_tpt_led_trigger);
>  
> +void __ieee80211_tpt_led_trig_tx(struct ieee80211_hw *hw, int bytes)
> +{
> +	struct ieee80211_local *local = hw_to_local(hw);
> +
> +	if (atomic_read(&local->tpt_led_active))
> +		local->tpt_led_trigger->tx_bytes += bytes;
> +}
> +EXPORT_SYMBOL(__ieee80211_tpt_led_trig_tx);
> +
> +void __ieee80211_tpt_led_trig_rx(struct ieee80211_hw *hw, int bytes)
> +{
> +	struct ieee80211_local *local = hw_to_local(hw);
> +
> +	if (atomic_read(&local->tpt_led_active))
> +		local->tpt_led_trigger->rx_bytes += bytes;
> +}
> +EXPORT_SYMBOL(__ieee80211_tpt_led_trig_rx);
> 

It feels a bit wasteful to export not one but even two functions for
this ...

The trigger only really cares about the sum of the two, so maybe we
shouldn't really care too much, even in mac80211? I think the only
reason we currently separate RX and TX is that they can run
concurrently, but the truth is that it already can race anyway, at least
if you have multiple interfaces ...

So maybe we should just switch to a single counter, and accept that we
may sometimes lose an update?

Also this seems wasteful for mac80211 internals, so maybe instead add
triple-underscore versions that are still inline and called from the
double-underscore versions as well as the existing mac80211 callers.

What do you think?

johannes



More information about the Linux-mediatek mailing list