]> git.ipfire.org Git - thirdparty/openwrt.git/blob
9bcaf86504170db5b5b77c1c40c96be1cbb5d701
[thirdparty/openwrt.git] /
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Wed, 6 Aug 2025 10:52:03 +0200
3 Subject: [PATCH] mac80211: estimate expected throughput if not provided by
4 driver/rc
5
6 Estimate the tx throughput based on the expected per-packet tx time.
7 This is useful for mesh implementations that rely on expected throughput,
8 e.g. 802.11s or batman-adv.
9
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 ---
12
13 --- a/net/mac80211/sta_info.c
14 +++ b/net/mac80211/sta_info.c
15 @@ -2621,6 +2621,27 @@ static inline u64 sta_get_stats_bytes(st
16 return value;
17 }
18
19 +static u32 sta_estimate_expected_throughput(struct sta_info *sta,
20 + struct station_info *sinfo)
21 +{
22 + struct ieee80211_sub_if_data *sdata = sta->sdata;
23 + struct ieee80211_local *local = sdata->local;
24 + struct rate_info *ri = &sinfo->txrate;
25 + struct ieee80211_hw *hw = &local->hw;
26 + struct ieee80211_chanctx_conf *conf;
27 + u32 duration;
28 + u8 band = 0;
29 +
30 + conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
31 + if (conf)
32 + band = conf->def.chan->band;
33 +
34 + duration = ieee80211_rate_expected_tx_airtime(hw, NULL, ri, band, true, 1024);
35 + duration += duration >> 4; /* add assumed packet error rate of ~6% */
36 +
37 + return ((1024 * USEC_PER_SEC) / duration) * 8;
38 +}
39 +
40 void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
41 bool tidstats)
42 {
43 @@ -2865,6 +2886,8 @@ void sta_set_sinfo(struct sta_info *sta,
44 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER);
45
46 thr = sta_get_expected_throughput(sta);
47 + if (!thr && (sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE)))
48 + thr = sta_estimate_expected_throughput(sta, sinfo);
49
50 if (thr != 0) {
51 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_EXPECTED_THROUGHPUT);