blob: f9df82bdd21326500ce1ce4f47cdc80e8c558364 [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>
Paul Gortmakeree40fa02011-05-27 16:14:23 -040019#include <linux/export.h>
Gabor Juhos52103112009-03-06 09:57:39 +010020#include <asm/unaligned.h>
21
Sujith394cf0a2009-02-09 13:26:54 +053022#include "ath9k.h"
Sujith88b126a2008-11-28 22:19:02 +053023
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -040024#define REG_WRITE_D(_ah, _reg, _val) \
25 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
26#define REG_READ_D(_ah, _reg) \
27 ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
28
Sujith2a163c62008-11-28 22:21:08 +053029
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -080030static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf,
31 size_t count, loff_t *ppos)
32{
33 u8 *buf = file->private_data;
34 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
35}
36
37static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file)
38{
39 vfree(file->private_data);
40 return 0;
41}
42
Felix Fietkaua830df02009-11-23 22:33:27 +010043#ifdef CONFIG_ATH_DEBUG
44
Jeff Hansen24939282009-05-27 12:48:29 +000045static ssize_t read_file_debug(struct file *file, char __user *user_buf,
46 size_t count, loff_t *ppos)
47{
48 struct ath_softc *sc = file->private_data;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070049 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Jeff Hansen24939282009-05-27 12:48:29 +000050 char buf[32];
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053051 unsigned int len;
52
Dan Carpenter2b87f3a2010-05-14 15:24:37 +020053 len = sprintf(buf, "0x%08x\n", common->debug_mask);
Jeff Hansen24939282009-05-27 12:48:29 +000054 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
55}
56
57static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
58 size_t count, loff_t *ppos)
59{
60 struct ath_softc *sc = file->private_data;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070061 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Jeff Hansen24939282009-05-27 12:48:29 +000062 unsigned long mask;
63 char buf[32];
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053064 ssize_t len;
65
66 len = min(count, sizeof(buf) - 1);
67 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +020068 return -EFAULT;
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053069
70 buf[len] = '\0';
71 if (strict_strtoul(buf, 0, &mask))
72 return -EINVAL;
73
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070074 common->debug_mask = mask;
Jeff Hansen24939282009-05-27 12:48:29 +000075 return count;
76}
77
78static const struct file_operations fops_debug = {
79 .read = read_file_debug,
80 .write = write_file_debug,
Stephen Boyd234e3402012-04-05 14:25:11 -070081 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +020082 .owner = THIS_MODULE,
83 .llseek = default_llseek,
Jeff Hansen24939282009-05-27 12:48:29 +000084};
85
Felix Fietkaua830df02009-11-23 22:33:27 +010086#endif
87
Pavel Roskin991a0982010-01-29 17:22:26 -050088#define DMA_BUF_LEN 1024
89
Felix Fietkau15340692010-05-11 17:23:01 +020090static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf,
91 size_t count, loff_t *ppos)
92{
93 struct ath_softc *sc = file->private_data;
Felix Fietkau82b2d332011-09-03 01:40:23 +020094 struct ath_hw *ah = sc->sc_ah;
Felix Fietkau15340692010-05-11 17:23:01 +020095 char buf[32];
96 unsigned int len;
97
Felix Fietkau82b2d332011-09-03 01:40:23 +020098 len = sprintf(buf, "0x%08x\n", ah->txchainmask);
Felix Fietkau15340692010-05-11 17:23:01 +020099 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
100}
101
102static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf,
103 size_t count, loff_t *ppos)
104{
105 struct ath_softc *sc = file->private_data;
Felix Fietkau82b2d332011-09-03 01:40:23 +0200106 struct ath_hw *ah = sc->sc_ah;
Felix Fietkau15340692010-05-11 17:23:01 +0200107 unsigned long mask;
108 char buf[32];
109 ssize_t len;
110
111 len = min(count, sizeof(buf) - 1);
112 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +0200113 return -EFAULT;
Felix Fietkau15340692010-05-11 17:23:01 +0200114
115 buf[len] = '\0';
116 if (strict_strtoul(buf, 0, &mask))
117 return -EINVAL;
118
Felix Fietkau82b2d332011-09-03 01:40:23 +0200119 ah->txchainmask = mask;
120 ah->caps.tx_chainmask = mask;
Felix Fietkau15340692010-05-11 17:23:01 +0200121 return count;
122}
123
124static const struct file_operations fops_tx_chainmask = {
125 .read = read_file_tx_chainmask,
126 .write = write_file_tx_chainmask,
Stephen Boyd234e3402012-04-05 14:25:11 -0700127 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200128 .owner = THIS_MODULE,
129 .llseek = default_llseek,
Felix Fietkau15340692010-05-11 17:23:01 +0200130};
131
132
133static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf,
134 size_t count, loff_t *ppos)
135{
136 struct ath_softc *sc = file->private_data;
Felix Fietkau82b2d332011-09-03 01:40:23 +0200137 struct ath_hw *ah = sc->sc_ah;
Felix Fietkau15340692010-05-11 17:23:01 +0200138 char buf[32];
139 unsigned int len;
140
Felix Fietkau82b2d332011-09-03 01:40:23 +0200141 len = sprintf(buf, "0x%08x\n", ah->rxchainmask);
Felix Fietkau15340692010-05-11 17:23:01 +0200142 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
143}
144
145static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf,
146 size_t count, loff_t *ppos)
147{
148 struct ath_softc *sc = file->private_data;
Felix Fietkau82b2d332011-09-03 01:40:23 +0200149 struct ath_hw *ah = sc->sc_ah;
Felix Fietkau15340692010-05-11 17:23:01 +0200150 unsigned long mask;
151 char buf[32];
152 ssize_t len;
153
154 len = min(count, sizeof(buf) - 1);
155 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +0200156 return -EFAULT;
Felix Fietkau15340692010-05-11 17:23:01 +0200157
158 buf[len] = '\0';
159 if (strict_strtoul(buf, 0, &mask))
160 return -EINVAL;
161
Felix Fietkau82b2d332011-09-03 01:40:23 +0200162 ah->rxchainmask = mask;
163 ah->caps.rx_chainmask = mask;
Felix Fietkau15340692010-05-11 17:23:01 +0200164 return count;
165}
166
167static const struct file_operations fops_rx_chainmask = {
168 .read = read_file_rx_chainmask,
169 .write = write_file_rx_chainmask,
Stephen Boyd234e3402012-04-05 14:25:11 -0700170 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200171 .owner = THIS_MODULE,
172 .llseek = default_llseek,
Felix Fietkau15340692010-05-11 17:23:01 +0200173};
174
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530175static ssize_t read_file_disable_ani(struct file *file, char __user *user_buf,
176 size_t count, loff_t *ppos)
177{
178 struct ath_softc *sc = file->private_data;
179 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
180 char buf[32];
181 unsigned int len;
182
183 len = sprintf(buf, "%d\n", common->disable_ani);
184 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
185}
186
187static ssize_t write_file_disable_ani(struct file *file,
188 const char __user *user_buf,
189 size_t count, loff_t *ppos)
190{
191 struct ath_softc *sc = file->private_data;
192 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
193 unsigned long disable_ani;
194 char buf[32];
195 ssize_t len;
196
197 len = min(count, sizeof(buf) - 1);
198 if (copy_from_user(buf, user_buf, len))
199 return -EFAULT;
200
201 buf[len] = '\0';
202 if (strict_strtoul(buf, 0, &disable_ani))
203 return -EINVAL;
204
205 common->disable_ani = !!disable_ani;
206
207 if (disable_ani) {
Sujith Manoharan781b14a2012-06-04 20:23:55 +0530208 clear_bit(SC_OP_ANI_RUN, &sc->sc_flags);
Sujith Manoharanda0d45f2012-07-17 17:16:29 +0530209 ath_stop_ani(sc);
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530210 } else {
Sujith Manoharanda0d45f2012-07-17 17:16:29 +0530211 ath_check_ani(sc);
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530212 }
213
214 return count;
215}
216
217static const struct file_operations fops_disable_ani = {
218 .read = read_file_disable_ani,
219 .write = write_file_disable_ani,
Stephen Boyd234e3402012-04-05 14:25:11 -0700220 .open = simple_open,
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530221 .owner = THIS_MODULE,
222 .llseek = default_llseek,
223};
Felix Fietkau15340692010-05-11 17:23:01 +0200224
Sujith Manoharan302a3c32012-09-26 07:55:18 +0530225static ssize_t read_file_ant_diversity(struct file *file, char __user *user_buf,
226 size_t count, loff_t *ppos)
227{
228 struct ath_softc *sc = file->private_data;
229 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
230 char buf[32];
231 unsigned int len;
232
233 len = sprintf(buf, "%d\n", common->antenna_diversity);
234 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
235}
236
237static ssize_t write_file_ant_diversity(struct file *file,
238 const char __user *user_buf,
239 size_t count, loff_t *ppos)
240{
241 struct ath_softc *sc = file->private_data;
242 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
243 unsigned long antenna_diversity;
244 char buf[32];
245 ssize_t len;
246
247 len = min(count, sizeof(buf) - 1);
248 if (copy_from_user(buf, user_buf, len))
249 return -EFAULT;
250
251 if (!AR_SREV_9565(sc->sc_ah))
252 goto exit;
253
254 buf[len] = '\0';
255 if (strict_strtoul(buf, 0, &antenna_diversity))
256 return -EINVAL;
257
258 common->antenna_diversity = !!antenna_diversity;
259 ath9k_ps_wakeup(sc);
260 ath_ant_comb_update(sc);
261 ath_dbg(common, CONFIG, "Antenna diversity: %d\n",
262 common->antenna_diversity);
263 ath9k_ps_restore(sc);
264exit:
265 return count;
266}
267
268static const struct file_operations fops_ant_diversity = {
269 .read = read_file_ant_diversity,
270 .write = write_file_ant_diversity,
271 .open = simple_open,
272 .owner = THIS_MODULE,
273 .llseek = default_llseek,
274};
275
Sujith2a163c62008-11-28 22:21:08 +0530276static ssize_t read_file_dma(struct file *file, char __user *user_buf,
277 size_t count, loff_t *ppos)
278{
279 struct ath_softc *sc = file->private_data;
Sujithcbe61d82009-02-09 13:27:12 +0530280 struct ath_hw *ah = sc->sc_ah;
Pavel Roskin991a0982010-01-29 17:22:26 -0500281 char *buf;
282 int retval;
Sujith2a163c62008-11-28 22:21:08 +0530283 unsigned int len = 0;
284 u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
285 int i, qcuOffset = 0, dcuOffset = 0;
286 u32 *qcuBase = &val[0], *dcuBase = &val[4];
287
Pavel Roskin991a0982010-01-29 17:22:26 -0500288 buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL);
289 if (!buf)
Dan Carpenter04236062010-05-14 15:25:39 +0200290 return -ENOMEM;
Pavel Roskin991a0982010-01-29 17:22:26 -0500291
Sujith7cf4a2e2009-08-26 11:11:57 +0530292 ath9k_ps_wakeup(sc);
293
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400294 REG_WRITE_D(ah, AR_MACMISC,
Sujith2a163c62008-11-28 22:21:08 +0530295 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
296 (AR_MACMISC_MISC_OBS_BUS_1 <<
297 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
298
Pavel Roskin991a0982010-01-29 17:22:26 -0500299 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530300 "Raw DMA Debug values:\n");
301
302 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
303 if (i % 4 == 0)
Pavel Roskin991a0982010-01-29 17:22:26 -0500304 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
Sujith2a163c62008-11-28 22:21:08 +0530305
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400306 val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
Pavel Roskin991a0982010-01-29 17:22:26 -0500307 len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ",
Sujith2a163c62008-11-28 22:21:08 +0530308 i, val[i]);
309 }
310
Pavel Roskin991a0982010-01-29 17:22:26 -0500311 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n");
312 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530313 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
314
315 for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
316 if (i == 8) {
317 qcuOffset = 0;
318 qcuBase++;
319 }
320
321 if (i == 6) {
322 dcuOffset = 0;
323 dcuBase++;
324 }
325
Pavel Roskin991a0982010-01-29 17:22:26 -0500326 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530327 "%2d %2x %1x %2x %2x\n",
328 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
329 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
330 val[2] & (0x7 << (i * 3)) >> (i * 3),
331 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
332 }
333
Pavel Roskin991a0982010-01-29 17:22:26 -0500334 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
Sujith2a163c62008-11-28 22:21:08 +0530335
Pavel Roskin991a0982010-01-29 17:22:26 -0500336 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530337 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
338 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
Pavel Roskin991a0982010-01-29 17:22:26 -0500339 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530340 "qcu_complete state: %2x dcu_complete state: %2x\n",
341 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
Pavel Roskin991a0982010-01-29 17:22:26 -0500342 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530343 "dcu_arb state: %2x dcu_fp state: %2x\n",
344 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
Pavel Roskin991a0982010-01-29 17:22:26 -0500345 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530346 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
347 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
Pavel Roskin991a0982010-01-29 17:22:26 -0500348 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530349 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
350 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
Pavel Roskin991a0982010-01-29 17:22:26 -0500351 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530352 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
353 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
354
Frans Pop60ece402010-03-24 19:46:30 +0100355 len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n",
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400356 REG_READ_D(ah, AR_OBS_BUS_1));
Pavel Roskin991a0982010-01-29 17:22:26 -0500357 len += snprintf(buf + len, DMA_BUF_LEN - len,
Frans Pop60ece402010-03-24 19:46:30 +0100358 "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR));
Sujith2a163c62008-11-28 22:21:08 +0530359
Sujith7cf4a2e2009-08-26 11:11:57 +0530360 ath9k_ps_restore(sc);
361
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200362 if (len > DMA_BUF_LEN)
363 len = DMA_BUF_LEN;
364
Pavel Roskin991a0982010-01-29 17:22:26 -0500365 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
366 kfree(buf);
367 return retval;
Sujith2a163c62008-11-28 22:21:08 +0530368}
369
370static const struct file_operations fops_dma = {
371 .read = read_file_dma,
Stephen Boyd234e3402012-04-05 14:25:11 -0700372 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200373 .owner = THIS_MODULE,
374 .llseek = default_llseek,
Sujith2a163c62008-11-28 22:21:08 +0530375};
376
Sujith817e11d2008-12-07 21:42:44 +0530377
378void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status)
379{
380 if (status)
Sujith17d79042009-02-09 13:27:03 +0530381 sc->debug.stats.istats.total++;
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400382 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
383 if (status & ATH9K_INT_RXLP)
384 sc->debug.stats.istats.rxlp++;
385 if (status & ATH9K_INT_RXHP)
386 sc->debug.stats.istats.rxhp++;
Luis R. Rodriguez08578b82010-05-13 13:33:44 -0400387 if (status & ATH9K_INT_BB_WATCHDOG)
388 sc->debug.stats.istats.bb_watchdog++;
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400389 } else {
390 if (status & ATH9K_INT_RX)
391 sc->debug.stats.istats.rxok++;
392 }
Sujith817e11d2008-12-07 21:42:44 +0530393 if (status & ATH9K_INT_RXEOL)
Sujith17d79042009-02-09 13:27:03 +0530394 sc->debug.stats.istats.rxeol++;
Sujith817e11d2008-12-07 21:42:44 +0530395 if (status & ATH9K_INT_RXORN)
Sujith17d79042009-02-09 13:27:03 +0530396 sc->debug.stats.istats.rxorn++;
Sujith817e11d2008-12-07 21:42:44 +0530397 if (status & ATH9K_INT_TX)
Sujith17d79042009-02-09 13:27:03 +0530398 sc->debug.stats.istats.txok++;
Sujith817e11d2008-12-07 21:42:44 +0530399 if (status & ATH9K_INT_TXURN)
Sujith17d79042009-02-09 13:27:03 +0530400 sc->debug.stats.istats.txurn++;
Sujith817e11d2008-12-07 21:42:44 +0530401 if (status & ATH9K_INT_RXPHY)
Sujith17d79042009-02-09 13:27:03 +0530402 sc->debug.stats.istats.rxphyerr++;
Sujith817e11d2008-12-07 21:42:44 +0530403 if (status & ATH9K_INT_RXKCM)
Sujith17d79042009-02-09 13:27:03 +0530404 sc->debug.stats.istats.rx_keycache_miss++;
Sujith817e11d2008-12-07 21:42:44 +0530405 if (status & ATH9K_INT_SWBA)
Sujith17d79042009-02-09 13:27:03 +0530406 sc->debug.stats.istats.swba++;
Sujith817e11d2008-12-07 21:42:44 +0530407 if (status & ATH9K_INT_BMISS)
Sujith17d79042009-02-09 13:27:03 +0530408 sc->debug.stats.istats.bmiss++;
Sujith817e11d2008-12-07 21:42:44 +0530409 if (status & ATH9K_INT_BNR)
Sujith17d79042009-02-09 13:27:03 +0530410 sc->debug.stats.istats.bnr++;
Sujith817e11d2008-12-07 21:42:44 +0530411 if (status & ATH9K_INT_CST)
Sujith17d79042009-02-09 13:27:03 +0530412 sc->debug.stats.istats.cst++;
Sujith817e11d2008-12-07 21:42:44 +0530413 if (status & ATH9K_INT_GTT)
Sujith17d79042009-02-09 13:27:03 +0530414 sc->debug.stats.istats.gtt++;
Sujith817e11d2008-12-07 21:42:44 +0530415 if (status & ATH9K_INT_TIM)
Sujith17d79042009-02-09 13:27:03 +0530416 sc->debug.stats.istats.tim++;
Sujith817e11d2008-12-07 21:42:44 +0530417 if (status & ATH9K_INT_CABEND)
Sujith17d79042009-02-09 13:27:03 +0530418 sc->debug.stats.istats.cabend++;
Sujith817e11d2008-12-07 21:42:44 +0530419 if (status & ATH9K_INT_DTIMSYNC)
Sujith17d79042009-02-09 13:27:03 +0530420 sc->debug.stats.istats.dtimsync++;
Sujith817e11d2008-12-07 21:42:44 +0530421 if (status & ATH9K_INT_DTIM)
Sujith17d79042009-02-09 13:27:03 +0530422 sc->debug.stats.istats.dtim++;
Mohammed Shafi Shajakhan6dde1aa2011-04-22 17:27:01 +0530423 if (status & ATH9K_INT_TSFOOR)
424 sc->debug.stats.istats.tsfoor++;
Sujith Manoharan97ba5152012-06-04 16:27:41 +0530425 if (status & ATH9K_INT_MCI)
426 sc->debug.stats.istats.mci++;
Mohammed Shafi Shajakhanc9e6e982012-09-07 15:54:13 +0530427 if (status & ATH9K_INT_GENTIMER)
428 sc->debug.stats.istats.gen_timer++;
Sujith817e11d2008-12-07 21:42:44 +0530429}
430
431static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
432 size_t count, loff_t *ppos)
433{
434 struct ath_softc *sc = file->private_data;
Sujith817e11d2008-12-07 21:42:44 +0530435 unsigned int len = 0;
Ben Greear462e58f2012-04-12 10:04:00 -0700436 int rv;
437 int mxlen = 4000;
438 char *buf = kmalloc(mxlen, GFP_KERNEL);
439 if (!buf)
440 return -ENOMEM;
441
442#define PR_IS(a, s) \
443 do { \
444 len += snprintf(buf + len, mxlen - len, \
445 "%21s: %10u\n", a, \
446 sc->debug.stats.istats.s); \
447 } while (0)
Sujith817e11d2008-12-07 21:42:44 +0530448
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400449 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
Ben Greear462e58f2012-04-12 10:04:00 -0700450 PR_IS("RXLP", rxlp);
451 PR_IS("RXHP", rxhp);
452 PR_IS("WATHDOG", bb_watchdog);
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400453 } else {
Ben Greear462e58f2012-04-12 10:04:00 -0700454 PR_IS("RX", rxok);
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400455 }
Ben Greear462e58f2012-04-12 10:04:00 -0700456 PR_IS("RXEOL", rxeol);
457 PR_IS("RXORN", rxorn);
458 PR_IS("TX", txok);
459 PR_IS("TXURN", txurn);
460 PR_IS("MIB", mib);
461 PR_IS("RXPHY", rxphyerr);
462 PR_IS("RXKCM", rx_keycache_miss);
463 PR_IS("SWBA", swba);
464 PR_IS("BMISS", bmiss);
465 PR_IS("BNR", bnr);
466 PR_IS("CST", cst);
467 PR_IS("GTT", gtt);
468 PR_IS("TIM", tim);
469 PR_IS("CABEND", cabend);
470 PR_IS("DTIMSYNC", dtimsync);
471 PR_IS("DTIM", dtim);
472 PR_IS("TSFOOR", tsfoor);
Sujith Manoharan97ba5152012-06-04 16:27:41 +0530473 PR_IS("MCI", mci);
Mohammed Shafi Shajakhanc9e6e982012-09-07 15:54:13 +0530474 PR_IS("GENTIMER", gen_timer);
Ben Greear462e58f2012-04-12 10:04:00 -0700475 PR_IS("TOTAL", total);
Sujith817e11d2008-12-07 21:42:44 +0530476
Ben Greear462e58f2012-04-12 10:04:00 -0700477 len += snprintf(buf + len, mxlen - len,
478 "SYNC_CAUSE stats:\n");
Mohammed Shafi Shajakhan6dde1aa2011-04-22 17:27:01 +0530479
Ben Greear462e58f2012-04-12 10:04:00 -0700480 PR_IS("Sync-All", sync_cause_all);
481 PR_IS("RTC-IRQ", sync_rtc_irq);
482 PR_IS("MAC-IRQ", sync_mac_irq);
483 PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access);
484 PR_IS("APB-Timeout", apb_timeout);
485 PR_IS("PCI-Mode-Conflict", pci_mode_conflict);
486 PR_IS("HOST1-Fatal", host1_fatal);
487 PR_IS("HOST1-Perr", host1_perr);
488 PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr);
489 PR_IS("RADM-CPL-EP", radm_cpl_ep);
490 PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort);
491 PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort);
492 PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err);
493 PR_IS("RADM-CPL-Timeout", radm_cpl_timeout);
494 PR_IS("Local-Bus-Timeout", local_timeout);
495 PR_IS("PM-Access", pm_access);
496 PR_IS("MAC-Awake", mac_awake);
497 PR_IS("MAC-Asleep", mac_asleep);
498 PR_IS("MAC-Sleep-Access", mac_sleep_access);
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200499
Ben Greear462e58f2012-04-12 10:04:00 -0700500 if (len > mxlen)
501 len = mxlen;
502
503 rv = simple_read_from_buffer(user_buf, count, ppos, buf, len);
504 kfree(buf);
505 return rv;
Sujith817e11d2008-12-07 21:42:44 +0530506}
507
508static const struct file_operations fops_interrupt = {
509 .read = read_file_interrupt,
Stephen Boyd234e3402012-04-05 14:25:11 -0700510 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200511 .owner = THIS_MODULE,
512 .llseek = default_llseek,
Sujith817e11d2008-12-07 21:42:44 +0530513};
514
Sujithfec247c2009-07-27 12:08:16 +0530515static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
516 size_t count, loff_t *ppos)
517{
518 struct ath_softc *sc = file->private_data;
519 char *buf;
Sujith Manoharan78ef7312012-11-21 18:13:11 +0530520 unsigned int len = 0, size = 2048;
Sujithfec247c2009-07-27 12:08:16 +0530521 ssize_t retval = 0;
522
523 buf = kzalloc(size, GFP_KERNEL);
524 if (buf == NULL)
Dan Carpenter04236062010-05-14 15:25:39 +0200525 return -ENOMEM;
Sujithfec247c2009-07-27 12:08:16 +0530526
Sujith Manoharan78ef7312012-11-21 18:13:11 +0530527 len += sprintf(buf, "%30s %10s%10s%10s\n\n",
Ben Greear7f010c92011-01-09 23:11:49 -0800528 "BE", "BK", "VI", "VO");
Sujithfec247c2009-07-27 12:08:16 +0530529
530 PR("MPDUs Queued: ", queued);
531 PR("MPDUs Completed: ", completed);
Felix Fietkau5a6f78a2011-05-31 21:21:41 +0200532 PR("MPDUs XRetried: ", xretries);
Sujithfec247c2009-07-27 12:08:16 +0530533 PR("Aggregates: ", a_aggr);
Ben Greearbda8add2011-01-09 23:11:48 -0800534 PR("AMPDUs Queued HW:", a_queued_hw);
535 PR("AMPDUs Queued SW:", a_queued_sw);
Sujithfec247c2009-07-27 12:08:16 +0530536 PR("AMPDUs Completed:", a_completed);
537 PR("AMPDUs Retried: ", a_retries);
538 PR("AMPDUs XRetried: ", a_xretries);
539 PR("FIFO Underrun: ", fifo_underrun);
540 PR("TXOP Exceeded: ", xtxop);
541 PR("TXTIMER Expiry: ", timer_exp);
542 PR("DESC CFG Error: ", desc_cfg_err);
543 PR("DATA Underrun: ", data_underrun);
544 PR("DELIM Underrun: ", delim_underrun);
Ben Greear99c15bf2010-10-01 12:26:30 -0700545 PR("TX-Pkts-All: ", tx_pkts_all);
546 PR("TX-Bytes-All: ", tx_bytes_all);
Sujith Manoharan78ef7312012-11-21 18:13:11 +0530547 PR("HW-put-tx-buf: ", puttxbuf);
548 PR("HW-tx-start: ", txstart);
549 PR("HW-tx-proc-desc: ", txprocdesc);
Ben Greeara5a0bca2012-04-03 09:16:55 -0700550 PR("TX-Failed: ", txfailed);
Sujithfec247c2009-07-27 12:08:16 +0530551
Ben Greear7f010c92011-01-09 23:11:49 -0800552 if (len > size)
553 len = size;
554
555 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
556 kfree(buf);
557
558 return retval;
559}
560
561static ssize_t read_file_stations(struct file *file, char __user *user_buf,
562 size_t count, loff_t *ppos)
563{
564 struct ath_softc *sc = file->private_data;
565 char *buf;
566 unsigned int len = 0, size = 64000;
567 struct ath_node *an = NULL;
568 ssize_t retval = 0;
569 int q;
570
571 buf = kzalloc(size, GFP_KERNEL);
572 if (buf == NULL)
573 return -ENOMEM;
574
575 len += snprintf(buf + len, size - len,
576 "Stations:\n"
Ben Greear7e1e3862011-11-03 11:33:13 -0700577 " tid: addr sched paused buf_q-empty an ac baw\n"
Ben Greear7f010c92011-01-09 23:11:49 -0800578 " ac: addr sched tid_q-empty txq\n");
579
580 spin_lock(&sc->nodes_lock);
581 list_for_each_entry(an, &sc->nodes, list) {
Ben Greear7e1e3862011-11-03 11:33:13 -0700582 unsigned short ma = an->maxampdu;
583 if (ma == 0)
584 ma = 65535; /* see ath_lookup_rate */
Ben Greear7f010c92011-01-09 23:11:49 -0800585 len += snprintf(buf + len, size - len,
Ben Greear7e1e3862011-11-03 11:33:13 -0700586 "iface: %pM sta: %pM max-ampdu: %hu mpdu-density: %uus\n",
587 an->vif->addr, an->sta->addr, ma,
588 (unsigned int)(an->mpdudensity));
Ben Greear7f010c92011-01-09 23:11:49 -0800589 if (len >= size)
590 goto done;
591
592 for (q = 0; q < WME_NUM_TID; q++) {
593 struct ath_atx_tid *tid = &(an->tid[q]);
594 len += snprintf(buf + len, size - len,
Ben Greear7e1e3862011-11-03 11:33:13 -0700595 " tid: %p %s %s %i %p %p %hu\n",
Ben Greear7f010c92011-01-09 23:11:49 -0800596 tid, tid->sched ? "sched" : "idle",
597 tid->paused ? "paused" : "running",
Felix Fietkau56dc6332011-08-28 00:32:22 +0200598 skb_queue_empty(&tid->buf_q),
Ben Greear7e1e3862011-11-03 11:33:13 -0700599 tid->an, tid->ac, tid->baw_size);
Ben Greear7f010c92011-01-09 23:11:49 -0800600 if (len >= size)
601 goto done;
602 }
603
Sujith Manoharanbea843c2012-11-21 18:13:10 +0530604 for (q = 0; q < IEEE80211_NUM_ACS; q++) {
Ben Greear7f010c92011-01-09 23:11:49 -0800605 struct ath_atx_ac *ac = &(an->ac[q]);
606 len += snprintf(buf + len, size - len,
607 " ac: %p %s %i %p\n",
608 ac, ac->sched ? "sched" : "idle",
609 list_empty(&ac->tid_q), ac->txq);
610 if (len >= size)
611 goto done;
612 }
613 }
614
615done:
616 spin_unlock(&sc->nodes_lock);
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200617 if (len > size)
618 len = size;
619
Sujithfec247c2009-07-27 12:08:16 +0530620 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
621 kfree(buf);
622
623 return retval;
624}
625
Ben Greear55f6d0f2011-01-17 11:54:50 -0800626static ssize_t read_file_misc(struct file *file, char __user *user_buf,
627 size_t count, loff_t *ppos)
628{
629 struct ath_softc *sc = file->private_data;
630 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Ben Greear55f6d0f2011-01-17 11:54:50 -0800631 struct ieee80211_hw *hw = sc->hw;
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530632 struct ath9k_vif_iter_data iter_data;
633 char buf[512];
634 unsigned int len = 0;
Ben Greear55f6d0f2011-01-17 11:54:50 -0800635 ssize_t retval = 0;
Ben Greear55f6d0f2011-01-17 11:54:50 -0800636 unsigned int reg;
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530637 u32 rxfilter;
Ben Greear55f6d0f2011-01-17 11:54:50 -0800638
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530639 len += snprintf(buf + len, sizeof(buf) - len,
640 "BSSID: %pM\n", common->curbssid);
641 len += snprintf(buf + len, sizeof(buf) - len,
642 "BSSID-MASK: %pM\n", common->bssidmask);
643 len += snprintf(buf + len, sizeof(buf) - len,
644 "OPMODE: %s\n", ath_opmode_to_string(sc->sc_ah->opmode));
Ben Greear55f6d0f2011-01-17 11:54:50 -0800645
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +0530646 ath9k_ps_wakeup(sc);
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530647 rxfilter = ath9k_hw_getrxfilter(sc->sc_ah);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +0530648 ath9k_ps_restore(sc);
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530649
650 len += snprintf(buf + len, sizeof(buf) - len,
651 "RXFILTER: 0x%x", rxfilter);
652
653 if (rxfilter & ATH9K_RX_FILTER_UCAST)
654 len += snprintf(buf + len, sizeof(buf) - len, " UCAST");
655 if (rxfilter & ATH9K_RX_FILTER_MCAST)
656 len += snprintf(buf + len, sizeof(buf) - len, " MCAST");
657 if (rxfilter & ATH9K_RX_FILTER_BCAST)
658 len += snprintf(buf + len, sizeof(buf) - len, " BCAST");
659 if (rxfilter & ATH9K_RX_FILTER_CONTROL)
660 len += snprintf(buf + len, sizeof(buf) - len, " CONTROL");
661 if (rxfilter & ATH9K_RX_FILTER_BEACON)
662 len += snprintf(buf + len, sizeof(buf) - len, " BEACON");
663 if (rxfilter & ATH9K_RX_FILTER_PROM)
664 len += snprintf(buf + len, sizeof(buf) - len, " PROM");
665 if (rxfilter & ATH9K_RX_FILTER_PROBEREQ)
666 len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ");
667 if (rxfilter & ATH9K_RX_FILTER_PHYERR)
668 len += snprintf(buf + len, sizeof(buf) - len, " PHYERR");
669 if (rxfilter & ATH9K_RX_FILTER_MYBEACON)
670 len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON");
671 if (rxfilter & ATH9K_RX_FILTER_COMP_BAR)
672 len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR");
673 if (rxfilter & ATH9K_RX_FILTER_PSPOLL)
674 len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL");
675 if (rxfilter & ATH9K_RX_FILTER_PHYRADAR)
676 len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR");
677 if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL)
678 len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL");
679 if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER)
680 len += snprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER");
681
682 len += snprintf(buf + len, sizeof(buf) - len, "\n");
Ben Greear55f6d0f2011-01-17 11:54:50 -0800683
684 reg = sc->sc_ah->imask;
Ben Greear55f6d0f2011-01-17 11:54:50 -0800685
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530686 len += snprintf(buf + len, sizeof(buf) - len, "INTERRUPT-MASK: 0x%x", reg);
687
688 if (reg & ATH9K_INT_SWBA)
689 len += snprintf(buf + len, sizeof(buf) - len, " SWBA");
690 if (reg & ATH9K_INT_BMISS)
691 len += snprintf(buf + len, sizeof(buf) - len, " BMISS");
692 if (reg & ATH9K_INT_CST)
693 len += snprintf(buf + len, sizeof(buf) - len, " CST");
694 if (reg & ATH9K_INT_RX)
695 len += snprintf(buf + len, sizeof(buf) - len, " RX");
696 if (reg & ATH9K_INT_RXHP)
697 len += snprintf(buf + len, sizeof(buf) - len, " RXHP");
698 if (reg & ATH9K_INT_RXLP)
699 len += snprintf(buf + len, sizeof(buf) - len, " RXLP");
700 if (reg & ATH9K_INT_BB_WATCHDOG)
701 len += snprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG");
702
703 len += snprintf(buf + len, sizeof(buf) - len, "\n");
704
705 ath9k_calculate_iter_data(hw, NULL, &iter_data);
706
707 len += snprintf(buf + len, sizeof(buf) - len,
708 "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i"
Sujith Manoharanbcf6f962012-03-14 14:40:38 +0530709 " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n",
Ben Greear55f6d0f2011-01-17 11:54:50 -0800710 iter_data.naps, iter_data.nstations, iter_data.nmeshes,
Sujith Manoharanbcf6f962012-03-14 14:40:38 +0530711 iter_data.nwds, iter_data.nadhocs,
Ben Greear55f6d0f2011-01-17 11:54:50 -0800712 sc->nvifs, sc->nbcnvifs);
713
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530714 if (len > sizeof(buf))
715 len = sizeof(buf);
Ben Greear55f6d0f2011-01-17 11:54:50 -0800716
717 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
Ben Greear55f6d0f2011-01-17 11:54:50 -0800718 return retval;
719}
720
Sujith Manoharanf8b815d2012-02-16 11:51:11 +0530721static ssize_t read_file_reset(struct file *file, char __user *user_buf,
722 size_t count, loff_t *ppos)
723{
724 struct ath_softc *sc = file->private_data;
725 char buf[512];
726 unsigned int len = 0;
727
728 len += snprintf(buf + len, sizeof(buf) - len,
729 "%17s: %2d\n", "Baseband Hang",
730 sc->debug.stats.reset[RESET_TYPE_BB_HANG]);
731 len += snprintf(buf + len, sizeof(buf) - len,
732 "%17s: %2d\n", "Baseband Watchdog",
733 sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]);
734 len += snprintf(buf + len, sizeof(buf) - len,
735 "%17s: %2d\n", "Fatal HW Error",
736 sc->debug.stats.reset[RESET_TYPE_FATAL_INT]);
737 len += snprintf(buf + len, sizeof(buf) - len,
738 "%17s: %2d\n", "TX HW error",
739 sc->debug.stats.reset[RESET_TYPE_TX_ERROR]);
740 len += snprintf(buf + len, sizeof(buf) - len,
741 "%17s: %2d\n", "TX Path Hang",
742 sc->debug.stats.reset[RESET_TYPE_TX_HANG]);
743 len += snprintf(buf + len, sizeof(buf) - len,
744 "%17s: %2d\n", "PLL RX Hang",
745 sc->debug.stats.reset[RESET_TYPE_PLL_HANG]);
Rajkumar Manoharanb88083b2012-11-20 18:30:00 +0530746 len += snprintf(buf + len, sizeof(buf) - len,
747 "%17s: %2d\n", "MCI Reset",
748 sc->debug.stats.reset[RESET_TYPE_MCI]);
Sujith Manoharanf8b815d2012-02-16 11:51:11 +0530749
750 if (len > sizeof(buf))
751 len = sizeof(buf);
752
753 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
754}
755
Felix Fietkau066dae92010-11-07 14:59:39 +0100756void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
Felix Fietkau55797b12011-09-14 21:24:16 +0200757 struct ath_tx_status *ts, struct ath_txq *txq,
758 unsigned int flags)
Sujithfec247c2009-07-27 12:08:16 +0530759{
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530760#define TX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].ts\
761 [sc->debug.tsidx].c)
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100762 int qnum = txq->axq_qnum;
Felix Fietkau066dae92010-11-07 14:59:39 +0100763
764 TX_STAT_INC(qnum, tx_pkts_all);
765 sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len;
Ben Greear99c15bf2010-10-01 12:26:30 -0700766
Sujithfec247c2009-07-27 12:08:16 +0530767 if (bf_isampdu(bf)) {
Felix Fietkau156369f2011-12-14 22:08:04 +0100768 if (flags & ATH_TX_ERROR)
Felix Fietkau066dae92010-11-07 14:59:39 +0100769 TX_STAT_INC(qnum, a_xretries);
Sujithfec247c2009-07-27 12:08:16 +0530770 else
Felix Fietkau066dae92010-11-07 14:59:39 +0100771 TX_STAT_INC(qnum, a_completed);
Sujithfec247c2009-07-27 12:08:16 +0530772 } else {
Felix Fietkau55797b12011-09-14 21:24:16 +0200773 if (ts->ts_status & ATH9K_TXERR_XRETRY)
Felix Fietkau5a6f78a2011-05-31 21:21:41 +0200774 TX_STAT_INC(qnum, xretries);
775 else
776 TX_STAT_INC(qnum, completed);
Sujithfec247c2009-07-27 12:08:16 +0530777 }
778
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700779 if (ts->ts_status & ATH9K_TXERR_FIFO)
Felix Fietkau066dae92010-11-07 14:59:39 +0100780 TX_STAT_INC(qnum, fifo_underrun);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700781 if (ts->ts_status & ATH9K_TXERR_XTXOP)
Felix Fietkau066dae92010-11-07 14:59:39 +0100782 TX_STAT_INC(qnum, xtxop);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700783 if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED)
Felix Fietkau066dae92010-11-07 14:59:39 +0100784 TX_STAT_INC(qnum, timer_exp);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700785 if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR)
Felix Fietkau066dae92010-11-07 14:59:39 +0100786 TX_STAT_INC(qnum, desc_cfg_err);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700787 if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN)
Felix Fietkau066dae92010-11-07 14:59:39 +0100788 TX_STAT_INC(qnum, data_underrun);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700789 if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
Felix Fietkau066dae92010-11-07 14:59:39 +0100790 TX_STAT_INC(qnum, delim_underrun);
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530791
Felix Fietkau5baec742012-03-03 15:17:03 +0100792#ifdef CONFIG_ATH9K_MAC_DEBUG
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530793 spin_lock(&sc->debug.samp_lock);
794 TX_SAMP_DBG(jiffies) = jiffies;
795 TX_SAMP_DBG(rssi_ctl0) = ts->ts_rssi_ctl0;
796 TX_SAMP_DBG(rssi_ctl1) = ts->ts_rssi_ctl1;
797 TX_SAMP_DBG(rssi_ctl2) = ts->ts_rssi_ctl2;
798 TX_SAMP_DBG(rssi_ext0) = ts->ts_rssi_ext0;
799 TX_SAMP_DBG(rssi_ext1) = ts->ts_rssi_ext1;
800 TX_SAMP_DBG(rssi_ext2) = ts->ts_rssi_ext2;
801 TX_SAMP_DBG(rateindex) = ts->ts_rateindex;
802 TX_SAMP_DBG(isok) = !!(ts->ts_status & ATH9K_TXERR_MASK);
803 TX_SAMP_DBG(rts_fail_cnt) = ts->ts_shortretry;
804 TX_SAMP_DBG(data_fail_cnt) = ts->ts_longretry;
805 TX_SAMP_DBG(rssi) = ts->ts_rssi;
806 TX_SAMP_DBG(tid) = ts->tid;
807 TX_SAMP_DBG(qid) = ts->qid;
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +0530808
809 if (ts->ts_flags & ATH9K_TX_BA) {
810 TX_SAMP_DBG(ba_low) = ts->ba_low;
811 TX_SAMP_DBG(ba_high) = ts->ba_high;
812 } else {
813 TX_SAMP_DBG(ba_low) = 0;
814 TX_SAMP_DBG(ba_high) = 0;
815 }
816
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530817 sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES;
818 spin_unlock(&sc->debug.samp_lock);
Felix Fietkau5baec742012-03-03 15:17:03 +0100819#endif
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530820
821#undef TX_SAMP_DBG
Sujithfec247c2009-07-27 12:08:16 +0530822}
823
824static const struct file_operations fops_xmit = {
825 .read = read_file_xmit,
Stephen Boyd234e3402012-04-05 14:25:11 -0700826 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200827 .owner = THIS_MODULE,
828 .llseek = default_llseek,
Sujithfec247c2009-07-27 12:08:16 +0530829};
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200830
Ben Greear7f010c92011-01-09 23:11:49 -0800831static const struct file_operations fops_stations = {
832 .read = read_file_stations,
Stephen Boyd234e3402012-04-05 14:25:11 -0700833 .open = simple_open,
Ben Greear7f010c92011-01-09 23:11:49 -0800834 .owner = THIS_MODULE,
835 .llseek = default_llseek,
836};
837
Ben Greear55f6d0f2011-01-17 11:54:50 -0800838static const struct file_operations fops_misc = {
839 .read = read_file_misc,
Stephen Boyd234e3402012-04-05 14:25:11 -0700840 .open = simple_open,
Ben Greear55f6d0f2011-01-17 11:54:50 -0800841 .owner = THIS_MODULE,
842 .llseek = default_llseek,
843};
844
Sujith Manoharanf8b815d2012-02-16 11:51:11 +0530845static const struct file_operations fops_reset = {
846 .read = read_file_reset,
Stephen Boyd234e3402012-04-05 14:25:11 -0700847 .open = simple_open,
Sujith Manoharanf8b815d2012-02-16 11:51:11 +0530848 .owner = THIS_MODULE,
849 .llseek = default_llseek,
850};
851
Sujith1395d3f2010-01-08 10:36:11 +0530852static ssize_t read_file_recv(struct file *file, char __user *user_buf,
853 size_t count, loff_t *ppos)
854{
855#define PHY_ERR(s, p) \
Sujith Manoharan42032142012-02-16 11:51:23 +0530856 len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \
Sujith1395d3f2010-01-08 10:36:11 +0530857 sc->debug.stats.rxstats.phy_err_stats[p]);
858
Ben Greear24a07312012-04-12 10:03:59 -0700859#define RXS_ERR(s, e) \
860 do { \
861 len += snprintf(buf + len, size - len, \
862 "%22s : %10u\n", s, \
863 sc->debug.stats.rxstats.e); \
864 } while (0)
865
Sujith1395d3f2010-01-08 10:36:11 +0530866 struct ath_softc *sc = file->private_data;
867 char *buf;
Sujith Manoharan42032142012-02-16 11:51:23 +0530868 unsigned int len = 0, size = 1600;
Sujith1395d3f2010-01-08 10:36:11 +0530869 ssize_t retval = 0;
870
871 buf = kzalloc(size, GFP_KERNEL);
872 if (buf == NULL)
Dan Carpenter04236062010-05-14 15:25:39 +0200873 return -ENOMEM;
Sujith1395d3f2010-01-08 10:36:11 +0530874
Ben Greear24a07312012-04-12 10:03:59 -0700875 RXS_ERR("CRC ERR", crc_err);
876 RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err);
877 RXS_ERR("PHY ERR", phy_err);
878 RXS_ERR("MIC ERR", mic_err);
879 RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err);
880 RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err);
881 RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err);
882 RXS_ERR("RX-LENGTH-ERR", rx_len_err);
883 RXS_ERR("RX-OOM-ERR", rx_oom_err);
884 RXS_ERR("RX-RATE-ERR", rx_rate_err);
885 RXS_ERR("RX-DROP-RXFLUSH", rx_drop_rxflush);
886 RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err);
Sujith1395d3f2010-01-08 10:36:11 +0530887
Sujith Manoharan42032142012-02-16 11:51:23 +0530888 PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN);
889 PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING);
890 PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY);
891 PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE);
892 PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH);
893 PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR);
894 PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE);
895 PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR);
896 PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING);
897 PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY);
898 PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL);
899 PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL);
900 PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP);
901 PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE);
902 PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART);
903 PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT);
904 PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING);
905 PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC);
906 PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL);
907 PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE);
908 PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART);
909 PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL);
910 PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP);
911 PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR);
912 PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
913 PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL);
914
Ben Greear24a07312012-04-12 10:03:59 -0700915 RXS_ERR("RX-Pkts-All", rx_pkts_all);
916 RXS_ERR("RX-Bytes-All", rx_bytes_all);
917 RXS_ERR("RX-Beacons", rx_beacons);
918 RXS_ERR("RX-Frags", rx_frags);
Ben Greear99c15bf2010-10-01 12:26:30 -0700919
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200920 if (len > size)
921 len = size;
922
Sujith1395d3f2010-01-08 10:36:11 +0530923 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
924 kfree(buf);
925
926 return retval;
927
Ben Greear24a07312012-04-12 10:03:59 -0700928#undef RXS_ERR
Sujith1395d3f2010-01-08 10:36:11 +0530929#undef PHY_ERR
930}
931
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700932void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
Sujith1395d3f2010-01-08 10:36:11 +0530933{
Sujith1395d3f2010-01-08 10:36:11 +0530934#define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530935#define RX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].rs\
936 [sc->debug.rsidx].c)
Sujith1395d3f2010-01-08 10:36:11 +0530937
Ben Greear99c15bf2010-10-01 12:26:30 -0700938 RX_STAT_INC(rx_pkts_all);
939 sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen;
940
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700941 if (rs->rs_status & ATH9K_RXERR_CRC)
Sujith1395d3f2010-01-08 10:36:11 +0530942 RX_STAT_INC(crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700943 if (rs->rs_status & ATH9K_RXERR_DECRYPT)
Sujith1395d3f2010-01-08 10:36:11 +0530944 RX_STAT_INC(decrypt_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700945 if (rs->rs_status & ATH9K_RXERR_MIC)
Sujith1395d3f2010-01-08 10:36:11 +0530946 RX_STAT_INC(mic_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700947 if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE)
Sujith1395d3f2010-01-08 10:36:11 +0530948 RX_STAT_INC(pre_delim_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700949 if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST)
Sujith1395d3f2010-01-08 10:36:11 +0530950 RX_STAT_INC(post_delim_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700951 if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY)
Sujith1395d3f2010-01-08 10:36:11 +0530952 RX_STAT_INC(decrypt_busy_err);
953
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700954 if (rs->rs_status & ATH9K_RXERR_PHY) {
Sujith1395d3f2010-01-08 10:36:11 +0530955 RX_STAT_INC(phy_err);
Sujith Manoharandbb07f02012-02-16 11:52:25 +0530956 if (rs->rs_phyerr < ATH9K_PHYERR_MAX)
957 RX_PHY_ERR_INC(rs->rs_phyerr);
Sujith1395d3f2010-01-08 10:36:11 +0530958 }
959
Felix Fietkau5baec742012-03-03 15:17:03 +0100960#ifdef CONFIG_ATH9K_MAC_DEBUG
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530961 spin_lock(&sc->debug.samp_lock);
962 RX_SAMP_DBG(jiffies) = jiffies;
963 RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0;
964 RX_SAMP_DBG(rssi_ctl1) = rs->rs_rssi_ctl1;
965 RX_SAMP_DBG(rssi_ctl2) = rs->rs_rssi_ctl2;
966 RX_SAMP_DBG(rssi_ext0) = rs->rs_rssi_ext0;
967 RX_SAMP_DBG(rssi_ext1) = rs->rs_rssi_ext1;
968 RX_SAMP_DBG(rssi_ext2) = rs->rs_rssi_ext2;
969 RX_SAMP_DBG(antenna) = rs->rs_antenna;
970 RX_SAMP_DBG(rssi) = rs->rs_rssi;
971 RX_SAMP_DBG(rate) = rs->rs_rate;
972 RX_SAMP_DBG(is_mybeacon) = rs->is_mybeacon;
973
974 sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES;
975 spin_unlock(&sc->debug.samp_lock);
976
Felix Fietkau5baec742012-03-03 15:17:03 +0100977#endif
978
Sujith1395d3f2010-01-08 10:36:11 +0530979#undef RX_PHY_ERR_INC
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530980#undef RX_SAMP_DBG
Sujith1395d3f2010-01-08 10:36:11 +0530981}
982
983static const struct file_operations fops_recv = {
984 .read = read_file_recv,
Stephen Boyd234e3402012-04-05 14:25:11 -0700985 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200986 .owner = THIS_MODULE,
987 .llseek = default_llseek,
Sujith1395d3f2010-01-08 10:36:11 +0530988};
989
Felix Fietkau9bff0bc2010-05-11 17:23:02 +0200990static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
991 size_t count, loff_t *ppos)
992{
993 struct ath_softc *sc = file->private_data;
994 char buf[32];
995 unsigned int len;
996
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200997 len = sprintf(buf, "0x%08x\n", sc->debug.regidx);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +0200998 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
999}
1000
1001static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
1002 size_t count, loff_t *ppos)
1003{
1004 struct ath_softc *sc = file->private_data;
1005 unsigned long regidx;
1006 char buf[32];
1007 ssize_t len;
1008
1009 len = min(count, sizeof(buf) - 1);
1010 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +02001011 return -EFAULT;
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001012
1013 buf[len] = '\0';
1014 if (strict_strtoul(buf, 0, &regidx))
1015 return -EINVAL;
1016
1017 sc->debug.regidx = regidx;
1018 return count;
1019}
1020
1021static const struct file_operations fops_regidx = {
1022 .read = read_file_regidx,
1023 .write = write_file_regidx,
Stephen Boyd234e3402012-04-05 14:25:11 -07001024 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001025 .owner = THIS_MODULE,
1026 .llseek = default_llseek,
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001027};
1028
1029static ssize_t read_file_regval(struct file *file, char __user *user_buf,
1030 size_t count, loff_t *ppos)
1031{
1032 struct ath_softc *sc = file->private_data;
1033 struct ath_hw *ah = sc->sc_ah;
1034 char buf[32];
1035 unsigned int len;
1036 u32 regval;
1037
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301038 ath9k_ps_wakeup(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001039 regval = REG_READ_D(ah, sc->debug.regidx);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301040 ath9k_ps_restore(sc);
Dan Carpenter2b87f3a2010-05-14 15:24:37 +02001041 len = sprintf(buf, "0x%08x\n", regval);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001042 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1043}
1044
1045static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
1046 size_t count, loff_t *ppos)
1047{
1048 struct ath_softc *sc = file->private_data;
1049 struct ath_hw *ah = sc->sc_ah;
1050 unsigned long regval;
1051 char buf[32];
1052 ssize_t len;
1053
1054 len = min(count, sizeof(buf) - 1);
1055 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +02001056 return -EFAULT;
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001057
1058 buf[len] = '\0';
1059 if (strict_strtoul(buf, 0, &regval))
1060 return -EINVAL;
1061
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301062 ath9k_ps_wakeup(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001063 REG_WRITE_D(ah, sc->debug.regidx, regval);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301064 ath9k_ps_restore(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001065 return count;
1066}
1067
1068static const struct file_operations fops_regval = {
1069 .read = read_file_regval,
1070 .write = write_file_regval,
Stephen Boyd234e3402012-04-05 14:25:11 -07001071 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001072 .owner = THIS_MODULE,
1073 .llseek = default_llseek,
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001074};
1075
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -08001076#define REGDUMP_LINE_SIZE 20
1077
1078static int open_file_regdump(struct inode *inode, struct file *file)
1079{
1080 struct ath_softc *sc = inode->i_private;
1081 unsigned int len = 0;
1082 u8 *buf;
1083 int i;
1084 unsigned long num_regs, regdump_len, max_reg_offset;
1085
1086 max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500;
1087 num_regs = max_reg_offset / 4 + 1;
1088 regdump_len = num_regs * REGDUMP_LINE_SIZE + 1;
1089 buf = vmalloc(regdump_len);
1090 if (!buf)
1091 return -ENOMEM;
1092
1093 ath9k_ps_wakeup(sc);
1094 for (i = 0; i < num_regs; i++)
1095 len += scnprintf(buf + len, regdump_len - len,
1096 "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2));
1097 ath9k_ps_restore(sc);
1098
1099 file->private_data = buf;
1100
1101 return 0;
1102}
1103
1104static const struct file_operations fops_regdump = {
1105 .open = open_file_regdump,
1106 .read = ath9k_debugfs_read_buf,
1107 .release = ath9k_debugfs_release_buf,
1108 .owner = THIS_MODULE,
1109 .llseek = default_llseek,/* read accesses f_pos */
1110};
1111
Rajkumar Manoharand069a462011-08-13 10:28:18 +05301112static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf,
1113 size_t count, loff_t *ppos)
1114{
1115 struct ath_softc *sc = file->private_data;
1116 struct ath_hw *ah = sc->sc_ah;
1117 struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist;
1118 struct ath_common *common = ath9k_hw_common(ah);
1119 struct ieee80211_conf *conf = &common->hw->conf;
1120 u32 len = 0, size = 1500;
1121 u32 i, j;
1122 ssize_t retval = 0;
1123 char *buf;
1124 u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
1125 u8 nread;
1126
1127 buf = kzalloc(size, GFP_KERNEL);
1128 if (!buf)
1129 return -ENOMEM;
1130
1131 len += snprintf(buf + len, size - len,
1132 "Channel Noise Floor : %d\n", ah->noise);
1133 len += snprintf(buf + len, size - len,
1134 "Chain | privNF | # Readings | NF Readings\n");
1135 for (i = 0; i < NUM_NF_READINGS; i++) {
1136 if (!(chainmask & (1 << i)) ||
1137 ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
1138 continue;
1139
1140 nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount;
1141 len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t",
1142 i, h[i].privNF, nread);
1143 for (j = 0; j < nread; j++)
1144 len += snprintf(buf + len, size - len,
1145 " %d", h[i].nfCalBuffer[j]);
1146 len += snprintf(buf + len, size - len, "\n");
1147 }
1148
1149 if (len > size)
1150 len = size;
1151
1152 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1153 kfree(buf);
1154
1155 return retval;
1156}
1157
1158static const struct file_operations fops_dump_nfcal = {
1159 .read = read_file_dump_nfcal,
Stephen Boyd234e3402012-04-05 14:25:11 -07001160 .open = simple_open,
Rajkumar Manoharand069a462011-08-13 10:28:18 +05301161 .owner = THIS_MODULE,
1162 .llseek = default_llseek,
1163};
1164
Rajkumar Manoharan580f0102011-07-29 17:38:12 +05301165static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
1166 size_t count, loff_t *ppos)
1167{
1168 struct ath_softc *sc = file->private_data;
1169 struct ath_hw *ah = sc->sc_ah;
1170 u32 len = 0, size = 1500;
1171 ssize_t retval = 0;
1172 char *buf;
1173
1174 buf = kzalloc(size, GFP_KERNEL);
1175 if (!buf)
1176 return -ENOMEM;
1177
1178 len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size);
1179
1180 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1181 kfree(buf);
1182
1183 return retval;
1184}
1185
1186static const struct file_operations fops_base_eeprom = {
1187 .read = read_file_base_eeprom,
Stephen Boyd234e3402012-04-05 14:25:11 -07001188 .open = simple_open,
Rajkumar Manoharan580f0102011-07-29 17:38:12 +05301189 .owner = THIS_MODULE,
1190 .llseek = default_llseek,
1191};
1192
Rajkumar Manoharan3f4c4bd2011-07-29 17:38:13 +05301193static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf,
1194 size_t count, loff_t *ppos)
1195{
1196 struct ath_softc *sc = file->private_data;
1197 struct ath_hw *ah = sc->sc_ah;
1198 u32 len = 0, size = 6000;
1199 char *buf;
1200 size_t retval;
1201
1202 buf = kzalloc(size, GFP_KERNEL);
1203 if (buf == NULL)
1204 return -ENOMEM;
1205
1206 len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size);
1207
1208 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1209 kfree(buf);
1210
1211 return retval;
1212}
1213
1214static const struct file_operations fops_modal_eeprom = {
1215 .read = read_file_modal_eeprom,
Stephen Boyd234e3402012-04-05 14:25:11 -07001216 .open = simple_open,
Rajkumar Manoharan3f4c4bd2011-07-29 17:38:13 +05301217 .owner = THIS_MODULE,
1218 .llseek = default_llseek,
1219};
1220
Felix Fietkau5baec742012-03-03 15:17:03 +01001221#ifdef CONFIG_ATH9K_MAC_DEBUG
1222
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301223void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
1224{
1225#define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c)
1226 struct ath_hw *ah = sc->sc_ah;
1227 struct ath_common *common = ath9k_hw_common(ah);
1228 unsigned long flags;
1229 int i;
1230
1231 ath9k_ps_wakeup(sc);
1232
Rajkumar Manoharan6bc05a92011-09-06 21:00:07 +05301233 spin_lock_bh(&sc->debug.samp_lock);
1234
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301235 spin_lock_irqsave(&common->cc_lock, flags);
1236 ath_hw_cycle_counters_update(common);
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301237
1238 ATH_SAMP_DBG(cc.cycles) = common->cc_ani.cycles;
1239 ATH_SAMP_DBG(cc.rx_busy) = common->cc_ani.rx_busy;
1240 ATH_SAMP_DBG(cc.rx_frame) = common->cc_ani.rx_frame;
1241 ATH_SAMP_DBG(cc.tx_frame) = common->cc_ani.tx_frame;
Rajkumar Manoharan6bc05a92011-09-06 21:00:07 +05301242 spin_unlock_irqrestore(&common->cc_lock, flags);
1243
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301244 ATH_SAMP_DBG(noise) = ah->noise;
1245
1246 REG_WRITE_D(ah, AR_MACMISC,
1247 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
1248 (AR_MACMISC_MISC_OBS_BUS_1 <<
1249 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
1250
1251 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++)
1252 ATH_SAMP_DBG(dma_dbg_reg_vals[i]) = REG_READ_D(ah,
1253 AR_DMADBG_0 + (i * sizeof(u32)));
1254
1255 ATH_SAMP_DBG(pcu_obs) = REG_READ_D(ah, AR_OBS_BUS_1);
1256 ATH_SAMP_DBG(pcu_cr) = REG_READ_D(ah, AR_CR);
1257
1258 memcpy(ATH_SAMP_DBG(nfCalHist), sc->caldata.nfCalHist,
1259 sizeof(ATH_SAMP_DBG(nfCalHist)));
1260
1261 sc->debug.sampidx = (sc->debug.sampidx + 1) % ATH_DBG_MAX_SAMPLES;
1262 spin_unlock_bh(&sc->debug.samp_lock);
1263 ath9k_ps_restore(sc);
1264
1265#undef ATH_SAMP_DBG
1266}
1267
1268static int open_file_bb_mac_samps(struct inode *inode, struct file *file)
1269{
1270#define ATH_SAMP_DBG(c) bb_mac_samp[sampidx].c
1271 struct ath_softc *sc = inode->i_private;
1272 struct ath_hw *ah = sc->sc_ah;
1273 struct ath_common *common = ath9k_hw_common(ah);
1274 struct ieee80211_conf *conf = &common->hw->conf;
1275 struct ath_dbg_bb_mac_samp *bb_mac_samp;
1276 struct ath9k_nfcal_hist *h;
1277 int i, j, qcuOffset = 0, dcuOffset = 0;
1278 u32 *qcuBase, *dcuBase, size = 30000, len = 0;
1279 u32 sampidx = 0;
1280 u8 *buf;
1281 u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
1282 u8 nread;
1283
Sujith Manoharan781b14a2012-06-04 20:23:55 +05301284 if (test_bit(SC_OP_INVALID, &sc->sc_flags))
Rajkumar Manoharanf7e014d2011-09-06 21:00:06 +05301285 return -EAGAIN;
1286
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301287 buf = vmalloc(size);
1288 if (!buf)
1289 return -ENOMEM;
1290 bb_mac_samp = vmalloc(sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES);
1291 if (!bb_mac_samp) {
1292 vfree(buf);
1293 return -ENOMEM;
1294 }
Rajkumar Manoharanf7e014d2011-09-06 21:00:06 +05301295 /* Account the current state too */
1296 ath9k_debug_samp_bb_mac(sc);
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301297
1298 spin_lock_bh(&sc->debug.samp_lock);
1299 memcpy(bb_mac_samp, sc->debug.bb_mac_samp,
1300 sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES);
Rajkumar Manoharan6bc05a92011-09-06 21:00:07 +05301301 len += snprintf(buf + len, size - len,
1302 "Current Sample Index: %d\n", sc->debug.sampidx);
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301303 spin_unlock_bh(&sc->debug.samp_lock);
1304
1305 len += snprintf(buf + len, size - len,
1306 "Raw DMA Debug Dump:\n");
1307 len += snprintf(buf + len, size - len, "Sample |\t");
1308 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++)
1309 len += snprintf(buf + len, size - len, " DMA Reg%d |\t", i);
1310 len += snprintf(buf + len, size - len, "\n");
1311
1312 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1313 len += snprintf(buf + len, size - len, "%d\t", sampidx);
1314
1315 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++)
1316 len += snprintf(buf + len, size - len, " %08x\t",
1317 ATH_SAMP_DBG(dma_dbg_reg_vals[i]));
1318 len += snprintf(buf + len, size - len, "\n");
1319 }
1320 len += snprintf(buf + len, size - len, "\n");
1321
1322 len += snprintf(buf + len, size - len,
1323 "Sample Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
1324 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1325 qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]);
1326 dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]);
1327
1328 for (i = 0; i < ATH9K_NUM_QUEUES; i++,
1329 qcuOffset += 4, dcuOffset += 5) {
1330 if (i == 8) {
1331 qcuOffset = 0;
1332 qcuBase++;
1333 }
1334
1335 if (i == 6) {
1336 dcuOffset = 0;
1337 dcuBase++;
1338 }
1339 if (!sc->debug.stats.txstats[i].queued)
1340 continue;
1341
1342 len += snprintf(buf + len, size - len,
1343 "%4d %7d %2x %1x %2x %2x\n",
1344 sampidx, i,
1345 (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
1346 (*qcuBase & (0x8 << qcuOffset)) >>
1347 (qcuOffset + 3),
1348 ATH_SAMP_DBG(dma_dbg_reg_vals[2]) &
1349 (0x7 << (i * 3)) >> (i * 3),
1350 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
1351 }
1352 len += snprintf(buf + len, size - len, "\n");
1353 }
1354 len += snprintf(buf + len, size - len,
1355 "samp qcu_sh qcu_fh qcu_comp dcu_comp dcu_arb dcu_fp "
1356 "ch_idle_dur ch_idle_dur_val txfifo_val0 txfifo_val1 "
1357 "txfifo_dcu0 txfifo_dcu1 pcu_obs AR_CR\n");
1358
1359 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1360 qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]);
1361 dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]);
1362
1363 len += snprintf(buf + len, size - len, "%4d %5x %5x ", sampidx,
1364 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x003c0000) >> 18,
1365 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x03c00000) >> 22);
1366 len += snprintf(buf + len, size - len, "%7x %8x ",
1367 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x1c000000) >> 26,
1368 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x3));
1369 len += snprintf(buf + len, size - len, "%7x %7x ",
1370 (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x06000000) >> 25,
1371 (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x38000000) >> 27);
1372 len += snprintf(buf + len, size - len, "%7d %12d ",
1373 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x000003fc) >> 2,
1374 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000400) >> 10);
1375 len += snprintf(buf + len, size - len, "%12d %12d ",
1376 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000800) >> 11,
1377 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00001000) >> 12);
1378 len += snprintf(buf + len, size - len, "%12d %12d ",
1379 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x0001e000) >> 13,
1380 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x001e0000) >> 17);
1381 len += snprintf(buf + len, size - len, "0x%07x 0x%07x\n",
1382 ATH_SAMP_DBG(pcu_obs), ATH_SAMP_DBG(pcu_cr));
1383 }
1384
1385 len += snprintf(buf + len, size - len,
1386 "Sample ChNoise Chain privNF #Reading Readings\n");
1387 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1388 h = ATH_SAMP_DBG(nfCalHist);
1389 if (!ATH_SAMP_DBG(noise))
1390 continue;
1391
1392 for (i = 0; i < NUM_NF_READINGS; i++) {
1393 if (!(chainmask & (1 << i)) ||
1394 ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
1395 continue;
1396
1397 nread = AR_PHY_CCA_FILTERWINDOW_LENGTH -
1398 h[i].invalidNFcount;
1399 len += snprintf(buf + len, size - len,
1400 "%4d %5d %4d\t %d\t %d\t",
1401 sampidx, ATH_SAMP_DBG(noise),
1402 i, h[i].privNF, nread);
1403 for (j = 0; j < nread; j++)
1404 len += snprintf(buf + len, size - len,
1405 " %d", h[i].nfCalBuffer[j]);
1406 len += snprintf(buf + len, size - len, "\n");
1407 }
1408 }
1409 len += snprintf(buf + len, size - len, "\nCycle counters:\n"
1410 "Sample Total Rxbusy Rxframes Txframes\n");
1411 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1412 if (!ATH_SAMP_DBG(cc.cycles))
1413 continue;
1414 len += snprintf(buf + len, size - len,
1415 "%4d %08x %08x %08x %08x\n",
1416 sampidx, ATH_SAMP_DBG(cc.cycles),
1417 ATH_SAMP_DBG(cc.rx_busy),
1418 ATH_SAMP_DBG(cc.rx_frame),
1419 ATH_SAMP_DBG(cc.tx_frame));
1420 }
1421
1422 len += snprintf(buf + len, size - len, "Tx status Dump :\n");
1423 len += snprintf(buf + len, size - len,
1424 "Sample rssi:- ctl0 ctl1 ctl2 ext0 ext1 ext2 comb "
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +05301425 "isok rts_fail data_fail rate tid qid "
1426 "ba_low ba_high tx_before(ms)\n");
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301427 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1428 for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) {
1429 if (!ATH_SAMP_DBG(ts[i].jiffies))
1430 continue;
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +05301431 len += snprintf(buf + len, size - len, "%-14d"
1432 "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-8d "
1433 "%-9d %-4d %-3d %-3d %08x %08x %-11d\n",
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301434 sampidx,
1435 ATH_SAMP_DBG(ts[i].rssi_ctl0),
1436 ATH_SAMP_DBG(ts[i].rssi_ctl1),
1437 ATH_SAMP_DBG(ts[i].rssi_ctl2),
1438 ATH_SAMP_DBG(ts[i].rssi_ext0),
1439 ATH_SAMP_DBG(ts[i].rssi_ext1),
1440 ATH_SAMP_DBG(ts[i].rssi_ext2),
1441 ATH_SAMP_DBG(ts[i].rssi),
1442 ATH_SAMP_DBG(ts[i].isok),
1443 ATH_SAMP_DBG(ts[i].rts_fail_cnt),
1444 ATH_SAMP_DBG(ts[i].data_fail_cnt),
1445 ATH_SAMP_DBG(ts[i].rateindex),
1446 ATH_SAMP_DBG(ts[i].tid),
1447 ATH_SAMP_DBG(ts[i].qid),
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +05301448 ATH_SAMP_DBG(ts[i].ba_low),
1449 ATH_SAMP_DBG(ts[i].ba_high),
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301450 jiffies_to_msecs(jiffies -
1451 ATH_SAMP_DBG(ts[i].jiffies)));
1452 }
1453 }
1454
1455 len += snprintf(buf + len, size - len, "Rx status Dump :\n");
1456 len += snprintf(buf + len, size - len, "Sample rssi:- ctl0 ctl1 ctl2 "
1457 "ext0 ext1 ext2 comb beacon ant rate rx_before(ms)\n");
1458 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1459 for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) {
1460 if (!ATH_SAMP_DBG(rs[i].jiffies))
1461 continue;
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +05301462 len += snprintf(buf + len, size - len, "%-14d"
1463 "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-9s %-2d %02x %-13d\n",
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301464 sampidx,
1465 ATH_SAMP_DBG(rs[i].rssi_ctl0),
1466 ATH_SAMP_DBG(rs[i].rssi_ctl1),
1467 ATH_SAMP_DBG(rs[i].rssi_ctl2),
1468 ATH_SAMP_DBG(rs[i].rssi_ext0),
1469 ATH_SAMP_DBG(rs[i].rssi_ext1),
1470 ATH_SAMP_DBG(rs[i].rssi_ext2),
1471 ATH_SAMP_DBG(rs[i].rssi),
1472 ATH_SAMP_DBG(rs[i].is_mybeacon) ?
1473 "True" : "False",
1474 ATH_SAMP_DBG(rs[i].antenna),
1475 ATH_SAMP_DBG(rs[i].rate),
1476 jiffies_to_msecs(jiffies -
1477 ATH_SAMP_DBG(rs[i].jiffies)));
1478 }
1479 }
1480
1481 vfree(bb_mac_samp);
1482 file->private_data = buf;
1483
1484 return 0;
1485#undef ATH_SAMP_DBG
1486}
1487
1488static const struct file_operations fops_samps = {
1489 .open = open_file_bb_mac_samps,
1490 .read = ath9k_debugfs_read_buf,
1491 .release = ath9k_debugfs_release_buf,
1492 .owner = THIS_MODULE,
1493 .llseek = default_llseek,
1494};
1495
Felix Fietkau5baec742012-03-03 15:17:03 +01001496#endif
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301497
Rajkumar Manoharan4df50ca2012-10-25 17:16:54 +05301498#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1499static ssize_t read_file_btcoex(struct file *file, char __user *user_buf,
1500 size_t count, loff_t *ppos)
1501{
1502 struct ath_softc *sc = file->private_data;
1503 u32 len = 0, size = 1500;
1504 char *buf;
1505 size_t retval;
1506
1507 buf = kzalloc(size, GFP_KERNEL);
1508 if (buf == NULL)
1509 return -ENOMEM;
1510
Sujith Manoharanac46ba42012-11-19 14:24:46 +05301511 if (!sc->sc_ah->common.btcoex_enabled) {
1512 len = snprintf(buf, size, "%s\n",
1513 "BTCOEX is disabled");
1514 goto exit;
1515 }
Rajkumar Manoharan4df50ca2012-10-25 17:16:54 +05301516
Sujith Manoharanac46ba42012-11-19 14:24:46 +05301517 len = ath9k_dump_btcoex(sc, buf, size);
1518exit:
Rajkumar Manoharan4df50ca2012-10-25 17:16:54 +05301519 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1520 kfree(buf);
1521
1522 return retval;
1523}
1524
1525static const struct file_operations fops_btcoex = {
1526 .read = read_file_btcoex,
1527 .open = simple_open,
1528 .owner = THIS_MODULE,
1529 .llseek = default_llseek,
1530};
1531#endif
1532
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -07001533int ath9k_init_debug(struct ath_hw *ah)
Sujith88b126a2008-11-28 22:19:02 +05301534{
Luis R. Rodriguezbc974f42009-09-28 02:54:40 -04001535 struct ath_common *common = ath9k_hw_common(ah);
1536 struct ath_softc *sc = (struct ath_softc *) common->priv;
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -07001537
Ben Greeareb272442010-11-29 14:13:22 -08001538 sc->debug.debugfs_phy = debugfs_create_dir("ath9k",
1539 sc->hw->wiphy->debugfsdir);
Sujith17d79042009-02-09 13:27:03 +05301540 if (!sc->debug.debugfs_phy)
Felix Fietkauc8a72c02010-05-11 17:23:00 +02001541 return -ENOMEM;
Sujith826d2682008-11-28 22:20:23 +05301542
Felix Fietkaua830df02009-11-23 22:33:27 +01001543#ifdef CONFIG_ATH_DEBUG
Felix Fietkauc70cab12011-03-19 13:55:37 +01001544 debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1545 sc, &fops_debug);
Felix Fietkaua830df02009-11-23 22:33:27 +01001546#endif
Zefir Kurtisi29942bc2011-12-14 20:16:34 -08001547
1548 ath9k_dfs_init_debug(sc);
1549
Felix Fietkauc70cab12011-03-19 13:55:37 +01001550 debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
1551 &fops_dma);
1552 debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
1553 &fops_interrupt);
Felix Fietkauc70cab12011-03-19 13:55:37 +01001554 debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc,
1555 &fops_xmit);
Felix Fietkau7702e782012-07-15 19:53:35 +02001556 debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
Sujith Manoharanbea843c2012-11-21 18:13:10 +05301557 &sc->tx.txq_max_pending[IEEE80211_AC_BK]);
Felix Fietkau7702e782012-07-15 19:53:35 +02001558 debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
Sujith Manoharanbea843c2012-11-21 18:13:10 +05301559 &sc->tx.txq_max_pending[IEEE80211_AC_BE]);
Felix Fietkau7702e782012-07-15 19:53:35 +02001560 debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
Sujith Manoharanbea843c2012-11-21 18:13:10 +05301561 &sc->tx.txq_max_pending[IEEE80211_AC_VI]);
Felix Fietkau7702e782012-07-15 19:53:35 +02001562 debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
Sujith Manoharanbea843c2012-11-21 18:13:10 +05301563 &sc->tx.txq_max_pending[IEEE80211_AC_VO]);
Felix Fietkauc70cab12011-03-19 13:55:37 +01001564 debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc,
1565 &fops_stations);
1566 debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc,
1567 &fops_misc);
Sujith Manoharanf8b815d2012-02-16 11:51:11 +05301568 debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc,
1569 &fops_reset);
Felix Fietkauc70cab12011-03-19 13:55:37 +01001570 debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc,
1571 &fops_recv);
1572 debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR,
1573 sc->debug.debugfs_phy, sc, &fops_rx_chainmask);
1574 debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR,
1575 sc->debug.debugfs_phy, sc, &fops_tx_chainmask);
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +05301576 debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR,
1577 sc->debug.debugfs_phy, sc, &fops_disable_ani);
Felix Fietkau74673db2012-09-08 15:24:17 +02001578 debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1579 &sc->sc_ah->config.enable_paprd);
Felix Fietkauc70cab12011-03-19 13:55:37 +01001580 debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1581 sc, &fops_regidx);
1582 debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1583 sc, &fops_regval);
1584 debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR,
1585 sc->debug.debugfs_phy,
1586 &ah->config.cwm_ignore_extcca);
1587 debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc,
1588 &fops_regdump);
Rajkumar Manoharand069a462011-08-13 10:28:18 +05301589 debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc,
1590 &fops_dump_nfcal);
Rajkumar Manoharan580f0102011-07-29 17:38:12 +05301591 debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
1592 &fops_base_eeprom);
Rajkumar Manoharan3f4c4bd2011-07-29 17:38:13 +05301593 debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
1594 &fops_modal_eeprom);
Felix Fietkau5baec742012-03-03 15:17:03 +01001595#ifdef CONFIG_ATH9K_MAC_DEBUG
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301596 debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc,
1597 &fops_samps);
Felix Fietkau5baec742012-03-03 15:17:03 +01001598#endif
Felix Fietkau691680b2011-03-19 13:55:38 +01001599 debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
1600 sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
Felix Fietkau691680b2011-03-19 13:55:38 +01001601 debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
1602 sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
Sujith Manoharan302a3c32012-09-26 07:55:18 +05301603 debugfs_create_file("diversity", S_IRUSR | S_IWUSR,
1604 sc->debug.debugfs_phy, sc, &fops_ant_diversity);
Rajkumar Manoharan4df50ca2012-10-25 17:16:54 +05301605#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1606 debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc,
1607 &fops_btcoex);
1608#endif
Sujith826d2682008-11-28 22:20:23 +05301609 return 0;
Sujith88b126a2008-11-28 22:19:02 +05301610}