blob: b2c60690255a09eb15a3ec68ba107b11519b4444 [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 +053029static int ath9k_debugfs_open(struct inode *inode, struct file *file)
30{
31 file->private_data = inode->i_private;
32 return 0;
33}
34
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -080035static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf,
36 size_t count, loff_t *ppos)
37{
38 u8 *buf = file->private_data;
39 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
40}
41
42static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file)
43{
44 vfree(file->private_data);
45 return 0;
46}
47
Felix Fietkaua830df02009-11-23 22:33:27 +010048#ifdef CONFIG_ATH_DEBUG
49
Jeff Hansen24939282009-05-27 12:48:29 +000050static ssize_t read_file_debug(struct file *file, char __user *user_buf,
51 size_t count, loff_t *ppos)
52{
53 struct ath_softc *sc = file->private_data;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070054 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Jeff Hansen24939282009-05-27 12:48:29 +000055 char buf[32];
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053056 unsigned int len;
57
Dan Carpenter2b87f3a2010-05-14 15:24:37 +020058 len = sprintf(buf, "0x%08x\n", common->debug_mask);
Jeff Hansen24939282009-05-27 12:48:29 +000059 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
60}
61
62static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
63 size_t count, loff_t *ppos)
64{
65 struct ath_softc *sc = file->private_data;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070066 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Jeff Hansen24939282009-05-27 12:48:29 +000067 unsigned long mask;
68 char buf[32];
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053069 ssize_t len;
70
71 len = min(count, sizeof(buf) - 1);
72 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +020073 return -EFAULT;
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053074
75 buf[len] = '\0';
76 if (strict_strtoul(buf, 0, &mask))
77 return -EINVAL;
78
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070079 common->debug_mask = mask;
Jeff Hansen24939282009-05-27 12:48:29 +000080 return count;
81}
82
83static const struct file_operations fops_debug = {
84 .read = read_file_debug,
85 .write = write_file_debug,
86 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +020087 .owner = THIS_MODULE,
88 .llseek = default_llseek,
Jeff Hansen24939282009-05-27 12:48:29 +000089};
90
Felix Fietkaua830df02009-11-23 22:33:27 +010091#endif
92
Pavel Roskin991a0982010-01-29 17:22:26 -050093#define DMA_BUF_LEN 1024
94
Felix Fietkau15340692010-05-11 17:23:01 +020095static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf,
96 size_t count, loff_t *ppos)
97{
98 struct ath_softc *sc = file->private_data;
Felix Fietkau82b2d332011-09-03 01:40:23 +020099 struct ath_hw *ah = sc->sc_ah;
Felix Fietkau15340692010-05-11 17:23:01 +0200100 char buf[32];
101 unsigned int len;
102
Felix Fietkau82b2d332011-09-03 01:40:23 +0200103 len = sprintf(buf, "0x%08x\n", ah->txchainmask);
Felix Fietkau15340692010-05-11 17:23:01 +0200104 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
105}
106
107static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf,
108 size_t count, loff_t *ppos)
109{
110 struct ath_softc *sc = file->private_data;
Felix Fietkau82b2d332011-09-03 01:40:23 +0200111 struct ath_hw *ah = sc->sc_ah;
Felix Fietkau15340692010-05-11 17:23:01 +0200112 unsigned long mask;
113 char buf[32];
114 ssize_t len;
115
116 len = min(count, sizeof(buf) - 1);
117 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +0200118 return -EFAULT;
Felix Fietkau15340692010-05-11 17:23:01 +0200119
120 buf[len] = '\0';
121 if (strict_strtoul(buf, 0, &mask))
122 return -EINVAL;
123
Felix Fietkau82b2d332011-09-03 01:40:23 +0200124 ah->txchainmask = mask;
125 ah->caps.tx_chainmask = mask;
Felix Fietkau15340692010-05-11 17:23:01 +0200126 return count;
127}
128
129static const struct file_operations fops_tx_chainmask = {
130 .read = read_file_tx_chainmask,
131 .write = write_file_tx_chainmask,
132 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200133 .owner = THIS_MODULE,
134 .llseek = default_llseek,
Felix Fietkau15340692010-05-11 17:23:01 +0200135};
136
137
138static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf,
139 size_t count, loff_t *ppos)
140{
141 struct ath_softc *sc = file->private_data;
Felix Fietkau82b2d332011-09-03 01:40:23 +0200142 struct ath_hw *ah = sc->sc_ah;
Felix Fietkau15340692010-05-11 17:23:01 +0200143 char buf[32];
144 unsigned int len;
145
Felix Fietkau82b2d332011-09-03 01:40:23 +0200146 len = sprintf(buf, "0x%08x\n", ah->rxchainmask);
Felix Fietkau15340692010-05-11 17:23:01 +0200147 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
148}
149
150static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf,
151 size_t count, loff_t *ppos)
152{
153 struct ath_softc *sc = file->private_data;
Felix Fietkau82b2d332011-09-03 01:40:23 +0200154 struct ath_hw *ah = sc->sc_ah;
Felix Fietkau15340692010-05-11 17:23:01 +0200155 unsigned long mask;
156 char buf[32];
157 ssize_t len;
158
159 len = min(count, sizeof(buf) - 1);
160 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +0200161 return -EFAULT;
Felix Fietkau15340692010-05-11 17:23:01 +0200162
163 buf[len] = '\0';
164 if (strict_strtoul(buf, 0, &mask))
165 return -EINVAL;
166
Felix Fietkau82b2d332011-09-03 01:40:23 +0200167 ah->rxchainmask = mask;
168 ah->caps.rx_chainmask = mask;
Felix Fietkau15340692010-05-11 17:23:01 +0200169 return count;
170}
171
172static const struct file_operations fops_rx_chainmask = {
173 .read = read_file_rx_chainmask,
174 .write = write_file_rx_chainmask,
175 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200176 .owner = THIS_MODULE,
177 .llseek = default_llseek,
Felix Fietkau15340692010-05-11 17:23:01 +0200178};
179
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530180static ssize_t read_file_disable_ani(struct file *file, char __user *user_buf,
181 size_t count, loff_t *ppos)
182{
183 struct ath_softc *sc = file->private_data;
184 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
185 char buf[32];
186 unsigned int len;
187
188 len = sprintf(buf, "%d\n", common->disable_ani);
189 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
190}
191
192static ssize_t write_file_disable_ani(struct file *file,
193 const char __user *user_buf,
194 size_t count, loff_t *ppos)
195{
196 struct ath_softc *sc = file->private_data;
197 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
198 unsigned long disable_ani;
199 char buf[32];
200 ssize_t len;
201
202 len = min(count, sizeof(buf) - 1);
203 if (copy_from_user(buf, user_buf, len))
204 return -EFAULT;
205
206 buf[len] = '\0';
207 if (strict_strtoul(buf, 0, &disable_ani))
208 return -EINVAL;
209
210 common->disable_ani = !!disable_ani;
211
212 if (disable_ani) {
213 sc->sc_flags &= ~SC_OP_ANI_RUN;
214 del_timer_sync(&common->ani.timer);
215 } else {
216 sc->sc_flags |= SC_OP_ANI_RUN;
217 ath_start_ani(common);
218 }
219
220 return count;
221}
222
223static const struct file_operations fops_disable_ani = {
224 .read = read_file_disable_ani,
225 .write = write_file_disable_ani,
226 .open = ath9k_debugfs_open,
227 .owner = THIS_MODULE,
228 .llseek = default_llseek,
229};
Felix Fietkau15340692010-05-11 17:23:01 +0200230
Sujith2a163c62008-11-28 22:21:08 +0530231static ssize_t read_file_dma(struct file *file, char __user *user_buf,
232 size_t count, loff_t *ppos)
233{
234 struct ath_softc *sc = file->private_data;
Sujithcbe61d82009-02-09 13:27:12 +0530235 struct ath_hw *ah = sc->sc_ah;
Pavel Roskin991a0982010-01-29 17:22:26 -0500236 char *buf;
237 int retval;
Sujith2a163c62008-11-28 22:21:08 +0530238 unsigned int len = 0;
239 u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
240 int i, qcuOffset = 0, dcuOffset = 0;
241 u32 *qcuBase = &val[0], *dcuBase = &val[4];
242
Pavel Roskin991a0982010-01-29 17:22:26 -0500243 buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL);
244 if (!buf)
Dan Carpenter04236062010-05-14 15:25:39 +0200245 return -ENOMEM;
Pavel Roskin991a0982010-01-29 17:22:26 -0500246
Sujith7cf4a2e2009-08-26 11:11:57 +0530247 ath9k_ps_wakeup(sc);
248
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400249 REG_WRITE_D(ah, AR_MACMISC,
Sujith2a163c62008-11-28 22:21:08 +0530250 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
251 (AR_MACMISC_MISC_OBS_BUS_1 <<
252 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
253
Pavel Roskin991a0982010-01-29 17:22:26 -0500254 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530255 "Raw DMA Debug values:\n");
256
257 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
258 if (i % 4 == 0)
Pavel Roskin991a0982010-01-29 17:22:26 -0500259 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
Sujith2a163c62008-11-28 22:21:08 +0530260
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400261 val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
Pavel Roskin991a0982010-01-29 17:22:26 -0500262 len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ",
Sujith2a163c62008-11-28 22:21:08 +0530263 i, val[i]);
264 }
265
Pavel Roskin991a0982010-01-29 17:22:26 -0500266 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n");
267 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530268 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
269
270 for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
271 if (i == 8) {
272 qcuOffset = 0;
273 qcuBase++;
274 }
275
276 if (i == 6) {
277 dcuOffset = 0;
278 dcuBase++;
279 }
280
Pavel Roskin991a0982010-01-29 17:22:26 -0500281 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530282 "%2d %2x %1x %2x %2x\n",
283 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
284 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
285 val[2] & (0x7 << (i * 3)) >> (i * 3),
286 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
287 }
288
Pavel Roskin991a0982010-01-29 17:22:26 -0500289 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
Sujith2a163c62008-11-28 22:21:08 +0530290
Pavel Roskin991a0982010-01-29 17:22:26 -0500291 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530292 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
293 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
Pavel Roskin991a0982010-01-29 17:22:26 -0500294 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530295 "qcu_complete state: %2x dcu_complete state: %2x\n",
296 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
Pavel Roskin991a0982010-01-29 17:22:26 -0500297 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530298 "dcu_arb state: %2x dcu_fp state: %2x\n",
299 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
Pavel Roskin991a0982010-01-29 17:22:26 -0500300 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530301 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
302 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
Pavel Roskin991a0982010-01-29 17:22:26 -0500303 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530304 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
305 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
Pavel Roskin991a0982010-01-29 17:22:26 -0500306 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530307 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
308 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
309
Frans Pop60ece402010-03-24 19:46:30 +0100310 len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n",
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400311 REG_READ_D(ah, AR_OBS_BUS_1));
Pavel Roskin991a0982010-01-29 17:22:26 -0500312 len += snprintf(buf + len, DMA_BUF_LEN - len,
Frans Pop60ece402010-03-24 19:46:30 +0100313 "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR));
Sujith2a163c62008-11-28 22:21:08 +0530314
Sujith7cf4a2e2009-08-26 11:11:57 +0530315 ath9k_ps_restore(sc);
316
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200317 if (len > DMA_BUF_LEN)
318 len = DMA_BUF_LEN;
319
Pavel Roskin991a0982010-01-29 17:22:26 -0500320 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
321 kfree(buf);
322 return retval;
Sujith2a163c62008-11-28 22:21:08 +0530323}
324
325static const struct file_operations fops_dma = {
326 .read = read_file_dma,
327 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200328 .owner = THIS_MODULE,
329 .llseek = default_llseek,
Sujith2a163c62008-11-28 22:21:08 +0530330};
331
Sujith817e11d2008-12-07 21:42:44 +0530332
333void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status)
334{
335 if (status)
Sujith17d79042009-02-09 13:27:03 +0530336 sc->debug.stats.istats.total++;
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400337 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
338 if (status & ATH9K_INT_RXLP)
339 sc->debug.stats.istats.rxlp++;
340 if (status & ATH9K_INT_RXHP)
341 sc->debug.stats.istats.rxhp++;
Luis R. Rodriguez08578b82010-05-13 13:33:44 -0400342 if (status & ATH9K_INT_BB_WATCHDOG)
343 sc->debug.stats.istats.bb_watchdog++;
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400344 } else {
345 if (status & ATH9K_INT_RX)
346 sc->debug.stats.istats.rxok++;
347 }
Sujith817e11d2008-12-07 21:42:44 +0530348 if (status & ATH9K_INT_RXEOL)
Sujith17d79042009-02-09 13:27:03 +0530349 sc->debug.stats.istats.rxeol++;
Sujith817e11d2008-12-07 21:42:44 +0530350 if (status & ATH9K_INT_RXORN)
Sujith17d79042009-02-09 13:27:03 +0530351 sc->debug.stats.istats.rxorn++;
Sujith817e11d2008-12-07 21:42:44 +0530352 if (status & ATH9K_INT_TX)
Sujith17d79042009-02-09 13:27:03 +0530353 sc->debug.stats.istats.txok++;
Sujith817e11d2008-12-07 21:42:44 +0530354 if (status & ATH9K_INT_TXURN)
Sujith17d79042009-02-09 13:27:03 +0530355 sc->debug.stats.istats.txurn++;
Sujith817e11d2008-12-07 21:42:44 +0530356 if (status & ATH9K_INT_MIB)
Sujith17d79042009-02-09 13:27:03 +0530357 sc->debug.stats.istats.mib++;
Sujith817e11d2008-12-07 21:42:44 +0530358 if (status & ATH9K_INT_RXPHY)
Sujith17d79042009-02-09 13:27:03 +0530359 sc->debug.stats.istats.rxphyerr++;
Sujith817e11d2008-12-07 21:42:44 +0530360 if (status & ATH9K_INT_RXKCM)
Sujith17d79042009-02-09 13:27:03 +0530361 sc->debug.stats.istats.rx_keycache_miss++;
Sujith817e11d2008-12-07 21:42:44 +0530362 if (status & ATH9K_INT_SWBA)
Sujith17d79042009-02-09 13:27:03 +0530363 sc->debug.stats.istats.swba++;
Sujith817e11d2008-12-07 21:42:44 +0530364 if (status & ATH9K_INT_BMISS)
Sujith17d79042009-02-09 13:27:03 +0530365 sc->debug.stats.istats.bmiss++;
Sujith817e11d2008-12-07 21:42:44 +0530366 if (status & ATH9K_INT_BNR)
Sujith17d79042009-02-09 13:27:03 +0530367 sc->debug.stats.istats.bnr++;
Sujith817e11d2008-12-07 21:42:44 +0530368 if (status & ATH9K_INT_CST)
Sujith17d79042009-02-09 13:27:03 +0530369 sc->debug.stats.istats.cst++;
Sujith817e11d2008-12-07 21:42:44 +0530370 if (status & ATH9K_INT_GTT)
Sujith17d79042009-02-09 13:27:03 +0530371 sc->debug.stats.istats.gtt++;
Sujith817e11d2008-12-07 21:42:44 +0530372 if (status & ATH9K_INT_TIM)
Sujith17d79042009-02-09 13:27:03 +0530373 sc->debug.stats.istats.tim++;
Sujith817e11d2008-12-07 21:42:44 +0530374 if (status & ATH9K_INT_CABEND)
Sujith17d79042009-02-09 13:27:03 +0530375 sc->debug.stats.istats.cabend++;
Sujith817e11d2008-12-07 21:42:44 +0530376 if (status & ATH9K_INT_DTIMSYNC)
Sujith17d79042009-02-09 13:27:03 +0530377 sc->debug.stats.istats.dtimsync++;
Sujith817e11d2008-12-07 21:42:44 +0530378 if (status & ATH9K_INT_DTIM)
Sujith17d79042009-02-09 13:27:03 +0530379 sc->debug.stats.istats.dtim++;
Mohammed Shafi Shajakhan6dde1aa2011-04-22 17:27:01 +0530380 if (status & ATH9K_INT_TSFOOR)
381 sc->debug.stats.istats.tsfoor++;
Sujith817e11d2008-12-07 21:42:44 +0530382}
383
384static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
385 size_t count, loff_t *ppos)
386{
387 struct ath_softc *sc = file->private_data;
388 char buf[512];
389 unsigned int len = 0;
390
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400391 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
392 len += snprintf(buf + len, sizeof(buf) - len,
393 "%8s: %10u\n", "RXLP", sc->debug.stats.istats.rxlp);
394 len += snprintf(buf + len, sizeof(buf) - len,
395 "%8s: %10u\n", "RXHP", sc->debug.stats.istats.rxhp);
Luis R. Rodriguez08578b82010-05-13 13:33:44 -0400396 len += snprintf(buf + len, sizeof(buf) - len,
397 "%8s: %10u\n", "WATCHDOG",
398 sc->debug.stats.istats.bb_watchdog);
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400399 } else {
400 len += snprintf(buf + len, sizeof(buf) - len,
401 "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok);
402 }
Sujith817e11d2008-12-07 21:42:44 +0530403 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530404 "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol);
Sujith817e11d2008-12-07 21:42:44 +0530405 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530406 "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn);
Sujith817e11d2008-12-07 21:42:44 +0530407 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530408 "%8s: %10u\n", "TX", sc->debug.stats.istats.txok);
Sujith817e11d2008-12-07 21:42:44 +0530409 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530410 "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn);
Sujith817e11d2008-12-07 21:42:44 +0530411 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530412 "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib);
Sujith817e11d2008-12-07 21:42:44 +0530413 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530414 "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr);
Sujith817e11d2008-12-07 21:42:44 +0530415 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530416 "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss);
Sujith817e11d2008-12-07 21:42:44 +0530417 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530418 "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba);
Sujith817e11d2008-12-07 21:42:44 +0530419 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530420 "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss);
Sujith817e11d2008-12-07 21:42:44 +0530421 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530422 "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr);
Sujith817e11d2008-12-07 21:42:44 +0530423 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530424 "%8s: %10u\n", "CST", sc->debug.stats.istats.cst);
Sujith817e11d2008-12-07 21:42:44 +0530425 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530426 "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt);
Sujith817e11d2008-12-07 21:42:44 +0530427 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530428 "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim);
Sujith817e11d2008-12-07 21:42:44 +0530429 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530430 "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend);
Sujith817e11d2008-12-07 21:42:44 +0530431 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530432 "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync);
Sujith817e11d2008-12-07 21:42:44 +0530433 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530434 "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim);
Sujith817e11d2008-12-07 21:42:44 +0530435 len += snprintf(buf + len, sizeof(buf) - len,
Mohammed Shafi Shajakhan6dde1aa2011-04-22 17:27:01 +0530436 "%8s: %10u\n", "TSFOOR", sc->debug.stats.istats.tsfoor);
437 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530438 "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total);
Sujith817e11d2008-12-07 21:42:44 +0530439
Mohammed Shafi Shajakhan6dde1aa2011-04-22 17:27:01 +0530440
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200441 if (len > sizeof(buf))
442 len = sizeof(buf);
443
Sujith817e11d2008-12-07 21:42:44 +0530444 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
445}
446
447static const struct file_operations fops_interrupt = {
448 .read = read_file_interrupt,
449 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200450 .owner = THIS_MODULE,
451 .llseek = default_llseek,
Sujith817e11d2008-12-07 21:42:44 +0530452};
453
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100454#define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum
Sujithfec247c2009-07-27 12:08:16 +0530455#define PR(str, elem) \
456 do { \
457 len += snprintf(buf + len, size - len, \
458 "%s%13u%11u%10u%10u\n", str, \
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100459 sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem, \
460 sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem, \
461 sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem, \
462 sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem); \
Ben Greear7f010c92011-01-09 23:11:49 -0800463 if (len >= size) \
464 goto done; \
Sujithfec247c2009-07-27 12:08:16 +0530465} while(0)
466
Ben Greear1f427dd2011-01-09 23:11:43 -0800467#define PRX(str, elem) \
468do { \
469 len += snprintf(buf + len, size - len, \
470 "%s%13u%11u%10u%10u\n", str, \
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100471 (unsigned int)(sc->tx.txq_map[WME_AC_BE]->elem), \
472 (unsigned int)(sc->tx.txq_map[WME_AC_BK]->elem), \
473 (unsigned int)(sc->tx.txq_map[WME_AC_VI]->elem), \
474 (unsigned int)(sc->tx.txq_map[WME_AC_VO]->elem)); \
Ben Greear7f010c92011-01-09 23:11:49 -0800475 if (len >= size) \
476 goto done; \
Ben Greear1f427dd2011-01-09 23:11:43 -0800477} while(0)
478
Ben Greear2dac4fb2011-01-09 23:11:45 -0800479#define PRQLE(str, elem) \
480do { \
481 len += snprintf(buf + len, size - len, \
482 "%s%13i%11i%10i%10i\n", str, \
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100483 list_empty(&sc->tx.txq_map[WME_AC_BE]->elem), \
484 list_empty(&sc->tx.txq_map[WME_AC_BK]->elem), \
485 list_empty(&sc->tx.txq_map[WME_AC_VI]->elem), \
486 list_empty(&sc->tx.txq_map[WME_AC_VO]->elem)); \
Ben Greear7f010c92011-01-09 23:11:49 -0800487 if (len >= size) \
488 goto done; \
Ben Greear2dac4fb2011-01-09 23:11:45 -0800489} while (0)
490
Sujithfec247c2009-07-27 12:08:16 +0530491static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
492 size_t count, loff_t *ppos)
493{
494 struct ath_softc *sc = file->private_data;
495 char *buf;
Ben Greear7f010c92011-01-09 23:11:49 -0800496 unsigned int len = 0, size = 8000;
Ben Greear2dac4fb2011-01-09 23:11:45 -0800497 int i;
Sujithfec247c2009-07-27 12:08:16 +0530498 ssize_t retval = 0;
Ben Greear2dac4fb2011-01-09 23:11:45 -0800499 char tmp[32];
Sujithfec247c2009-07-27 12:08:16 +0530500
501 buf = kzalloc(size, GFP_KERNEL);
502 if (buf == NULL)
Dan Carpenter04236062010-05-14 15:25:39 +0200503 return -ENOMEM;
Sujithfec247c2009-07-27 12:08:16 +0530504
Ben Greear60f2d1d2011-01-09 23:11:52 -0800505 len += sprintf(buf, "Num-Tx-Queues: %i tx-queues-setup: 0x%x"
506 " poll-work-seen: %u\n"
Ben Greear7f010c92011-01-09 23:11:49 -0800507 "%30s %10s%10s%10s\n\n",
508 ATH9K_NUM_TX_QUEUES, sc->tx.txqsetup,
Ben Greear60f2d1d2011-01-09 23:11:52 -0800509 sc->tx_complete_poll_work_seen,
Ben Greear7f010c92011-01-09 23:11:49 -0800510 "BE", "BK", "VI", "VO");
Sujithfec247c2009-07-27 12:08:16 +0530511
512 PR("MPDUs Queued: ", queued);
513 PR("MPDUs Completed: ", completed);
Felix Fietkau5a6f78a2011-05-31 21:21:41 +0200514 PR("MPDUs XRetried: ", xretries);
Sujithfec247c2009-07-27 12:08:16 +0530515 PR("Aggregates: ", a_aggr);
Ben Greearbda8add2011-01-09 23:11:48 -0800516 PR("AMPDUs Queued HW:", a_queued_hw);
517 PR("AMPDUs Queued SW:", a_queued_sw);
Sujithfec247c2009-07-27 12:08:16 +0530518 PR("AMPDUs Completed:", a_completed);
519 PR("AMPDUs Retried: ", a_retries);
520 PR("AMPDUs XRetried: ", a_xretries);
521 PR("FIFO Underrun: ", fifo_underrun);
522 PR("TXOP Exceeded: ", xtxop);
523 PR("TXTIMER Expiry: ", timer_exp);
524 PR("DESC CFG Error: ", desc_cfg_err);
525 PR("DATA Underrun: ", data_underrun);
526 PR("DELIM Underrun: ", delim_underrun);
Ben Greear99c15bf2010-10-01 12:26:30 -0700527 PR("TX-Pkts-All: ", tx_pkts_all);
528 PR("TX-Bytes-All: ", tx_bytes_all);
Ben Greear2dac4fb2011-01-09 23:11:45 -0800529 PR("hw-put-tx-buf: ", puttxbuf);
530 PR("hw-tx-start: ", txstart);
531 PR("hw-tx-proc-desc: ", txprocdesc);
Ben Greear7f010c92011-01-09 23:11:49 -0800532 len += snprintf(buf + len, size - len,
533 "%s%11p%11p%10p%10p\n", "txq-memory-address:",
Ben Greeardb7889c2011-03-03 16:25:59 -0800534 sc->tx.txq_map[WME_AC_BE],
535 sc->tx.txq_map[WME_AC_BK],
536 sc->tx.txq_map[WME_AC_VI],
537 sc->tx.txq_map[WME_AC_VO]);
Ben Greear7f010c92011-01-09 23:11:49 -0800538 if (len >= size)
539 goto done;
Sujithfec247c2009-07-27 12:08:16 +0530540
Ben Greear1f427dd2011-01-09 23:11:43 -0800541 PRX("axq-qnum: ", axq_qnum);
542 PRX("axq-depth: ", axq_depth);
Ben Greear2dac4fb2011-01-09 23:11:45 -0800543 PRX("axq-ampdu_depth: ", axq_ampdu_depth);
Ben Greear1f427dd2011-01-09 23:11:43 -0800544 PRX("axq-stopped ", stopped);
545 PRX("tx-in-progress ", axq_tx_inprogress);
546 PRX("pending-frames ", pending_frames);
Ben Greear2dac4fb2011-01-09 23:11:45 -0800547 PRX("txq_headidx: ", txq_headidx);
548 PRX("txq_tailidx: ", txq_headidx);
Ben Greear1f427dd2011-01-09 23:11:43 -0800549
Ben Greear2dac4fb2011-01-09 23:11:45 -0800550 PRQLE("axq_q empty: ", axq_q);
551 PRQLE("axq_acq empty: ", axq_acq);
Ben Greear2dac4fb2011-01-09 23:11:45 -0800552 for (i = 0; i < ATH_TXFIFO_DEPTH; i++) {
553 snprintf(tmp, sizeof(tmp) - 1, "txq_fifo[%i] empty: ", i);
554 PRQLE(tmp, txq_fifo[i]);
555 }
Ben Greear7f010c92011-01-09 23:11:49 -0800556
Ben Greear71e025a2011-01-09 23:11:50 -0800557 /* Print out more detailed queue-info */
558 for (i = 0; i <= WME_AC_BK; i++) {
559 struct ath_txq *txq = &(sc->tx.txq[i]);
560 struct ath_atx_ac *ac;
561 struct ath_atx_tid *tid;
562 if (len >= size)
563 goto done;
564 spin_lock_bh(&txq->axq_lock);
565 if (!list_empty(&txq->axq_acq)) {
566 ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac,
567 list);
568 len += snprintf(buf + len, size - len,
569 "txq[%i] first-ac: %p sched: %i\n",
570 i, ac, ac->sched);
571 if (list_empty(&ac->tid_q) || (len >= size))
572 goto done_for;
573 tid = list_first_entry(&ac->tid_q, struct ath_atx_tid,
574 list);
575 len += snprintf(buf + len, size - len,
576 " first-tid: %p sched: %i paused: %i\n",
577 tid, tid->sched, tid->paused);
578 }
579 done_for:
580 spin_unlock_bh(&txq->axq_lock);
581 }
582
Ben Greear7f010c92011-01-09 23:11:49 -0800583done:
584 if (len > size)
585 len = size;
586
587 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
588 kfree(buf);
589
590 return retval;
591}
592
593static ssize_t read_file_stations(struct file *file, char __user *user_buf,
594 size_t count, loff_t *ppos)
595{
596 struct ath_softc *sc = file->private_data;
597 char *buf;
598 unsigned int len = 0, size = 64000;
599 struct ath_node *an = NULL;
600 ssize_t retval = 0;
601 int q;
602
603 buf = kzalloc(size, GFP_KERNEL);
604 if (buf == NULL)
605 return -ENOMEM;
606
607 len += snprintf(buf + len, size - len,
608 "Stations:\n"
Ben Greear7e1e3862011-11-03 11:33:13 -0700609 " tid: addr sched paused buf_q-empty an ac baw\n"
Ben Greear7f010c92011-01-09 23:11:49 -0800610 " ac: addr sched tid_q-empty txq\n");
611
612 spin_lock(&sc->nodes_lock);
613 list_for_each_entry(an, &sc->nodes, list) {
Ben Greear7e1e3862011-11-03 11:33:13 -0700614 unsigned short ma = an->maxampdu;
615 if (ma == 0)
616 ma = 65535; /* see ath_lookup_rate */
Ben Greear7f010c92011-01-09 23:11:49 -0800617 len += snprintf(buf + len, size - len,
Ben Greear7e1e3862011-11-03 11:33:13 -0700618 "iface: %pM sta: %pM max-ampdu: %hu mpdu-density: %uus\n",
619 an->vif->addr, an->sta->addr, ma,
620 (unsigned int)(an->mpdudensity));
Ben Greear7f010c92011-01-09 23:11:49 -0800621 if (len >= size)
622 goto done;
623
624 for (q = 0; q < WME_NUM_TID; q++) {
625 struct ath_atx_tid *tid = &(an->tid[q]);
626 len += snprintf(buf + len, size - len,
Ben Greear7e1e3862011-11-03 11:33:13 -0700627 " tid: %p %s %s %i %p %p %hu\n",
Ben Greear7f010c92011-01-09 23:11:49 -0800628 tid, tid->sched ? "sched" : "idle",
629 tid->paused ? "paused" : "running",
Felix Fietkau56dc6332011-08-28 00:32:22 +0200630 skb_queue_empty(&tid->buf_q),
Ben Greear7e1e3862011-11-03 11:33:13 -0700631 tid->an, tid->ac, tid->baw_size);
Ben Greear7f010c92011-01-09 23:11:49 -0800632 if (len >= size)
633 goto done;
634 }
635
636 for (q = 0; q < WME_NUM_AC; q++) {
637 struct ath_atx_ac *ac = &(an->ac[q]);
638 len += snprintf(buf + len, size - len,
639 " ac: %p %s %i %p\n",
640 ac, ac->sched ? "sched" : "idle",
641 list_empty(&ac->tid_q), ac->txq);
642 if (len >= size)
643 goto done;
644 }
645 }
646
647done:
648 spin_unlock(&sc->nodes_lock);
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200649 if (len > size)
650 len = size;
651
Sujithfec247c2009-07-27 12:08:16 +0530652 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
653 kfree(buf);
654
655 return retval;
656}
657
Ben Greear55f6d0f2011-01-17 11:54:50 -0800658static ssize_t read_file_misc(struct file *file, char __user *user_buf,
659 size_t count, loff_t *ppos)
660{
661 struct ath_softc *sc = file->private_data;
662 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Ben Greear55f6d0f2011-01-17 11:54:50 -0800663 struct ieee80211_hw *hw = sc->hw;
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530664 struct ath9k_vif_iter_data iter_data;
665 char buf[512];
666 unsigned int len = 0;
Ben Greear55f6d0f2011-01-17 11:54:50 -0800667 ssize_t retval = 0;
Ben Greear55f6d0f2011-01-17 11:54:50 -0800668 unsigned int reg;
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530669 u32 rxfilter;
Ben Greear55f6d0f2011-01-17 11:54:50 -0800670
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530671 len += snprintf(buf + len, sizeof(buf) - len,
672 "BSSID: %pM\n", common->curbssid);
673 len += snprintf(buf + len, sizeof(buf) - len,
674 "BSSID-MASK: %pM\n", common->bssidmask);
675 len += snprintf(buf + len, sizeof(buf) - len,
676 "OPMODE: %s\n", ath_opmode_to_string(sc->sc_ah->opmode));
Ben Greear55f6d0f2011-01-17 11:54:50 -0800677
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +0530678 ath9k_ps_wakeup(sc);
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530679 rxfilter = ath9k_hw_getrxfilter(sc->sc_ah);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +0530680 ath9k_ps_restore(sc);
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530681
682 len += snprintf(buf + len, sizeof(buf) - len,
683 "RXFILTER: 0x%x", rxfilter);
684
685 if (rxfilter & ATH9K_RX_FILTER_UCAST)
686 len += snprintf(buf + len, sizeof(buf) - len, " UCAST");
687 if (rxfilter & ATH9K_RX_FILTER_MCAST)
688 len += snprintf(buf + len, sizeof(buf) - len, " MCAST");
689 if (rxfilter & ATH9K_RX_FILTER_BCAST)
690 len += snprintf(buf + len, sizeof(buf) - len, " BCAST");
691 if (rxfilter & ATH9K_RX_FILTER_CONTROL)
692 len += snprintf(buf + len, sizeof(buf) - len, " CONTROL");
693 if (rxfilter & ATH9K_RX_FILTER_BEACON)
694 len += snprintf(buf + len, sizeof(buf) - len, " BEACON");
695 if (rxfilter & ATH9K_RX_FILTER_PROM)
696 len += snprintf(buf + len, sizeof(buf) - len, " PROM");
697 if (rxfilter & ATH9K_RX_FILTER_PROBEREQ)
698 len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ");
699 if (rxfilter & ATH9K_RX_FILTER_PHYERR)
700 len += snprintf(buf + len, sizeof(buf) - len, " PHYERR");
701 if (rxfilter & ATH9K_RX_FILTER_MYBEACON)
702 len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON");
703 if (rxfilter & ATH9K_RX_FILTER_COMP_BAR)
704 len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR");
705 if (rxfilter & ATH9K_RX_FILTER_PSPOLL)
706 len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL");
707 if (rxfilter & ATH9K_RX_FILTER_PHYRADAR)
708 len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR");
709 if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL)
710 len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL");
711 if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER)
712 len += snprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER");
713
714 len += snprintf(buf + len, sizeof(buf) - len, "\n");
Ben Greear55f6d0f2011-01-17 11:54:50 -0800715
716 reg = sc->sc_ah->imask;
Ben Greear55f6d0f2011-01-17 11:54:50 -0800717
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530718 len += snprintf(buf + len, sizeof(buf) - len, "INTERRUPT-MASK: 0x%x", reg);
719
720 if (reg & ATH9K_INT_SWBA)
721 len += snprintf(buf + len, sizeof(buf) - len, " SWBA");
722 if (reg & ATH9K_INT_BMISS)
723 len += snprintf(buf + len, sizeof(buf) - len, " BMISS");
724 if (reg & ATH9K_INT_CST)
725 len += snprintf(buf + len, sizeof(buf) - len, " CST");
726 if (reg & ATH9K_INT_RX)
727 len += snprintf(buf + len, sizeof(buf) - len, " RX");
728 if (reg & ATH9K_INT_RXHP)
729 len += snprintf(buf + len, sizeof(buf) - len, " RXHP");
730 if (reg & ATH9K_INT_RXLP)
731 len += snprintf(buf + len, sizeof(buf) - len, " RXLP");
732 if (reg & ATH9K_INT_BB_WATCHDOG)
733 len += snprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG");
734
735 len += snprintf(buf + len, sizeof(buf) - len, "\n");
736
737 ath9k_calculate_iter_data(hw, NULL, &iter_data);
738
739 len += snprintf(buf + len, sizeof(buf) - len,
740 "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i"
741 " ADHOC: %i OTHER: %i TOTAL: %hi BEACON-VIF: %hi\n",
Ben Greear55f6d0f2011-01-17 11:54:50 -0800742 iter_data.naps, iter_data.nstations, iter_data.nmeshes,
743 iter_data.nwds, iter_data.nadhocs, iter_data.nothers,
744 sc->nvifs, sc->nbcnvifs);
745
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530746 if (len > sizeof(buf))
747 len = sizeof(buf);
Ben Greear55f6d0f2011-01-17 11:54:50 -0800748
749 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
Ben Greear55f6d0f2011-01-17 11:54:50 -0800750 return retval;
751}
752
Felix Fietkau066dae92010-11-07 14:59:39 +0100753void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
Felix Fietkau55797b12011-09-14 21:24:16 +0200754 struct ath_tx_status *ts, struct ath_txq *txq,
755 unsigned int flags)
Sujithfec247c2009-07-27 12:08:16 +0530756{
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530757#define TX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].ts\
758 [sc->debug.tsidx].c)
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100759 int qnum = txq->axq_qnum;
Felix Fietkau066dae92010-11-07 14:59:39 +0100760
761 TX_STAT_INC(qnum, tx_pkts_all);
762 sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len;
Ben Greear99c15bf2010-10-01 12:26:30 -0700763
Sujithfec247c2009-07-27 12:08:16 +0530764 if (bf_isampdu(bf)) {
Felix Fietkau156369f2011-12-14 22:08:04 +0100765 if (flags & ATH_TX_ERROR)
Felix Fietkau066dae92010-11-07 14:59:39 +0100766 TX_STAT_INC(qnum, a_xretries);
Sujithfec247c2009-07-27 12:08:16 +0530767 else
Felix Fietkau066dae92010-11-07 14:59:39 +0100768 TX_STAT_INC(qnum, a_completed);
Sujithfec247c2009-07-27 12:08:16 +0530769 } else {
Felix Fietkau55797b12011-09-14 21:24:16 +0200770 if (ts->ts_status & ATH9K_TXERR_XRETRY)
Felix Fietkau5a6f78a2011-05-31 21:21:41 +0200771 TX_STAT_INC(qnum, xretries);
772 else
773 TX_STAT_INC(qnum, completed);
Sujithfec247c2009-07-27 12:08:16 +0530774 }
775
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700776 if (ts->ts_status & ATH9K_TXERR_FIFO)
Felix Fietkau066dae92010-11-07 14:59:39 +0100777 TX_STAT_INC(qnum, fifo_underrun);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700778 if (ts->ts_status & ATH9K_TXERR_XTXOP)
Felix Fietkau066dae92010-11-07 14:59:39 +0100779 TX_STAT_INC(qnum, xtxop);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700780 if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED)
Felix Fietkau066dae92010-11-07 14:59:39 +0100781 TX_STAT_INC(qnum, timer_exp);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700782 if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR)
Felix Fietkau066dae92010-11-07 14:59:39 +0100783 TX_STAT_INC(qnum, desc_cfg_err);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700784 if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN)
Felix Fietkau066dae92010-11-07 14:59:39 +0100785 TX_STAT_INC(qnum, data_underrun);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700786 if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
Felix Fietkau066dae92010-11-07 14:59:39 +0100787 TX_STAT_INC(qnum, delim_underrun);
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530788
789 spin_lock(&sc->debug.samp_lock);
790 TX_SAMP_DBG(jiffies) = jiffies;
791 TX_SAMP_DBG(rssi_ctl0) = ts->ts_rssi_ctl0;
792 TX_SAMP_DBG(rssi_ctl1) = ts->ts_rssi_ctl1;
793 TX_SAMP_DBG(rssi_ctl2) = ts->ts_rssi_ctl2;
794 TX_SAMP_DBG(rssi_ext0) = ts->ts_rssi_ext0;
795 TX_SAMP_DBG(rssi_ext1) = ts->ts_rssi_ext1;
796 TX_SAMP_DBG(rssi_ext2) = ts->ts_rssi_ext2;
797 TX_SAMP_DBG(rateindex) = ts->ts_rateindex;
798 TX_SAMP_DBG(isok) = !!(ts->ts_status & ATH9K_TXERR_MASK);
799 TX_SAMP_DBG(rts_fail_cnt) = ts->ts_shortretry;
800 TX_SAMP_DBG(data_fail_cnt) = ts->ts_longretry;
801 TX_SAMP_DBG(rssi) = ts->ts_rssi;
802 TX_SAMP_DBG(tid) = ts->tid;
803 TX_SAMP_DBG(qid) = ts->qid;
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +0530804
805 if (ts->ts_flags & ATH9K_TX_BA) {
806 TX_SAMP_DBG(ba_low) = ts->ba_low;
807 TX_SAMP_DBG(ba_high) = ts->ba_high;
808 } else {
809 TX_SAMP_DBG(ba_low) = 0;
810 TX_SAMP_DBG(ba_high) = 0;
811 }
812
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530813 sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES;
814 spin_unlock(&sc->debug.samp_lock);
815
816#undef TX_SAMP_DBG
Sujithfec247c2009-07-27 12:08:16 +0530817}
818
819static const struct file_operations fops_xmit = {
820 .read = read_file_xmit,
821 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200822 .owner = THIS_MODULE,
823 .llseek = default_llseek,
Sujithfec247c2009-07-27 12:08:16 +0530824};
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200825
Ben Greear7f010c92011-01-09 23:11:49 -0800826static const struct file_operations fops_stations = {
827 .read = read_file_stations,
828 .open = ath9k_debugfs_open,
829 .owner = THIS_MODULE,
830 .llseek = default_llseek,
831};
832
Ben Greear55f6d0f2011-01-17 11:54:50 -0800833static const struct file_operations fops_misc = {
834 .read = read_file_misc,
835 .open = ath9k_debugfs_open,
836 .owner = THIS_MODULE,
837 .llseek = default_llseek,
838};
839
Sujith1395d3f2010-01-08 10:36:11 +0530840static ssize_t read_file_recv(struct file *file, char __user *user_buf,
841 size_t count, loff_t *ppos)
842{
843#define PHY_ERR(s, p) \
844 len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \
845 sc->debug.stats.rxstats.phy_err_stats[p]);
846
847 struct ath_softc *sc = file->private_data;
848 char *buf;
Senthil Balasubramanian7d755412011-04-08 15:30:34 +0530849 unsigned int len = 0, size = 1400;
Sujith1395d3f2010-01-08 10:36:11 +0530850 ssize_t retval = 0;
851
852 buf = kzalloc(size, GFP_KERNEL);
853 if (buf == NULL)
Dan Carpenter04236062010-05-14 15:25:39 +0200854 return -ENOMEM;
Sujith1395d3f2010-01-08 10:36:11 +0530855
856 len += snprintf(buf + len, size - len,
857 "%18s : %10u\n", "CRC ERR",
858 sc->debug.stats.rxstats.crc_err);
859 len += snprintf(buf + len, size - len,
860 "%18s : %10u\n", "DECRYPT CRC ERR",
861 sc->debug.stats.rxstats.decrypt_crc_err);
862 len += snprintf(buf + len, size - len,
863 "%18s : %10u\n", "PHY ERR",
864 sc->debug.stats.rxstats.phy_err);
865 len += snprintf(buf + len, size - len,
866 "%18s : %10u\n", "MIC ERR",
867 sc->debug.stats.rxstats.mic_err);
868 len += snprintf(buf + len, size - len,
869 "%18s : %10u\n", "PRE-DELIM CRC ERR",
870 sc->debug.stats.rxstats.pre_delim_crc_err);
871 len += snprintf(buf + len, size - len,
872 "%18s : %10u\n", "POST-DELIM CRC ERR",
873 sc->debug.stats.rxstats.post_delim_crc_err);
874 len += snprintf(buf + len, size - len,
875 "%18s : %10u\n", "DECRYPT BUSY ERR",
876 sc->debug.stats.rxstats.decrypt_busy_err);
877
Senthil Balasubramanian7d755412011-04-08 15:30:34 +0530878 len += snprintf(buf + len, size - len,
879 "%18s : %10d\n", "RSSI-CTL0",
880 sc->debug.stats.rxstats.rs_rssi_ctl0);
881
882 len += snprintf(buf + len, size - len,
883 "%18s : %10d\n", "RSSI-CTL1",
884 sc->debug.stats.rxstats.rs_rssi_ctl1);
885
886 len += snprintf(buf + len, size - len,
887 "%18s : %10d\n", "RSSI-CTL2",
888 sc->debug.stats.rxstats.rs_rssi_ctl2);
889
890 len += snprintf(buf + len, size - len,
891 "%18s : %10d\n", "RSSI-EXT0",
892 sc->debug.stats.rxstats.rs_rssi_ext0);
893
894 len += snprintf(buf + len, size - len,
895 "%18s : %10d\n", "RSSI-EXT1",
896 sc->debug.stats.rxstats.rs_rssi_ext1);
897
898 len += snprintf(buf + len, size - len,
899 "%18s : %10d\n", "RSSI-EXT2",
900 sc->debug.stats.rxstats.rs_rssi_ext2);
901
902 len += snprintf(buf + len, size - len,
903 "%18s : %10d\n", "Rx Antenna",
904 sc->debug.stats.rxstats.rs_antenna);
905
Sujith1395d3f2010-01-08 10:36:11 +0530906 PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN);
907 PHY_ERR("TIMING", ATH9K_PHYERR_TIMING);
908 PHY_ERR("PARITY", ATH9K_PHYERR_PARITY);
909 PHY_ERR("RATE", ATH9K_PHYERR_RATE);
910 PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH);
911 PHY_ERR("RADAR", ATH9K_PHYERR_RADAR);
912 PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE);
913 PHY_ERR("TOR", ATH9K_PHYERR_TOR);
914 PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING);
915 PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY);
916 PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL);
917 PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL);
918 PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP);
919 PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE);
920 PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART);
921 PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT);
922 PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING);
923 PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC);
924 PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL);
925 PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE);
926 PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART);
927 PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL);
928 PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP);
929 PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR);
930 PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
931 PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL);
932
Ben Greear99c15bf2010-10-01 12:26:30 -0700933 len += snprintf(buf + len, size - len,
934 "%18s : %10u\n", "RX-Pkts-All",
935 sc->debug.stats.rxstats.rx_pkts_all);
936 len += snprintf(buf + len, size - len,
937 "%18s : %10u\n", "RX-Bytes-All",
938 sc->debug.stats.rxstats.rx_bytes_all);
939
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200940 if (len > size)
941 len = size;
942
Sujith1395d3f2010-01-08 10:36:11 +0530943 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
944 kfree(buf);
945
946 return retval;
947
948#undef PHY_ERR
949}
950
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700951void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
Sujith1395d3f2010-01-08 10:36:11 +0530952{
953#define RX_STAT_INC(c) sc->debug.stats.rxstats.c++
954#define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530955#define RX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].rs\
956 [sc->debug.rsidx].c)
Sujith1395d3f2010-01-08 10:36:11 +0530957
Sujith1395d3f2010-01-08 10:36:11 +0530958 u32 phyerr;
959
Ben Greear99c15bf2010-10-01 12:26:30 -0700960 RX_STAT_INC(rx_pkts_all);
961 sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen;
962
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700963 if (rs->rs_status & ATH9K_RXERR_CRC)
Sujith1395d3f2010-01-08 10:36:11 +0530964 RX_STAT_INC(crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700965 if (rs->rs_status & ATH9K_RXERR_DECRYPT)
Sujith1395d3f2010-01-08 10:36:11 +0530966 RX_STAT_INC(decrypt_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700967 if (rs->rs_status & ATH9K_RXERR_MIC)
Sujith1395d3f2010-01-08 10:36:11 +0530968 RX_STAT_INC(mic_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700969 if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE)
Sujith1395d3f2010-01-08 10:36:11 +0530970 RX_STAT_INC(pre_delim_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700971 if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST)
Sujith1395d3f2010-01-08 10:36:11 +0530972 RX_STAT_INC(post_delim_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700973 if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY)
Sujith1395d3f2010-01-08 10:36:11 +0530974 RX_STAT_INC(decrypt_busy_err);
975
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700976 if (rs->rs_status & ATH9K_RXERR_PHY) {
Sujith1395d3f2010-01-08 10:36:11 +0530977 RX_STAT_INC(phy_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700978 phyerr = rs->rs_phyerr & 0x24;
Sujith1395d3f2010-01-08 10:36:11 +0530979 RX_PHY_ERR_INC(phyerr);
980 }
981
Senthil Balasubramanian7d755412011-04-08 15:30:34 +0530982 sc->debug.stats.rxstats.rs_rssi_ctl0 = rs->rs_rssi_ctl0;
983 sc->debug.stats.rxstats.rs_rssi_ctl1 = rs->rs_rssi_ctl1;
984 sc->debug.stats.rxstats.rs_rssi_ctl2 = rs->rs_rssi_ctl2;
985
986 sc->debug.stats.rxstats.rs_rssi_ext0 = rs->rs_rssi_ext0;
987 sc->debug.stats.rxstats.rs_rssi_ext1 = rs->rs_rssi_ext1;
988 sc->debug.stats.rxstats.rs_rssi_ext2 = rs->rs_rssi_ext2;
989
990 sc->debug.stats.rxstats.rs_antenna = rs->rs_antenna;
991
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530992 spin_lock(&sc->debug.samp_lock);
993 RX_SAMP_DBG(jiffies) = jiffies;
994 RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0;
995 RX_SAMP_DBG(rssi_ctl1) = rs->rs_rssi_ctl1;
996 RX_SAMP_DBG(rssi_ctl2) = rs->rs_rssi_ctl2;
997 RX_SAMP_DBG(rssi_ext0) = rs->rs_rssi_ext0;
998 RX_SAMP_DBG(rssi_ext1) = rs->rs_rssi_ext1;
999 RX_SAMP_DBG(rssi_ext2) = rs->rs_rssi_ext2;
1000 RX_SAMP_DBG(antenna) = rs->rs_antenna;
1001 RX_SAMP_DBG(rssi) = rs->rs_rssi;
1002 RX_SAMP_DBG(rate) = rs->rs_rate;
1003 RX_SAMP_DBG(is_mybeacon) = rs->is_mybeacon;
1004
1005 sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES;
1006 spin_unlock(&sc->debug.samp_lock);
1007
Sujith1395d3f2010-01-08 10:36:11 +05301008#undef RX_STAT_INC
1009#undef RX_PHY_ERR_INC
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301010#undef RX_SAMP_DBG
Sujith1395d3f2010-01-08 10:36:11 +05301011}
1012
1013static const struct file_operations fops_recv = {
1014 .read = read_file_recv,
1015 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001016 .owner = THIS_MODULE,
1017 .llseek = default_llseek,
Sujith1395d3f2010-01-08 10:36:11 +05301018};
1019
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001020static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
1021 size_t count, loff_t *ppos)
1022{
1023 struct ath_softc *sc = file->private_data;
1024 char buf[32];
1025 unsigned int len;
1026
Dan Carpenter2b87f3a2010-05-14 15:24:37 +02001027 len = sprintf(buf, "0x%08x\n", sc->debug.regidx);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001028 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1029}
1030
1031static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
1032 size_t count, loff_t *ppos)
1033{
1034 struct ath_softc *sc = file->private_data;
1035 unsigned long regidx;
1036 char buf[32];
1037 ssize_t len;
1038
1039 len = min(count, sizeof(buf) - 1);
1040 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +02001041 return -EFAULT;
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001042
1043 buf[len] = '\0';
1044 if (strict_strtoul(buf, 0, &regidx))
1045 return -EINVAL;
1046
1047 sc->debug.regidx = regidx;
1048 return count;
1049}
1050
1051static const struct file_operations fops_regidx = {
1052 .read = read_file_regidx,
1053 .write = write_file_regidx,
1054 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001055 .owner = THIS_MODULE,
1056 .llseek = default_llseek,
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001057};
1058
1059static ssize_t read_file_regval(struct file *file, char __user *user_buf,
1060 size_t count, loff_t *ppos)
1061{
1062 struct ath_softc *sc = file->private_data;
1063 struct ath_hw *ah = sc->sc_ah;
1064 char buf[32];
1065 unsigned int len;
1066 u32 regval;
1067
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301068 ath9k_ps_wakeup(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001069 regval = REG_READ_D(ah, sc->debug.regidx);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301070 ath9k_ps_restore(sc);
Dan Carpenter2b87f3a2010-05-14 15:24:37 +02001071 len = sprintf(buf, "0x%08x\n", regval);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001072 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1073}
1074
1075static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
1076 size_t count, loff_t *ppos)
1077{
1078 struct ath_softc *sc = file->private_data;
1079 struct ath_hw *ah = sc->sc_ah;
1080 unsigned long regval;
1081 char buf[32];
1082 ssize_t len;
1083
1084 len = min(count, sizeof(buf) - 1);
1085 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +02001086 return -EFAULT;
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001087
1088 buf[len] = '\0';
1089 if (strict_strtoul(buf, 0, &regval))
1090 return -EINVAL;
1091
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301092 ath9k_ps_wakeup(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001093 REG_WRITE_D(ah, sc->debug.regidx, regval);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301094 ath9k_ps_restore(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001095 return count;
1096}
1097
1098static const struct file_operations fops_regval = {
1099 .read = read_file_regval,
1100 .write = write_file_regval,
1101 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001102 .owner = THIS_MODULE,
1103 .llseek = default_llseek,
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001104};
1105
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -08001106#define REGDUMP_LINE_SIZE 20
1107
1108static int open_file_regdump(struct inode *inode, struct file *file)
1109{
1110 struct ath_softc *sc = inode->i_private;
1111 unsigned int len = 0;
1112 u8 *buf;
1113 int i;
1114 unsigned long num_regs, regdump_len, max_reg_offset;
1115
1116 max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500;
1117 num_regs = max_reg_offset / 4 + 1;
1118 regdump_len = num_regs * REGDUMP_LINE_SIZE + 1;
1119 buf = vmalloc(regdump_len);
1120 if (!buf)
1121 return -ENOMEM;
1122
1123 ath9k_ps_wakeup(sc);
1124 for (i = 0; i < num_regs; i++)
1125 len += scnprintf(buf + len, regdump_len - len,
1126 "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2));
1127 ath9k_ps_restore(sc);
1128
1129 file->private_data = buf;
1130
1131 return 0;
1132}
1133
1134static const struct file_operations fops_regdump = {
1135 .open = open_file_regdump,
1136 .read = ath9k_debugfs_read_buf,
1137 .release = ath9k_debugfs_release_buf,
1138 .owner = THIS_MODULE,
1139 .llseek = default_llseek,/* read accesses f_pos */
1140};
1141
Rajkumar Manoharand069a462011-08-13 10:28:18 +05301142static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf,
1143 size_t count, loff_t *ppos)
1144{
1145 struct ath_softc *sc = file->private_data;
1146 struct ath_hw *ah = sc->sc_ah;
1147 struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist;
1148 struct ath_common *common = ath9k_hw_common(ah);
1149 struct ieee80211_conf *conf = &common->hw->conf;
1150 u32 len = 0, size = 1500;
1151 u32 i, j;
1152 ssize_t retval = 0;
1153 char *buf;
1154 u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
1155 u8 nread;
1156
1157 buf = kzalloc(size, GFP_KERNEL);
1158 if (!buf)
1159 return -ENOMEM;
1160
1161 len += snprintf(buf + len, size - len,
1162 "Channel Noise Floor : %d\n", ah->noise);
1163 len += snprintf(buf + len, size - len,
1164 "Chain | privNF | # Readings | NF Readings\n");
1165 for (i = 0; i < NUM_NF_READINGS; i++) {
1166 if (!(chainmask & (1 << i)) ||
1167 ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
1168 continue;
1169
1170 nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount;
1171 len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t",
1172 i, h[i].privNF, nread);
1173 for (j = 0; j < nread; j++)
1174 len += snprintf(buf + len, size - len,
1175 " %d", h[i].nfCalBuffer[j]);
1176 len += snprintf(buf + len, size - len, "\n");
1177 }
1178
1179 if (len > size)
1180 len = size;
1181
1182 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1183 kfree(buf);
1184
1185 return retval;
1186}
1187
1188static const struct file_operations fops_dump_nfcal = {
1189 .read = read_file_dump_nfcal,
1190 .open = ath9k_debugfs_open,
1191 .owner = THIS_MODULE,
1192 .llseek = default_llseek,
1193};
1194
Rajkumar Manoharan580f0102011-07-29 17:38:12 +05301195static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
1196 size_t count, loff_t *ppos)
1197{
1198 struct ath_softc *sc = file->private_data;
1199 struct ath_hw *ah = sc->sc_ah;
1200 u32 len = 0, size = 1500;
1201 ssize_t retval = 0;
1202 char *buf;
1203
1204 buf = kzalloc(size, GFP_KERNEL);
1205 if (!buf)
1206 return -ENOMEM;
1207
1208 len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size);
1209
1210 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1211 kfree(buf);
1212
1213 return retval;
1214}
1215
1216static const struct file_operations fops_base_eeprom = {
1217 .read = read_file_base_eeprom,
1218 .open = ath9k_debugfs_open,
1219 .owner = THIS_MODULE,
1220 .llseek = default_llseek,
1221};
1222
Rajkumar Manoharan3f4c4bd2011-07-29 17:38:13 +05301223static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf,
1224 size_t count, loff_t *ppos)
1225{
1226 struct ath_softc *sc = file->private_data;
1227 struct ath_hw *ah = sc->sc_ah;
1228 u32 len = 0, size = 6000;
1229 char *buf;
1230 size_t retval;
1231
1232 buf = kzalloc(size, GFP_KERNEL);
1233 if (buf == NULL)
1234 return -ENOMEM;
1235
1236 len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size);
1237
1238 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1239 kfree(buf);
1240
1241 return retval;
1242}
1243
1244static const struct file_operations fops_modal_eeprom = {
1245 .read = read_file_modal_eeprom,
1246 .open = ath9k_debugfs_open,
1247 .owner = THIS_MODULE,
1248 .llseek = default_llseek,
1249};
1250
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301251void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
1252{
1253#define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c)
1254 struct ath_hw *ah = sc->sc_ah;
1255 struct ath_common *common = ath9k_hw_common(ah);
1256 unsigned long flags;
1257 int i;
1258
1259 ath9k_ps_wakeup(sc);
1260
Rajkumar Manoharan6bc05a92011-09-06 21:00:07 +05301261 spin_lock_bh(&sc->debug.samp_lock);
1262
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301263 spin_lock_irqsave(&common->cc_lock, flags);
1264 ath_hw_cycle_counters_update(common);
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301265
1266 ATH_SAMP_DBG(cc.cycles) = common->cc_ani.cycles;
1267 ATH_SAMP_DBG(cc.rx_busy) = common->cc_ani.rx_busy;
1268 ATH_SAMP_DBG(cc.rx_frame) = common->cc_ani.rx_frame;
1269 ATH_SAMP_DBG(cc.tx_frame) = common->cc_ani.tx_frame;
Rajkumar Manoharan6bc05a92011-09-06 21:00:07 +05301270 spin_unlock_irqrestore(&common->cc_lock, flags);
1271
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301272 ATH_SAMP_DBG(noise) = ah->noise;
1273
1274 REG_WRITE_D(ah, AR_MACMISC,
1275 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
1276 (AR_MACMISC_MISC_OBS_BUS_1 <<
1277 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
1278
1279 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++)
1280 ATH_SAMP_DBG(dma_dbg_reg_vals[i]) = REG_READ_D(ah,
1281 AR_DMADBG_0 + (i * sizeof(u32)));
1282
1283 ATH_SAMP_DBG(pcu_obs) = REG_READ_D(ah, AR_OBS_BUS_1);
1284 ATH_SAMP_DBG(pcu_cr) = REG_READ_D(ah, AR_CR);
1285
1286 memcpy(ATH_SAMP_DBG(nfCalHist), sc->caldata.nfCalHist,
1287 sizeof(ATH_SAMP_DBG(nfCalHist)));
1288
1289 sc->debug.sampidx = (sc->debug.sampidx + 1) % ATH_DBG_MAX_SAMPLES;
1290 spin_unlock_bh(&sc->debug.samp_lock);
1291 ath9k_ps_restore(sc);
1292
1293#undef ATH_SAMP_DBG
1294}
1295
1296static int open_file_bb_mac_samps(struct inode *inode, struct file *file)
1297{
1298#define ATH_SAMP_DBG(c) bb_mac_samp[sampidx].c
1299 struct ath_softc *sc = inode->i_private;
1300 struct ath_hw *ah = sc->sc_ah;
1301 struct ath_common *common = ath9k_hw_common(ah);
1302 struct ieee80211_conf *conf = &common->hw->conf;
1303 struct ath_dbg_bb_mac_samp *bb_mac_samp;
1304 struct ath9k_nfcal_hist *h;
1305 int i, j, qcuOffset = 0, dcuOffset = 0;
1306 u32 *qcuBase, *dcuBase, size = 30000, len = 0;
1307 u32 sampidx = 0;
1308 u8 *buf;
1309 u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
1310 u8 nread;
1311
Rajkumar Manoharanf7e014d2011-09-06 21:00:06 +05301312 if (sc->sc_flags & SC_OP_INVALID)
1313 return -EAGAIN;
1314
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301315 buf = vmalloc(size);
1316 if (!buf)
1317 return -ENOMEM;
1318 bb_mac_samp = vmalloc(sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES);
1319 if (!bb_mac_samp) {
1320 vfree(buf);
1321 return -ENOMEM;
1322 }
Rajkumar Manoharanf7e014d2011-09-06 21:00:06 +05301323 /* Account the current state too */
1324 ath9k_debug_samp_bb_mac(sc);
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301325
1326 spin_lock_bh(&sc->debug.samp_lock);
1327 memcpy(bb_mac_samp, sc->debug.bb_mac_samp,
1328 sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES);
Rajkumar Manoharan6bc05a92011-09-06 21:00:07 +05301329 len += snprintf(buf + len, size - len,
1330 "Current Sample Index: %d\n", sc->debug.sampidx);
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301331 spin_unlock_bh(&sc->debug.samp_lock);
1332
1333 len += snprintf(buf + len, size - len,
1334 "Raw DMA Debug Dump:\n");
1335 len += snprintf(buf + len, size - len, "Sample |\t");
1336 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++)
1337 len += snprintf(buf + len, size - len, " DMA Reg%d |\t", i);
1338 len += snprintf(buf + len, size - len, "\n");
1339
1340 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1341 len += snprintf(buf + len, size - len, "%d\t", sampidx);
1342
1343 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++)
1344 len += snprintf(buf + len, size - len, " %08x\t",
1345 ATH_SAMP_DBG(dma_dbg_reg_vals[i]));
1346 len += snprintf(buf + len, size - len, "\n");
1347 }
1348 len += snprintf(buf + len, size - len, "\n");
1349
1350 len += snprintf(buf + len, size - len,
1351 "Sample Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
1352 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1353 qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]);
1354 dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]);
1355
1356 for (i = 0; i < ATH9K_NUM_QUEUES; i++,
1357 qcuOffset += 4, dcuOffset += 5) {
1358 if (i == 8) {
1359 qcuOffset = 0;
1360 qcuBase++;
1361 }
1362
1363 if (i == 6) {
1364 dcuOffset = 0;
1365 dcuBase++;
1366 }
1367 if (!sc->debug.stats.txstats[i].queued)
1368 continue;
1369
1370 len += snprintf(buf + len, size - len,
1371 "%4d %7d %2x %1x %2x %2x\n",
1372 sampidx, i,
1373 (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
1374 (*qcuBase & (0x8 << qcuOffset)) >>
1375 (qcuOffset + 3),
1376 ATH_SAMP_DBG(dma_dbg_reg_vals[2]) &
1377 (0x7 << (i * 3)) >> (i * 3),
1378 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
1379 }
1380 len += snprintf(buf + len, size - len, "\n");
1381 }
1382 len += snprintf(buf + len, size - len,
1383 "samp qcu_sh qcu_fh qcu_comp dcu_comp dcu_arb dcu_fp "
1384 "ch_idle_dur ch_idle_dur_val txfifo_val0 txfifo_val1 "
1385 "txfifo_dcu0 txfifo_dcu1 pcu_obs AR_CR\n");
1386
1387 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1388 qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]);
1389 dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]);
1390
1391 len += snprintf(buf + len, size - len, "%4d %5x %5x ", sampidx,
1392 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x003c0000) >> 18,
1393 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x03c00000) >> 22);
1394 len += snprintf(buf + len, size - len, "%7x %8x ",
1395 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x1c000000) >> 26,
1396 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x3));
1397 len += snprintf(buf + len, size - len, "%7x %7x ",
1398 (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x06000000) >> 25,
1399 (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x38000000) >> 27);
1400 len += snprintf(buf + len, size - len, "%7d %12d ",
1401 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x000003fc) >> 2,
1402 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000400) >> 10);
1403 len += snprintf(buf + len, size - len, "%12d %12d ",
1404 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000800) >> 11,
1405 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00001000) >> 12);
1406 len += snprintf(buf + len, size - len, "%12d %12d ",
1407 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x0001e000) >> 13,
1408 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x001e0000) >> 17);
1409 len += snprintf(buf + len, size - len, "0x%07x 0x%07x\n",
1410 ATH_SAMP_DBG(pcu_obs), ATH_SAMP_DBG(pcu_cr));
1411 }
1412
1413 len += snprintf(buf + len, size - len,
1414 "Sample ChNoise Chain privNF #Reading Readings\n");
1415 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1416 h = ATH_SAMP_DBG(nfCalHist);
1417 if (!ATH_SAMP_DBG(noise))
1418 continue;
1419
1420 for (i = 0; i < NUM_NF_READINGS; i++) {
1421 if (!(chainmask & (1 << i)) ||
1422 ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
1423 continue;
1424
1425 nread = AR_PHY_CCA_FILTERWINDOW_LENGTH -
1426 h[i].invalidNFcount;
1427 len += snprintf(buf + len, size - len,
1428 "%4d %5d %4d\t %d\t %d\t",
1429 sampidx, ATH_SAMP_DBG(noise),
1430 i, h[i].privNF, nread);
1431 for (j = 0; j < nread; j++)
1432 len += snprintf(buf + len, size - len,
1433 " %d", h[i].nfCalBuffer[j]);
1434 len += snprintf(buf + len, size - len, "\n");
1435 }
1436 }
1437 len += snprintf(buf + len, size - len, "\nCycle counters:\n"
1438 "Sample Total Rxbusy Rxframes Txframes\n");
1439 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1440 if (!ATH_SAMP_DBG(cc.cycles))
1441 continue;
1442 len += snprintf(buf + len, size - len,
1443 "%4d %08x %08x %08x %08x\n",
1444 sampidx, ATH_SAMP_DBG(cc.cycles),
1445 ATH_SAMP_DBG(cc.rx_busy),
1446 ATH_SAMP_DBG(cc.rx_frame),
1447 ATH_SAMP_DBG(cc.tx_frame));
1448 }
1449
1450 len += snprintf(buf + len, size - len, "Tx status Dump :\n");
1451 len += snprintf(buf + len, size - len,
1452 "Sample rssi:- ctl0 ctl1 ctl2 ext0 ext1 ext2 comb "
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +05301453 "isok rts_fail data_fail rate tid qid "
1454 "ba_low ba_high tx_before(ms)\n");
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301455 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1456 for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) {
1457 if (!ATH_SAMP_DBG(ts[i].jiffies))
1458 continue;
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +05301459 len += snprintf(buf + len, size - len, "%-14d"
1460 "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-8d "
1461 "%-9d %-4d %-3d %-3d %08x %08x %-11d\n",
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301462 sampidx,
1463 ATH_SAMP_DBG(ts[i].rssi_ctl0),
1464 ATH_SAMP_DBG(ts[i].rssi_ctl1),
1465 ATH_SAMP_DBG(ts[i].rssi_ctl2),
1466 ATH_SAMP_DBG(ts[i].rssi_ext0),
1467 ATH_SAMP_DBG(ts[i].rssi_ext1),
1468 ATH_SAMP_DBG(ts[i].rssi_ext2),
1469 ATH_SAMP_DBG(ts[i].rssi),
1470 ATH_SAMP_DBG(ts[i].isok),
1471 ATH_SAMP_DBG(ts[i].rts_fail_cnt),
1472 ATH_SAMP_DBG(ts[i].data_fail_cnt),
1473 ATH_SAMP_DBG(ts[i].rateindex),
1474 ATH_SAMP_DBG(ts[i].tid),
1475 ATH_SAMP_DBG(ts[i].qid),
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +05301476 ATH_SAMP_DBG(ts[i].ba_low),
1477 ATH_SAMP_DBG(ts[i].ba_high),
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301478 jiffies_to_msecs(jiffies -
1479 ATH_SAMP_DBG(ts[i].jiffies)));
1480 }
1481 }
1482
1483 len += snprintf(buf + len, size - len, "Rx status Dump :\n");
1484 len += snprintf(buf + len, size - len, "Sample rssi:- ctl0 ctl1 ctl2 "
1485 "ext0 ext1 ext2 comb beacon ant rate rx_before(ms)\n");
1486 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1487 for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) {
1488 if (!ATH_SAMP_DBG(rs[i].jiffies))
1489 continue;
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +05301490 len += snprintf(buf + len, size - len, "%-14d"
1491 "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-9s %-2d %02x %-13d\n",
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301492 sampidx,
1493 ATH_SAMP_DBG(rs[i].rssi_ctl0),
1494 ATH_SAMP_DBG(rs[i].rssi_ctl1),
1495 ATH_SAMP_DBG(rs[i].rssi_ctl2),
1496 ATH_SAMP_DBG(rs[i].rssi_ext0),
1497 ATH_SAMP_DBG(rs[i].rssi_ext1),
1498 ATH_SAMP_DBG(rs[i].rssi_ext2),
1499 ATH_SAMP_DBG(rs[i].rssi),
1500 ATH_SAMP_DBG(rs[i].is_mybeacon) ?
1501 "True" : "False",
1502 ATH_SAMP_DBG(rs[i].antenna),
1503 ATH_SAMP_DBG(rs[i].rate),
1504 jiffies_to_msecs(jiffies -
1505 ATH_SAMP_DBG(rs[i].jiffies)));
1506 }
1507 }
1508
1509 vfree(bb_mac_samp);
1510 file->private_data = buf;
1511
1512 return 0;
1513#undef ATH_SAMP_DBG
1514}
1515
1516static const struct file_operations fops_samps = {
1517 .open = open_file_bb_mac_samps,
1518 .read = ath9k_debugfs_read_buf,
1519 .release = ath9k_debugfs_release_buf,
1520 .owner = THIS_MODULE,
1521 .llseek = default_llseek,
1522};
1523
1524
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -07001525int ath9k_init_debug(struct ath_hw *ah)
Sujith88b126a2008-11-28 22:19:02 +05301526{
Luis R. Rodriguezbc974f42009-09-28 02:54:40 -04001527 struct ath_common *common = ath9k_hw_common(ah);
1528 struct ath_softc *sc = (struct ath_softc *) common->priv;
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -07001529
Ben Greeareb272442010-11-29 14:13:22 -08001530 sc->debug.debugfs_phy = debugfs_create_dir("ath9k",
1531 sc->hw->wiphy->debugfsdir);
Sujith17d79042009-02-09 13:27:03 +05301532 if (!sc->debug.debugfs_phy)
Felix Fietkauc8a72c02010-05-11 17:23:00 +02001533 return -ENOMEM;
Sujith826d2682008-11-28 22:20:23 +05301534
Felix Fietkaua830df02009-11-23 22:33:27 +01001535#ifdef CONFIG_ATH_DEBUG
Felix Fietkauc70cab12011-03-19 13:55:37 +01001536 debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1537 sc, &fops_debug);
Felix Fietkaua830df02009-11-23 22:33:27 +01001538#endif
Zefir Kurtisi29942bc2011-12-14 20:16:34 -08001539
1540 ath9k_dfs_init_debug(sc);
1541
Felix Fietkauc70cab12011-03-19 13:55:37 +01001542 debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
1543 &fops_dma);
1544 debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
1545 &fops_interrupt);
Felix Fietkauc70cab12011-03-19 13:55:37 +01001546 debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc,
1547 &fops_xmit);
1548 debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc,
1549 &fops_stations);
1550 debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc,
1551 &fops_misc);
1552 debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc,
1553 &fops_recv);
1554 debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR,
1555 sc->debug.debugfs_phy, sc, &fops_rx_chainmask);
1556 debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR,
1557 sc->debug.debugfs_phy, sc, &fops_tx_chainmask);
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +05301558 debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR,
1559 sc->debug.debugfs_phy, sc, &fops_disable_ani);
Felix Fietkauc70cab12011-03-19 13:55:37 +01001560 debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1561 sc, &fops_regidx);
1562 debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1563 sc, &fops_regval);
1564 debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR,
1565 sc->debug.debugfs_phy,
1566 &ah->config.cwm_ignore_extcca);
1567 debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc,
1568 &fops_regdump);
Rajkumar Manoharand069a462011-08-13 10:28:18 +05301569 debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc,
1570 &fops_dump_nfcal);
Rajkumar Manoharan580f0102011-07-29 17:38:12 +05301571 debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
1572 &fops_base_eeprom);
Rajkumar Manoharan3f4c4bd2011-07-29 17:38:13 +05301573 debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
1574 &fops_modal_eeprom);
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301575 debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc,
1576 &fops_samps);
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -08001577
Felix Fietkau691680b2011-03-19 13:55:38 +01001578 debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
1579 sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
1580
1581 debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
1582 sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
1583
Sujith826d2682008-11-28 22:20:23 +05301584 return 0;
Sujith88b126a2008-11-28 22:19:02 +05301585}