blob: a5329c98f9ea53858772503669ba4c50e9e4cd6a [file] [log] [blame]
Sujith88b126a2008-11-28 22:19:02 +05301/*
Sujith Manoharan5b681382011-05-17 13:36:18 +05302 * Copyright (c) 2008-2011 Atheros Communications Inc.
Sujith88b126a2008-11-28 22:19:02 +05303 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090017#include <linux/slab.h>
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -080018#include <linux/vmalloc.h>
Gabor Juhos52103112009-03-06 09:57:39 +010019#include <asm/unaligned.h>
20
Sujith394cf0a2009-02-09 13:26:54 +053021#include "ath9k.h"
Sujith88b126a2008-11-28 22:19:02 +053022
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -040023#define REG_WRITE_D(_ah, _reg, _val) \
24 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
25#define REG_READ_D(_ah, _reg) \
26 ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
27
Sujith2a163c62008-11-28 22:21:08 +053028static int ath9k_debugfs_open(struct inode *inode, struct file *file)
29{
30 file->private_data = inode->i_private;
31 return 0;
32}
33
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -080034static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf,
35 size_t count, loff_t *ppos)
36{
37 u8 *buf = file->private_data;
38 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
39}
40
41static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file)
42{
43 vfree(file->private_data);
44 return 0;
45}
46
Felix Fietkaua830df02009-11-23 22:33:27 +010047#ifdef CONFIG_ATH_DEBUG
48
Jeff Hansen24939282009-05-27 12:48:29 +000049static ssize_t read_file_debug(struct file *file, char __user *user_buf,
50 size_t count, loff_t *ppos)
51{
52 struct ath_softc *sc = file->private_data;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070053 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Jeff Hansen24939282009-05-27 12:48:29 +000054 char buf[32];
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053055 unsigned int len;
56
Dan Carpenter2b87f3a2010-05-14 15:24:37 +020057 len = sprintf(buf, "0x%08x\n", common->debug_mask);
Jeff Hansen24939282009-05-27 12:48:29 +000058 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
59}
60
61static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
62 size_t count, loff_t *ppos)
63{
64 struct ath_softc *sc = file->private_data;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070065 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Jeff Hansen24939282009-05-27 12:48:29 +000066 unsigned long mask;
67 char buf[32];
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053068 ssize_t len;
69
70 len = min(count, sizeof(buf) - 1);
71 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +020072 return -EFAULT;
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053073
74 buf[len] = '\0';
75 if (strict_strtoul(buf, 0, &mask))
76 return -EINVAL;
77
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070078 common->debug_mask = mask;
Jeff Hansen24939282009-05-27 12:48:29 +000079 return count;
80}
81
82static const struct file_operations fops_debug = {
83 .read = read_file_debug,
84 .write = write_file_debug,
85 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +020086 .owner = THIS_MODULE,
87 .llseek = default_llseek,
Jeff Hansen24939282009-05-27 12:48:29 +000088};
89
Felix Fietkaua830df02009-11-23 22:33:27 +010090#endif
91
Pavel Roskin991a0982010-01-29 17:22:26 -050092#define DMA_BUF_LEN 1024
93
Felix Fietkau15340692010-05-11 17:23:01 +020094static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf,
95 size_t count, loff_t *ppos)
96{
97 struct ath_softc *sc = file->private_data;
Felix Fietkau82b2d332011-09-03 01:40:23 +020098 struct ath_hw *ah = sc->sc_ah;
Felix Fietkau15340692010-05-11 17:23:01 +020099 char buf[32];
100 unsigned int len;
101
Felix Fietkau82b2d332011-09-03 01:40:23 +0200102 len = sprintf(buf, "0x%08x\n", ah->txchainmask);
Felix Fietkau15340692010-05-11 17:23:01 +0200103 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
104}
105
106static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf,
107 size_t count, loff_t *ppos)
108{
109 struct ath_softc *sc = file->private_data;
Felix Fietkau82b2d332011-09-03 01:40:23 +0200110 struct ath_hw *ah = sc->sc_ah;
Felix Fietkau15340692010-05-11 17:23:01 +0200111 unsigned long mask;
112 char buf[32];
113 ssize_t len;
114
115 len = min(count, sizeof(buf) - 1);
116 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +0200117 return -EFAULT;
Felix Fietkau15340692010-05-11 17:23:01 +0200118
119 buf[len] = '\0';
120 if (strict_strtoul(buf, 0, &mask))
121 return -EINVAL;
122
Felix Fietkau82b2d332011-09-03 01:40:23 +0200123 ah->txchainmask = mask;
124 ah->caps.tx_chainmask = mask;
Felix Fietkau15340692010-05-11 17:23:01 +0200125 return count;
126}
127
128static const struct file_operations fops_tx_chainmask = {
129 .read = read_file_tx_chainmask,
130 .write = write_file_tx_chainmask,
131 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200132 .owner = THIS_MODULE,
133 .llseek = default_llseek,
Felix Fietkau15340692010-05-11 17:23:01 +0200134};
135
136
137static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf,
138 size_t count, loff_t *ppos)
139{
140 struct ath_softc *sc = file->private_data;
Felix Fietkau82b2d332011-09-03 01:40:23 +0200141 struct ath_hw *ah = sc->sc_ah;
Felix Fietkau15340692010-05-11 17:23:01 +0200142 char buf[32];
143 unsigned int len;
144
Felix Fietkau82b2d332011-09-03 01:40:23 +0200145 len = sprintf(buf, "0x%08x\n", ah->rxchainmask);
Felix Fietkau15340692010-05-11 17:23:01 +0200146 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
147}
148
149static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf,
150 size_t count, loff_t *ppos)
151{
152 struct ath_softc *sc = file->private_data;
Felix Fietkau82b2d332011-09-03 01:40:23 +0200153 struct ath_hw *ah = sc->sc_ah;
Felix Fietkau15340692010-05-11 17:23:01 +0200154 unsigned long mask;
155 char buf[32];
156 ssize_t len;
157
158 len = min(count, sizeof(buf) - 1);
159 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +0200160 return -EFAULT;
Felix Fietkau15340692010-05-11 17:23:01 +0200161
162 buf[len] = '\0';
163 if (strict_strtoul(buf, 0, &mask))
164 return -EINVAL;
165
Felix Fietkau82b2d332011-09-03 01:40:23 +0200166 ah->rxchainmask = mask;
167 ah->caps.rx_chainmask = mask;
Felix Fietkau15340692010-05-11 17:23:01 +0200168 return count;
169}
170
171static const struct file_operations fops_rx_chainmask = {
172 .read = read_file_rx_chainmask,
173 .write = write_file_rx_chainmask,
174 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200175 .owner = THIS_MODULE,
176 .llseek = default_llseek,
Felix Fietkau15340692010-05-11 17:23:01 +0200177};
178
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530179static ssize_t read_file_disable_ani(struct file *file, char __user *user_buf,
180 size_t count, loff_t *ppos)
181{
182 struct ath_softc *sc = file->private_data;
183 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
184 char buf[32];
185 unsigned int len;
186
187 len = sprintf(buf, "%d\n", common->disable_ani);
188 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
189}
190
191static ssize_t write_file_disable_ani(struct file *file,
192 const char __user *user_buf,
193 size_t count, loff_t *ppos)
194{
195 struct ath_softc *sc = file->private_data;
196 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
197 unsigned long disable_ani;
198 char buf[32];
199 ssize_t len;
200
201 len = min(count, sizeof(buf) - 1);
202 if (copy_from_user(buf, user_buf, len))
203 return -EFAULT;
204
205 buf[len] = '\0';
206 if (strict_strtoul(buf, 0, &disable_ani))
207 return -EINVAL;
208
209 common->disable_ani = !!disable_ani;
210
211 if (disable_ani) {
212 sc->sc_flags &= ~SC_OP_ANI_RUN;
213 del_timer_sync(&common->ani.timer);
214 } else {
215 sc->sc_flags |= SC_OP_ANI_RUN;
216 ath_start_ani(common);
217 }
218
219 return count;
220}
221
222static const struct file_operations fops_disable_ani = {
223 .read = read_file_disable_ani,
224 .write = write_file_disable_ani,
225 .open = ath9k_debugfs_open,
226 .owner = THIS_MODULE,
227 .llseek = default_llseek,
228};
Felix Fietkau15340692010-05-11 17:23:01 +0200229
Sujith2a163c62008-11-28 22:21:08 +0530230static ssize_t read_file_dma(struct file *file, char __user *user_buf,
231 size_t count, loff_t *ppos)
232{
233 struct ath_softc *sc = file->private_data;
Sujithcbe61d82009-02-09 13:27:12 +0530234 struct ath_hw *ah = sc->sc_ah;
Pavel Roskin991a0982010-01-29 17:22:26 -0500235 char *buf;
236 int retval;
Sujith2a163c62008-11-28 22:21:08 +0530237 unsigned int len = 0;
238 u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
239 int i, qcuOffset = 0, dcuOffset = 0;
240 u32 *qcuBase = &val[0], *dcuBase = &val[4];
241
Pavel Roskin991a0982010-01-29 17:22:26 -0500242 buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL);
243 if (!buf)
Dan Carpenter04236062010-05-14 15:25:39 +0200244 return -ENOMEM;
Pavel Roskin991a0982010-01-29 17:22:26 -0500245
Sujith7cf4a2e2009-08-26 11:11:57 +0530246 ath9k_ps_wakeup(sc);
247
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400248 REG_WRITE_D(ah, AR_MACMISC,
Sujith2a163c62008-11-28 22:21:08 +0530249 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
250 (AR_MACMISC_MISC_OBS_BUS_1 <<
251 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
252
Pavel Roskin991a0982010-01-29 17:22:26 -0500253 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530254 "Raw DMA Debug values:\n");
255
256 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
257 if (i % 4 == 0)
Pavel Roskin991a0982010-01-29 17:22:26 -0500258 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
Sujith2a163c62008-11-28 22:21:08 +0530259
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400260 val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
Pavel Roskin991a0982010-01-29 17:22:26 -0500261 len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ",
Sujith2a163c62008-11-28 22:21:08 +0530262 i, val[i]);
263 }
264
Pavel Roskin991a0982010-01-29 17:22:26 -0500265 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n");
266 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530267 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
268
269 for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
270 if (i == 8) {
271 qcuOffset = 0;
272 qcuBase++;
273 }
274
275 if (i == 6) {
276 dcuOffset = 0;
277 dcuBase++;
278 }
279
Pavel Roskin991a0982010-01-29 17:22:26 -0500280 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530281 "%2d %2x %1x %2x %2x\n",
282 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
283 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
284 val[2] & (0x7 << (i * 3)) >> (i * 3),
285 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
286 }
287
Pavel Roskin991a0982010-01-29 17:22:26 -0500288 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
Sujith2a163c62008-11-28 22:21:08 +0530289
Pavel Roskin991a0982010-01-29 17:22:26 -0500290 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530291 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
292 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
Pavel Roskin991a0982010-01-29 17:22:26 -0500293 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530294 "qcu_complete state: %2x dcu_complete state: %2x\n",
295 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
Pavel Roskin991a0982010-01-29 17:22:26 -0500296 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530297 "dcu_arb state: %2x dcu_fp state: %2x\n",
298 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
Pavel Roskin991a0982010-01-29 17:22:26 -0500299 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530300 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
301 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
Pavel Roskin991a0982010-01-29 17:22:26 -0500302 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530303 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
304 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
Pavel Roskin991a0982010-01-29 17:22:26 -0500305 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530306 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
307 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
308
Frans Pop60ece402010-03-24 19:46:30 +0100309 len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n",
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400310 REG_READ_D(ah, AR_OBS_BUS_1));
Pavel Roskin991a0982010-01-29 17:22:26 -0500311 len += snprintf(buf + len, DMA_BUF_LEN - len,
Frans Pop60ece402010-03-24 19:46:30 +0100312 "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR));
Sujith2a163c62008-11-28 22:21:08 +0530313
Sujith7cf4a2e2009-08-26 11:11:57 +0530314 ath9k_ps_restore(sc);
315
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200316 if (len > DMA_BUF_LEN)
317 len = DMA_BUF_LEN;
318
Pavel Roskin991a0982010-01-29 17:22:26 -0500319 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
320 kfree(buf);
321 return retval;
Sujith2a163c62008-11-28 22:21:08 +0530322}
323
324static const struct file_operations fops_dma = {
325 .read = read_file_dma,
326 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200327 .owner = THIS_MODULE,
328 .llseek = default_llseek,
Sujith2a163c62008-11-28 22:21:08 +0530329};
330
Sujith817e11d2008-12-07 21:42:44 +0530331
332void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status)
333{
334 if (status)
Sujith17d79042009-02-09 13:27:03 +0530335 sc->debug.stats.istats.total++;
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400336 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
337 if (status & ATH9K_INT_RXLP)
338 sc->debug.stats.istats.rxlp++;
339 if (status & ATH9K_INT_RXHP)
340 sc->debug.stats.istats.rxhp++;
Luis R. Rodriguez08578b82010-05-13 13:33:44 -0400341 if (status & ATH9K_INT_BB_WATCHDOG)
342 sc->debug.stats.istats.bb_watchdog++;
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400343 } else {
344 if (status & ATH9K_INT_RX)
345 sc->debug.stats.istats.rxok++;
346 }
Sujith817e11d2008-12-07 21:42:44 +0530347 if (status & ATH9K_INT_RXEOL)
Sujith17d79042009-02-09 13:27:03 +0530348 sc->debug.stats.istats.rxeol++;
Sujith817e11d2008-12-07 21:42:44 +0530349 if (status & ATH9K_INT_RXORN)
Sujith17d79042009-02-09 13:27:03 +0530350 sc->debug.stats.istats.rxorn++;
Sujith817e11d2008-12-07 21:42:44 +0530351 if (status & ATH9K_INT_TX)
Sujith17d79042009-02-09 13:27:03 +0530352 sc->debug.stats.istats.txok++;
Sujith817e11d2008-12-07 21:42:44 +0530353 if (status & ATH9K_INT_TXURN)
Sujith17d79042009-02-09 13:27:03 +0530354 sc->debug.stats.istats.txurn++;
Sujith817e11d2008-12-07 21:42:44 +0530355 if (status & ATH9K_INT_MIB)
Sujith17d79042009-02-09 13:27:03 +0530356 sc->debug.stats.istats.mib++;
Sujith817e11d2008-12-07 21:42:44 +0530357 if (status & ATH9K_INT_RXPHY)
Sujith17d79042009-02-09 13:27:03 +0530358 sc->debug.stats.istats.rxphyerr++;
Sujith817e11d2008-12-07 21:42:44 +0530359 if (status & ATH9K_INT_RXKCM)
Sujith17d79042009-02-09 13:27:03 +0530360 sc->debug.stats.istats.rx_keycache_miss++;
Sujith817e11d2008-12-07 21:42:44 +0530361 if (status & ATH9K_INT_SWBA)
Sujith17d79042009-02-09 13:27:03 +0530362 sc->debug.stats.istats.swba++;
Sujith817e11d2008-12-07 21:42:44 +0530363 if (status & ATH9K_INT_BMISS)
Sujith17d79042009-02-09 13:27:03 +0530364 sc->debug.stats.istats.bmiss++;
Sujith817e11d2008-12-07 21:42:44 +0530365 if (status & ATH9K_INT_BNR)
Sujith17d79042009-02-09 13:27:03 +0530366 sc->debug.stats.istats.bnr++;
Sujith817e11d2008-12-07 21:42:44 +0530367 if (status & ATH9K_INT_CST)
Sujith17d79042009-02-09 13:27:03 +0530368 sc->debug.stats.istats.cst++;
Sujith817e11d2008-12-07 21:42:44 +0530369 if (status & ATH9K_INT_GTT)
Sujith17d79042009-02-09 13:27:03 +0530370 sc->debug.stats.istats.gtt++;
Sujith817e11d2008-12-07 21:42:44 +0530371 if (status & ATH9K_INT_TIM)
Sujith17d79042009-02-09 13:27:03 +0530372 sc->debug.stats.istats.tim++;
Sujith817e11d2008-12-07 21:42:44 +0530373 if (status & ATH9K_INT_CABEND)
Sujith17d79042009-02-09 13:27:03 +0530374 sc->debug.stats.istats.cabend++;
Sujith817e11d2008-12-07 21:42:44 +0530375 if (status & ATH9K_INT_DTIMSYNC)
Sujith17d79042009-02-09 13:27:03 +0530376 sc->debug.stats.istats.dtimsync++;
Sujith817e11d2008-12-07 21:42:44 +0530377 if (status & ATH9K_INT_DTIM)
Sujith17d79042009-02-09 13:27:03 +0530378 sc->debug.stats.istats.dtim++;
Mohammed Shafi Shajakhan6dde1aa2011-04-22 17:27:01 +0530379 if (status & ATH9K_INT_TSFOOR)
380 sc->debug.stats.istats.tsfoor++;
Sujith817e11d2008-12-07 21:42:44 +0530381}
382
383static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
384 size_t count, loff_t *ppos)
385{
386 struct ath_softc *sc = file->private_data;
387 char buf[512];
388 unsigned int len = 0;
389
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400390 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
391 len += snprintf(buf + len, sizeof(buf) - len,
392 "%8s: %10u\n", "RXLP", sc->debug.stats.istats.rxlp);
393 len += snprintf(buf + len, sizeof(buf) - len,
394 "%8s: %10u\n", "RXHP", sc->debug.stats.istats.rxhp);
Luis R. Rodriguez08578b82010-05-13 13:33:44 -0400395 len += snprintf(buf + len, sizeof(buf) - len,
396 "%8s: %10u\n", "WATCHDOG",
397 sc->debug.stats.istats.bb_watchdog);
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400398 } else {
399 len += snprintf(buf + len, sizeof(buf) - len,
400 "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok);
401 }
Sujith817e11d2008-12-07 21:42:44 +0530402 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530403 "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol);
Sujith817e11d2008-12-07 21:42:44 +0530404 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530405 "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn);
Sujith817e11d2008-12-07 21:42:44 +0530406 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530407 "%8s: %10u\n", "TX", sc->debug.stats.istats.txok);
Sujith817e11d2008-12-07 21:42:44 +0530408 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530409 "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn);
Sujith817e11d2008-12-07 21:42:44 +0530410 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530411 "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib);
Sujith817e11d2008-12-07 21:42:44 +0530412 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530413 "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr);
Sujith817e11d2008-12-07 21:42:44 +0530414 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530415 "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss);
Sujith817e11d2008-12-07 21:42:44 +0530416 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530417 "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba);
Sujith817e11d2008-12-07 21:42:44 +0530418 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530419 "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss);
Sujith817e11d2008-12-07 21:42:44 +0530420 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530421 "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr);
Sujith817e11d2008-12-07 21:42:44 +0530422 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530423 "%8s: %10u\n", "CST", sc->debug.stats.istats.cst);
Sujith817e11d2008-12-07 21:42:44 +0530424 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530425 "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt);
Sujith817e11d2008-12-07 21:42:44 +0530426 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530427 "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim);
Sujith817e11d2008-12-07 21:42:44 +0530428 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530429 "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend);
Sujith817e11d2008-12-07 21:42:44 +0530430 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530431 "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync);
Sujith817e11d2008-12-07 21:42:44 +0530432 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530433 "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim);
Sujith817e11d2008-12-07 21:42:44 +0530434 len += snprintf(buf + len, sizeof(buf) - len,
Mohammed Shafi Shajakhan6dde1aa2011-04-22 17:27:01 +0530435 "%8s: %10u\n", "TSFOOR", sc->debug.stats.istats.tsfoor);
436 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530437 "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total);
Sujith817e11d2008-12-07 21:42:44 +0530438
Mohammed Shafi Shajakhan6dde1aa2011-04-22 17:27:01 +0530439
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200440 if (len > sizeof(buf))
441 len = sizeof(buf);
442
Sujith817e11d2008-12-07 21:42:44 +0530443 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
444}
445
446static const struct file_operations fops_interrupt = {
447 .read = read_file_interrupt,
448 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200449 .owner = THIS_MODULE,
450 .llseek = default_llseek,
Sujith817e11d2008-12-07 21:42:44 +0530451};
452
Ben Greear4e6975f2011-01-31 10:37:36 -0800453static const char *channel_type_str(enum nl80211_channel_type t)
454{
455 switch (t) {
456 case NL80211_CHAN_NO_HT:
457 return "no ht";
458 case NL80211_CHAN_HT20:
459 return "ht20";
460 case NL80211_CHAN_HT40MINUS:
461 return "ht40-";
462 case NL80211_CHAN_HT40PLUS:
463 return "ht40+";
464 default:
465 return "???";
466 }
467}
468
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200469static ssize_t read_file_wiphy(struct file *file, char __user *user_buf,
470 size_t count, loff_t *ppos)
471{
472 struct ath_softc *sc = file->private_data;
Felix Fietkau34302392011-01-24 19:23:15 +0100473 struct ieee80211_channel *chan = sc->hw->conf.channel;
Ben Greear4e6975f2011-01-31 10:37:36 -0800474 struct ieee80211_conf *conf = &(sc->hw->conf);
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200475 char buf[512];
476 unsigned int len = 0;
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200477 u8 addr[ETH_ALEN];
Ben Greear39057512010-09-14 12:46:04 -0700478 u32 tmp;
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200479
480 len += snprintf(buf + len, sizeof(buf) - len,
Ben Greear4e6975f2011-01-31 10:37:36 -0800481 "%s (chan=%d center-freq: %d MHz channel-type: %d (%s))\n",
Felix Fietkau34302392011-01-24 19:23:15 +0100482 wiphy_name(sc->hw->wiphy),
Mohammed Shafi Shajakhan8e0167a2010-10-01 15:25:05 +0530483 ieee80211_frequency_to_channel(chan->center_freq),
Ben Greear4e6975f2011-01-31 10:37:36 -0800484 chan->center_freq,
485 conf->channel_type,
486 channel_type_str(conf->channel_type));
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200487
Mohammed Shafi Shajakhanc6e38c02011-05-18 17:56:00 +0530488 ath9k_ps_wakeup(sc);
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400489 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr);
490 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4);
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200491 len += snprintf(buf + len, sizeof(buf) - len,
492 "addr: %pM\n", addr);
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400493 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr);
494 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4);
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200495 len += snprintf(buf + len, sizeof(buf) - len,
496 "addrmask: %pM\n", addr);
Ben Greear39057512010-09-14 12:46:04 -0700497 tmp = ath9k_hw_getrxfilter(sc->sc_ah);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +0530498 ath9k_ps_restore(sc);
Ben Greear39057512010-09-14 12:46:04 -0700499 len += snprintf(buf + len, sizeof(buf) - len,
500 "rfilt: 0x%x", tmp);
501 if (tmp & ATH9K_RX_FILTER_UCAST)
502 len += snprintf(buf + len, sizeof(buf) - len, " UCAST");
503 if (tmp & ATH9K_RX_FILTER_MCAST)
504 len += snprintf(buf + len, sizeof(buf) - len, " MCAST");
505 if (tmp & ATH9K_RX_FILTER_BCAST)
506 len += snprintf(buf + len, sizeof(buf) - len, " BCAST");
507 if (tmp & ATH9K_RX_FILTER_CONTROL)
508 len += snprintf(buf + len, sizeof(buf) - len, " CONTROL");
509 if (tmp & ATH9K_RX_FILTER_BEACON)
510 len += snprintf(buf + len, sizeof(buf) - len, " BEACON");
511 if (tmp & ATH9K_RX_FILTER_PROM)
512 len += snprintf(buf + len, sizeof(buf) - len, " PROM");
513 if (tmp & ATH9K_RX_FILTER_PROBEREQ)
514 len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ");
515 if (tmp & ATH9K_RX_FILTER_PHYERR)
516 len += snprintf(buf + len, sizeof(buf) - len, " PHYERR");
517 if (tmp & ATH9K_RX_FILTER_MYBEACON)
518 len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON");
519 if (tmp & ATH9K_RX_FILTER_COMP_BAR)
520 len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR");
521 if (tmp & ATH9K_RX_FILTER_PSPOLL)
522 len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL");
523 if (tmp & ATH9K_RX_FILTER_PHYRADAR)
524 len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR");
525 if (tmp & ATH9K_RX_FILTER_MCAST_BCAST_ALL)
526 len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL\n");
527 else
528 len += snprintf(buf + len, sizeof(buf) - len, "\n");
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200529
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200530 if (len > sizeof(buf))
531 len = sizeof(buf);
532
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200533 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
534}
535
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200536static const struct file_operations fops_wiphy = {
537 .read = read_file_wiphy,
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200538 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200539 .owner = THIS_MODULE,
540 .llseek = default_llseek,
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200541};
542
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100543#define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum
Sujithfec247c2009-07-27 12:08:16 +0530544#define PR(str, elem) \
545 do { \
546 len += snprintf(buf + len, size - len, \
547 "%s%13u%11u%10u%10u\n", str, \
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100548 sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem, \
549 sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem, \
550 sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem, \
551 sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem); \
Ben Greear7f010c92011-01-09 23:11:49 -0800552 if (len >= size) \
553 goto done; \
Sujithfec247c2009-07-27 12:08:16 +0530554} while(0)
555
Ben Greear1f427dd2011-01-09 23:11:43 -0800556#define PRX(str, elem) \
557do { \
558 len += snprintf(buf + len, size - len, \
559 "%s%13u%11u%10u%10u\n", str, \
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100560 (unsigned int)(sc->tx.txq_map[WME_AC_BE]->elem), \
561 (unsigned int)(sc->tx.txq_map[WME_AC_BK]->elem), \
562 (unsigned int)(sc->tx.txq_map[WME_AC_VI]->elem), \
563 (unsigned int)(sc->tx.txq_map[WME_AC_VO]->elem)); \
Ben Greear7f010c92011-01-09 23:11:49 -0800564 if (len >= size) \
565 goto done; \
Ben Greear1f427dd2011-01-09 23:11:43 -0800566} while(0)
567
Ben Greear2dac4fb2011-01-09 23:11:45 -0800568#define PRQLE(str, elem) \
569do { \
570 len += snprintf(buf + len, size - len, \
571 "%s%13i%11i%10i%10i\n", str, \
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100572 list_empty(&sc->tx.txq_map[WME_AC_BE]->elem), \
573 list_empty(&sc->tx.txq_map[WME_AC_BK]->elem), \
574 list_empty(&sc->tx.txq_map[WME_AC_VI]->elem), \
575 list_empty(&sc->tx.txq_map[WME_AC_VO]->elem)); \
Ben Greear7f010c92011-01-09 23:11:49 -0800576 if (len >= size) \
577 goto done; \
Ben Greear2dac4fb2011-01-09 23:11:45 -0800578} while (0)
579
Sujithfec247c2009-07-27 12:08:16 +0530580static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
581 size_t count, loff_t *ppos)
582{
583 struct ath_softc *sc = file->private_data;
584 char *buf;
Ben Greear7f010c92011-01-09 23:11:49 -0800585 unsigned int len = 0, size = 8000;
Ben Greear2dac4fb2011-01-09 23:11:45 -0800586 int i;
Sujithfec247c2009-07-27 12:08:16 +0530587 ssize_t retval = 0;
Ben Greear2dac4fb2011-01-09 23:11:45 -0800588 char tmp[32];
Sujithfec247c2009-07-27 12:08:16 +0530589
590 buf = kzalloc(size, GFP_KERNEL);
591 if (buf == NULL)
Dan Carpenter04236062010-05-14 15:25:39 +0200592 return -ENOMEM;
Sujithfec247c2009-07-27 12:08:16 +0530593
Ben Greear60f2d1d2011-01-09 23:11:52 -0800594 len += sprintf(buf, "Num-Tx-Queues: %i tx-queues-setup: 0x%x"
595 " poll-work-seen: %u\n"
Ben Greear7f010c92011-01-09 23:11:49 -0800596 "%30s %10s%10s%10s\n\n",
597 ATH9K_NUM_TX_QUEUES, sc->tx.txqsetup,
Ben Greear60f2d1d2011-01-09 23:11:52 -0800598 sc->tx_complete_poll_work_seen,
Ben Greear7f010c92011-01-09 23:11:49 -0800599 "BE", "BK", "VI", "VO");
Sujithfec247c2009-07-27 12:08:16 +0530600
601 PR("MPDUs Queued: ", queued);
602 PR("MPDUs Completed: ", completed);
Felix Fietkau5a6f78a2011-05-31 21:21:41 +0200603 PR("MPDUs XRetried: ", xretries);
Sujithfec247c2009-07-27 12:08:16 +0530604 PR("Aggregates: ", a_aggr);
Ben Greearbda8add2011-01-09 23:11:48 -0800605 PR("AMPDUs Queued HW:", a_queued_hw);
606 PR("AMPDUs Queued SW:", a_queued_sw);
Sujithfec247c2009-07-27 12:08:16 +0530607 PR("AMPDUs Completed:", a_completed);
608 PR("AMPDUs Retried: ", a_retries);
609 PR("AMPDUs XRetried: ", a_xretries);
610 PR("FIFO Underrun: ", fifo_underrun);
611 PR("TXOP Exceeded: ", xtxop);
612 PR("TXTIMER Expiry: ", timer_exp);
613 PR("DESC CFG Error: ", desc_cfg_err);
614 PR("DATA Underrun: ", data_underrun);
615 PR("DELIM Underrun: ", delim_underrun);
Ben Greear99c15bf2010-10-01 12:26:30 -0700616 PR("TX-Pkts-All: ", tx_pkts_all);
617 PR("TX-Bytes-All: ", tx_bytes_all);
Ben Greear2dac4fb2011-01-09 23:11:45 -0800618 PR("hw-put-tx-buf: ", puttxbuf);
619 PR("hw-tx-start: ", txstart);
620 PR("hw-tx-proc-desc: ", txprocdesc);
Ben Greear7f010c92011-01-09 23:11:49 -0800621 len += snprintf(buf + len, size - len,
622 "%s%11p%11p%10p%10p\n", "txq-memory-address:",
Ben Greeardb7889c2011-03-03 16:25:59 -0800623 sc->tx.txq_map[WME_AC_BE],
624 sc->tx.txq_map[WME_AC_BK],
625 sc->tx.txq_map[WME_AC_VI],
626 sc->tx.txq_map[WME_AC_VO]);
Ben Greear7f010c92011-01-09 23:11:49 -0800627 if (len >= size)
628 goto done;
Sujithfec247c2009-07-27 12:08:16 +0530629
Ben Greear1f427dd2011-01-09 23:11:43 -0800630 PRX("axq-qnum: ", axq_qnum);
631 PRX("axq-depth: ", axq_depth);
Ben Greear2dac4fb2011-01-09 23:11:45 -0800632 PRX("axq-ampdu_depth: ", axq_ampdu_depth);
Ben Greear1f427dd2011-01-09 23:11:43 -0800633 PRX("axq-stopped ", stopped);
634 PRX("tx-in-progress ", axq_tx_inprogress);
635 PRX("pending-frames ", pending_frames);
Ben Greear2dac4fb2011-01-09 23:11:45 -0800636 PRX("txq_headidx: ", txq_headidx);
637 PRX("txq_tailidx: ", txq_headidx);
Ben Greear1f427dd2011-01-09 23:11:43 -0800638
Ben Greear2dac4fb2011-01-09 23:11:45 -0800639 PRQLE("axq_q empty: ", axq_q);
640 PRQLE("axq_acq empty: ", axq_acq);
Ben Greear2dac4fb2011-01-09 23:11:45 -0800641 for (i = 0; i < ATH_TXFIFO_DEPTH; i++) {
642 snprintf(tmp, sizeof(tmp) - 1, "txq_fifo[%i] empty: ", i);
643 PRQLE(tmp, txq_fifo[i]);
644 }
Ben Greear7f010c92011-01-09 23:11:49 -0800645
Ben Greear71e025a2011-01-09 23:11:50 -0800646 /* Print out more detailed queue-info */
647 for (i = 0; i <= WME_AC_BK; i++) {
648 struct ath_txq *txq = &(sc->tx.txq[i]);
649 struct ath_atx_ac *ac;
650 struct ath_atx_tid *tid;
651 if (len >= size)
652 goto done;
653 spin_lock_bh(&txq->axq_lock);
654 if (!list_empty(&txq->axq_acq)) {
655 ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac,
656 list);
657 len += snprintf(buf + len, size - len,
658 "txq[%i] first-ac: %p sched: %i\n",
659 i, ac, ac->sched);
660 if (list_empty(&ac->tid_q) || (len >= size))
661 goto done_for;
662 tid = list_first_entry(&ac->tid_q, struct ath_atx_tid,
663 list);
664 len += snprintf(buf + len, size - len,
665 " first-tid: %p sched: %i paused: %i\n",
666 tid, tid->sched, tid->paused);
667 }
668 done_for:
669 spin_unlock_bh(&txq->axq_lock);
670 }
671
Ben Greear7f010c92011-01-09 23:11:49 -0800672done:
673 if (len > size)
674 len = size;
675
676 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
677 kfree(buf);
678
679 return retval;
680}
681
682static ssize_t read_file_stations(struct file *file, char __user *user_buf,
683 size_t count, loff_t *ppos)
684{
685 struct ath_softc *sc = file->private_data;
686 char *buf;
687 unsigned int len = 0, size = 64000;
688 struct ath_node *an = NULL;
689 ssize_t retval = 0;
690 int q;
691
692 buf = kzalloc(size, GFP_KERNEL);
693 if (buf == NULL)
694 return -ENOMEM;
695
696 len += snprintf(buf + len, size - len,
697 "Stations:\n"
698 " tid: addr sched paused buf_q-empty an ac\n"
699 " ac: addr sched tid_q-empty txq\n");
700
701 spin_lock(&sc->nodes_lock);
702 list_for_each_entry(an, &sc->nodes, list) {
703 len += snprintf(buf + len, size - len,
704 "%pM\n", an->sta->addr);
705 if (len >= size)
706 goto done;
707
708 for (q = 0; q < WME_NUM_TID; q++) {
709 struct ath_atx_tid *tid = &(an->tid[q]);
710 len += snprintf(buf + len, size - len,
711 " tid: %p %s %s %i %p %p\n",
712 tid, tid->sched ? "sched" : "idle",
713 tid->paused ? "paused" : "running",
Felix Fietkau56dc6332011-08-28 00:32:22 +0200714 skb_queue_empty(&tid->buf_q),
Ben Greear7f010c92011-01-09 23:11:49 -0800715 tid->an, tid->ac);
716 if (len >= size)
717 goto done;
718 }
719
720 for (q = 0; q < WME_NUM_AC; q++) {
721 struct ath_atx_ac *ac = &(an->ac[q]);
722 len += snprintf(buf + len, size - len,
723 " ac: %p %s %i %p\n",
724 ac, ac->sched ? "sched" : "idle",
725 list_empty(&ac->tid_q), ac->txq);
726 if (len >= size)
727 goto done;
728 }
729 }
730
731done:
732 spin_unlock(&sc->nodes_lock);
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200733 if (len > size)
734 len = size;
735
Sujithfec247c2009-07-27 12:08:16 +0530736 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
737 kfree(buf);
738
739 return retval;
740}
741
Ben Greear55f6d0f2011-01-17 11:54:50 -0800742static ssize_t read_file_misc(struct file *file, char __user *user_buf,
743 size_t count, loff_t *ppos)
744{
745 struct ath_softc *sc = file->private_data;
746 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
747 struct ath_hw *ah = sc->sc_ah;
748 struct ieee80211_hw *hw = sc->hw;
749 char *buf;
750 unsigned int len = 0, size = 8000;
751 ssize_t retval = 0;
Ben Greear55f6d0f2011-01-17 11:54:50 -0800752 unsigned int reg;
753 struct ath9k_vif_iter_data iter_data;
754
755 ath9k_calculate_iter_data(hw, NULL, &iter_data);
756
757 buf = kzalloc(size, GFP_KERNEL);
758 if (buf == NULL)
759 return -ENOMEM;
760
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +0530761 ath9k_ps_wakeup(sc);
Ben Greear55f6d0f2011-01-17 11:54:50 -0800762 len += snprintf(buf + len, size - len,
763 "curbssid: %pM\n"
764 "OP-Mode: %s(%i)\n"
765 "Beacon-Timer-Register: 0x%x\n",
766 common->curbssid,
Pavel Roskin21ec4892011-07-15 19:06:46 -0400767 ath_opmode_to_string(sc->sc_ah->opmode),
768 (int)(sc->sc_ah->opmode),
Ben Greear55f6d0f2011-01-17 11:54:50 -0800769 REG_READ(ah, AR_BEACON_PERIOD));
770
771 reg = REG_READ(ah, AR_TIMER_MODE);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +0530772 ath9k_ps_restore(sc);
Ben Greear55f6d0f2011-01-17 11:54:50 -0800773 len += snprintf(buf + len, size - len, "Timer-Mode-Register: 0x%x (",
774 reg);
775 if (reg & AR_TBTT_TIMER_EN)
776 len += snprintf(buf + len, size - len, "TBTT ");
777 if (reg & AR_DBA_TIMER_EN)
778 len += snprintf(buf + len, size - len, "DBA ");
779 if (reg & AR_SWBA_TIMER_EN)
780 len += snprintf(buf + len, size - len, "SWBA ");
781 if (reg & AR_HCF_TIMER_EN)
782 len += snprintf(buf + len, size - len, "HCF ");
783 if (reg & AR_TIM_TIMER_EN)
784 len += snprintf(buf + len, size - len, "TIM ");
785 if (reg & AR_DTIM_TIMER_EN)
786 len += snprintf(buf + len, size - len, "DTIM ");
787 len += snprintf(buf + len, size - len, ")\n");
788
789 reg = sc->sc_ah->imask;
790 len += snprintf(buf + len, size - len, "imask: 0x%x (", reg);
791 if (reg & ATH9K_INT_SWBA)
792 len += snprintf(buf + len, size - len, "SWBA ");
793 if (reg & ATH9K_INT_BMISS)
794 len += snprintf(buf + len, size - len, "BMISS ");
795 if (reg & ATH9K_INT_CST)
796 len += snprintf(buf + len, size - len, "CST ");
797 if (reg & ATH9K_INT_RX)
798 len += snprintf(buf + len, size - len, "RX ");
799 if (reg & ATH9K_INT_RXHP)
800 len += snprintf(buf + len, size - len, "RXHP ");
801 if (reg & ATH9K_INT_RXLP)
802 len += snprintf(buf + len, size - len, "RXLP ");
803 if (reg & ATH9K_INT_BB_WATCHDOG)
804 len += snprintf(buf + len, size - len, "BB_WATCHDOG ");
805 /* there are other IRQs if one wanted to add them. */
806 len += snprintf(buf + len, size - len, ")\n");
807
808 len += snprintf(buf + len, size - len,
809 "VIF Counts: AP: %i STA: %i MESH: %i WDS: %i"
810 " ADHOC: %i OTHER: %i nvifs: %hi beacon-vifs: %hi\n",
811 iter_data.naps, iter_data.nstations, iter_data.nmeshes,
812 iter_data.nwds, iter_data.nadhocs, iter_data.nothers,
813 sc->nvifs, sc->nbcnvifs);
814
815 len += snprintf(buf + len, size - len,
816 "Calculated-BSSID-Mask: %pM\n",
817 iter_data.mask);
818
819 if (len > size)
820 len = size;
821
822 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
823 kfree(buf);
824
825 return retval;
826}
827
Felix Fietkau066dae92010-11-07 14:59:39 +0100828void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
Felix Fietkau55797b12011-09-14 21:24:16 +0200829 struct ath_tx_status *ts, struct ath_txq *txq,
830 unsigned int flags)
Sujithfec247c2009-07-27 12:08:16 +0530831{
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530832#define TX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].ts\
833 [sc->debug.tsidx].c)
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100834 int qnum = txq->axq_qnum;
Felix Fietkau066dae92010-11-07 14:59:39 +0100835
836 TX_STAT_INC(qnum, tx_pkts_all);
837 sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len;
Ben Greear99c15bf2010-10-01 12:26:30 -0700838
Sujithfec247c2009-07-27 12:08:16 +0530839 if (bf_isampdu(bf)) {
Felix Fietkau55797b12011-09-14 21:24:16 +0200840 if (flags & ATH_TX_BAR)
Felix Fietkau066dae92010-11-07 14:59:39 +0100841 TX_STAT_INC(qnum, a_xretries);
Sujithfec247c2009-07-27 12:08:16 +0530842 else
Felix Fietkau066dae92010-11-07 14:59:39 +0100843 TX_STAT_INC(qnum, a_completed);
Sujithfec247c2009-07-27 12:08:16 +0530844 } else {
Felix Fietkau55797b12011-09-14 21:24:16 +0200845 if (ts->ts_status & ATH9K_TXERR_XRETRY)
Felix Fietkau5a6f78a2011-05-31 21:21:41 +0200846 TX_STAT_INC(qnum, xretries);
847 else
848 TX_STAT_INC(qnum, completed);
Sujithfec247c2009-07-27 12:08:16 +0530849 }
850
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700851 if (ts->ts_status & ATH9K_TXERR_FIFO)
Felix Fietkau066dae92010-11-07 14:59:39 +0100852 TX_STAT_INC(qnum, fifo_underrun);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700853 if (ts->ts_status & ATH9K_TXERR_XTXOP)
Felix Fietkau066dae92010-11-07 14:59:39 +0100854 TX_STAT_INC(qnum, xtxop);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700855 if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED)
Felix Fietkau066dae92010-11-07 14:59:39 +0100856 TX_STAT_INC(qnum, timer_exp);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700857 if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR)
Felix Fietkau066dae92010-11-07 14:59:39 +0100858 TX_STAT_INC(qnum, desc_cfg_err);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700859 if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN)
Felix Fietkau066dae92010-11-07 14:59:39 +0100860 TX_STAT_INC(qnum, data_underrun);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700861 if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
Felix Fietkau066dae92010-11-07 14:59:39 +0100862 TX_STAT_INC(qnum, delim_underrun);
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530863
864 spin_lock(&sc->debug.samp_lock);
865 TX_SAMP_DBG(jiffies) = jiffies;
866 TX_SAMP_DBG(rssi_ctl0) = ts->ts_rssi_ctl0;
867 TX_SAMP_DBG(rssi_ctl1) = ts->ts_rssi_ctl1;
868 TX_SAMP_DBG(rssi_ctl2) = ts->ts_rssi_ctl2;
869 TX_SAMP_DBG(rssi_ext0) = ts->ts_rssi_ext0;
870 TX_SAMP_DBG(rssi_ext1) = ts->ts_rssi_ext1;
871 TX_SAMP_DBG(rssi_ext2) = ts->ts_rssi_ext2;
872 TX_SAMP_DBG(rateindex) = ts->ts_rateindex;
873 TX_SAMP_DBG(isok) = !!(ts->ts_status & ATH9K_TXERR_MASK);
874 TX_SAMP_DBG(rts_fail_cnt) = ts->ts_shortretry;
875 TX_SAMP_DBG(data_fail_cnt) = ts->ts_longretry;
876 TX_SAMP_DBG(rssi) = ts->ts_rssi;
877 TX_SAMP_DBG(tid) = ts->tid;
878 TX_SAMP_DBG(qid) = ts->qid;
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +0530879
880 if (ts->ts_flags & ATH9K_TX_BA) {
881 TX_SAMP_DBG(ba_low) = ts->ba_low;
882 TX_SAMP_DBG(ba_high) = ts->ba_high;
883 } else {
884 TX_SAMP_DBG(ba_low) = 0;
885 TX_SAMP_DBG(ba_high) = 0;
886 }
887
Rajkumar Manoharancf3af742011-08-27 16:17:47 +0530888 sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES;
889 spin_unlock(&sc->debug.samp_lock);
890
891#undef TX_SAMP_DBG
Sujithfec247c2009-07-27 12:08:16 +0530892}
893
894static const struct file_operations fops_xmit = {
895 .read = read_file_xmit,
896 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200897 .owner = THIS_MODULE,
898 .llseek = default_llseek,
Sujithfec247c2009-07-27 12:08:16 +0530899};
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200900
Ben Greear7f010c92011-01-09 23:11:49 -0800901static const struct file_operations fops_stations = {
902 .read = read_file_stations,
903 .open = ath9k_debugfs_open,
904 .owner = THIS_MODULE,
905 .llseek = default_llseek,
906};
907
Ben Greear55f6d0f2011-01-17 11:54:50 -0800908static const struct file_operations fops_misc = {
909 .read = read_file_misc,
910 .open = ath9k_debugfs_open,
911 .owner = THIS_MODULE,
912 .llseek = default_llseek,
913};
914
Sujith1395d3f2010-01-08 10:36:11 +0530915static ssize_t read_file_recv(struct file *file, char __user *user_buf,
916 size_t count, loff_t *ppos)
917{
918#define PHY_ERR(s, p) \
919 len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \
920 sc->debug.stats.rxstats.phy_err_stats[p]);
921
922 struct ath_softc *sc = file->private_data;
923 char *buf;
Senthil Balasubramanian7d755412011-04-08 15:30:34 +0530924 unsigned int len = 0, size = 1400;
Sujith1395d3f2010-01-08 10:36:11 +0530925 ssize_t retval = 0;
926
927 buf = kzalloc(size, GFP_KERNEL);
928 if (buf == NULL)
Dan Carpenter04236062010-05-14 15:25:39 +0200929 return -ENOMEM;
Sujith1395d3f2010-01-08 10:36:11 +0530930
931 len += snprintf(buf + len, size - len,
932 "%18s : %10u\n", "CRC ERR",
933 sc->debug.stats.rxstats.crc_err);
934 len += snprintf(buf + len, size - len,
935 "%18s : %10u\n", "DECRYPT CRC ERR",
936 sc->debug.stats.rxstats.decrypt_crc_err);
937 len += snprintf(buf + len, size - len,
938 "%18s : %10u\n", "PHY ERR",
939 sc->debug.stats.rxstats.phy_err);
940 len += snprintf(buf + len, size - len,
941 "%18s : %10u\n", "MIC ERR",
942 sc->debug.stats.rxstats.mic_err);
943 len += snprintf(buf + len, size - len,
944 "%18s : %10u\n", "PRE-DELIM CRC ERR",
945 sc->debug.stats.rxstats.pre_delim_crc_err);
946 len += snprintf(buf + len, size - len,
947 "%18s : %10u\n", "POST-DELIM CRC ERR",
948 sc->debug.stats.rxstats.post_delim_crc_err);
949 len += snprintf(buf + len, size - len,
950 "%18s : %10u\n", "DECRYPT BUSY ERR",
951 sc->debug.stats.rxstats.decrypt_busy_err);
952
Senthil Balasubramanian7d755412011-04-08 15:30:34 +0530953 len += snprintf(buf + len, size - len,
954 "%18s : %10d\n", "RSSI-CTL0",
955 sc->debug.stats.rxstats.rs_rssi_ctl0);
956
957 len += snprintf(buf + len, size - len,
958 "%18s : %10d\n", "RSSI-CTL1",
959 sc->debug.stats.rxstats.rs_rssi_ctl1);
960
961 len += snprintf(buf + len, size - len,
962 "%18s : %10d\n", "RSSI-CTL2",
963 sc->debug.stats.rxstats.rs_rssi_ctl2);
964
965 len += snprintf(buf + len, size - len,
966 "%18s : %10d\n", "RSSI-EXT0",
967 sc->debug.stats.rxstats.rs_rssi_ext0);
968
969 len += snprintf(buf + len, size - len,
970 "%18s : %10d\n", "RSSI-EXT1",
971 sc->debug.stats.rxstats.rs_rssi_ext1);
972
973 len += snprintf(buf + len, size - len,
974 "%18s : %10d\n", "RSSI-EXT2",
975 sc->debug.stats.rxstats.rs_rssi_ext2);
976
977 len += snprintf(buf + len, size - len,
978 "%18s : %10d\n", "Rx Antenna",
979 sc->debug.stats.rxstats.rs_antenna);
980
Sujith1395d3f2010-01-08 10:36:11 +0530981 PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN);
982 PHY_ERR("TIMING", ATH9K_PHYERR_TIMING);
983 PHY_ERR("PARITY", ATH9K_PHYERR_PARITY);
984 PHY_ERR("RATE", ATH9K_PHYERR_RATE);
985 PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH);
986 PHY_ERR("RADAR", ATH9K_PHYERR_RADAR);
987 PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE);
988 PHY_ERR("TOR", ATH9K_PHYERR_TOR);
989 PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING);
990 PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY);
991 PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL);
992 PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL);
993 PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP);
994 PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE);
995 PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART);
996 PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT);
997 PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING);
998 PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC);
999 PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL);
1000 PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE);
1001 PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART);
1002 PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL);
1003 PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP);
1004 PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR);
1005 PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
1006 PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL);
1007
Ben Greear99c15bf2010-10-01 12:26:30 -07001008 len += snprintf(buf + len, size - len,
1009 "%18s : %10u\n", "RX-Pkts-All",
1010 sc->debug.stats.rxstats.rx_pkts_all);
1011 len += snprintf(buf + len, size - len,
1012 "%18s : %10u\n", "RX-Bytes-All",
1013 sc->debug.stats.rxstats.rx_bytes_all);
1014
Dan Carpenter2b87f3a2010-05-14 15:24:37 +02001015 if (len > size)
1016 len = size;
1017
Sujith1395d3f2010-01-08 10:36:11 +05301018 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1019 kfree(buf);
1020
1021 return retval;
1022
1023#undef PHY_ERR
1024}
1025
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001026void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
Sujith1395d3f2010-01-08 10:36:11 +05301027{
1028#define RX_STAT_INC(c) sc->debug.stats.rxstats.c++
1029#define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301030#define RX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].rs\
1031 [sc->debug.rsidx].c)
Sujith1395d3f2010-01-08 10:36:11 +05301032
Sujith1395d3f2010-01-08 10:36:11 +05301033 u32 phyerr;
1034
Ben Greear99c15bf2010-10-01 12:26:30 -07001035 RX_STAT_INC(rx_pkts_all);
1036 sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen;
1037
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001038 if (rs->rs_status & ATH9K_RXERR_CRC)
Sujith1395d3f2010-01-08 10:36:11 +05301039 RX_STAT_INC(crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001040 if (rs->rs_status & ATH9K_RXERR_DECRYPT)
Sujith1395d3f2010-01-08 10:36:11 +05301041 RX_STAT_INC(decrypt_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001042 if (rs->rs_status & ATH9K_RXERR_MIC)
Sujith1395d3f2010-01-08 10:36:11 +05301043 RX_STAT_INC(mic_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001044 if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE)
Sujith1395d3f2010-01-08 10:36:11 +05301045 RX_STAT_INC(pre_delim_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001046 if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST)
Sujith1395d3f2010-01-08 10:36:11 +05301047 RX_STAT_INC(post_delim_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001048 if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY)
Sujith1395d3f2010-01-08 10:36:11 +05301049 RX_STAT_INC(decrypt_busy_err);
1050
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001051 if (rs->rs_status & ATH9K_RXERR_PHY) {
Sujith1395d3f2010-01-08 10:36:11 +05301052 RX_STAT_INC(phy_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001053 phyerr = rs->rs_phyerr & 0x24;
Sujith1395d3f2010-01-08 10:36:11 +05301054 RX_PHY_ERR_INC(phyerr);
1055 }
1056
Senthil Balasubramanian7d755412011-04-08 15:30:34 +05301057 sc->debug.stats.rxstats.rs_rssi_ctl0 = rs->rs_rssi_ctl0;
1058 sc->debug.stats.rxstats.rs_rssi_ctl1 = rs->rs_rssi_ctl1;
1059 sc->debug.stats.rxstats.rs_rssi_ctl2 = rs->rs_rssi_ctl2;
1060
1061 sc->debug.stats.rxstats.rs_rssi_ext0 = rs->rs_rssi_ext0;
1062 sc->debug.stats.rxstats.rs_rssi_ext1 = rs->rs_rssi_ext1;
1063 sc->debug.stats.rxstats.rs_rssi_ext2 = rs->rs_rssi_ext2;
1064
1065 sc->debug.stats.rxstats.rs_antenna = rs->rs_antenna;
1066
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301067 spin_lock(&sc->debug.samp_lock);
1068 RX_SAMP_DBG(jiffies) = jiffies;
1069 RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0;
1070 RX_SAMP_DBG(rssi_ctl1) = rs->rs_rssi_ctl1;
1071 RX_SAMP_DBG(rssi_ctl2) = rs->rs_rssi_ctl2;
1072 RX_SAMP_DBG(rssi_ext0) = rs->rs_rssi_ext0;
1073 RX_SAMP_DBG(rssi_ext1) = rs->rs_rssi_ext1;
1074 RX_SAMP_DBG(rssi_ext2) = rs->rs_rssi_ext2;
1075 RX_SAMP_DBG(antenna) = rs->rs_antenna;
1076 RX_SAMP_DBG(rssi) = rs->rs_rssi;
1077 RX_SAMP_DBG(rate) = rs->rs_rate;
1078 RX_SAMP_DBG(is_mybeacon) = rs->is_mybeacon;
1079
1080 sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES;
1081 spin_unlock(&sc->debug.samp_lock);
1082
Sujith1395d3f2010-01-08 10:36:11 +05301083#undef RX_STAT_INC
1084#undef RX_PHY_ERR_INC
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301085#undef RX_SAMP_DBG
Sujith1395d3f2010-01-08 10:36:11 +05301086}
1087
1088static const struct file_operations fops_recv = {
1089 .read = read_file_recv,
1090 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001091 .owner = THIS_MODULE,
1092 .llseek = default_llseek,
Sujith1395d3f2010-01-08 10:36:11 +05301093};
1094
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001095static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
1096 size_t count, loff_t *ppos)
1097{
1098 struct ath_softc *sc = file->private_data;
1099 char buf[32];
1100 unsigned int len;
1101
Dan Carpenter2b87f3a2010-05-14 15:24:37 +02001102 len = sprintf(buf, "0x%08x\n", sc->debug.regidx);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001103 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1104}
1105
1106static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
1107 size_t count, loff_t *ppos)
1108{
1109 struct ath_softc *sc = file->private_data;
1110 unsigned long regidx;
1111 char buf[32];
1112 ssize_t len;
1113
1114 len = min(count, sizeof(buf) - 1);
1115 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +02001116 return -EFAULT;
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001117
1118 buf[len] = '\0';
1119 if (strict_strtoul(buf, 0, &regidx))
1120 return -EINVAL;
1121
1122 sc->debug.regidx = regidx;
1123 return count;
1124}
1125
1126static const struct file_operations fops_regidx = {
1127 .read = read_file_regidx,
1128 .write = write_file_regidx,
1129 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001130 .owner = THIS_MODULE,
1131 .llseek = default_llseek,
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001132};
1133
1134static ssize_t read_file_regval(struct file *file, char __user *user_buf,
1135 size_t count, loff_t *ppos)
1136{
1137 struct ath_softc *sc = file->private_data;
1138 struct ath_hw *ah = sc->sc_ah;
1139 char buf[32];
1140 unsigned int len;
1141 u32 regval;
1142
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301143 ath9k_ps_wakeup(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001144 regval = REG_READ_D(ah, sc->debug.regidx);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301145 ath9k_ps_restore(sc);
Dan Carpenter2b87f3a2010-05-14 15:24:37 +02001146 len = sprintf(buf, "0x%08x\n", regval);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001147 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1148}
1149
1150static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
1151 size_t count, loff_t *ppos)
1152{
1153 struct ath_softc *sc = file->private_data;
1154 struct ath_hw *ah = sc->sc_ah;
1155 unsigned long regval;
1156 char buf[32];
1157 ssize_t len;
1158
1159 len = min(count, sizeof(buf) - 1);
1160 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +02001161 return -EFAULT;
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001162
1163 buf[len] = '\0';
1164 if (strict_strtoul(buf, 0, &regval))
1165 return -EINVAL;
1166
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301167 ath9k_ps_wakeup(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001168 REG_WRITE_D(ah, sc->debug.regidx, regval);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301169 ath9k_ps_restore(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001170 return count;
1171}
1172
1173static const struct file_operations fops_regval = {
1174 .read = read_file_regval,
1175 .write = write_file_regval,
1176 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001177 .owner = THIS_MODULE,
1178 .llseek = default_llseek,
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001179};
1180
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -08001181#define REGDUMP_LINE_SIZE 20
1182
1183static int open_file_regdump(struct inode *inode, struct file *file)
1184{
1185 struct ath_softc *sc = inode->i_private;
1186 unsigned int len = 0;
1187 u8 *buf;
1188 int i;
1189 unsigned long num_regs, regdump_len, max_reg_offset;
1190
1191 max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500;
1192 num_regs = max_reg_offset / 4 + 1;
1193 regdump_len = num_regs * REGDUMP_LINE_SIZE + 1;
1194 buf = vmalloc(regdump_len);
1195 if (!buf)
1196 return -ENOMEM;
1197
1198 ath9k_ps_wakeup(sc);
1199 for (i = 0; i < num_regs; i++)
1200 len += scnprintf(buf + len, regdump_len - len,
1201 "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2));
1202 ath9k_ps_restore(sc);
1203
1204 file->private_data = buf;
1205
1206 return 0;
1207}
1208
1209static const struct file_operations fops_regdump = {
1210 .open = open_file_regdump,
1211 .read = ath9k_debugfs_read_buf,
1212 .release = ath9k_debugfs_release_buf,
1213 .owner = THIS_MODULE,
1214 .llseek = default_llseek,/* read accesses f_pos */
1215};
1216
Rajkumar Manoharand069a462011-08-13 10:28:18 +05301217static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf,
1218 size_t count, loff_t *ppos)
1219{
1220 struct ath_softc *sc = file->private_data;
1221 struct ath_hw *ah = sc->sc_ah;
1222 struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist;
1223 struct ath_common *common = ath9k_hw_common(ah);
1224 struct ieee80211_conf *conf = &common->hw->conf;
1225 u32 len = 0, size = 1500;
1226 u32 i, j;
1227 ssize_t retval = 0;
1228 char *buf;
1229 u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
1230 u8 nread;
1231
1232 buf = kzalloc(size, GFP_KERNEL);
1233 if (!buf)
1234 return -ENOMEM;
1235
1236 len += snprintf(buf + len, size - len,
1237 "Channel Noise Floor : %d\n", ah->noise);
1238 len += snprintf(buf + len, size - len,
1239 "Chain | privNF | # Readings | NF Readings\n");
1240 for (i = 0; i < NUM_NF_READINGS; i++) {
1241 if (!(chainmask & (1 << i)) ||
1242 ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
1243 continue;
1244
1245 nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount;
1246 len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t",
1247 i, h[i].privNF, nread);
1248 for (j = 0; j < nread; j++)
1249 len += snprintf(buf + len, size - len,
1250 " %d", h[i].nfCalBuffer[j]);
1251 len += snprintf(buf + len, size - len, "\n");
1252 }
1253
1254 if (len > size)
1255 len = size;
1256
1257 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1258 kfree(buf);
1259
1260 return retval;
1261}
1262
1263static const struct file_operations fops_dump_nfcal = {
1264 .read = read_file_dump_nfcal,
1265 .open = ath9k_debugfs_open,
1266 .owner = THIS_MODULE,
1267 .llseek = default_llseek,
1268};
1269
Rajkumar Manoharan580f0102011-07-29 17:38:12 +05301270static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
1271 size_t count, loff_t *ppos)
1272{
1273 struct ath_softc *sc = file->private_data;
1274 struct ath_hw *ah = sc->sc_ah;
1275 u32 len = 0, size = 1500;
1276 ssize_t retval = 0;
1277 char *buf;
1278
1279 buf = kzalloc(size, GFP_KERNEL);
1280 if (!buf)
1281 return -ENOMEM;
1282
1283 len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size);
1284
1285 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1286 kfree(buf);
1287
1288 return retval;
1289}
1290
1291static const struct file_operations fops_base_eeprom = {
1292 .read = read_file_base_eeprom,
1293 .open = ath9k_debugfs_open,
1294 .owner = THIS_MODULE,
1295 .llseek = default_llseek,
1296};
1297
Rajkumar Manoharan3f4c4bd2011-07-29 17:38:13 +05301298static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf,
1299 size_t count, loff_t *ppos)
1300{
1301 struct ath_softc *sc = file->private_data;
1302 struct ath_hw *ah = sc->sc_ah;
1303 u32 len = 0, size = 6000;
1304 char *buf;
1305 size_t retval;
1306
1307 buf = kzalloc(size, GFP_KERNEL);
1308 if (buf == NULL)
1309 return -ENOMEM;
1310
1311 len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size);
1312
1313 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1314 kfree(buf);
1315
1316 return retval;
1317}
1318
1319static const struct file_operations fops_modal_eeprom = {
1320 .read = read_file_modal_eeprom,
1321 .open = ath9k_debugfs_open,
1322 .owner = THIS_MODULE,
1323 .llseek = default_llseek,
1324};
1325
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301326void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
1327{
1328#define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c)
1329 struct ath_hw *ah = sc->sc_ah;
1330 struct ath_common *common = ath9k_hw_common(ah);
1331 unsigned long flags;
1332 int i;
1333
1334 ath9k_ps_wakeup(sc);
1335
Rajkumar Manoharan6bc05a92011-09-06 21:00:07 +05301336 spin_lock_bh(&sc->debug.samp_lock);
1337
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301338 spin_lock_irqsave(&common->cc_lock, flags);
1339 ath_hw_cycle_counters_update(common);
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301340
1341 ATH_SAMP_DBG(cc.cycles) = common->cc_ani.cycles;
1342 ATH_SAMP_DBG(cc.rx_busy) = common->cc_ani.rx_busy;
1343 ATH_SAMP_DBG(cc.rx_frame) = common->cc_ani.rx_frame;
1344 ATH_SAMP_DBG(cc.tx_frame) = common->cc_ani.tx_frame;
Rajkumar Manoharan6bc05a92011-09-06 21:00:07 +05301345 spin_unlock_irqrestore(&common->cc_lock, flags);
1346
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301347 ATH_SAMP_DBG(noise) = ah->noise;
1348
1349 REG_WRITE_D(ah, AR_MACMISC,
1350 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
1351 (AR_MACMISC_MISC_OBS_BUS_1 <<
1352 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
1353
1354 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++)
1355 ATH_SAMP_DBG(dma_dbg_reg_vals[i]) = REG_READ_D(ah,
1356 AR_DMADBG_0 + (i * sizeof(u32)));
1357
1358 ATH_SAMP_DBG(pcu_obs) = REG_READ_D(ah, AR_OBS_BUS_1);
1359 ATH_SAMP_DBG(pcu_cr) = REG_READ_D(ah, AR_CR);
1360
1361 memcpy(ATH_SAMP_DBG(nfCalHist), sc->caldata.nfCalHist,
1362 sizeof(ATH_SAMP_DBG(nfCalHist)));
1363
1364 sc->debug.sampidx = (sc->debug.sampidx + 1) % ATH_DBG_MAX_SAMPLES;
1365 spin_unlock_bh(&sc->debug.samp_lock);
1366 ath9k_ps_restore(sc);
1367
1368#undef ATH_SAMP_DBG
1369}
1370
1371static int open_file_bb_mac_samps(struct inode *inode, struct file *file)
1372{
1373#define ATH_SAMP_DBG(c) bb_mac_samp[sampidx].c
1374 struct ath_softc *sc = inode->i_private;
1375 struct ath_hw *ah = sc->sc_ah;
1376 struct ath_common *common = ath9k_hw_common(ah);
1377 struct ieee80211_conf *conf = &common->hw->conf;
1378 struct ath_dbg_bb_mac_samp *bb_mac_samp;
1379 struct ath9k_nfcal_hist *h;
1380 int i, j, qcuOffset = 0, dcuOffset = 0;
1381 u32 *qcuBase, *dcuBase, size = 30000, len = 0;
1382 u32 sampidx = 0;
1383 u8 *buf;
1384 u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
1385 u8 nread;
1386
Rajkumar Manoharanf7e014d2011-09-06 21:00:06 +05301387 if (sc->sc_flags & SC_OP_INVALID)
1388 return -EAGAIN;
1389
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301390 buf = vmalloc(size);
1391 if (!buf)
1392 return -ENOMEM;
1393 bb_mac_samp = vmalloc(sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES);
1394 if (!bb_mac_samp) {
1395 vfree(buf);
1396 return -ENOMEM;
1397 }
Rajkumar Manoharanf7e014d2011-09-06 21:00:06 +05301398 /* Account the current state too */
1399 ath9k_debug_samp_bb_mac(sc);
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301400
1401 spin_lock_bh(&sc->debug.samp_lock);
1402 memcpy(bb_mac_samp, sc->debug.bb_mac_samp,
1403 sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES);
Rajkumar Manoharan6bc05a92011-09-06 21:00:07 +05301404 len += snprintf(buf + len, size - len,
1405 "Current Sample Index: %d\n", sc->debug.sampidx);
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301406 spin_unlock_bh(&sc->debug.samp_lock);
1407
1408 len += snprintf(buf + len, size - len,
1409 "Raw DMA Debug Dump:\n");
1410 len += snprintf(buf + len, size - len, "Sample |\t");
1411 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++)
1412 len += snprintf(buf + len, size - len, " DMA Reg%d |\t", i);
1413 len += snprintf(buf + len, size - len, "\n");
1414
1415 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1416 len += snprintf(buf + len, size - len, "%d\t", sampidx);
1417
1418 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++)
1419 len += snprintf(buf + len, size - len, " %08x\t",
1420 ATH_SAMP_DBG(dma_dbg_reg_vals[i]));
1421 len += snprintf(buf + len, size - len, "\n");
1422 }
1423 len += snprintf(buf + len, size - len, "\n");
1424
1425 len += snprintf(buf + len, size - len,
1426 "Sample Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
1427 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1428 qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]);
1429 dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]);
1430
1431 for (i = 0; i < ATH9K_NUM_QUEUES; i++,
1432 qcuOffset += 4, dcuOffset += 5) {
1433 if (i == 8) {
1434 qcuOffset = 0;
1435 qcuBase++;
1436 }
1437
1438 if (i == 6) {
1439 dcuOffset = 0;
1440 dcuBase++;
1441 }
1442 if (!sc->debug.stats.txstats[i].queued)
1443 continue;
1444
1445 len += snprintf(buf + len, size - len,
1446 "%4d %7d %2x %1x %2x %2x\n",
1447 sampidx, i,
1448 (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
1449 (*qcuBase & (0x8 << qcuOffset)) >>
1450 (qcuOffset + 3),
1451 ATH_SAMP_DBG(dma_dbg_reg_vals[2]) &
1452 (0x7 << (i * 3)) >> (i * 3),
1453 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
1454 }
1455 len += snprintf(buf + len, size - len, "\n");
1456 }
1457 len += snprintf(buf + len, size - len,
1458 "samp qcu_sh qcu_fh qcu_comp dcu_comp dcu_arb dcu_fp "
1459 "ch_idle_dur ch_idle_dur_val txfifo_val0 txfifo_val1 "
1460 "txfifo_dcu0 txfifo_dcu1 pcu_obs AR_CR\n");
1461
1462 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1463 qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]);
1464 dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]);
1465
1466 len += snprintf(buf + len, size - len, "%4d %5x %5x ", sampidx,
1467 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x003c0000) >> 18,
1468 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x03c00000) >> 22);
1469 len += snprintf(buf + len, size - len, "%7x %8x ",
1470 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x1c000000) >> 26,
1471 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x3));
1472 len += snprintf(buf + len, size - len, "%7x %7x ",
1473 (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x06000000) >> 25,
1474 (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x38000000) >> 27);
1475 len += snprintf(buf + len, size - len, "%7d %12d ",
1476 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x000003fc) >> 2,
1477 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000400) >> 10);
1478 len += snprintf(buf + len, size - len, "%12d %12d ",
1479 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000800) >> 11,
1480 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00001000) >> 12);
1481 len += snprintf(buf + len, size - len, "%12d %12d ",
1482 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x0001e000) >> 13,
1483 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x001e0000) >> 17);
1484 len += snprintf(buf + len, size - len, "0x%07x 0x%07x\n",
1485 ATH_SAMP_DBG(pcu_obs), ATH_SAMP_DBG(pcu_cr));
1486 }
1487
1488 len += snprintf(buf + len, size - len,
1489 "Sample ChNoise Chain privNF #Reading Readings\n");
1490 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1491 h = ATH_SAMP_DBG(nfCalHist);
1492 if (!ATH_SAMP_DBG(noise))
1493 continue;
1494
1495 for (i = 0; i < NUM_NF_READINGS; i++) {
1496 if (!(chainmask & (1 << i)) ||
1497 ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
1498 continue;
1499
1500 nread = AR_PHY_CCA_FILTERWINDOW_LENGTH -
1501 h[i].invalidNFcount;
1502 len += snprintf(buf + len, size - len,
1503 "%4d %5d %4d\t %d\t %d\t",
1504 sampidx, ATH_SAMP_DBG(noise),
1505 i, h[i].privNF, nread);
1506 for (j = 0; j < nread; j++)
1507 len += snprintf(buf + len, size - len,
1508 " %d", h[i].nfCalBuffer[j]);
1509 len += snprintf(buf + len, size - len, "\n");
1510 }
1511 }
1512 len += snprintf(buf + len, size - len, "\nCycle counters:\n"
1513 "Sample Total Rxbusy Rxframes Txframes\n");
1514 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1515 if (!ATH_SAMP_DBG(cc.cycles))
1516 continue;
1517 len += snprintf(buf + len, size - len,
1518 "%4d %08x %08x %08x %08x\n",
1519 sampidx, ATH_SAMP_DBG(cc.cycles),
1520 ATH_SAMP_DBG(cc.rx_busy),
1521 ATH_SAMP_DBG(cc.rx_frame),
1522 ATH_SAMP_DBG(cc.tx_frame));
1523 }
1524
1525 len += snprintf(buf + len, size - len, "Tx status Dump :\n");
1526 len += snprintf(buf + len, size - len,
1527 "Sample rssi:- ctl0 ctl1 ctl2 ext0 ext1 ext2 comb "
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +05301528 "isok rts_fail data_fail rate tid qid "
1529 "ba_low ba_high tx_before(ms)\n");
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301530 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1531 for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) {
1532 if (!ATH_SAMP_DBG(ts[i].jiffies))
1533 continue;
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +05301534 len += snprintf(buf + len, size - len, "%-14d"
1535 "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-8d "
1536 "%-9d %-4d %-3d %-3d %08x %08x %-11d\n",
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301537 sampidx,
1538 ATH_SAMP_DBG(ts[i].rssi_ctl0),
1539 ATH_SAMP_DBG(ts[i].rssi_ctl1),
1540 ATH_SAMP_DBG(ts[i].rssi_ctl2),
1541 ATH_SAMP_DBG(ts[i].rssi_ext0),
1542 ATH_SAMP_DBG(ts[i].rssi_ext1),
1543 ATH_SAMP_DBG(ts[i].rssi_ext2),
1544 ATH_SAMP_DBG(ts[i].rssi),
1545 ATH_SAMP_DBG(ts[i].isok),
1546 ATH_SAMP_DBG(ts[i].rts_fail_cnt),
1547 ATH_SAMP_DBG(ts[i].data_fail_cnt),
1548 ATH_SAMP_DBG(ts[i].rateindex),
1549 ATH_SAMP_DBG(ts[i].tid),
1550 ATH_SAMP_DBG(ts[i].qid),
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +05301551 ATH_SAMP_DBG(ts[i].ba_low),
1552 ATH_SAMP_DBG(ts[i].ba_high),
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301553 jiffies_to_msecs(jiffies -
1554 ATH_SAMP_DBG(ts[i].jiffies)));
1555 }
1556 }
1557
1558 len += snprintf(buf + len, size - len, "Rx status Dump :\n");
1559 len += snprintf(buf + len, size - len, "Sample rssi:- ctl0 ctl1 ctl2 "
1560 "ext0 ext1 ext2 comb beacon ant rate rx_before(ms)\n");
1561 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1562 for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) {
1563 if (!ATH_SAMP_DBG(rs[i].jiffies))
1564 continue;
Mohammed Shafi Shajakhan129321802011-09-21 14:22:49 +05301565 len += snprintf(buf + len, size - len, "%-14d"
1566 "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-9s %-2d %02x %-13d\n",
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301567 sampidx,
1568 ATH_SAMP_DBG(rs[i].rssi_ctl0),
1569 ATH_SAMP_DBG(rs[i].rssi_ctl1),
1570 ATH_SAMP_DBG(rs[i].rssi_ctl2),
1571 ATH_SAMP_DBG(rs[i].rssi_ext0),
1572 ATH_SAMP_DBG(rs[i].rssi_ext1),
1573 ATH_SAMP_DBG(rs[i].rssi_ext2),
1574 ATH_SAMP_DBG(rs[i].rssi),
1575 ATH_SAMP_DBG(rs[i].is_mybeacon) ?
1576 "True" : "False",
1577 ATH_SAMP_DBG(rs[i].antenna),
1578 ATH_SAMP_DBG(rs[i].rate),
1579 jiffies_to_msecs(jiffies -
1580 ATH_SAMP_DBG(rs[i].jiffies)));
1581 }
1582 }
1583
1584 vfree(bb_mac_samp);
1585 file->private_data = buf;
1586
1587 return 0;
1588#undef ATH_SAMP_DBG
1589}
1590
1591static const struct file_operations fops_samps = {
1592 .open = open_file_bb_mac_samps,
1593 .read = ath9k_debugfs_read_buf,
1594 .release = ath9k_debugfs_release_buf,
1595 .owner = THIS_MODULE,
1596 .llseek = default_llseek,
1597};
1598
1599
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -07001600int ath9k_init_debug(struct ath_hw *ah)
Sujith88b126a2008-11-28 22:19:02 +05301601{
Luis R. Rodriguezbc974f42009-09-28 02:54:40 -04001602 struct ath_common *common = ath9k_hw_common(ah);
1603 struct ath_softc *sc = (struct ath_softc *) common->priv;
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -07001604
Ben Greeareb272442010-11-29 14:13:22 -08001605 sc->debug.debugfs_phy = debugfs_create_dir("ath9k",
1606 sc->hw->wiphy->debugfsdir);
Sujith17d79042009-02-09 13:27:03 +05301607 if (!sc->debug.debugfs_phy)
Felix Fietkauc8a72c02010-05-11 17:23:00 +02001608 return -ENOMEM;
Sujith826d2682008-11-28 22:20:23 +05301609
Felix Fietkaua830df02009-11-23 22:33:27 +01001610#ifdef CONFIG_ATH_DEBUG
Felix Fietkauc70cab12011-03-19 13:55:37 +01001611 debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1612 sc, &fops_debug);
Felix Fietkaua830df02009-11-23 22:33:27 +01001613#endif
Felix Fietkauc70cab12011-03-19 13:55:37 +01001614 debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
1615 &fops_dma);
1616 debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
1617 &fops_interrupt);
1618 debugfs_create_file("wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1619 sc, &fops_wiphy);
1620 debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc,
1621 &fops_xmit);
1622 debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc,
1623 &fops_stations);
1624 debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc,
1625 &fops_misc);
1626 debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc,
1627 &fops_recv);
1628 debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR,
1629 sc->debug.debugfs_phy, sc, &fops_rx_chainmask);
1630 debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR,
1631 sc->debug.debugfs_phy, sc, &fops_tx_chainmask);
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +05301632 debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR,
1633 sc->debug.debugfs_phy, sc, &fops_disable_ani);
Felix Fietkauc70cab12011-03-19 13:55:37 +01001634 debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1635 sc, &fops_regidx);
1636 debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1637 sc, &fops_regval);
1638 debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR,
1639 sc->debug.debugfs_phy,
1640 &ah->config.cwm_ignore_extcca);
1641 debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc,
1642 &fops_regdump);
Rajkumar Manoharand069a462011-08-13 10:28:18 +05301643 debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc,
1644 &fops_dump_nfcal);
Rajkumar Manoharan580f0102011-07-29 17:38:12 +05301645 debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
1646 &fops_base_eeprom);
Rajkumar Manoharan3f4c4bd2011-07-29 17:38:13 +05301647 debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
1648 &fops_modal_eeprom);
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301649 debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc,
1650 &fops_samps);
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -08001651
Felix Fietkau691680b2011-03-19 13:55:38 +01001652 debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
1653 sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
1654
1655 debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
1656 sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
1657
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001658 sc->debug.regidx = 0;
Rajkumar Manoharancf3af742011-08-27 16:17:47 +05301659 memset(&sc->debug.bb_mac_samp, 0, sizeof(sc->debug.bb_mac_samp));
1660 sc->debug.sampidx = 0;
1661 sc->debug.tsidx = 0;
1662 sc->debug.rsidx = 0;
Sujith826d2682008-11-28 22:20:23 +05301663 return 0;
Sujith88b126a2008-11-28 22:19:02 +05301664}