Skip to content

Commit 911bde0

Browse files
tohojojmberg-intel
authored andcommitted
mac80211: Turn AQL into an NL80211_EXT_FEATURE
Instead of just having an airtime flag in debugfs, turn AQL into a proper NL80211_EXT_FEATURE, so drivers can turn it on when they are ready, and so we also expose the presence of the feature to userspace. This also has the effect of flipping the default, so drivers have to opt in to using AQL instead of getting it by default with TXQs. To keep functionality the same as pre-patch, we set this feature for ath10k (which is where it is needed the most). While we're at it, split out the debugfs interface so AQL gets its own per-station debugfs file instead of using the 'airtime' file. [Johannes:] This effectively disables AQL for iwlwifi, where it fixes a number of issues: * TSO in iwlwifi is causing underflows and associated warnings in AQL * HE (802.11ax) rates aren't reported properly so at HE rates, AQL could never have a valid estimate (it'd use 6 Mbps instead of up to 2400!) Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> Link: https://lore.kernel.org/r/20191212111437.224294-1-toke@redhat.com Fixes: 3ace10f ("mac80211: Implement Airtime-based Queue Limit (AQL)") Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent e548f74 commit 911bde0

7 files changed

Lines changed: 70 additions & 24 deletions

File tree

‎drivers/net/wireless/ath/ath10k/mac.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8958,6 +8958,7 @@ int ath10k_mac_register(struct ath10k *ar)
89588958
wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
89598959
wiphy_ext_feature_set(ar->hw->wiphy,
89608960
NL80211_EXT_FEATURE_SET_SCAN_DWELL);
8961+
wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_AQL);
89618962

89628963
if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI, ar->wmi.svc_map) ||
89638964
test_bit(WMI_SERVICE_HTT_MGMT_TX_COMP_VALID_FLAGS, ar->wmi.svc_map))

‎include/uapi/linux/nl80211.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5517,6 +5517,10 @@ enum nl80211_feature_flags {
55175517
* with VLAN tagged frames and separate VLAN-specific netdevs added using
55185518
* vconfig similarly to the Ethernet case.
55195519
*
5520+
* @NL80211_EXT_FEATURE_AQL: The driver supports the Airtime Queue Limit (AQL)
5521+
* feature, which prevents bufferbloat by using the expected transmission
5522+
* time to limit the amount of data buffered in the hardware.
5523+
*
55205524
* @NUM_NL80211_EXT_FEATURES: number of extended features.
55215525
* @MAX_NL80211_EXT_FEATURES: highest extended feature index.
55225526
*/
@@ -5563,6 +5567,7 @@ enum nl80211_ext_feature_index {
55635567
NL80211_EXT_FEATURE_STA_TX_PWR,
55645568
NL80211_EXT_FEATURE_SAE_OFFLOAD,
55655569
NL80211_EXT_FEATURE_VLAN_OFFLOAD,
5570+
NL80211_EXT_FEATURE_AQL,
55665571

55675572
/* add new features before the definition below */
55685573
NUM_NL80211_EXT_FEATURES,

‎net/mac80211/debugfs_sta.c‎

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ static ssize_t sta_airtime_read(struct file *file, char __user *userbuf,
201201
char *buf = kzalloc(bufsz, GFP_KERNEL), *p = buf;
202202
u64 rx_airtime = 0, tx_airtime = 0;
203203
s64 deficit[IEEE80211_NUM_ACS];
204-
u32 q_depth[IEEE80211_NUM_ACS];
205-
u32 q_limit_l[IEEE80211_NUM_ACS], q_limit_h[IEEE80211_NUM_ACS];
206204
ssize_t rv;
207205
int ac;
208206

@@ -214,19 +212,65 @@ static ssize_t sta_airtime_read(struct file *file, char __user *userbuf,
214212
rx_airtime += sta->airtime[ac].rx_airtime;
215213
tx_airtime += sta->airtime[ac].tx_airtime;
216214
deficit[ac] = sta->airtime[ac].deficit;
215+
spin_unlock_bh(&local->active_txq_lock[ac]);
216+
}
217+
218+
p += scnprintf(p, bufsz + buf - p,
219+
"RX: %llu us\nTX: %llu us\nWeight: %u\n"
220+
"Deficit: VO: %lld us VI: %lld us BE: %lld us BK: %lld us\n",
221+
rx_airtime, tx_airtime, sta->airtime_weight,
222+
deficit[0], deficit[1], deficit[2], deficit[3]);
223+
224+
rv = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
225+
kfree(buf);
226+
return rv;
227+
}
228+
229+
static ssize_t sta_airtime_write(struct file *file, const char __user *userbuf,
230+
size_t count, loff_t *ppos)
231+
{
232+
struct sta_info *sta = file->private_data;
233+
struct ieee80211_local *local = sta->sdata->local;
234+
int ac;
235+
236+
for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
237+
spin_lock_bh(&local->active_txq_lock[ac]);
238+
sta->airtime[ac].rx_airtime = 0;
239+
sta->airtime[ac].tx_airtime = 0;
240+
sta->airtime[ac].deficit = sta->airtime_weight;
241+
spin_unlock_bh(&local->active_txq_lock[ac]);
242+
}
243+
244+
return count;
245+
}
246+
STA_OPS_RW(airtime);
247+
248+
static ssize_t sta_aql_read(struct file *file, char __user *userbuf,
249+
size_t count, loff_t *ppos)
250+
{
251+
struct sta_info *sta = file->private_data;
252+
struct ieee80211_local *local = sta->sdata->local;
253+
size_t bufsz = 400;
254+
char *buf = kzalloc(bufsz, GFP_KERNEL), *p = buf;
255+
u32 q_depth[IEEE80211_NUM_ACS];
256+
u32 q_limit_l[IEEE80211_NUM_ACS], q_limit_h[IEEE80211_NUM_ACS];
257+
ssize_t rv;
258+
int ac;
259+
260+
if (!buf)
261+
return -ENOMEM;
262+
263+
for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
264+
spin_lock_bh(&local->active_txq_lock[ac]);
217265
q_limit_l[ac] = sta->airtime[ac].aql_limit_low;
218266
q_limit_h[ac] = sta->airtime[ac].aql_limit_high;
219267
spin_unlock_bh(&local->active_txq_lock[ac]);
220268
q_depth[ac] = atomic_read(&sta->airtime[ac].aql_tx_pending);
221269
}
222270

223271
p += scnprintf(p, bufsz + buf - p,
224-
"RX: %llu us\nTX: %llu us\nWeight: %u\n"
225-
"Deficit: VO: %lld us VI: %lld us BE: %lld us BK: %lld us\n"
226272
"Q depth: VO: %u us VI: %u us BE: %u us BK: %u us\n"
227273
"Q limit[low/high]: VO: %u/%u VI: %u/%u BE: %u/%u BK: %u/%u\n",
228-
rx_airtime, tx_airtime, sta->airtime_weight,
229-
deficit[0], deficit[1], deficit[2], deficit[3],
230274
q_depth[0], q_depth[1], q_depth[2], q_depth[3],
231275
q_limit_l[0], q_limit_h[0], q_limit_l[1], q_limit_h[1],
232276
q_limit_l[2], q_limit_h[2], q_limit_l[3], q_limit_h[3]),
@@ -236,11 +280,10 @@ static ssize_t sta_airtime_read(struct file *file, char __user *userbuf,
236280
return rv;
237281
}
238282

239-
static ssize_t sta_airtime_write(struct file *file, const char __user *userbuf,
283+
static ssize_t sta_aql_write(struct file *file, const char __user *userbuf,
240284
size_t count, loff_t *ppos)
241285
{
242286
struct sta_info *sta = file->private_data;
243-
struct ieee80211_local *local = sta->sdata->local;
244287
u32 ac, q_limit_l, q_limit_h;
245288
char _buf[100] = {}, *buf = _buf;
246289

@@ -251,7 +294,7 @@ static ssize_t sta_airtime_write(struct file *file, const char __user *userbuf,
251294
return -EFAULT;
252295

253296
buf[sizeof(_buf) - 1] = '\0';
254-
if (sscanf(buf, "queue limit %u %u %u", &ac, &q_limit_l, &q_limit_h)
297+
if (sscanf(buf, "limit %u %u %u", &ac, &q_limit_l, &q_limit_h)
255298
!= 3)
256299
return -EINVAL;
257300

@@ -261,17 +304,10 @@ static ssize_t sta_airtime_write(struct file *file, const char __user *userbuf,
261304
sta->airtime[ac].aql_limit_low = q_limit_l;
262305
sta->airtime[ac].aql_limit_high = q_limit_h;
263306

264-
for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
265-
spin_lock_bh(&local->active_txq_lock[ac]);
266-
sta->airtime[ac].rx_airtime = 0;
267-
sta->airtime[ac].tx_airtime = 0;
268-
sta->airtime[ac].deficit = sta->airtime_weight;
269-
spin_unlock_bh(&local->active_txq_lock[ac]);
270-
}
271-
272307
return count;
273308
}
274-
STA_OPS_RW(airtime);
309+
STA_OPS_RW(aql);
310+
275311

276312
static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf,
277313
size_t count, loff_t *ppos)
@@ -996,6 +1032,10 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
9961032
NL80211_EXT_FEATURE_AIRTIME_FAIRNESS))
9971033
DEBUGFS_ADD(airtime);
9981034

1035+
if (wiphy_ext_feature_isset(local->hw.wiphy,
1036+
NL80211_EXT_FEATURE_AQL))
1037+
DEBUGFS_ADD(aql);
1038+
9991039
debugfs_create_xul("driver_buffered_tids", 0400, sta->debugfs_dir,
10001040
&sta->driver_buffered_tids);
10011041

‎net/mac80211/main.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,7 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
672672
IEEE80211_DEFAULT_AQL_TXQ_LIMIT_H;
673673
}
674674

675-
local->airtime_flags = AIRTIME_USE_TX |
676-
AIRTIME_USE_RX |
677-
AIRTIME_USE_AQL;
675+
local->airtime_flags = AIRTIME_USE_TX | AIRTIME_USE_RX;
678676
local->aql_threshold = IEEE80211_AQL_THRESHOLD;
679677
atomic_set(&local->aql_total_pending_airtime, 0);
680678

‎net/mac80211/sta_info.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,6 +1916,9 @@ void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local,
19161916
{
19171917
int tx_pending;
19181918

1919+
if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL))
1920+
return;
1921+
19191922
if (!tx_completed) {
19201923
if (sta)
19211924
atomic_add(tx_airtime,

‎net/mac80211/sta_info.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ enum ieee80211_agg_stop_reason {
127127
/* Debugfs flags to enable/disable use of RX/TX airtime in scheduler */
128128
#define AIRTIME_USE_TX BIT(0)
129129
#define AIRTIME_USE_RX BIT(1)
130-
#define AIRTIME_USE_AQL BIT(2)
131130

132131
struct airtime_info {
133132
u64 rx_airtime;

‎net/mac80211/tx.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3677,7 +3677,7 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
36773677

36783678
IEEE80211_SKB_CB(skb)->control.vif = vif;
36793679

3680-
if (local->airtime_flags & AIRTIME_USE_AQL) {
3680+
if (wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) {
36813681
u32 airtime;
36823682

36833683
airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta,
@@ -3799,7 +3799,7 @@ bool ieee80211_txq_airtime_check(struct ieee80211_hw *hw,
37993799
struct sta_info *sta;
38003800
struct ieee80211_local *local = hw_to_local(hw);
38013801

3802-
if (!(local->airtime_flags & AIRTIME_USE_AQL))
3802+
if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL))
38033803
return true;
38043804

38053805
if (!txq->sta)

0 commit comments

Comments
 (0)