]>
Commit | Line | Data |
---|---|---|
88b126af | 1 | /* |
5b68138e | 2 | * Copyright (c) 2008-2011 Atheros Communications Inc. |
88b126af S |
3 | * |
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 | ||
5a0e3ad6 | 17 | #include <linux/slab.h> |
582d0064 | 18 | #include <linux/vmalloc.h> |
ee40fa06 | 19 | #include <linux/export.h> |
52103115 GJ |
20 | #include <asm/unaligned.h> |
21 | ||
394cf0a1 | 22 | #include "ath9k.h" |
88b126af | 23 | |
475a6e4d LR |
24 | #define REG_WRITE_D(_ah, _reg, _val) \ |
25 | ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) | |
26 | #define REG_READ_D(_ah, _reg) \ | |
27 | ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) | |
28 | ||
2a163c6d | 29 | |
582d0064 VT |
30 | static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf, |
31 | size_t count, loff_t *ppos) | |
32 | { | |
33 | u8 *buf = file->private_data; | |
34 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); | |
35 | } | |
36 | ||
37 | static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file) | |
38 | { | |
39 | vfree(file->private_data); | |
40 | return 0; | |
41 | } | |
42 | ||
a830df07 FF |
43 | #ifdef CONFIG_ATH_DEBUG |
44 | ||
2493928e JH |
45 | static ssize_t read_file_debug(struct file *file, char __user *user_buf, |
46 | size_t count, loff_t *ppos) | |
47 | { | |
48 | struct ath_softc *sc = file->private_data; | |
c46917bb | 49 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
2493928e | 50 | char buf[32]; |
581f725c VT |
51 | unsigned int len; |
52 | ||
2b87f3aa | 53 | len = sprintf(buf, "0x%08x\n", common->debug_mask); |
2493928e JH |
54 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
55 | } | |
56 | ||
57 | static ssize_t write_file_debug(struct file *file, const char __user *user_buf, | |
58 | size_t count, loff_t *ppos) | |
59 | { | |
60 | struct ath_softc *sc = file->private_data; | |
c46917bb | 61 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
2493928e JH |
62 | unsigned long mask; |
63 | char buf[32]; | |
581f725c VT |
64 | ssize_t len; |
65 | ||
66 | len = min(count, sizeof(buf) - 1); | |
67 | if (copy_from_user(buf, user_buf, len)) | |
04236066 | 68 | return -EFAULT; |
581f725c VT |
69 | |
70 | buf[len] = '\0'; | |
71 | if (strict_strtoul(buf, 0, &mask)) | |
72 | return -EINVAL; | |
73 | ||
c46917bb | 74 | common->debug_mask = mask; |
2493928e JH |
75 | return count; |
76 | } | |
77 | ||
78 | static const struct file_operations fops_debug = { | |
79 | .read = read_file_debug, | |
80 | .write = write_file_debug, | |
234e3405 | 81 | .open = simple_open, |
6038f373 AB |
82 | .owner = THIS_MODULE, |
83 | .llseek = default_llseek, | |
2493928e JH |
84 | }; |
85 | ||
a830df07 FF |
86 | #endif |
87 | ||
991a0987 PR |
88 | #define DMA_BUF_LEN 1024 |
89 | ||
15340694 FF |
90 | static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf, |
91 | size_t count, loff_t *ppos) | |
92 | { | |
93 | struct ath_softc *sc = file->private_data; | |
82b2d334 | 94 | struct ath_hw *ah = sc->sc_ah; |
15340694 FF |
95 | char buf[32]; |
96 | unsigned int len; | |
97 | ||
82b2d334 | 98 | len = sprintf(buf, "0x%08x\n", ah->txchainmask); |
15340694 FF |
99 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
100 | } | |
101 | ||
102 | static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf, | |
103 | size_t count, loff_t *ppos) | |
104 | { | |
105 | struct ath_softc *sc = file->private_data; | |
82b2d334 | 106 | struct ath_hw *ah = sc->sc_ah; |
15340694 FF |
107 | unsigned long mask; |
108 | char buf[32]; | |
109 | ssize_t len; | |
110 | ||
111 | len = min(count, sizeof(buf) - 1); | |
112 | if (copy_from_user(buf, user_buf, len)) | |
04236066 | 113 | return -EFAULT; |
15340694 FF |
114 | |
115 | buf[len] = '\0'; | |
116 | if (strict_strtoul(buf, 0, &mask)) | |
117 | return -EINVAL; | |
118 | ||
82b2d334 FF |
119 | ah->txchainmask = mask; |
120 | ah->caps.tx_chainmask = mask; | |
15340694 FF |
121 | return count; |
122 | } | |
123 | ||
124 | static const struct file_operations fops_tx_chainmask = { | |
125 | .read = read_file_tx_chainmask, | |
126 | .write = write_file_tx_chainmask, | |
234e3405 | 127 | .open = simple_open, |
6038f373 AB |
128 | .owner = THIS_MODULE, |
129 | .llseek = default_llseek, | |
15340694 FF |
130 | }; |
131 | ||
132 | ||
133 | static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf, | |
134 | size_t count, loff_t *ppos) | |
135 | { | |
136 | struct ath_softc *sc = file->private_data; | |
82b2d334 | 137 | struct ath_hw *ah = sc->sc_ah; |
15340694 FF |
138 | char buf[32]; |
139 | unsigned int len; | |
140 | ||
82b2d334 | 141 | len = sprintf(buf, "0x%08x\n", ah->rxchainmask); |
15340694 FF |
142 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
143 | } | |
144 | ||
145 | static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf, | |
146 | size_t count, loff_t *ppos) | |
147 | { | |
148 | struct ath_softc *sc = file->private_data; | |
82b2d334 | 149 | struct ath_hw *ah = sc->sc_ah; |
15340694 FF |
150 | unsigned long mask; |
151 | char buf[32]; | |
152 | ssize_t len; | |
153 | ||
154 | len = min(count, sizeof(buf) - 1); | |
155 | if (copy_from_user(buf, user_buf, len)) | |
04236066 | 156 | return -EFAULT; |
15340694 FF |
157 | |
158 | buf[len] = '\0'; | |
159 | if (strict_strtoul(buf, 0, &mask)) | |
160 | return -EINVAL; | |
161 | ||
82b2d334 FF |
162 | ah->rxchainmask = mask; |
163 | ah->caps.rx_chainmask = mask; | |
15340694 FF |
164 | return count; |
165 | } | |
166 | ||
167 | static const struct file_operations fops_rx_chainmask = { | |
168 | .read = read_file_rx_chainmask, | |
169 | .write = write_file_rx_chainmask, | |
234e3405 | 170 | .open = simple_open, |
6038f373 AB |
171 | .owner = THIS_MODULE, |
172 | .llseek = default_llseek, | |
15340694 FF |
173 | }; |
174 | ||
05c0be2f MSS |
175 | static ssize_t read_file_disable_ani(struct file *file, char __user *user_buf, |
176 | size_t count, loff_t *ppos) | |
177 | { | |
178 | struct ath_softc *sc = file->private_data; | |
179 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | |
180 | char buf[32]; | |
181 | unsigned int len; | |
182 | ||
183 | len = sprintf(buf, "%d\n", common->disable_ani); | |
184 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); | |
185 | } | |
186 | ||
187 | static ssize_t write_file_disable_ani(struct file *file, | |
188 | const char __user *user_buf, | |
189 | size_t count, loff_t *ppos) | |
190 | { | |
191 | struct ath_softc *sc = file->private_data; | |
192 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | |
193 | unsigned long disable_ani; | |
194 | char buf[32]; | |
195 | ssize_t len; | |
196 | ||
197 | len = min(count, sizeof(buf) - 1); | |
198 | if (copy_from_user(buf, user_buf, len)) | |
199 | return -EFAULT; | |
200 | ||
201 | buf[len] = '\0'; | |
202 | if (strict_strtoul(buf, 0, &disable_ani)) | |
203 | return -EINVAL; | |
204 | ||
205 | common->disable_ani = !!disable_ani; | |
206 | ||
207 | if (disable_ani) { | |
208 | sc->sc_flags &= ~SC_OP_ANI_RUN; | |
209 | del_timer_sync(&common->ani.timer); | |
210 | } else { | |
211 | sc->sc_flags |= SC_OP_ANI_RUN; | |
212 | ath_start_ani(common); | |
213 | } | |
214 | ||
215 | return count; | |
216 | } | |
217 | ||
218 | static const struct file_operations fops_disable_ani = { | |
219 | .read = read_file_disable_ani, | |
220 | .write = write_file_disable_ani, | |
234e3405 | 221 | .open = simple_open, |
05c0be2f MSS |
222 | .owner = THIS_MODULE, |
223 | .llseek = default_llseek, | |
224 | }; | |
15340694 | 225 | |
2a163c6d S |
226 | static ssize_t read_file_dma(struct file *file, char __user *user_buf, |
227 | size_t count, loff_t *ppos) | |
228 | { | |
229 | struct ath_softc *sc = file->private_data; | |
cbe61d8a | 230 | struct ath_hw *ah = sc->sc_ah; |
991a0987 PR |
231 | char *buf; |
232 | int retval; | |
2a163c6d S |
233 | unsigned int len = 0; |
234 | u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; | |
235 | int i, qcuOffset = 0, dcuOffset = 0; | |
236 | u32 *qcuBase = &val[0], *dcuBase = &val[4]; | |
237 | ||
991a0987 PR |
238 | buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); |
239 | if (!buf) | |
04236066 | 240 | return -ENOMEM; |
991a0987 | 241 | |
7cf4a2e7 S |
242 | ath9k_ps_wakeup(sc); |
243 | ||
475a6e4d | 244 | REG_WRITE_D(ah, AR_MACMISC, |
2a163c6d S |
245 | ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | |
246 | (AR_MACMISC_MISC_OBS_BUS_1 << | |
247 | AR_MACMISC_MISC_OBS_BUS_MSB_S))); | |
248 | ||
991a0987 | 249 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
2a163c6d S |
250 | "Raw DMA Debug values:\n"); |
251 | ||
252 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { | |
253 | if (i % 4 == 0) | |
991a0987 | 254 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
2a163c6d | 255 | |
475a6e4d | 256 | val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); |
991a0987 | 257 | len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", |
2a163c6d S |
258 | i, val[i]); |
259 | } | |
260 | ||
991a0987 PR |
261 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); |
262 | len += snprintf(buf + len, DMA_BUF_LEN - len, | |
2a163c6d S |
263 | "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); |
264 | ||
265 | for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { | |
266 | if (i == 8) { | |
267 | qcuOffset = 0; | |
268 | qcuBase++; | |
269 | } | |
270 | ||
271 | if (i == 6) { | |
272 | dcuOffset = 0; | |
273 | dcuBase++; | |
274 | } | |
275 | ||
991a0987 | 276 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
2a163c6d S |
277 | "%2d %2x %1x %2x %2x\n", |
278 | i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, | |
279 | (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), | |
280 | val[2] & (0x7 << (i * 3)) >> (i * 3), | |
281 | (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); | |
282 | } | |
283 | ||
991a0987 | 284 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
2a163c6d | 285 | |
991a0987 | 286 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
2a163c6d S |
287 | "qcu_stitch state: %2x qcu_fetch state: %2x\n", |
288 | (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); | |
991a0987 | 289 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
2a163c6d S |
290 | "qcu_complete state: %2x dcu_complete state: %2x\n", |
291 | (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); | |
991a0987 | 292 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
2a163c6d S |
293 | "dcu_arb state: %2x dcu_fp state: %2x\n", |
294 | (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); | |
991a0987 | 295 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
2a163c6d S |
296 | "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", |
297 | (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); | |
991a0987 | 298 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
2a163c6d S |
299 | "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", |
300 | (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); | |
991a0987 | 301 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
2a163c6d S |
302 | "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", |
303 | (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); | |
304 | ||
60ece404 | 305 | len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n", |
475a6e4d | 306 | REG_READ_D(ah, AR_OBS_BUS_1)); |
991a0987 | 307 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
60ece404 | 308 | "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); |
2a163c6d | 309 | |
7cf4a2e7 S |
310 | ath9k_ps_restore(sc); |
311 | ||
2b87f3aa DC |
312 | if (len > DMA_BUF_LEN) |
313 | len = DMA_BUF_LEN; | |
314 | ||
991a0987 PR |
315 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
316 | kfree(buf); | |
317 | return retval; | |
2a163c6d S |
318 | } |
319 | ||
320 | static const struct file_operations fops_dma = { | |
321 | .read = read_file_dma, | |
234e3405 | 322 | .open = simple_open, |
6038f373 AB |
323 | .owner = THIS_MODULE, |
324 | .llseek = default_llseek, | |
2a163c6d S |
325 | }; |
326 | ||
817e11de S |
327 | |
328 | void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) | |
329 | { | |
330 | if (status) | |
17d7904d | 331 | sc->debug.stats.istats.total++; |
a9616f41 LR |
332 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
333 | if (status & ATH9K_INT_RXLP) | |
334 | sc->debug.stats.istats.rxlp++; | |
335 | if (status & ATH9K_INT_RXHP) | |
336 | sc->debug.stats.istats.rxhp++; | |
08578b8f LR |
337 | if (status & ATH9K_INT_BB_WATCHDOG) |
338 | sc->debug.stats.istats.bb_watchdog++; | |
a9616f41 LR |
339 | } else { |
340 | if (status & ATH9K_INT_RX) | |
341 | sc->debug.stats.istats.rxok++; | |
342 | } | |
817e11de | 343 | if (status & ATH9K_INT_RXEOL) |
17d7904d | 344 | sc->debug.stats.istats.rxeol++; |
817e11de | 345 | if (status & ATH9K_INT_RXORN) |
17d7904d | 346 | sc->debug.stats.istats.rxorn++; |
817e11de | 347 | if (status & ATH9K_INT_TX) |
17d7904d | 348 | sc->debug.stats.istats.txok++; |
817e11de | 349 | if (status & ATH9K_INT_TXURN) |
17d7904d | 350 | sc->debug.stats.istats.txurn++; |
817e11de | 351 | if (status & ATH9K_INT_MIB) |
17d7904d | 352 | sc->debug.stats.istats.mib++; |
817e11de | 353 | if (status & ATH9K_INT_RXPHY) |
17d7904d | 354 | sc->debug.stats.istats.rxphyerr++; |
817e11de | 355 | if (status & ATH9K_INT_RXKCM) |
17d7904d | 356 | sc->debug.stats.istats.rx_keycache_miss++; |
817e11de | 357 | if (status & ATH9K_INT_SWBA) |
17d7904d | 358 | sc->debug.stats.istats.swba++; |
817e11de | 359 | if (status & ATH9K_INT_BMISS) |
17d7904d | 360 | sc->debug.stats.istats.bmiss++; |
817e11de | 361 | if (status & ATH9K_INT_BNR) |
17d7904d | 362 | sc->debug.stats.istats.bnr++; |
817e11de | 363 | if (status & ATH9K_INT_CST) |
17d7904d | 364 | sc->debug.stats.istats.cst++; |
817e11de | 365 | if (status & ATH9K_INT_GTT) |
17d7904d | 366 | sc->debug.stats.istats.gtt++; |
817e11de | 367 | if (status & ATH9K_INT_TIM) |
17d7904d | 368 | sc->debug.stats.istats.tim++; |
817e11de | 369 | if (status & ATH9K_INT_CABEND) |
17d7904d | 370 | sc->debug.stats.istats.cabend++; |
817e11de | 371 | if (status & ATH9K_INT_DTIMSYNC) |
17d7904d | 372 | sc->debug.stats.istats.dtimsync++; |
817e11de | 373 | if (status & ATH9K_INT_DTIM) |
17d7904d | 374 | sc->debug.stats.istats.dtim++; |
6dde1aab MSS |
375 | if (status & ATH9K_INT_TSFOOR) |
376 | sc->debug.stats.istats.tsfoor++; | |
97ba515a SM |
377 | if (status & ATH9K_INT_MCI) |
378 | sc->debug.stats.istats.mci++; | |
817e11de S |
379 | } |
380 | ||
381 | static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, | |
382 | size_t count, loff_t *ppos) | |
383 | { | |
384 | struct ath_softc *sc = file->private_data; | |
817e11de | 385 | unsigned int len = 0; |
462e58f2 BG |
386 | int rv; |
387 | int mxlen = 4000; | |
388 | char *buf = kmalloc(mxlen, GFP_KERNEL); | |
389 | if (!buf) | |
390 | return -ENOMEM; | |
391 | ||
392 | #define PR_IS(a, s) \ | |
393 | do { \ | |
394 | len += snprintf(buf + len, mxlen - len, \ | |
395 | "%21s: %10u\n", a, \ | |
396 | sc->debug.stats.istats.s); \ | |
397 | } while (0) | |
817e11de | 398 | |
a9616f41 | 399 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
462e58f2 BG |
400 | PR_IS("RXLP", rxlp); |
401 | PR_IS("RXHP", rxhp); | |
402 | PR_IS("WATHDOG", bb_watchdog); | |
a9616f41 | 403 | } else { |
462e58f2 | 404 | PR_IS("RX", rxok); |
a9616f41 | 405 | } |
462e58f2 BG |
406 | PR_IS("RXEOL", rxeol); |
407 | PR_IS("RXORN", rxorn); | |
408 | PR_IS("TX", txok); | |
409 | PR_IS("TXURN", txurn); | |
410 | PR_IS("MIB", mib); | |
411 | PR_IS("RXPHY", rxphyerr); | |
412 | PR_IS("RXKCM", rx_keycache_miss); | |
413 | PR_IS("SWBA", swba); | |
414 | PR_IS("BMISS", bmiss); | |
415 | PR_IS("BNR", bnr); | |
416 | PR_IS("CST", cst); | |
417 | PR_IS("GTT", gtt); | |
418 | PR_IS("TIM", tim); | |
419 | PR_IS("CABEND", cabend); | |
420 | PR_IS("DTIMSYNC", dtimsync); | |
421 | PR_IS("DTIM", dtim); | |
422 | PR_IS("TSFOOR", tsfoor); | |
97ba515a | 423 | PR_IS("MCI", mci); |
462e58f2 BG |
424 | PR_IS("TOTAL", total); |
425 | ||
426 | len += snprintf(buf + len, mxlen - len, | |
427 | "SYNC_CAUSE stats:\n"); | |
428 | ||
429 | PR_IS("Sync-All", sync_cause_all); | |
430 | PR_IS("RTC-IRQ", sync_rtc_irq); | |
431 | PR_IS("MAC-IRQ", sync_mac_irq); | |
432 | PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access); | |
433 | PR_IS("APB-Timeout", apb_timeout); | |
434 | PR_IS("PCI-Mode-Conflict", pci_mode_conflict); | |
435 | PR_IS("HOST1-Fatal", host1_fatal); | |
436 | PR_IS("HOST1-Perr", host1_perr); | |
437 | PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr); | |
438 | PR_IS("RADM-CPL-EP", radm_cpl_ep); | |
439 | PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort); | |
440 | PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort); | |
441 | PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err); | |
442 | PR_IS("RADM-CPL-Timeout", radm_cpl_timeout); | |
443 | PR_IS("Local-Bus-Timeout", local_timeout); | |
444 | PR_IS("PM-Access", pm_access); | |
445 | PR_IS("MAC-Awake", mac_awake); | |
446 | PR_IS("MAC-Asleep", mac_asleep); | |
447 | PR_IS("MAC-Sleep-Access", mac_sleep_access); | |
448 | ||
449 | if (len > mxlen) | |
450 | len = mxlen; | |
451 | ||
452 | rv = simple_read_from_buffer(user_buf, count, ppos, buf, len); | |
453 | kfree(buf); | |
454 | return rv; | |
817e11de S |
455 | } |
456 | ||
457 | static const struct file_operations fops_interrupt = { | |
458 | .read = read_file_interrupt, | |
234e3405 | 459 | .open = simple_open, |
6038f373 AB |
460 | .owner = THIS_MODULE, |
461 | .llseek = default_llseek, | |
817e11de S |
462 | }; |
463 | ||
5bec3e5a | 464 | #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum |
fec247c0 S |
465 | #define PR(str, elem) \ |
466 | do { \ | |
467 | len += snprintf(buf + len, size - len, \ | |
468 | "%s%13u%11u%10u%10u\n", str, \ | |
5bec3e5a FF |
469 | sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem, \ |
470 | sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem, \ | |
471 | sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem, \ | |
472 | sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem); \ | |
7f010c93 BG |
473 | if (len >= size) \ |
474 | goto done; \ | |
fec247c0 S |
475 | } while(0) |
476 | ||
1f427dd9 BG |
477 | #define PRX(str, elem) \ |
478 | do { \ | |
479 | len += snprintf(buf + len, size - len, \ | |
480 | "%s%13u%11u%10u%10u\n", str, \ | |
5bec3e5a FF |
481 | (unsigned int)(sc->tx.txq_map[WME_AC_BE]->elem), \ |
482 | (unsigned int)(sc->tx.txq_map[WME_AC_BK]->elem), \ | |
483 | (unsigned int)(sc->tx.txq_map[WME_AC_VI]->elem), \ | |
484 | (unsigned int)(sc->tx.txq_map[WME_AC_VO]->elem)); \ | |
7f010c93 BG |
485 | if (len >= size) \ |
486 | goto done; \ | |
1f427dd9 BG |
487 | } while(0) |
488 | ||
2dac4fb9 BG |
489 | #define PRQLE(str, elem) \ |
490 | do { \ | |
491 | len += snprintf(buf + len, size - len, \ | |
492 | "%s%13i%11i%10i%10i\n", str, \ | |
5bec3e5a FF |
493 | list_empty(&sc->tx.txq_map[WME_AC_BE]->elem), \ |
494 | list_empty(&sc->tx.txq_map[WME_AC_BK]->elem), \ | |
495 | list_empty(&sc->tx.txq_map[WME_AC_VI]->elem), \ | |
496 | list_empty(&sc->tx.txq_map[WME_AC_VO]->elem)); \ | |
7f010c93 BG |
497 | if (len >= size) \ |
498 | goto done; \ | |
2dac4fb9 BG |
499 | } while (0) |
500 | ||
fec247c0 S |
501 | static ssize_t read_file_xmit(struct file *file, char __user *user_buf, |
502 | size_t count, loff_t *ppos) | |
503 | { | |
504 | struct ath_softc *sc = file->private_data; | |
505 | char *buf; | |
7f010c93 | 506 | unsigned int len = 0, size = 8000; |
2dac4fb9 | 507 | int i; |
fec247c0 | 508 | ssize_t retval = 0; |
2dac4fb9 | 509 | char tmp[32]; |
fec247c0 S |
510 | |
511 | buf = kzalloc(size, GFP_KERNEL); | |
512 | if (buf == NULL) | |
04236066 | 513 | return -ENOMEM; |
fec247c0 | 514 | |
60f2d1d5 BG |
515 | len += sprintf(buf, "Num-Tx-Queues: %i tx-queues-setup: 0x%x" |
516 | " poll-work-seen: %u\n" | |
7f010c93 BG |
517 | "%30s %10s%10s%10s\n\n", |
518 | ATH9K_NUM_TX_QUEUES, sc->tx.txqsetup, | |
60f2d1d5 | 519 | sc->tx_complete_poll_work_seen, |
7f010c93 | 520 | "BE", "BK", "VI", "VO"); |
fec247c0 S |
521 | |
522 | PR("MPDUs Queued: ", queued); | |
523 | PR("MPDUs Completed: ", completed); | |
5a6f78af | 524 | PR("MPDUs XRetried: ", xretries); |
fec247c0 | 525 | PR("Aggregates: ", a_aggr); |
bda8adda BG |
526 | PR("AMPDUs Queued HW:", a_queued_hw); |
527 | PR("AMPDUs Queued SW:", a_queued_sw); | |
fec247c0 S |
528 | PR("AMPDUs Completed:", a_completed); |
529 | PR("AMPDUs Retried: ", a_retries); | |
530 | PR("AMPDUs XRetried: ", a_xretries); | |
531 | PR("FIFO Underrun: ", fifo_underrun); | |
532 | PR("TXOP Exceeded: ", xtxop); | |
533 | PR("TXTIMER Expiry: ", timer_exp); | |
534 | PR("DESC CFG Error: ", desc_cfg_err); | |
535 | PR("DATA Underrun: ", data_underrun); | |
536 | PR("DELIM Underrun: ", delim_underrun); | |
99c15bf5 BG |
537 | PR("TX-Pkts-All: ", tx_pkts_all); |
538 | PR("TX-Bytes-All: ", tx_bytes_all); | |
2dac4fb9 BG |
539 | PR("hw-put-tx-buf: ", puttxbuf); |
540 | PR("hw-tx-start: ", txstart); | |
541 | PR("hw-tx-proc-desc: ", txprocdesc); | |
a5a0bca1 | 542 | PR("TX-Failed: ", txfailed); |
7f010c93 BG |
543 | len += snprintf(buf + len, size - len, |
544 | "%s%11p%11p%10p%10p\n", "txq-memory-address:", | |
db7889cd BG |
545 | sc->tx.txq_map[WME_AC_BE], |
546 | sc->tx.txq_map[WME_AC_BK], | |
547 | sc->tx.txq_map[WME_AC_VI], | |
548 | sc->tx.txq_map[WME_AC_VO]); | |
7f010c93 BG |
549 | if (len >= size) |
550 | goto done; | |
fec247c0 | 551 | |
1f427dd9 BG |
552 | PRX("axq-qnum: ", axq_qnum); |
553 | PRX("axq-depth: ", axq_depth); | |
2dac4fb9 | 554 | PRX("axq-ampdu_depth: ", axq_ampdu_depth); |
1f427dd9 BG |
555 | PRX("axq-stopped ", stopped); |
556 | PRX("tx-in-progress ", axq_tx_inprogress); | |
557 | PRX("pending-frames ", pending_frames); | |
2dac4fb9 BG |
558 | PRX("txq_headidx: ", txq_headidx); |
559 | PRX("txq_tailidx: ", txq_headidx); | |
560 | ||
561 | PRQLE("axq_q empty: ", axq_q); | |
562 | PRQLE("axq_acq empty: ", axq_acq); | |
2dac4fb9 BG |
563 | for (i = 0; i < ATH_TXFIFO_DEPTH; i++) { |
564 | snprintf(tmp, sizeof(tmp) - 1, "txq_fifo[%i] empty: ", i); | |
565 | PRQLE(tmp, txq_fifo[i]); | |
566 | } | |
7f010c93 | 567 | |
71e025a5 BG |
568 | /* Print out more detailed queue-info */ |
569 | for (i = 0; i <= WME_AC_BK; i++) { | |
570 | struct ath_txq *txq = &(sc->tx.txq[i]); | |
571 | struct ath_atx_ac *ac; | |
572 | struct ath_atx_tid *tid; | |
573 | if (len >= size) | |
574 | goto done; | |
575 | spin_lock_bh(&txq->axq_lock); | |
576 | if (!list_empty(&txq->axq_acq)) { | |
577 | ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, | |
578 | list); | |
579 | len += snprintf(buf + len, size - len, | |
580 | "txq[%i] first-ac: %p sched: %i\n", | |
581 | i, ac, ac->sched); | |
582 | if (list_empty(&ac->tid_q) || (len >= size)) | |
583 | goto done_for; | |
584 | tid = list_first_entry(&ac->tid_q, struct ath_atx_tid, | |
585 | list); | |
586 | len += snprintf(buf + len, size - len, | |
587 | " first-tid: %p sched: %i paused: %i\n", | |
588 | tid, tid->sched, tid->paused); | |
589 | } | |
590 | done_for: | |
591 | spin_unlock_bh(&txq->axq_lock); | |
592 | } | |
593 | ||
7f010c93 BG |
594 | done: |
595 | if (len > size) | |
596 | len = size; | |
597 | ||
598 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | |
599 | kfree(buf); | |
600 | ||
601 | return retval; | |
602 | } | |
603 | ||
604 | static ssize_t read_file_stations(struct file *file, char __user *user_buf, | |
605 | size_t count, loff_t *ppos) | |
606 | { | |
607 | struct ath_softc *sc = file->private_data; | |
608 | char *buf; | |
609 | unsigned int len = 0, size = 64000; | |
610 | struct ath_node *an = NULL; | |
611 | ssize_t retval = 0; | |
612 | int q; | |
613 | ||
614 | buf = kzalloc(size, GFP_KERNEL); | |
615 | if (buf == NULL) | |
616 | return -ENOMEM; | |
617 | ||
618 | len += snprintf(buf + len, size - len, | |
619 | "Stations:\n" | |
7e1e3864 | 620 | " tid: addr sched paused buf_q-empty an ac baw\n" |
7f010c93 BG |
621 | " ac: addr sched tid_q-empty txq\n"); |
622 | ||
623 | spin_lock(&sc->nodes_lock); | |
624 | list_for_each_entry(an, &sc->nodes, list) { | |
7e1e3864 BG |
625 | unsigned short ma = an->maxampdu; |
626 | if (ma == 0) | |
627 | ma = 65535; /* see ath_lookup_rate */ | |
7f010c93 | 628 | len += snprintf(buf + len, size - len, |
7e1e3864 BG |
629 | "iface: %pM sta: %pM max-ampdu: %hu mpdu-density: %uus\n", |
630 | an->vif->addr, an->sta->addr, ma, | |
631 | (unsigned int)(an->mpdudensity)); | |
7f010c93 BG |
632 | if (len >= size) |
633 | goto done; | |
634 | ||
635 | for (q = 0; q < WME_NUM_TID; q++) { | |
636 | struct ath_atx_tid *tid = &(an->tid[q]); | |
637 | len += snprintf(buf + len, size - len, | |
7e1e3864 | 638 | " tid: %p %s %s %i %p %p %hu\n", |
7f010c93 BG |
639 | tid, tid->sched ? "sched" : "idle", |
640 | tid->paused ? "paused" : "running", | |
56dc6336 | 641 | skb_queue_empty(&tid->buf_q), |
7e1e3864 | 642 | tid->an, tid->ac, tid->baw_size); |
7f010c93 BG |
643 | if (len >= size) |
644 | goto done; | |
645 | } | |
646 | ||
647 | for (q = 0; q < WME_NUM_AC; q++) { | |
648 | struct ath_atx_ac *ac = &(an->ac[q]); | |
649 | len += snprintf(buf + len, size - len, | |
650 | " ac: %p %s %i %p\n", | |
651 | ac, ac->sched ? "sched" : "idle", | |
652 | list_empty(&ac->tid_q), ac->txq); | |
653 | if (len >= size) | |
654 | goto done; | |
655 | } | |
656 | } | |
657 | ||
658 | done: | |
659 | spin_unlock(&sc->nodes_lock); | |
2b87f3aa DC |
660 | if (len > size) |
661 | len = size; | |
662 | ||
fec247c0 S |
663 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
664 | kfree(buf); | |
665 | ||
666 | return retval; | |
667 | } | |
668 | ||
55f6d0ff BG |
669 | static ssize_t read_file_misc(struct file *file, char __user *user_buf, |
670 | size_t count, loff_t *ppos) | |
671 | { | |
672 | struct ath_softc *sc = file->private_data; | |
673 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | |
55f6d0ff | 674 | struct ieee80211_hw *hw = sc->hw; |
6bcf6f64 SM |
675 | struct ath9k_vif_iter_data iter_data; |
676 | char buf[512]; | |
677 | unsigned int len = 0; | |
55f6d0ff | 678 | ssize_t retval = 0; |
55f6d0ff | 679 | unsigned int reg; |
6bcf6f64 | 680 | u32 rxfilter; |
55f6d0ff | 681 | |
6bcf6f64 SM |
682 | len += snprintf(buf + len, sizeof(buf) - len, |
683 | "BSSID: %pM\n", common->curbssid); | |
684 | len += snprintf(buf + len, sizeof(buf) - len, | |
685 | "BSSID-MASK: %pM\n", common->bssidmask); | |
686 | len += snprintf(buf + len, sizeof(buf) - len, | |
687 | "OPMODE: %s\n", ath_opmode_to_string(sc->sc_ah->opmode)); | |
55f6d0ff | 688 | |
79d2b157 | 689 | ath9k_ps_wakeup(sc); |
6bcf6f64 | 690 | rxfilter = ath9k_hw_getrxfilter(sc->sc_ah); |
79d2b157 | 691 | ath9k_ps_restore(sc); |
6bcf6f64 SM |
692 | |
693 | len += snprintf(buf + len, sizeof(buf) - len, | |
694 | "RXFILTER: 0x%x", rxfilter); | |
695 | ||
696 | if (rxfilter & ATH9K_RX_FILTER_UCAST) | |
697 | len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); | |
698 | if (rxfilter & ATH9K_RX_FILTER_MCAST) | |
699 | len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); | |
700 | if (rxfilter & ATH9K_RX_FILTER_BCAST) | |
701 | len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); | |
702 | if (rxfilter & ATH9K_RX_FILTER_CONTROL) | |
703 | len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); | |
704 | if (rxfilter & ATH9K_RX_FILTER_BEACON) | |
705 | len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); | |
706 | if (rxfilter & ATH9K_RX_FILTER_PROM) | |
707 | len += snprintf(buf + len, sizeof(buf) - len, " PROM"); | |
708 | if (rxfilter & ATH9K_RX_FILTER_PROBEREQ) | |
709 | len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); | |
710 | if (rxfilter & ATH9K_RX_FILTER_PHYERR) | |
711 | len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); | |
712 | if (rxfilter & ATH9K_RX_FILTER_MYBEACON) | |
713 | len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); | |
714 | if (rxfilter & ATH9K_RX_FILTER_COMP_BAR) | |
715 | len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); | |
716 | if (rxfilter & ATH9K_RX_FILTER_PSPOLL) | |
717 | len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); | |
718 | if (rxfilter & ATH9K_RX_FILTER_PHYRADAR) | |
719 | len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); | |
720 | if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL) | |
721 | len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); | |
722 | if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER) | |
723 | len += snprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER"); | |
724 | ||
725 | len += snprintf(buf + len, sizeof(buf) - len, "\n"); | |
55f6d0ff BG |
726 | |
727 | reg = sc->sc_ah->imask; | |
6bcf6f64 SM |
728 | |
729 | len += snprintf(buf + len, sizeof(buf) - len, "INTERRUPT-MASK: 0x%x", reg); | |
730 | ||
55f6d0ff | 731 | if (reg & ATH9K_INT_SWBA) |
6bcf6f64 | 732 | len += snprintf(buf + len, sizeof(buf) - len, " SWBA"); |
55f6d0ff | 733 | if (reg & ATH9K_INT_BMISS) |
6bcf6f64 | 734 | len += snprintf(buf + len, sizeof(buf) - len, " BMISS"); |
55f6d0ff | 735 | if (reg & ATH9K_INT_CST) |
6bcf6f64 | 736 | len += snprintf(buf + len, sizeof(buf) - len, " CST"); |
55f6d0ff | 737 | if (reg & ATH9K_INT_RX) |
6bcf6f64 | 738 | len += snprintf(buf + len, sizeof(buf) - len, " RX"); |
55f6d0ff | 739 | if (reg & ATH9K_INT_RXHP) |
6bcf6f64 | 740 | len += snprintf(buf + len, sizeof(buf) - len, " RXHP"); |
55f6d0ff | 741 | if (reg & ATH9K_INT_RXLP) |
6bcf6f64 | 742 | len += snprintf(buf + len, sizeof(buf) - len, " RXLP"); |
55f6d0ff | 743 | if (reg & ATH9K_INT_BB_WATCHDOG) |
6bcf6f64 | 744 | len += snprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG"); |
55f6d0ff | 745 | |
6bcf6f64 SM |
746 | len += snprintf(buf + len, sizeof(buf) - len, "\n"); |
747 | ||
748 | ath9k_calculate_iter_data(hw, NULL, &iter_data); | |
749 | ||
750 | len += snprintf(buf + len, sizeof(buf) - len, | |
751 | "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i" | |
bcf6f96e | 752 | " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n", |
55f6d0ff | 753 | iter_data.naps, iter_data.nstations, iter_data.nmeshes, |
bcf6f96e | 754 | iter_data.nwds, iter_data.nadhocs, |
55f6d0ff BG |
755 | sc->nvifs, sc->nbcnvifs); |
756 | ||
6bcf6f64 SM |
757 | if (len > sizeof(buf)) |
758 | len = sizeof(buf); | |
55f6d0ff BG |
759 | |
760 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | |
55f6d0ff BG |
761 | return retval; |
762 | } | |
763 | ||
f8b815dc SM |
764 | static ssize_t read_file_reset(struct file *file, char __user *user_buf, |
765 | size_t count, loff_t *ppos) | |
766 | { | |
767 | struct ath_softc *sc = file->private_data; | |
768 | char buf[512]; | |
769 | unsigned int len = 0; | |
770 | ||
771 | len += snprintf(buf + len, sizeof(buf) - len, | |
772 | "%17s: %2d\n", "Baseband Hang", | |
773 | sc->debug.stats.reset[RESET_TYPE_BB_HANG]); | |
774 | len += snprintf(buf + len, sizeof(buf) - len, | |
775 | "%17s: %2d\n", "Baseband Watchdog", | |
776 | sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]); | |
777 | len += snprintf(buf + len, sizeof(buf) - len, | |
778 | "%17s: %2d\n", "Fatal HW Error", | |
779 | sc->debug.stats.reset[RESET_TYPE_FATAL_INT]); | |
780 | len += snprintf(buf + len, sizeof(buf) - len, | |
781 | "%17s: %2d\n", "TX HW error", | |
782 | sc->debug.stats.reset[RESET_TYPE_TX_ERROR]); | |
783 | len += snprintf(buf + len, sizeof(buf) - len, | |
784 | "%17s: %2d\n", "TX Path Hang", | |
785 | sc->debug.stats.reset[RESET_TYPE_TX_HANG]); | |
786 | len += snprintf(buf + len, sizeof(buf) - len, | |
787 | "%17s: %2d\n", "PLL RX Hang", | |
788 | sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); | |
789 | ||
790 | if (len > sizeof(buf)) | |
791 | len = sizeof(buf); | |
792 | ||
793 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); | |
794 | } | |
795 | ||
066dae93 | 796 | void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, |
55797b1a FF |
797 | struct ath_tx_status *ts, struct ath_txq *txq, |
798 | unsigned int flags) | |
fec247c0 | 799 | { |
cf3af748 RM |
800 | #define TX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].ts\ |
801 | [sc->debug.tsidx].c) | |
5bec3e5a | 802 | int qnum = txq->axq_qnum; |
066dae93 FF |
803 | |
804 | TX_STAT_INC(qnum, tx_pkts_all); | |
805 | sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; | |
99c15bf5 | 806 | |
fec247c0 | 807 | if (bf_isampdu(bf)) { |
156369fa | 808 | if (flags & ATH_TX_ERROR) |
066dae93 | 809 | TX_STAT_INC(qnum, a_xretries); |
fec247c0 | 810 | else |
066dae93 | 811 | TX_STAT_INC(qnum, a_completed); |
fec247c0 | 812 | } else { |
55797b1a | 813 | if (ts->ts_status & ATH9K_TXERR_XRETRY) |
5a6f78af FF |
814 | TX_STAT_INC(qnum, xretries); |
815 | else | |
816 | TX_STAT_INC(qnum, completed); | |
fec247c0 S |
817 | } |
818 | ||
db1a052b | 819 | if (ts->ts_status & ATH9K_TXERR_FIFO) |
066dae93 | 820 | TX_STAT_INC(qnum, fifo_underrun); |
db1a052b | 821 | if (ts->ts_status & ATH9K_TXERR_XTXOP) |
066dae93 | 822 | TX_STAT_INC(qnum, xtxop); |
db1a052b | 823 | if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) |
066dae93 | 824 | TX_STAT_INC(qnum, timer_exp); |
db1a052b | 825 | if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) |
066dae93 | 826 | TX_STAT_INC(qnum, desc_cfg_err); |
db1a052b | 827 | if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) |
066dae93 | 828 | TX_STAT_INC(qnum, data_underrun); |
db1a052b | 829 | if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) |
066dae93 | 830 | TX_STAT_INC(qnum, delim_underrun); |
cf3af748 | 831 | |
5baec742 | 832 | #ifdef CONFIG_ATH9K_MAC_DEBUG |
cf3af748 RM |
833 | spin_lock(&sc->debug.samp_lock); |
834 | TX_SAMP_DBG(jiffies) = jiffies; | |
835 | TX_SAMP_DBG(rssi_ctl0) = ts->ts_rssi_ctl0; | |
836 | TX_SAMP_DBG(rssi_ctl1) = ts->ts_rssi_ctl1; | |
837 | TX_SAMP_DBG(rssi_ctl2) = ts->ts_rssi_ctl2; | |
838 | TX_SAMP_DBG(rssi_ext0) = ts->ts_rssi_ext0; | |
839 | TX_SAMP_DBG(rssi_ext1) = ts->ts_rssi_ext1; | |
840 | TX_SAMP_DBG(rssi_ext2) = ts->ts_rssi_ext2; | |
841 | TX_SAMP_DBG(rateindex) = ts->ts_rateindex; | |
842 | TX_SAMP_DBG(isok) = !!(ts->ts_status & ATH9K_TXERR_MASK); | |
843 | TX_SAMP_DBG(rts_fail_cnt) = ts->ts_shortretry; | |
844 | TX_SAMP_DBG(data_fail_cnt) = ts->ts_longretry; | |
845 | TX_SAMP_DBG(rssi) = ts->ts_rssi; | |
846 | TX_SAMP_DBG(tid) = ts->tid; | |
847 | TX_SAMP_DBG(qid) = ts->qid; | |
12932180 MSS |
848 | |
849 | if (ts->ts_flags & ATH9K_TX_BA) { | |
850 | TX_SAMP_DBG(ba_low) = ts->ba_low; | |
851 | TX_SAMP_DBG(ba_high) = ts->ba_high; | |
852 | } else { | |
853 | TX_SAMP_DBG(ba_low) = 0; | |
854 | TX_SAMP_DBG(ba_high) = 0; | |
855 | } | |
856 | ||
cf3af748 RM |
857 | sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES; |
858 | spin_unlock(&sc->debug.samp_lock); | |
5baec742 | 859 | #endif |
cf3af748 RM |
860 | |
861 | #undef TX_SAMP_DBG | |
fec247c0 S |
862 | } |
863 | ||
864 | static const struct file_operations fops_xmit = { | |
865 | .read = read_file_xmit, | |
234e3405 | 866 | .open = simple_open, |
6038f373 AB |
867 | .owner = THIS_MODULE, |
868 | .llseek = default_llseek, | |
fec247c0 | 869 | }; |
39d89cd3 | 870 | |
7f010c93 BG |
871 | static const struct file_operations fops_stations = { |
872 | .read = read_file_stations, | |
234e3405 | 873 | .open = simple_open, |
7f010c93 BG |
874 | .owner = THIS_MODULE, |
875 | .llseek = default_llseek, | |
876 | }; | |
877 | ||
55f6d0ff BG |
878 | static const struct file_operations fops_misc = { |
879 | .read = read_file_misc, | |
234e3405 | 880 | .open = simple_open, |
55f6d0ff BG |
881 | .owner = THIS_MODULE, |
882 | .llseek = default_llseek, | |
883 | }; | |
884 | ||
f8b815dc SM |
885 | static const struct file_operations fops_reset = { |
886 | .read = read_file_reset, | |
234e3405 | 887 | .open = simple_open, |
f8b815dc SM |
888 | .owner = THIS_MODULE, |
889 | .llseek = default_llseek, | |
890 | }; | |
891 | ||
1395d3f0 S |
892 | static ssize_t read_file_recv(struct file *file, char __user *user_buf, |
893 | size_t count, loff_t *ppos) | |
894 | { | |
895 | #define PHY_ERR(s, p) \ | |
4203214e | 896 | len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \ |
1395d3f0 S |
897 | sc->debug.stats.rxstats.phy_err_stats[p]); |
898 | ||
24a0731e BG |
899 | #define RXS_ERR(s, e) \ |
900 | do { \ | |
901 | len += snprintf(buf + len, size - len, \ | |
902 | "%22s : %10u\n", s, \ | |
903 | sc->debug.stats.rxstats.e); \ | |
904 | } while (0) | |
905 | ||
1395d3f0 S |
906 | struct ath_softc *sc = file->private_data; |
907 | char *buf; | |
4203214e | 908 | unsigned int len = 0, size = 1600; |
1395d3f0 S |
909 | ssize_t retval = 0; |
910 | ||
911 | buf = kzalloc(size, GFP_KERNEL); | |
912 | if (buf == NULL) | |
04236066 | 913 | return -ENOMEM; |
1395d3f0 | 914 | |
24a0731e BG |
915 | RXS_ERR("CRC ERR", crc_err); |
916 | RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err); | |
917 | RXS_ERR("PHY ERR", phy_err); | |
918 | RXS_ERR("MIC ERR", mic_err); | |
919 | RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err); | |
920 | RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err); | |
921 | RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err); | |
922 | RXS_ERR("RX-LENGTH-ERR", rx_len_err); | |
923 | RXS_ERR("RX-OOM-ERR", rx_oom_err); | |
924 | RXS_ERR("RX-RATE-ERR", rx_rate_err); | |
925 | RXS_ERR("RX-DROP-RXFLUSH", rx_drop_rxflush); | |
926 | RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err); | |
1395d3f0 | 927 | |
4203214e SM |
928 | PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN); |
929 | PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING); | |
930 | PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY); | |
931 | PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE); | |
932 | PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH); | |
933 | PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR); | |
934 | PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE); | |
935 | PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR); | |
936 | PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING); | |
937 | PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); | |
938 | PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); | |
939 | PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); | |
940 | PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP); | |
941 | PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE); | |
942 | PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART); | |
943 | PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT); | |
944 | PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING); | |
945 | PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC); | |
946 | PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL); | |
947 | PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE); | |
948 | PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART); | |
949 | PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); | |
950 | PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP); | |
951 | PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR); | |
952 | PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); | |
953 | PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL); | |
954 | ||
24a0731e BG |
955 | RXS_ERR("RX-Pkts-All", rx_pkts_all); |
956 | RXS_ERR("RX-Bytes-All", rx_bytes_all); | |
957 | RXS_ERR("RX-Beacons", rx_beacons); | |
958 | RXS_ERR("RX-Frags", rx_frags); | |
99c15bf5 | 959 | |
2b87f3aa DC |
960 | if (len > size) |
961 | len = size; | |
962 | ||
1395d3f0 S |
963 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
964 | kfree(buf); | |
965 | ||
966 | return retval; | |
967 | ||
24a0731e | 968 | #undef RXS_ERR |
1395d3f0 S |
969 | #undef PHY_ERR |
970 | } | |
971 | ||
8e6f5aa2 | 972 | void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) |
1395d3f0 | 973 | { |
1395d3f0 | 974 | #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++ |
cf3af748 RM |
975 | #define RX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].rs\ |
976 | [sc->debug.rsidx].c) | |
1395d3f0 | 977 | |
99c15bf5 BG |
978 | RX_STAT_INC(rx_pkts_all); |
979 | sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; | |
980 | ||
8e6f5aa2 | 981 | if (rs->rs_status & ATH9K_RXERR_CRC) |
1395d3f0 | 982 | RX_STAT_INC(crc_err); |
8e6f5aa2 | 983 | if (rs->rs_status & ATH9K_RXERR_DECRYPT) |
1395d3f0 | 984 | RX_STAT_INC(decrypt_crc_err); |
8e6f5aa2 | 985 | if (rs->rs_status & ATH9K_RXERR_MIC) |
1395d3f0 | 986 | RX_STAT_INC(mic_err); |
8e6f5aa2 | 987 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) |
1395d3f0 | 988 | RX_STAT_INC(pre_delim_crc_err); |
8e6f5aa2 | 989 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) |
1395d3f0 | 990 | RX_STAT_INC(post_delim_crc_err); |
8e6f5aa2 | 991 | if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) |
1395d3f0 S |
992 | RX_STAT_INC(decrypt_busy_err); |
993 | ||
8e6f5aa2 | 994 | if (rs->rs_status & ATH9K_RXERR_PHY) { |
1395d3f0 | 995 | RX_STAT_INC(phy_err); |
dbb07f00 SM |
996 | if (rs->rs_phyerr < ATH9K_PHYERR_MAX) |
997 | RX_PHY_ERR_INC(rs->rs_phyerr); | |
1395d3f0 S |
998 | } |
999 | ||
5baec742 | 1000 | #ifdef CONFIG_ATH9K_MAC_DEBUG |
cf3af748 RM |
1001 | spin_lock(&sc->debug.samp_lock); |
1002 | RX_SAMP_DBG(jiffies) = jiffies; | |
1003 | RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0; | |
1004 | RX_SAMP_DBG(rssi_ctl1) = rs->rs_rssi_ctl1; | |
1005 | RX_SAMP_DBG(rssi_ctl2) = rs->rs_rssi_ctl2; | |
1006 | RX_SAMP_DBG(rssi_ext0) = rs->rs_rssi_ext0; | |
1007 | RX_SAMP_DBG(rssi_ext1) = rs->rs_rssi_ext1; | |
1008 | RX_SAMP_DBG(rssi_ext2) = rs->rs_rssi_ext2; | |
1009 | RX_SAMP_DBG(antenna) = rs->rs_antenna; | |
1010 | RX_SAMP_DBG(rssi) = rs->rs_rssi; | |
1011 | RX_SAMP_DBG(rate) = rs->rs_rate; | |
1012 | RX_SAMP_DBG(is_mybeacon) = rs->is_mybeacon; | |
1013 | ||
1014 | sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES; | |
1015 | spin_unlock(&sc->debug.samp_lock); | |
1016 | ||
5baec742 FF |
1017 | #endif |
1018 | ||
1395d3f0 | 1019 | #undef RX_PHY_ERR_INC |
cf3af748 | 1020 | #undef RX_SAMP_DBG |
1395d3f0 S |
1021 | } |
1022 | ||
1023 | static const struct file_operations fops_recv = { | |
1024 | .read = read_file_recv, | |
234e3405 | 1025 | .open = simple_open, |
6038f373 AB |
1026 | .owner = THIS_MODULE, |
1027 | .llseek = default_llseek, | |
1395d3f0 S |
1028 | }; |
1029 | ||
9bff0bc4 FF |
1030 | static ssize_t read_file_regidx(struct file *file, char __user *user_buf, |
1031 | size_t count, loff_t *ppos) | |
1032 | { | |
1033 | struct ath_softc *sc = file->private_data; | |
1034 | char buf[32]; | |
1035 | unsigned int len; | |
1036 | ||
2b87f3aa | 1037 | len = sprintf(buf, "0x%08x\n", sc->debug.regidx); |
9bff0bc4 FF |
1038 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
1039 | } | |
1040 | ||
1041 | static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, | |
1042 | size_t count, loff_t *ppos) | |
1043 | { | |
1044 | struct ath_softc *sc = file->private_data; | |
1045 | unsigned long regidx; | |
1046 | char buf[32]; | |
1047 | ssize_t len; | |
1048 | ||
1049 | len = min(count, sizeof(buf) - 1); | |
1050 | if (copy_from_user(buf, user_buf, len)) | |
04236066 | 1051 | return -EFAULT; |
9bff0bc4 FF |
1052 | |
1053 | buf[len] = '\0'; | |
1054 | if (strict_strtoul(buf, 0, ®idx)) | |
1055 | return -EINVAL; | |
1056 | ||
1057 | sc->debug.regidx = regidx; | |
1058 | return count; | |
1059 | } | |
1060 | ||
1061 | static const struct file_operations fops_regidx = { | |
1062 | .read = read_file_regidx, | |
1063 | .write = write_file_regidx, | |
234e3405 | 1064 | .open = simple_open, |
6038f373 AB |
1065 | .owner = THIS_MODULE, |
1066 | .llseek = default_llseek, | |
9bff0bc4 FF |
1067 | }; |
1068 | ||
1069 | static ssize_t read_file_regval(struct file *file, char __user *user_buf, | |
1070 | size_t count, loff_t *ppos) | |
1071 | { | |
1072 | struct ath_softc *sc = file->private_data; | |
1073 | struct ath_hw *ah = sc->sc_ah; | |
1074 | char buf[32]; | |
1075 | unsigned int len; | |
1076 | u32 regval; | |
1077 | ||
79d2b157 | 1078 | ath9k_ps_wakeup(sc); |
9bff0bc4 | 1079 | regval = REG_READ_D(ah, sc->debug.regidx); |
79d2b157 | 1080 | ath9k_ps_restore(sc); |
2b87f3aa | 1081 | len = sprintf(buf, "0x%08x\n", regval); |
9bff0bc4 FF |
1082 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
1083 | } | |
1084 | ||
1085 | static ssize_t write_file_regval(struct file *file, const char __user *user_buf, | |
1086 | size_t count, loff_t *ppos) | |
1087 | { | |
1088 | struct ath_softc *sc = file->private_data; | |
1089 | struct ath_hw *ah = sc->sc_ah; | |
1090 | unsigned long regval; | |
1091 | char buf[32]; | |
1092 | ssize_t len; | |
1093 | ||
1094 | len = min(count, sizeof(buf) - 1); | |
1095 | if (copy_from_user(buf, user_buf, len)) | |
04236066 | 1096 | return -EFAULT; |
9bff0bc4 FF |
1097 | |
1098 | buf[len] = '\0'; | |
1099 | if (strict_strtoul(buf, 0, ®val)) | |
1100 | return -EINVAL; | |
1101 | ||
79d2b157 | 1102 | ath9k_ps_wakeup(sc); |
9bff0bc4 | 1103 | REG_WRITE_D(ah, sc->debug.regidx, regval); |
79d2b157 | 1104 | ath9k_ps_restore(sc); |
9bff0bc4 FF |
1105 | return count; |
1106 | } | |
1107 | ||
1108 | static const struct file_operations fops_regval = { | |
1109 | .read = read_file_regval, | |
1110 | .write = write_file_regval, | |
234e3405 | 1111 | .open = simple_open, |
6038f373 AB |
1112 | .owner = THIS_MODULE, |
1113 | .llseek = default_llseek, | |
9bff0bc4 FF |
1114 | }; |
1115 | ||
582d0064 VT |
1116 | #define REGDUMP_LINE_SIZE 20 |
1117 | ||
1118 | static int open_file_regdump(struct inode *inode, struct file *file) | |
1119 | { | |
1120 | struct ath_softc *sc = inode->i_private; | |
1121 | unsigned int len = 0; | |
1122 | u8 *buf; | |
1123 | int i; | |
1124 | unsigned long num_regs, regdump_len, max_reg_offset; | |
1125 | ||
1126 | max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500; | |
1127 | num_regs = max_reg_offset / 4 + 1; | |
1128 | regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; | |
1129 | buf = vmalloc(regdump_len); | |
1130 | if (!buf) | |
1131 | return -ENOMEM; | |
1132 | ||
1133 | ath9k_ps_wakeup(sc); | |
1134 | for (i = 0; i < num_regs; i++) | |
1135 | len += scnprintf(buf + len, regdump_len - len, | |
1136 | "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); | |
1137 | ath9k_ps_restore(sc); | |
1138 | ||
1139 | file->private_data = buf; | |
1140 | ||
1141 | return 0; | |
1142 | } | |
1143 | ||
1144 | static const struct file_operations fops_regdump = { | |
1145 | .open = open_file_regdump, | |
1146 | .read = ath9k_debugfs_read_buf, | |
1147 | .release = ath9k_debugfs_release_buf, | |
1148 | .owner = THIS_MODULE, | |
1149 | .llseek = default_llseek,/* read accesses f_pos */ | |
1150 | }; | |
1151 | ||
d069a46b RM |
1152 | static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf, |
1153 | size_t count, loff_t *ppos) | |
1154 | { | |
1155 | struct ath_softc *sc = file->private_data; | |
1156 | struct ath_hw *ah = sc->sc_ah; | |
1157 | struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist; | |
1158 | struct ath_common *common = ath9k_hw_common(ah); | |
1159 | struct ieee80211_conf *conf = &common->hw->conf; | |
1160 | u32 len = 0, size = 1500; | |
1161 | u32 i, j; | |
1162 | ssize_t retval = 0; | |
1163 | char *buf; | |
1164 | u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; | |
1165 | u8 nread; | |
1166 | ||
1167 | buf = kzalloc(size, GFP_KERNEL); | |
1168 | if (!buf) | |
1169 | return -ENOMEM; | |
1170 | ||
1171 | len += snprintf(buf + len, size - len, | |
1172 | "Channel Noise Floor : %d\n", ah->noise); | |
1173 | len += snprintf(buf + len, size - len, | |
1174 | "Chain | privNF | # Readings | NF Readings\n"); | |
1175 | for (i = 0; i < NUM_NF_READINGS; i++) { | |
1176 | if (!(chainmask & (1 << i)) || | |
1177 | ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) | |
1178 | continue; | |
1179 | ||
1180 | nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; | |
1181 | len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t", | |
1182 | i, h[i].privNF, nread); | |
1183 | for (j = 0; j < nread; j++) | |
1184 | len += snprintf(buf + len, size - len, | |
1185 | " %d", h[i].nfCalBuffer[j]); | |
1186 | len += snprintf(buf + len, size - len, "\n"); | |
1187 | } | |
1188 | ||
1189 | if (len > size) | |
1190 | len = size; | |
1191 | ||
1192 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | |
1193 | kfree(buf); | |
1194 | ||
1195 | return retval; | |
1196 | } | |
1197 | ||
1198 | static const struct file_operations fops_dump_nfcal = { | |
1199 | .read = read_file_dump_nfcal, | |
234e3405 | 1200 | .open = simple_open, |
d069a46b RM |
1201 | .owner = THIS_MODULE, |
1202 | .llseek = default_llseek, | |
1203 | }; | |
1204 | ||
580f010f RM |
1205 | static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf, |
1206 | size_t count, loff_t *ppos) | |
1207 | { | |
1208 | struct ath_softc *sc = file->private_data; | |
1209 | struct ath_hw *ah = sc->sc_ah; | |
1210 | u32 len = 0, size = 1500; | |
1211 | ssize_t retval = 0; | |
1212 | char *buf; | |
1213 | ||
1214 | buf = kzalloc(size, GFP_KERNEL); | |
1215 | if (!buf) | |
1216 | return -ENOMEM; | |
1217 | ||
1218 | len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size); | |
1219 | ||
1220 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | |
1221 | kfree(buf); | |
1222 | ||
1223 | return retval; | |
1224 | } | |
1225 | ||
1226 | static const struct file_operations fops_base_eeprom = { | |
1227 | .read = read_file_base_eeprom, | |
234e3405 | 1228 | .open = simple_open, |
580f010f RM |
1229 | .owner = THIS_MODULE, |
1230 | .llseek = default_llseek, | |
1231 | }; | |
1232 | ||
3f4c4bdd RM |
1233 | static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf, |
1234 | size_t count, loff_t *ppos) | |
1235 | { | |
1236 | struct ath_softc *sc = file->private_data; | |
1237 | struct ath_hw *ah = sc->sc_ah; | |
1238 | u32 len = 0, size = 6000; | |
1239 | char *buf; | |
1240 | size_t retval; | |
1241 | ||
1242 | buf = kzalloc(size, GFP_KERNEL); | |
1243 | if (buf == NULL) | |
1244 | return -ENOMEM; | |
1245 | ||
1246 | len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size); | |
1247 | ||
1248 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | |
1249 | kfree(buf); | |
1250 | ||
1251 | return retval; | |
1252 | } | |
1253 | ||
1254 | static const struct file_operations fops_modal_eeprom = { | |
1255 | .read = read_file_modal_eeprom, | |
234e3405 | 1256 | .open = simple_open, |
3f4c4bdd RM |
1257 | .owner = THIS_MODULE, |
1258 | .llseek = default_llseek, | |
1259 | }; | |
1260 | ||
5baec742 FF |
1261 | #ifdef CONFIG_ATH9K_MAC_DEBUG |
1262 | ||
cf3af748 RM |
1263 | void ath9k_debug_samp_bb_mac(struct ath_softc *sc) |
1264 | { | |
1265 | #define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c) | |
1266 | struct ath_hw *ah = sc->sc_ah; | |
1267 | struct ath_common *common = ath9k_hw_common(ah); | |
1268 | unsigned long flags; | |
1269 | int i; | |
1270 | ||
1271 | ath9k_ps_wakeup(sc); | |
1272 | ||
6bc05a95 RM |
1273 | spin_lock_bh(&sc->debug.samp_lock); |
1274 | ||
cf3af748 RM |
1275 | spin_lock_irqsave(&common->cc_lock, flags); |
1276 | ath_hw_cycle_counters_update(common); | |
cf3af748 RM |
1277 | |
1278 | ATH_SAMP_DBG(cc.cycles) = common->cc_ani.cycles; | |
1279 | ATH_SAMP_DBG(cc.rx_busy) = common->cc_ani.rx_busy; | |
1280 | ATH_SAMP_DBG(cc.rx_frame) = common->cc_ani.rx_frame; | |
1281 | ATH_SAMP_DBG(cc.tx_frame) = common->cc_ani.tx_frame; | |
6bc05a95 RM |
1282 | spin_unlock_irqrestore(&common->cc_lock, flags); |
1283 | ||
cf3af748 RM |
1284 | ATH_SAMP_DBG(noise) = ah->noise; |
1285 | ||
1286 | REG_WRITE_D(ah, AR_MACMISC, | |
1287 | ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | | |
1288 | (AR_MACMISC_MISC_OBS_BUS_1 << | |
1289 | AR_MACMISC_MISC_OBS_BUS_MSB_S))); | |
1290 | ||
1291 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) | |
1292 | ATH_SAMP_DBG(dma_dbg_reg_vals[i]) = REG_READ_D(ah, | |
1293 | AR_DMADBG_0 + (i * sizeof(u32))); | |
1294 | ||
1295 | ATH_SAMP_DBG(pcu_obs) = REG_READ_D(ah, AR_OBS_BUS_1); | |
1296 | ATH_SAMP_DBG(pcu_cr) = REG_READ_D(ah, AR_CR); | |
1297 | ||
1298 | memcpy(ATH_SAMP_DBG(nfCalHist), sc->caldata.nfCalHist, | |
1299 | sizeof(ATH_SAMP_DBG(nfCalHist))); | |
1300 | ||
1301 | sc->debug.sampidx = (sc->debug.sampidx + 1) % ATH_DBG_MAX_SAMPLES; | |
1302 | spin_unlock_bh(&sc->debug.samp_lock); | |
1303 | ath9k_ps_restore(sc); | |
1304 | ||
1305 | #undef ATH_SAMP_DBG | |
1306 | } | |
1307 | ||
1308 | static int open_file_bb_mac_samps(struct inode *inode, struct file *file) | |
1309 | { | |
1310 | #define ATH_SAMP_DBG(c) bb_mac_samp[sampidx].c | |
1311 | struct ath_softc *sc = inode->i_private; | |
1312 | struct ath_hw *ah = sc->sc_ah; | |
1313 | struct ath_common *common = ath9k_hw_common(ah); | |
1314 | struct ieee80211_conf *conf = &common->hw->conf; | |
1315 | struct ath_dbg_bb_mac_samp *bb_mac_samp; | |
1316 | struct ath9k_nfcal_hist *h; | |
1317 | int i, j, qcuOffset = 0, dcuOffset = 0; | |
1318 | u32 *qcuBase, *dcuBase, size = 30000, len = 0; | |
1319 | u32 sampidx = 0; | |
1320 | u8 *buf; | |
1321 | u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; | |
1322 | u8 nread; | |
1323 | ||
f7e014da RM |
1324 | if (sc->sc_flags & SC_OP_INVALID) |
1325 | return -EAGAIN; | |
1326 | ||
cf3af748 RM |
1327 | buf = vmalloc(size); |
1328 | if (!buf) | |
1329 | return -ENOMEM; | |
1330 | bb_mac_samp = vmalloc(sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES); | |
1331 | if (!bb_mac_samp) { | |
1332 | vfree(buf); | |
1333 | return -ENOMEM; | |
1334 | } | |
f7e014da RM |
1335 | /* Account the current state too */ |
1336 | ath9k_debug_samp_bb_mac(sc); | |
cf3af748 RM |
1337 | |
1338 | spin_lock_bh(&sc->debug.samp_lock); | |
1339 | memcpy(bb_mac_samp, sc->debug.bb_mac_samp, | |
1340 | sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES); | |
6bc05a95 RM |
1341 | len += snprintf(buf + len, size - len, |
1342 | "Current Sample Index: %d\n", sc->debug.sampidx); | |
cf3af748 RM |
1343 | spin_unlock_bh(&sc->debug.samp_lock); |
1344 | ||
1345 | len += snprintf(buf + len, size - len, | |
1346 | "Raw DMA Debug Dump:\n"); | |
1347 | len += snprintf(buf + len, size - len, "Sample |\t"); | |
1348 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) | |
1349 | len += snprintf(buf + len, size - len, " DMA Reg%d |\t", i); | |
1350 | len += snprintf(buf + len, size - len, "\n"); | |
1351 | ||
1352 | for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { | |
1353 | len += snprintf(buf + len, size - len, "%d\t", sampidx); | |
1354 | ||
1355 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) | |
1356 | len += snprintf(buf + len, size - len, " %08x\t", | |
1357 | ATH_SAMP_DBG(dma_dbg_reg_vals[i])); | |
1358 | len += snprintf(buf + len, size - len, "\n"); | |
1359 | } | |
1360 | len += snprintf(buf + len, size - len, "\n"); | |
1361 | ||
1362 | len += snprintf(buf + len, size - len, | |
1363 | "Sample Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); | |
1364 | for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { | |
1365 | qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]); | |
1366 | dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]); | |
1367 | ||
1368 | for (i = 0; i < ATH9K_NUM_QUEUES; i++, | |
1369 | qcuOffset += 4, dcuOffset += 5) { | |
1370 | if (i == 8) { | |
1371 | qcuOffset = 0; | |
1372 | qcuBase++; | |
1373 | } | |
1374 | ||
1375 | if (i == 6) { | |
1376 | dcuOffset = 0; | |
1377 | dcuBase++; | |
1378 | } | |
1379 | if (!sc->debug.stats.txstats[i].queued) | |
1380 | continue; | |
1381 | ||
1382 | len += snprintf(buf + len, size - len, | |
1383 | "%4d %7d %2x %1x %2x %2x\n", | |
1384 | sampidx, i, | |
1385 | (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, | |
1386 | (*qcuBase & (0x8 << qcuOffset)) >> | |
1387 | (qcuOffset + 3), | |
1388 | ATH_SAMP_DBG(dma_dbg_reg_vals[2]) & | |
1389 | (0x7 << (i * 3)) >> (i * 3), | |
1390 | (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); | |
1391 | } | |
1392 | len += snprintf(buf + len, size - len, "\n"); | |
1393 | } | |
1394 | len += snprintf(buf + len, size - len, | |
1395 | "samp qcu_sh qcu_fh qcu_comp dcu_comp dcu_arb dcu_fp " | |
1396 | "ch_idle_dur ch_idle_dur_val txfifo_val0 txfifo_val1 " | |
1397 | "txfifo_dcu0 txfifo_dcu1 pcu_obs AR_CR\n"); | |
1398 | ||
1399 | for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { | |
1400 | qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]); | |
1401 | dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]); | |
1402 | ||
1403 | len += snprintf(buf + len, size - len, "%4d %5x %5x ", sampidx, | |
1404 | (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x003c0000) >> 18, | |
1405 | (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x03c00000) >> 22); | |
1406 | len += snprintf(buf + len, size - len, "%7x %8x ", | |
1407 | (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x1c000000) >> 26, | |
1408 | (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x3)); | |
1409 | len += snprintf(buf + len, size - len, "%7x %7x ", | |
1410 | (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x06000000) >> 25, | |
1411 | (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x38000000) >> 27); | |
1412 | len += snprintf(buf + len, size - len, "%7d %12d ", | |
1413 | (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x000003fc) >> 2, | |
1414 | (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000400) >> 10); | |
1415 | len += snprintf(buf + len, size - len, "%12d %12d ", | |
1416 | (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000800) >> 11, | |
1417 | (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00001000) >> 12); | |
1418 | len += snprintf(buf + len, size - len, "%12d %12d ", | |
1419 | (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x0001e000) >> 13, | |
1420 | (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x001e0000) >> 17); | |
1421 | len += snprintf(buf + len, size - len, "0x%07x 0x%07x\n", | |
1422 | ATH_SAMP_DBG(pcu_obs), ATH_SAMP_DBG(pcu_cr)); | |
1423 | } | |
1424 | ||
1425 | len += snprintf(buf + len, size - len, | |
1426 | "Sample ChNoise Chain privNF #Reading Readings\n"); | |
1427 | for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { | |
1428 | h = ATH_SAMP_DBG(nfCalHist); | |
1429 | if (!ATH_SAMP_DBG(noise)) | |
1430 | continue; | |
1431 | ||
1432 | for (i = 0; i < NUM_NF_READINGS; i++) { | |
1433 | if (!(chainmask & (1 << i)) || | |
1434 | ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) | |
1435 | continue; | |
1436 | ||
1437 | nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - | |
1438 | h[i].invalidNFcount; | |
1439 | len += snprintf(buf + len, size - len, | |
1440 | "%4d %5d %4d\t %d\t %d\t", | |
1441 | sampidx, ATH_SAMP_DBG(noise), | |
1442 | i, h[i].privNF, nread); | |
1443 | for (j = 0; j < nread; j++) | |
1444 | len += snprintf(buf + len, size - len, | |
1445 | " %d", h[i].nfCalBuffer[j]); | |
1446 | len += snprintf(buf + len, size - len, "\n"); | |
1447 | } | |
1448 | } | |
1449 | len += snprintf(buf + len, size - len, "\nCycle counters:\n" | |
1450 | "Sample Total Rxbusy Rxframes Txframes\n"); | |
1451 | for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { | |
1452 | if (!ATH_SAMP_DBG(cc.cycles)) | |
1453 | continue; | |
1454 | len += snprintf(buf + len, size - len, | |
1455 | "%4d %08x %08x %08x %08x\n", | |
1456 | sampidx, ATH_SAMP_DBG(cc.cycles), | |
1457 | ATH_SAMP_DBG(cc.rx_busy), | |
1458 | ATH_SAMP_DBG(cc.rx_frame), | |
1459 | ATH_SAMP_DBG(cc.tx_frame)); | |
1460 | } | |
1461 | ||
1462 | len += snprintf(buf + len, size - len, "Tx status Dump :\n"); | |
1463 | len += snprintf(buf + len, size - len, | |
1464 | "Sample rssi:- ctl0 ctl1 ctl2 ext0 ext1 ext2 comb " | |
12932180 MSS |
1465 | "isok rts_fail data_fail rate tid qid " |
1466 | "ba_low ba_high tx_before(ms)\n"); | |
cf3af748 RM |
1467 | for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { |
1468 | for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) { | |
1469 | if (!ATH_SAMP_DBG(ts[i].jiffies)) | |
1470 | continue; | |
12932180 MSS |
1471 | len += snprintf(buf + len, size - len, "%-14d" |
1472 | "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-8d " | |
1473 | "%-9d %-4d %-3d %-3d %08x %08x %-11d\n", | |
cf3af748 RM |
1474 | sampidx, |
1475 | ATH_SAMP_DBG(ts[i].rssi_ctl0), | |
1476 | ATH_SAMP_DBG(ts[i].rssi_ctl1), | |
1477 | ATH_SAMP_DBG(ts[i].rssi_ctl2), | |
1478 | ATH_SAMP_DBG(ts[i].rssi_ext0), | |
1479 | ATH_SAMP_DBG(ts[i].rssi_ext1), | |
1480 | ATH_SAMP_DBG(ts[i].rssi_ext2), | |
1481 | ATH_SAMP_DBG(ts[i].rssi), | |
1482 | ATH_SAMP_DBG(ts[i].isok), | |
1483 | ATH_SAMP_DBG(ts[i].rts_fail_cnt), | |
1484 | ATH_SAMP_DBG(ts[i].data_fail_cnt), | |
1485 | ATH_SAMP_DBG(ts[i].rateindex), | |
1486 | ATH_SAMP_DBG(ts[i].tid), | |
1487 | ATH_SAMP_DBG(ts[i].qid), | |
12932180 MSS |
1488 | ATH_SAMP_DBG(ts[i].ba_low), |
1489 | ATH_SAMP_DBG(ts[i].ba_high), | |
cf3af748 RM |
1490 | jiffies_to_msecs(jiffies - |
1491 | ATH_SAMP_DBG(ts[i].jiffies))); | |
1492 | } | |
1493 | } | |
1494 | ||
1495 | len += snprintf(buf + len, size - len, "Rx status Dump :\n"); | |
1496 | len += snprintf(buf + len, size - len, "Sample rssi:- ctl0 ctl1 ctl2 " | |
1497 | "ext0 ext1 ext2 comb beacon ant rate rx_before(ms)\n"); | |
1498 | for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { | |
1499 | for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) { | |
1500 | if (!ATH_SAMP_DBG(rs[i].jiffies)) | |
1501 | continue; | |
12932180 MSS |
1502 | len += snprintf(buf + len, size - len, "%-14d" |
1503 | "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-9s %-2d %02x %-13d\n", | |
cf3af748 RM |
1504 | sampidx, |
1505 | ATH_SAMP_DBG(rs[i].rssi_ctl0), | |
1506 | ATH_SAMP_DBG(rs[i].rssi_ctl1), | |
1507 | ATH_SAMP_DBG(rs[i].rssi_ctl2), | |
1508 | ATH_SAMP_DBG(rs[i].rssi_ext0), | |
1509 | ATH_SAMP_DBG(rs[i].rssi_ext1), | |
1510 | ATH_SAMP_DBG(rs[i].rssi_ext2), | |
1511 | ATH_SAMP_DBG(rs[i].rssi), | |
1512 | ATH_SAMP_DBG(rs[i].is_mybeacon) ? | |
1513 | "True" : "False", | |
1514 | ATH_SAMP_DBG(rs[i].antenna), | |
1515 | ATH_SAMP_DBG(rs[i].rate), | |
1516 | jiffies_to_msecs(jiffies - | |
1517 | ATH_SAMP_DBG(rs[i].jiffies))); | |
1518 | } | |
1519 | } | |
1520 | ||
1521 | vfree(bb_mac_samp); | |
1522 | file->private_data = buf; | |
1523 | ||
1524 | return 0; | |
1525 | #undef ATH_SAMP_DBG | |
1526 | } | |
1527 | ||
1528 | static const struct file_operations fops_samps = { | |
1529 | .open = open_file_bb_mac_samps, | |
1530 | .read = ath9k_debugfs_read_buf, | |
1531 | .release = ath9k_debugfs_release_buf, | |
1532 | .owner = THIS_MODULE, | |
1533 | .llseek = default_llseek, | |
1534 | }; | |
1535 | ||
5baec742 | 1536 | #endif |
cf3af748 | 1537 | |
4d6b228d | 1538 | int ath9k_init_debug(struct ath_hw *ah) |
88b126af | 1539 | { |
bc974f4a LR |
1540 | struct ath_common *common = ath9k_hw_common(ah); |
1541 | struct ath_softc *sc = (struct ath_softc *) common->priv; | |
4d6b228d | 1542 | |
eb272441 BG |
1543 | sc->debug.debugfs_phy = debugfs_create_dir("ath9k", |
1544 | sc->hw->wiphy->debugfsdir); | |
17d7904d | 1545 | if (!sc->debug.debugfs_phy) |
c8a72c00 | 1546 | return -ENOMEM; |
826d2680 | 1547 | |
a830df07 | 1548 | #ifdef CONFIG_ATH_DEBUG |
c70cab1a FF |
1549 | debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
1550 | sc, &fops_debug); | |
a830df07 | 1551 | #endif |
29942bc1 ZK |
1552 | |
1553 | ath9k_dfs_init_debug(sc); | |
1554 | ||
c70cab1a FF |
1555 | debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, |
1556 | &fops_dma); | |
1557 | debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, | |
1558 | &fops_interrupt); | |
c70cab1a FF |
1559 | debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, |
1560 | &fops_xmit); | |
1561 | debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc, | |
1562 | &fops_stations); | |
1563 | debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, | |
1564 | &fops_misc); | |
f8b815dc SM |
1565 | debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc, |
1566 | &fops_reset); | |
c70cab1a FF |
1567 | debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, |
1568 | &fops_recv); | |
1569 | debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, | |
1570 | sc->debug.debugfs_phy, sc, &fops_rx_chainmask); | |
1571 | debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, | |
1572 | sc->debug.debugfs_phy, sc, &fops_tx_chainmask); | |
05c0be2f MSS |
1573 | debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR, |
1574 | sc->debug.debugfs_phy, sc, &fops_disable_ani); | |
c70cab1a FF |
1575 | debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
1576 | sc, &fops_regidx); | |
1577 | debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, | |
1578 | sc, &fops_regval); | |
1579 | debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, | |
1580 | sc->debug.debugfs_phy, | |
1581 | &ah->config.cwm_ignore_extcca); | |
1582 | debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, | |
1583 | &fops_regdump); | |
d069a46b RM |
1584 | debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc, |
1585 | &fops_dump_nfcal); | |
580f010f RM |
1586 | debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, |
1587 | &fops_base_eeprom); | |
3f4c4bdd RM |
1588 | debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, |
1589 | &fops_modal_eeprom); | |
5baec742 | 1590 | #ifdef CONFIG_ATH9K_MAC_DEBUG |
cf3af748 RM |
1591 | debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc, |
1592 | &fops_samps); | |
5baec742 | 1593 | #endif |
582d0064 | 1594 | |
691680b8 FF |
1595 | debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, |
1596 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); | |
1597 | ||
1598 | debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, | |
1599 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); | |
1600 | ||
826d2680 | 1601 | return 0; |
88b126af | 1602 | } |