Skip to content

Commit

Permalink
mac80211: Import airtime calculation code from mt76
Browse files Browse the repository at this point in the history
Felix recently added code to calculate airtime of packets to the mt76
driver. Import this into mac80211 so we can use it for airtime queue limit
calculations.

The airtime.c file is copied verbatim from the mt76 driver, and adjusted to
be usable in mac80211. This involves:

- Switching to mac80211 data structures.
- Adding support for 160 MHz channels and HE mode.
- Moving the symbol and duration calculations around a bit to avoid
  rounding with the higher rates and longer symbol times used for HE rates.

The per-rate TX rate calculation is also split out to its own function so
it can be used directly for the AQL calculations later.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/r/20191119060610.76681-3-kyan@google.com
[fix HE_GROUP_IDX() to use 3 * bw, since there are 3 _gi values]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Toke Høiland-Jørgensen authored and Johannes Berg committed Nov 22, 2019
1 parent bc71d8b commit db3e1c4
Show file tree
Hide file tree
Showing 4 changed files with 632 additions and 1 deletion.
29 changes: 29 additions & 0 deletions include/net/mac80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -6424,4 +6424,33 @@ void ieee80211_nan_func_match(struct ieee80211_vif *vif,
struct cfg80211_nan_match_params *match,
gfp_t gfp);

/**
* ieee80211_calc_rx_airtime - calculate estimated transmission airtime for RX.
*
* This function calculates the estimated airtime usage of a frame based on the
* rate information in the RX status struct and the frame length.
*
* @hw: pointer as obtained from ieee80211_alloc_hw()
* @status: &struct ieee80211_rx_status containing the transmission rate
* information.
* @len: frame length in bytes
*/
u32 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw,
struct ieee80211_rx_status *status,
int len);

/**
* ieee80211_calc_tx_airtime - calculate estimated transmission airtime for TX.
*
* This function calculates the estimated airtime usage of a frame based on the
* rate information in the TX info struct and the frame length.
*
* @hw: pointer as obtained from ieee80211_alloc_hw()
* @info: &struct ieee80211_tx_info of the frame.
* @len: frame length in bytes
*/
u32 ieee80211_calc_tx_airtime(struct ieee80211_hw *hw,
struct ieee80211_tx_info *info,
int len);

#endif /* MAC80211_H */
3 changes: 2 additions & 1 deletion net/mac80211/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ mac80211-y := \
chan.o \
trace.o mlme.o \
tdls.o \
ocb.o
ocb.o \
airtime.o

mac80211-$(CONFIG_MAC80211_LEDS) += led.o
mac80211-$(CONFIG_MAC80211_DEBUGFS) += \
Expand Down
Loading

0 comments on commit db3e1c4

Please sign in to comment.