blob: ab59e2ec18c696d81c809ccebb6de5eada70c577 [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
Gabor Juhos52103112009-03-06 09:57:39 +010017#include <asm/unaligned.h>
18
Sujith394cf0a2009-02-09 13:26:54 +053019#include "ath9k.h"
Sujith88b126a2008-11-28 22:19:02 +053020
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -040021#define REG_WRITE_D(_ah, _reg, _val) \
22 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
23#define REG_READ_D(_ah, _reg) \
24 ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
25
Gabor Juhos19d8bc22009-03-05 16:55:18 +010026static struct dentry *ath9k_debugfs_root;
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
Felix Fietkaua830df02009-11-23 22:33:27 +010034#ifdef CONFIG_ATH_DEBUG
35
Jeff Hansen24939282009-05-27 12:48:29 +000036static ssize_t read_file_debug(struct file *file, char __user *user_buf,
37 size_t count, loff_t *ppos)
38{
39 struct ath_softc *sc = file->private_data;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070040 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Jeff Hansen24939282009-05-27 12:48:29 +000041 char buf[32];
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053042 unsigned int len;
43
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070044 len = snprintf(buf, sizeof(buf), "0x%08x\n", common->debug_mask);
Jeff Hansen24939282009-05-27 12:48:29 +000045 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
46}
47
48static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
49 size_t count, loff_t *ppos)
50{
51 struct ath_softc *sc = file->private_data;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070052 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Jeff Hansen24939282009-05-27 12:48:29 +000053 unsigned long mask;
54 char buf[32];
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053055 ssize_t len;
56
57 len = min(count, sizeof(buf) - 1);
58 if (copy_from_user(buf, user_buf, len))
59 return -EINVAL;
60
61 buf[len] = '\0';
62 if (strict_strtoul(buf, 0, &mask))
63 return -EINVAL;
64
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070065 common->debug_mask = mask;
Jeff Hansen24939282009-05-27 12:48:29 +000066 return count;
67}
68
69static const struct file_operations fops_debug = {
70 .read = read_file_debug,
71 .write = write_file_debug,
72 .open = ath9k_debugfs_open,
73 .owner = THIS_MODULE
74};
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
Sujith2a163c62008-11-28 22:21:08 +053080static ssize_t read_file_dma(struct file *file, char __user *user_buf,
81 size_t count, loff_t *ppos)
82{
83 struct ath_softc *sc = file->private_data;
Sujithcbe61d82009-02-09 13:27:12 +053084 struct ath_hw *ah = sc->sc_ah;
Pavel Roskin991a0982010-01-29 17:22:26 -050085 char *buf;
86 int retval;
Sujith2a163c62008-11-28 22:21:08 +053087 unsigned int len = 0;
88 u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
89 int i, qcuOffset = 0, dcuOffset = 0;
90 u32 *qcuBase = &val[0], *dcuBase = &val[4];
91
Pavel Roskin991a0982010-01-29 17:22:26 -050092 buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL);
93 if (!buf)
94 return 0;
95
Sujith7cf4a2e2009-08-26 11:11:57 +053096 ath9k_ps_wakeup(sc);
97
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -040098 REG_WRITE_D(ah, AR_MACMISC,
Sujith2a163c62008-11-28 22:21:08 +053099 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
100 (AR_MACMISC_MISC_OBS_BUS_1 <<
101 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
102
Pavel Roskin991a0982010-01-29 17:22:26 -0500103 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530104 "Raw DMA Debug values:\n");
105
106 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
107 if (i % 4 == 0)
Pavel Roskin991a0982010-01-29 17:22:26 -0500108 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
Sujith2a163c62008-11-28 22:21:08 +0530109
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400110 val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
Pavel Roskin991a0982010-01-29 17:22:26 -0500111 len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ",
Sujith2a163c62008-11-28 22:21:08 +0530112 i, val[i]);
113 }
114
Pavel Roskin991a0982010-01-29 17:22:26 -0500115 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n");
116 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530117 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
118
119 for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
120 if (i == 8) {
121 qcuOffset = 0;
122 qcuBase++;
123 }
124
125 if (i == 6) {
126 dcuOffset = 0;
127 dcuBase++;
128 }
129
Pavel Roskin991a0982010-01-29 17:22:26 -0500130 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530131 "%2d %2x %1x %2x %2x\n",
132 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
133 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
134 val[2] & (0x7 << (i * 3)) >> (i * 3),
135 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
136 }
137
Pavel Roskin991a0982010-01-29 17:22:26 -0500138 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
Sujith2a163c62008-11-28 22:21:08 +0530139
Pavel Roskin991a0982010-01-29 17:22:26 -0500140 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530141 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
142 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
Pavel Roskin991a0982010-01-29 17:22:26 -0500143 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530144 "qcu_complete state: %2x dcu_complete state: %2x\n",
145 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
Pavel Roskin991a0982010-01-29 17:22:26 -0500146 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530147 "dcu_arb state: %2x dcu_fp state: %2x\n",
148 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
Pavel Roskin991a0982010-01-29 17:22:26 -0500149 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530150 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
151 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
Pavel Roskin991a0982010-01-29 17:22:26 -0500152 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530153 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
154 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
Pavel Roskin991a0982010-01-29 17:22:26 -0500155 len += snprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530156 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
157 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
158
Frans Pop60ece402010-03-24 19:46:30 +0100159 len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n",
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400160 REG_READ_D(ah, AR_OBS_BUS_1));
Pavel Roskin991a0982010-01-29 17:22:26 -0500161 len += snprintf(buf + len, DMA_BUF_LEN - len,
Frans Pop60ece402010-03-24 19:46:30 +0100162 "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR));
Sujith2a163c62008-11-28 22:21:08 +0530163
Sujith7cf4a2e2009-08-26 11:11:57 +0530164 ath9k_ps_restore(sc);
165
Pavel Roskin991a0982010-01-29 17:22:26 -0500166 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
167 kfree(buf);
168 return retval;
Sujith2a163c62008-11-28 22:21:08 +0530169}
170
171static const struct file_operations fops_dma = {
172 .read = read_file_dma,
173 .open = ath9k_debugfs_open,
174 .owner = THIS_MODULE
175};
176
Sujith817e11d2008-12-07 21:42:44 +0530177
178void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status)
179{
180 if (status)
Sujith17d79042009-02-09 13:27:03 +0530181 sc->debug.stats.istats.total++;
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400182 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
183 if (status & ATH9K_INT_RXLP)
184 sc->debug.stats.istats.rxlp++;
185 if (status & ATH9K_INT_RXHP)
186 sc->debug.stats.istats.rxhp++;
187 } else {
188 if (status & ATH9K_INT_RX)
189 sc->debug.stats.istats.rxok++;
190 }
Sujith817e11d2008-12-07 21:42:44 +0530191 if (status & ATH9K_INT_RXEOL)
Sujith17d79042009-02-09 13:27:03 +0530192 sc->debug.stats.istats.rxeol++;
Sujith817e11d2008-12-07 21:42:44 +0530193 if (status & ATH9K_INT_RXORN)
Sujith17d79042009-02-09 13:27:03 +0530194 sc->debug.stats.istats.rxorn++;
Sujith817e11d2008-12-07 21:42:44 +0530195 if (status & ATH9K_INT_TX)
Sujith17d79042009-02-09 13:27:03 +0530196 sc->debug.stats.istats.txok++;
Sujith817e11d2008-12-07 21:42:44 +0530197 if (status & ATH9K_INT_TXURN)
Sujith17d79042009-02-09 13:27:03 +0530198 sc->debug.stats.istats.txurn++;
Sujith817e11d2008-12-07 21:42:44 +0530199 if (status & ATH9K_INT_MIB)
Sujith17d79042009-02-09 13:27:03 +0530200 sc->debug.stats.istats.mib++;
Sujith817e11d2008-12-07 21:42:44 +0530201 if (status & ATH9K_INT_RXPHY)
Sujith17d79042009-02-09 13:27:03 +0530202 sc->debug.stats.istats.rxphyerr++;
Sujith817e11d2008-12-07 21:42:44 +0530203 if (status & ATH9K_INT_RXKCM)
Sujith17d79042009-02-09 13:27:03 +0530204 sc->debug.stats.istats.rx_keycache_miss++;
Sujith817e11d2008-12-07 21:42:44 +0530205 if (status & ATH9K_INT_SWBA)
Sujith17d79042009-02-09 13:27:03 +0530206 sc->debug.stats.istats.swba++;
Sujith817e11d2008-12-07 21:42:44 +0530207 if (status & ATH9K_INT_BMISS)
Sujith17d79042009-02-09 13:27:03 +0530208 sc->debug.stats.istats.bmiss++;
Sujith817e11d2008-12-07 21:42:44 +0530209 if (status & ATH9K_INT_BNR)
Sujith17d79042009-02-09 13:27:03 +0530210 sc->debug.stats.istats.bnr++;
Sujith817e11d2008-12-07 21:42:44 +0530211 if (status & ATH9K_INT_CST)
Sujith17d79042009-02-09 13:27:03 +0530212 sc->debug.stats.istats.cst++;
Sujith817e11d2008-12-07 21:42:44 +0530213 if (status & ATH9K_INT_GTT)
Sujith17d79042009-02-09 13:27:03 +0530214 sc->debug.stats.istats.gtt++;
Sujith817e11d2008-12-07 21:42:44 +0530215 if (status & ATH9K_INT_TIM)
Sujith17d79042009-02-09 13:27:03 +0530216 sc->debug.stats.istats.tim++;
Sujith817e11d2008-12-07 21:42:44 +0530217 if (status & ATH9K_INT_CABEND)
Sujith17d79042009-02-09 13:27:03 +0530218 sc->debug.stats.istats.cabend++;
Sujith817e11d2008-12-07 21:42:44 +0530219 if (status & ATH9K_INT_DTIMSYNC)
Sujith17d79042009-02-09 13:27:03 +0530220 sc->debug.stats.istats.dtimsync++;
Sujith817e11d2008-12-07 21:42:44 +0530221 if (status & ATH9K_INT_DTIM)
Sujith17d79042009-02-09 13:27:03 +0530222 sc->debug.stats.istats.dtim++;
Sujith817e11d2008-12-07 21:42:44 +0530223}
224
225static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
226 size_t count, loff_t *ppos)
227{
228 struct ath_softc *sc = file->private_data;
229 char buf[512];
230 unsigned int len = 0;
231
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400232 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
233 len += snprintf(buf + len, sizeof(buf) - len,
234 "%8s: %10u\n", "RXLP", sc->debug.stats.istats.rxlp);
235 len += snprintf(buf + len, sizeof(buf) - len,
236 "%8s: %10u\n", "RXHP", sc->debug.stats.istats.rxhp);
237 } else {
238 len += snprintf(buf + len, sizeof(buf) - len,
239 "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok);
240 }
Sujith817e11d2008-12-07 21:42:44 +0530241 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530242 "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol);
Sujith817e11d2008-12-07 21:42:44 +0530243 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530244 "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn);
Sujith817e11d2008-12-07 21:42:44 +0530245 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530246 "%8s: %10u\n", "TX", sc->debug.stats.istats.txok);
Sujith817e11d2008-12-07 21:42:44 +0530247 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530248 "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn);
Sujith817e11d2008-12-07 21:42:44 +0530249 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530250 "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib);
Sujith817e11d2008-12-07 21:42:44 +0530251 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530252 "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr);
Sujith817e11d2008-12-07 21:42:44 +0530253 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530254 "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss);
Sujith817e11d2008-12-07 21:42:44 +0530255 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530256 "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba);
Sujith817e11d2008-12-07 21:42:44 +0530257 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530258 "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss);
Sujith817e11d2008-12-07 21:42:44 +0530259 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530260 "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr);
Sujith817e11d2008-12-07 21:42:44 +0530261 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530262 "%8s: %10u\n", "CST", sc->debug.stats.istats.cst);
Sujith817e11d2008-12-07 21:42:44 +0530263 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530264 "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt);
Sujith817e11d2008-12-07 21:42:44 +0530265 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530266 "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim);
Sujith817e11d2008-12-07 21:42:44 +0530267 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530268 "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend);
Sujith817e11d2008-12-07 21:42:44 +0530269 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530270 "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync);
Sujith817e11d2008-12-07 21:42:44 +0530271 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530272 "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim);
Sujith817e11d2008-12-07 21:42:44 +0530273 len += snprintf(buf + len, sizeof(buf) - len,
Sujith17d79042009-02-09 13:27:03 +0530274 "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total);
Sujith817e11d2008-12-07 21:42:44 +0530275
276 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
277}
278
279static const struct file_operations fops_interrupt = {
280 .read = read_file_interrupt,
281 .open = ath9k_debugfs_open,
282 .owner = THIS_MODULE
283};
284
Felix Fietkau545750d2009-11-23 22:21:01 +0100285void ath_debug_stat_rc(struct ath_softc *sc, int final_rate)
Sujith7a7dec62009-01-30 14:32:09 +0530286{
Jeff Hansenbedf0872009-05-27 12:48:28 +0000287 struct ath_rc_stats *stats;
Sujith7a7dec62009-01-30 14:32:09 +0530288
Felix Fietkau545750d2009-11-23 22:21:01 +0100289 stats = &sc->debug.stats.rcstats[final_rate];
Jeff Hansenbedf0872009-05-27 12:48:28 +0000290 stats->success++;
Sujith7a7dec62009-01-30 14:32:09 +0530291}
292
Sujith029bc432009-02-04 08:10:26 +0530293void ath_debug_stat_retries(struct ath_softc *sc, int rix,
Sujith9e712792009-02-20 15:13:20 +0530294 int xretries, int retries, u8 per)
Sujith029bc432009-02-04 08:10:26 +0530295{
Jeff Hansenbedf0872009-05-27 12:48:28 +0000296 struct ath_rc_stats *stats = &sc->debug.stats.rcstats[rix];
Sujith029bc432009-02-04 08:10:26 +0530297
Jeff Hansenbedf0872009-05-27 12:48:28 +0000298 stats->xretries += xretries;
299 stats->retries += retries;
300 stats->per = per;
Sujith7a7dec62009-01-30 14:32:09 +0530301}
302
303static ssize_t read_file_rcstat(struct file *file, char __user *user_buf,
304 size_t count, loff_t *ppos)
305{
306 struct ath_softc *sc = file->private_data;
Jeff Hansenbedf0872009-05-27 12:48:28 +0000307 char *buf;
308 unsigned int len = 0, max;
309 int i = 0;
310 ssize_t retval;
Sujith7a7dec62009-01-30 14:32:09 +0530311
Sujith62b4fb62009-03-09 09:32:01 +0530312 if (sc->cur_rate_table == NULL)
313 return 0;
314
Luis R. Rodriguezc755ad32009-12-07 12:38:41 -0500315 max = 80 + sc->cur_rate_table->rate_cnt * 1024;
Jeff Hansenbedf0872009-05-27 12:48:28 +0000316 buf = kmalloc(max + 1, GFP_KERNEL);
317 if (buf == NULL)
318 return 0;
319 buf[max] = 0;
320
Luis R. Rodriguezc755ad32009-12-07 12:38:41 -0500321 len += sprintf(buf, "%6s %6s %6s "
322 "%10s %10s %10s %10s\n",
323 "HT", "MCS", "Rate",
324 "Success", "Retries", "XRetries", "PER");
Jeff Hansenbedf0872009-05-27 12:48:28 +0000325
326 for (i = 0; i < sc->cur_rate_table->rate_cnt; i++) {
327 u32 ratekbps = sc->cur_rate_table->info[i].ratekbps;
328 struct ath_rc_stats *stats = &sc->debug.stats.rcstats[i];
Luis R. Rodriguezc755ad32009-12-07 12:38:41 -0500329 char mcs[5];
330 char htmode[5];
331 int used_mcs = 0, used_htmode = 0;
332
333 if (WLAN_RC_PHY_HT(sc->cur_rate_table->info[i].phy)) {
334 used_mcs = snprintf(mcs, 5, "%d",
335 sc->cur_rate_table->info[i].ratecode);
336
337 if (WLAN_RC_PHY_40(sc->cur_rate_table->info[i].phy))
338 used_htmode = snprintf(htmode, 5, "HT40");
339 else if (WLAN_RC_PHY_20(sc->cur_rate_table->info[i].phy))
340 used_htmode = snprintf(htmode, 5, "HT20");
341 else
342 used_htmode = snprintf(htmode, 5, "????");
343 }
344
345 mcs[used_mcs] = '\0';
346 htmode[used_htmode] = '\0';
Jeff Hansenbedf0872009-05-27 12:48:28 +0000347
348 len += snprintf(buf + len, max - len,
Luis R. Rodriguezc755ad32009-12-07 12:38:41 -0500349 "%6s %6s %3u.%d: "
350 "%10u %10u %10u %10u\n",
351 htmode,
352 mcs,
353 ratekbps / 1000,
354 (ratekbps % 1000) / 100,
355 stats->success,
356 stats->retries,
357 stats->xretries,
Jeff Hansenbedf0872009-05-27 12:48:28 +0000358 stats->per);
359 }
360
361 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
362 kfree(buf);
363 return retval;
Sujith7a7dec62009-01-30 14:32:09 +0530364}
365
366static const struct file_operations fops_rcstat = {
367 .read = read_file_rcstat,
368 .open = ath9k_debugfs_open,
369 .owner = THIS_MODULE
370};
Alina Friedrichsen27abe062009-01-23 05:44:21 +0100371
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200372static const char * ath_wiphy_state_str(enum ath_wiphy_state state)
373{
374 switch (state) {
375 case ATH_WIPHY_INACTIVE:
376 return "INACTIVE";
377 case ATH_WIPHY_ACTIVE:
378 return "ACTIVE";
379 case ATH_WIPHY_PAUSING:
380 return "PAUSING";
381 case ATH_WIPHY_PAUSED:
382 return "PAUSED";
383 case ATH_WIPHY_SCAN:
384 return "SCAN";
385 }
386 return "?";
387}
388
389static ssize_t read_file_wiphy(struct file *file, char __user *user_buf,
390 size_t count, loff_t *ppos)
391{
392 struct ath_softc *sc = file->private_data;
393 char buf[512];
394 unsigned int len = 0;
395 int i;
396 u8 addr[ETH_ALEN];
397
398 len += snprintf(buf + len, sizeof(buf) - len,
399 "primary: %s (%s chan=%d ht=%d)\n",
400 wiphy_name(sc->pri_wiphy->hw->wiphy),
401 ath_wiphy_state_str(sc->pri_wiphy->state),
402 sc->pri_wiphy->chan_idx, sc->pri_wiphy->chan_is_ht);
403 for (i = 0; i < sc->num_sec_wiphy; i++) {
404 struct ath_wiphy *aphy = sc->sec_wiphy[i];
405 if (aphy == NULL)
406 continue;
407 len += snprintf(buf + len, sizeof(buf) - len,
408 "secondary: %s (%s chan=%d ht=%d)\n",
409 wiphy_name(aphy->hw->wiphy),
410 ath_wiphy_state_str(aphy->state),
411 aphy->chan_idx, aphy->chan_is_ht);
412 }
413
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400414 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr);
415 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4);
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200416 len += snprintf(buf + len, sizeof(buf) - len,
417 "addr: %pM\n", addr);
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400418 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr);
419 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4);
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200420 len += snprintf(buf + len, sizeof(buf) - len,
421 "addrmask: %pM\n", addr);
422
423 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
424}
425
426static struct ath_wiphy * get_wiphy(struct ath_softc *sc, const char *name)
427{
428 int i;
429 if (strcmp(name, wiphy_name(sc->pri_wiphy->hw->wiphy)) == 0)
430 return sc->pri_wiphy;
431 for (i = 0; i < sc->num_sec_wiphy; i++) {
432 struct ath_wiphy *aphy = sc->sec_wiphy[i];
433 if (aphy && strcmp(name, wiphy_name(aphy->hw->wiphy)) == 0)
434 return aphy;
435 }
436 return NULL;
437}
438
439static int del_wiphy(struct ath_softc *sc, const char *name)
440{
441 struct ath_wiphy *aphy = get_wiphy(sc, name);
442 if (!aphy)
443 return -ENOENT;
444 return ath9k_wiphy_del(aphy);
445}
446
447static int pause_wiphy(struct ath_softc *sc, const char *name)
448{
449 struct ath_wiphy *aphy = get_wiphy(sc, name);
450 if (!aphy)
451 return -ENOENT;
452 return ath9k_wiphy_pause(aphy);
453}
454
455static int unpause_wiphy(struct ath_softc *sc, const char *name)
456{
457 struct ath_wiphy *aphy = get_wiphy(sc, name);
458 if (!aphy)
459 return -ENOENT;
460 return ath9k_wiphy_unpause(aphy);
461}
462
463static int select_wiphy(struct ath_softc *sc, const char *name)
464{
465 struct ath_wiphy *aphy = get_wiphy(sc, name);
466 if (!aphy)
467 return -ENOENT;
468 return ath9k_wiphy_select(aphy);
469}
470
471static int schedule_wiphy(struct ath_softc *sc, const char *msec)
472{
473 ath9k_wiphy_set_scheduler(sc, simple_strtoul(msec, NULL, 0));
474 return 0;
475}
476
477static ssize_t write_file_wiphy(struct file *file, const char __user *user_buf,
478 size_t count, loff_t *ppos)
479{
480 struct ath_softc *sc = file->private_data;
481 char buf[50];
482 size_t len;
483
484 len = min(count, sizeof(buf) - 1);
485 if (copy_from_user(buf, user_buf, len))
486 return -EFAULT;
487 buf[len] = '\0';
488 if (len > 0 && buf[len - 1] == '\n')
489 buf[len - 1] = '\0';
490
491 if (strncmp(buf, "add", 3) == 0) {
492 int res = ath9k_wiphy_add(sc);
493 if (res < 0)
494 return res;
495 } else if (strncmp(buf, "del=", 4) == 0) {
496 int res = del_wiphy(sc, buf + 4);
497 if (res < 0)
498 return res;
499 } else if (strncmp(buf, "pause=", 6) == 0) {
500 int res = pause_wiphy(sc, buf + 6);
501 if (res < 0)
502 return res;
503 } else if (strncmp(buf, "unpause=", 8) == 0) {
504 int res = unpause_wiphy(sc, buf + 8);
505 if (res < 0)
506 return res;
507 } else if (strncmp(buf, "select=", 7) == 0) {
508 int res = select_wiphy(sc, buf + 7);
509 if (res < 0)
510 return res;
511 } else if (strncmp(buf, "schedule=", 9) == 0) {
512 int res = schedule_wiphy(sc, buf + 9);
513 if (res < 0)
514 return res;
515 } else
516 return -EOPNOTSUPP;
517
518 return count;
519}
520
521static const struct file_operations fops_wiphy = {
522 .read = read_file_wiphy,
523 .write = write_file_wiphy,
524 .open = ath9k_debugfs_open,
525 .owner = THIS_MODULE
526};
527
Sujithfec247c2009-07-27 12:08:16 +0530528#define PR(str, elem) \
529 do { \
530 len += snprintf(buf + len, size - len, \
531 "%s%13u%11u%10u%10u\n", str, \
532 sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_BE]].elem, \
533 sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_BK]].elem, \
534 sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_VI]].elem, \
535 sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_VO]].elem); \
536} while(0)
537
538static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
539 size_t count, loff_t *ppos)
540{
541 struct ath_softc *sc = file->private_data;
542 char *buf;
543 unsigned int len = 0, size = 2048;
544 ssize_t retval = 0;
545
546 buf = kzalloc(size, GFP_KERNEL);
547 if (buf == NULL)
548 return 0;
549
550 len += sprintf(buf, "%30s %10s%10s%10s\n\n", "BE", "BK", "VI", "VO");
551
552 PR("MPDUs Queued: ", queued);
553 PR("MPDUs Completed: ", completed);
554 PR("Aggregates: ", a_aggr);
555 PR("AMPDUs Queued: ", a_queued);
556 PR("AMPDUs Completed:", a_completed);
557 PR("AMPDUs Retried: ", a_retries);
558 PR("AMPDUs XRetried: ", a_xretries);
559 PR("FIFO Underrun: ", fifo_underrun);
560 PR("TXOP Exceeded: ", xtxop);
561 PR("TXTIMER Expiry: ", timer_exp);
562 PR("DESC CFG Error: ", desc_cfg_err);
563 PR("DATA Underrun: ", data_underrun);
564 PR("DELIM Underrun: ", delim_underrun);
565
566 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
567 kfree(buf);
568
569 return retval;
570}
571
572void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700573 struct ath_buf *bf, struct ath_tx_status *ts)
Sujithfec247c2009-07-27 12:08:16 +0530574{
Sujithfec247c2009-07-27 12:08:16 +0530575 if (bf_isampdu(bf)) {
576 if (bf_isxretried(bf))
577 TX_STAT_INC(txq->axq_qnum, a_xretries);
578 else
579 TX_STAT_INC(txq->axq_qnum, a_completed);
580 } else {
581 TX_STAT_INC(txq->axq_qnum, completed);
582 }
583
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700584 if (ts->ts_status & ATH9K_TXERR_FIFO)
Sujithfec247c2009-07-27 12:08:16 +0530585 TX_STAT_INC(txq->axq_qnum, fifo_underrun);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700586 if (ts->ts_status & ATH9K_TXERR_XTXOP)
Sujithfec247c2009-07-27 12:08:16 +0530587 TX_STAT_INC(txq->axq_qnum, xtxop);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700588 if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED)
Sujithfec247c2009-07-27 12:08:16 +0530589 TX_STAT_INC(txq->axq_qnum, timer_exp);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700590 if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR)
Sujithfec247c2009-07-27 12:08:16 +0530591 TX_STAT_INC(txq->axq_qnum, desc_cfg_err);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700592 if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN)
Sujithfec247c2009-07-27 12:08:16 +0530593 TX_STAT_INC(txq->axq_qnum, data_underrun);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700594 if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
Sujithfec247c2009-07-27 12:08:16 +0530595 TX_STAT_INC(txq->axq_qnum, delim_underrun);
596}
597
598static const struct file_operations fops_xmit = {
599 .read = read_file_xmit,
600 .open = ath9k_debugfs_open,
601 .owner = THIS_MODULE
602};
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200603
Sujith1395d3f2010-01-08 10:36:11 +0530604static ssize_t read_file_recv(struct file *file, char __user *user_buf,
605 size_t count, loff_t *ppos)
606{
607#define PHY_ERR(s, p) \
608 len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \
609 sc->debug.stats.rxstats.phy_err_stats[p]);
610
611 struct ath_softc *sc = file->private_data;
612 char *buf;
613 unsigned int len = 0, size = 1152;
614 ssize_t retval = 0;
615
616 buf = kzalloc(size, GFP_KERNEL);
617 if (buf == NULL)
618 return 0;
619
620 len += snprintf(buf + len, size - len,
621 "%18s : %10u\n", "CRC ERR",
622 sc->debug.stats.rxstats.crc_err);
623 len += snprintf(buf + len, size - len,
624 "%18s : %10u\n", "DECRYPT CRC ERR",
625 sc->debug.stats.rxstats.decrypt_crc_err);
626 len += snprintf(buf + len, size - len,
627 "%18s : %10u\n", "PHY ERR",
628 sc->debug.stats.rxstats.phy_err);
629 len += snprintf(buf + len, size - len,
630 "%18s : %10u\n", "MIC ERR",
631 sc->debug.stats.rxstats.mic_err);
632 len += snprintf(buf + len, size - len,
633 "%18s : %10u\n", "PRE-DELIM CRC ERR",
634 sc->debug.stats.rxstats.pre_delim_crc_err);
635 len += snprintf(buf + len, size - len,
636 "%18s : %10u\n", "POST-DELIM CRC ERR",
637 sc->debug.stats.rxstats.post_delim_crc_err);
638 len += snprintf(buf + len, size - len,
639 "%18s : %10u\n", "DECRYPT BUSY ERR",
640 sc->debug.stats.rxstats.decrypt_busy_err);
641
642 PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN);
643 PHY_ERR("TIMING", ATH9K_PHYERR_TIMING);
644 PHY_ERR("PARITY", ATH9K_PHYERR_PARITY);
645 PHY_ERR("RATE", ATH9K_PHYERR_RATE);
646 PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH);
647 PHY_ERR("RADAR", ATH9K_PHYERR_RADAR);
648 PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE);
649 PHY_ERR("TOR", ATH9K_PHYERR_TOR);
650 PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING);
651 PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY);
652 PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL);
653 PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL);
654 PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP);
655 PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE);
656 PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART);
657 PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT);
658 PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING);
659 PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC);
660 PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL);
661 PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE);
662 PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART);
663 PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL);
664 PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP);
665 PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR);
666 PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
667 PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL);
668
669 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
670 kfree(buf);
671
672 return retval;
673
674#undef PHY_ERR
675}
676
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700677void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
Sujith1395d3f2010-01-08 10:36:11 +0530678{
679#define RX_STAT_INC(c) sc->debug.stats.rxstats.c++
680#define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
681
Sujith1395d3f2010-01-08 10:36:11 +0530682 u32 phyerr;
683
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700684 if (rs->rs_status & ATH9K_RXERR_CRC)
Sujith1395d3f2010-01-08 10:36:11 +0530685 RX_STAT_INC(crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700686 if (rs->rs_status & ATH9K_RXERR_DECRYPT)
Sujith1395d3f2010-01-08 10:36:11 +0530687 RX_STAT_INC(decrypt_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700688 if (rs->rs_status & ATH9K_RXERR_MIC)
Sujith1395d3f2010-01-08 10:36:11 +0530689 RX_STAT_INC(mic_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700690 if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE)
Sujith1395d3f2010-01-08 10:36:11 +0530691 RX_STAT_INC(pre_delim_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700692 if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST)
Sujith1395d3f2010-01-08 10:36:11 +0530693 RX_STAT_INC(post_delim_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700694 if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY)
Sujith1395d3f2010-01-08 10:36:11 +0530695 RX_STAT_INC(decrypt_busy_err);
696
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700697 if (rs->rs_status & ATH9K_RXERR_PHY) {
Sujith1395d3f2010-01-08 10:36:11 +0530698 RX_STAT_INC(phy_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700699 phyerr = rs->rs_phyerr & 0x24;
Sujith1395d3f2010-01-08 10:36:11 +0530700 RX_PHY_ERR_INC(phyerr);
701 }
702
703#undef RX_STAT_INC
704#undef RX_PHY_ERR_INC
705}
706
707static const struct file_operations fops_recv = {
708 .read = read_file_recv,
709 .open = ath9k_debugfs_open,
710 .owner = THIS_MODULE
711};
712
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -0700713int ath9k_init_debug(struct ath_hw *ah)
Sujith88b126a2008-11-28 22:19:02 +0530714{
Luis R. Rodriguezbc974f42009-09-28 02:54:40 -0400715 struct ath_common *common = ath9k_hw_common(ah);
716 struct ath_softc *sc = (struct ath_softc *) common->priv;
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -0700717
Sujith7dd58742009-03-30 15:28:42 +0530718 if (!ath9k_debugfs_root)
719 return -ENOENT;
720
Sujith17d79042009-02-09 13:27:03 +0530721 sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
Gabor Juhos19d8bc22009-03-05 16:55:18 +0100722 ath9k_debugfs_root);
Sujith17d79042009-02-09 13:27:03 +0530723 if (!sc->debug.debugfs_phy)
Sujith826d2682008-11-28 22:20:23 +0530724 goto err;
725
Felix Fietkaua830df02009-11-23 22:33:27 +0100726#ifdef CONFIG_ATH_DEBUG
Jeff Hansen24939282009-05-27 12:48:29 +0000727 sc->debug.debugfs_debug = debugfs_create_file("debug",
Jiri Slaby9d49e862009-06-28 23:25:28 +0200728 S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_debug);
Jeff Hansen24939282009-05-27 12:48:29 +0000729 if (!sc->debug.debugfs_debug)
730 goto err;
Felix Fietkaua830df02009-11-23 22:33:27 +0100731#endif
Jeff Hansen24939282009-05-27 12:48:29 +0000732
Jiri Slaby9d49e862009-06-28 23:25:28 +0200733 sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUSR,
Sujith17d79042009-02-09 13:27:03 +0530734 sc->debug.debugfs_phy, sc, &fops_dma);
735 if (!sc->debug.debugfs_dma)
Sujith2a163c62008-11-28 22:21:08 +0530736 goto err;
737
Sujith17d79042009-02-09 13:27:03 +0530738 sc->debug.debugfs_interrupt = debugfs_create_file("interrupt",
Jiri Slaby9d49e862009-06-28 23:25:28 +0200739 S_IRUSR,
Sujith17d79042009-02-09 13:27:03 +0530740 sc->debug.debugfs_phy,
Sujith817e11d2008-12-07 21:42:44 +0530741 sc, &fops_interrupt);
Sujith17d79042009-02-09 13:27:03 +0530742 if (!sc->debug.debugfs_interrupt)
Sujith817e11d2008-12-07 21:42:44 +0530743 goto err;
744
Sujith17d79042009-02-09 13:27:03 +0530745 sc->debug.debugfs_rcstat = debugfs_create_file("rcstat",
Jiri Slaby9d49e862009-06-28 23:25:28 +0200746 S_IRUSR,
Sujith17d79042009-02-09 13:27:03 +0530747 sc->debug.debugfs_phy,
Sujith7a7dec62009-01-30 14:32:09 +0530748 sc, &fops_rcstat);
Sujith17d79042009-02-09 13:27:03 +0530749 if (!sc->debug.debugfs_rcstat)
Sujith7a7dec62009-01-30 14:32:09 +0530750 goto err;
751
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200752 sc->debug.debugfs_wiphy = debugfs_create_file(
Jiri Slaby9d49e862009-06-28 23:25:28 +0200753 "wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc,
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200754 &fops_wiphy);
755 if (!sc->debug.debugfs_wiphy)
756 goto err;
757
Sujithfec247c2009-07-27 12:08:16 +0530758 sc->debug.debugfs_xmit = debugfs_create_file("xmit",
759 S_IRUSR,
760 sc->debug.debugfs_phy,
761 sc, &fops_xmit);
762 if (!sc->debug.debugfs_xmit)
763 goto err;
764
Sujith1395d3f2010-01-08 10:36:11 +0530765 sc->debug.debugfs_recv = debugfs_create_file("recv",
766 S_IRUSR,
767 sc->debug.debugfs_phy,
768 sc, &fops_recv);
769 if (!sc->debug.debugfs_recv)
770 goto err;
771
Sujith826d2682008-11-28 22:20:23 +0530772 return 0;
773err:
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -0700774 ath9k_exit_debug(ah);
Sujith826d2682008-11-28 22:20:23 +0530775 return -ENOMEM;
776}
777
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -0700778void ath9k_exit_debug(struct ath_hw *ah)
Sujith826d2682008-11-28 22:20:23 +0530779{
Luis R. Rodriguezbc974f42009-09-28 02:54:40 -0400780 struct ath_common *common = ath9k_hw_common(ah);
781 struct ath_softc *sc = (struct ath_softc *) common->priv;
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -0700782
Sujith1395d3f2010-01-08 10:36:11 +0530783 debugfs_remove(sc->debug.debugfs_recv);
Sujithfec247c2009-07-27 12:08:16 +0530784 debugfs_remove(sc->debug.debugfs_xmit);
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200785 debugfs_remove(sc->debug.debugfs_wiphy);
Sujith17d79042009-02-09 13:27:03 +0530786 debugfs_remove(sc->debug.debugfs_rcstat);
787 debugfs_remove(sc->debug.debugfs_interrupt);
788 debugfs_remove(sc->debug.debugfs_dma);
Jeff Hansen24939282009-05-27 12:48:29 +0000789 debugfs_remove(sc->debug.debugfs_debug);
Sujith17d79042009-02-09 13:27:03 +0530790 debugfs_remove(sc->debug.debugfs_phy);
Gabor Juhos19d8bc22009-03-05 16:55:18 +0100791}
792
793int ath9k_debug_create_root(void)
794{
795 ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
796 if (!ath9k_debugfs_root)
797 return -ENOENT;
798
799 return 0;
800}
801
802void ath9k_debug_remove_root(void)
803{
804 debugfs_remove(ath9k_debugfs_root);
805 ath9k_debugfs_root = NULL;
Sujith88b126a2008-11-28 22:19:02 +0530806}