blob: d55ffd7d4bd28565df7d93b5e1ed65c010b99ba5 [file] [log] [blame]
Sujith88b126a2008-11-28 22:19:02 +05301/*
Sujith Manoharan5b681382011-05-17 13:36:18 +05302 * Copyright (c) 2008-2011 Atheros Communications Inc.
Sujith88b126a2008-11-28 22:19:02 +05303 *
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.
7 *
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.
15 */
16
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090017#include <linux/slab.h>
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -080018#include <linux/vmalloc.h>
Gabor Juhos52103112009-03-06 09:57:39 +010019#include <asm/unaligned.h>
20
Sujith394cf0a2009-02-09 13:26:54 +053021#include "ath9k.h"
Sujith88b126a2008-11-28 22:19:02 +053022
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -040023#define REG_WRITE_D(_ah, _reg, _val) \
24 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
25#define REG_READ_D(_ah, _reg) \
26 ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
27
Sujith2a163c62008-11-28 22:21:08 +053028static int ath9k_debugfs_open(struct inode *inode, struct file *file)
29{
30 file->private_data = inode->i_private;
31 return 0;
32}
33
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -080034static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf,
35 size_t count, loff_t *ppos)
36{
37 u8 *buf = file->private_data;
38 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
39}
40
41static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file)
42{
43 vfree(file->private_data);
44 return 0;
45}
46
Felix Fietkaua830df02009-11-23 22:33:27 +010047#ifdef CONFIG_ATH_DEBUG
48
Jeff Hansen24939282009-05-27 12:48:29 +000049static ssize_t read_file_debug(struct file *file, char __user *user_buf,
50 size_t count, loff_t *ppos)
51{
52 struct ath_softc *sc = file->private_data;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070053 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Jeff Hansen24939282009-05-27 12:48:29 +000054 char buf[32];
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053055 unsigned int len;
56
Dan Carpenter2b87f3a2010-05-14 15:24:37 +020057 len = sprintf(buf, "0x%08x\n", common->debug_mask);
Jeff Hansen24939282009-05-27 12:48:29 +000058 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
59}
60
61static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
62 size_t count, loff_t *ppos)
63{
64 struct ath_softc *sc = file->private_data;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070065 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Jeff Hansen24939282009-05-27 12:48:29 +000066 unsigned long mask;
67 char buf[32];
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053068 ssize_t len;
69
70 len = min(count, sizeof(buf) - 1);
71 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +020072 return -EFAULT;
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053073
74 buf[len] = '\0';
75 if (strict_strtoul(buf, 0, &mask))
76 return -EINVAL;
77
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070078 common->debug_mask = mask;
Jeff Hansen24939282009-05-27 12:48:29 +000079 return count;
80}
81
82static const struct file_operations fops_debug = {
83 .read = read_file_debug,
84 .write = write_file_debug,
85 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +020086 .owner = THIS_MODULE,
87 .llseek = default_llseek,
Jeff Hansen24939282009-05-27 12:48:29 +000088};
89
Felix Fietkaua830df02009-11-23 22:33:27 +010090#endif
91
Pavel Roskin991a0982010-01-29 17:22:26 -050092#define DMA_BUF_LEN 1024
93
Felix Fietkau15340692010-05-11 17:23:01 +020094static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf,
95 size_t count, loff_t *ppos)
96{
97 struct ath_softc *sc = file->private_data;
98 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
99 char buf[32];
100 unsigned int len;
101
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200102 len = sprintf(buf, "0x%08x\n", common->tx_chainmask);
Felix Fietkau15340692010-05-11 17:23:01 +0200103 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
104}
105
106static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf,
107 size_t count, loff_t *ppos)
108{
109 struct ath_softc *sc = file->private_data;
110 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
111 unsigned long mask;
112 char buf[32];
113 ssize_t len;
114
115 len = min(count, sizeof(buf) - 1);
116 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +0200117 return -EFAULT;
Felix Fietkau15340692010-05-11 17:23:01 +0200118
119 buf[len] = '\0';
120 if (strict_strtoul(buf, 0, &mask))
121 return -EINVAL;
122
123 common->tx_chainmask = mask;
124 sc->sc_ah->caps.tx_chainmask = mask;
125 return count;
126}
127
128static const struct file_operations fops_tx_chainmask = {
129 .read = read_file_tx_chainmask,
130 .write = write_file_tx_chainmask,
131 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200132 .owner = THIS_MODULE,
133 .llseek = default_llseek,
Felix Fietkau15340692010-05-11 17:23:01 +0200134};
135
136
137static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf,
138 size_t count, loff_t *ppos)
139{
140 struct ath_softc *sc = file->private_data;
141 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
142 char buf[32];
143 unsigned int len;
144
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200145 len = sprintf(buf, "0x%08x\n", common->rx_chainmask);
Felix Fietkau15340692010-05-11 17:23:01 +0200146 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
147}
148
149static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf,
150 size_t count, loff_t *ppos)
151{
152 struct ath_softc *sc = file->private_data;
153 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
154 unsigned long mask;
155 char buf[32];
156 ssize_t len;
157
158 len = min(count, sizeof(buf) - 1);
159 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +0200160 return -EFAULT;
Felix Fietkau15340692010-05-11 17:23:01 +0200161
162 buf[len] = '\0';
163 if (strict_strtoul(buf, 0, &mask))
164 return -EINVAL;
165
166 common->rx_chainmask = mask;
167 sc->sc_ah->caps.rx_chainmask = mask;
168 return count;
169}
170
171static const struct file_operations fops_rx_chainmask = {
172 .read = read_file_rx_chainmask,
173 .write = write_file_rx_chainmask,
174 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200175 .owner = THIS_MODULE,
176 .llseek = default_llseek,
Felix Fietkau15340692010-05-11 17:23:01 +0200177};
178
179
Sujith2a163c62008-11-28 22:21:08 +0530180static ssize_t read_file_dma(struct file *file, char __user *user_buf,
181 size_t count, loff_t *ppos)
182{
183 struct ath_softc *sc = file->private_data;
Sujithcbe61d82009-02-09 13:27:12 +0530184 struct ath_hw *ah = sc->sc_ah;
Pavel Roskin991a0982010-01-29 17:22:26 -0500185 char *buf;
186 int retval;
Sujith2a163c62008-11-28 22:21:08 +0530187 unsigned int len = 0;
188 u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
189 int i, qcuOffset = 0, dcuOffset = 0;
190 u32 *qcuBase = &val[0], *dcuBase = &val[4];
191
Pavel Roskin991a0982010-01-29 17:22:26 -0500192 buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL);
193 if (!buf)
Dan Carpenter04236062010-05-14 15:25:39 +0200194 return -ENOMEM;
Pavel Roskin991a0982010-01-29 17:22:26 -0500195
Sujith7cf4a2e2009-08-26 11:11:57 +0530196 ath9k_ps_wakeup(sc);
197
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400198 REG_WRITE_D(ah, AR_MACMISC,
Sujith2a163c62008-11-28 22:21:08 +0530199 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
200 (AR_MACMISC_MISC_OBS_BUS_1 <<
201 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
202
Pavel Roskin991a0982010-01-29 17:22:26 -0500203 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530204 "Raw DMA Debug values:\n");
205
206 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
207 if (i % 4 == 0)
Pavel Roskin991a0982010-01-29 17:22:26 -0500208 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
Sujith2a163c62008-11-28 22:21:08 +0530209
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400210 val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
Pavel Roskin991a0982010-01-29 17:22:26 -0500211 len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ",
Sujith2a163c62008-11-28 22:21:08 +0530212 i, val[i]);
213 }
214
Pavel Roskin991a0982010-01-29 17:22:26 -0500215 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n");
216 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530217 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
218
219 for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
220 if (i == 8) {
221 qcuOffset = 0;
222 qcuBase++;
223 }
224
225 if (i == 6) {
226 dcuOffset = 0;
227 dcuBase++;
228 }
229
Pavel Roskin991a0982010-01-29 17:22:26 -0500230 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530231 "%2d %2x %1x %2x %2x\n",
232 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
233 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
234 val[2] & (0x7 << (i * 3)) >> (i * 3),
235 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
236 }
237
Pavel Roskin991a0982010-01-29 17:22:26 -0500238 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
Sujith2a163c62008-11-28 22:21:08 +0530239
Pavel Roskin991a0982010-01-29 17:22:26 -0500240 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530241 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
242 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
Pavel Roskin991a0982010-01-29 17:22:26 -0500243 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530244 "qcu_complete state: %2x dcu_complete state: %2x\n",
245 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
Pavel Roskin991a0982010-01-29 17:22:26 -0500246 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530247 "dcu_arb state: %2x dcu_fp state: %2x\n",
248 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
Pavel Roskin991a0982010-01-29 17:22:26 -0500249 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530250 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
251 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
Pavel Roskin991a0982010-01-29 17:22:26 -0500252 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530253 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
254 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
Pavel Roskin991a0982010-01-29 17:22:26 -0500255 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530256 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
257 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
258
Frans Pop60ece402010-03-24 19:46:30 +0100259 len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n",
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400260 REG_READ_D(ah, AR_OBS_BUS_1));
Pavel Roskin991a0982010-01-29 17:22:26 -0500261 len += snprintf(buf + len, DMA_BUF_LEN - len,
Frans Pop60ece402010-03-24 19:46:30 +0100262 "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR));
Sujith2a163c62008-11-28 22:21:08 +0530263
Sujith7cf4a2e2009-08-26 11:11:57 +0530264 ath9k_ps_restore(sc);
265
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200266 if (len > DMA_BUF_LEN)
267 len = DMA_BUF_LEN;
268
Pavel Roskin991a0982010-01-29 17:22:26 -0500269 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
270 kfree(buf);
271 return retval;
Sujith2a163c62008-11-28 22:21:08 +0530272}
273
274static const struct file_operations fops_dma = {
275 .read = read_file_dma,
276 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200277 .owner = THIS_MODULE,
278 .llseek = default_llseek,
Sujith2a163c62008-11-28 22:21:08 +0530279};
280
Sujith817e11d2008-12-07 21:42:44 +0530281
282void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status)
283{
284 if (status)
Sujith17d79042009-02-09 13:27:03 +0530285 sc->debug.stats.istats.total++;
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400286 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
287 if (status & ATH9K_INT_RXLP)
288 sc->debug.stats.istats.rxlp++;
289 if (status & ATH9K_INT_RXHP)
290 sc->debug.stats.istats.rxhp++;
Luis R. Rodriguez08578b82010-05-13 13:33:44 -0400291 if (status & ATH9K_INT_BB_WATCHDOG)
292 sc->debug.stats.istats.bb_watchdog++;
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400293 } else {
294 if (status & ATH9K_INT_RX)
295 sc->debug.stats.istats.rxok++;
296 }
Sujith817e11d2008-12-07 21:42:44 +0530297 if (status & ATH9K_INT_RXEOL)
Sujith17d79042009-02-09 13:27:03 +0530298 sc->debug.stats.istats.rxeol++;
Sujith817e11d2008-12-07 21:42:44 +0530299 if (status & ATH9K_INT_RXORN)
Sujith17d79042009-02-09 13:27:03 +0530300 sc->debug.stats.istats.rxorn++;
Sujith817e11d2008-12-07 21:42:44 +0530301 if (status & ATH9K_INT_TX)
Sujith17d79042009-02-09 13:27:03 +0530302 sc->debug.stats.istats.txok++;
Sujith817e11d2008-12-07 21:42:44 +0530303 if (status & ATH9K_INT_TXURN)
Sujith17d79042009-02-09 13:27:03 +0530304 sc->debug.stats.istats.txurn++;
Sujith817e11d2008-12-07 21:42:44 +0530305 if (status & ATH9K_INT_MIB)
Sujith17d79042009-02-09 13:27:03 +0530306 sc->debug.stats.istats.mib++;
Sujith817e11d2008-12-07 21:42:44 +0530307 if (status & ATH9K_INT_RXPHY)
Sujith17d79042009-02-09 13:27:03 +0530308 sc->debug.stats.istats.rxphyerr++;
Sujith817e11d2008-12-07 21:42:44 +0530309 if (status & ATH9K_INT_RXKCM)
Sujith17d79042009-02-09 13:27:03 +0530310 sc->debug.stats.istats.rx_keycache_miss++;
Sujith817e11d2008-12-07 21:42:44 +0530311 if (status & ATH9K_INT_SWBA)
Sujith17d79042009-02-09 13:27:03 +0530312 sc->debug.stats.istats.swba++;
Sujith817e11d2008-12-07 21:42:44 +0530313 if (status & ATH9K_INT_BMISS)
Sujith17d79042009-02-09 13:27:03 +0530314 sc->debug.stats.istats.bmiss++;
Sujith817e11d2008-12-07 21:42:44 +0530315 if (status & ATH9K_INT_BNR)
Sujith17d79042009-02-09 13:27:03 +0530316 sc->debug.stats.istats.bnr++;
Sujith817e11d2008-12-07 21:42:44 +0530317 if (status & ATH9K_INT_CST)
Sujith17d79042009-02-09 13:27:03 +0530318 sc->debug.stats.istats.cst++;
Sujith817e11d2008-12-07 21:42:44 +0530319 if (status & ATH9K_INT_GTT)
Sujith17d79042009-02-09 13:27:03 +0530320 sc->debug.stats.istats.gtt++;
Sujith817e11d2008-12-07 21:42:44 +0530321 if (status & ATH9K_INT_TIM)
Sujith17d79042009-02-09 13:27:03 +0530322 sc->debug.stats.istats.tim++;
Sujith817e11d2008-12-07 21:42:44 +0530323 if (status & ATH9K_INT_CABEND)
Sujith17d79042009-02-09 13:27:03 +0530324 sc->debug.stats.istats.cabend++;
Sujith817e11d2008-12-07 21:42:44 +0530325 if (status & ATH9K_INT_DTIMSYNC)
Sujith17d79042009-02-09 13:27:03 +0530326 sc->debug.stats.istats.dtimsync++;
Sujith817e11d2008-12-07 21:42:44 +0530327 if (status & ATH9K_INT_DTIM)
Sujith17d79042009-02-09 13:27:03 +0530328 sc->debug.stats.istats.dtim++;
Mohammed Shafi Shajakhan6dde1aa2011-04-22 17:27:01 +0530329 if (status & ATH9K_INT_TSFOOR)
330 sc->debug.stats.istats.tsfoor++;
Sujith817e11d2008-12-07 21:42:44 +0530331}
332
333static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
334 size_t count, loff_t *ppos)
335{
336 struct ath_softc *sc = file->private_data;
337 char buf[512];
338 unsigned int len = 0;
339
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400340 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
341 len += snprintf(buf + len, sizeof(buf) - len,
342 "%8s: %10u\n", "RXLP", sc->debug.stats.istats.rxlp);
343 len += snprintf(buf + len, sizeof(buf) - len,
344 "%8s: %10u\n", "RXHP", sc->debug.stats.istats.rxhp);
Luis R. Rodriguez08578b82010-05-13 13:33:44 -0400345 len += snprintf(buf + len, sizeof(buf) - len,
346 "%8s: %10u\n", "WATCHDOG",
347 sc->debug.stats.istats.bb_watchdog);
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400348 } else {
349 len += snprintf(buf + len, sizeof(buf) - len,
350 "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok);
351 }
Sujith817e11d2008-12-07 21:42:44 +0530352 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530353 "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol);
Sujith817e11d2008-12-07 21:42:44 +0530354 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530355 "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn);
Sujith817e11d2008-12-07 21:42:44 +0530356 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530357 "%8s: %10u\n", "TX", sc->debug.stats.istats.txok);
Sujith817e11d2008-12-07 21:42:44 +0530358 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530359 "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn);
Sujith817e11d2008-12-07 21:42:44 +0530360 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530361 "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib);
Sujith817e11d2008-12-07 21:42:44 +0530362 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530363 "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr);
Sujith817e11d2008-12-07 21:42:44 +0530364 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530365 "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss);
Sujith817e11d2008-12-07 21:42:44 +0530366 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530367 "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba);
Sujith817e11d2008-12-07 21:42:44 +0530368 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530369 "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss);
Sujith817e11d2008-12-07 21:42:44 +0530370 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530371 "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr);
Sujith817e11d2008-12-07 21:42:44 +0530372 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530373 "%8s: %10u\n", "CST", sc->debug.stats.istats.cst);
Sujith817e11d2008-12-07 21:42:44 +0530374 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530375 "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt);
Sujith817e11d2008-12-07 21:42:44 +0530376 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530377 "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim);
Sujith817e11d2008-12-07 21:42:44 +0530378 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530379 "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend);
Sujith817e11d2008-12-07 21:42:44 +0530380 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530381 "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync);
Sujith817e11d2008-12-07 21:42:44 +0530382 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530383 "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim);
Sujith817e11d2008-12-07 21:42:44 +0530384 len += snprintf(buf + len, sizeof(buf) - len,
Mohammed Shafi Shajakhan6dde1aa2011-04-22 17:27:01 +0530385 "%8s: %10u\n", "TSFOOR", sc->debug.stats.istats.tsfoor);
386 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530387 "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total);
Sujith817e11d2008-12-07 21:42:44 +0530388
Mohammed Shafi Shajakhan6dde1aa2011-04-22 17:27:01 +0530389
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200390 if (len > sizeof(buf))
391 len = sizeof(buf);
392
Sujith817e11d2008-12-07 21:42:44 +0530393 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
394}
395
396static const struct file_operations fops_interrupt = {
397 .read = read_file_interrupt,
398 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200399 .owner = THIS_MODULE,
400 .llseek = default_llseek,
Sujith817e11d2008-12-07 21:42:44 +0530401};
402
Ben Greear4e6975f2011-01-31 10:37:36 -0800403static const char *channel_type_str(enum nl80211_channel_type t)
404{
405 switch (t) {
406 case NL80211_CHAN_NO_HT:
407 return "no ht";
408 case NL80211_CHAN_HT20:
409 return "ht20";
410 case NL80211_CHAN_HT40MINUS:
411 return "ht40-";
412 case NL80211_CHAN_HT40PLUS:
413 return "ht40+";
414 default:
415 return "???";
416 }
417}
418
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200419static ssize_t read_file_wiphy(struct file *file, char __user *user_buf,
420 size_t count, loff_t *ppos)
421{
422 struct ath_softc *sc = file->private_data;
Felix Fietkau34302392011-01-24 19:23:15 +0100423 struct ieee80211_channel *chan = sc->hw->conf.channel;
Ben Greear4e6975f2011-01-31 10:37:36 -0800424 struct ieee80211_conf *conf = &(sc->hw->conf);
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200425 char buf[512];
426 unsigned int len = 0;
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200427 u8 addr[ETH_ALEN];
Ben Greear39057512010-09-14 12:46:04 -0700428 u32 tmp;
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200429
430 len += snprintf(buf + len, sizeof(buf) - len,
Ben Greear4e6975f2011-01-31 10:37:36 -0800431 "%s (chan=%d center-freq: %d MHz channel-type: %d (%s))\n",
Felix Fietkau34302392011-01-24 19:23:15 +0100432 wiphy_name(sc->hw->wiphy),
Mohammed Shafi Shajakhan8e0167a2010-10-01 15:25:05 +0530433 ieee80211_frequency_to_channel(chan->center_freq),
Ben Greear4e6975f2011-01-31 10:37:36 -0800434 chan->center_freq,
435 conf->channel_type,
436 channel_type_str(conf->channel_type));
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200437
Mohammed Shafi Shajakhanc6e38c02011-05-18 17:56:00 +0530438 ath9k_ps_wakeup(sc);
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400439 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr);
440 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4);
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200441 len += snprintf(buf + len, sizeof(buf) - len,
442 "addr: %pM\n", addr);
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400443 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr);
444 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4);
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200445 len += snprintf(buf + len, sizeof(buf) - len,
446 "addrmask: %pM\n", addr);
Ben Greear39057512010-09-14 12:46:04 -0700447 tmp = ath9k_hw_getrxfilter(sc->sc_ah);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +0530448 ath9k_ps_restore(sc);
Ben Greear39057512010-09-14 12:46:04 -0700449 len += snprintf(buf + len, sizeof(buf) - len,
450 "rfilt: 0x%x", tmp);
451 if (tmp & ATH9K_RX_FILTER_UCAST)
452 len += snprintf(buf + len, sizeof(buf) - len, " UCAST");
453 if (tmp & ATH9K_RX_FILTER_MCAST)
454 len += snprintf(buf + len, sizeof(buf) - len, " MCAST");
455 if (tmp & ATH9K_RX_FILTER_BCAST)
456 len += snprintf(buf + len, sizeof(buf) - len, " BCAST");
457 if (tmp & ATH9K_RX_FILTER_CONTROL)
458 len += snprintf(buf + len, sizeof(buf) - len, " CONTROL");
459 if (tmp & ATH9K_RX_FILTER_BEACON)
460 len += snprintf(buf + len, sizeof(buf) - len, " BEACON");
461 if (tmp & ATH9K_RX_FILTER_PROM)
462 len += snprintf(buf + len, sizeof(buf) - len, " PROM");
463 if (tmp & ATH9K_RX_FILTER_PROBEREQ)
464 len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ");
465 if (tmp & ATH9K_RX_FILTER_PHYERR)
466 len += snprintf(buf + len, sizeof(buf) - len, " PHYERR");
467 if (tmp & ATH9K_RX_FILTER_MYBEACON)
468 len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON");
469 if (tmp & ATH9K_RX_FILTER_COMP_BAR)
470 len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR");
471 if (tmp & ATH9K_RX_FILTER_PSPOLL)
472 len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL");
473 if (tmp & ATH9K_RX_FILTER_PHYRADAR)
474 len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR");
475 if (tmp & ATH9K_RX_FILTER_MCAST_BCAST_ALL)
476 len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL\n");
477 else
478 len += snprintf(buf + len, sizeof(buf) - len, "\n");
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200479
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200480 if (len > sizeof(buf))
481 len = sizeof(buf);
482
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200483 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
484}
485
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200486static const struct file_operations fops_wiphy = {
487 .read = read_file_wiphy,
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200488 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200489 .owner = THIS_MODULE,
490 .llseek = default_llseek,
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200491};
492
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100493#define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum
Sujithfec247c2009-07-27 12:08:16 +0530494#define PR(str, elem) \
495 do { \
496 len += snprintf(buf + len, size - len, \
497 "%s%13u%11u%10u%10u\n", str, \
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100498 sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem, \
499 sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem, \
500 sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem, \
501 sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem); \
Ben Greear7f010c92011-01-09 23:11:49 -0800502 if (len >= size) \
503 goto done; \
Sujithfec247c2009-07-27 12:08:16 +0530504} while(0)
505
Ben Greear1f427dd2011-01-09 23:11:43 -0800506#define PRX(str, elem) \
507do { \
508 len += snprintf(buf + len, size - len, \
509 "%s%13u%11u%10u%10u\n", str, \
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100510 (unsigned int)(sc->tx.txq_map[WME_AC_BE]->elem), \
511 (unsigned int)(sc->tx.txq_map[WME_AC_BK]->elem), \
512 (unsigned int)(sc->tx.txq_map[WME_AC_VI]->elem), \
513 (unsigned int)(sc->tx.txq_map[WME_AC_VO]->elem)); \
Ben Greear7f010c92011-01-09 23:11:49 -0800514 if (len >= size) \
515 goto done; \
Ben Greear1f427dd2011-01-09 23:11:43 -0800516} while(0)
517
Ben Greear2dac4fb2011-01-09 23:11:45 -0800518#define PRQLE(str, elem) \
519do { \
520 len += snprintf(buf + len, size - len, \
521 "%s%13i%11i%10i%10i\n", str, \
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100522 list_empty(&sc->tx.txq_map[WME_AC_BE]->elem), \
523 list_empty(&sc->tx.txq_map[WME_AC_BK]->elem), \
524 list_empty(&sc->tx.txq_map[WME_AC_VI]->elem), \
525 list_empty(&sc->tx.txq_map[WME_AC_VO]->elem)); \
Ben Greear7f010c92011-01-09 23:11:49 -0800526 if (len >= size) \
527 goto done; \
Ben Greear2dac4fb2011-01-09 23:11:45 -0800528} while (0)
529
Sujithfec247c2009-07-27 12:08:16 +0530530static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
531 size_t count, loff_t *ppos)
532{
533 struct ath_softc *sc = file->private_data;
534 char *buf;
Ben Greear7f010c92011-01-09 23:11:49 -0800535 unsigned int len = 0, size = 8000;
Ben Greear2dac4fb2011-01-09 23:11:45 -0800536 int i;
Sujithfec247c2009-07-27 12:08:16 +0530537 ssize_t retval = 0;
Ben Greear2dac4fb2011-01-09 23:11:45 -0800538 char tmp[32];
Sujithfec247c2009-07-27 12:08:16 +0530539
540 buf = kzalloc(size, GFP_KERNEL);
541 if (buf == NULL)
Dan Carpenter04236062010-05-14 15:25:39 +0200542 return -ENOMEM;
Sujithfec247c2009-07-27 12:08:16 +0530543
Ben Greear60f2d1d2011-01-09 23:11:52 -0800544 len += sprintf(buf, "Num-Tx-Queues: %i tx-queues-setup: 0x%x"
545 " poll-work-seen: %u\n"
Ben Greear7f010c92011-01-09 23:11:49 -0800546 "%30s %10s%10s%10s\n\n",
547 ATH9K_NUM_TX_QUEUES, sc->tx.txqsetup,
Ben Greear60f2d1d2011-01-09 23:11:52 -0800548 sc->tx_complete_poll_work_seen,
Ben Greear7f010c92011-01-09 23:11:49 -0800549 "BE", "BK", "VI", "VO");
Sujithfec247c2009-07-27 12:08:16 +0530550
551 PR("MPDUs Queued: ", queued);
552 PR("MPDUs Completed: ", completed);
553 PR("Aggregates: ", a_aggr);
Ben Greearbda8add2011-01-09 23:11:48 -0800554 PR("AMPDUs Queued HW:", a_queued_hw);
555 PR("AMPDUs Queued SW:", a_queued_sw);
Sujithfec247c2009-07-27 12:08:16 +0530556 PR("AMPDUs Completed:", a_completed);
557 PR("AMPDUs Retried: ", a_retries);
558 PR("AMPDUs XRetried: ", a_xretries);
559 PR("FIFO Underrun: ", fifo_underrun);
560 PR("TXOP Exceeded: ", xtxop);
561 PR("TXTIMER Expiry: ", timer_exp);
562 PR("DESC CFG Error: ", desc_cfg_err);
563 PR("DATA Underrun: ", data_underrun);
564 PR("DELIM Underrun: ", delim_underrun);
Ben Greear99c15bf2010-10-01 12:26:30 -0700565 PR("TX-Pkts-All: ", tx_pkts_all);
566 PR("TX-Bytes-All: ", tx_bytes_all);
Ben Greear2dac4fb2011-01-09 23:11:45 -0800567 PR("hw-put-tx-buf: ", puttxbuf);
568 PR("hw-tx-start: ", txstart);
569 PR("hw-tx-proc-desc: ", txprocdesc);
Ben Greear7f010c92011-01-09 23:11:49 -0800570 len += snprintf(buf + len, size - len,
571 "%s%11p%11p%10p%10p\n", "txq-memory-address:",
Ben Greeardb7889c2011-03-03 16:25:59 -0800572 sc->tx.txq_map[WME_AC_BE],
573 sc->tx.txq_map[WME_AC_BK],
574 sc->tx.txq_map[WME_AC_VI],
575 sc->tx.txq_map[WME_AC_VO]);
Ben Greear7f010c92011-01-09 23:11:49 -0800576 if (len >= size)
577 goto done;
Sujithfec247c2009-07-27 12:08:16 +0530578
Ben Greear1f427dd2011-01-09 23:11:43 -0800579 PRX("axq-qnum: ", axq_qnum);
580 PRX("axq-depth: ", axq_depth);
Ben Greear2dac4fb2011-01-09 23:11:45 -0800581 PRX("axq-ampdu_depth: ", axq_ampdu_depth);
Ben Greear1f427dd2011-01-09 23:11:43 -0800582 PRX("axq-stopped ", stopped);
583 PRX("tx-in-progress ", axq_tx_inprogress);
584 PRX("pending-frames ", pending_frames);
Ben Greear2dac4fb2011-01-09 23:11:45 -0800585 PRX("txq_headidx: ", txq_headidx);
586 PRX("txq_tailidx: ", txq_headidx);
Ben Greear1f427dd2011-01-09 23:11:43 -0800587
Ben Greear2dac4fb2011-01-09 23:11:45 -0800588 PRQLE("axq_q empty: ", axq_q);
589 PRQLE("axq_acq empty: ", axq_acq);
590 PRQLE("txq_fifo_pending: ", txq_fifo_pending);
591 for (i = 0; i < ATH_TXFIFO_DEPTH; i++) {
592 snprintf(tmp, sizeof(tmp) - 1, "txq_fifo[%i] empty: ", i);
593 PRQLE(tmp, txq_fifo[i]);
594 }
Ben Greear7f010c92011-01-09 23:11:49 -0800595
Ben Greear71e025a2011-01-09 23:11:50 -0800596 /* Print out more detailed queue-info */
597 for (i = 0; i <= WME_AC_BK; i++) {
598 struct ath_txq *txq = &(sc->tx.txq[i]);
599 struct ath_atx_ac *ac;
600 struct ath_atx_tid *tid;
601 if (len >= size)
602 goto done;
603 spin_lock_bh(&txq->axq_lock);
604 if (!list_empty(&txq->axq_acq)) {
605 ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac,
606 list);
607 len += snprintf(buf + len, size - len,
608 "txq[%i] first-ac: %p sched: %i\n",
609 i, ac, ac->sched);
610 if (list_empty(&ac->tid_q) || (len >= size))
611 goto done_for;
612 tid = list_first_entry(&ac->tid_q, struct ath_atx_tid,
613 list);
614 len += snprintf(buf + len, size - len,
615 " first-tid: %p sched: %i paused: %i\n",
616 tid, tid->sched, tid->paused);
617 }
618 done_for:
619 spin_unlock_bh(&txq->axq_lock);
620 }
621
Ben Greear7f010c92011-01-09 23:11:49 -0800622done:
623 if (len > size)
624 len = size;
625
626 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
627 kfree(buf);
628
629 return retval;
630}
631
632static ssize_t read_file_stations(struct file *file, char __user *user_buf,
633 size_t count, loff_t *ppos)
634{
635 struct ath_softc *sc = file->private_data;
636 char *buf;
637 unsigned int len = 0, size = 64000;
638 struct ath_node *an = NULL;
639 ssize_t retval = 0;
640 int q;
641
642 buf = kzalloc(size, GFP_KERNEL);
643 if (buf == NULL)
644 return -ENOMEM;
645
646 len += snprintf(buf + len, size - len,
647 "Stations:\n"
648 " tid: addr sched paused buf_q-empty an ac\n"
649 " ac: addr sched tid_q-empty txq\n");
650
651 spin_lock(&sc->nodes_lock);
652 list_for_each_entry(an, &sc->nodes, list) {
653 len += snprintf(buf + len, size - len,
654 "%pM\n", an->sta->addr);
655 if (len >= size)
656 goto done;
657
658 for (q = 0; q < WME_NUM_TID; q++) {
659 struct ath_atx_tid *tid = &(an->tid[q]);
660 len += snprintf(buf + len, size - len,
661 " tid: %p %s %s %i %p %p\n",
662 tid, tid->sched ? "sched" : "idle",
663 tid->paused ? "paused" : "running",
664 list_empty(&tid->buf_q),
665 tid->an, tid->ac);
666 if (len >= size)
667 goto done;
668 }
669
670 for (q = 0; q < WME_NUM_AC; q++) {
671 struct ath_atx_ac *ac = &(an->ac[q]);
672 len += snprintf(buf + len, size - len,
673 " ac: %p %s %i %p\n",
674 ac, ac->sched ? "sched" : "idle",
675 list_empty(&ac->tid_q), ac->txq);
676 if (len >= size)
677 goto done;
678 }
679 }
680
681done:
682 spin_unlock(&sc->nodes_lock);
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200683 if (len > size)
684 len = size;
685
Sujithfec247c2009-07-27 12:08:16 +0530686 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
687 kfree(buf);
688
689 return retval;
690}
691
Ben Greear55f6d0f2011-01-17 11:54:50 -0800692static ssize_t read_file_misc(struct file *file, char __user *user_buf,
693 size_t count, loff_t *ppos)
694{
695 struct ath_softc *sc = file->private_data;
696 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
697 struct ath_hw *ah = sc->sc_ah;
698 struct ieee80211_hw *hw = sc->hw;
699 char *buf;
700 unsigned int len = 0, size = 8000;
701 ssize_t retval = 0;
702 const char *tmp;
703 unsigned int reg;
704 struct ath9k_vif_iter_data iter_data;
705
706 ath9k_calculate_iter_data(hw, NULL, &iter_data);
707
708 buf = kzalloc(size, GFP_KERNEL);
709 if (buf == NULL)
710 return -ENOMEM;
711
712 switch (sc->sc_ah->opmode) {
713 case NL80211_IFTYPE_ADHOC:
714 tmp = "ADHOC";
715 break;
716 case NL80211_IFTYPE_MESH_POINT:
717 tmp = "MESH";
718 break;
719 case NL80211_IFTYPE_AP:
720 tmp = "AP";
721 break;
722 case NL80211_IFTYPE_STATION:
723 tmp = "STATION";
724 break;
725 default:
726 tmp = "???";
727 break;
728 }
729
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +0530730 ath9k_ps_wakeup(sc);
Ben Greear55f6d0f2011-01-17 11:54:50 -0800731 len += snprintf(buf + len, size - len,
732 "curbssid: %pM\n"
733 "OP-Mode: %s(%i)\n"
734 "Beacon-Timer-Register: 0x%x\n",
735 common->curbssid,
736 tmp, (int)(sc->sc_ah->opmode),
737 REG_READ(ah, AR_BEACON_PERIOD));
738
739 reg = REG_READ(ah, AR_TIMER_MODE);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +0530740 ath9k_ps_restore(sc);
Ben Greear55f6d0f2011-01-17 11:54:50 -0800741 len += snprintf(buf + len, size - len, "Timer-Mode-Register: 0x%x (",
742 reg);
743 if (reg & AR_TBTT_TIMER_EN)
744 len += snprintf(buf + len, size - len, "TBTT ");
745 if (reg & AR_DBA_TIMER_EN)
746 len += snprintf(buf + len, size - len, "DBA ");
747 if (reg & AR_SWBA_TIMER_EN)
748 len += snprintf(buf + len, size - len, "SWBA ");
749 if (reg & AR_HCF_TIMER_EN)
750 len += snprintf(buf + len, size - len, "HCF ");
751 if (reg & AR_TIM_TIMER_EN)
752 len += snprintf(buf + len, size - len, "TIM ");
753 if (reg & AR_DTIM_TIMER_EN)
754 len += snprintf(buf + len, size - len, "DTIM ");
755 len += snprintf(buf + len, size - len, ")\n");
756
757 reg = sc->sc_ah->imask;
758 len += snprintf(buf + len, size - len, "imask: 0x%x (", reg);
759 if (reg & ATH9K_INT_SWBA)
760 len += snprintf(buf + len, size - len, "SWBA ");
761 if (reg & ATH9K_INT_BMISS)
762 len += snprintf(buf + len, size - len, "BMISS ");
763 if (reg & ATH9K_INT_CST)
764 len += snprintf(buf + len, size - len, "CST ");
765 if (reg & ATH9K_INT_RX)
766 len += snprintf(buf + len, size - len, "RX ");
767 if (reg & ATH9K_INT_RXHP)
768 len += snprintf(buf + len, size - len, "RXHP ");
769 if (reg & ATH9K_INT_RXLP)
770 len += snprintf(buf + len, size - len, "RXLP ");
771 if (reg & ATH9K_INT_BB_WATCHDOG)
772 len += snprintf(buf + len, size - len, "BB_WATCHDOG ");
773 /* there are other IRQs if one wanted to add them. */
774 len += snprintf(buf + len, size - len, ")\n");
775
776 len += snprintf(buf + len, size - len,
777 "VIF Counts: AP: %i STA: %i MESH: %i WDS: %i"
778 " ADHOC: %i OTHER: %i nvifs: %hi beacon-vifs: %hi\n",
779 iter_data.naps, iter_data.nstations, iter_data.nmeshes,
780 iter_data.nwds, iter_data.nadhocs, iter_data.nothers,
781 sc->nvifs, sc->nbcnvifs);
782
783 len += snprintf(buf + len, size - len,
784 "Calculated-BSSID-Mask: %pM\n",
785 iter_data.mask);
786
787 if (len > size)
788 len = size;
789
790 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
791 kfree(buf);
792
793 return retval;
794}
795
Felix Fietkau066dae92010-11-07 14:59:39 +0100796void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100797 struct ath_tx_status *ts, struct ath_txq *txq)
Sujithfec247c2009-07-27 12:08:16 +0530798{
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100799 int qnum = txq->axq_qnum;
Felix Fietkau066dae92010-11-07 14:59:39 +0100800
801 TX_STAT_INC(qnum, tx_pkts_all);
802 sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len;
Ben Greear99c15bf2010-10-01 12:26:30 -0700803
Sujithfec247c2009-07-27 12:08:16 +0530804 if (bf_isampdu(bf)) {
805 if (bf_isxretried(bf))
Felix Fietkau066dae92010-11-07 14:59:39 +0100806 TX_STAT_INC(qnum, a_xretries);
Sujithfec247c2009-07-27 12:08:16 +0530807 else
Felix Fietkau066dae92010-11-07 14:59:39 +0100808 TX_STAT_INC(qnum, a_completed);
Sujithfec247c2009-07-27 12:08:16 +0530809 } else {
Felix Fietkau066dae92010-11-07 14:59:39 +0100810 TX_STAT_INC(qnum, completed);
Sujithfec247c2009-07-27 12:08:16 +0530811 }
812
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700813 if (ts->ts_status & ATH9K_TXERR_FIFO)
Felix Fietkau066dae92010-11-07 14:59:39 +0100814 TX_STAT_INC(qnum, fifo_underrun);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700815 if (ts->ts_status & ATH9K_TXERR_XTXOP)
Felix Fietkau066dae92010-11-07 14:59:39 +0100816 TX_STAT_INC(qnum, xtxop);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700817 if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED)
Felix Fietkau066dae92010-11-07 14:59:39 +0100818 TX_STAT_INC(qnum, timer_exp);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700819 if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR)
Felix Fietkau066dae92010-11-07 14:59:39 +0100820 TX_STAT_INC(qnum, desc_cfg_err);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700821 if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN)
Felix Fietkau066dae92010-11-07 14:59:39 +0100822 TX_STAT_INC(qnum, data_underrun);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700823 if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
Felix Fietkau066dae92010-11-07 14:59:39 +0100824 TX_STAT_INC(qnum, delim_underrun);
Sujithfec247c2009-07-27 12:08:16 +0530825}
826
827static const struct file_operations fops_xmit = {
828 .read = read_file_xmit,
829 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200830 .owner = THIS_MODULE,
831 .llseek = default_llseek,
Sujithfec247c2009-07-27 12:08:16 +0530832};
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200833
Ben Greear7f010c92011-01-09 23:11:49 -0800834static const struct file_operations fops_stations = {
835 .read = read_file_stations,
836 .open = ath9k_debugfs_open,
837 .owner = THIS_MODULE,
838 .llseek = default_llseek,
839};
840
Ben Greear55f6d0f2011-01-17 11:54:50 -0800841static const struct file_operations fops_misc = {
842 .read = read_file_misc,
843 .open = ath9k_debugfs_open,
844 .owner = THIS_MODULE,
845 .llseek = default_llseek,
846};
847
Sujith1395d3f2010-01-08 10:36:11 +0530848static ssize_t read_file_recv(struct file *file, char __user *user_buf,
849 size_t count, loff_t *ppos)
850{
851#define PHY_ERR(s, p) \
852 len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \
853 sc->debug.stats.rxstats.phy_err_stats[p]);
854
855 struct ath_softc *sc = file->private_data;
856 char *buf;
Senthil Balasubramanian7d755412011-04-08 15:30:34 +0530857 unsigned int len = 0, size = 1400;
Sujith1395d3f2010-01-08 10:36:11 +0530858 ssize_t retval = 0;
859
860 buf = kzalloc(size, GFP_KERNEL);
861 if (buf == NULL)
Dan Carpenter04236062010-05-14 15:25:39 +0200862 return -ENOMEM;
Sujith1395d3f2010-01-08 10:36:11 +0530863
864 len += snprintf(buf + len, size - len,
865 "%18s : %10u\n", "CRC ERR",
866 sc->debug.stats.rxstats.crc_err);
867 len += snprintf(buf + len, size - len,
868 "%18s : %10u\n", "DECRYPT CRC ERR",
869 sc->debug.stats.rxstats.decrypt_crc_err);
870 len += snprintf(buf + len, size - len,
871 "%18s : %10u\n", "PHY ERR",
872 sc->debug.stats.rxstats.phy_err);
873 len += snprintf(buf + len, size - len,
874 "%18s : %10u\n", "MIC ERR",
875 sc->debug.stats.rxstats.mic_err);
876 len += snprintf(buf + len, size - len,
877 "%18s : %10u\n", "PRE-DELIM CRC ERR",
878 sc->debug.stats.rxstats.pre_delim_crc_err);
879 len += snprintf(buf + len, size - len,
880 "%18s : %10u\n", "POST-DELIM CRC ERR",
881 sc->debug.stats.rxstats.post_delim_crc_err);
882 len += snprintf(buf + len, size - len,
883 "%18s : %10u\n", "DECRYPT BUSY ERR",
884 sc->debug.stats.rxstats.decrypt_busy_err);
885
Senthil Balasubramanian7d755412011-04-08 15:30:34 +0530886 len += snprintf(buf + len, size - len,
887 "%18s : %10d\n", "RSSI-CTL0",
888 sc->debug.stats.rxstats.rs_rssi_ctl0);
889
890 len += snprintf(buf + len, size - len,
891 "%18s : %10d\n", "RSSI-CTL1",
892 sc->debug.stats.rxstats.rs_rssi_ctl1);
893
894 len += snprintf(buf + len, size - len,
895 "%18s : %10d\n", "RSSI-CTL2",
896 sc->debug.stats.rxstats.rs_rssi_ctl2);
897
898 len += snprintf(buf + len, size - len,
899 "%18s : %10d\n", "RSSI-EXT0",
900 sc->debug.stats.rxstats.rs_rssi_ext0);
901
902 len += snprintf(buf + len, size - len,
903 "%18s : %10d\n", "RSSI-EXT1",
904 sc->debug.stats.rxstats.rs_rssi_ext1);
905
906 len += snprintf(buf + len, size - len,
907 "%18s : %10d\n", "RSSI-EXT2",
908 sc->debug.stats.rxstats.rs_rssi_ext2);
909
910 len += snprintf(buf + len, size - len,
911 "%18s : %10d\n", "Rx Antenna",
912 sc->debug.stats.rxstats.rs_antenna);
913
Sujith1395d3f2010-01-08 10:36:11 +0530914 PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN);
915 PHY_ERR("TIMING", ATH9K_PHYERR_TIMING);
916 PHY_ERR("PARITY", ATH9K_PHYERR_PARITY);
917 PHY_ERR("RATE", ATH9K_PHYERR_RATE);
918 PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH);
919 PHY_ERR("RADAR", ATH9K_PHYERR_RADAR);
920 PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE);
921 PHY_ERR("TOR", ATH9K_PHYERR_TOR);
922 PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING);
923 PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY);
924 PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL);
925 PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL);
926 PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP);
927 PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE);
928 PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART);
929 PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT);
930 PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING);
931 PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC);
932 PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL);
933 PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE);
934 PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART);
935 PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL);
936 PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP);
937 PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR);
938 PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
939 PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL);
940
Ben Greear99c15bf2010-10-01 12:26:30 -0700941 len += snprintf(buf + len, size - len,
942 "%18s : %10u\n", "RX-Pkts-All",
943 sc->debug.stats.rxstats.rx_pkts_all);
944 len += snprintf(buf + len, size - len,
945 "%18s : %10u\n", "RX-Bytes-All",
946 sc->debug.stats.rxstats.rx_bytes_all);
947
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200948 if (len > size)
949 len = size;
950
Sujith1395d3f2010-01-08 10:36:11 +0530951 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
952 kfree(buf);
953
954 return retval;
955
956#undef PHY_ERR
957}
958
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700959void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
Sujith1395d3f2010-01-08 10:36:11 +0530960{
961#define RX_STAT_INC(c) sc->debug.stats.rxstats.c++
962#define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
963
Sujith1395d3f2010-01-08 10:36:11 +0530964 u32 phyerr;
965
Ben Greear99c15bf2010-10-01 12:26:30 -0700966 RX_STAT_INC(rx_pkts_all);
967 sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen;
968
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700969 if (rs->rs_status & ATH9K_RXERR_CRC)
Sujith1395d3f2010-01-08 10:36:11 +0530970 RX_STAT_INC(crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700971 if (rs->rs_status & ATH9K_RXERR_DECRYPT)
Sujith1395d3f2010-01-08 10:36:11 +0530972 RX_STAT_INC(decrypt_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700973 if (rs->rs_status & ATH9K_RXERR_MIC)
Sujith1395d3f2010-01-08 10:36:11 +0530974 RX_STAT_INC(mic_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700975 if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE)
Sujith1395d3f2010-01-08 10:36:11 +0530976 RX_STAT_INC(pre_delim_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700977 if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST)
Sujith1395d3f2010-01-08 10:36:11 +0530978 RX_STAT_INC(post_delim_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700979 if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY)
Sujith1395d3f2010-01-08 10:36:11 +0530980 RX_STAT_INC(decrypt_busy_err);
981
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700982 if (rs->rs_status & ATH9K_RXERR_PHY) {
Sujith1395d3f2010-01-08 10:36:11 +0530983 RX_STAT_INC(phy_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700984 phyerr = rs->rs_phyerr & 0x24;
Sujith1395d3f2010-01-08 10:36:11 +0530985 RX_PHY_ERR_INC(phyerr);
986 }
987
Senthil Balasubramanian7d755412011-04-08 15:30:34 +0530988 sc->debug.stats.rxstats.rs_rssi_ctl0 = rs->rs_rssi_ctl0;
989 sc->debug.stats.rxstats.rs_rssi_ctl1 = rs->rs_rssi_ctl1;
990 sc->debug.stats.rxstats.rs_rssi_ctl2 = rs->rs_rssi_ctl2;
991
992 sc->debug.stats.rxstats.rs_rssi_ext0 = rs->rs_rssi_ext0;
993 sc->debug.stats.rxstats.rs_rssi_ext1 = rs->rs_rssi_ext1;
994 sc->debug.stats.rxstats.rs_rssi_ext2 = rs->rs_rssi_ext2;
995
996 sc->debug.stats.rxstats.rs_antenna = rs->rs_antenna;
997
Sujith1395d3f2010-01-08 10:36:11 +0530998#undef RX_STAT_INC
999#undef RX_PHY_ERR_INC
1000}
1001
1002static const struct file_operations fops_recv = {
1003 .read = read_file_recv,
1004 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001005 .owner = THIS_MODULE,
1006 .llseek = default_llseek,
Sujith1395d3f2010-01-08 10:36:11 +05301007};
1008
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001009static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
1010 size_t count, loff_t *ppos)
1011{
1012 struct ath_softc *sc = file->private_data;
1013 char buf[32];
1014 unsigned int len;
1015
Dan Carpenter2b87f3a2010-05-14 15:24:37 +02001016 len = sprintf(buf, "0x%08x\n", sc->debug.regidx);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001017 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1018}
1019
1020static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
1021 size_t count, loff_t *ppos)
1022{
1023 struct ath_softc *sc = file->private_data;
1024 unsigned long regidx;
1025 char buf[32];
1026 ssize_t len;
1027
1028 len = min(count, sizeof(buf) - 1);
1029 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +02001030 return -EFAULT;
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001031
1032 buf[len] = '\0';
1033 if (strict_strtoul(buf, 0, &regidx))
1034 return -EINVAL;
1035
1036 sc->debug.regidx = regidx;
1037 return count;
1038}
1039
1040static const struct file_operations fops_regidx = {
1041 .read = read_file_regidx,
1042 .write = write_file_regidx,
1043 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001044 .owner = THIS_MODULE,
1045 .llseek = default_llseek,
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001046};
1047
1048static ssize_t read_file_regval(struct file *file, char __user *user_buf,
1049 size_t count, loff_t *ppos)
1050{
1051 struct ath_softc *sc = file->private_data;
1052 struct ath_hw *ah = sc->sc_ah;
1053 char buf[32];
1054 unsigned int len;
1055 u32 regval;
1056
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301057 ath9k_ps_wakeup(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001058 regval = REG_READ_D(ah, sc->debug.regidx);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301059 ath9k_ps_restore(sc);
Dan Carpenter2b87f3a2010-05-14 15:24:37 +02001060 len = sprintf(buf, "0x%08x\n", regval);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001061 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1062}
1063
1064static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
1065 size_t count, loff_t *ppos)
1066{
1067 struct ath_softc *sc = file->private_data;
1068 struct ath_hw *ah = sc->sc_ah;
1069 unsigned long regval;
1070 char buf[32];
1071 ssize_t len;
1072
1073 len = min(count, sizeof(buf) - 1);
1074 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +02001075 return -EFAULT;
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001076
1077 buf[len] = '\0';
1078 if (strict_strtoul(buf, 0, &regval))
1079 return -EINVAL;
1080
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301081 ath9k_ps_wakeup(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001082 REG_WRITE_D(ah, sc->debug.regidx, regval);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301083 ath9k_ps_restore(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001084 return count;
1085}
1086
1087static const struct file_operations fops_regval = {
1088 .read = read_file_regval,
1089 .write = write_file_regval,
1090 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001091 .owner = THIS_MODULE,
1092 .llseek = default_llseek,
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001093};
1094
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -08001095#define REGDUMP_LINE_SIZE 20
1096
1097static int open_file_regdump(struct inode *inode, struct file *file)
1098{
1099 struct ath_softc *sc = inode->i_private;
1100 unsigned int len = 0;
1101 u8 *buf;
1102 int i;
1103 unsigned long num_regs, regdump_len, max_reg_offset;
1104
1105 max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500;
1106 num_regs = max_reg_offset / 4 + 1;
1107 regdump_len = num_regs * REGDUMP_LINE_SIZE + 1;
1108 buf = vmalloc(regdump_len);
1109 if (!buf)
1110 return -ENOMEM;
1111
1112 ath9k_ps_wakeup(sc);
1113 for (i = 0; i < num_regs; i++)
1114 len += scnprintf(buf + len, regdump_len - len,
1115 "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2));
1116 ath9k_ps_restore(sc);
1117
1118 file->private_data = buf;
1119
1120 return 0;
1121}
1122
1123static const struct file_operations fops_regdump = {
1124 .open = open_file_regdump,
1125 .read = ath9k_debugfs_read_buf,
1126 .release = ath9k_debugfs_release_buf,
1127 .owner = THIS_MODULE,
1128 .llseek = default_llseek,/* read accesses f_pos */
1129};
1130
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -07001131int ath9k_init_debug(struct ath_hw *ah)
Sujith88b126a2008-11-28 22:19:02 +05301132{
Luis R. Rodriguezbc974f42009-09-28 02:54:40 -04001133 struct ath_common *common = ath9k_hw_common(ah);
1134 struct ath_softc *sc = (struct ath_softc *) common->priv;
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -07001135
Ben Greeareb272442010-11-29 14:13:22 -08001136 sc->debug.debugfs_phy = debugfs_create_dir("ath9k",
1137 sc->hw->wiphy->debugfsdir);
Sujith17d79042009-02-09 13:27:03 +05301138 if (!sc->debug.debugfs_phy)
Felix Fietkauc8a72c02010-05-11 17:23:00 +02001139 return -ENOMEM;
Sujith826d2682008-11-28 22:20:23 +05301140
Felix Fietkaua830df02009-11-23 22:33:27 +01001141#ifdef CONFIG_ATH_DEBUG
Felix Fietkauc70cab12011-03-19 13:55:37 +01001142 debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1143 sc, &fops_debug);
Felix Fietkaua830df02009-11-23 22:33:27 +01001144#endif
Felix Fietkauc70cab12011-03-19 13:55:37 +01001145 debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
1146 &fops_dma);
1147 debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
1148 &fops_interrupt);
1149 debugfs_create_file("wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1150 sc, &fops_wiphy);
1151 debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc,
1152 &fops_xmit);
1153 debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc,
1154 &fops_stations);
1155 debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc,
1156 &fops_misc);
1157 debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc,
1158 &fops_recv);
1159 debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR,
1160 sc->debug.debugfs_phy, sc, &fops_rx_chainmask);
1161 debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR,
1162 sc->debug.debugfs_phy, sc, &fops_tx_chainmask);
1163 debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1164 sc, &fops_regidx);
1165 debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1166 sc, &fops_regval);
1167 debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR,
1168 sc->debug.debugfs_phy,
1169 &ah->config.cwm_ignore_extcca);
1170 debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc,
1171 &fops_regdump);
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -08001172
Felix Fietkau691680b2011-03-19 13:55:38 +01001173 debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
1174 sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
1175
1176 debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
1177 sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
1178
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001179 sc->debug.regidx = 0;
Sujith826d2682008-11-28 22:20:23 +05301180 return 0;
Sujith88b126a2008-11-28 22:19:02 +05301181}