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 (strict_strtoul(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 (strict_strtoul(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 (strict_strtoul(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_disable_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
);
184 len
= sprintf(buf
, "%d\n", common
->disable_ani
);
185 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
188 static ssize_t
write_file_disable_ani(struct file
*file
,
189 const char __user
*user_buf
,
190 size_t count
, loff_t
*ppos
)
192 struct ath_softc
*sc
= file
->private_data
;
193 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
194 unsigned long disable_ani
;
198 len
= min(count
, sizeof(buf
) - 1);
199 if (copy_from_user(buf
, user_buf
, len
))
203 if (strict_strtoul(buf
, 0, &disable_ani
))
206 common
->disable_ani
= !!disable_ani
;
209 clear_bit(SC_OP_ANI_RUN
, &sc
->sc_flags
);
218 static const struct file_operations fops_disable_ani
= {
219 .read
= read_file_disable_ani
,
220 .write
= write_file_disable_ani
,
222 .owner
= THIS_MODULE
,
223 .llseek
= default_llseek
,
226 static ssize_t
read_file_ant_diversity(struct file
*file
, char __user
*user_buf
,
227 size_t count
, loff_t
*ppos
)
229 struct ath_softc
*sc
= file
->private_data
;
230 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
234 len
= sprintf(buf
, "%d\n", common
->antenna_diversity
);
235 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
238 static ssize_t
write_file_ant_diversity(struct file
*file
,
239 const char __user
*user_buf
,
240 size_t count
, loff_t
*ppos
)
242 struct ath_softc
*sc
= file
->private_data
;
243 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
244 unsigned long antenna_diversity
;
248 len
= min(count
, sizeof(buf
) - 1);
249 if (copy_from_user(buf
, user_buf
, len
))
252 if (!AR_SREV_9565(sc
->sc_ah
))
256 if (strict_strtoul(buf
, 0, &antenna_diversity
))
259 common
->antenna_diversity
= !!antenna_diversity
;
261 ath_ant_comb_update(sc
);
262 ath_dbg(common
, CONFIG
, "Antenna diversity: %d\n",
263 common
->antenna_diversity
);
264 ath9k_ps_restore(sc
);
269 static const struct file_operations fops_ant_diversity
= {
270 .read
= read_file_ant_diversity
,
271 .write
= write_file_ant_diversity
,
273 .owner
= THIS_MODULE
,
274 .llseek
= default_llseek
,
277 static ssize_t
read_file_dma(struct file
*file
, char __user
*user_buf
,
278 size_t count
, loff_t
*ppos
)
280 struct ath_softc
*sc
= file
->private_data
;
281 struct ath_hw
*ah
= sc
->sc_ah
;
284 unsigned int len
= 0;
285 u32 val
[ATH9K_NUM_DMA_DEBUG_REGS
];
286 int i
, qcuOffset
= 0, dcuOffset
= 0;
287 u32
*qcuBase
= &val
[0], *dcuBase
= &val
[4];
289 buf
= kmalloc(DMA_BUF_LEN
, GFP_KERNEL
);
295 REG_WRITE_D(ah
, AR_MACMISC
,
296 ((AR_MACMISC_DMA_OBS_LINE_8
<< AR_MACMISC_DMA_OBS_S
) |
297 (AR_MACMISC_MISC_OBS_BUS_1
<<
298 AR_MACMISC_MISC_OBS_BUS_MSB_S
)));
300 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
301 "Raw DMA Debug values:\n");
303 for (i
= 0; i
< ATH9K_NUM_DMA_DEBUG_REGS
; i
++) {
305 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "\n");
307 val
[i
] = REG_READ_D(ah
, AR_DMADBG_0
+ (i
* sizeof(u32
)));
308 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "%d: %08x ",
312 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "\n\n");
313 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
314 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
316 for (i
= 0; i
< ATH9K_NUM_QUEUES
; i
++, qcuOffset
+= 4, dcuOffset
+= 5) {
327 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
328 "%2d %2x %1x %2x %2x\n",
329 i
, (*qcuBase
& (0x7 << qcuOffset
)) >> qcuOffset
,
330 (*qcuBase
& (0x8 << qcuOffset
)) >> (qcuOffset
+ 3),
331 val
[2] & (0x7 << (i
* 3)) >> (i
* 3),
332 (*dcuBase
& (0x1f << dcuOffset
)) >> dcuOffset
);
335 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "\n");
337 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
338 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
339 (val
[3] & 0x003c0000) >> 18, (val
[3] & 0x03c00000) >> 22);
340 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
341 "qcu_complete state: %2x dcu_complete state: %2x\n",
342 (val
[3] & 0x1c000000) >> 26, (val
[6] & 0x3));
343 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
344 "dcu_arb state: %2x dcu_fp state: %2x\n",
345 (val
[5] & 0x06000000) >> 25, (val
[5] & 0x38000000) >> 27);
346 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
347 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
348 (val
[6] & 0x000003fc) >> 2, (val
[6] & 0x00000400) >> 10);
349 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
350 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
351 (val
[6] & 0x00000800) >> 11, (val
[6] & 0x00001000) >> 12);
352 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
353 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
354 (val
[6] & 0x0001e000) >> 13, (val
[6] & 0x001e0000) >> 17);
356 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
, "pcu observe: 0x%x\n",
357 REG_READ_D(ah
, AR_OBS_BUS_1
));
358 len
+= snprintf(buf
+ len
, DMA_BUF_LEN
- len
,
359 "AR_CR: 0x%x\n", REG_READ_D(ah
, AR_CR
));
361 ath9k_ps_restore(sc
);
363 if (len
> DMA_BUF_LEN
)
366 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
371 static const struct file_operations fops_dma
= {
372 .read
= read_file_dma
,
374 .owner
= THIS_MODULE
,
375 .llseek
= default_llseek
,
379 void ath_debug_stat_interrupt(struct ath_softc
*sc
, enum ath9k_int status
)
382 sc
->debug
.stats
.istats
.total
++;
383 if (sc
->sc_ah
->caps
.hw_caps
& ATH9K_HW_CAP_EDMA
) {
384 if (status
& ATH9K_INT_RXLP
)
385 sc
->debug
.stats
.istats
.rxlp
++;
386 if (status
& ATH9K_INT_RXHP
)
387 sc
->debug
.stats
.istats
.rxhp
++;
388 if (status
& ATH9K_INT_BB_WATCHDOG
)
389 sc
->debug
.stats
.istats
.bb_watchdog
++;
391 if (status
& ATH9K_INT_RX
)
392 sc
->debug
.stats
.istats
.rxok
++;
394 if (status
& ATH9K_INT_RXEOL
)
395 sc
->debug
.stats
.istats
.rxeol
++;
396 if (status
& ATH9K_INT_RXORN
)
397 sc
->debug
.stats
.istats
.rxorn
++;
398 if (status
& ATH9K_INT_TX
)
399 sc
->debug
.stats
.istats
.txok
++;
400 if (status
& ATH9K_INT_TXURN
)
401 sc
->debug
.stats
.istats
.txurn
++;
402 if (status
& ATH9K_INT_RXPHY
)
403 sc
->debug
.stats
.istats
.rxphyerr
++;
404 if (status
& ATH9K_INT_RXKCM
)
405 sc
->debug
.stats
.istats
.rx_keycache_miss
++;
406 if (status
& ATH9K_INT_SWBA
)
407 sc
->debug
.stats
.istats
.swba
++;
408 if (status
& ATH9K_INT_BMISS
)
409 sc
->debug
.stats
.istats
.bmiss
++;
410 if (status
& ATH9K_INT_BNR
)
411 sc
->debug
.stats
.istats
.bnr
++;
412 if (status
& ATH9K_INT_CST
)
413 sc
->debug
.stats
.istats
.cst
++;
414 if (status
& ATH9K_INT_GTT
)
415 sc
->debug
.stats
.istats
.gtt
++;
416 if (status
& ATH9K_INT_TIM
)
417 sc
->debug
.stats
.istats
.tim
++;
418 if (status
& ATH9K_INT_CABEND
)
419 sc
->debug
.stats
.istats
.cabend
++;
420 if (status
& ATH9K_INT_DTIMSYNC
)
421 sc
->debug
.stats
.istats
.dtimsync
++;
422 if (status
& ATH9K_INT_DTIM
)
423 sc
->debug
.stats
.istats
.dtim
++;
424 if (status
& ATH9K_INT_TSFOOR
)
425 sc
->debug
.stats
.istats
.tsfoor
++;
426 if (status
& ATH9K_INT_MCI
)
427 sc
->debug
.stats
.istats
.mci
++;
428 if (status
& ATH9K_INT_GENTIMER
)
429 sc
->debug
.stats
.istats
.gen_timer
++;
432 static ssize_t
read_file_interrupt(struct file
*file
, char __user
*user_buf
,
433 size_t count
, loff_t
*ppos
)
435 struct ath_softc
*sc
= file
->private_data
;
436 unsigned int len
= 0;
439 char *buf
= kmalloc(mxlen
, GFP_KERNEL
);
443 #define PR_IS(a, s) \
445 len += snprintf(buf + len, mxlen - len, \
447 sc->debug.stats.istats.s); \
450 if (sc
->sc_ah
->caps
.hw_caps
& ATH9K_HW_CAP_EDMA
) {
453 PR_IS("WATHDOG", bb_watchdog
);
457 PR_IS("RXEOL", rxeol
);
458 PR_IS("RXORN", rxorn
);
460 PR_IS("TXURN", txurn
);
462 PR_IS("RXPHY", rxphyerr
);
463 PR_IS("RXKCM", rx_keycache_miss
);
465 PR_IS("BMISS", bmiss
);
470 PR_IS("CABEND", cabend
);
471 PR_IS("DTIMSYNC", dtimsync
);
473 PR_IS("TSFOOR", tsfoor
);
475 PR_IS("GENTIMER", gen_timer
);
476 PR_IS("TOTAL", total
);
478 len
+= snprintf(buf
+ len
, mxlen
- len
,
479 "SYNC_CAUSE stats:\n");
481 PR_IS("Sync-All", sync_cause_all
);
482 PR_IS("RTC-IRQ", sync_rtc_irq
);
483 PR_IS("MAC-IRQ", sync_mac_irq
);
484 PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access
);
485 PR_IS("APB-Timeout", apb_timeout
);
486 PR_IS("PCI-Mode-Conflict", pci_mode_conflict
);
487 PR_IS("HOST1-Fatal", host1_fatal
);
488 PR_IS("HOST1-Perr", host1_perr
);
489 PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr
);
490 PR_IS("RADM-CPL-EP", radm_cpl_ep
);
491 PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort
);
492 PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort
);
493 PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err
);
494 PR_IS("RADM-CPL-Timeout", radm_cpl_timeout
);
495 PR_IS("Local-Bus-Timeout", local_timeout
);
496 PR_IS("PM-Access", pm_access
);
497 PR_IS("MAC-Awake", mac_awake
);
498 PR_IS("MAC-Asleep", mac_asleep
);
499 PR_IS("MAC-Sleep-Access", mac_sleep_access
);
504 rv
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
509 static const struct file_operations fops_interrupt
= {
510 .read
= read_file_interrupt
,
512 .owner
= THIS_MODULE
,
513 .llseek
= default_llseek
,
516 static ssize_t
read_file_xmit(struct file
*file
, char __user
*user_buf
,
517 size_t count
, loff_t
*ppos
)
519 struct ath_softc
*sc
= file
->private_data
;
521 unsigned int len
= 0, size
= 2048;
524 buf
= kzalloc(size
, GFP_KERNEL
);
528 len
+= sprintf(buf
, "%30s %10s%10s%10s\n\n",
529 "BE", "BK", "VI", "VO");
531 PR("MPDUs Queued: ", queued
);
532 PR("MPDUs Completed: ", completed
);
533 PR("MPDUs XRetried: ", xretries
);
534 PR("Aggregates: ", a_aggr
);
535 PR("AMPDUs Queued HW:", a_queued_hw
);
536 PR("AMPDUs Queued SW:", a_queued_sw
);
537 PR("AMPDUs Completed:", a_completed
);
538 PR("AMPDUs Retried: ", a_retries
);
539 PR("AMPDUs XRetried: ", a_xretries
);
540 PR("TXERR Filtered: ", txerr_filtered
);
541 PR("FIFO Underrun: ", fifo_underrun
);
542 PR("TXOP Exceeded: ", xtxop
);
543 PR("TXTIMER Expiry: ", timer_exp
);
544 PR("DESC CFG Error: ", desc_cfg_err
);
545 PR("DATA Underrun: ", data_underrun
);
546 PR("DELIM Underrun: ", delim_underrun
);
547 PR("TX-Pkts-All: ", tx_pkts_all
);
548 PR("TX-Bytes-All: ", tx_bytes_all
);
549 PR("HW-put-tx-buf: ", puttxbuf
);
550 PR("HW-tx-start: ", txstart
);
551 PR("HW-tx-proc-desc: ", txprocdesc
);
552 PR("TX-Failed: ", txfailed
);
557 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
563 static ssize_t
read_file_queues(struct file
*file
, char __user
*user_buf
,
564 size_t count
, loff_t
*ppos
)
566 struct ath_softc
*sc
= file
->private_data
;
569 unsigned int len
= 0, size
= 1024;
572 char *qname
[4] = {"VO", "VI", "BE", "BK"};
574 buf
= kzalloc(size
, GFP_KERNEL
);
578 for (i
= 0; i
< IEEE80211_NUM_ACS
; i
++) {
579 txq
= sc
->tx
.txq_map
[i
];
580 len
+= snprintf(buf
+ len
, size
- len
, "(%s): ", qname
[i
]);
582 ath_txq_lock(sc
, txq
);
584 len
+= snprintf(buf
+ len
, size
- len
, "%s: %d ",
585 "qnum", txq
->axq_qnum
);
586 len
+= snprintf(buf
+ len
, size
- len
, "%s: %2d ",
587 "qdepth", txq
->axq_depth
);
588 len
+= snprintf(buf
+ len
, size
- len
, "%s: %2d ",
589 "ampdu-depth", txq
->axq_ampdu_depth
);
590 len
+= snprintf(buf
+ len
, size
- len
, "%s: %3d ",
591 "pending", txq
->pending_frames
);
592 len
+= snprintf(buf
+ len
, size
- len
, "%s: %d\n",
593 "stopped", txq
->stopped
);
595 ath_txq_unlock(sc
, txq
);
601 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
607 static ssize_t
read_file_misc(struct file
*file
, char __user
*user_buf
,
608 size_t count
, loff_t
*ppos
)
610 struct ath_softc
*sc
= file
->private_data
;
611 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
612 struct ieee80211_hw
*hw
= sc
->hw
;
613 struct ath9k_vif_iter_data iter_data
;
615 unsigned int len
= 0;
620 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
621 "BSSID: %pM\n", common
->curbssid
);
622 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
623 "BSSID-MASK: %pM\n", common
->bssidmask
);
624 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
625 "OPMODE: %s\n", ath_opmode_to_string(sc
->sc_ah
->opmode
));
628 rxfilter
= ath9k_hw_getrxfilter(sc
->sc_ah
);
629 ath9k_ps_restore(sc
);
631 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
632 "RXFILTER: 0x%x", rxfilter
);
634 if (rxfilter
& ATH9K_RX_FILTER_UCAST
)
635 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " UCAST");
636 if (rxfilter
& ATH9K_RX_FILTER_MCAST
)
637 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " MCAST");
638 if (rxfilter
& ATH9K_RX_FILTER_BCAST
)
639 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " BCAST");
640 if (rxfilter
& ATH9K_RX_FILTER_CONTROL
)
641 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " CONTROL");
642 if (rxfilter
& ATH9K_RX_FILTER_BEACON
)
643 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " BEACON");
644 if (rxfilter
& ATH9K_RX_FILTER_PROM
)
645 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PROM");
646 if (rxfilter
& ATH9K_RX_FILTER_PROBEREQ
)
647 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PROBEREQ");
648 if (rxfilter
& ATH9K_RX_FILTER_PHYERR
)
649 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PHYERR");
650 if (rxfilter
& ATH9K_RX_FILTER_MYBEACON
)
651 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " MYBEACON");
652 if (rxfilter
& ATH9K_RX_FILTER_COMP_BAR
)
653 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " COMP_BAR");
654 if (rxfilter
& ATH9K_RX_FILTER_PSPOLL
)
655 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PSPOLL");
656 if (rxfilter
& ATH9K_RX_FILTER_PHYRADAR
)
657 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " PHYRADAR");
658 if (rxfilter
& ATH9K_RX_FILTER_MCAST_BCAST_ALL
)
659 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " MCAST_BCAST_ALL");
660 if (rxfilter
& ATH9K_RX_FILTER_CONTROL_WRAPPER
)
661 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " CONTROL_WRAPPER");
663 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "\n");
665 reg
= sc
->sc_ah
->imask
;
667 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "INTERRUPT-MASK: 0x%x", reg
);
669 if (reg
& ATH9K_INT_SWBA
)
670 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " SWBA");
671 if (reg
& ATH9K_INT_BMISS
)
672 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " BMISS");
673 if (reg
& ATH9K_INT_CST
)
674 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " CST");
675 if (reg
& ATH9K_INT_RX
)
676 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " RX");
677 if (reg
& ATH9K_INT_RXHP
)
678 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " RXHP");
679 if (reg
& ATH9K_INT_RXLP
)
680 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " RXLP");
681 if (reg
& ATH9K_INT_BB_WATCHDOG
)
682 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, " BB_WATCHDOG");
684 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "\n");
686 ath9k_calculate_iter_data(hw
, NULL
, &iter_data
);
688 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
689 "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i"
690 " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n",
691 iter_data
.naps
, iter_data
.nstations
, iter_data
.nmeshes
,
692 iter_data
.nwds
, iter_data
.nadhocs
,
693 sc
->nvifs
, sc
->nbcnvifs
);
695 if (len
> sizeof(buf
))
698 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
702 static ssize_t
read_file_reset(struct file
*file
, char __user
*user_buf
,
703 size_t count
, loff_t
*ppos
)
705 struct ath_softc
*sc
= file
->private_data
;
707 unsigned int len
= 0;
709 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
710 "%17s: %2d\n", "Baseband Hang",
711 sc
->debug
.stats
.reset
[RESET_TYPE_BB_HANG
]);
712 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
713 "%17s: %2d\n", "Baseband Watchdog",
714 sc
->debug
.stats
.reset
[RESET_TYPE_BB_WATCHDOG
]);
715 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
716 "%17s: %2d\n", "Fatal HW Error",
717 sc
->debug
.stats
.reset
[RESET_TYPE_FATAL_INT
]);
718 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
719 "%17s: %2d\n", "TX HW error",
720 sc
->debug
.stats
.reset
[RESET_TYPE_TX_ERROR
]);
721 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
722 "%17s: %2d\n", "TX Path Hang",
723 sc
->debug
.stats
.reset
[RESET_TYPE_TX_HANG
]);
724 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
725 "%17s: %2d\n", "PLL RX Hang",
726 sc
->debug
.stats
.reset
[RESET_TYPE_PLL_HANG
]);
727 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
728 "%17s: %2d\n", "MCI Reset",
729 sc
->debug
.stats
.reset
[RESET_TYPE_MCI
]);
731 if (len
> sizeof(buf
))
734 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
737 void ath_debug_stat_tx(struct ath_softc
*sc
, struct ath_buf
*bf
,
738 struct ath_tx_status
*ts
, struct ath_txq
*txq
,
741 #define TX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].ts\
743 int qnum
= txq
->axq_qnum
;
745 TX_STAT_INC(qnum
, tx_pkts_all
);
746 sc
->debug
.stats
.txstats
[qnum
].tx_bytes_all
+= bf
->bf_mpdu
->len
;
748 if (bf_isampdu(bf
)) {
749 if (flags
& ATH_TX_ERROR
)
750 TX_STAT_INC(qnum
, a_xretries
);
752 TX_STAT_INC(qnum
, a_completed
);
754 if (ts
->ts_status
& ATH9K_TXERR_XRETRY
)
755 TX_STAT_INC(qnum
, xretries
);
757 TX_STAT_INC(qnum
, completed
);
760 if (ts
->ts_status
& ATH9K_TXERR_FILT
)
761 TX_STAT_INC(qnum
, txerr_filtered
);
762 if (ts
->ts_status
& ATH9K_TXERR_FIFO
)
763 TX_STAT_INC(qnum
, fifo_underrun
);
764 if (ts
->ts_status
& ATH9K_TXERR_XTXOP
)
765 TX_STAT_INC(qnum
, xtxop
);
766 if (ts
->ts_status
& ATH9K_TXERR_TIMER_EXPIRED
)
767 TX_STAT_INC(qnum
, timer_exp
);
768 if (ts
->ts_flags
& ATH9K_TX_DESC_CFG_ERR
)
769 TX_STAT_INC(qnum
, desc_cfg_err
);
770 if (ts
->ts_flags
& ATH9K_TX_DATA_UNDERRUN
)
771 TX_STAT_INC(qnum
, data_underrun
);
772 if (ts
->ts_flags
& ATH9K_TX_DELIM_UNDERRUN
)
773 TX_STAT_INC(qnum
, delim_underrun
);
775 #ifdef CONFIG_ATH9K_MAC_DEBUG
776 spin_lock(&sc
->debug
.samp_lock
);
777 TX_SAMP_DBG(jiffies
) = jiffies
;
778 TX_SAMP_DBG(rssi_ctl0
) = ts
->ts_rssi_ctl0
;
779 TX_SAMP_DBG(rssi_ctl1
) = ts
->ts_rssi_ctl1
;
780 TX_SAMP_DBG(rssi_ctl2
) = ts
->ts_rssi_ctl2
;
781 TX_SAMP_DBG(rssi_ext0
) = ts
->ts_rssi_ext0
;
782 TX_SAMP_DBG(rssi_ext1
) = ts
->ts_rssi_ext1
;
783 TX_SAMP_DBG(rssi_ext2
) = ts
->ts_rssi_ext2
;
784 TX_SAMP_DBG(rateindex
) = ts
->ts_rateindex
;
785 TX_SAMP_DBG(isok
) = !!(ts
->ts_status
& ATH9K_TXERR_MASK
);
786 TX_SAMP_DBG(rts_fail_cnt
) = ts
->ts_shortretry
;
787 TX_SAMP_DBG(data_fail_cnt
) = ts
->ts_longretry
;
788 TX_SAMP_DBG(rssi
) = ts
->ts_rssi
;
789 TX_SAMP_DBG(tid
) = ts
->tid
;
790 TX_SAMP_DBG(qid
) = ts
->qid
;
792 if (ts
->ts_flags
& ATH9K_TX_BA
) {
793 TX_SAMP_DBG(ba_low
) = ts
->ba_low
;
794 TX_SAMP_DBG(ba_high
) = ts
->ba_high
;
796 TX_SAMP_DBG(ba_low
) = 0;
797 TX_SAMP_DBG(ba_high
) = 0;
800 sc
->debug
.tsidx
= (sc
->debug
.tsidx
+ 1) % ATH_DBG_MAX_SAMPLES
;
801 spin_unlock(&sc
->debug
.samp_lock
);
807 static const struct file_operations fops_xmit
= {
808 .read
= read_file_xmit
,
810 .owner
= THIS_MODULE
,
811 .llseek
= default_llseek
,
814 static const struct file_operations fops_queues
= {
815 .read
= read_file_queues
,
817 .owner
= THIS_MODULE
,
818 .llseek
= default_llseek
,
821 static const struct file_operations fops_misc
= {
822 .read
= read_file_misc
,
824 .owner
= THIS_MODULE
,
825 .llseek
= default_llseek
,
828 static const struct file_operations fops_reset
= {
829 .read
= read_file_reset
,
831 .owner
= THIS_MODULE
,
832 .llseek
= default_llseek
,
835 static ssize_t
read_file_recv(struct file
*file
, char __user
*user_buf
,
836 size_t count
, loff_t
*ppos
)
838 #define PHY_ERR(s, p) \
839 len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \
840 sc->debug.stats.rxstats.phy_err_stats[p]);
842 #define RXS_ERR(s, e) \
844 len += snprintf(buf + len, size - len, \
845 "%22s : %10u\n", s, \
846 sc->debug.stats.rxstats.e); \
849 struct ath_softc
*sc
= file
->private_data
;
851 unsigned int len
= 0, size
= 1600;
854 buf
= kzalloc(size
, GFP_KERNEL
);
858 RXS_ERR("CRC ERR", crc_err
);
859 RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err
);
860 RXS_ERR("PHY ERR", phy_err
);
861 RXS_ERR("MIC ERR", mic_err
);
862 RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err
);
863 RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err
);
864 RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err
);
865 RXS_ERR("RX-LENGTH-ERR", rx_len_err
);
866 RXS_ERR("RX-OOM-ERR", rx_oom_err
);
867 RXS_ERR("RX-RATE-ERR", rx_rate_err
);
868 RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err
);
870 PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN
);
871 PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING
);
872 PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY
);
873 PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE
);
874 PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH
);
875 PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR
);
876 PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE
);
877 PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR
);
878 PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING
);
879 PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY
);
880 PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL
);
881 PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL
);
882 PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP
);
883 PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE
);
884 PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART
);
885 PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT
);
886 PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING
);
887 PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC
);
888 PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL
);
889 PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE
);
890 PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART
);
891 PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL
);
892 PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP
);
893 PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR
);
894 PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL
);
895 PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL
);
897 RXS_ERR("RX-Pkts-All", rx_pkts_all
);
898 RXS_ERR("RX-Bytes-All", rx_bytes_all
);
899 RXS_ERR("RX-Beacons", rx_beacons
);
900 RXS_ERR("RX-Frags", rx_frags
);
901 RXS_ERR("RX-Spectral", rx_spectral
);
906 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
915 void ath_debug_stat_rx(struct ath_softc
*sc
, struct ath_rx_status
*rs
)
917 #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
918 #define RX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].rs\
921 RX_STAT_INC(rx_pkts_all
);
922 sc
->debug
.stats
.rxstats
.rx_bytes_all
+= rs
->rs_datalen
;
924 if (rs
->rs_status
& ATH9K_RXERR_CRC
)
925 RX_STAT_INC(crc_err
);
926 if (rs
->rs_status
& ATH9K_RXERR_DECRYPT
)
927 RX_STAT_INC(decrypt_crc_err
);
928 if (rs
->rs_status
& ATH9K_RXERR_MIC
)
929 RX_STAT_INC(mic_err
);
930 if (rs
->rs_status
& ATH9K_RX_DELIM_CRC_PRE
)
931 RX_STAT_INC(pre_delim_crc_err
);
932 if (rs
->rs_status
& ATH9K_RX_DELIM_CRC_POST
)
933 RX_STAT_INC(post_delim_crc_err
);
934 if (rs
->rs_status
& ATH9K_RX_DECRYPT_BUSY
)
935 RX_STAT_INC(decrypt_busy_err
);
937 if (rs
->rs_status
& ATH9K_RXERR_PHY
) {
938 RX_STAT_INC(phy_err
);
939 if (rs
->rs_phyerr
< ATH9K_PHYERR_MAX
)
940 RX_PHY_ERR_INC(rs
->rs_phyerr
);
943 #ifdef CONFIG_ATH9K_MAC_DEBUG
944 spin_lock(&sc
->debug
.samp_lock
);
945 RX_SAMP_DBG(jiffies
) = jiffies
;
946 RX_SAMP_DBG(rssi_ctl0
) = rs
->rs_rssi_ctl0
;
947 RX_SAMP_DBG(rssi_ctl1
) = rs
->rs_rssi_ctl1
;
948 RX_SAMP_DBG(rssi_ctl2
) = rs
->rs_rssi_ctl2
;
949 RX_SAMP_DBG(rssi_ext0
) = rs
->rs_rssi_ext0
;
950 RX_SAMP_DBG(rssi_ext1
) = rs
->rs_rssi_ext1
;
951 RX_SAMP_DBG(rssi_ext2
) = rs
->rs_rssi_ext2
;
952 RX_SAMP_DBG(antenna
) = rs
->rs_antenna
;
953 RX_SAMP_DBG(rssi
) = rs
->rs_rssi
;
954 RX_SAMP_DBG(rate
) = rs
->rs_rate
;
955 RX_SAMP_DBG(is_mybeacon
) = rs
->is_mybeacon
;
957 sc
->debug
.rsidx
= (sc
->debug
.rsidx
+ 1) % ATH_DBG_MAX_SAMPLES
;
958 spin_unlock(&sc
->debug
.samp_lock
);
962 #undef RX_PHY_ERR_INC
966 static const struct file_operations fops_recv
= {
967 .read
= read_file_recv
,
969 .owner
= THIS_MODULE
,
970 .llseek
= default_llseek
,
973 static ssize_t
read_file_spec_scan_ctl(struct file
*file
, char __user
*user_buf
,
974 size_t count
, loff_t
*ppos
)
976 struct ath_softc
*sc
= file
->private_data
;
980 switch (sc
->spectral_mode
) {
981 case SPECTRAL_DISABLED
:
984 case SPECTRAL_BACKGROUND
:
987 case SPECTRAL_CHANSCAN
:
990 case SPECTRAL_MANUAL
:
995 return simple_read_from_buffer(user_buf
, count
, ppos
, mode
, len
);
998 static ssize_t
write_file_spec_scan_ctl(struct file
*file
,
999 const char __user
*user_buf
,
1000 size_t count
, loff_t
*ppos
)
1002 struct ath_softc
*sc
= file
->private_data
;
1003 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
1007 len
= min(count
, sizeof(buf
) - 1);
1008 if (copy_from_user(buf
, user_buf
, len
))
1013 if (strncmp("trigger", buf
, 7) == 0) {
1014 ath9k_spectral_scan_trigger(sc
->hw
);
1015 } else if (strncmp("background", buf
, 9) == 0) {
1016 ath9k_spectral_scan_config(sc
->hw
, SPECTRAL_BACKGROUND
);
1017 ath_dbg(common
, CONFIG
, "spectral scan: background mode enabled\n");
1018 } else if (strncmp("chanscan", buf
, 8) == 0) {
1019 ath9k_spectral_scan_config(sc
->hw
, SPECTRAL_CHANSCAN
);
1020 ath_dbg(common
, CONFIG
, "spectral scan: channel scan mode enabled\n");
1021 } else if (strncmp("manual", buf
, 6) == 0) {
1022 ath9k_spectral_scan_config(sc
->hw
, SPECTRAL_MANUAL
);
1023 ath_dbg(common
, CONFIG
, "spectral scan: manual mode enabled\n");
1024 } else if (strncmp("disable", buf
, 7) == 0) {
1025 ath9k_spectral_scan_config(sc
->hw
, SPECTRAL_DISABLED
);
1026 ath_dbg(common
, CONFIG
, "spectral scan: disabled\n");
1034 static const struct file_operations fops_spec_scan_ctl
= {
1035 .read
= read_file_spec_scan_ctl
,
1036 .write
= write_file_spec_scan_ctl
,
1037 .open
= simple_open
,
1038 .owner
= THIS_MODULE
,
1039 .llseek
= default_llseek
,
1042 static ssize_t
read_file_spectral_short_repeat(struct file
*file
,
1043 char __user
*user_buf
,
1044 size_t count
, loff_t
*ppos
)
1046 struct ath_softc
*sc
= file
->private_data
;
1050 len
= sprintf(buf
, "%d\n", sc
->spec_config
.short_repeat
);
1051 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1054 static ssize_t
write_file_spectral_short_repeat(struct file
*file
,
1055 const char __user
*user_buf
,
1056 size_t count
, loff_t
*ppos
)
1058 struct ath_softc
*sc
= file
->private_data
;
1063 len
= min(count
, sizeof(buf
) - 1);
1064 if (copy_from_user(buf
, user_buf
, len
))
1068 if (kstrtoul(buf
, 0, &val
))
1071 if (val
< 0 || val
> 1)
1074 sc
->spec_config
.short_repeat
= val
;
1078 static const struct file_operations fops_spectral_short_repeat
= {
1079 .read
= read_file_spectral_short_repeat
,
1080 .write
= write_file_spectral_short_repeat
,
1081 .open
= simple_open
,
1082 .owner
= THIS_MODULE
,
1083 .llseek
= default_llseek
,
1086 static ssize_t
read_file_spectral_count(struct file
*file
,
1087 char __user
*user_buf
,
1088 size_t count
, loff_t
*ppos
)
1090 struct ath_softc
*sc
= file
->private_data
;
1094 len
= sprintf(buf
, "%d\n", sc
->spec_config
.count
);
1095 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1098 static ssize_t
write_file_spectral_count(struct file
*file
,
1099 const char __user
*user_buf
,
1100 size_t count
, loff_t
*ppos
)
1102 struct ath_softc
*sc
= file
->private_data
;
1107 len
= min(count
, sizeof(buf
) - 1);
1108 if (copy_from_user(buf
, user_buf
, len
))
1112 if (kstrtoul(buf
, 0, &val
))
1115 if (val
< 0 || val
> 255)
1118 sc
->spec_config
.count
= val
;
1122 static const struct file_operations fops_spectral_count
= {
1123 .read
= read_file_spectral_count
,
1124 .write
= write_file_spectral_count
,
1125 .open
= simple_open
,
1126 .owner
= THIS_MODULE
,
1127 .llseek
= default_llseek
,
1130 static ssize_t
read_file_spectral_period(struct file
*file
,
1131 char __user
*user_buf
,
1132 size_t count
, loff_t
*ppos
)
1134 struct ath_softc
*sc
= file
->private_data
;
1138 len
= sprintf(buf
, "%d\n", sc
->spec_config
.period
);
1139 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1142 static ssize_t
write_file_spectral_period(struct file
*file
,
1143 const char __user
*user_buf
,
1144 size_t count
, loff_t
*ppos
)
1146 struct ath_softc
*sc
= file
->private_data
;
1151 len
= min(count
, sizeof(buf
) - 1);
1152 if (copy_from_user(buf
, user_buf
, len
))
1156 if (kstrtoul(buf
, 0, &val
))
1159 if (val
< 0 || val
> 255)
1162 sc
->spec_config
.period
= val
;
1166 static const struct file_operations fops_spectral_period
= {
1167 .read
= read_file_spectral_period
,
1168 .write
= write_file_spectral_period
,
1169 .open
= simple_open
,
1170 .owner
= THIS_MODULE
,
1171 .llseek
= default_llseek
,
1174 static ssize_t
read_file_spectral_fft_period(struct file
*file
,
1175 char __user
*user_buf
,
1176 size_t count
, loff_t
*ppos
)
1178 struct ath_softc
*sc
= file
->private_data
;
1182 len
= sprintf(buf
, "%d\n", sc
->spec_config
.fft_period
);
1183 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1186 static ssize_t
write_file_spectral_fft_period(struct file
*file
,
1187 const char __user
*user_buf
,
1188 size_t count
, loff_t
*ppos
)
1190 struct ath_softc
*sc
= file
->private_data
;
1195 len
= min(count
, sizeof(buf
) - 1);
1196 if (copy_from_user(buf
, user_buf
, len
))
1200 if (kstrtoul(buf
, 0, &val
))
1203 if (val
< 0 || val
> 15)
1206 sc
->spec_config
.fft_period
= val
;
1210 static const struct file_operations fops_spectral_fft_period
= {
1211 .read
= read_file_spectral_fft_period
,
1212 .write
= write_file_spectral_fft_period
,
1213 .open
= simple_open
,
1214 .owner
= THIS_MODULE
,
1215 .llseek
= default_llseek
,
1218 static struct dentry
*create_buf_file_handler(const char *filename
,
1219 struct dentry
*parent
,
1221 struct rchan_buf
*buf
,
1224 struct dentry
*buf_file
;
1226 buf_file
= debugfs_create_file(filename
, mode
, parent
, buf
,
1227 &relay_file_operations
);
1232 static int remove_buf_file_handler(struct dentry
*dentry
)
1234 debugfs_remove(dentry
);
1239 void ath_debug_send_fft_sample(struct ath_softc
*sc
,
1240 struct fft_sample_tlv
*fft_sample_tlv
)
1243 if (!sc
->rfs_chan_spec_scan
)
1246 length
= __be16_to_cpu(fft_sample_tlv
->length
) +
1247 sizeof(*fft_sample_tlv
);
1248 relay_write(sc
->rfs_chan_spec_scan
, fft_sample_tlv
, length
);
1251 static struct rchan_callbacks rfs_spec_scan_cb
= {
1252 .create_buf_file
= create_buf_file_handler
,
1253 .remove_buf_file
= remove_buf_file_handler
,
1257 static ssize_t
read_file_regidx(struct file
*file
, char __user
*user_buf
,
1258 size_t count
, loff_t
*ppos
)
1260 struct ath_softc
*sc
= file
->private_data
;
1264 len
= sprintf(buf
, "0x%08x\n", sc
->debug
.regidx
);
1265 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1268 static ssize_t
write_file_regidx(struct file
*file
, const char __user
*user_buf
,
1269 size_t count
, loff_t
*ppos
)
1271 struct ath_softc
*sc
= file
->private_data
;
1272 unsigned long regidx
;
1276 len
= min(count
, sizeof(buf
) - 1);
1277 if (copy_from_user(buf
, user_buf
, len
))
1281 if (strict_strtoul(buf
, 0, ®idx
))
1284 sc
->debug
.regidx
= regidx
;
1288 static const struct file_operations fops_regidx
= {
1289 .read
= read_file_regidx
,
1290 .write
= write_file_regidx
,
1291 .open
= simple_open
,
1292 .owner
= THIS_MODULE
,
1293 .llseek
= default_llseek
,
1296 static ssize_t
read_file_regval(struct file
*file
, char __user
*user_buf
,
1297 size_t count
, loff_t
*ppos
)
1299 struct ath_softc
*sc
= file
->private_data
;
1300 struct ath_hw
*ah
= sc
->sc_ah
;
1305 ath9k_ps_wakeup(sc
);
1306 regval
= REG_READ_D(ah
, sc
->debug
.regidx
);
1307 ath9k_ps_restore(sc
);
1308 len
= sprintf(buf
, "0x%08x\n", regval
);
1309 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1312 static ssize_t
write_file_regval(struct file
*file
, const char __user
*user_buf
,
1313 size_t count
, loff_t
*ppos
)
1315 struct ath_softc
*sc
= file
->private_data
;
1316 struct ath_hw
*ah
= sc
->sc_ah
;
1317 unsigned long regval
;
1321 len
= min(count
, sizeof(buf
) - 1);
1322 if (copy_from_user(buf
, user_buf
, len
))
1326 if (strict_strtoul(buf
, 0, ®val
))
1329 ath9k_ps_wakeup(sc
);
1330 REG_WRITE_D(ah
, sc
->debug
.regidx
, regval
);
1331 ath9k_ps_restore(sc
);
1335 static const struct file_operations fops_regval
= {
1336 .read
= read_file_regval
,
1337 .write
= write_file_regval
,
1338 .open
= simple_open
,
1339 .owner
= THIS_MODULE
,
1340 .llseek
= default_llseek
,
1343 #define REGDUMP_LINE_SIZE 20
1345 static int open_file_regdump(struct inode
*inode
, struct file
*file
)
1347 struct ath_softc
*sc
= inode
->i_private
;
1348 unsigned int len
= 0;
1351 unsigned long num_regs
, regdump_len
, max_reg_offset
;
1353 max_reg_offset
= AR_SREV_9300_20_OR_LATER(sc
->sc_ah
) ? 0x16bd4 : 0xb500;
1354 num_regs
= max_reg_offset
/ 4 + 1;
1355 regdump_len
= num_regs
* REGDUMP_LINE_SIZE
+ 1;
1356 buf
= vmalloc(regdump_len
);
1360 ath9k_ps_wakeup(sc
);
1361 for (i
= 0; i
< num_regs
; i
++)
1362 len
+= scnprintf(buf
+ len
, regdump_len
- len
,
1363 "0x%06x 0x%08x\n", i
<< 2, REG_READ(sc
->sc_ah
, i
<< 2));
1364 ath9k_ps_restore(sc
);
1366 file
->private_data
= buf
;
1371 static const struct file_operations fops_regdump
= {
1372 .open
= open_file_regdump
,
1373 .read
= ath9k_debugfs_read_buf
,
1374 .release
= ath9k_debugfs_release_buf
,
1375 .owner
= THIS_MODULE
,
1376 .llseek
= default_llseek
,/* read accesses f_pos */
1379 static ssize_t
read_file_dump_nfcal(struct file
*file
, char __user
*user_buf
,
1380 size_t count
, loff_t
*ppos
)
1382 struct ath_softc
*sc
= file
->private_data
;
1383 struct ath_hw
*ah
= sc
->sc_ah
;
1384 struct ath9k_nfcal_hist
*h
= sc
->caldata
.nfCalHist
;
1385 struct ath_common
*common
= ath9k_hw_common(ah
);
1386 struct ieee80211_conf
*conf
= &common
->hw
->conf
;
1387 u32 len
= 0, size
= 1500;
1391 u8 chainmask
= (ah
->rxchainmask
<< 3) | ah
->rxchainmask
;
1394 buf
= kzalloc(size
, GFP_KERNEL
);
1398 len
+= snprintf(buf
+ len
, size
- len
,
1399 "Channel Noise Floor : %d\n", ah
->noise
);
1400 len
+= snprintf(buf
+ len
, size
- len
,
1401 "Chain | privNF | # Readings | NF Readings\n");
1402 for (i
= 0; i
< NUM_NF_READINGS
; i
++) {
1403 if (!(chainmask
& (1 << i
)) ||
1404 ((i
>= AR5416_MAX_CHAINS
) && !conf_is_ht40(conf
)))
1407 nread
= AR_PHY_CCA_FILTERWINDOW_LENGTH
- h
[i
].invalidNFcount
;
1408 len
+= snprintf(buf
+ len
, size
- len
, " %d\t %d\t %d\t\t",
1409 i
, h
[i
].privNF
, nread
);
1410 for (j
= 0; j
< nread
; j
++)
1411 len
+= snprintf(buf
+ len
, size
- len
,
1412 " %d", h
[i
].nfCalBuffer
[j
]);
1413 len
+= snprintf(buf
+ len
, size
- len
, "\n");
1419 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1425 static const struct file_operations fops_dump_nfcal
= {
1426 .read
= read_file_dump_nfcal
,
1427 .open
= simple_open
,
1428 .owner
= THIS_MODULE
,
1429 .llseek
= default_llseek
,
1432 static ssize_t
read_file_base_eeprom(struct file
*file
, char __user
*user_buf
,
1433 size_t count
, loff_t
*ppos
)
1435 struct ath_softc
*sc
= file
->private_data
;
1436 struct ath_hw
*ah
= sc
->sc_ah
;
1437 u32 len
= 0, size
= 1500;
1441 buf
= kzalloc(size
, GFP_KERNEL
);
1445 len
= ah
->eep_ops
->dump_eeprom(ah
, true, buf
, len
, size
);
1447 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1453 static const struct file_operations fops_base_eeprom
= {
1454 .read
= read_file_base_eeprom
,
1455 .open
= simple_open
,
1456 .owner
= THIS_MODULE
,
1457 .llseek
= default_llseek
,
1460 static ssize_t
read_file_modal_eeprom(struct file
*file
, char __user
*user_buf
,
1461 size_t count
, loff_t
*ppos
)
1463 struct ath_softc
*sc
= file
->private_data
;
1464 struct ath_hw
*ah
= sc
->sc_ah
;
1465 u32 len
= 0, size
= 6000;
1469 buf
= kzalloc(size
, GFP_KERNEL
);
1473 len
= ah
->eep_ops
->dump_eeprom(ah
, false, buf
, len
, size
);
1475 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1481 static const struct file_operations fops_modal_eeprom
= {
1482 .read
= read_file_modal_eeprom
,
1483 .open
= simple_open
,
1484 .owner
= THIS_MODULE
,
1485 .llseek
= default_llseek
,
1488 #ifdef CONFIG_ATH9K_MAC_DEBUG
1490 void ath9k_debug_samp_bb_mac(struct ath_softc
*sc
)
1492 #define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c)
1493 struct ath_hw
*ah
= sc
->sc_ah
;
1494 struct ath_common
*common
= ath9k_hw_common(ah
);
1495 unsigned long flags
;
1498 ath9k_ps_wakeup(sc
);
1500 spin_lock_bh(&sc
->debug
.samp_lock
);
1502 spin_lock_irqsave(&common
->cc_lock
, flags
);
1503 ath_hw_cycle_counters_update(common
);
1505 ATH_SAMP_DBG(cc
.cycles
) = common
->cc_ani
.cycles
;
1506 ATH_SAMP_DBG(cc
.rx_busy
) = common
->cc_ani
.rx_busy
;
1507 ATH_SAMP_DBG(cc
.rx_frame
) = common
->cc_ani
.rx_frame
;
1508 ATH_SAMP_DBG(cc
.tx_frame
) = common
->cc_ani
.tx_frame
;
1509 spin_unlock_irqrestore(&common
->cc_lock
, flags
);
1511 ATH_SAMP_DBG(noise
) = ah
->noise
;
1513 REG_WRITE_D(ah
, AR_MACMISC
,
1514 ((AR_MACMISC_DMA_OBS_LINE_8
<< AR_MACMISC_DMA_OBS_S
) |
1515 (AR_MACMISC_MISC_OBS_BUS_1
<<
1516 AR_MACMISC_MISC_OBS_BUS_MSB_S
)));
1518 for (i
= 0; i
< ATH9K_NUM_DMA_DEBUG_REGS
; i
++)
1519 ATH_SAMP_DBG(dma_dbg_reg_vals
[i
]) = REG_READ_D(ah
,
1520 AR_DMADBG_0
+ (i
* sizeof(u32
)));
1522 ATH_SAMP_DBG(pcu_obs
) = REG_READ_D(ah
, AR_OBS_BUS_1
);
1523 ATH_SAMP_DBG(pcu_cr
) = REG_READ_D(ah
, AR_CR
);
1525 memcpy(ATH_SAMP_DBG(nfCalHist
), sc
->caldata
.nfCalHist
,
1526 sizeof(ATH_SAMP_DBG(nfCalHist
)));
1528 sc
->debug
.sampidx
= (sc
->debug
.sampidx
+ 1) % ATH_DBG_MAX_SAMPLES
;
1529 spin_unlock_bh(&sc
->debug
.samp_lock
);
1530 ath9k_ps_restore(sc
);
1535 static int open_file_bb_mac_samps(struct inode
*inode
, struct file
*file
)
1537 #define ATH_SAMP_DBG(c) bb_mac_samp[sampidx].c
1538 struct ath_softc
*sc
= inode
->i_private
;
1539 struct ath_hw
*ah
= sc
->sc_ah
;
1540 struct ath_common
*common
= ath9k_hw_common(ah
);
1541 struct ieee80211_conf
*conf
= &common
->hw
->conf
;
1542 struct ath_dbg_bb_mac_samp
*bb_mac_samp
;
1543 struct ath9k_nfcal_hist
*h
;
1544 int i
, j
, qcuOffset
= 0, dcuOffset
= 0;
1545 u32
*qcuBase
, *dcuBase
, size
= 30000, len
= 0;
1548 u8 chainmask
= (ah
->rxchainmask
<< 3) | ah
->rxchainmask
;
1551 if (test_bit(SC_OP_INVALID
, &sc
->sc_flags
))
1554 buf
= vmalloc(size
);
1557 bb_mac_samp
= vmalloc(sizeof(*bb_mac_samp
) * ATH_DBG_MAX_SAMPLES
);
1562 /* Account the current state too */
1563 ath9k_debug_samp_bb_mac(sc
);
1565 spin_lock_bh(&sc
->debug
.samp_lock
);
1566 memcpy(bb_mac_samp
, sc
->debug
.bb_mac_samp
,
1567 sizeof(*bb_mac_samp
) * ATH_DBG_MAX_SAMPLES
);
1568 len
+= snprintf(buf
+ len
, size
- len
,
1569 "Current Sample Index: %d\n", sc
->debug
.sampidx
);
1570 spin_unlock_bh(&sc
->debug
.samp_lock
);
1572 len
+= snprintf(buf
+ len
, size
- len
,
1573 "Raw DMA Debug Dump:\n");
1574 len
+= snprintf(buf
+ len
, size
- len
, "Sample |\t");
1575 for (i
= 0; i
< ATH9K_NUM_DMA_DEBUG_REGS
; i
++)
1576 len
+= snprintf(buf
+ len
, size
- len
, " DMA Reg%d |\t", i
);
1577 len
+= snprintf(buf
+ len
, size
- len
, "\n");
1579 for (sampidx
= 0; sampidx
< ATH_DBG_MAX_SAMPLES
; sampidx
++) {
1580 len
+= snprintf(buf
+ len
, size
- len
, "%d\t", sampidx
);
1582 for (i
= 0; i
< ATH9K_NUM_DMA_DEBUG_REGS
; i
++)
1583 len
+= snprintf(buf
+ len
, size
- len
, " %08x\t",
1584 ATH_SAMP_DBG(dma_dbg_reg_vals
[i
]));
1585 len
+= snprintf(buf
+ len
, size
- len
, "\n");
1587 len
+= snprintf(buf
+ len
, size
- len
, "\n");
1589 len
+= snprintf(buf
+ len
, size
- len
,
1590 "Sample Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
1591 for (sampidx
= 0; sampidx
< ATH_DBG_MAX_SAMPLES
; sampidx
++) {
1592 qcuBase
= &ATH_SAMP_DBG(dma_dbg_reg_vals
[0]);
1593 dcuBase
= &ATH_SAMP_DBG(dma_dbg_reg_vals
[4]);
1595 for (i
= 0; i
< ATH9K_NUM_QUEUES
; i
++,
1596 qcuOffset
+= 4, dcuOffset
+= 5) {
1606 if (!sc
->debug
.stats
.txstats
[i
].queued
)
1609 len
+= snprintf(buf
+ len
, size
- len
,
1610 "%4d %7d %2x %1x %2x %2x\n",
1612 (*qcuBase
& (0x7 << qcuOffset
)) >> qcuOffset
,
1613 (*qcuBase
& (0x8 << qcuOffset
)) >>
1615 ATH_SAMP_DBG(dma_dbg_reg_vals
[2]) &
1616 (0x7 << (i
* 3)) >> (i
* 3),
1617 (*dcuBase
& (0x1f << dcuOffset
)) >> dcuOffset
);
1619 len
+= snprintf(buf
+ len
, size
- len
, "\n");
1621 len
+= snprintf(buf
+ len
, size
- len
,
1622 "samp qcu_sh qcu_fh qcu_comp dcu_comp dcu_arb dcu_fp "
1623 "ch_idle_dur ch_idle_dur_val txfifo_val0 txfifo_val1 "
1624 "txfifo_dcu0 txfifo_dcu1 pcu_obs AR_CR\n");
1626 for (sampidx
= 0; sampidx
< ATH_DBG_MAX_SAMPLES
; sampidx
++) {
1627 qcuBase
= &ATH_SAMP_DBG(dma_dbg_reg_vals
[0]);
1628 dcuBase
= &ATH_SAMP_DBG(dma_dbg_reg_vals
[4]);
1630 len
+= snprintf(buf
+ len
, size
- len
, "%4d %5x %5x ", sampidx
,
1631 (ATH_SAMP_DBG(dma_dbg_reg_vals
[3]) & 0x003c0000) >> 18,
1632 (ATH_SAMP_DBG(dma_dbg_reg_vals
[3]) & 0x03c00000) >> 22);
1633 len
+= snprintf(buf
+ len
, size
- len
, "%7x %8x ",
1634 (ATH_SAMP_DBG(dma_dbg_reg_vals
[3]) & 0x1c000000) >> 26,
1635 (ATH_SAMP_DBG(dma_dbg_reg_vals
[6]) & 0x3));
1636 len
+= snprintf(buf
+ len
, size
- len
, "%7x %7x ",
1637 (ATH_SAMP_DBG(dma_dbg_reg_vals
[5]) & 0x06000000) >> 25,
1638 (ATH_SAMP_DBG(dma_dbg_reg_vals
[5]) & 0x38000000) >> 27);
1639 len
+= snprintf(buf
+ len
, size
- len
, "%7d %12d ",
1640 (ATH_SAMP_DBG(dma_dbg_reg_vals
[6]) & 0x000003fc) >> 2,
1641 (ATH_SAMP_DBG(dma_dbg_reg_vals
[6]) & 0x00000400) >> 10);
1642 len
+= snprintf(buf
+ len
, size
- len
, "%12d %12d ",
1643 (ATH_SAMP_DBG(dma_dbg_reg_vals
[6]) & 0x00000800) >> 11,
1644 (ATH_SAMP_DBG(dma_dbg_reg_vals
[6]) & 0x00001000) >> 12);
1645 len
+= snprintf(buf
+ len
, size
- len
, "%12d %12d ",
1646 (ATH_SAMP_DBG(dma_dbg_reg_vals
[6]) & 0x0001e000) >> 13,
1647 (ATH_SAMP_DBG(dma_dbg_reg_vals
[6]) & 0x001e0000) >> 17);
1648 len
+= snprintf(buf
+ len
, size
- len
, "0x%07x 0x%07x\n",
1649 ATH_SAMP_DBG(pcu_obs
), ATH_SAMP_DBG(pcu_cr
));
1652 len
+= snprintf(buf
+ len
, size
- len
,
1653 "Sample ChNoise Chain privNF #Reading Readings\n");
1654 for (sampidx
= 0; sampidx
< ATH_DBG_MAX_SAMPLES
; sampidx
++) {
1655 h
= ATH_SAMP_DBG(nfCalHist
);
1656 if (!ATH_SAMP_DBG(noise
))
1659 for (i
= 0; i
< NUM_NF_READINGS
; i
++) {
1660 if (!(chainmask
& (1 << i
)) ||
1661 ((i
>= AR5416_MAX_CHAINS
) && !conf_is_ht40(conf
)))
1664 nread
= AR_PHY_CCA_FILTERWINDOW_LENGTH
-
1665 h
[i
].invalidNFcount
;
1666 len
+= snprintf(buf
+ len
, size
- len
,
1667 "%4d %5d %4d\t %d\t %d\t",
1668 sampidx
, ATH_SAMP_DBG(noise
),
1669 i
, h
[i
].privNF
, nread
);
1670 for (j
= 0; j
< nread
; j
++)
1671 len
+= snprintf(buf
+ len
, size
- len
,
1672 " %d", h
[i
].nfCalBuffer
[j
]);
1673 len
+= snprintf(buf
+ len
, size
- len
, "\n");
1676 len
+= snprintf(buf
+ len
, size
- len
, "\nCycle counters:\n"
1677 "Sample Total Rxbusy Rxframes Txframes\n");
1678 for (sampidx
= 0; sampidx
< ATH_DBG_MAX_SAMPLES
; sampidx
++) {
1679 if (!ATH_SAMP_DBG(cc
.cycles
))
1681 len
+= snprintf(buf
+ len
, size
- len
,
1682 "%4d %08x %08x %08x %08x\n",
1683 sampidx
, ATH_SAMP_DBG(cc
.cycles
),
1684 ATH_SAMP_DBG(cc
.rx_busy
),
1685 ATH_SAMP_DBG(cc
.rx_frame
),
1686 ATH_SAMP_DBG(cc
.tx_frame
));
1689 len
+= snprintf(buf
+ len
, size
- len
, "Tx status Dump :\n");
1690 len
+= snprintf(buf
+ len
, size
- len
,
1691 "Sample rssi:- ctl0 ctl1 ctl2 ext0 ext1 ext2 comb "
1692 "isok rts_fail data_fail rate tid qid "
1693 "ba_low ba_high tx_before(ms)\n");
1694 for (sampidx
= 0; sampidx
< ATH_DBG_MAX_SAMPLES
; sampidx
++) {
1695 for (i
= 0; i
< ATH_DBG_MAX_SAMPLES
; i
++) {
1696 if (!ATH_SAMP_DBG(ts
[i
].jiffies
))
1698 len
+= snprintf(buf
+ len
, size
- len
, "%-14d"
1699 "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-8d "
1700 "%-9d %-4d %-3d %-3d %08x %08x %-11d\n",
1702 ATH_SAMP_DBG(ts
[i
].rssi_ctl0
),
1703 ATH_SAMP_DBG(ts
[i
].rssi_ctl1
),
1704 ATH_SAMP_DBG(ts
[i
].rssi_ctl2
),
1705 ATH_SAMP_DBG(ts
[i
].rssi_ext0
),
1706 ATH_SAMP_DBG(ts
[i
].rssi_ext1
),
1707 ATH_SAMP_DBG(ts
[i
].rssi_ext2
),
1708 ATH_SAMP_DBG(ts
[i
].rssi
),
1709 ATH_SAMP_DBG(ts
[i
].isok
),
1710 ATH_SAMP_DBG(ts
[i
].rts_fail_cnt
),
1711 ATH_SAMP_DBG(ts
[i
].data_fail_cnt
),
1712 ATH_SAMP_DBG(ts
[i
].rateindex
),
1713 ATH_SAMP_DBG(ts
[i
].tid
),
1714 ATH_SAMP_DBG(ts
[i
].qid
),
1715 ATH_SAMP_DBG(ts
[i
].ba_low
),
1716 ATH_SAMP_DBG(ts
[i
].ba_high
),
1717 jiffies_to_msecs(jiffies
-
1718 ATH_SAMP_DBG(ts
[i
].jiffies
)));
1722 len
+= snprintf(buf
+ len
, size
- len
, "Rx status Dump :\n");
1723 len
+= snprintf(buf
+ len
, size
- len
, "Sample rssi:- ctl0 ctl1 ctl2 "
1724 "ext0 ext1 ext2 comb beacon ant rate rx_before(ms)\n");
1725 for (sampidx
= 0; sampidx
< ATH_DBG_MAX_SAMPLES
; sampidx
++) {
1726 for (i
= 0; i
< ATH_DBG_MAX_SAMPLES
; i
++) {
1727 if (!ATH_SAMP_DBG(rs
[i
].jiffies
))
1729 len
+= snprintf(buf
+ len
, size
- len
, "%-14d"
1730 "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-9s %-2d %02x %-13d\n",
1732 ATH_SAMP_DBG(rs
[i
].rssi_ctl0
),
1733 ATH_SAMP_DBG(rs
[i
].rssi_ctl1
),
1734 ATH_SAMP_DBG(rs
[i
].rssi_ctl2
),
1735 ATH_SAMP_DBG(rs
[i
].rssi_ext0
),
1736 ATH_SAMP_DBG(rs
[i
].rssi_ext1
),
1737 ATH_SAMP_DBG(rs
[i
].rssi_ext2
),
1738 ATH_SAMP_DBG(rs
[i
].rssi
),
1739 ATH_SAMP_DBG(rs
[i
].is_mybeacon
) ?
1741 ATH_SAMP_DBG(rs
[i
].antenna
),
1742 ATH_SAMP_DBG(rs
[i
].rate
),
1743 jiffies_to_msecs(jiffies
-
1744 ATH_SAMP_DBG(rs
[i
].jiffies
)));
1749 file
->private_data
= buf
;
1755 static const struct file_operations fops_samps
= {
1756 .open
= open_file_bb_mac_samps
,
1757 .read
= ath9k_debugfs_read_buf
,
1758 .release
= ath9k_debugfs_release_buf
,
1759 .owner
= THIS_MODULE
,
1760 .llseek
= default_llseek
,
1765 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1766 static ssize_t
read_file_btcoex(struct file
*file
, char __user
*user_buf
,
1767 size_t count
, loff_t
*ppos
)
1769 struct ath_softc
*sc
= file
->private_data
;
1770 u32 len
= 0, size
= 1500;
1774 buf
= kzalloc(size
, GFP_KERNEL
);
1778 if (!sc
->sc_ah
->common
.btcoex_enabled
) {
1779 len
= snprintf(buf
, size
, "%s\n",
1780 "BTCOEX is disabled");
1784 len
= ath9k_dump_btcoex(sc
, buf
, size
);
1786 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1792 static const struct file_operations fops_btcoex
= {
1793 .read
= read_file_btcoex
,
1794 .open
= simple_open
,
1795 .owner
= THIS_MODULE
,
1796 .llseek
= default_llseek
,
1800 static ssize_t
read_file_node_stat(struct file
*file
, char __user
*user_buf
,
1801 size_t count
, loff_t
*ppos
)
1803 struct ath_node
*an
= file
->private_data
;
1804 struct ath_softc
*sc
= an
->sc
;
1805 struct ath_atx_tid
*tid
;
1806 struct ath_atx_ac
*ac
;
1807 struct ath_txq
*txq
;
1808 u32 len
= 0, size
= 4096;
1813 buf
= kzalloc(size
, GFP_KERNEL
);
1817 if (!an
->sta
->ht_cap
.ht_supported
) {
1818 len
= snprintf(buf
, size
, "%s\n",
1819 "HT not supported");
1823 len
= snprintf(buf
, size
, "Max-AMPDU: %d\n",
1825 len
+= snprintf(buf
+ len
, size
- len
, "MPDU Density: %d\n\n",
1828 len
+= snprintf(buf
+ len
, size
- len
,
1829 "%2s%7s\n", "AC", "SCHED");
1831 for (acno
= 0, ac
= &an
->ac
[acno
];
1832 acno
< IEEE80211_NUM_ACS
; acno
++, ac
++) {
1834 ath_txq_lock(sc
, txq
);
1835 len
+= snprintf(buf
+ len
, size
- len
,
1838 ath_txq_unlock(sc
, txq
);
1841 len
+= snprintf(buf
+ len
, size
- len
,
1842 "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n",
1843 "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE",
1844 "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED");
1846 for (tidno
= 0, tid
= &an
->tid
[tidno
];
1847 tidno
< IEEE80211_NUM_TIDS
; tidno
++, tid
++) {
1849 ath_txq_lock(sc
, txq
);
1850 len
+= snprintf(buf
+ len
, size
- len
,
1851 "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n",
1852 tid
->tidno
, tid
->seq_start
, tid
->seq_next
,
1853 tid
->baw_size
, tid
->baw_head
, tid
->baw_tail
,
1854 tid
->bar_index
, tid
->sched
, tid
->paused
);
1855 ath_txq_unlock(sc
, txq
);
1858 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1864 static const struct file_operations fops_node_stat
= {
1865 .read
= read_file_node_stat
,
1866 .open
= simple_open
,
1867 .owner
= THIS_MODULE
,
1868 .llseek
= default_llseek
,
1871 void ath9k_sta_add_debugfs(struct ieee80211_hw
*hw
,
1872 struct ieee80211_vif
*vif
,
1873 struct ieee80211_sta
*sta
,
1876 struct ath_node
*an
= (struct ath_node
*)sta
->drv_priv
;
1877 an
->node_stat
= debugfs_create_file("node_stat", S_IRUGO
,
1878 dir
, an
, &fops_node_stat
);
1881 void ath9k_sta_remove_debugfs(struct ieee80211_hw
*hw
,
1882 struct ieee80211_vif
*vif
,
1883 struct ieee80211_sta
*sta
,
1886 struct ath_node
*an
= (struct ath_node
*)sta
->drv_priv
;
1887 debugfs_remove(an
->node_stat
);
1890 /* Ethtool support for get-stats */
1892 #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
1893 static const char ath9k_gstrings_stats
[][ETH_GSTRING_LEN
] = {
1900 AMKSTR(d_tx_mpdus_queued
),
1901 AMKSTR(d_tx_mpdus_completed
),
1902 AMKSTR(d_tx_mpdu_xretries
),
1903 AMKSTR(d_tx_aggregates
),
1904 AMKSTR(d_tx_ampdus_queued_hw
),
1905 AMKSTR(d_tx_ampdus_queued_sw
),
1906 AMKSTR(d_tx_ampdus_completed
),
1907 AMKSTR(d_tx_ampdu_retries
),
1908 AMKSTR(d_tx_ampdu_xretries
),
1909 AMKSTR(d_tx_fifo_underrun
),
1910 AMKSTR(d_tx_op_exceeded
),
1911 AMKSTR(d_tx_timer_expiry
),
1912 AMKSTR(d_tx_desc_cfg_err
),
1913 AMKSTR(d_tx_data_underrun
),
1914 AMKSTR(d_tx_delim_underrun
),
1916 "d_rx_decrypt_crc_err",
1919 "d_rx_pre_delim_crc_err",
1920 "d_rx_post_delim_crc_err",
1921 "d_rx_decrypt_busy_err",
1923 "d_rx_phyerr_radar",
1924 "d_rx_phyerr_ofdm_timing",
1925 "d_rx_phyerr_cck_timing",
1928 #define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats)
1930 void ath9k_get_et_strings(struct ieee80211_hw
*hw
,
1931 struct ieee80211_vif
*vif
,
1934 if (sset
== ETH_SS_STATS
)
1935 memcpy(data
, *ath9k_gstrings_stats
,
1936 sizeof(ath9k_gstrings_stats
));
1939 int ath9k_get_et_sset_count(struct ieee80211_hw
*hw
,
1940 struct ieee80211_vif
*vif
, int sset
)
1942 if (sset
== ETH_SS_STATS
)
1943 return ATH9K_SSTATS_LEN
;
1947 #define AWDATA(elem) \
1949 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].elem; \
1950 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].elem; \
1951 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].elem; \
1952 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].elem; \
1955 #define AWDATA_RX(elem) \
1957 data[i++] = sc->debug.stats.rxstats.elem; \
1960 void ath9k_get_et_stats(struct ieee80211_hw
*hw
,
1961 struct ieee80211_vif
*vif
,
1962 struct ethtool_stats
*stats
, u64
*data
)
1964 struct ath_softc
*sc
= hw
->priv
;
1967 data
[i
++] = (sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_BE
)].tx_pkts_all
+
1968 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_BK
)].tx_pkts_all
+
1969 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_VI
)].tx_pkts_all
+
1970 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_VO
)].tx_pkts_all
);
1971 data
[i
++] = (sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_BE
)].tx_bytes_all
+
1972 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_BK
)].tx_bytes_all
+
1973 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_VI
)].tx_bytes_all
+
1974 sc
->debug
.stats
.txstats
[PR_QNUM(IEEE80211_AC_VO
)].tx_bytes_all
);
1975 AWDATA_RX(rx_pkts_all
);
1976 AWDATA_RX(rx_bytes_all
);
1978 AWDATA(tx_pkts_all
);
1979 AWDATA(tx_bytes_all
);
1984 AWDATA(a_queued_hw
);
1985 AWDATA(a_queued_sw
);
1986 AWDATA(a_completed
);
1989 AWDATA(fifo_underrun
);
1992 AWDATA(desc_cfg_err
);
1993 AWDATA(data_underrun
);
1994 AWDATA(delim_underrun
);
1997 AWDATA_RX(decrypt_crc_err
);
2000 AWDATA_RX(pre_delim_crc_err
);
2001 AWDATA_RX(post_delim_crc_err
);
2002 AWDATA_RX(decrypt_busy_err
);
2004 AWDATA_RX(phy_err_stats
[ATH9K_PHYERR_RADAR
]);
2005 AWDATA_RX(phy_err_stats
[ATH9K_PHYERR_OFDM_TIMING
]);
2006 AWDATA_RX(phy_err_stats
[ATH9K_PHYERR_CCK_TIMING
]);
2008 WARN_ON(i
!= ATH9K_SSTATS_LEN
);
2011 int ath9k_init_debug(struct ath_hw
*ah
)
2013 struct ath_common
*common
= ath9k_hw_common(ah
);
2014 struct ath_softc
*sc
= (struct ath_softc
*) common
->priv
;
2016 sc
->debug
.debugfs_phy
= debugfs_create_dir("ath9k",
2017 sc
->hw
->wiphy
->debugfsdir
);
2018 if (!sc
->debug
.debugfs_phy
)
2021 #ifdef CONFIG_ATH_DEBUG
2022 debugfs_create_file("debug", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
2026 ath9k_dfs_init_debug(sc
);
2028 debugfs_create_file("dma", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
2030 debugfs_create_file("interrupt", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
2032 debugfs_create_file("xmit", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
2034 debugfs_create_file("queues", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
2036 debugfs_create_u32("qlen_bk", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
2037 &sc
->tx
.txq_max_pending
[IEEE80211_AC_BK
]);
2038 debugfs_create_u32("qlen_be", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
2039 &sc
->tx
.txq_max_pending
[IEEE80211_AC_BE
]);
2040 debugfs_create_u32("qlen_vi", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
2041 &sc
->tx
.txq_max_pending
[IEEE80211_AC_VI
]);
2042 debugfs_create_u32("qlen_vo", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
2043 &sc
->tx
.txq_max_pending
[IEEE80211_AC_VO
]);
2044 debugfs_create_file("misc", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
2046 debugfs_create_file("reset", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
2048 debugfs_create_file("recv", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
2050 debugfs_create_file("rx_chainmask", S_IRUSR
| S_IWUSR
,
2051 sc
->debug
.debugfs_phy
, sc
, &fops_rx_chainmask
);
2052 debugfs_create_file("tx_chainmask", S_IRUSR
| S_IWUSR
,
2053 sc
->debug
.debugfs_phy
, sc
, &fops_tx_chainmask
);
2054 debugfs_create_file("disable_ani", S_IRUSR
| S_IWUSR
,
2055 sc
->debug
.debugfs_phy
, sc
, &fops_disable_ani
);
2056 debugfs_create_bool("paprd", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
2057 &sc
->sc_ah
->config
.enable_paprd
);
2058 debugfs_create_file("regidx", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
2060 debugfs_create_file("regval", S_IRUSR
| S_IWUSR
, sc
->debug
.debugfs_phy
,
2062 debugfs_create_bool("ignore_extcca", S_IRUSR
| S_IWUSR
,
2063 sc
->debug
.debugfs_phy
,
2064 &ah
->config
.cwm_ignore_extcca
);
2065 debugfs_create_file("regdump", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
2067 debugfs_create_file("dump_nfcal", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
2069 debugfs_create_file("base_eeprom", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
2071 debugfs_create_file("modal_eeprom", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
2072 &fops_modal_eeprom
);
2073 sc
->rfs_chan_spec_scan
= relay_open("spectral_scan",
2074 sc
->debug
.debugfs_phy
,
2075 1024, 256, &rfs_spec_scan_cb
,
2077 debugfs_create_file("spectral_scan_ctl", S_IRUSR
| S_IWUSR
,
2078 sc
->debug
.debugfs_phy
, sc
,
2079 &fops_spec_scan_ctl
);
2080 debugfs_create_file("spectral_short_repeat", S_IRUSR
| S_IWUSR
,
2081 sc
->debug
.debugfs_phy
, sc
,
2082 &fops_spectral_short_repeat
);
2083 debugfs_create_file("spectral_count", S_IRUSR
| S_IWUSR
,
2084 sc
->debug
.debugfs_phy
, sc
, &fops_spectral_count
);
2085 debugfs_create_file("spectral_period", S_IRUSR
| S_IWUSR
,
2086 sc
->debug
.debugfs_phy
, sc
, &fops_spectral_period
);
2087 debugfs_create_file("spectral_fft_period", S_IRUSR
| S_IWUSR
,
2088 sc
->debug
.debugfs_phy
, sc
,
2089 &fops_spectral_fft_period
);
2091 #ifdef CONFIG_ATH9K_MAC_DEBUG
2092 debugfs_create_file("samples", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,
2095 debugfs_create_u32("gpio_mask", S_IRUSR
| S_IWUSR
,
2096 sc
->debug
.debugfs_phy
, &sc
->sc_ah
->gpio_mask
);
2097 debugfs_create_u32("gpio_val", S_IRUSR
| S_IWUSR
,
2098 sc
->debug
.debugfs_phy
, &sc
->sc_ah
->gpio_val
);
2099 debugfs_create_file("diversity", S_IRUSR
| S_IWUSR
,
2100 sc
->debug
.debugfs_phy
, sc
, &fops_ant_diversity
);
2101 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
2102 debugfs_create_file("btcoex", S_IRUSR
, sc
->debug
.debugfs_phy
, sc
,