ath9k: Add an option for station statistics
[linux-2.6/btrfs-unstable.git] / drivers / net / wireless / ath / ath9k / debug_sta.c
blob3fe2bab2c4f5a30871143b6a8376b433478b62c6
1 /*
2 * Copyright (c) 2013 Qualcomm Atheros, Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include "ath9k.h"
19 static ssize_t read_file_node_aggr(struct file *file, char __user *user_buf,
20 size_t count, loff_t *ppos)
22 struct ath_node *an = file->private_data;
23 struct ath_softc *sc = an->sc;
24 struct ath_atx_tid *tid;
25 struct ath_atx_ac *ac;
26 struct ath_txq *txq;
27 u32 len = 0, size = 4096;
28 char *buf;
29 size_t retval;
30 int tidno, acno;
32 buf = kzalloc(size, GFP_KERNEL);
33 if (buf == NULL)
34 return -ENOMEM;
36 if (!an->sta->ht_cap.ht_supported) {
37 len = scnprintf(buf, size, "%s\n",
38 "HT not supported");
39 goto exit;
42 len = scnprintf(buf, size, "Max-AMPDU: %d\n",
43 an->maxampdu);
44 len += scnprintf(buf + len, size - len, "MPDU Density: %d\n\n",
45 an->mpdudensity);
47 len += scnprintf(buf + len, size - len,
48 "%2s%7s\n", "AC", "SCHED");
50 for (acno = 0, ac = &an->ac[acno];
51 acno < IEEE80211_NUM_ACS; acno++, ac++) {
52 txq = ac->txq;
53 ath_txq_lock(sc, txq);
54 len += scnprintf(buf + len, size - len,
55 "%2d%7d\n",
56 acno, ac->sched);
57 ath_txq_unlock(sc, txq);
60 len += scnprintf(buf + len, size - len,
61 "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n",
62 "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE",
63 "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED");
65 for (tidno = 0, tid = &an->tid[tidno];
66 tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
67 txq = tid->ac->txq;
68 ath_txq_lock(sc, txq);
69 len += scnprintf(buf + len, size - len,
70 "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n",
71 tid->tidno, tid->seq_start, tid->seq_next,
72 tid->baw_size, tid->baw_head, tid->baw_tail,
73 tid->bar_index, tid->sched, tid->paused);
74 ath_txq_unlock(sc, txq);
76 exit:
77 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
78 kfree(buf);
80 return retval;
83 static const struct file_operations fops_node_aggr = {
84 .read = read_file_node_aggr,
85 .open = simple_open,
86 .owner = THIS_MODULE,
87 .llseek = default_llseek,
90 void ath9k_sta_add_debugfs(struct ieee80211_hw *hw,
91 struct ieee80211_vif *vif,
92 struct ieee80211_sta *sta,
93 struct dentry *dir)
95 struct ath_node *an = (struct ath_node *)sta->drv_priv;
96 debugfs_create_file("node_aggr", S_IRUGO, dir, an, &fops_node_aggr);