Skip to content

Commit 8ccc070

Browse files
nbd168jmberg-intel
authored andcommitted
wifi: mac80211: keep recently active tx queues in scheduling list
This allows proper deficit accounting to ensure that they don't carry their deficit until the next time they become active Signed-off-by: Felix Fietkau <[email protected]> Acked-by: Toke Høiland-Jørgensen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent 9c1be3c commit 8ccc070

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

net/mac80211/ieee80211_i.h

+7
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ extern const u8 ieee80211_ac_to_qos_mask[IEEE80211_NUM_ACS];
8383

8484
#define IEEE80211_MAX_NAN_INSTANCE_ID 255
8585

86+
87+
/*
88+
* Keep a station's queues on the active list for deficit accounting purposes
89+
* if it was active or queued during the last 100ms
90+
*/
91+
#define AIRTIME_ACTIVE_DURATION (HZ / 10)
92+
8693
struct ieee80211_bss {
8794
u32 device_ts_beacon, device_ts_presp;
8895

net/mac80211/sta_info.h

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ enum ieee80211_agg_stop_reason {
138138
struct airtime_info {
139139
u64 rx_airtime;
140140
u64 tx_airtime;
141+
u32 last_active;
141142
s32 deficit;
142143
atomic_t aql_tx_pending; /* Estimated airtime for frames pending */
143144
u32 aql_limit_low;

net/mac80211/tx.c

+36-4
Original file line numberDiff line numberDiff line change
@@ -3807,6 +3807,36 @@ static inline s32 ieee80211_sta_deficit(struct sta_info *sta, u8 ac)
38073807
return air_info->deficit - atomic_read(&air_info->aql_tx_pending);
38083808
}
38093809

3810+
static void
3811+
ieee80211_txq_set_active(struct txq_info *txqi)
3812+
{
3813+
struct sta_info *sta;
3814+
3815+
if (!txqi->txq.sta)
3816+
return;
3817+
3818+
sta = container_of(txqi->txq.sta, struct sta_info, sta);
3819+
sta->airtime[txqi->txq.ac].last_active = (u32)jiffies;
3820+
}
3821+
3822+
static bool
3823+
ieee80211_txq_keep_active(struct txq_info *txqi)
3824+
{
3825+
struct sta_info *sta;
3826+
u32 diff;
3827+
3828+
if (!txqi->txq.sta)
3829+
return false;
3830+
3831+
sta = container_of(txqi->txq.sta, struct sta_info, sta);
3832+
if (ieee80211_sta_deficit(sta, txqi->txq.ac) >= 0)
3833+
return false;
3834+
3835+
diff = (u32)jiffies - sta->airtime[txqi->txq.ac].last_active;
3836+
3837+
return diff <= AIRTIME_ACTIVE_DURATION;
3838+
}
3839+
38103840
struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac)
38113841
{
38123842
struct ieee80211_local *local = hw_to_local(hw);
@@ -3853,7 +3883,6 @@ struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac)
38533883
}
38543884
}
38553885

3856-
38573886
if (txqi->schedule_round == local->schedule_round[ac])
38583887
goto out;
38593888

@@ -3873,27 +3902,30 @@ void __ieee80211_schedule_txq(struct ieee80211_hw *hw,
38733902
{
38743903
struct ieee80211_local *local = hw_to_local(hw);
38753904
struct txq_info *txqi = to_txq_info(txq);
3905+
bool has_queue;
38763906

38773907
spin_lock_bh(&local->active_txq_lock[txq->ac]);
38783908

3909+
has_queue = force || txq_has_queue(txq);
38793910
if (list_empty(&txqi->schedule_order) &&
3880-
(force || !skb_queue_empty(&txqi->frags) ||
3881-
txqi->tin.backlog_packets)) {
3911+
(has_queue || ieee80211_txq_keep_active(txqi))) {
38823912
/* If airtime accounting is active, always enqueue STAs at the
38833913
* head of the list to ensure that they only get moved to the
38843914
* back by the airtime DRR scheduler once they have a negative
38853915
* deficit. A station that already has a negative deficit will
38863916
* get immediately moved to the back of the list on the next
38873917
* call to ieee80211_next_txq().
38883918
*/
3889-
if (txqi->txq.sta && local->airtime_flags &&
3919+
if (txqi->txq.sta && local->airtime_flags && has_queue &&
38903920
wiphy_ext_feature_isset(local->hw.wiphy,
38913921
NL80211_EXT_FEATURE_AIRTIME_FAIRNESS))
38923922
list_add(&txqi->schedule_order,
38933923
&local->active_txqs[txq->ac]);
38943924
else
38953925
list_add_tail(&txqi->schedule_order,
38963926
&local->active_txqs[txq->ac]);
3927+
if (has_queue)
3928+
ieee80211_txq_set_active(txqi);
38973929
}
38983930

38993931
spin_unlock_bh(&local->active_txq_lock[txq->ac]);

0 commit comments

Comments
 (0)