c214294603d8a2fb09e6bfbaddc6dfcc78c01ffb
[openwrt/staging/981213.git] /
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 20 Jun 2022 14:59:09 +0200
3 Subject: [PATCH] mac80211: consider aql_tx_pending when checking airtime
4 deficit
5
6 When queueing packets for a station, deficit only gets added once the packets
7 have been transmitted, which could be much later. During that time, a lot of
8 temporary unfairness could happen, which could lead to bursty behavior.
9 Fix this by subtracting the aql_tx_pending when checking the deficit in tx
10 scheduling.
11
12 Signed-off-by: Felix Fietkau <nbd@nbd.name>
13 ---
14
15 --- a/net/mac80211/tx.c
16 +++ b/net/mac80211/tx.c
17 @@ -3817,6 +3817,13 @@ out:
18 }
19 EXPORT_SYMBOL(ieee80211_tx_dequeue);
20
21 +static inline s32 ieee80211_sta_deficit(struct sta_info *sta, u8 ac)
22 +{
23 + struct airtime_info *air_info = &sta->airtime[ac];
24 +
25 + return air_info->deficit - atomic_read(&air_info->aql_tx_pending);
26 +}
27 +
28 struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac)
29 {
30 struct ieee80211_local *local = hw_to_local(hw);
31 @@ -3847,7 +3854,7 @@ struct ieee80211_txq *ieee80211_next_txq
32 struct sta_info *sta = container_of(txqi->txq.sta,
33 struct sta_info, sta);
34 bool aql_check = ieee80211_txq_airtime_check(hw, &txqi->txq);
35 - s32 deficit = sta->airtime[txqi->txq.ac].deficit;
36 + s32 deficit = ieee80211_sta_deficit(sta, txqi->txq.ac);
37
38 if (aql_check)
39 found_eligible_txq = true;
40 @@ -3972,7 +3979,7 @@ bool ieee80211_txq_may_transmit(struct i
41 continue;
42 }
43 sta = container_of(iter->txq.sta, struct sta_info, sta);
44 - if (sta->airtime[ac].deficit < 0)
45 + if (ieee80211_sta_deficit(sta, ac) < 0)
46 sta->airtime[ac].deficit += sta->airtime_weight;
47 list_move_tail(&iter->schedule_order, &local->active_txqs[ac]);
48 }