1 From: Lorenzo Bianconi <lorenzo@kernel.org>
2 Date: Sat, 9 Jan 2021 18:57:51 +0100
3 Subject: [PATCH] mac80211: introduce aql_enable node in debugfs
5 Introduce aql_enable node in debugfs in order to enable/disable aql.
6 This is useful for debugging purpose.
8 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
9 Link: https://lore.kernel.org/r/e7a934d5d84e4796c4f97ea5de4e66c824296b07.1610214851.git.lorenzo@kernel.org
10 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
13 --- a/net/mac80211/debugfs.c
14 +++ b/net/mac80211/debugfs.c
15 @@ -281,6 +281,56 @@ static const struct file_operations aql_
16 .llseek = default_llseek,
19 +static ssize_t aql_enable_read(struct file *file, char __user *user_buf,
20 + size_t count, loff_t *ppos)
25 + len = scnprintf(buf, sizeof(buf), "%d\n",
26 + !static_key_false(&aql_disable.key));
28 + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
31 +static ssize_t aql_enable_write(struct file *file, const char __user *user_buf,
32 + size_t count, loff_t *ppos)
34 + bool aql_disabled = static_key_false(&aql_disable.key);
38 + if (count > sizeof(buf))
41 + if (copy_from_user(buf, user_buf, count))
44 + buf[sizeof(buf) - 1] = '\0';
46 + if (len > 0 && buf[len - 1] == '\n')
49 + if (buf[0] == '0' && buf[1] == '\0') {
51 + static_branch_inc(&aql_disable);
52 + } else if (buf[0] == '1' && buf[1] == '\0') {
54 + static_branch_dec(&aql_disable);
62 +static const struct file_operations aql_enable_ops = {
63 + .write = aql_enable_write,
64 + .read = aql_enable_read,
65 + .open = simple_open,
66 + .llseek = default_llseek,
69 static ssize_t force_tx_status_read(struct file *file,
70 char __user *user_buf,
72 @@ -569,6 +619,7 @@ void debugfs_hw_add(struct ieee80211_loc
75 DEBUGFS_ADD_MODE(force_tx_status, 0600);
76 + DEBUGFS_ADD_MODE(aql_enable, 0600);
78 if (local->ops->wake_tx_queue)
79 DEBUGFS_ADD_MODE(aqm, 0600);
80 --- a/net/mac80211/ieee80211_i.h
81 +++ b/net/mac80211/ieee80211_i.h
82 @@ -1147,6 +1147,8 @@ enum mac80211_scan_state {
86 +DECLARE_STATIC_KEY_FALSE(aql_disable);
88 struct ieee80211_local {
89 /* embed the driver visible part.
90 * don't cast (use the static inlines below), but we keep
91 --- a/net/mac80211/tx.c
92 +++ b/net/mac80211/tx.c
93 @@ -3858,6 +3858,8 @@ void __ieee80211_schedule_txq(struct iee
95 EXPORT_SYMBOL(__ieee80211_schedule_txq);
97 +DEFINE_STATIC_KEY_FALSE(aql_disable);
99 bool ieee80211_txq_airtime_check(struct ieee80211_hw *hw,
100 struct ieee80211_txq *txq)
102 @@ -3867,6 +3869,9 @@ bool ieee80211_txq_airtime_check(struct
103 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL))
106 + if (static_branch_unlikely(&aql_disable))