blob: f0c80ec290d1b2f290ba9a73f19c0fa74e242097 [file] [log] [blame]
Sujith88b126a2008-11-28 22:19:02 +05301/*
Sujithcee075a2009-03-13 09:07:23 +05302 * Copyright (c) 2008-2009 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>
Gabor Juhos52103112009-03-06 09:57:39 +010018#include <asm/unaligned.h>
19
Sujith394cf0a2009-02-09 13:26:54 +053020#include "ath9k.h"
Sujith88b126a2008-11-28 22:19:02 +053021
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -040022#define REG_WRITE_D(_ah, _reg, _val) \
23 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
24#define REG_READ_D(_ah, _reg) \
25 ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
26
Sujith2a163c62008-11-28 22:21:08 +053027static int ath9k_debugfs_open(struct inode *inode, struct file *file)
28{
29 file->private_data = inode->i_private;
30 return 0;
31}
32
Felix Fietkaua830df02009-11-23 22:33:27 +010033#ifdef CONFIG_ATH_DEBUG
34
Jeff Hansen24939282009-05-27 12:48:29 +000035static ssize_t read_file_debug(struct file *file, char __user *user_buf,
36 size_t count, loff_t *ppos)
37{
38 struct ath_softc *sc = file->private_data;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070039 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Jeff Hansen24939282009-05-27 12:48:29 +000040 char buf[32];
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053041 unsigned int len;
42
Dan Carpenter2b87f3a2010-05-14 15:24:37 +020043 len = sprintf(buf, "0x%08x\n", common->debug_mask);
Jeff Hansen24939282009-05-27 12:48:29 +000044 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
45}
46
47static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
48 size_t count, loff_t *ppos)
49{
50 struct ath_softc *sc = file->private_data;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070051 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Jeff Hansen24939282009-05-27 12:48:29 +000052 unsigned long mask;
53 char buf[32];
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053054 ssize_t len;
55
56 len = min(count, sizeof(buf) - 1);
57 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +020058 return -EFAULT;
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053059
60 buf[len] = '\0';
61 if (strict_strtoul(buf, 0, &mask))
62 return -EINVAL;
63
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070064 common->debug_mask = mask;
Jeff Hansen24939282009-05-27 12:48:29 +000065 return count;
66}
67
68static const struct file_operations fops_debug = {
69 .read = read_file_debug,
70 .write = write_file_debug,
71 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +020072 .owner = THIS_MODULE,
73 .llseek = default_llseek,
Jeff Hansen24939282009-05-27 12:48:29 +000074};
75
Felix Fietkaua830df02009-11-23 22:33:27 +010076#endif
77
Pavel Roskin991a0982010-01-29 17:22:26 -050078#define DMA_BUF_LEN 1024
79
Felix Fietkau15340692010-05-11 17:23:01 +020080static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf,
81 size_t count, loff_t *ppos)
82{
83 struct ath_softc *sc = file->private_data;
84 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
85 char buf[32];
86 unsigned int len;
87
Dan Carpenter2b87f3a2010-05-14 15:24:37 +020088 len = sprintf(buf, "0x%08x\n", common->tx_chainmask);
Felix Fietkau15340692010-05-11 17:23:01 +020089 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
90}
91
92static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf,
93 size_t count, loff_t *ppos)
94{
95 struct ath_softc *sc = file->private_data;
96 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
97 unsigned long mask;
98 char buf[32];
99 ssize_t len;
100
101 len = min(count, sizeof(buf) - 1);
102 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +0200103 return -EFAULT;
Felix Fietkau15340692010-05-11 17:23:01 +0200104
105 buf[len] = '\0';
106 if (strict_strtoul(buf, 0, &mask))
107 return -EINVAL;
108
109 common->tx_chainmask = mask;
110 sc->sc_ah->caps.tx_chainmask = mask;
111 return count;
112}
113
114static const struct file_operations fops_tx_chainmask = {
115 .read = read_file_tx_chainmask,
116 .write = write_file_tx_chainmask,
117 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200118 .owner = THIS_MODULE,
119 .llseek = default_llseek,
Felix Fietkau15340692010-05-11 17:23:01 +0200120};
121
122
123static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf,
124 size_t count, loff_t *ppos)
125{
126 struct ath_softc *sc = file->private_data;
127 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
128 char buf[32];
129 unsigned int len;
130
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200131 len = sprintf(buf, "0x%08x\n", common->rx_chainmask);
Felix Fietkau15340692010-05-11 17:23:01 +0200132 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
133}
134
135static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf,
136 size_t count, loff_t *ppos)
137{
138 struct ath_softc *sc = file->private_data;
139 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
140 unsigned long mask;
141 char buf[32];
142 ssize_t len;
143
144 len = min(count, sizeof(buf) - 1);
145 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +0200146 return -EFAULT;
Felix Fietkau15340692010-05-11 17:23:01 +0200147
148 buf[len] = '\0';
149 if (strict_strtoul(buf, 0, &mask))
150 return -EINVAL;
151
152 common->rx_chainmask = mask;
153 sc->sc_ah->caps.rx_chainmask = mask;
154 return count;
155}
156
157static const struct file_operations fops_rx_chainmask = {
158 .read = read_file_rx_chainmask,
159 .write = write_file_rx_chainmask,
160 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200161 .owner = THIS_MODULE,
162 .llseek = default_llseek,
Felix Fietkau15340692010-05-11 17:23:01 +0200163};
164
165
Sujith2a163c62008-11-28 22:21:08 +0530166static ssize_t read_file_dma(struct file *file, char __user *user_buf,
167 size_t count, loff_t *ppos)
168{
169 struct ath_softc *sc = file->private_data;
Sujithcbe61d82009-02-09 13:27:12 +0530170 struct ath_hw *ah = sc->sc_ah;
Pavel Roskin991a0982010-01-29 17:22:26 -0500171 char *buf;
172 int retval;
Sujith2a163c62008-11-28 22:21:08 +0530173 unsigned int len = 0;
174 u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
175 int i, qcuOffset = 0, dcuOffset = 0;
176 u32 *qcuBase = &val[0], *dcuBase = &val[4];
177
Pavel Roskin991a0982010-01-29 17:22:26 -0500178 buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL);
179 if (!buf)
Dan Carpenter04236062010-05-14 15:25:39 +0200180 return -ENOMEM;
Pavel Roskin991a0982010-01-29 17:22:26 -0500181
Sujith7cf4a2e2009-08-26 11:11:57 +0530182 ath9k_ps_wakeup(sc);
183
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400184 REG_WRITE_D(ah, AR_MACMISC,
Sujith2a163c62008-11-28 22:21:08 +0530185 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
186 (AR_MACMISC_MISC_OBS_BUS_1 <<
187 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
188
Pavel Roskin991a0982010-01-29 17:22:26 -0500189 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530190 "Raw DMA Debug values:\n");
191
192 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
193 if (i % 4 == 0)
Pavel Roskin991a0982010-01-29 17:22:26 -0500194 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
Sujith2a163c62008-11-28 22:21:08 +0530195
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400196 val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
Pavel Roskin991a0982010-01-29 17:22:26 -0500197 len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ",
Sujith2a163c62008-11-28 22:21:08 +0530198 i, val[i]);
199 }
200
Pavel Roskin991a0982010-01-29 17:22:26 -0500201 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n");
202 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530203 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
204
205 for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
206 if (i == 8) {
207 qcuOffset = 0;
208 qcuBase++;
209 }
210
211 if (i == 6) {
212 dcuOffset = 0;
213 dcuBase++;
214 }
215
Pavel Roskin991a0982010-01-29 17:22:26 -0500216 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530217 "%2d %2x %1x %2x %2x\n",
218 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
219 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
220 val[2] & (0x7 << (i * 3)) >> (i * 3),
221 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
222 }
223
Pavel Roskin991a0982010-01-29 17:22:26 -0500224 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
Sujith2a163c62008-11-28 22:21:08 +0530225
Pavel Roskin991a0982010-01-29 17:22:26 -0500226 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530227 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
228 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
Pavel Roskin991a0982010-01-29 17:22:26 -0500229 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530230 "qcu_complete state: %2x dcu_complete state: %2x\n",
231 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
Pavel Roskin991a0982010-01-29 17:22:26 -0500232 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530233 "dcu_arb state: %2x dcu_fp state: %2x\n",
234 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
Pavel Roskin991a0982010-01-29 17:22:26 -0500235 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530236 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
237 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
Pavel Roskin991a0982010-01-29 17:22:26 -0500238 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530239 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
240 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
Pavel Roskin991a0982010-01-29 17:22:26 -0500241 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530242 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
243 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
244
Frans Pop60ece402010-03-24 19:46:30 +0100245 len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n",
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400246 REG_READ_D(ah, AR_OBS_BUS_1));
Pavel Roskin991a0982010-01-29 17:22:26 -0500247 len += snprintf(buf + len, DMA_BUF_LEN - len,
Frans Pop60ece402010-03-24 19:46:30 +0100248 "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR));
Sujith2a163c62008-11-28 22:21:08 +0530249
Sujith7cf4a2e2009-08-26 11:11:57 +0530250 ath9k_ps_restore(sc);
251
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200252 if (len > DMA_BUF_LEN)
253 len = DMA_BUF_LEN;
254
Pavel Roskin991a0982010-01-29 17:22:26 -0500255 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
256 kfree(buf);
257 return retval;
Sujith2a163c62008-11-28 22:21:08 +0530258}
259
260static const struct file_operations fops_dma = {
261 .read = read_file_dma,
262 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200263 .owner = THIS_MODULE,
264 .llseek = default_llseek,
Sujith2a163c62008-11-28 22:21:08 +0530265};
266
Sujith817e11d2008-12-07 21:42:44 +0530267
268void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status)
269{
270 if (status)
Sujith17d79042009-02-09 13:27:03 +0530271 sc->debug.stats.istats.total++;
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400272 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
273 if (status & ATH9K_INT_RXLP)
274 sc->debug.stats.istats.rxlp++;
275 if (status & ATH9K_INT_RXHP)
276 sc->debug.stats.istats.rxhp++;
Luis R. Rodriguez08578b82010-05-13 13:33:44 -0400277 if (status & ATH9K_INT_BB_WATCHDOG)
278 sc->debug.stats.istats.bb_watchdog++;
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400279 } else {
280 if (status & ATH9K_INT_RX)
281 sc->debug.stats.istats.rxok++;
282 }
Sujith817e11d2008-12-07 21:42:44 +0530283 if (status & ATH9K_INT_RXEOL)
Sujith17d79042009-02-09 13:27:03 +0530284 sc->debug.stats.istats.rxeol++;
Sujith817e11d2008-12-07 21:42:44 +0530285 if (status & ATH9K_INT_RXORN)
Sujith17d79042009-02-09 13:27:03 +0530286 sc->debug.stats.istats.rxorn++;
Sujith817e11d2008-12-07 21:42:44 +0530287 if (status & ATH9K_INT_TX)
Sujith17d79042009-02-09 13:27:03 +0530288 sc->debug.stats.istats.txok++;
Sujith817e11d2008-12-07 21:42:44 +0530289 if (status & ATH9K_INT_TXURN)
Sujith17d79042009-02-09 13:27:03 +0530290 sc->debug.stats.istats.txurn++;
Sujith817e11d2008-12-07 21:42:44 +0530291 if (status & ATH9K_INT_MIB)
Sujith17d79042009-02-09 13:27:03 +0530292 sc->debug.stats.istats.mib++;
Sujith817e11d2008-12-07 21:42:44 +0530293 if (status & ATH9K_INT_RXPHY)
Sujith17d79042009-02-09 13:27:03 +0530294 sc->debug.stats.istats.rxphyerr++;
Sujith817e11d2008-12-07 21:42:44 +0530295 if (status & ATH9K_INT_RXKCM)
Sujith17d79042009-02-09 13:27:03 +0530296 sc->debug.stats.istats.rx_keycache_miss++;
Sujith817e11d2008-12-07 21:42:44 +0530297 if (status & ATH9K_INT_SWBA)
Sujith17d79042009-02-09 13:27:03 +0530298 sc->debug.stats.istats.swba++;
Sujith817e11d2008-12-07 21:42:44 +0530299 if (status & ATH9K_INT_BMISS)
Sujith17d79042009-02-09 13:27:03 +0530300 sc->debug.stats.istats.bmiss++;
Sujith817e11d2008-12-07 21:42:44 +0530301 if (status & ATH9K_INT_BNR)
Sujith17d79042009-02-09 13:27:03 +0530302 sc->debug.stats.istats.bnr++;
Sujith817e11d2008-12-07 21:42:44 +0530303 if (status & ATH9K_INT_CST)
Sujith17d79042009-02-09 13:27:03 +0530304 sc->debug.stats.istats.cst++;
Sujith817e11d2008-12-07 21:42:44 +0530305 if (status & ATH9K_INT_GTT)
Sujith17d79042009-02-09 13:27:03 +0530306 sc->debug.stats.istats.gtt++;
Sujith817e11d2008-12-07 21:42:44 +0530307 if (status & ATH9K_INT_TIM)
Sujith17d79042009-02-09 13:27:03 +0530308 sc->debug.stats.istats.tim++;
Sujith817e11d2008-12-07 21:42:44 +0530309 if (status & ATH9K_INT_CABEND)
Sujith17d79042009-02-09 13:27:03 +0530310 sc->debug.stats.istats.cabend++;
Sujith817e11d2008-12-07 21:42:44 +0530311 if (status & ATH9K_INT_DTIMSYNC)
Sujith17d79042009-02-09 13:27:03 +0530312 sc->debug.stats.istats.dtimsync++;
Sujith817e11d2008-12-07 21:42:44 +0530313 if (status & ATH9K_INT_DTIM)
Sujith17d79042009-02-09 13:27:03 +0530314 sc->debug.stats.istats.dtim++;
Sujith817e11d2008-12-07 21:42:44 +0530315}
316
317static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
318 size_t count, loff_t *ppos)
319{
320 struct ath_softc *sc = file->private_data;
321 char buf[512];
322 unsigned int len = 0;
323
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400324 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
325 len += snprintf(buf + len, sizeof(buf) - len,
326 "%8s: %10u\n", "RXLP", sc->debug.stats.istats.rxlp);
327 len += snprintf(buf + len, sizeof(buf) - len,
328 "%8s: %10u\n", "RXHP", sc->debug.stats.istats.rxhp);
Luis R. Rodriguez08578b82010-05-13 13:33:44 -0400329 len += snprintf(buf + len, sizeof(buf) - len,
330 "%8s: %10u\n", "WATCHDOG",
331 sc->debug.stats.istats.bb_watchdog);
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400332 } else {
333 len += snprintf(buf + len, sizeof(buf) - len,
334 "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok);
335 }
Sujith817e11d2008-12-07 21:42:44 +0530336 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530337 "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol);
Sujith817e11d2008-12-07 21:42:44 +0530338 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530339 "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn);
Sujith817e11d2008-12-07 21:42:44 +0530340 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530341 "%8s: %10u\n", "TX", sc->debug.stats.istats.txok);
Sujith817e11d2008-12-07 21:42:44 +0530342 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530343 "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn);
Sujith817e11d2008-12-07 21:42:44 +0530344 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530345 "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib);
Sujith817e11d2008-12-07 21:42:44 +0530346 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530347 "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr);
Sujith817e11d2008-12-07 21:42:44 +0530348 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530349 "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss);
Sujith817e11d2008-12-07 21:42:44 +0530350 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530351 "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba);
Sujith817e11d2008-12-07 21:42:44 +0530352 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530353 "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss);
Sujith817e11d2008-12-07 21:42:44 +0530354 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530355 "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr);
Sujith817e11d2008-12-07 21:42:44 +0530356 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530357 "%8s: %10u\n", "CST", sc->debug.stats.istats.cst);
Sujith817e11d2008-12-07 21:42:44 +0530358 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530359 "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt);
Sujith817e11d2008-12-07 21:42:44 +0530360 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530361 "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim);
Sujith817e11d2008-12-07 21:42:44 +0530362 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530363 "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend);
Sujith817e11d2008-12-07 21:42:44 +0530364 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530365 "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync);
Sujith817e11d2008-12-07 21:42:44 +0530366 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530367 "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim);
Sujith817e11d2008-12-07 21:42:44 +0530368 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530369 "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total);
Sujith817e11d2008-12-07 21:42:44 +0530370
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200371 if (len > sizeof(buf))
372 len = sizeof(buf);
373
Sujith817e11d2008-12-07 21:42:44 +0530374 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
375}
376
377static const struct file_operations fops_interrupt = {
378 .read = read_file_interrupt,
379 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200380 .owner = THIS_MODULE,
381 .llseek = default_llseek,
Sujith817e11d2008-12-07 21:42:44 +0530382};
383
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200384static const char * ath_wiphy_state_str(enum ath_wiphy_state state)
385{
386 switch (state) {
387 case ATH_WIPHY_INACTIVE:
388 return "INACTIVE";
389 case ATH_WIPHY_ACTIVE:
390 return "ACTIVE";
391 case ATH_WIPHY_PAUSING:
392 return "PAUSING";
393 case ATH_WIPHY_PAUSED:
394 return "PAUSED";
395 case ATH_WIPHY_SCAN:
396 return "SCAN";
397 }
398 return "?";
399}
400
401static ssize_t read_file_wiphy(struct file *file, char __user *user_buf,
402 size_t count, loff_t *ppos)
403{
404 struct ath_softc *sc = file->private_data;
Mohammed Shafi Shajakhan8e0167a2010-10-01 15:25:05 +0530405 struct ath_wiphy *aphy = sc->pri_wiphy;
406 struct ieee80211_channel *chan = aphy->hw->conf.channel;
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200407 char buf[512];
408 unsigned int len = 0;
409 int i;
410 u8 addr[ETH_ALEN];
Ben Greear39057512010-09-14 12:46:04 -0700411 u32 tmp;
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200412
413 len += snprintf(buf + len, sizeof(buf) - len,
414 "primary: %s (%s chan=%d ht=%d)\n",
415 wiphy_name(sc->pri_wiphy->hw->wiphy),
416 ath_wiphy_state_str(sc->pri_wiphy->state),
Mohammed Shafi Shajakhan8e0167a2010-10-01 15:25:05 +0530417 ieee80211_frequency_to_channel(chan->center_freq),
418 aphy->chan_is_ht);
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200419
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400420 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr);
421 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4);
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200422 len += snprintf(buf + len, sizeof(buf) - len,
423 "addr: %pM\n", addr);
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400424 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr);
425 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4);
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200426 len += snprintf(buf + len, sizeof(buf) - len,
427 "addrmask: %pM\n", addr);
Ben Greear39057512010-09-14 12:46:04 -0700428 tmp = ath9k_hw_getrxfilter(sc->sc_ah);
429 len += snprintf(buf + len, sizeof(buf) - len,
430 "rfilt: 0x%x", tmp);
431 if (tmp & ATH9K_RX_FILTER_UCAST)
432 len += snprintf(buf + len, sizeof(buf) - len, " UCAST");
433 if (tmp & ATH9K_RX_FILTER_MCAST)
434 len += snprintf(buf + len, sizeof(buf) - len, " MCAST");
435 if (tmp & ATH9K_RX_FILTER_BCAST)
436 len += snprintf(buf + len, sizeof(buf) - len, " BCAST");
437 if (tmp & ATH9K_RX_FILTER_CONTROL)
438 len += snprintf(buf + len, sizeof(buf) - len, " CONTROL");
439 if (tmp & ATH9K_RX_FILTER_BEACON)
440 len += snprintf(buf + len, sizeof(buf) - len, " BEACON");
441 if (tmp & ATH9K_RX_FILTER_PROM)
442 len += snprintf(buf + len, sizeof(buf) - len, " PROM");
443 if (tmp & ATH9K_RX_FILTER_PROBEREQ)
444 len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ");
445 if (tmp & ATH9K_RX_FILTER_PHYERR)
446 len += snprintf(buf + len, sizeof(buf) - len, " PHYERR");
447 if (tmp & ATH9K_RX_FILTER_MYBEACON)
448 len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON");
449 if (tmp & ATH9K_RX_FILTER_COMP_BAR)
450 len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR");
451 if (tmp & ATH9K_RX_FILTER_PSPOLL)
452 len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL");
453 if (tmp & ATH9K_RX_FILTER_PHYRADAR)
454 len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR");
455 if (tmp & ATH9K_RX_FILTER_MCAST_BCAST_ALL)
456 len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL\n");
457 else
458 len += snprintf(buf + len, sizeof(buf) - len, "\n");
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200459
Ben Greear39057512010-09-14 12:46:04 -0700460 /* Put variable-length stuff down here, and check for overflows. */
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200461 for (i = 0; i < sc->num_sec_wiphy; i++) {
Luis R. Rodriguez191d6a12010-10-15 13:27:49 -0700462 struct ath_wiphy *aphy_tmp = sc->sec_wiphy[i];
463 if (aphy_tmp == NULL)
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200464 continue;
Luis R. Rodriguez191d6a12010-10-15 13:27:49 -0700465 chan = aphy_tmp->hw->conf.channel;
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200466 len += snprintf(buf + len, sizeof(buf) - len,
Mohammed Shafi Shajakhan8e0167a2010-10-01 15:25:05 +0530467 "secondary: %s (%s chan=%d ht=%d)\n",
Luis R. Rodriguez191d6a12010-10-15 13:27:49 -0700468 wiphy_name(aphy_tmp->hw->wiphy),
469 ath_wiphy_state_str(aphy_tmp->state),
Mohammed Shafi Shajakhan8e0167a2010-10-01 15:25:05 +0530470 ieee80211_frequency_to_channel(chan->center_freq),
Luis R. Rodriguez191d6a12010-10-15 13:27:49 -0700471 aphy_tmp->chan_is_ht);
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200472 }
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200473 if (len > sizeof(buf))
474 len = sizeof(buf);
475
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200476 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
477}
478
479static struct ath_wiphy * get_wiphy(struct ath_softc *sc, const char *name)
480{
481 int i;
482 if (strcmp(name, wiphy_name(sc->pri_wiphy->hw->wiphy)) == 0)
483 return sc->pri_wiphy;
484 for (i = 0; i < sc->num_sec_wiphy; i++) {
485 struct ath_wiphy *aphy = sc->sec_wiphy[i];
486 if (aphy && strcmp(name, wiphy_name(aphy->hw->wiphy)) == 0)
487 return aphy;
488 }
489 return NULL;
490}
491
492static int del_wiphy(struct ath_softc *sc, const char *name)
493{
494 struct ath_wiphy *aphy = get_wiphy(sc, name);
495 if (!aphy)
496 return -ENOENT;
497 return ath9k_wiphy_del(aphy);
498}
499
500static int pause_wiphy(struct ath_softc *sc, const char *name)
501{
502 struct ath_wiphy *aphy = get_wiphy(sc, name);
503 if (!aphy)
504 return -ENOENT;
505 return ath9k_wiphy_pause(aphy);
506}
507
508static int unpause_wiphy(struct ath_softc *sc, const char *name)
509{
510 struct ath_wiphy *aphy = get_wiphy(sc, name);
511 if (!aphy)
512 return -ENOENT;
513 return ath9k_wiphy_unpause(aphy);
514}
515
516static int select_wiphy(struct ath_softc *sc, const char *name)
517{
518 struct ath_wiphy *aphy = get_wiphy(sc, name);
519 if (!aphy)
520 return -ENOENT;
521 return ath9k_wiphy_select(aphy);
522}
523
524static int schedule_wiphy(struct ath_softc *sc, const char *msec)
525{
526 ath9k_wiphy_set_scheduler(sc, simple_strtoul(msec, NULL, 0));
527 return 0;
528}
529
530static ssize_t write_file_wiphy(struct file *file, const char __user *user_buf,
531 size_t count, loff_t *ppos)
532{
533 struct ath_softc *sc = file->private_data;
534 char buf[50];
535 size_t len;
536
537 len = min(count, sizeof(buf) - 1);
538 if (copy_from_user(buf, user_buf, len))
539 return -EFAULT;
540 buf[len] = '\0';
541 if (len > 0 && buf[len - 1] == '\n')
542 buf[len - 1] = '\0';
543
544 if (strncmp(buf, "add", 3) == 0) {
545 int res = ath9k_wiphy_add(sc);
546 if (res < 0)
547 return res;
548 } else if (strncmp(buf, "del=", 4) == 0) {
549 int res = del_wiphy(sc, buf + 4);
550 if (res < 0)
551 return res;
552 } else if (strncmp(buf, "pause=", 6) == 0) {
553 int res = pause_wiphy(sc, buf + 6);
554 if (res < 0)
555 return res;
556 } else if (strncmp(buf, "unpause=", 8) == 0) {
557 int res = unpause_wiphy(sc, buf + 8);
558 if (res < 0)
559 return res;
560 } else if (strncmp(buf, "select=", 7) == 0) {
561 int res = select_wiphy(sc, buf + 7);
562 if (res < 0)
563 return res;
564 } else if (strncmp(buf, "schedule=", 9) == 0) {
565 int res = schedule_wiphy(sc, buf + 9);
566 if (res < 0)
567 return res;
568 } else
569 return -EOPNOTSUPP;
570
571 return count;
572}
573
574static const struct file_operations fops_wiphy = {
575 .read = read_file_wiphy,
576 .write = write_file_wiphy,
577 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200578 .owner = THIS_MODULE,
579 .llseek = default_llseek,
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200580};
581
Sujithfec247c2009-07-27 12:08:16 +0530582#define PR(str, elem) \
583 do { \
584 len += snprintf(buf + len, size - len, \
585 "%s%13u%11u%10u%10u\n", str, \
Felix Fietkau066dae92010-11-07 14:59:39 +0100586 sc->debug.stats.txstats[WME_AC_BE].elem, \
587 sc->debug.stats.txstats[WME_AC_BK].elem, \
588 sc->debug.stats.txstats[WME_AC_VI].elem, \
589 sc->debug.stats.txstats[WME_AC_VO].elem); \
Ben Greear7f010c92011-01-09 23:11:49 -0800590 if (len >= size) \
591 goto done; \
Sujithfec247c2009-07-27 12:08:16 +0530592} while(0)
593
Ben Greear1f427dd2011-01-09 23:11:43 -0800594#define PRX(str, elem) \
595do { \
596 len += snprintf(buf + len, size - len, \
597 "%s%13u%11u%10u%10u\n", str, \
Ben Greear55f6d0f2011-01-17 11:54:50 -0800598 (unsigned int)(sc->tx.txq[ATH_TXQ_AC_BE].elem), \
599 (unsigned int)(sc->tx.txq[ATH_TXQ_AC_BK].elem), \
600 (unsigned int)(sc->tx.txq[ATH_TXQ_AC_VI].elem), \
601 (unsigned int)(sc->tx.txq[ATH_TXQ_AC_VO].elem)); \
Ben Greear7f010c92011-01-09 23:11:49 -0800602 if (len >= size) \
603 goto done; \
Ben Greear1f427dd2011-01-09 23:11:43 -0800604} while(0)
605
Ben Greear2dac4fb2011-01-09 23:11:45 -0800606#define PRQLE(str, elem) \
607do { \
608 len += snprintf(buf + len, size - len, \
609 "%s%13i%11i%10i%10i\n", str, \
Ben Greear55f6d0f2011-01-17 11:54:50 -0800610 list_empty(&sc->tx.txq[ATH_TXQ_AC_BE].elem), \
611 list_empty(&sc->tx.txq[ATH_TXQ_AC_BK].elem), \
612 list_empty(&sc->tx.txq[ATH_TXQ_AC_VI].elem), \
613 list_empty(&sc->tx.txq[ATH_TXQ_AC_VO].elem)); \
Ben Greear7f010c92011-01-09 23:11:49 -0800614 if (len >= size) \
615 goto done; \
Ben Greear2dac4fb2011-01-09 23:11:45 -0800616} while (0)
617
Sujithfec247c2009-07-27 12:08:16 +0530618static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
619 size_t count, loff_t *ppos)
620{
621 struct ath_softc *sc = file->private_data;
622 char *buf;
Ben Greear7f010c92011-01-09 23:11:49 -0800623 unsigned int len = 0, size = 8000;
Ben Greear2dac4fb2011-01-09 23:11:45 -0800624 int i;
Sujithfec247c2009-07-27 12:08:16 +0530625 ssize_t retval = 0;
Ben Greear2dac4fb2011-01-09 23:11:45 -0800626 char tmp[32];
Sujithfec247c2009-07-27 12:08:16 +0530627
628 buf = kzalloc(size, GFP_KERNEL);
629 if (buf == NULL)
Dan Carpenter04236062010-05-14 15:25:39 +0200630 return -ENOMEM;
Sujithfec247c2009-07-27 12:08:16 +0530631
Ben Greear60f2d1d2011-01-09 23:11:52 -0800632 len += sprintf(buf, "Num-Tx-Queues: %i tx-queues-setup: 0x%x"
633 " poll-work-seen: %u\n"
Ben Greear7f010c92011-01-09 23:11:49 -0800634 "%30s %10s%10s%10s\n\n",
635 ATH9K_NUM_TX_QUEUES, sc->tx.txqsetup,
Ben Greear60f2d1d2011-01-09 23:11:52 -0800636 sc->tx_complete_poll_work_seen,
Ben Greear7f010c92011-01-09 23:11:49 -0800637 "BE", "BK", "VI", "VO");
Sujithfec247c2009-07-27 12:08:16 +0530638
639 PR("MPDUs Queued: ", queued);
640 PR("MPDUs Completed: ", completed);
641 PR("Aggregates: ", a_aggr);
Ben Greearbda8add2011-01-09 23:11:48 -0800642 PR("AMPDUs Queued HW:", a_queued_hw);
643 PR("AMPDUs Queued SW:", a_queued_sw);
Sujithfec247c2009-07-27 12:08:16 +0530644 PR("AMPDUs Completed:", a_completed);
645 PR("AMPDUs Retried: ", a_retries);
646 PR("AMPDUs XRetried: ", a_xretries);
647 PR("FIFO Underrun: ", fifo_underrun);
648 PR("TXOP Exceeded: ", xtxop);
649 PR("TXTIMER Expiry: ", timer_exp);
650 PR("DESC CFG Error: ", desc_cfg_err);
651 PR("DATA Underrun: ", data_underrun);
652 PR("DELIM Underrun: ", delim_underrun);
Ben Greear99c15bf2010-10-01 12:26:30 -0700653 PR("TX-Pkts-All: ", tx_pkts_all);
654 PR("TX-Bytes-All: ", tx_bytes_all);
Ben Greear2dac4fb2011-01-09 23:11:45 -0800655 PR("hw-put-tx-buf: ", puttxbuf);
656 PR("hw-tx-start: ", txstart);
657 PR("hw-tx-proc-desc: ", txprocdesc);
Ben Greear7f010c92011-01-09 23:11:49 -0800658 len += snprintf(buf + len, size - len,
659 "%s%11p%11p%10p%10p\n", "txq-memory-address:",
Ben Greear55f6d0f2011-01-17 11:54:50 -0800660 &(sc->tx.txq[ATH_TXQ_AC_BE]),
661 &(sc->tx.txq[ATH_TXQ_AC_BK]),
662 &(sc->tx.txq[ATH_TXQ_AC_VI]),
663 &(sc->tx.txq[ATH_TXQ_AC_VO]));
Ben Greear7f010c92011-01-09 23:11:49 -0800664 if (len >= size)
665 goto done;
Sujithfec247c2009-07-27 12:08:16 +0530666
Ben Greear1f427dd2011-01-09 23:11:43 -0800667 PRX("axq-qnum: ", axq_qnum);
668 PRX("axq-depth: ", axq_depth);
Ben Greear2dac4fb2011-01-09 23:11:45 -0800669 PRX("axq-ampdu_depth: ", axq_ampdu_depth);
Ben Greear1f427dd2011-01-09 23:11:43 -0800670 PRX("axq-stopped ", stopped);
671 PRX("tx-in-progress ", axq_tx_inprogress);
672 PRX("pending-frames ", pending_frames);
Ben Greear2dac4fb2011-01-09 23:11:45 -0800673 PRX("txq_headidx: ", txq_headidx);
674 PRX("txq_tailidx: ", txq_headidx);
Ben Greear1f427dd2011-01-09 23:11:43 -0800675
Ben Greear2dac4fb2011-01-09 23:11:45 -0800676 PRQLE("axq_q empty: ", axq_q);
677 PRQLE("axq_acq empty: ", axq_acq);
678 PRQLE("txq_fifo_pending: ", txq_fifo_pending);
679 for (i = 0; i < ATH_TXFIFO_DEPTH; i++) {
680 snprintf(tmp, sizeof(tmp) - 1, "txq_fifo[%i] empty: ", i);
681 PRQLE(tmp, txq_fifo[i]);
682 }
Ben Greear7f010c92011-01-09 23:11:49 -0800683
Ben Greear71e025a2011-01-09 23:11:50 -0800684 /* Print out more detailed queue-info */
685 for (i = 0; i <= WME_AC_BK; i++) {
686 struct ath_txq *txq = &(sc->tx.txq[i]);
687 struct ath_atx_ac *ac;
688 struct ath_atx_tid *tid;
689 if (len >= size)
690 goto done;
691 spin_lock_bh(&txq->axq_lock);
692 if (!list_empty(&txq->axq_acq)) {
693 ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac,
694 list);
695 len += snprintf(buf + len, size - len,
696 "txq[%i] first-ac: %p sched: %i\n",
697 i, ac, ac->sched);
698 if (list_empty(&ac->tid_q) || (len >= size))
699 goto done_for;
700 tid = list_first_entry(&ac->tid_q, struct ath_atx_tid,
701 list);
702 len += snprintf(buf + len, size - len,
703 " first-tid: %p sched: %i paused: %i\n",
704 tid, tid->sched, tid->paused);
705 }
706 done_for:
707 spin_unlock_bh(&txq->axq_lock);
708 }
709
Ben Greear7f010c92011-01-09 23:11:49 -0800710done:
711 if (len > size)
712 len = size;
713
714 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
715 kfree(buf);
716
717 return retval;
718}
719
720static ssize_t read_file_stations(struct file *file, char __user *user_buf,
721 size_t count, loff_t *ppos)
722{
723 struct ath_softc *sc = file->private_data;
724 char *buf;
725 unsigned int len = 0, size = 64000;
726 struct ath_node *an = NULL;
727 ssize_t retval = 0;
728 int q;
729
730 buf = kzalloc(size, GFP_KERNEL);
731 if (buf == NULL)
732 return -ENOMEM;
733
734 len += snprintf(buf + len, size - len,
735 "Stations:\n"
736 " tid: addr sched paused buf_q-empty an ac\n"
737 " ac: addr sched tid_q-empty txq\n");
738
739 spin_lock(&sc->nodes_lock);
740 list_for_each_entry(an, &sc->nodes, list) {
741 len += snprintf(buf + len, size - len,
742 "%pM\n", an->sta->addr);
743 if (len >= size)
744 goto done;
745
746 for (q = 0; q < WME_NUM_TID; q++) {
747 struct ath_atx_tid *tid = &(an->tid[q]);
748 len += snprintf(buf + len, size - len,
749 " tid: %p %s %s %i %p %p\n",
750 tid, tid->sched ? "sched" : "idle",
751 tid->paused ? "paused" : "running",
752 list_empty(&tid->buf_q),
753 tid->an, tid->ac);
754 if (len >= size)
755 goto done;
756 }
757
758 for (q = 0; q < WME_NUM_AC; q++) {
759 struct ath_atx_ac *ac = &(an->ac[q]);
760 len += snprintf(buf + len, size - len,
761 " ac: %p %s %i %p\n",
762 ac, ac->sched ? "sched" : "idle",
763 list_empty(&ac->tid_q), ac->txq);
764 if (len >= size)
765 goto done;
766 }
767 }
768
769done:
770 spin_unlock(&sc->nodes_lock);
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200771 if (len > size)
772 len = size;
773
Sujithfec247c2009-07-27 12:08:16 +0530774 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
775 kfree(buf);
776
777 return retval;
778}
779
Ben Greear55f6d0f2011-01-17 11:54:50 -0800780static ssize_t read_file_misc(struct file *file, char __user *user_buf,
781 size_t count, loff_t *ppos)
782{
783 struct ath_softc *sc = file->private_data;
784 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
785 struct ath_hw *ah = sc->sc_ah;
786 struct ieee80211_hw *hw = sc->hw;
787 char *buf;
788 unsigned int len = 0, size = 8000;
789 ssize_t retval = 0;
790 const char *tmp;
791 unsigned int reg;
792 struct ath9k_vif_iter_data iter_data;
793
794 ath9k_calculate_iter_data(hw, NULL, &iter_data);
795
796 buf = kzalloc(size, GFP_KERNEL);
797 if (buf == NULL)
798 return -ENOMEM;
799
800 switch (sc->sc_ah->opmode) {
801 case NL80211_IFTYPE_ADHOC:
802 tmp = "ADHOC";
803 break;
804 case NL80211_IFTYPE_MESH_POINT:
805 tmp = "MESH";
806 break;
807 case NL80211_IFTYPE_AP:
808 tmp = "AP";
809 break;
810 case NL80211_IFTYPE_STATION:
811 tmp = "STATION";
812 break;
813 default:
814 tmp = "???";
815 break;
816 }
817
818 len += snprintf(buf + len, size - len,
819 "curbssid: %pM\n"
820 "OP-Mode: %s(%i)\n"
821 "Beacon-Timer-Register: 0x%x\n",
822 common->curbssid,
823 tmp, (int)(sc->sc_ah->opmode),
824 REG_READ(ah, AR_BEACON_PERIOD));
825
826 reg = REG_READ(ah, AR_TIMER_MODE);
827 len += snprintf(buf + len, size - len, "Timer-Mode-Register: 0x%x (",
828 reg);
829 if (reg & AR_TBTT_TIMER_EN)
830 len += snprintf(buf + len, size - len, "TBTT ");
831 if (reg & AR_DBA_TIMER_EN)
832 len += snprintf(buf + len, size - len, "DBA ");
833 if (reg & AR_SWBA_TIMER_EN)
834 len += snprintf(buf + len, size - len, "SWBA ");
835 if (reg & AR_HCF_TIMER_EN)
836 len += snprintf(buf + len, size - len, "HCF ");
837 if (reg & AR_TIM_TIMER_EN)
838 len += snprintf(buf + len, size - len, "TIM ");
839 if (reg & AR_DTIM_TIMER_EN)
840 len += snprintf(buf + len, size - len, "DTIM ");
841 len += snprintf(buf + len, size - len, ")\n");
842
843 reg = sc->sc_ah->imask;
844 len += snprintf(buf + len, size - len, "imask: 0x%x (", reg);
845 if (reg & ATH9K_INT_SWBA)
846 len += snprintf(buf + len, size - len, "SWBA ");
847 if (reg & ATH9K_INT_BMISS)
848 len += snprintf(buf + len, size - len, "BMISS ");
849 if (reg & ATH9K_INT_CST)
850 len += snprintf(buf + len, size - len, "CST ");
851 if (reg & ATH9K_INT_RX)
852 len += snprintf(buf + len, size - len, "RX ");
853 if (reg & ATH9K_INT_RXHP)
854 len += snprintf(buf + len, size - len, "RXHP ");
855 if (reg & ATH9K_INT_RXLP)
856 len += snprintf(buf + len, size - len, "RXLP ");
857 if (reg & ATH9K_INT_BB_WATCHDOG)
858 len += snprintf(buf + len, size - len, "BB_WATCHDOG ");
859 /* there are other IRQs if one wanted to add them. */
860 len += snprintf(buf + len, size - len, ")\n");
861
862 len += snprintf(buf + len, size - len,
863 "VIF Counts: AP: %i STA: %i MESH: %i WDS: %i"
864 " ADHOC: %i OTHER: %i nvifs: %hi beacon-vifs: %hi\n",
865 iter_data.naps, iter_data.nstations, iter_data.nmeshes,
866 iter_data.nwds, iter_data.nadhocs, iter_data.nothers,
867 sc->nvifs, sc->nbcnvifs);
868
869 len += snprintf(buf + len, size - len,
870 "Calculated-BSSID-Mask: %pM\n",
871 iter_data.mask);
872
873 if (len > size)
874 len = size;
875
876 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
877 kfree(buf);
878
879 return retval;
880}
881
Felix Fietkau066dae92010-11-07 14:59:39 +0100882void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
883 struct ath_tx_status *ts)
Sujithfec247c2009-07-27 12:08:16 +0530884{
Felix Fietkau066dae92010-11-07 14:59:39 +0100885 int qnum = skb_get_queue_mapping(bf->bf_mpdu);
886
887 TX_STAT_INC(qnum, tx_pkts_all);
888 sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len;
Ben Greear99c15bf2010-10-01 12:26:30 -0700889
Sujithfec247c2009-07-27 12:08:16 +0530890 if (bf_isampdu(bf)) {
891 if (bf_isxretried(bf))
Felix Fietkau066dae92010-11-07 14:59:39 +0100892 TX_STAT_INC(qnum, a_xretries);
Sujithfec247c2009-07-27 12:08:16 +0530893 else
Felix Fietkau066dae92010-11-07 14:59:39 +0100894 TX_STAT_INC(qnum, a_completed);
Sujithfec247c2009-07-27 12:08:16 +0530895 } else {
Felix Fietkau066dae92010-11-07 14:59:39 +0100896 TX_STAT_INC(qnum, completed);
Sujithfec247c2009-07-27 12:08:16 +0530897 }
898
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700899 if (ts->ts_status & ATH9K_TXERR_FIFO)
Felix Fietkau066dae92010-11-07 14:59:39 +0100900 TX_STAT_INC(qnum, fifo_underrun);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700901 if (ts->ts_status & ATH9K_TXERR_XTXOP)
Felix Fietkau066dae92010-11-07 14:59:39 +0100902 TX_STAT_INC(qnum, xtxop);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700903 if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED)
Felix Fietkau066dae92010-11-07 14:59:39 +0100904 TX_STAT_INC(qnum, timer_exp);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700905 if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR)
Felix Fietkau066dae92010-11-07 14:59:39 +0100906 TX_STAT_INC(qnum, desc_cfg_err);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700907 if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN)
Felix Fietkau066dae92010-11-07 14:59:39 +0100908 TX_STAT_INC(qnum, data_underrun);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700909 if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
Felix Fietkau066dae92010-11-07 14:59:39 +0100910 TX_STAT_INC(qnum, delim_underrun);
Sujithfec247c2009-07-27 12:08:16 +0530911}
912
913static const struct file_operations fops_xmit = {
914 .read = read_file_xmit,
915 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200916 .owner = THIS_MODULE,
917 .llseek = default_llseek,
Sujithfec247c2009-07-27 12:08:16 +0530918};
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200919
Ben Greear7f010c92011-01-09 23:11:49 -0800920static const struct file_operations fops_stations = {
921 .read = read_file_stations,
922 .open = ath9k_debugfs_open,
923 .owner = THIS_MODULE,
924 .llseek = default_llseek,
925};
926
Ben Greear55f6d0f2011-01-17 11:54:50 -0800927static const struct file_operations fops_misc = {
928 .read = read_file_misc,
929 .open = ath9k_debugfs_open,
930 .owner = THIS_MODULE,
931 .llseek = default_llseek,
932};
933
Sujith1395d3f2010-01-08 10:36:11 +0530934static ssize_t read_file_recv(struct file *file, char __user *user_buf,
935 size_t count, loff_t *ppos)
936{
937#define PHY_ERR(s, p) \
938 len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \
939 sc->debug.stats.rxstats.phy_err_stats[p]);
940
941 struct ath_softc *sc = file->private_data;
942 char *buf;
943 unsigned int len = 0, size = 1152;
944 ssize_t retval = 0;
945
946 buf = kzalloc(size, GFP_KERNEL);
947 if (buf == NULL)
Dan Carpenter04236062010-05-14 15:25:39 +0200948 return -ENOMEM;
Sujith1395d3f2010-01-08 10:36:11 +0530949
950 len += snprintf(buf + len, size - len,
951 "%18s : %10u\n", "CRC ERR",
952 sc->debug.stats.rxstats.crc_err);
953 len += snprintf(buf + len, size - len,
954 "%18s : %10u\n", "DECRYPT CRC ERR",
955 sc->debug.stats.rxstats.decrypt_crc_err);
956 len += snprintf(buf + len, size - len,
957 "%18s : %10u\n", "PHY ERR",
958 sc->debug.stats.rxstats.phy_err);
959 len += snprintf(buf + len, size - len,
960 "%18s : %10u\n", "MIC ERR",
961 sc->debug.stats.rxstats.mic_err);
962 len += snprintf(buf + len, size - len,
963 "%18s : %10u\n", "PRE-DELIM CRC ERR",
964 sc->debug.stats.rxstats.pre_delim_crc_err);
965 len += snprintf(buf + len, size - len,
966 "%18s : %10u\n", "POST-DELIM CRC ERR",
967 sc->debug.stats.rxstats.post_delim_crc_err);
968 len += snprintf(buf + len, size - len,
969 "%18s : %10u\n", "DECRYPT BUSY ERR",
970 sc->debug.stats.rxstats.decrypt_busy_err);
971
972 PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN);
973 PHY_ERR("TIMING", ATH9K_PHYERR_TIMING);
974 PHY_ERR("PARITY", ATH9K_PHYERR_PARITY);
975 PHY_ERR("RATE", ATH9K_PHYERR_RATE);
976 PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH);
977 PHY_ERR("RADAR", ATH9K_PHYERR_RADAR);
978 PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE);
979 PHY_ERR("TOR", ATH9K_PHYERR_TOR);
980 PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING);
981 PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY);
982 PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL);
983 PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL);
984 PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP);
985 PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE);
986 PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART);
987 PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT);
988 PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING);
989 PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC);
990 PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL);
991 PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE);
992 PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART);
993 PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL);
994 PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP);
995 PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR);
996 PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
997 PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL);
998
Ben Greear99c15bf2010-10-01 12:26:30 -0700999 len += snprintf(buf + len, size - len,
1000 "%18s : %10u\n", "RX-Pkts-All",
1001 sc->debug.stats.rxstats.rx_pkts_all);
1002 len += snprintf(buf + len, size - len,
1003 "%18s : %10u\n", "RX-Bytes-All",
1004 sc->debug.stats.rxstats.rx_bytes_all);
1005
Dan Carpenter2b87f3a2010-05-14 15:24:37 +02001006 if (len > size)
1007 len = size;
1008
Sujith1395d3f2010-01-08 10:36:11 +05301009 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1010 kfree(buf);
1011
1012 return retval;
1013
1014#undef PHY_ERR
1015}
1016
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001017void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
Sujith1395d3f2010-01-08 10:36:11 +05301018{
1019#define RX_STAT_INC(c) sc->debug.stats.rxstats.c++
1020#define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
1021
Sujith1395d3f2010-01-08 10:36:11 +05301022 u32 phyerr;
1023
Ben Greear99c15bf2010-10-01 12:26:30 -07001024 RX_STAT_INC(rx_pkts_all);
1025 sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen;
1026
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001027 if (rs->rs_status & ATH9K_RXERR_CRC)
Sujith1395d3f2010-01-08 10:36:11 +05301028 RX_STAT_INC(crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001029 if (rs->rs_status & ATH9K_RXERR_DECRYPT)
Sujith1395d3f2010-01-08 10:36:11 +05301030 RX_STAT_INC(decrypt_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001031 if (rs->rs_status & ATH9K_RXERR_MIC)
Sujith1395d3f2010-01-08 10:36:11 +05301032 RX_STAT_INC(mic_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001033 if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE)
Sujith1395d3f2010-01-08 10:36:11 +05301034 RX_STAT_INC(pre_delim_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001035 if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST)
Sujith1395d3f2010-01-08 10:36:11 +05301036 RX_STAT_INC(post_delim_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001037 if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY)
Sujith1395d3f2010-01-08 10:36:11 +05301038 RX_STAT_INC(decrypt_busy_err);
1039
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001040 if (rs->rs_status & ATH9K_RXERR_PHY) {
Sujith1395d3f2010-01-08 10:36:11 +05301041 RX_STAT_INC(phy_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001042 phyerr = rs->rs_phyerr & 0x24;
Sujith1395d3f2010-01-08 10:36:11 +05301043 RX_PHY_ERR_INC(phyerr);
1044 }
1045
1046#undef RX_STAT_INC
1047#undef RX_PHY_ERR_INC
1048}
1049
1050static const struct file_operations fops_recv = {
1051 .read = read_file_recv,
1052 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001053 .owner = THIS_MODULE,
1054 .llseek = default_llseek,
Sujith1395d3f2010-01-08 10:36:11 +05301055};
1056
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001057static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
1058 size_t count, loff_t *ppos)
1059{
1060 struct ath_softc *sc = file->private_data;
1061 char buf[32];
1062 unsigned int len;
1063
Dan Carpenter2b87f3a2010-05-14 15:24:37 +02001064 len = sprintf(buf, "0x%08x\n", sc->debug.regidx);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001065 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1066}
1067
1068static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
1069 size_t count, loff_t *ppos)
1070{
1071 struct ath_softc *sc = file->private_data;
1072 unsigned long regidx;
1073 char buf[32];
1074 ssize_t len;
1075
1076 len = min(count, sizeof(buf) - 1);
1077 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +02001078 return -EFAULT;
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001079
1080 buf[len] = '\0';
1081 if (strict_strtoul(buf, 0, &regidx))
1082 return -EINVAL;
1083
1084 sc->debug.regidx = regidx;
1085 return count;
1086}
1087
1088static const struct file_operations fops_regidx = {
1089 .read = read_file_regidx,
1090 .write = write_file_regidx,
1091 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001092 .owner = THIS_MODULE,
1093 .llseek = default_llseek,
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001094};
1095
1096static ssize_t read_file_regval(struct file *file, char __user *user_buf,
1097 size_t count, loff_t *ppos)
1098{
1099 struct ath_softc *sc = file->private_data;
1100 struct ath_hw *ah = sc->sc_ah;
1101 char buf[32];
1102 unsigned int len;
1103 u32 regval;
1104
1105 regval = REG_READ_D(ah, sc->debug.regidx);
Dan Carpenter2b87f3a2010-05-14 15:24:37 +02001106 len = sprintf(buf, "0x%08x\n", regval);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001107 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1108}
1109
1110static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
1111 size_t count, loff_t *ppos)
1112{
1113 struct ath_softc *sc = file->private_data;
1114 struct ath_hw *ah = sc->sc_ah;
1115 unsigned long regval;
1116 char buf[32];
1117 ssize_t len;
1118
1119 len = min(count, sizeof(buf) - 1);
1120 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +02001121 return -EFAULT;
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001122
1123 buf[len] = '\0';
1124 if (strict_strtoul(buf, 0, &regval))
1125 return -EINVAL;
1126
1127 REG_WRITE_D(ah, sc->debug.regidx, regval);
1128 return count;
1129}
1130
1131static const struct file_operations fops_regval = {
1132 .read = read_file_regval,
1133 .write = write_file_regval,
1134 .open = ath9k_debugfs_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001135 .owner = THIS_MODULE,
1136 .llseek = default_llseek,
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001137};
1138
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -07001139int ath9k_init_debug(struct ath_hw *ah)
Sujith88b126a2008-11-28 22:19:02 +05301140{
Luis R. Rodriguezbc974f42009-09-28 02:54:40 -04001141 struct ath_common *common = ath9k_hw_common(ah);
1142 struct ath_softc *sc = (struct ath_softc *) common->priv;
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -07001143
Ben Greeareb272442010-11-29 14:13:22 -08001144 sc->debug.debugfs_phy = debugfs_create_dir("ath9k",
1145 sc->hw->wiphy->debugfsdir);
Sujith17d79042009-02-09 13:27:03 +05301146 if (!sc->debug.debugfs_phy)
Felix Fietkauc8a72c02010-05-11 17:23:00 +02001147 return -ENOMEM;
Sujith826d2682008-11-28 22:20:23 +05301148
Felix Fietkaua830df02009-11-23 22:33:27 +01001149#ifdef CONFIG_ATH_DEBUG
Felix Fietkauc8a72c02010-05-11 17:23:00 +02001150 if (!debugfs_create_file("debug", S_IRUSR | S_IWUSR,
1151 sc->debug.debugfs_phy, sc, &fops_debug))
Jeff Hansen24939282009-05-27 12:48:29 +00001152 goto err;
Felix Fietkaua830df02009-11-23 22:33:27 +01001153#endif
Jeff Hansen24939282009-05-27 12:48:29 +00001154
Felix Fietkauc8a72c02010-05-11 17:23:00 +02001155 if (!debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy,
1156 sc, &fops_dma))
Sujith2a163c62008-11-28 22:21:08 +05301157 goto err;
1158
Felix Fietkauc8a72c02010-05-11 17:23:00 +02001159 if (!debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy,
1160 sc, &fops_interrupt))
Sujith817e11d2008-12-07 21:42:44 +05301161 goto err;
1162
Felix Fietkauc8a72c02010-05-11 17:23:00 +02001163 if (!debugfs_create_file("wiphy", S_IRUSR | S_IWUSR,
1164 sc->debug.debugfs_phy, sc, &fops_wiphy))
Jouni Malinen39d89cd2009-03-03 19:23:40 +02001165 goto err;
1166
Felix Fietkauc8a72c02010-05-11 17:23:00 +02001167 if (!debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy,
1168 sc, &fops_xmit))
Sujithfec247c2009-07-27 12:08:16 +05301169 goto err;
1170
Ben Greear7f010c92011-01-09 23:11:49 -08001171 if (!debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy,
1172 sc, &fops_stations))
1173 goto err;
1174
Ben Greear55f6d0f2011-01-17 11:54:50 -08001175 if (!debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy,
1176 sc, &fops_misc))
1177 goto err;
1178
Felix Fietkauc8a72c02010-05-11 17:23:00 +02001179 if (!debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy,
1180 sc, &fops_recv))
Sujith1395d3f2010-01-08 10:36:11 +05301181 goto err;
1182
Felix Fietkau15340692010-05-11 17:23:01 +02001183 if (!debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR,
1184 sc->debug.debugfs_phy, sc, &fops_rx_chainmask))
1185 goto err;
1186
1187 if (!debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR,
1188 sc->debug.debugfs_phy, sc, &fops_tx_chainmask))
1189 goto err;
1190
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001191 if (!debugfs_create_file("regidx", S_IRUSR | S_IWUSR,
1192 sc->debug.debugfs_phy, sc, &fops_regidx))
1193 goto err;
1194
1195 if (!debugfs_create_file("regval", S_IRUSR | S_IWUSR,
1196 sc->debug.debugfs_phy, sc, &fops_regval))
1197 goto err;
1198
Felix Fietkau41f3e542010-06-12 00:33:56 -04001199 if (!debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR,
1200 sc->debug.debugfs_phy, &ah->config.cwm_ignore_extcca))
1201 goto err;
1202
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001203 sc->debug.regidx = 0;
Sujith826d2682008-11-28 22:20:23 +05301204 return 0;
1205err:
Felix Fietkauc8a72c02010-05-11 17:23:00 +02001206 debugfs_remove_recursive(sc->debug.debugfs_phy);
Ben Greeareb272442010-11-29 14:13:22 -08001207 sc->debug.debugfs_phy = NULL;
1208 return -ENOMEM;
Sujith88b126a2008-11-28 22:19:02 +05301209}