mac80211: introduce aql_enable node in debugfs
authorLorenzo Bianconi <lorenzo@kernel.org>
Sat, 9 Jan 2021 17:57:51 +0000 (18:57 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 22 Jan 2021 08:11:37 +0000 (09:11 +0100)
Introduce aql_enable node in debugfs in order to enable/disable aql.
This is useful for debugging purpose.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/e7a934d5d84e4796c4f97ea5de4e66c824296b07.1610214851.git.lorenzo@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/debugfs.c
net/mac80211/ieee80211_i.h
net/mac80211/tx.c

index 08a6f6644dc4ec916244d9777b88771997b68215..5296898875ffba7b1dea1f99096d47fa09234f83 100644 (file)
@@ -281,6 +281,56 @@ static const struct file_operations aql_txq_limit_ops = {
        .llseek = default_llseek,
 };
 
+static ssize_t aql_enable_read(struct file *file, char __user *user_buf,
+                              size_t count, loff_t *ppos)
+{
+       char buf[3];
+       int len;
+
+       len = scnprintf(buf, sizeof(buf), "%d\n",
+                       !static_key_false(&aql_disable.key));
+
+       return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t aql_enable_write(struct file *file, const char __user *user_buf,
+                               size_t count, loff_t *ppos)
+{
+       bool aql_disabled = static_key_false(&aql_disable.key);
+       char buf[3];
+       size_t len;
+
+       if (count > sizeof(buf))
+               return -EINVAL;
+
+       if (copy_from_user(buf, user_buf, count))
+               return -EFAULT;
+
+       buf[sizeof(buf) - 1] = '\0';
+       len = strlen(buf);
+       if (len > 0 && buf[len - 1] == '\n')
+               buf[len - 1] = 0;
+
+       if (buf[0] == '0' && buf[1] == '\0') {
+               if (!aql_disabled)
+                       static_branch_inc(&aql_disable);
+       } else if (buf[0] == '1' && buf[1] == '\0') {
+               if (aql_disabled)
+                       static_branch_dec(&aql_disable);
+       } else {
+               return -EINVAL;
+       }
+
+       return count;
+}
+
+static const struct file_operations aql_enable_ops = {
+       .write = aql_enable_write,
+       .read = aql_enable_read,
+       .open = simple_open,
+       .llseek = default_llseek,
+};
+
 static ssize_t force_tx_status_read(struct file *file,
                                    char __user *user_buf,
                                    size_t count,
@@ -569,6 +619,7 @@ void debugfs_hw_add(struct ieee80211_local *local)
        DEBUGFS_ADD(power);
        DEBUGFS_ADD(hw_conf);
        DEBUGFS_ADD_MODE(force_tx_status, 0600);
+       DEBUGFS_ADD_MODE(aql_enable, 0600);
 
        if (local->ops->wake_tx_queue)
                DEBUGFS_ADD_MODE(aqm, 0600);
index c0f6168fdeedd14efce827e8e91b5ad2eaa3b5e5..982fdc12abd998d95f5b1d4856deb4ebf2ccbd14 100644 (file)
@@ -1142,6 +1142,8 @@ enum mac80211_scan_state {
        SCAN_ABORT,
 };
 
+DECLARE_STATIC_KEY_FALSE(aql_disable);
+
 struct ieee80211_local {
        /* embed the driver visible part.
         * don't cast (use the static inlines below), but we keep
index 45536185d8d7f6a5bfa05444ca880902de2e4b5e..d626e6808bef1518795e808b72f1b69e223a6db8 100644 (file)
@@ -3811,6 +3811,8 @@ void __ieee80211_schedule_txq(struct ieee80211_hw *hw,
 }
 EXPORT_SYMBOL(__ieee80211_schedule_txq);
 
+DEFINE_STATIC_KEY_FALSE(aql_disable);
+
 bool ieee80211_txq_airtime_check(struct ieee80211_hw *hw,
                                 struct ieee80211_txq *txq)
 {
@@ -3820,6 +3822,9 @@ bool ieee80211_txq_airtime_check(struct ieee80211_hw *hw,
        if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL))
                return true;
 
+       if (static_branch_unlikely(&aql_disable))
+               return true;
+
        if (!txq->sta)
                return true;