Lets make wifi fast again!
 help / color / mirror / Atom feed
From: Michal Kazior <michal.kazior@tieto.com>
To: linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net, dave.taht@gmail.com,
	make-wifi-fast@lists.bufferbloat.net, apenwarr@gmail.com,
	Michal Kazior <michal.kazior@tieto.com>
Subject: [Make-wifi-fast] [PATCHv5 3/5] mac80211: add debug knobs for fair queuing
Date: Thu, 19 May 2016 10:37:50 +0200	[thread overview]
Message-ID: <1463647072-16201-4-git-send-email-michal.kazior@tieto.com> (raw)
In-Reply-To: <1463647072-16201-1-git-send-email-michal.kazior@tieto.com>

This adds a debugfs entry to read and modify some
fq parameters and inroduces a module parameter to
control number of flows mac80211 shuold maintain.

This makes it easy to debug, test and experiment.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---

Notes:
    v5:
     * expose a single "aqm" debugfs knob to maintain
       coherent stat values [Dave]

 net/mac80211/debugfs.c | 173 +++++++++++++++++++++++++++++++++++++++++++++++++
 net/mac80211/tx.c      |   8 ++-
 2 files changed, 180 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index b251b2f7f8dd..2906c1004e1a 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -10,6 +10,7 @@
 
 #include <linux/debugfs.h>
 #include <linux/rtnetlink.h>
+#include <linux/vmalloc.h>
 #include "ieee80211_i.h"
 #include "driver-ops.h"
 #include "rate.h"
@@ -70,6 +71,177 @@ DEBUGFS_READONLY_FILE(wep_iv, "%#08x",
 DEBUGFS_READONLY_FILE(rate_ctrl_alg, "%s",
 	local->rate_ctrl ? local->rate_ctrl->ops->name : "hw/driver");
 
+struct aqm_info {
+	struct ieee80211_local *local;
+	size_t size;
+	size_t len;
+	unsigned char buf[0];
+};
+
+#define AQM_HDR_LEN 200
+#define AQM_HW_ENTRY_LEN 40
+#define AQM_TXQ_ENTRY_LEN 110
+
+static int aqm_open(struct inode *inode, struct file *file)
+{
+	struct ieee80211_local *local = inode->i_private;
+	struct ieee80211_sub_if_data *sdata;
+	struct sta_info *sta;
+	struct txq_info *txqi;
+	struct fq *fq = &local->fq;
+	struct aqm_info *info = NULL;
+	int len = 0;
+	int i;
+
+	if (!local->ops->wake_tx_queue)
+		return -EOPNOTSUPP;
+
+	len += AQM_HDR_LEN;
+	len += 6 * AQM_HW_ENTRY_LEN;
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(sdata, &local->interfaces, list)
+		len += AQM_TXQ_ENTRY_LEN;
+	list_for_each_entry_rcu(sta, &local->sta_list, list)
+		len += AQM_TXQ_ENTRY_LEN * ARRAY_SIZE(sta->sta.txq);
+	rcu_read_unlock();
+
+	info = vmalloc(len);
+	if (!info)
+		return -ENOMEM;
+
+	spin_lock_bh(&local->fq.lock);
+	rcu_read_lock();
+
+	file->private_data = info;
+	info->local = local;
+	info->size = len;
+	len = 0;
+
+	len += scnprintf(info->buf + len, info->size - len,
+			 "* hw\n"
+			 "access name value\n"
+			 "R fq_flows_cnt %u\n"
+			 "R fq_backlog %u\n"
+			 "R fq_overlimit %u\n"
+			 "R fq_collisions %u\n"
+			 "RW fq_limit %u\n"
+			 "RW fq_quantum %u\n",
+			 fq->flows_cnt,
+			 fq->backlog,
+			 fq->overlimit,
+			 fq->collisions,
+			 fq->limit,
+			 fq->quantum);
+
+	len += scnprintf(info->buf + len,
+			 info->size - len,
+			 "* vif\n"
+			 "ifname addr ac backlog-bytes backlog-packets flows overlimit collisions tx-bytes tx-packets\n");
+
+	list_for_each_entry_rcu(sdata, &local->interfaces, list) {
+		txqi = to_txq_info(sdata->vif.txq);
+		len += scnprintf(info->buf + len, info->size - len,
+				 "%s %pM %u %u %u %u %u %u %u %u\n",
+				 sdata->name,
+				 sdata->vif.addr,
+				 txqi->txq.ac,
+				 txqi->tin.backlog_bytes,
+				 txqi->tin.backlog_packets,
+				 txqi->tin.flows,
+				 txqi->tin.overlimit,
+				 txqi->tin.collisions,
+				 txqi->tin.tx_bytes,
+				 txqi->tin.tx_packets);
+	}
+
+	len += scnprintf(info->buf + len,
+			 info->size - len,
+			 "* sta\n"
+			 "ifname addr tid ac backlog-bytes backlog-packets flows overlimit collisions tx-bytes tx-packets\n");
+
+	list_for_each_entry_rcu(sta, &local->sta_list, list) {
+		sdata = sta->sdata;
+		for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
+			txqi = to_txq_info(sta->sta.txq[i]);
+			len += scnprintf(info->buf + len, info->size - len,
+					 "%s %pM %d %d %u %u %u %u %u %u %u\n",
+					 sdata->name,
+					 sta->sta.addr,
+					 txqi->txq.tid,
+					 txqi->txq.ac,
+					 txqi->tin.backlog_bytes,
+					 txqi->tin.backlog_packets,
+					 txqi->tin.flows,
+					 txqi->tin.overlimit,
+					 txqi->tin.collisions,
+					 txqi->tin.tx_bytes,
+					 txqi->tin.tx_packets);
+		}
+	}
+
+	info->len = len;
+
+	rcu_read_unlock();
+	spin_unlock_bh(&local->fq.lock);
+
+	return 0;
+}
+
+static int aqm_release(struct inode *inode, struct file *file)
+{
+	vfree(file->private_data);
+	return 0;
+}
+
+static ssize_t aqm_read(struct file *file,
+			char __user *user_buf,
+			size_t count,
+			loff_t *ppos)
+{
+	struct aqm_info *info = file->private_data;
+
+	return simple_read_from_buffer(user_buf, count, ppos,
+				       info->buf, info->len);
+}
+
+static ssize_t aqm_write(struct file *file,
+			 const char __user *user_buf,
+			 size_t count,
+			 loff_t *ppos)
+{
+	struct aqm_info *info = file->private_data;
+	struct ieee80211_local *local = info->local;
+	char buf[100];
+	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 (sscanf(buf, "fq_limit %u", &local->fq.limit) == 1)
+		return count;
+	else if (sscanf(buf, "fq_quantum %u", &local->fq.quantum) == 1)
+		return count;
+
+	return -EINVAL;
+}
+
+static const struct file_operations aqm_ops = {
+	.write = aqm_write,
+	.read = aqm_read,
+	.open = aqm_open,
+	.release = aqm_release,
+	.llseek = default_llseek,
+};
+
 #ifdef CONFIG_PM
 static ssize_t reset_write(struct file *file, const char __user *user_buf,
 			   size_t count, loff_t *ppos)
@@ -256,6 +428,7 @@ void debugfs_hw_add(struct ieee80211_local *local)
 	DEBUGFS_ADD(hwflags);
 	DEBUGFS_ADD(user_power);
 	DEBUGFS_ADD(power);
+	DEBUGFS_ADD_MODE(aqm, 0600);
 
 	statsd = debugfs_create_dir("statistics", phyd);
 
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 1d8343fca6d4..2b60b10e6990 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -17,6 +17,7 @@
 #include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/etherdevice.h>
+#include <linux/moduleparam.h>
 #include <linux/bitmap.h>
 #include <linux/rcupdate.h>
 #include <linux/export.h>
@@ -36,6 +37,11 @@
 #include "wme.h"
 #include "rate.h"
 
+static unsigned int fq_flows_cnt = 4096;
+module_param(fq_flows_cnt, uint, 0644);
+MODULE_PARM_DESC(fq_flows_cnt,
+		 "Maximum number of txq fair queuing flows. ");
+
 /* misc utils */
 
 static inline void ieee80211_tx_stats(struct net_device *dev, u32 len)
@@ -1346,7 +1352,7 @@ int ieee80211_txq_setup_flows(struct ieee80211_local *local)
 	if (!local->ops->wake_tx_queue)
 		return 0;
 
-	ret = fq_init(fq, 4096);
+	ret = fq_init(fq, max_t(u32, fq_flows_cnt, 1));
 	if (ret)
 		return ret;
 
-- 
2.1.4


  parent reply	other threads:[~2016-05-19  8:36 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 10:17 [Make-wifi-fast] [RFCv2 0/3] mac80211: implement fq codel Michal Kazior
2016-03-16 10:17 ` [Make-wifi-fast] [RFCv2 1/3] mac80211: implement fq_codel for software queuing Michal Kazior
2016-03-22  1:35   ` David Lang
2016-03-22  6:51     ` Michal Kazior
2016-03-16 10:17 ` [Make-wifi-fast] [RFCv2 2/3] ath10k: report per-station tx/rate rates to mac80211 Michal Kazior
2016-03-24  7:19   ` Mohammed Shafi Shajakhan
2016-03-24  7:49     ` Michal Kazior
2016-03-24 12:23       ` Mohammed Shafi Shajakhan
2016-03-24 12:31         ` Michal Kazior
2016-03-16 10:17 ` [Make-wifi-fast] [RFCv2 3/3] ath10k: use ieee80211_tx_schedule() Michal Kazior
2016-03-16 10:26 ` [Make-wifi-fast] [RFCv2 0/3] mac80211: implement fq codel Michal Kazior
2016-03-16 15:37   ` Dave Taht
2016-03-16 18:36     ` Dave Taht
2016-03-16 18:55       ` Bob Copeland
2016-03-16 19:48         ` Jasmine Strong
2016-03-17  8:55           ` Michal Kazior
2016-03-17 11:12             ` Bob Copeland
2016-03-17 17:00             ` Dave Taht
2016-03-17 17:24               ` [Make-wifi-fast] [Codel] " Rick Jones
2016-03-21 11:57               ` [Make-wifi-fast] " Michal Kazior
2016-03-17  9:43       ` Michal Kazior
2016-03-17  9:03     ` Michal Kazior
2016-03-25  9:27 ` [Make-wifi-fast] [PATCH 0/2] mac80211: implement fq_codel Michal Kazior
2016-03-25  9:27   ` [Make-wifi-fast] [PATCH 1/2] mac80211: implement fair queuing per txq Michal Kazior
     [not found]     ` <CAHqTa-0yEFYAFpSKyko1ET33GsN==_D8TpBeq6AtwLj4XMTW0A@mail.gmail.com>
2016-04-11  7:25       ` Michal Kazior
2016-03-25  9:27   ` [Make-wifi-fast] [PATCH 2/2] mac80211: expose some txq/fq internals and knobs via debugfs Michal Kazior
2016-03-31 10:28   ` [Make-wifi-fast] [PATCHv2 0/2] mac80211: implement fq_codel Michal Kazior
2016-03-31 10:28     ` [Make-wifi-fast] [PATCHv2 1/2] mac80211: implement fair queuing per txq Michal Kazior
2016-04-05 13:57       ` Johannes Berg
2016-04-05 14:32         ` Dave Taht
     [not found]           ` <1459927276.17504.6.camel@sipsolutions.net>
2016-04-06 17:39             ` Dave Taht
2016-04-07  8:53               ` Johannes Berg
2016-04-06  5:35         ` Michal Kazior
2016-04-06  6:03           ` Jonathan Morton
2016-04-06  7:16             ` Michal Kazior
2016-04-06 16:46               ` Jonathan Morton
2016-04-06  7:19           ` Johannes Berg
2016-03-31 10:28     ` [Make-wifi-fast] [PATCHv2 2/2] mac80211: expose some txq/fq internals and knobs via debugfs Michal Kazior
2016-04-14 12:18     ` [Make-wifi-fast] [PATCHv3 0/5] mac80211: implement fq_codel Michal Kazior
2016-04-14 12:18       ` [Make-wifi-fast] [PATCHv3 1/5] mac80211: skip netdev queue control with software queuing Michal Kazior
2016-04-16 22:21         ` Johannes Berg
2016-04-18  5:39           ` Michal Kazior
2016-04-14 12:18       ` [Make-wifi-fast] [PATCHv3 2/5] mac80211: implement fair queueing per txq Michal Kazior
2016-04-16 22:23         ` Johannes Berg
2016-04-16 22:25           ` Johannes Berg
2016-04-18  5:16             ` Michal Kazior
2016-04-18 12:31               ` [Make-wifi-fast] [Codel] " Eric Dumazet
2016-04-18 13:36                 ` Michal Kazior
2016-04-19  9:10                   ` Johannes Berg
2016-04-14 12:18       ` [Make-wifi-fast] [PATCHv3 3/5] mac80211: add debug knobs for fair queuing Michal Kazior
2016-04-14 12:18       ` [Make-wifi-fast] [PATCHv3 4/5] mac80211: implement codel on fair queuing flows Michal Kazior
2016-04-16 22:29         ` Johannes Berg
2016-04-18  5:31           ` Michal Kazior
2016-04-18 12:38             ` Michal Kazior
2016-04-19  9:06               ` Johannes Berg
2016-04-19  9:31                 ` Michal Kazior
2016-04-19  9:57                   ` Johannes Berg
2016-04-14 12:18       ` [Make-wifi-fast] [PATCHv3 5/5] mac80211: add debug knobs for codel Michal Kazior
2016-05-05 11:00       ` [Make-wifi-fast] [PATCHv4 0/5] mac80211: implement fq_codel Michal Kazior
2016-05-05 11:00         ` [Make-wifi-fast] [PATCHv4 1/5] mac80211: skip netdev queue control with software queuing Michal Kazior
2016-05-09 12:28           ` Michal Kazior
2016-05-05 11:00         ` [Make-wifi-fast] [PATCHv4 2/5] mac80211: implement fair queueing per txq Michal Kazior
2016-05-05 11:00         ` [Make-wifi-fast] [PATCHv4 3/5] mac80211: add debug knobs for fair queuing Michal Kazior
2016-06-09  9:48           ` Johannes Berg
2016-05-05 11:00         ` [Make-wifi-fast] [PATCHv4 4/5] mac80211: implement codel on fair queuing flows Michal Kazior
2016-05-05 15:30           ` Dave Taht
2016-05-05 11:00         ` [Make-wifi-fast] [PATCHv4 5/5] mac80211: add debug knobs for codel Michal Kazior
2016-05-05 15:21           ` Dave Taht
2016-05-06  5:27             ` Michal Kazior
2016-05-06  5:51               ` Dave Taht
2016-05-06  6:33                 ` Michal Kazior
2016-05-06  7:23                   ` Dave Taht
2016-05-19  8:37         ` [Make-wifi-fast] [PATCHv5 0/5] mac80211: implement fq_codel Michal Kazior
2016-05-19  8:37           ` [Make-wifi-fast] [PATCHv5 1/5] mac80211: skip netdev queue control with software queuing Michal Kazior
2016-05-19  8:37           ` [Make-wifi-fast] [PATCHv5 2/5] mac80211: implement fair queueing per txq Michal Kazior
2016-05-19  8:37           ` Michal Kazior [this message]
2016-05-19  8:37           ` [Make-wifi-fast] [PATCHv5 4/5] mac80211: implement codel on fair queuing flows Michal Kazior
2016-05-19  8:37           ` [Make-wifi-fast] [PATCHv5 5/5] mac80211: add debug knobs for codel Michal Kazior
2016-06-09  9:47             ` Johannes Berg
2016-05-31 12:12           ` [Make-wifi-fast] [PATCHv5 0/5] mac80211: implement fq_codel Toke Høiland-Jørgensen
2016-05-31 12:31             ` Michal Kazior
2016-06-09  9:49           ` Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.bufferbloat.net/postorius/lists/make-wifi-fast.lists.bufferbloat.net/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1463647072-16201-4-git-send-email-michal.kazior@tieto.com \
    --to=michal.kazior@tieto.com \
    --cc=apenwarr@gmail.com \
    --cc=dave.taht@gmail.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=make-wifi-fast@lists.bufferbloat.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox