2 * Copyright (c) 2008-2011 Atheros Communications Inc.
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.
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.
17 #include <linux/slab.h>
18 #include <linux/vmalloc.h>
19 #include <linux/export.h>
20 #include <linux/relay.h>
21 #include <asm/unaligned.h>
25 #define REG_WRITE_D(_ah, _reg, _val) \
26 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
27 #define REG_READ_D(_ah, _reg) \
28 ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
31 static ssize_t
ath9k_debugfs_read_buf(struct file
*file
, char __user
*user_buf
,
32 size_t count
, loff_t
*ppos
)
34 u8
*buf
= file
->private_data
;
35 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, strlen(buf
));
38 static int ath9k_debugfs_release_buf(struct inode
*inode
, struct file
*file
)
40 vfree(file
->private_data
);
44 #ifdef CONFIG_ATH_DEBUG
46 static ssize_t
read_file_debug(struct file
*file
, char __user
*user_buf
,
47 size_t count
, loff_t
*ppos
)
49 struct ath_softc
*sc
= file
->private_data
;
50 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
54 len
= sprintf(buf
, "0x%08x\n", common
->debug_mask
);
55 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
58 static ssize_t
write_file_debug(struct file
*file
, const char __user
*user_buf
,
59 size_t count
, loff_t
*ppos
)
61 struct ath_softc
*sc
= file
->private_data
;
62 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
67 len
= min(count
, sizeof(buf
) - 1);
68 if (copy_from_user(buf
, user_buf
, len
))
72 if (kstrtoul(buf
, 0, &mask
))
75 common
->debug_mask
= mask
;
79 static const struct file_operations fops_debug
= {
80 .read
= read_file_debug
,
81 .write
= write_file_debug
,
84 .llseek
= default_llseek
,
89 #define DMA_BUF_LEN 1024
91 static ssize_t
read_file_tx_chainmask(struct file
*file
, char __user
*user_buf
,
92 size_t count
, loff_t
*ppos
)
94 struct ath_softc
*sc
= file
->private_data
;
95 struct ath_hw
*ah
= sc
->sc_ah
;
99 len
= sprintf(buf
, "0x%08x\n", ah
->txchainmask
);
100 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
103 static ssize_t
write_file_tx_chainmask(struct file
*file
, const char __user
*user_buf
,
104 size_t count
, loff_t
*ppos
)
106 struct ath_softc
*sc
= file
->private_data
;
107 struct ath_hw
*ah
= sc
->sc_ah
;
112 len
= min(count
, sizeof(buf
) - 1);
113 if (copy_from_user(buf
, user_buf
, len
))
117 if (kstrtoul(buf
, 0, &mask
))
120 ah
->txchainmask
= mask
;
121 ah
->caps
.tx_chainmask
= mask
;
125 static const struct file_operations fops_tx_chainmask
= {
126 .read
= read_file_tx_chainmask
,
127 .write
= write_file_tx_chainmask
,
129 .owner
= THIS_MODULE
,
130 .llseek
= default_llseek
,
134 static ssize_t
read_file_rx_chainmask(struct file
*file
, char __user
*user_buf
,
135 size_t count
, loff_t
*ppos
)
137 struct ath_softc
*sc
= file
->private_data
;
138 struct ath_hw
*ah
= sc
->sc_ah
;
142 len
= sprintf(buf
, "0x%08x\n", ah
->rxchainmask
);
143 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
146 static ssize_t
write_file_rx_chainmask(struct file
*file
, const char __user
*user_buf
,
147 size_t count
, loff_t
*ppos
)
149 struct ath_softc
*sc
= file
->private_data
;
150 struct ath_hw
*ah
= sc
->sc_ah
;
155 len
= min(count
, sizeof(buf
) - 1);
156 if (copy_from_user(buf
, user_buf
, len
))
160 if (kstrtoul(buf
, 0, &mask
))
163 ah
->rxchainmask
= mask
;
164 ah
->caps
.rx_chainmask
= mask
;
168 static const struct file_operations fops_rx_chainmask
= {
169 .read
= read_file_rx_chainmask
,
170 .write
= write_file_rx_chainmask
,
172 .owner
= THIS_MODULE
,
173 .llseek
= default_llseek
,
176 static ssize_t
read_file_ani(struct file
*file
, char __user
*user_buf
,
177 size_t count
, loff_t
*ppos
)
179 struct ath_softc
*sc
= file
->private_data
;
180 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
181 struct ath_hw
*ah
= sc
->sc_ah
;
182 unsigned int len
= 0, size
= 1024;
186 buf
= kzalloc(size
, GFP_KERNEL
);
190 if (common
->disable_ani
) {
191 len
+= snprintf(buf
+ len
, size
- len
, "%s: %s\n",
196 len
+= snprintf(buf
+ len
, size
- len
, "%15s: %s\n",
198 len
+= snprintf(buf
+ len
, size
- len
, "%15s: %u\n",
199 "ANI RESET", ah
->stats
.ast_ani_reset
);
200 len
+= snprintf(buf
+ len
, size
- len
, "%15s: %u\n",
201 "SPUR UP", ah
->stats
.ast_ani_spurup
);
202 len
+= snprintf(buf
+ len
, size
- len
, "%15s: %u\n",
203 "SPUR DOWN", ah
->stats
.ast_ani_spurup
);
204 len
+= snprintf(buf
+ len
, size
- len
, "%15s: %u\n",
205 "OFDM WS-DET ON", ah
->stats
.ast_ani_ofdmon
);
206 len
+= snprintf(buf
+ len
, size
- len
, "%15s: %u\n",
207 "OFDM WS-DET OFF", ah
->stats
.ast_ani_ofdmoff
);
208 len
+= snprintf(buf
+ len
, size
- len
, "%15s: %u\n",
209 "MRC-CCK ON", ah
->stats
.ast_ani_ccklow
);
210 len
+= snprintf(buf
+ len
, size
- len
, "%15s: %u\n",
211 "MRC-CCK OFF", ah
->stats
.ast_ani_cckhigh
);
212 len
+= snprintf(buf
+ len
, size
- len
, "%15s: %u\n",
213 "FIR-STEP UP", ah
->stats
.ast_ani_stepup
);
214 len
+= snprintf(buf
+ len
, size
- len
, "%15s: %u\n",
215 "FIR-STEP DOWN", ah
->stats
.ast_ani_stepdown
);
216 len
+= snprintf(buf
+ len
, size
- len
, "%15s: %u\n",
217 "INV LISTENTIME", ah
->stats
.ast_ani_lneg_or_lzero
);
218 len
+= snprintf(buf
+ len
, size
- len
, "%15s: %u\n",
219 "OFDM ERRORS", ah
->stats
.ast_ani_ofdmerrs
);
220 len
+= snprintf(buf
+ len
, size
- len
, "%15s: %u\n",
221 "CCK ERRORS", ah
->stats
.ast_ani_cckerrs
);
226 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
232 static ssize_t
write_file_ani(struct file
*file
,
233 const char __user
*user_buf
,
234 size_t count
, loff_t
*ppos
)
236 struct ath_softc
*sc
= file
->private_data
;
237 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
242 len
= min(count
, sizeof(buf
) - 1);
243 if (copy_from_user(buf
, user_buf
, len
))
247 if (kstrtoul(buf
, 0, &ani
))
250 if (ani
< 0 || ani
> 1)
253 common
->disable_ani
= !ani
;
255 if (common
->disable_ani
) {
256 clear_bit(SC_OP_ANI_RUN
, &sc
->sc_flags
);
265 static const struct file_operations fops_ani
= {
266 .read
= read_file_ani
,
267 .write
= write_file_ani
,
269 .owner
= THIS_MODULE
,
270 .llseek
= default_llseek
,
273 static ssize_t
read_file_ant_diversity(struct file
*file
, char __user
*user_buf
,
274 size_t count
, loff_t
*ppos
)
276 struct ath_softc
*sc
= file
->private_data
;
277 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
281 len
= sprintf(buf
, "%d\n", common
->antenna_diversity
);
282 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
285 static ssize_t
write_file_ant_diversity(struct file
*file
,
286 const char __user
*user_buf
,
287 size_t count
, loff_t
*ppos
)
289 struct ath_softc
*sc
= file
->private_data
;
290 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
291 unsigned long antenna_diversity
;
295 len
= min(count
, sizeof(buf
) - 1);
296 if (copy_from_user(buf
, user_buf
, len
))
299 if (!AR_SREV_9565(sc
->sc_ah
))
303 if (kstrtoul(buf
, 0, &antenna_diversity
))
306 common
->antenna_diversity
= !!antenna_diversity
;
308 ath_ant_comb_update(sc
);
309 ath_dbg(common
, CONFIG
, "Antenna diversity: %d\n",
310 common
->antenna_diversity
);
311 ath9k_ps_restore(sc
);
316 static const struct file_operations fops_ant_diversity
= {
317 .read
= read_file_ant_diversity
,
318 .write
= write_file_ant_diversity
,
320 .owner
= THIS_MODULE
,
321 .llseek
= default_llseek
,
324 static ssize_t
read_file_dma(struct file
*file
, char __user
*user_buf
,
325 size_t count
, loff_t
*ppos
)
327 struct ath_softc
*sc
= file
->private_data
;
328 struct ath_hw
*ah
= sc
->sc_ah
;
331 unsigned int len
= 0;
332 u32 val
[ATH9K_NUM_DMA_DEBUG_REGS
];
333 int i
, qcuOffset
= 0, dcuOffset
= 0;
334 u32
*qcuBase
= &val
[0], *dcuBase
= &val
[4];
336 buf
= kmalloc(DMA_BUF_LEN
, GFP_KERNEL
);
342 REG_WRITE_D(ah
, AR_MACMISC
,
343 ((AR_MACMISC_DMA_OBS_LINE_8
<< AR_MACMISC_DMA_OBS_S
) |
344 (AR_MACMISC_MISC_OBS_BUS_1
<<
345 AR_MACMISC_MISC_OBS_BUS_MSB_S
)));
347 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
348 "Raw DMA Debug values:\n");
350 for (i
= 0; i
< ATH9K_NUM_DMA_DEBUG_REGS
; i
++) {
352 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "\n");
354 val
[i
] = REG_READ_D(ah
, AR_DMADBG_0
+ (i
* sizeof(u32
)));
355 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "%d: %08x ",
359 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "\n\n");
360 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
361 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
363 for (i
= 0; i
< ATH9K_NUM_QUEUES
; i
++, qcuOffset
+= 4, dcuOffset
+= 5) {
374 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
375 "%2d %2x %1x %2x %2x\n",
376 i
, (*qcuBase
& (0x7 << qcuOffset
)) >> qcuOffset
,
377 (*qcuBase
& (0x8 << qcuOffset
)) >> (qcuOffset
+ 3),
378 val
[2] & (0x7 << (i
* 3)) >> (i
* 3),
379 (*dcuBase
& (0x1f << dcuOffset
)) >> dcuOffset
);
382 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "\n");
384 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
385 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
386 (val
[3] & 0x003c0000) >> 18, (val
[3] & 0x03c00000) >> 22);
387 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
388 "qcu_complete state: %2x dcu_complete state: %2x\n",
389 (val
[3] & 0x1c000000) >> 26, (val
[6] & 0x3));
390 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
391 "dcu_arb state: %2x dcu_fp state: %2x\n",
392 (val
[5] & 0x06000000) >> 25, (val
[5] & 0x38000000) >> 27);
393 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
394 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
395 (val
[6] & 0x000003fc) >> 2, (val
[6] & 0x00000400) >> 10);
396 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
397 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
398 (val
[6] & 0x00000800) >> 11, (val
[6] & 0x00001000) >> 12);
399 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
400 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
401 (val
[6] & 0x0001e000) >> 13, (val
[6] & 0x001e0000) >> 17);
403 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "pcu observe: 0x%x\n",
404 REG_READ_D(ah
, AR_OBS_BUS_1
));
405 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
406 "AR_CR: 0x%x\n", REG_READ_D(ah
, AR_CR
));
408 ath9k_ps_restore(sc
);
410 if (len
> DMA_BUF_LEN
)
413 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
418 static const struct file_operations fops_dma
= {
419 .read
= read_file_dma
,
421 .owner
= THIS_MODULE
,
422 .llseek
= default_llseek
,
426 void ath_debug_stat_interrupt(struct ath_softc
*sc
, enum ath9k_int status
)
429 sc
->debug
.stats
.istats
.total
++;
430 if (sc
->sc_ah
->caps
.hw_caps
& ATH9K_HW_CAP_EDMA
) {
431 if (status
& ATH9K_INT_RXLP
)
432 sc
->debug
.stats
.istats
.rxlp
++;
433 if (status
& ATH9K_INT_RXHP
)
434 sc
->debug
.stats
.istats
.rxhp
++;
435 if (status
& ATH9K_INT_BB_WATCHDOG
)
436 sc
->debug
.stats
.istats
.bb_watchdog
++;
438 if (status
& ATH9K_INT_RX
)
439 sc
->debug
.stats
.istats
.rxok
++;
441 if (status
& ATH9K_INT_RXEOL
)
442 sc
->debug
.stats
.istats
.rxeol
++;
443 if (status
& ATH9K_INT_RXORN
)
444 sc
->debug
.stats
.istats
.rxorn
++;
445 if (status
& ATH9K_INT_TX
)
446 sc
->debug
.stats
.istats
.txok
++;
447 if (status
& ATH9K_INT_TXURN
)
448 sc
->debug
.stats
.istats
.txurn
++;
449 if (status
& ATH9K_INT_RXPHY
)
450 sc
->debug
.stats
.istats
.rxphyerr
++;
451 if (status
& ATH9K_INT_RXKCM
)
452 sc
->debug
.stats
.istats
.rx_keycache_miss
++;
453 if (status
& ATH9K_INT_SWBA
)
454 sc
->debug
.stats
.istats
.swba
++;
455 if (status
& ATH9K_INT_BMISS
)
456 sc
->debug
.stats
.istats
.bmiss
++;
457 if (status
& ATH9K_INT_BNR
)
458 sc
->debug
.stats
.istats
.bnr
++;
459 if (status
& ATH9K_INT_CST
)
460 sc
->debug
.stats
.istats
.cst
++;
461 if (status
& ATH9K_INT_GTT
)
462 sc
->debug
.stats
.istats
.gtt
++;
463 if (status
& ATH9K_INT_TIM
)
464 sc
->debug
.stats
.istats
.tim
++;
465 if (status
& ATH9K_INT_CABEND
)
466 sc
->debug
.stats
.istats
.cabend
++;
467 if (status
& ATH9K_INT_DTIMSYNC
)
468 sc
->debug
.stats
.istats
.dtimsync
++;
469 if (status
& ATH9K_INT_DTIM
)
470 sc
->debug
.stats
.istats
.dtim
++;
471 if (status
& ATH9K_INT_TSFOOR
)
472 sc
->debug
.stats
.istats
.tsfoor
++;
473 if (status
& ATH9K_INT_MCI
)
474 sc
->debug
.stats
.istats
.mci
++;
475 if (status
& ATH9K_INT_GENTIMER
)
476 sc
->debug
.stats
.istats
.gen_timer
++;
479 static ssize_t
read_file_interrupt(struct file
*file
, char __user
*user_buf
,
480 size_t count
, loff_t
*ppos
)
482 struct ath_softc
*sc
= file
->private_data
;
483 unsigned int len
= 0;
486 char *buf
= kmalloc(mxlen
, GFP_KERNEL
);
490 #define PR_IS(a, s) \
492 len += snprintf(buf + len, mxlen - len, \
494 sc->debug.stats.istats.s); \
497 if (sc
->sc_ah
->caps
.hw_caps
& ATH9K_HW_CAP_EDMA
) {
500 PR_IS("WATHDOG", bb_watchdog
);
504 PR_IS("RXEOL", rxeol
);
505 PR_IS("RXORN", rxorn
);
507 PR_IS("TXURN", txurn
);
509 PR_IS("RXPHY", rxphyerr
);
510 PR_IS("RXKCM", rx_keycache_miss
);
512 PR_IS("BMISS", bmiss
);
517 PR_IS("CABEND", cabend
);
518 PR_IS("DTIMSYNC", dtimsync
);
520 PR_IS("TSFOOR", tsfoor
);
522 PR_IS("GENTIMER", gen_timer
);
523 PR_IS("TOTAL", total
);
525 len
+= snprintf(buf
+ len
, mxlen
- len
,
526 "SYNC_CAUSE stats:\n");
528 PR_IS("Sync-All", sync_cause_all
);
529 PR_IS("RTC-IRQ", sync_rtc_irq
);
530 PR_IS("MAC-IRQ", sync_mac_irq
);
531 PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access
);
532 PR_IS("APB-Timeout", apb_timeout
);
533 PR_IS("PCI-Mode-Conflict", pci_mode_conflict
);
534 PR_IS("HOST1-Fatal", host1_fatal
);
535 PR_IS("HOST1-Perr", host1_perr
);
536 PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr
);
537 PR_IS("RADM-CPL-EP", radm_cpl_ep
);
538 PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort
);
539 PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort
);
540 PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err
);
541 PR_IS("RADM-CPL-Timeout", radm_cpl_timeout
);
542 PR_IS("Local-Bus-Timeout", local_timeout
);
543 PR_IS("PM-Access", pm_access
);
544 PR_IS("MAC-Awake", mac_awake
);
545 PR_IS("MAC-Asleep", mac_asleep
);
546 PR_IS("MAC-Sleep-Access", mac_sleep_access
);
551 rv
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
556 static const struct file_operations fops_interrupt
= {
557 .read
= read_file_interrupt
,
559 .owner
= THIS_MODULE
,
560 .llseek
= default_llseek
,
563 static ssize_t
read_file_xmit(struct file
*file
, char __user
*user_buf
,
564 size_t count
, loff_t
*ppos
)
566 struct ath_softc
*sc
= file
->private_data
;
568 unsigned int len
= 0, size
= 2048;
571 buf
= kzalloc(size
, GFP_KERNEL
);
575 len
+= sprintf(buf
, "%30s %10s%10s%10s\n\n",
576 "BE", "BK", "VI", "VO");
578 PR("MPDUs Queued: ", queued
);
579 PR("MPDUs Completed: ", completed
);
580 PR("MPDUs XRetried: ", xretries
);
581 PR("Aggregates: ", a_aggr
);
582 PR("AMPDUs Queued HW:", a_queued_hw
);
583 PR("AMPDUs Queued SW:", a_queued_sw
);
584 PR("AMPDUs Completed:", a_completed
);
585 PR("AMPDUs Retried: ", a_retries
);
586 PR("AMPDUs XRetried: ", a_xretries
);
587 PR("TXERR Filtered: ", txerr_filtered
);
588 PR("FIFO Underrun: ", fifo_underrun
);
589 PR("TXOP Exceeded: ", xtxop
);
590 PR("TXTIMER Expiry: ", timer_exp
);
591 PR("DESC CFG Error: ", desc_cfg_err
);
592 PR("DATA Underrun: ", data_underrun
);
593 PR("DELIM Underrun: ", delim_underrun
);
594 PR("TX-Pkts-All: ", tx_pkts_all
);
595 PR("TX-Bytes-All: ", tx_bytes_all
);
596 PR("HW-put-tx-buf: ", puttxbuf
);
597 PR("HW-tx-start: ", txstart
);
598 PR("HW-tx-proc-desc: ", txprocdesc
);
599 PR("TX-Failed: ", txfailed
);
604 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
610 static ssize_t
read_file_queues(struct file
*file
, char __user
*user_buf
,
611 size_t count
, loff_t
*ppos
)
613 struct ath_softc
*sc
= file
->private_data
;
616 unsigned int len
= 0, size
= 1024;
619 char *qname
[4] = {"VO", "VI", "BE", "BK"};
621 buf
= kzalloc(size
, GFP_KERNEL
);
625 for (i
= 0; i
< IEEE80211_NUM_ACS
; i
++) {
626 txq
= sc
->tx
.txq_map
[i
];
627 len
+= snprintf(buf
+ len
, size
- len
, "(%s): ", qname
[i
]);
629 ath_txq_lock(sc
, txq
);
631 len
+= snprintf(buf
+ len
, size
- len
, "%s: %d ",
632 "qnum", txq
->axq_qnum
);
633 len
+= snprintf(buf
+ len
, size
- len
, "%s: %2d ",
634 "qdepth", txq
->axq_depth
);
635 len
+= snprintf(buf
+ len
, size
- len
, "%s: %2d ",
636 "ampdu-depth", txq
->axq_ampdu_depth
);
637 len
+= snprintf(buf
+ len
, size
- len
, "%s: %3d ",
638 "pending", txq
->pending_frames
);
639 len
+= snprintf(buf
+ len
, size
- len
, "%s: %d\n",
640 "stopped", txq
->stopped
);
642 ath_txq_unlock(sc
, txq
);
648 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
654 static ssize_t
read_file_misc(struct file
*file
, char __user
*user_buf
,
655 size_t count
, loff_t
*ppos
)
657 struct ath_softc
*sc
= file
->private_data
;
658 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
659 struct ieee80211_hw
*hw
= sc
->hw
;
660 struct ath9k_vif_iter_data iter_data
;
662 unsigned int len
= 0;
667 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
668 "BSSID: %pM\n", common
->curbssid
);
669 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
670 "BSSID-MASK: %pM\n", common
->bssidmask
);
671 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
672 "OPMODE: %s\n", ath_opmode_to_string(sc
->sc_ah
->opmode
));
675 rxfilter
= ath9k_hw_getrxfilter(sc
->sc_ah
);
676 ath9k_ps_restore(sc
);
678 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
679 "RXFILTER: 0x%x", rxfilter
);
681 if (rxfilter
& ATH9K_RX_FILTER_UCAST
)
682 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " UCAST");
683 if (rxfilter
& ATH9K_RX_FILTER_MCAST
)
684 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " MCAST");
685 if (rxfilter
& ATH9K_RX_FILTER_BCAST
)
686 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " BCAST");
687 if (rxfilter
& ATH9K_RX_FILTER_CONTROL
)
688 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " CONTROL");
689 if (rxfilter
& ATH9K_RX_FILTER_BEACON
)
690 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " BEACON");
691 if (rxfilter
& ATH9K_RX_FILTER_PROM
)
692 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PROM");
693 if (rxfilter
& ATH9K_RX_FILTER_PROBEREQ
)
694 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PROBEREQ");
695 if (rxfilter
& ATH9K_RX_FILTER_PHYERR
)
696 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PHYERR");
697 if (rxfilter
& ATH9K_RX_FILTER_MYBEACON
)
698 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " MYBEACON");
699 if (rxfilter
& ATH9K_RX_FILTER_COMP_BAR
)
700 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " COMP_BAR");
701 if (rxfilter
& ATH9K_RX_FILTER_PSPOLL
)
702 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PSPOLL");
703 if (rxfilter
& ATH9K_RX_FILTER_PHYRADAR
)
704 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PHYRADAR");
705 if (rxfilter
& ATH9K_RX_FILTER_MCAST_BCAST_ALL
)
706 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " MCAST_BCAST_ALL");
707 if (rxfilter
& ATH9K_RX_FILTER_CONTROL_WRAPPER
)
708 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " CONTROL_WRAPPER");
710 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "\n");
712 reg
= sc
->sc_ah
->imask
;
714 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "INTERRUPT-MASK: 0x%x", reg
);
716 if (reg
& ATH9K_INT_SWBA
)
717 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " SWBA");
718 if (reg
& ATH9K_INT_BMISS
)
719 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " BMISS");
720 if (reg
& ATH9K_INT_CST
)
721 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " CST");
722 if (reg
& ATH9K_INT_RX
)
723 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " RX");
724 if (reg
& ATH9K_INT_RXHP
)
725 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " RXHP");
726 if (reg
& ATH9K_INT_RXLP
)
727 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " RXLP");
728 if (reg
& ATH9K_INT_BB_WATCHDOG
)
729 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " BB_WATCHDOG");
731 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "\n");
733 ath9k_calculate_iter_data(hw
, NULL
, &iter_data
);
735 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
736 "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i"
737 " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n",
738 iter_data
.naps
, iter_data
.nstations
, iter_data
.nmeshes
,
739 iter_data
.nwds
, iter_data
.nadhocs
,
740 sc
->nvifs
, sc
->nbcnvifs
);
742 if (len
> sizeof(buf
))
745 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
749 static ssize_t
read_file_reset(struct file
*file
, char __user
*user_buf
,
750 size_t count
, loff_t
*ppos
)
752 struct ath_softc
*sc
= file
->private_data
;
754 unsigned int len
= 0;
756 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
757 "%17s: %2d\n", "Baseband Hang",
758 sc
->debug
.stats
.reset
[RESET_TYPE_BB_HANG
]);
759 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
760 "%17s: %2d\n", "Baseband Watchdog",
761 sc
->debug
.stats
.reset
[RESET_TYPE_BB_WATCHDOG
]);
762 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
763 "%17s: %2d\n", "Fatal HW Error",
764 sc
->debug
.stats
.reset
[RESET_TYPE_FATAL_INT
]);
765 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
766 "%17s: %2d\n", "TX HW error",
767 sc
->debug
.stats
.reset
[RESET_TYPE_TX_ERROR
]);
768 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
769 "%17s: %2d\n", "TX Path Hang",
770 sc
->debug
.stats
.reset
[RESET_TYPE_TX_HANG
]);
771 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
772 "%17s: %2d\n", "PLL RX Hang",
773 sc
->debug
.stats
.reset
[RESET_TYPE_PLL_HANG
]);
774 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
775 "%17s: %2d\n", "MCI Reset",
776 sc
->debug
.stats
.reset
[RESET_TYPE_MCI
]);
778 if (len
> sizeof(buf
))
781 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
784 void ath_debug_stat_tx(struct ath_softc
*sc
, struct ath_buf
*bf
,
785 struct ath_tx_status
*ts
, struct ath_txq
*txq
,
788 int qnum
= txq
->axq_qnum
;
790 TX_STAT_INC(qnum
, tx_pkts_all
);
791 sc
->debug
.stats
.txstats
[qnum
].tx_bytes_all
+= bf
->bf_mpdu
->len
;
793 if (bf_isampdu(bf
)) {
794 if (flags
& ATH_TX_ERROR
)
795 TX_STAT_INC(qnum
, a_xretries
);
797 TX_STAT_INC(qnum
, a_completed
);
799 if (ts
->ts_status
& ATH9K_TXERR_XRETRY
)
800 TX_STAT_INC(qnum
, xretries
);
802 TX_STAT_INC(qnum
, completed
);
805 if (ts
->ts_status
& ATH9K_TXERR_FILT
)
806 TX_STAT_INC(qnum
, txerr_filtered
);
807 if (ts
->ts_status
& ATH9K_TXERR_FIFO
)
808 TX_STAT_INC(qnum
, fifo_underrun
);
809 if (ts
->ts_status
& ATH9K_TXERR_XTXOP
)
810 TX_STAT_INC(qnum
, xtxop
);
811 if (ts
->ts_status
& ATH9K_TXERR_TIMER_EXPIRED
)
812 TX_STAT_INC(qnum
, timer_exp
);
813 if (ts
->ts_flags
& ATH9K_TX_DESC_CFG_ERR
)
814 TX_STAT_INC(qnum
, desc_cfg_err
);
815 if (ts
->ts_flags
& ATH9K_TX_DATA_UNDERRUN
)
816 TX_STAT_INC(qnum
, data_underrun
);
817 if (ts
->ts_flags
& ATH9K_TX_DELIM_UNDERRUN
)
818 TX_STAT_INC(qnum
, delim_underrun
);
821 static const struct file_operations fops_xmit
= {
822 .read
= read_file_xmit
,
824 .owner
= THIS_MODULE
,
825 .llseek
= default_llseek
,
828 static const struct file_operations fops_queues
= {
829 .read
= read_file_queues
,
831 .owner
= THIS_MODULE
,
832 .llseek
= default_llseek
,
835 static const struct file_operations fops_misc
= {
836 .read
= read_file_misc
,
838 .owner
= THIS_MODULE
,
839 .llseek
= default_llseek
,
842 static const struct file_operations fops_reset
= {
843 .read
= read_file_reset
,
845 .owner
= THIS_MODULE
,
846 .llseek
= default_llseek
,
849 static ssize_t
read_file_recv(struct file
*file
, char __user
*user_buf
,
850 size_t count
, loff_t
*ppos
)
852 #define PHY_ERR(s, p) \
853 len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \
854 sc->debug.stats.rxstats.phy_err_stats[p]);
856 #define RXS_ERR(s, e) \
858 len += snprintf(buf + len, size - len, \
859 "%22s : %10u\n", s, \
860 sc->debug.stats.rxstats.e); \
863 struct ath_softc
*sc
= file
->private_data
;
865 unsigned int len
= 0, size
= 1600;
868 buf
= kzalloc(size
, GFP_KERNEL
);
872 RXS_ERR("CRC ERR", crc_err
);
873 RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err
);
874 RXS_ERR("PHY ERR", phy_err
);
875 RXS_ERR("MIC ERR", mic_err
);
876 RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err
);
877 RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err
);
878 RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err
);
879 RXS_ERR("RX-LENGTH-ERR", rx_len_err
);
880 RXS_ERR("RX-OOM-ERR", rx_oom_err
);
881 RXS_ERR("RX-RATE-ERR", rx_rate_err
);
882 RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err
);
884 PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN
);
885 PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING
);
886 PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY
);
887 PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE
);
888 PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH
);
889 PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR
);
890 PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE
);
891 PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR
);
892 PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING
);
893 PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY
);
894 PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL
);
895 PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL
);
896 PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP
);
897 PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE
);
898 PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART
);
899 PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT
);
900 PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING
);
901 PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC
);
902 PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL
);
903 PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE
);
904 PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART
);
905 PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL
);
906 PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP
);
907 PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR
);
908 PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL
);
909 PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL
);
911 RXS_ERR("RX-Pkts-All", rx_pkts_all
);
912 RXS_ERR("RX-Bytes-All", rx_bytes_all
);
913 RXS_ERR("RX-Beacons", rx_beacons
);
914 RXS_ERR("RX-Frags", rx_frags
);
915 RXS_ERR("RX-Spectral", rx_spectral
);
920 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
929 void ath_debug_stat_rx(struct ath_softc
*sc
, struct ath_rx_status
*rs
)
931 #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
933 RX_STAT_INC(rx_pkts_all
);
934 sc
->debug
.stats
.rxstats
.rx_bytes_all
+= rs
->rs_datalen
;
936 if (rs
->rs_status
& ATH9K_RXERR_CRC
)
937 RX_STAT_INC(crc_err
);
938 if (rs
->rs_status
& ATH9K_RXERR_DECRYPT
)
939 RX_STAT_INC(decrypt_crc_err
);
940 if (rs
->rs_status
& ATH9K_RXERR_MIC
)
941 RX_STAT_INC(mic_err
);
942 if (rs
->rs_status
& ATH9K_RX_DELIM_CRC_PRE
)
943 RX_STAT_INC(pre_delim_crc_err
);
944 if (rs
->rs_status
& ATH9K_RX_DELIM_CRC_POST
)
945 RX_STAT_INC(post_delim_crc_err
);
946 if (rs
->rs_status
& ATH9K_RX_DECRYPT_BUSY
)
947 RX_STAT_INC(decrypt_busy_err
);
949 if (rs
->rs_status
& ATH9K_RXERR_PHY
) {
950 RX_STAT_INC(phy_err
);
951 if (rs
->rs_phyerr
< ATH9K_PHYERR_MAX
)
952 RX_PHY_ERR_INC(rs
->rs_phyerr
);
955 #undef RX_PHY_ERR_INC
958 static const struct file_operations fops_recv
= {
959 .read
= read_file_recv
,
961 .owner
= THIS_MODULE
,
962 .llseek
= default_llseek
,
965 static ssize_t
read_file_spec_scan_ctl(struct file
*file
, char __user
*user_buf
,
966 size_t count
, loff_t
*ppos
)
968 struct ath_softc
*sc
= file
->private_data
;
972 switch (sc
->spectral_mode
) {
973 case SPECTRAL_DISABLED
:
976 case SPECTRAL_BACKGROUND
:
979 case SPECTRAL_CHANSCAN
:
982 case SPECTRAL_MANUAL
:
987 return simple_read_from_buffer(user_buf
, count
, ppos
, mode
, len
);
990 static ssize_t
write_file_spec_scan_ctl(struct file
*file
,
991 const char __user
*user_buf
,
992 size_t count
, loff_t
*ppos
)
994 struct ath_softc
*sc
= file
->private_data
;
995 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
999 len
= min(count
, sizeof(buf
) - 1);
1000 if (copy_from_user(buf
, user_buf
, len
))
1005 if (strncmp("trigger", buf
, 7) == 0) {
1006 ath9k_spectral_scan_trigger(sc
->hw
);
1007 } else if (strncmp("background", buf
, 9) == 0) {
1008 ath9k_spectral_scan_config(sc
->hw
, SPECTRAL_BACKGROUND
);
1009 ath_dbg(common
, CONFIG
, "spectral scan: background mode enabled\n");
1010 } else if (strncmp("chanscan", buf
, 8) == 0) {
1011 ath9k_spectral_scan_config(sc
->hw
, SPECTRAL_CHANSCAN
);
1012 ath_dbg(common
, CONFIG
, "spectral scan: channel scan mode enabled\n");
1013 } else if (strncmp("manual", buf
, 6) == 0) {
1014 ath9k_spectral_scan_config(sc
->hw
, SPECTRAL_MANUAL
);
1015 ath_dbg(common
, CONFIG
, "spectral scan: manual mode enabled\n");
1016 } else if (strncmp("disable", buf
, 7) == 0) {
1017 ath9k_spectral_scan_config(sc
->hw
, SPECTRAL_DISABLED
);
1018 ath_dbg(common
, CONFIG
, "spectral scan: disabled\n");
1026 static const struct file_operations fops_spec_scan_ctl
= {
1027 .read
= read_file_spec_scan_ctl
,
1028 .write
= write_file_spec_scan_ctl
,
1029 .open
= simple_open
,
1030 .owner
= THIS_MODULE
,
1031 .llseek
= default_llseek
,
1034 static ssize_t
read_file_spectral_short_repeat(struct file
*file
,
1035 char __user
*user_buf
,
1036 size_t count
, loff_t
*ppos
)
1038 struct ath_softc
*sc
= file
->private_data
;
1042 len
= sprintf(buf
, "%d\n", sc
->spec_config
.short_repeat
);
1043 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1046 static ssize_t
write_file_spectral_short_repeat(struct file
*file
,
1047 const char __user
*user_buf
,
1048 size_t count
, loff_t
*ppos
)
1050 struct ath_softc
*sc
= file
->private_data
;
1055 len
= min(count
, sizeof(buf
) - 1);
1056 if (copy_from_user(buf
, user_buf
, len
))
1060 if (kstrtoul(buf
, 0, &val
))
1063 if (val
< 0 || val
> 1)
1066 sc
->spec_config
.short_repeat
= val
;
1070 static const struct file_operations fops_spectral_short_repeat
= {
1071 .read
= read_file_spectral_short_repeat
,
1072 .write
= write_file_spectral_short_repeat
,
1073 .open
= simple_open
,
1074 .owner
= THIS_MODULE
,
1075 .llseek
= default_llseek
,
1078 static ssize_t
read_file_spectral_count(struct file
*file
,
1079 char __user
*user_buf
,
1080 size_t count
, loff_t
*ppos
)
1082 struct ath_softc
*sc
= file
->private_data
;
1086 len
= sprintf(buf
, "%d\n", sc
->spec_config
.count
);
1087 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1090 static ssize_t
write_file_spectral_count(struct file
*file
,
1091 const char __user
*user_buf
,
1092 size_t count
, loff_t
*ppos
)
1094 struct ath_softc
*sc
= file
->private_data
;
1099 len
= min(count
, sizeof(buf
) - 1);
1100 if (copy_from_user(buf
, user_buf
, len
))
1104 if (kstrtoul(buf
, 0, &val
))
1107 if (val
< 0 || val
> 255)
1110 sc
->spec_config
.count
= val
;
1114 static const struct file_operations fops_spectral_count
= {
1115 .read
= read_file_spectral_count
,
1116 .write
= write_file_spectral_count
,
1117 .open
= simple_open
,
1118 .owner
= THIS_MODULE
,
1119 .llseek
= default_llseek
,
1122 static ssize_t
read_file_spectral_period(struct file
*file
,
1123 char __user
*user_buf
,
1124 size_t count
, loff_t
*ppos
)
1126 struct ath_softc
*sc
= file
->private_data
;
1130 len
= sprintf(buf
, "%d\n", sc
->spec_config
.period
);
1131 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1134 static ssize_t
write_file_spectral_period(struct file
*file
,
1135 const char __user
*user_buf
,
1136 size_t count
, loff_t
*ppos
)
1138 struct ath_softc
*sc
= file
->private_data
;
1143 len
= min(count
, sizeof(buf
) - 1);
1144 if (copy_from_user(buf
, user_buf
, len
))
1148 if (kstrtoul(buf
, 0, &val
))
1151 if (val
< 0 || val
> 255)
1154 sc
->spec_config
.period
= val
;
1158 static const struct file_operations fops_spectral_period
= {
1159 .read
= read_file_spectral_period
,
1160 .write
= write_file_spectral_period
,
1161 .open
= simple_open
,
1162 .owner
= THIS_MODULE
,
1163 .llseek
= default_llseek
,
1166 static ssize_t
read_file_spectral_fft_period(struct file
*file
,
1167 char __user
*user_buf
,
1168 size_t count
, loff_t
*ppos
)
1170 struct ath_softc
*sc
= file
->private_data
;
1174 len
= sprintf(buf
, "%d\n", sc
->spec_config
.fft_period
);
1175 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1178 static ssize_t
write_file_spectral_fft_period(struct file
*file
,
1179 const char __user
*user_buf
,
1180 size_t count
, loff_t
*ppos
)
1182 struct ath_softc
*sc
= file
->private_data
;
1187 len
= min(count
, sizeof(buf
) - 1);
1188 if (copy_from_user(buf
, user_buf
, len
))
1192 if (kstrtoul(buf
, 0, &val
))
1195 if (val
< 0 || val
> 15)
1198 sc
->spec_config
.fft_period
= val
;
1202 static const struct file_operations fops_spectral_fft_period
= {
1203 .read
= read_file_spectral_fft_period
,
1204 .write
= write_file_spectral_fft_period
,
1205 .open
= simple_open
,
1206 .owner
= THIS_MODULE
,
1207 .llseek
= default_llseek
,
1210 static struct dentry
*create_buf_file_handler(const char *filename
,
1211 struct dentry
*parent
,
1213 struct rchan_buf
*buf
,
1216 struct dentry
*buf_file
;
1218 buf_file
= debugfs_create_file(filename
, mode
, parent
, buf
,
1219 &relay_file_operations
);
1224 static int remove_buf_file_handler(struct dentry
*dentry
)
1226 debugfs_remove(dentry
);
1231 void ath_debug_send_fft_sample(struct ath_softc
*sc
,
1232 struct fft_sample_tlv
*fft_sample_tlv
)
1235 if (!sc
->rfs_chan_spec_scan
)
1238 length
= __be16_to_cpu(fft_sample_tlv
->length
) +
1239 sizeof(*fft_sample_tlv
);
1240 relay_write(sc
->rfs_chan_spec_scan
, fft_sample_tlv
, length
);
1243 static struct rchan_callbacks rfs_spec_scan_cb
= {
1244 .create_buf_file
= create_buf_file_handler
,
1245 .remove_buf_file
= remove_buf_file_handler
,
1249 static ssize_t
read_file_regidx(struct file
*file
, char __user
*user_buf
,
1250 size_t count
, loff_t
*ppos
)
1252 struct ath_softc
*sc
= file
->private_data
;
1256 len
= sprintf(buf
, "0x%08x\n", sc
->debug
.regidx
);
1257 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1260 static ssize_t
write_file_regidx(struct file
*file
, const char __user
*user_buf
,
1261 size_t count
, loff_t
*ppos
)
1263 struct ath_softc
*sc
= file
->private_data
;
1264 unsigned long regidx
;
1268 len
= min(count
, sizeof(buf
) - 1);
1269 if (copy_from_user(buf
, user_buf
, len
))
1273 if (kstrtoul(buf
, 0, ®idx
))
1276 sc
->debug
.regidx
= regidx
;
1280 static const struct file_operations fops_regidx
= {
1281 .read
= read_file_regidx
,
1282 .write
= write_file_regidx
,
1283 .open
= simple_open
,
1284 .owner
= THIS_MODULE
,
1285 .llseek
= default_llseek
,
1288 static ssize_t
read_file_regval(struct file
*file
, char __user
*user_buf
,
1289 size_t count
, loff_t
*ppos
)
1291 struct ath_softc
*sc
= file
->private_data
;
1292 struct ath_hw
*ah
= sc
->sc_ah
;
1297 ath9k_ps_wakeup(sc
);
1298 regval
= REG_READ_D(ah
, sc
->debug
.regidx
);
1299 ath9k_ps_restore(sc
);
1300 len
= sprintf(buf
, "0x%08x\n", regval
);
1301 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1304 static ssize_t
write_file_regval(struct file
*file
, const char __user
*user_buf
,
1305 size_t count
, loff_t
*ppos
)
1307 struct ath_softc
*sc
= file
->private_data
;
1308 struct ath_hw
*ah
= sc
->sc_ah
;
1309 unsigned long regval
;
1313 len
= min(count
, sizeof(buf
) - 1);
1314 if (copy_from_user(buf
, user_buf
, len
))
1318 if (kstrtoul(buf
, 0, ®val
))
1321 ath9k_ps_wakeup(sc
);
1322 REG_WRITE_D(ah
, sc
->debug
.regidx
, regval
);
1323 ath9k_ps_restore(sc
);
1327 static const struct file_operations fops_regval
= {
1328 .read
= read_file_regval
,
1329 .write
= write_file_regval
,
1330 .open
= simple_open
,
1331 .owner
= THIS_MODULE
,
1332 .llseek
= default_llseek
,
1335 #define REGDUMP_LINE_SIZE 20
1337 static int open_file_regdump(struct inode
*inode
, struct file
*file
)
1339 struct ath_softc
*sc
= inode
->i_private
;
1340 unsigned int len
= 0;
1343 unsigned long num_regs
, regdump_len
, max_reg_offset
;
1345 max_reg_offset
= AR_SREV_9300_20_OR_LATER(sc
->sc_ah
) ? 0x16bd4 : 0xb500;
1346 num_regs
= max_reg_offset
/ 4 + 1;
1347 regdump_len
= num_regs
* REGDUMP_LINE_SIZE
+ 1;
1348 buf
= vmalloc(regdump_len
);
1352 ath9k_ps_wakeup(sc
);
1353 for (i
= 0; i
< num_regs
; i
++)
1354 len
+= scnprintf(buf
+ len
, regdump_len
- len
,
1355 "0x%06x 0x%08x\n", i
<< 2, REG_READ(sc
->sc_ah
, i
<< 2));
1356 ath9k_ps_restore(sc
);
1358 file
->private_data
= buf
;
1363 static const struct file_operations fops_regdump
= {
1364 .open
= open_file_regdump
,
1365 .read
= ath9k_debugfs_read_buf
,
1366 .release
= ath9k_debugfs_release_buf
,
1367 .owner
= THIS_MODULE
,
1368 .llseek
= default_llseek
,/* read accesses f_pos */
1371 static ssize_t
read_file_dump_nfcal(struct file
*file
, char __user
*user_buf
,
1372 size_t count
, loff_t
*ppos
)
1374 struct ath_softc
*sc
= file
->private_data
;
1375 struct ath_hw
*ah
= sc
->sc_ah
;
1376 struct ath9k_nfcal_hist
*h
= sc
->caldata
.nfCalHist
;
1377 struct ath_common
*common
= ath9k_hw_common(ah
);
1378 struct ieee80211_conf
*conf
= &common
->hw
->conf
;
1379 u32 len
= 0, size
= 1500;
1383 u8 chainmask
= (ah
->rxchainmask
<< 3) | ah
->rxchainmask
;
1386 buf
= kzalloc(size
, GFP_KERNEL
);
1390 len
+= snprintf(buf
+ len
, size
- len
,
1391 "Channel Noise Floor : %d\n", ah
->noise
);
1392 len
+= snprintf(buf
+ len
, size
- len
,
1393 "Chain | privNF | # Readings | NF Readings\n");
1394 for (i
= 0; i
< NUM_NF_READINGS
; i
++) {
1395 if (!(chainmask
& (1 << i
)) ||
1396 ((i
>= AR5416_MAX_CHAINS
) && !conf_is_ht40(conf
)))
1399 nread
= AR_PHY_CCA_FILTERWINDOW_LENGTH
- h
[i
].invalidNFcount
;
1400 len
+= snprintf(buf
+ len
, size
- len
, " %d\t %d\t %d\t\t",
1401 i
, h
[i
].privNF
, nread
);
1402 for (j
= 0; j
< nread
; j
++)
1403 len
+= snprintf(buf
+ len
, size
- len
,
1404 " %d", h
[i
].nfCalBuffer
[j
]);
1405 len
+= snprintf(buf
+ len
, size
- len
, "\n");
1411 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1417 static const struct file_operations fops_dump_nfcal
= {
1418 .read
= read_file_dump_nfcal
,
1419 .open
= simple_open
,
1420 .owner
= THIS_MODULE
,
1421 .llseek
= default_llseek
,
1424 static ssize_t
read_file_base_eeprom(struct file
*file
, char __user
*user_buf
,
1425 size_t count
, loff_t
*ppos
)
1427 struct ath_softc
*sc
= file
->private_data
;
1428 struct ath_hw
*ah
= sc
->sc_ah
;
1429 u32 len
= 0, size
= 1500;
1433 buf
= kzalloc(size
, GFP_KERNEL
);
1437 len
= ah
->eep_ops
->dump_eeprom(ah
, true, buf
, len
, size
);
1439 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1445 static const struct file_operations fops_base_eeprom
= {
1446 .read
= read_file_base_eeprom
,
1447 .open
= simple_open
,
1448 .owner
= THIS_MODULE
,
1449 .llseek
= default_llseek
,
1452 static ssize_t
read_file_modal_eeprom(struct file
*file
, char __user
*user_buf
,
1453 size_t count
, loff_t
*ppos
)
1455 struct ath_softc
*sc
= file
->private_data
;
1456 struct ath_hw
*ah
= sc
->sc_ah
;
1457 u32 len
= 0, size
= 6000;
1461 buf
= kzalloc(size
, GFP_KERNEL
);
1465 len
= ah
->eep_ops
->dump_eeprom(ah
, false, buf
, len
, size
);
1467 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1473 static const struct file_operations fops_modal_eeprom
= {
1474 .read
= read_file_modal_eeprom
,
1475 .open
= simple_open
,
1476 .owner
= THIS_MODULE
,
1477 .llseek
= default_llseek
,
1480 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1481 static ssize_t
read_file_btcoex(struct file
*file
, char __user
*user_buf
,
1482 size_t count
, loff_t
*ppos
)
1484 struct ath_softc
*sc
= file
->private_data
;
1485 u32 len
= 0, size
= 1500;
1489 buf
= kzalloc(size
, GFP_KERNEL
);
1493 if (!sc
->sc_ah
->common
.btcoex_enabled
) {
1494 len
= snprintf(buf
, size
, "%s\n",
1495 "BTCOEX is disabled");
1499 len
= ath9k_dump_btcoex(sc
, buf
, size
);
1501 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1507 static const struct file_operations fops_btcoex
= {
1508 .read
= read_file_btcoex
,
1509 .open
= simple_open
,
1510 .owner
= THIS_MODULE
,
1511 .llseek
= default_llseek
,
1515 static ssize_t
read_file_node_stat(struct file
*file
, char __user
*user_buf
,
1516 size_t count
, loff_t
*ppos
)
1518 struct ath_node
*an
= file
->private_data
;
1519 struct ath_softc
*sc
= an
->sc
;
1520 struct ath_atx_tid
*tid
;
1521 struct ath_atx_ac
*ac
;
1522 struct ath_txq
*txq
;
1523 u32 len
= 0, size
= 4096;
1528 buf
= kzalloc(size
, GFP_KERNEL
);
1532 if (!an
->sta
->ht_cap
.ht_supported
) {
1533 len
= snprintf(buf
, size
, "%s\n",
1534 "HT not supported");
1538 len
= snprintf(buf
, size
, "Max-AMPDU: %d\n",
1540 len
+= snprintf(buf
+ len
, size
- len
, "MPDU Density: %d\n\n",
1543 len
+= snprintf(buf
+ len
, size
- len
,
1544 "%2s%7s\n", "AC", "SCHED");
1546 for (acno
= 0, ac
= &an
->ac
[acno
];
1547 acno
< IEEE80211_NUM_ACS
; acno
++, ac
++) {
1549 ath_txq_lock(sc
, txq
);
1550 len
+= snprintf(buf
+ len
, size
- len
,
1553 ath_txq_unlock(sc
, txq
);
1556 len
+= snprintf(buf
+ len
, size
- len
,
1557 "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n",
1558 "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE",
1559 "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED");
1561 for (tidno
= 0, tid
= &an
->tid
[tidno
];
1562 tidno
< IEEE80211_NUM_TIDS
; tidno
++, tid
++) {
1564 ath_txq_lock(sc
, txq
);
1565 len
+= snprintf(buf
+ len
, size
- len
,
1566 "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n",
1567 tid
->tidno
, tid
->seq_start
, tid
->seq_next
,
1568 tid
->baw_size
, tid
->baw_head
, tid
->baw_tail
,
1569 tid
->bar_index
, tid
->sched
, tid
->paused
);
1570 ath_txq_unlock(sc
, txq
);
1573 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1579 static const struct file_operations fops_node_stat
= {
1580 .read
= read_file_node_stat
,
1581 .open
= simple_open
,
1582 .owner
= THIS_MODULE
,
1583 .llseek
= default_llseek
,
1586 void ath9k_sta_add_debugfs(struct ieee80211_hw
*hw
,
1587 struct ieee80211_vif
*vif
,
1588 struct ieee80211_sta
*sta
,
1591 struct ath_node
*an
= (struct ath_node
*)sta
->drv_priv
;
1592 an
->node_stat
= debugfs_create_file("node_stat", S_IRUGO
,
1593 dir
, an
, &fops_node_stat
);
1596 void ath9k_sta_remove_debugfs(struct ieee80211_hw
*hw
,
1597 struct ieee80211_vif
*vif
,
1598 struct ieee80211_sta
*sta
,
1601 struct ath_node
*an
= (struct ath_node
*)sta
->drv_priv
;
1602 debugfs_remove(an
->node_stat
);
1605 /* Ethtool support for get-stats */
1607 #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
1608 static const char ath9k_gstrings_stats
[][ETH_GSTRING_LEN
] = {
1615 AMKSTR(d_tx_mpdus_queued
),
1616 AMKSTR(d_tx_mpdus_completed
),
1617 AMKSTR(d_tx_mpdu_xretries
),
1618 AMKSTR(d_tx_aggregates
),
1619 AMKSTR(d_tx_ampdus_queued_hw
),
1620 AMKSTR(d_tx_ampdus_queued_sw
),
1621 AMKSTR(d_tx_ampdus_completed
),
1622 AMKSTR(d_tx_ampdu_retries
),
1623 AMKSTR(d_tx_ampdu_xretries
),
1624 AMKSTR(d_tx_fifo_underrun
),
1625 AMKSTR(d_tx_op_exceeded
),
1626 AMKSTR(d_tx_timer_expiry
),
1627 AMKSTR(d_tx_desc_cfg_err
),
1628 AMKSTR(d_tx_data_underrun
),
1629 AMKSTR(d_tx_delim_underrun
),
1631 "d_rx_decrypt_crc_err",
1634 "d_rx_pre_delim_crc_err",
1635 "d_rx_post_delim_crc_err",
1636 "d_rx_decrypt_busy_err",
1638 "d_rx_phyerr_radar",
1639 "d_rx_phyerr_ofdm_timing",
1640 "d_rx_phyerr_cck_timing",
1643 #define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats)
1645 void ath9k_get_et_strings(struct ieee80211_hw
*hw
,
1646 struct ieee80211_vif
*vif
,
1649 if (sset
== ETH_SS_STATS
)
1650 memcpy(data
, *ath9k_gstrings_stats
,
1651 sizeof(ath9k_gstrings_stats
));
1654 int ath9k_get_et_sset_count(struct ieee80211_hw
*hw
,
1655 struct ieee80211_vif
*vif
, int sset
)
1657 if (sset
== ETH_SS_STATS
)
1658 return ATH9K_SSTATS_LEN
;
1662 #define AWDATA(elem) \
1664 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].elem; \
1665 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].elem; \
1666 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].elem; \
1667 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].elem; \
1670 #define AWDATA_RX(elem) \
1672 data[i++] = sc->debug.stats.rxstats.elem; \
1675 void ath9k_get_et_stats(struct ieee80211_hw
*hw
,
1676 struct ieee80211_vif
*vif
,
1677 struct ethtool_stats
*stats
, u64
*data
)
1679 struct ath_softc
*sc
= hw
->priv
;
1682 data
[i
++] = (sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_BE
)].tx_pkts_all
+
1683 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_BK
)].tx_pkts_all
+
1684 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_VI
)].tx_pkts_all
+
1685 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_VO
)].tx_pkts_all
);
1686 data
[i
++] = (sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_BE
)].tx_bytes_all
+
1687 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_BK
)].tx_bytes_all
+
1688 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_VI
)].tx_bytes_all
+
1689 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_VO
)].tx_bytes_all
);
1690 AWDATA_RX(rx_pkts_all
);
1691 AWDATA_RX(rx_bytes_all
);
1693 AWDATA(tx_pkts_all
);
1694 AWDATA(tx_bytes_all
);
1699 AWDATA(a_queued_hw
);
1700 AWDATA(a_queued_sw
);
1701 AWDATA(a_completed
);
1704 AWDATA(fifo_underrun
);
1707 AWDATA(desc_cfg_err
);
1708 AWDATA(data_underrun
);
1709 AWDATA(delim_underrun
);
1712 AWDATA_RX(decrypt_crc_err
);
1715 AWDATA_RX(pre_delim_crc_err
);
1716 AWDATA_RX(post_delim_crc_err
);
1717 AWDATA_RX(decrypt_busy_err
);
1719 AWDATA_RX(phy_err_stats
[ATH9K_PHYERR_RADAR
]);
1720 AWDATA_RX(phy_err_stats
[ATH9K_PHYERR_OFDM_TIMING
]);
1721 AWDATA_RX(phy_err_stats
[ATH9K_PHYERR_CCK_TIMING
]);
1723 WARN_ON(i
!= ATH9K_SSTATS_LEN
);
1726 void ath9k_deinit_debug(struct ath_softc
*sc
)
1728 if (config_enabled(CONFIG_ATH9K_DEBUGFS
) && sc
->rfs_chan_spec_scan
) {
1729 relay_close(sc
->rfs_chan_spec_scan
);
1730 sc
->rfs_chan_spec_scan
= NULL
;
1734 int ath9k_init_debug(struct ath_hw
*ah
)
1736 struct ath_common
*common
= ath9k_hw_common(ah
);
1737 struct ath_softc
*sc
= (struct ath_softc
*) common
->priv
;
1739 sc
->debug
.debugfs_phy
= debugfs_create_dir("ath9k",
1740 sc
->hw
->wiphy
->debugfsdir
);
1741 if (!sc
->debug
.debugfs_phy
)
1744 #ifdef CONFIG_ATH_DEBUG
1745 debugfs_create_file("debug", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1749 ath9k_dfs_init_debug(sc
);
1751 debugfs_create_file("dma", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1753 debugfs_create_file("interrupt", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1755 debugfs_create_file("xmit", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1757 debugfs_create_file("queues", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1759 debugfs_create_u32("qlen_bk", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1760 &sc
->tx
.txq_max_pending
[IEEE80211_AC_BK
]);
1761 debugfs_create_u32("qlen_be", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1762 &sc
->tx
.txq_max_pending
[IEEE80211_AC_BE
]);
1763 debugfs_create_u32("qlen_vi", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1764 &sc
->tx
.txq_max_pending
[IEEE80211_AC_VI
]);
1765 debugfs_create_u32("qlen_vo", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1766 &sc
->tx
.txq_max_pending
[IEEE80211_AC_VO
]);
1767 debugfs_create_file("misc", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1769 debugfs_create_file("reset", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1771 debugfs_create_file("recv", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1773 debugfs_create_file("rx_chainmask", S_IRUSR
| S_IWUSR
,
1774 sc
->debug
.debugfs_phy
, sc
, &fops_rx_chainmask
);
1775 debugfs_create_file("tx_chainmask", S_IRUSR
| S_IWUSR
,
1776 sc
->debug
.debugfs_phy
, sc
, &fops_tx_chainmask
);
1777 debugfs_create_file("ani", S_IRUSR
| S_IWUSR
,
1778 sc
->debug
.debugfs_phy
, sc
, &fops_ani
);
1779 debugfs_create_bool("paprd", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1780 &sc
->sc_ah
->config
.enable_paprd
);
1781 debugfs_create_file("regidx", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1783 debugfs_create_file("regval", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
1785 debugfs_create_bool("ignore_extcca", S_IRUSR
| S_IWUSR
,
1786 sc
->debug
.debugfs_phy
,
1787 &ah
->config
.cwm_ignore_extcca
);
1788 debugfs_create_file("regdump", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1790 debugfs_create_file("dump_nfcal", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1792 debugfs_create_file("base_eeprom", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1794 debugfs_create_file("modal_eeprom", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
1795 &fops_modal_eeprom
);
1796 sc
->rfs_chan_spec_scan
= relay_open("spectral_scan",
1797 sc
->debug
.debugfs_phy
,
1798 1024, 256, &rfs_spec_scan_cb
,
1800 debugfs_create_file("spectral_scan_ctl", S_IRUSR
| S_IWUSR
,
1801 sc
->debug
.debugfs_phy
, sc
,
1802 &fops_spec_scan_ctl
);
1803 debugfs_create_file("spectral_short_repeat", S_IRUSR
| S_IWUSR
,
1804 sc
->debug
.debugfs_phy
, sc
,
1805 &fops_spectral_short_repeat
);
1806 debugfs_create_file("spectral_count", S_IRUSR
| S_IWUSR
,
1807 sc
->debug
.debugfs_phy
, sc
, &fops_spectral_count
);
1808 debugfs_create_file("spectral_period", S_IRUSR
| S_IWUSR
,
1809 sc
->debug
.debugfs_phy
, sc
, &fops_spectral_period
);
1810 debugfs_create_file("spectral_fft_period", S_IRUSR
| S_IWUSR
,
1811 sc
->debug
.debugfs_phy
, sc
,
1812 &fops_spectral_fft_period
);
1813 debugfs_create_u32("gpio_mask", S_IRUSR
| S_IWUSR
,
1814 sc
->debug
.debugfs_phy
, &sc
->sc_ah
->gpio_mask
);
1815 debugfs_create_u32("gpio_val", S_IRUSR
| S_IWUSR
,
1816 sc
->debug
.debugfs_phy
, &sc
->sc_ah
->gpio_val
);
1817 debugfs_create_file("diversity", S_IRUSR
| S_IWUSR
,
1818 sc
->debug
.debugfs_phy
, sc
, &fops_ant_diversity
);
1819 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1820 debugfs_create_file("btcoex", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,