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/unaligned.h>
24 #define REG_WRITE_D(_ah, _reg, _val) \
25 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
26 #define REG_READ_D(_ah, _reg) \
27 ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
29 void ath9k_debug_sync_cause(struct ath_softc *sc, u32 sync_cause)
32 sc->debug.stats.istats.sync_cause_all++;
33 if (sync_cause & AR_INTR_SYNC_RTC_IRQ)
34 sc->debug.stats.istats.sync_rtc_irq++;
35 if (sync_cause & AR_INTR_SYNC_MAC_IRQ)
36 sc->debug.stats.istats.sync_mac_irq++;
37 if (sync_cause & AR_INTR_SYNC_EEPROM_ILLEGAL_ACCESS)
38 sc->debug.stats.istats.eeprom_illegal_access++;
39 if (sync_cause & AR_INTR_SYNC_APB_TIMEOUT)
40 sc->debug.stats.istats.apb_timeout++;
41 if (sync_cause & AR_INTR_SYNC_PCI_MODE_CONFLICT)
42 sc->debug.stats.istats.pci_mode_conflict++;
43 if (sync_cause & AR_INTR_SYNC_HOST1_FATAL)
44 sc->debug.stats.istats.host1_fatal++;
45 if (sync_cause & AR_INTR_SYNC_HOST1_PERR)
46 sc->debug.stats.istats.host1_perr++;
47 if (sync_cause & AR_INTR_SYNC_TRCV_FIFO_PERR)
48 sc->debug.stats.istats.trcv_fifo_perr++;
49 if (sync_cause & AR_INTR_SYNC_RADM_CPL_EP)
50 sc->debug.stats.istats.radm_cpl_ep++;
51 if (sync_cause & AR_INTR_SYNC_RADM_CPL_DLLP_ABORT)
52 sc->debug.stats.istats.radm_cpl_dllp_abort++;
53 if (sync_cause & AR_INTR_SYNC_RADM_CPL_TLP_ABORT)
54 sc->debug.stats.istats.radm_cpl_tlp_abort++;
55 if (sync_cause & AR_INTR_SYNC_RADM_CPL_ECRC_ERR)
56 sc->debug.stats.istats.radm_cpl_ecrc_err++;
57 if (sync_cause & AR_INTR_SYNC_RADM_CPL_TIMEOUT)
58 sc->debug.stats.istats.radm_cpl_timeout++;
59 if (sync_cause & AR_INTR_SYNC_LOCAL_TIMEOUT)
60 sc->debug.stats.istats.local_timeout++;
61 if (sync_cause & AR_INTR_SYNC_PM_ACCESS)
62 sc->debug.stats.istats.pm_access++;
63 if (sync_cause & AR_INTR_SYNC_MAC_AWAKE)
64 sc->debug.stats.istats.mac_awake++;
65 if (sync_cause & AR_INTR_SYNC_MAC_ASLEEP)
66 sc->debug.stats.istats.mac_asleep++;
67 if (sync_cause & AR_INTR_SYNC_MAC_SLEEP_ACCESS)
68 sc->debug.stats.istats.mac_sleep_access++;
71 static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf,
72 size_t count, loff_t *ppos)
74 u8 *buf = file->private_data;
75 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
78 static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file)
80 vfree(file->private_data);
84 #ifdef CONFIG_ATH_DEBUG
86 static ssize_t read_file_debug(struct file *file, char __user *user_buf,
87 size_t count, loff_t *ppos)
89 struct ath_softc *sc = file->private_data;
90 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
94 len = sprintf(buf, "0x%08x\n", common->debug_mask);
95 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
98 static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
99 size_t count, loff_t *ppos)
101 struct ath_softc *sc = file->private_data;
102 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
106 ret = kstrtoul_from_user(user_buf, count, 0, &mask);
110 common->debug_mask = mask;
114 static const struct file_operations fops_debug = {
115 .read = read_file_debug,
116 .write = write_file_debug,
118 .owner = THIS_MODULE,
119 .llseek = default_llseek,
124 #define DMA_BUF_LEN 1024
127 static ssize_t read_file_ani(struct file *file, char __user *user_buf,
128 size_t count, loff_t *ppos)
130 struct ath_softc *sc = file->private_data;
131 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
132 struct ath_hw *ah = sc->sc_ah;
133 unsigned int len = 0;
134 const unsigned int size = 1024;
142 { "ANI RESET", ah->stats.ast_ani_reset },
143 { "OFDM LEVEL", ah->ani.ofdmNoiseImmunityLevel },
144 { "CCK LEVEL", ah->ani.cckNoiseImmunityLevel },
145 { "SPUR UP", ah->stats.ast_ani_spurup },
146 { "SPUR DOWN", ah->stats.ast_ani_spurdown },
147 { "OFDM WS-DET ON", ah->stats.ast_ani_ofdmon },
148 { "OFDM WS-DET OFF", ah->stats.ast_ani_ofdmoff },
149 { "MRC-CCK ON", ah->stats.ast_ani_ccklow },
150 { "MRC-CCK OFF", ah->stats.ast_ani_cckhigh },
151 { "FIR-STEP UP", ah->stats.ast_ani_stepup },
152 { "FIR-STEP DOWN", ah->stats.ast_ani_stepdown },
153 { "INV LISTENTIME", ah->stats.ast_ani_lneg_or_lzero },
154 { "OFDM ERRORS", ah->stats.ast_ani_ofdmerrs },
155 { "CCK ERRORS", ah->stats.ast_ani_cckerrs },
158 buf = kzalloc(size, GFP_KERNEL);
162 len += scnprintf(buf + len, size - len, "%15s: %s\n", "ANI",
163 common->disable_ani ? "DISABLED" : "ENABLED");
165 if (common->disable_ani)
168 for (i = 0; i < ARRAY_SIZE(ani_info); i++)
169 len += scnprintf(buf + len, size - len, "%15s: %u\n",
170 ani_info[i].name, ani_info[i].val);
176 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
182 static ssize_t write_file_ani(struct file *file,
183 const char __user *user_buf,
184 size_t count, loff_t *ppos)
186 struct ath_softc *sc = file->private_data;
187 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
191 ret = kstrtoul_from_user(user_buf, count, 0, &ani);
198 common->disable_ani = !ani;
200 if (common->disable_ani) {
201 clear_bit(ATH_OP_ANI_RUN, &common->op_flags);
210 static const struct file_operations fops_ani = {
211 .read = read_file_ani,
212 .write = write_file_ani,
214 .owner = THIS_MODULE,
215 .llseek = default_llseek,
218 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
220 static ssize_t read_file_bt_ant_diversity(struct file *file,
221 char __user *user_buf,
222 size_t count, loff_t *ppos)
224 struct ath_softc *sc = file->private_data;
225 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
229 len = sprintf(buf, "%d\n", common->bt_ant_diversity);
230 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
233 static ssize_t write_file_bt_ant_diversity(struct file *file,
234 const char __user *user_buf,
235 size_t count, loff_t *ppos)
237 struct ath_softc *sc = file->private_data;
238 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
239 struct ath9k_hw_capabilities *pCap = &sc->sc_ah->caps;
240 unsigned long bt_ant_diversity;
243 ret = kstrtoul_from_user(user_buf, count, 0, &bt_ant_diversity);
247 if (!(pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV))
250 common->bt_ant_diversity = !!bt_ant_diversity;
252 ath9k_hw_set_bt_ant_diversity(sc->sc_ah, common->bt_ant_diversity);
253 ath_dbg(common, CONFIG, "Enable WLAN/BT RX Antenna diversity: %d\n",
254 common->bt_ant_diversity);
255 ath9k_ps_restore(sc);
260 static const struct file_operations fops_bt_ant_diversity = {
261 .read = read_file_bt_ant_diversity,
262 .write = write_file_bt_ant_diversity,
264 .owner = THIS_MODULE,
265 .llseek = default_llseek,
270 void ath9k_debug_stat_ant(struct ath_softc *sc,
271 struct ath_hw_antcomb_conf *div_ant_conf,
272 int main_rssi_avg, int alt_rssi_avg)
274 struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN];
275 struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT];
277 as_main->lna_attempt_cnt[div_ant_conf->main_lna_conf]++;
278 as_alt->lna_attempt_cnt[div_ant_conf->alt_lna_conf]++;
280 as_main->rssi_avg = main_rssi_avg;
281 as_alt->rssi_avg = alt_rssi_avg;
284 static ssize_t read_file_antenna_diversity(struct file *file,
285 char __user *user_buf,
286 size_t count, loff_t *ppos)
288 struct ath_softc *sc = file->private_data;
289 struct ath_hw *ah = sc->sc_ah;
290 struct ath9k_hw_capabilities *pCap = &ah->caps;
291 struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN];
292 struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT];
293 struct ath_hw_antcomb_conf div_ant_conf;
294 unsigned int len = 0;
295 const unsigned int size = 1024;
298 static const char *lna_conf_str[4] = {
299 "LNA1_MINUS_LNA2", "LNA2", "LNA1", "LNA1_PLUS_LNA2"
302 buf = kzalloc(size, GFP_KERNEL);
306 if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) {
307 len += scnprintf(buf + len, size - len, "%s\n",
308 "Antenna Diversity Combining is disabled");
313 ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf);
314 len += scnprintf(buf + len, size - len, "Current MAIN config : %s\n",
315 lna_conf_str[div_ant_conf.main_lna_conf]);
316 len += scnprintf(buf + len, size - len, "Current ALT config : %s\n",
317 lna_conf_str[div_ant_conf.alt_lna_conf]);
318 len += scnprintf(buf + len, size - len, "Average MAIN RSSI : %d\n",
320 len += scnprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n",
322 ath9k_ps_restore(sc);
324 len += scnprintf(buf + len, size - len, "Packet Receive Cnt:\n");
325 len += scnprintf(buf + len, size - len, "-------------------\n");
327 len += scnprintf(buf + len, size - len, "%30s%15s\n",
329 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
333 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
335 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1],
336 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]);
337 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
339 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2],
340 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2]);
341 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
343 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2],
344 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]);
345 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
347 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2],
348 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]);
350 len += scnprintf(buf + len, size - len, "\nLNA Config Attempts:\n");
351 len += scnprintf(buf + len, size - len, "--------------------\n");
353 len += scnprintf(buf + len, size - len, "%30s%15s\n",
355 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
357 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1],
358 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]);
359 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
361 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2],
362 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2]);
363 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
365 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2],
366 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]);
367 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
369 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2],
370 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]);
376 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
382 static const struct file_operations fops_antenna_diversity = {
383 .read = read_file_antenna_diversity,
385 .owner = THIS_MODULE,
386 .llseek = default_llseek,
389 static int read_file_dma(struct seq_file *file, void *data)
391 struct ieee80211_hw *hw = dev_get_drvdata(file->private);
392 struct ath_softc *sc = hw->priv;
393 struct ath_hw *ah = sc->sc_ah;
394 u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
395 int i, qcuOffset = 0, dcuOffset = 0;
396 u32 *qcuBase = &val[0], *dcuBase = &val[4];
400 REG_WRITE_D(ah, AR_MACMISC,
401 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
402 (AR_MACMISC_MISC_OBS_BUS_1 <<
403 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
405 seq_puts(file, "Raw DMA Debug values:\n");
407 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
409 seq_puts(file, "\n");
411 val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
412 seq_printf(file, "%d: %08x ", i, val[i]);
415 seq_puts(file, "\n\n");
416 seq_puts(file, "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
418 for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
429 seq_printf(file, "%2d %2x %1x %2x %2x\n",
430 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
431 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
432 (val[2] & (0x7 << (i * 3))) >> (i * 3),
433 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
436 seq_puts(file, "\n");
438 seq_printf(file, "qcu_stitch state: %2x qcu_fetch state: %2x\n",
439 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
440 seq_printf(file, "qcu_complete state: %2x dcu_complete state: %2x\n",
441 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
442 seq_printf(file, "dcu_arb state: %2x dcu_fp state: %2x\n",
443 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
444 seq_printf(file, "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
445 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
446 seq_printf(file, "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
447 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
448 seq_printf(file, "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
449 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
451 seq_printf(file, "pcu observe: 0x%x\n", REG_READ_D(ah, AR_OBS_BUS_1));
452 seq_printf(file, "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR));
454 ath9k_ps_restore(sc);
459 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status)
462 sc->debug.stats.istats.total++;
463 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
464 if (status & ATH9K_INT_RXLP)
465 sc->debug.stats.istats.rxlp++;
466 if (status & ATH9K_INT_RXHP)
467 sc->debug.stats.istats.rxhp++;
468 if (status & ATH9K_INT_BB_WATCHDOG)
469 sc->debug.stats.istats.bb_watchdog++;
471 if (status & ATH9K_INT_RX)
472 sc->debug.stats.istats.rxok++;
474 if (status & ATH9K_INT_RXEOL)
475 sc->debug.stats.istats.rxeol++;
476 if (status & ATH9K_INT_RXORN)
477 sc->debug.stats.istats.rxorn++;
478 if (status & ATH9K_INT_TX)
479 sc->debug.stats.istats.txok++;
480 if (status & ATH9K_INT_TXURN)
481 sc->debug.stats.istats.txurn++;
482 if (status & ATH9K_INT_RXPHY)
483 sc->debug.stats.istats.rxphyerr++;
484 if (status & ATH9K_INT_RXKCM)
485 sc->debug.stats.istats.rx_keycache_miss++;
486 if (status & ATH9K_INT_SWBA)
487 sc->debug.stats.istats.swba++;
488 if (status & ATH9K_INT_BMISS)
489 sc->debug.stats.istats.bmiss++;
490 if (status & ATH9K_INT_BNR)
491 sc->debug.stats.istats.bnr++;
492 if (status & ATH9K_INT_CST)
493 sc->debug.stats.istats.cst++;
494 if (status & ATH9K_INT_GTT)
495 sc->debug.stats.istats.gtt++;
496 if (status & ATH9K_INT_TIM)
497 sc->debug.stats.istats.tim++;
498 if (status & ATH9K_INT_CABEND)
499 sc->debug.stats.istats.cabend++;
500 if (status & ATH9K_INT_DTIMSYNC)
501 sc->debug.stats.istats.dtimsync++;
502 if (status & ATH9K_INT_DTIM)
503 sc->debug.stats.istats.dtim++;
504 if (status & ATH9K_INT_TSFOOR)
505 sc->debug.stats.istats.tsfoor++;
506 if (status & ATH9K_INT_MCI)
507 sc->debug.stats.istats.mci++;
508 if (status & ATH9K_INT_GENTIMER)
509 sc->debug.stats.istats.gen_timer++;
512 static int read_file_interrupt(struct seq_file *file, void *data)
514 struct ieee80211_hw *hw = dev_get_drvdata(file->private);
515 struct ath_softc *sc = hw->priv;
517 #define PR_IS(a, s) \
519 seq_printf(file, "%21s: %10u\n", a, \
520 sc->debug.stats.istats.s); \
523 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
526 PR_IS("WATCHDOG", bb_watchdog);
530 PR_IS("RXEOL", rxeol);
531 PR_IS("RXORN", rxorn);
533 PR_IS("TXURN", txurn);
535 PR_IS("RXPHY", rxphyerr);
536 PR_IS("RXKCM", rx_keycache_miss);
538 PR_IS("BMISS", bmiss);
543 PR_IS("CABEND", cabend);
544 PR_IS("DTIMSYNC", dtimsync);
546 PR_IS("TSFOOR", tsfoor);
548 PR_IS("GENTIMER", gen_timer);
549 PR_IS("TOTAL", total);
551 seq_puts(file, "SYNC_CAUSE stats:\n");
553 PR_IS("Sync-All", sync_cause_all);
554 PR_IS("RTC-IRQ", sync_rtc_irq);
555 PR_IS("MAC-IRQ", sync_mac_irq);
556 PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access);
557 PR_IS("APB-Timeout", apb_timeout);
558 PR_IS("PCI-Mode-Conflict", pci_mode_conflict);
559 PR_IS("HOST1-Fatal", host1_fatal);
560 PR_IS("HOST1-Perr", host1_perr);
561 PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr);
562 PR_IS("RADM-CPL-EP", radm_cpl_ep);
563 PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort);
564 PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort);
565 PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err);
566 PR_IS("RADM-CPL-Timeout", radm_cpl_timeout);
567 PR_IS("Local-Bus-Timeout", local_timeout);
568 PR_IS("PM-Access", pm_access);
569 PR_IS("MAC-Awake", mac_awake);
570 PR_IS("MAC-Asleep", mac_asleep);
571 PR_IS("MAC-Sleep-Access", mac_sleep_access);
576 static int read_file_xmit(struct seq_file *file, void *data)
578 struct ieee80211_hw *hw = dev_get_drvdata(file->private);
579 struct ath_softc *sc = hw->priv;
581 seq_printf(file, "%30s %10s%10s%10s\n\n", "BE", "BK", "VI", "VO");
583 PR("MPDUs Queued: ", queued);
584 PR("MPDUs Completed: ", completed);
585 PR("MPDUs XRetried: ", xretries);
586 PR("Aggregates: ", a_aggr);
587 PR("AMPDUs Queued HW:", a_queued_hw);
588 PR("AMPDUs Completed:", a_completed);
589 PR("AMPDUs Retried: ", a_retries);
590 PR("AMPDUs XRetried: ", a_xretries);
591 PR("TXERR Filtered: ", txerr_filtered);
592 PR("FIFO Underrun: ", fifo_underrun);
593 PR("TXOP Exceeded: ", xtxop);
594 PR("TXTIMER Expiry: ", timer_exp);
595 PR("DESC CFG Error: ", desc_cfg_err);
596 PR("DATA Underrun: ", data_underrun);
597 PR("DELIM Underrun: ", delim_underrun);
598 PR("TX-Pkts-All: ", tx_pkts_all);
599 PR("TX-Bytes-All: ", tx_bytes_all);
600 PR("HW-put-tx-buf: ", puttxbuf);
601 PR("HW-tx-start: ", txstart);
602 PR("HW-tx-proc-desc: ", txprocdesc);
603 PR("TX-Failed: ", txfailed);
608 static void print_queue(struct ath_softc *sc, struct ath_txq *txq,
609 struct seq_file *file)
611 ath_txq_lock(sc, txq);
613 seq_printf(file, "%s: %d ", "qnum", txq->axq_qnum);
614 seq_printf(file, "%s: %2d ", "qdepth", txq->axq_depth);
615 seq_printf(file, "%s: %2d ", "ampdu-depth", txq->axq_ampdu_depth);
616 seq_printf(file, "%s: %3d\n", "pending", txq->pending_frames);
618 ath_txq_unlock(sc, txq);
621 static int read_file_queues(struct seq_file *file, void *data)
623 struct ieee80211_hw *hw = dev_get_drvdata(file->private);
624 struct ath_softc *sc = hw->priv;
627 static const char *qname[4] = {
628 "VO", "VI", "BE", "BK"
631 for (i = 0; i < IEEE80211_NUM_ACS; i++) {
632 txq = sc->tx.txq_map[i];
633 seq_printf(file, "(%s): ", qname[i]);
634 print_queue(sc, txq, file);
637 seq_puts(file, "(CAB): ");
638 print_queue(sc, sc->beacon.cabq, file);
643 static int read_file_misc(struct seq_file *file, void *data)
645 struct ieee80211_hw *hw = dev_get_drvdata(file->private);
646 struct ath_softc *sc = hw->priv;
647 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
648 struct ath9k_vif_iter_data iter_data;
649 struct ath_chanctx *ctx;
653 seq_printf(file, "BSSID: %pM\n", common->curbssid);
654 seq_printf(file, "BSSID-MASK: %pM\n", common->bssidmask);
655 seq_printf(file, "OPMODE: %s\n",
656 ath_opmode_to_string(sc->sc_ah->opmode));
659 rxfilter = ath9k_hw_getrxfilter(sc->sc_ah);
660 ath9k_ps_restore(sc);
662 seq_printf(file, "RXFILTER: 0x%x", rxfilter);
664 if (rxfilter & ATH9K_RX_FILTER_UCAST)
665 seq_puts(file, " UCAST");
666 if (rxfilter & ATH9K_RX_FILTER_MCAST)
667 seq_puts(file, " MCAST");
668 if (rxfilter & ATH9K_RX_FILTER_BCAST)
669 seq_puts(file, " BCAST");
670 if (rxfilter & ATH9K_RX_FILTER_CONTROL)
671 seq_puts(file, " CONTROL");
672 if (rxfilter & ATH9K_RX_FILTER_BEACON)
673 seq_puts(file, " BEACON");
674 if (rxfilter & ATH9K_RX_FILTER_PROM)
675 seq_puts(file, " PROM");
676 if (rxfilter & ATH9K_RX_FILTER_PROBEREQ)
677 seq_puts(file, " PROBEREQ");
678 if (rxfilter & ATH9K_RX_FILTER_PHYERR)
679 seq_puts(file, " PHYERR");
680 if (rxfilter & ATH9K_RX_FILTER_MYBEACON)
681 seq_puts(file, " MYBEACON");
682 if (rxfilter & ATH9K_RX_FILTER_COMP_BAR)
683 seq_puts(file, " COMP_BAR");
684 if (rxfilter & ATH9K_RX_FILTER_PSPOLL)
685 seq_puts(file, " PSPOLL");
686 if (rxfilter & ATH9K_RX_FILTER_PHYRADAR)
687 seq_puts(file, " PHYRADAR");
688 if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL)
689 seq_puts(file, " MCAST_BCAST_ALL");
690 if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER)
691 seq_puts(file, " CONTROL_WRAPPER");
693 seq_puts(file, "\n");
695 reg = sc->sc_ah->imask;
697 seq_printf(file, "INTERRUPT-MASK: 0x%x", reg);
699 if (reg & ATH9K_INT_SWBA)
700 seq_puts(file, " SWBA");
701 if (reg & ATH9K_INT_BMISS)
702 seq_puts(file, " BMISS");
703 if (reg & ATH9K_INT_CST)
704 seq_puts(file, " CST");
705 if (reg & ATH9K_INT_RX)
706 seq_puts(file, " RX");
707 if (reg & ATH9K_INT_RXHP)
708 seq_puts(file, " RXHP");
709 if (reg & ATH9K_INT_RXLP)
710 seq_puts(file, " RXLP");
711 if (reg & ATH9K_INT_BB_WATCHDOG)
712 seq_puts(file, " BB_WATCHDOG");
714 seq_puts(file, "\n");
717 ath_for_each_chanctx(sc, ctx) {
718 if (list_empty(&ctx->vifs))
720 ath9k_calculate_iter_data(sc, ctx, &iter_data);
723 "VIFS: CTX %i(%i) AP: %i STA: %i MESH: %i",
724 i++, (int)(ctx->assigned), iter_data.naps,
727 seq_printf(file, " ADHOC: %i OCB: %i TOTAL: %hi BEACON-VIF: %hi\n",
728 iter_data.nadhocs, iter_data.nocbs, sc->cur_chan->nvifs,
735 static int read_file_reset(struct seq_file *file, void *data)
737 struct ath_softc *sc = file->private;
738 static const char * const reset_cause[__RESET_TYPE_MAX] = {
739 [RESET_TYPE_USER] = "User reset",
740 [RESET_TYPE_BB_HANG] = "Baseband Hang",
741 [RESET_TYPE_BB_WATCHDOG] = "Baseband Watchdog",
742 [RESET_TYPE_FATAL_INT] = "Fatal HW Error",
743 [RESET_TYPE_TX_ERROR] = "TX HW error",
744 [RESET_TYPE_TX_GTT] = "Transmit timeout",
745 [RESET_TYPE_TX_HANG] = "TX Path Hang",
746 [RESET_TYPE_PLL_HANG] = "PLL RX Hang",
747 [RESET_TYPE_MAC_HANG] = "MAC Hang",
748 [RESET_TYPE_BEACON_STUCK] = "Stuck Beacon",
749 [RESET_TYPE_MCI] = "MCI Reset",
750 [RESET_TYPE_CALIBRATION] = "Calibration error",
751 [RESET_TX_DMA_ERROR] = "Tx DMA stop error",
752 [RESET_RX_DMA_ERROR] = "Rx DMA stop error",
753 [RESET_TYPE_RX_INACTIVE] = "Rx path inactive",
757 for (i = 0; i < ARRAY_SIZE(reset_cause); i++) {
761 seq_printf(file, "%17s: %2d\n", reset_cause[i],
762 sc->debug.stats.reset[i]);
768 static int open_file_reset(struct inode *inode, struct file *f)
770 return single_open(f, read_file_reset, inode->i_private);
773 static ssize_t write_file_reset(struct file *file,
774 const char __user *user_buf,
775 size_t count, loff_t *ppos)
777 struct ath_softc *sc = file_inode(file)->i_private;
778 struct ath_hw *ah = sc->sc_ah;
779 struct ath_common *common = ath9k_hw_common(ah);
783 ret = kstrtoul_from_user(user_buf, count, 0, &val);
790 /* avoid rearming hw_reset_work on shutdown */
791 mutex_lock(&sc->mutex);
792 if (test_bit(ATH_OP_INVALID, &common->op_flags)) {
793 mutex_unlock(&sc->mutex);
797 ath9k_queue_reset(sc, RESET_TYPE_USER);
798 mutex_unlock(&sc->mutex);
803 static const struct file_operations fops_reset = {
805 .write = write_file_reset,
806 .open = open_file_reset,
807 .owner = THIS_MODULE,
809 .release = single_release,
812 void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
813 struct ath_tx_status *ts, struct ath_txq *txq,
816 int qnum = txq->axq_qnum;
818 TX_STAT_INC(sc, qnum, tx_pkts_all);
819 sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len;
821 if (bf_isampdu(bf)) {
822 if (flags & ATH_TX_ERROR)
823 TX_STAT_INC(sc, qnum, a_xretries);
825 TX_STAT_INC(sc, qnum, a_completed);
827 if (ts->ts_status & ATH9K_TXERR_XRETRY)
828 TX_STAT_INC(sc, qnum, xretries);
830 TX_STAT_INC(sc, qnum, completed);
833 if (ts->ts_status & ATH9K_TXERR_FILT)
834 TX_STAT_INC(sc, qnum, txerr_filtered);
835 if (ts->ts_status & ATH9K_TXERR_FIFO)
836 TX_STAT_INC(sc, qnum, fifo_underrun);
837 if (ts->ts_status & ATH9K_TXERR_XTXOP)
838 TX_STAT_INC(sc, qnum, xtxop);
839 if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED)
840 TX_STAT_INC(sc, qnum, timer_exp);
841 if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR)
842 TX_STAT_INC(sc, qnum, desc_cfg_err);
843 if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN)
844 TX_STAT_INC(sc, qnum, data_underrun);
845 if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
846 TX_STAT_INC(sc, qnum, delim_underrun);
849 void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
851 ath9k_cmn_debug_stat_rx(&sc->debug.stats.rxstats, rs);
854 static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
855 size_t count, loff_t *ppos)
857 struct ath_softc *sc = file->private_data;
861 len = sprintf(buf, "0x%08x\n", sc->debug.regidx);
862 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
865 static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
866 size_t count, loff_t *ppos)
868 struct ath_softc *sc = file->private_data;
869 unsigned long regidx;
872 ret = kstrtoul_from_user(user_buf, count, 0, ®idx);
876 sc->debug.regidx = regidx;
880 static const struct file_operations fops_regidx = {
881 .read = read_file_regidx,
882 .write = write_file_regidx,
884 .owner = THIS_MODULE,
885 .llseek = default_llseek,
888 static ssize_t read_file_regval(struct file *file, char __user *user_buf,
889 size_t count, loff_t *ppos)
891 struct ath_softc *sc = file->private_data;
892 struct ath_hw *ah = sc->sc_ah;
898 regval = REG_READ_D(ah, sc->debug.regidx);
899 ath9k_ps_restore(sc);
900 len = sprintf(buf, "0x%08x\n", regval);
901 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
904 static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
905 size_t count, loff_t *ppos)
907 struct ath_softc *sc = file->private_data;
908 struct ath_hw *ah = sc->sc_ah;
909 unsigned long regval;
912 ret = kstrtoul_from_user(user_buf, count, 0, ®val);
917 REG_WRITE_D(ah, sc->debug.regidx, regval);
918 ath9k_ps_restore(sc);
922 static const struct file_operations fops_regval = {
923 .read = read_file_regval,
924 .write = write_file_regval,
926 .owner = THIS_MODULE,
927 .llseek = default_llseek,
930 #define REGDUMP_LINE_SIZE 20
932 static int open_file_regdump(struct inode *inode, struct file *file)
934 struct ath_softc *sc = inode->i_private;
935 unsigned int len = 0;
938 unsigned long num_regs, regdump_len, max_reg_offset;
939 static const struct reg_hole {
942 } reg_hole_list[] = {
951 max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x8800 : 0xb500;
952 num_regs = max_reg_offset / 4 + 1;
953 regdump_len = num_regs * REGDUMP_LINE_SIZE + 1;
954 buf = vmalloc(regdump_len);
959 for (i = 0; i < num_regs; i++) {
960 if (reg_hole_list[j].start == i << 2) {
961 i = reg_hole_list[j].end >> 2;
966 len += scnprintf(buf + len, regdump_len - len,
967 "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2));
969 ath9k_ps_restore(sc);
971 file->private_data = buf;
976 static const struct file_operations fops_regdump = {
977 .open = open_file_regdump,
978 .read = ath9k_debugfs_read_buf,
979 .release = ath9k_debugfs_release_buf,
980 .owner = THIS_MODULE,
981 .llseek = default_llseek,/* read accesses f_pos */
984 static int read_file_dump_nfcal(struct seq_file *file, void *data)
986 struct ieee80211_hw *hw = dev_get_drvdata(file->private);
987 struct ath_softc *sc = hw->priv;
988 struct ath_hw *ah = sc->sc_ah;
989 struct ath9k_nfcal_hist *h = sc->cur_chan->caldata.nfCalHist;
990 struct ath_common *common = ath9k_hw_common(ah);
991 struct ieee80211_conf *conf = &common->hw->conf;
993 u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
996 seq_printf(file, "Channel Noise Floor : %d\n", ah->noise);
997 seq_puts(file, "Chain | privNF | # Readings | NF Readings\n");
998 for (i = 0; i < NUM_NF_READINGS; i++) {
999 if (!(chainmask & (1 << i)) ||
1000 ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
1003 nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount;
1004 seq_printf(file, " %d\t %d\t %d\t\t", i, h[i].privNF, nread);
1005 for (j = 0; j < nread; j++)
1006 seq_printf(file, " %d", h[i].nfCalBuffer[j]);
1007 seq_puts(file, "\n");
1013 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1014 static ssize_t read_file_btcoex(struct file *file, char __user *user_buf,
1015 size_t count, loff_t *ppos)
1017 struct ath_softc *sc = file->private_data;
1018 u32 len = 0, size = 1500;
1022 buf = kzalloc(size, GFP_KERNEL);
1026 if (!sc->sc_ah->common.btcoex_enabled) {
1027 len = scnprintf(buf, size, "%s\n",
1028 "BTCOEX is disabled");
1032 len = ath9k_dump_btcoex(sc, buf, size);
1034 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1040 static const struct file_operations fops_btcoex = {
1041 .read = read_file_btcoex,
1042 .open = simple_open,
1043 .owner = THIS_MODULE,
1044 .llseek = default_llseek,
1048 #ifdef CONFIG_ATH9K_DYNACK
1049 static ssize_t read_file_ackto(struct file *file, char __user *user_buf,
1050 size_t count, loff_t *ppos)
1052 struct ath_softc *sc = file->private_data;
1053 struct ath_hw *ah = sc->sc_ah;
1057 len = sprintf(buf, "%u %c\n", ah->dynack.ackto,
1058 (ah->dynack.enabled) ? 'A' : 'S');
1060 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1063 static const struct file_operations fops_ackto = {
1064 .read = read_file_ackto,
1065 .open = simple_open,
1066 .owner = THIS_MODULE,
1067 .llseek = default_llseek,
1071 #ifdef CONFIG_ATH9K_WOW
1073 static ssize_t read_file_wow(struct file *file, char __user *user_buf,
1074 size_t count, loff_t *ppos)
1076 struct ath_softc *sc = file->private_data;
1077 unsigned int len = 0, size = 32;
1081 buf = kzalloc(size, GFP_KERNEL);
1085 len += scnprintf(buf + len, size - len, "WOW: %s\n",
1086 sc->force_wow ? "ENABLED" : "DISABLED");
1091 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1097 static ssize_t write_file_wow(struct file *file, const char __user *user_buf,
1098 size_t count, loff_t *ppos)
1100 struct ath_softc *sc = file->private_data;
1104 ret = kstrtoul_from_user(user_buf, count, 0, &val);
1111 if (!sc->force_wow) {
1112 sc->force_wow = true;
1113 ath9k_init_wow(sc->hw);
1119 static const struct file_operations fops_wow = {
1120 .read = read_file_wow,
1121 .write = write_file_wow,
1122 .open = simple_open,
1123 .owner = THIS_MODULE,
1124 .llseek = default_llseek,
1129 static ssize_t read_file_tpc(struct file *file, char __user *user_buf,
1130 size_t count, loff_t *ppos)
1132 struct ath_softc *sc = file->private_data;
1133 struct ath_hw *ah = sc->sc_ah;
1134 unsigned int len = 0, size = 32;
1138 buf = kzalloc(size, GFP_KERNEL);
1142 len += scnprintf(buf + len, size - len, "%s\n",
1143 ah->tpc_enabled ? "ENABLED" : "DISABLED");
1148 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1154 static ssize_t write_file_tpc(struct file *file, const char __user *user_buf,
1155 size_t count, loff_t *ppos)
1157 struct ath_softc *sc = file->private_data;
1158 struct ath_hw *ah = sc->sc_ah;
1163 ret = kstrtoul_from_user(user_buf, count, 0, &val);
1170 tpc_enabled = !!val;
1172 if (tpc_enabled != ah->tpc_enabled) {
1173 ah->tpc_enabled = tpc_enabled;
1175 mutex_lock(&sc->mutex);
1176 ath9k_set_txpower(sc, NULL);
1177 mutex_unlock(&sc->mutex);
1183 static const struct file_operations fops_tpc = {
1184 .read = read_file_tpc,
1185 .write = write_file_tpc,
1186 .open = simple_open,
1187 .owner = THIS_MODULE,
1188 .llseek = default_llseek,
1191 static ssize_t read_file_nf_override(struct file *file,
1192 char __user *user_buf,
1193 size_t count, loff_t *ppos)
1195 struct ath_softc *sc = file->private_data;
1196 struct ath_hw *ah = sc->sc_ah;
1200 if (ah->nf_override == 0)
1201 len = sprintf(buf, "off\n");
1203 len = sprintf(buf, "%d\n", ah->nf_override);
1205 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1208 static ssize_t write_file_nf_override(struct file *file,
1209 const char __user *user_buf,
1210 size_t count, loff_t *ppos)
1212 struct ath_softc *sc = file->private_data;
1213 struct ath_hw *ah = sc->sc_ah;
1218 len = min(count, sizeof(buf) - 1);
1219 if (copy_from_user(buf, user_buf, len))
1223 if (strncmp("off", buf, 3) == 0)
1225 else if (kstrtol(buf, 0, &val))
1234 ah->nf_override = val;
1237 ath9k_ps_wakeup(sc);
1238 ath9k_hw_loadnf(ah, ah->curchan);
1239 ath9k_ps_restore(sc);
1245 static const struct file_operations fops_nf_override = {
1246 .read = read_file_nf_override,
1247 .write = write_file_nf_override,
1248 .open = simple_open,
1249 .owner = THIS_MODULE,
1250 .llseek = default_llseek,
1253 /* Ethtool support for get-stats */
1255 #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
1256 static const char ath9k_gstrings_stats[][ETH_GSTRING_LEN] = {
1263 AMKSTR(d_tx_mpdus_queued),
1264 AMKSTR(d_tx_mpdus_completed),
1265 AMKSTR(d_tx_mpdu_xretries),
1266 AMKSTR(d_tx_aggregates),
1267 AMKSTR(d_tx_ampdus_queued_hw),
1268 AMKSTR(d_tx_ampdus_completed),
1269 AMKSTR(d_tx_ampdu_retries),
1270 AMKSTR(d_tx_ampdu_xretries),
1271 AMKSTR(d_tx_fifo_underrun),
1272 AMKSTR(d_tx_op_exceeded),
1273 AMKSTR(d_tx_timer_expiry),
1274 AMKSTR(d_tx_desc_cfg_err),
1275 AMKSTR(d_tx_data_underrun),
1276 AMKSTR(d_tx_delim_underrun),
1278 "d_rx_decrypt_crc_err",
1281 "d_rx_pre_delim_crc_err",
1282 "d_rx_post_delim_crc_err",
1283 "d_rx_decrypt_busy_err",
1285 "d_rx_phyerr_radar",
1286 "d_rx_phyerr_ofdm_timing",
1287 "d_rx_phyerr_cck_timing",
1290 #define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats)
1292 void ath9k_get_et_strings(struct ieee80211_hw *hw,
1293 struct ieee80211_vif *vif,
1296 if (sset == ETH_SS_STATS)
1297 memcpy(data, ath9k_gstrings_stats,
1298 sizeof(ath9k_gstrings_stats));
1301 int ath9k_get_et_sset_count(struct ieee80211_hw *hw,
1302 struct ieee80211_vif *vif, int sset)
1304 if (sset == ETH_SS_STATS)
1305 return ATH9K_SSTATS_LEN;
1309 #define AWDATA(elem) \
1311 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].elem; \
1312 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].elem; \
1313 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].elem; \
1314 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].elem; \
1317 #define AWDATA_RX(elem) \
1319 data[i++] = sc->debug.stats.rxstats.elem; \
1322 void ath9k_get_et_stats(struct ieee80211_hw *hw,
1323 struct ieee80211_vif *vif,
1324 struct ethtool_stats *stats, u64 *data)
1326 struct ath_softc *sc = hw->priv;
1329 data[i++] = ((u64)sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_pkts_all +
1330 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_pkts_all +
1331 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_pkts_all +
1332 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_pkts_all);
1333 data[i++] = ((u64)sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_bytes_all +
1334 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_bytes_all +
1335 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_bytes_all +
1336 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_bytes_all);
1337 AWDATA_RX(rx_pkts_all);
1338 AWDATA_RX(rx_bytes_all);
1340 AWDATA(tx_pkts_all);
1341 AWDATA(tx_bytes_all);
1346 AWDATA(a_queued_hw);
1347 AWDATA(a_completed);
1350 AWDATA(fifo_underrun);
1353 AWDATA(desc_cfg_err);
1354 AWDATA(data_underrun);
1355 AWDATA(delim_underrun);
1358 AWDATA_RX(decrypt_crc_err);
1361 AWDATA_RX(pre_delim_crc_err);
1362 AWDATA_RX(post_delim_crc_err);
1363 AWDATA_RX(decrypt_busy_err);
1365 AWDATA_RX(phy_err_stats[ATH9K_PHYERR_RADAR]);
1366 AWDATA_RX(phy_err_stats[ATH9K_PHYERR_OFDM_TIMING]);
1367 AWDATA_RX(phy_err_stats[ATH9K_PHYERR_CCK_TIMING]);
1369 WARN_ON(i != ATH9K_SSTATS_LEN);
1372 void ath9k_deinit_debug(struct ath_softc *sc)
1374 ath9k_cmn_spectral_deinit_debug(&sc->spec_priv);
1377 int ath9k_init_debug(struct ath_hw *ah)
1379 struct ath_common *common = ath9k_hw_common(ah);
1380 struct ath_softc *sc = common->priv;
1382 sc->debug.debugfs_phy = debugfs_create_dir("ath9k",
1383 sc->hw->wiphy->debugfsdir);
1385 #ifdef CONFIG_ATH_DEBUG
1386 debugfs_create_file("debug", 0600, sc->debug.debugfs_phy,
1390 ath9k_dfs_init_debug(sc);
1391 ath9k_tx99_init_debug(sc);
1392 ath9k_cmn_spectral_init_debug(&sc->spec_priv, sc->debug.debugfs_phy);
1394 debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy,
1396 debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy,
1397 read_file_interrupt);
1398 debugfs_create_devm_seqfile(sc->dev, "xmit", sc->debug.debugfs_phy,
1400 debugfs_create_devm_seqfile(sc->dev, "queues", sc->debug.debugfs_phy,
1402 debugfs_create_devm_seqfile(sc->dev, "misc", sc->debug.debugfs_phy,
1404 debugfs_create_file("reset", 0600, sc->debug.debugfs_phy,
1407 ath9k_cmn_debug_recv(sc->debug.debugfs_phy, &sc->debug.stats.rxstats);
1408 ath9k_cmn_debug_phy_err(sc->debug.debugfs_phy, &sc->debug.stats.rxstats);
1410 debugfs_create_u8("rx_chainmask", 0400, sc->debug.debugfs_phy,
1412 debugfs_create_u8("tx_chainmask", 0400, sc->debug.debugfs_phy,
1414 debugfs_create_file("ani", 0600,
1415 sc->debug.debugfs_phy, sc, &fops_ani);
1416 debugfs_create_bool("paprd", 0600, sc->debug.debugfs_phy,
1417 &sc->sc_ah->config.enable_paprd);
1418 debugfs_create_file("regidx", 0600, sc->debug.debugfs_phy,
1420 debugfs_create_file("regval", 0600, sc->debug.debugfs_phy,
1422 debugfs_create_bool("ignore_extcca", 0600,
1423 sc->debug.debugfs_phy,
1424 &ah->config.cwm_ignore_extcca);
1425 debugfs_create_file("regdump", 0400, sc->debug.debugfs_phy, sc,
1427 debugfs_create_devm_seqfile(sc->dev, "dump_nfcal",
1428 sc->debug.debugfs_phy,
1429 read_file_dump_nfcal);
1431 ath9k_cmn_debug_base_eeprom(sc->debug.debugfs_phy, sc->sc_ah);
1432 ath9k_cmn_debug_modal_eeprom(sc->debug.debugfs_phy, sc->sc_ah);
1434 debugfs_create_u32("gpio_mask", 0600,
1435 sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
1436 debugfs_create_u32("gpio_val", 0600,
1437 sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
1438 debugfs_create_file("antenna_diversity", 0400,
1439 sc->debug.debugfs_phy, sc, &fops_antenna_diversity);
1440 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1441 debugfs_create_file("bt_ant_diversity", 0600,
1442 sc->debug.debugfs_phy, sc, &fops_bt_ant_diversity);
1443 debugfs_create_file("btcoex", 0400, sc->debug.debugfs_phy, sc,
1447 #ifdef CONFIG_ATH9K_WOW
1448 debugfs_create_file("wow", 0600, sc->debug.debugfs_phy, sc, &fops_wow);
1451 #ifdef CONFIG_ATH9K_DYNACK
1452 debugfs_create_file("ack_to", 0400, sc->debug.debugfs_phy,
1455 debugfs_create_file("tpc", 0600, sc->debug.debugfs_phy, sc, &fops_tpc);
1457 debugfs_create_file("nf_override", 0600,
1458 sc->debug.debugfs_phy, sc, &fops_nf_override);