17 #include <linux/slab.h>
19 #include <linux/export.h>
20 #include <asm/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))
30 static ssize_t ath9k_debugfs_read_buf(
struct file *
file,
char __user *user_buf,
31 size_t count, loff_t *ppos)
43 #ifdef CONFIG_ATH_DEBUG
45 static ssize_t read_file_debug(
struct file *
file,
char __user *user_buf,
46 size_t count, loff_t *ppos)
57 static ssize_t write_file_debug(
struct file *
file,
const char __user *user_buf,
58 size_t count, loff_t *ppos)
66 len =
min(count,
sizeof(buf) - 1);
79 .
read = read_file_debug,
80 .write = write_file_debug,
88 #define DMA_BUF_LEN 1024
90 static ssize_t read_file_tx_chainmask(
struct file *file,
char __user *user_buf,
91 size_t count, loff_t *ppos)
102 static ssize_t write_file_tx_chainmask(
struct file *file,
const char __user *user_buf,
103 size_t count, loff_t *ppos)
111 len =
min(count,
sizeof(buf) - 1);
125 .read = read_file_tx_chainmask,
126 .write = write_file_tx_chainmask,
133 static ssize_t read_file_rx_chainmask(
struct file *file,
char __user *user_buf,
134 size_t count, loff_t *ppos)
145 static ssize_t write_file_rx_chainmask(
struct file *file,
const char __user *user_buf,
146 size_t count, loff_t *ppos)
154 len =
min(count,
sizeof(buf) - 1);
168 .read = read_file_rx_chainmask,
169 .write = write_file_rx_chainmask,
175 static ssize_t read_file_disable_ani(
struct file *file,
char __user *user_buf,
176 size_t count, loff_t *ppos)
187 static ssize_t write_file_disable_ani(
struct file *file,
188 const char __user *user_buf,
189 size_t count, loff_t *ppos)
197 len =
min(count,
sizeof(buf) - 1);
218 .read = read_file_disable_ani,
219 .write = write_file_disable_ani,
225 static ssize_t read_file_ant_diversity(
struct file *file,
char __user *user_buf,
226 size_t count, loff_t *ppos)
237 static ssize_t write_file_ant_diversity(
struct file *file,
238 const char __user *user_buf,
239 size_t count, loff_t *ppos)
247 len =
min(count,
sizeof(buf) - 1);
269 .read = read_file_ant_diversity,
270 .write = write_file_ant_diversity,
276 static ssize_t read_file_dma(
struct file *file,
char __user *user_buf,
277 size_t count, loff_t *ppos)
283 unsigned int len = 0;
285 int i, qcuOffset = 0, dcuOffset = 0;
286 u32 *qcuBase = &val[0], *dcuBase = &val[4];
300 "Raw DMA Debug values:\n");
313 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
327 "%2d %2x %1x %2x %2x\n",
328 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
329 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
330 val[2] & (0x7 << (i * 3)) >> (i * 3),
331 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
337 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
338 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
340 "qcu_complete state: %2x dcu_complete state: %2x\n",
341 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
343 "dcu_arb state: %2x dcu_fp state: %2x\n",
344 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
346 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
347 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
349 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
350 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
352 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
353 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
371 .read = read_file_dma,
381 sc->debug.stats.istats.total++;
384 sc->debug.stats.istats.rxlp++;
386 sc->debug.stats.istats.rxhp++;
388 sc->debug.stats.istats.bb_watchdog++;
391 sc->debug.stats.istats.rxok++;
394 sc->debug.stats.istats.rxeol++;
396 sc->debug.stats.istats.rxorn++;
398 sc->debug.stats.istats.txok++;
400 sc->debug.stats.istats.txurn++;
402 sc->debug.stats.istats.rxphyerr++;
404 sc->debug.stats.istats.rx_keycache_miss++;
406 sc->debug.stats.istats.swba++;
408 sc->debug.stats.istats.bmiss++;
410 sc->debug.stats.istats.bnr++;
412 sc->debug.stats.istats.cst++;
414 sc->debug.stats.istats.gtt++;
416 sc->debug.stats.istats.tim++;
418 sc->debug.stats.istats.cabend++;
420 sc->debug.stats.istats.dtimsync++;
422 sc->debug.stats.istats.dtim++;
424 sc->debug.stats.istats.tsfoor++;
426 sc->debug.stats.istats.mci++;
428 sc->debug.stats.istats.gen_timer++;
431 static ssize_t read_file_interrupt(
struct file *file,
char __user *user_buf,
432 size_t count, loff_t *ppos)
435 unsigned int len = 0;
442 #define PR_IS(a, s) \
444 len += snprintf(buf + len, mxlen - len, \
446 sc->debug.stats.istats.s); \
452 PR_IS(
"WATHDOG", bb_watchdog);
456 PR_IS(
"RXEOL", rxeol);
457 PR_IS(
"RXORN", rxorn);
459 PR_IS(
"TXURN", txurn);
461 PR_IS(
"RXPHY", rxphyerr);
462 PR_IS(
"RXKCM", rx_keycache_miss);
464 PR_IS(
"BMISS", bmiss);
469 PR_IS(
"CABEND", cabend);
470 PR_IS(
"DTIMSYNC", dtimsync);
472 PR_IS(
"TSFOOR", tsfoor);
474 PR_IS(
"GENTIMER", gen_timer);
475 PR_IS(
"TOTAL", total);
477 len +=
snprintf(buf + len, mxlen - len,
478 "SYNC_CAUSE stats:\n");
480 PR_IS(
"Sync-All", sync_cause_all);
481 PR_IS(
"RTC-IRQ", sync_rtc_irq);
482 PR_IS(
"MAC-IRQ", sync_mac_irq);
483 PR_IS(
"EEPROM-Illegal-Access", eeprom_illegal_access);
484 PR_IS(
"APB-Timeout", apb_timeout);
485 PR_IS(
"PCI-Mode-Conflict", pci_mode_conflict);
486 PR_IS(
"HOST1-Fatal", host1_fatal);
487 PR_IS(
"HOST1-Perr", host1_perr);
488 PR_IS(
"TRCV-FIFO-Perr", trcv_fifo_perr);
489 PR_IS(
"RADM-CPL-EP", radm_cpl_ep);
490 PR_IS(
"RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort);
491 PR_IS(
"RADM-CPL-TLP-Abort", radm_cpl_tlp_abort);
492 PR_IS(
"RADM-CPL-ECRC-Err", radm_cpl_ecrc_err);
493 PR_IS(
"RADM-CPL-Timeout", radm_cpl_timeout);
494 PR_IS(
"Local-Bus-Timeout", local_timeout);
495 PR_IS(
"PM-Access", pm_access);
496 PR_IS(
"MAC-Awake", mac_awake);
497 PR_IS(
"MAC-Asleep", mac_asleep);
498 PR_IS(
"MAC-Sleep-Access", mac_sleep_access);
509 .read = read_file_interrupt,
515 #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum
516 #define PR(str, elem) \
518 len += snprintf(buf + len, size - len, \
519 "%s%13u%11u%10u%10u\n", str, \
520 sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem, \
521 sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem, \
522 sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem, \
523 sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem); \
528 #define PRX(str, elem) \
530 len += snprintf(buf + len, size - len, \
531 "%s%13u%11u%10u%10u\n", str, \
532 (unsigned int)(sc->tx.txq_map[WME_AC_BE]->elem), \
533 (unsigned int)(sc->tx.txq_map[WME_AC_BK]->elem), \
534 (unsigned int)(sc->tx.txq_map[WME_AC_VI]->elem), \
535 (unsigned int)(sc->tx.txq_map[WME_AC_VO]->elem)); \
540 #define PRQLE(str, elem) \
542 len += snprintf(buf + len, size - len, \
543 "%s%13i%11i%10i%10i\n", str, \
544 list_empty(&sc->tx.txq_map[WME_AC_BE]->elem), \
545 list_empty(&sc->tx.txq_map[WME_AC_BK]->elem), \
546 list_empty(&sc->tx.txq_map[WME_AC_VI]->elem), \
547 list_empty(&sc->tx.txq_map[WME_AC_VO]->elem)); \
552 static ssize_t read_file_xmit(
struct file *file,
char __user *user_buf,
553 size_t count, loff_t *ppos)
557 unsigned int len = 0,
size = 8000;
566 len +=
sprintf(buf,
"Num-Tx-Queues: %i tx-queues-setup: 0x%x"
567 " poll-work-seen: %u\n"
568 "%30s %10s%10s%10s\n\n",
570 sc->tx_complete_poll_work_seen,
571 "BE",
"BK",
"VI",
"VO");
573 PR(
"MPDUs Queued: ", queued);
575 PR(
"MPDUs XRetried: ", xretries);
576 PR(
"Aggregates: ", a_aggr);
577 PR(
"AMPDUs Queued HW:", a_queued_hw);
578 PR(
"AMPDUs Queued SW:", a_queued_sw);
579 PR(
"AMPDUs Completed:", a_completed);
580 PR(
"AMPDUs Retried: ", a_retries);
581 PR(
"AMPDUs XRetried: ", a_xretries);
582 PR(
"FIFO Underrun: ", fifo_underrun);
583 PR(
"TXOP Exceeded: ", xtxop);
584 PR(
"TXTIMER Expiry: ", timer_exp);
585 PR(
"DESC CFG Error: ", desc_cfg_err);
586 PR(
"DATA Underrun: ", data_underrun);
587 PR(
"DELIM Underrun: ", delim_underrun);
588 PR(
"TX-Pkts-All: ", tx_pkts_all);
589 PR(
"TX-Bytes-All: ", tx_bytes_all);
590 PR(
"hw-put-tx-buf: ", puttxbuf);
591 PR(
"hw-tx-start: ", txstart);
592 PR(
"hw-tx-proc-desc: ", txprocdesc);
593 PR(
"TX-Failed: ", txfailed);
595 "%s%11p%11p%10p%10p\n",
"txq-memory-address:",
603 PRX(
"axq-qnum: ", axq_qnum);
604 PRX(
"axq-depth: ", axq_depth);
605 PRX(
"axq-ampdu_depth: ", axq_ampdu_depth);
607 PRX(
"tx-in-progress ", axq_tx_inprogress);
608 PRX(
"pending-frames ", pending_frames);
609 PRX(
"txq_headidx: ", txq_headidx);
610 PRX(
"txq_tailidx: ", txq_headidx);
612 PRQLE(
"axq_q empty: ", axq_q);
613 PRQLE(
"axq_acq empty: ", axq_acq);
615 snprintf(tmp,
sizeof(tmp) - 1,
"txq_fifo[%i] empty: ", i);
616 PRQLE(tmp, txq_fifo[i]);
627 if (!list_empty(&txq->
axq_acq)) {
631 "txq[%i] first-ac: %p sched: %i\n",
633 if (list_empty(&ac->
tid_q) || (len >=
size))
638 " first-tid: %p sched: %i paused: %i\n",
655 static ssize_t read_file_stations(
struct file *file,
char __user *user_buf,
656 size_t count, loff_t *ppos)
660 unsigned int len = 0,
size = 64000;
671 " tid: addr sched paused buf_q-empty an ac baw\n"
672 " ac: addr sched tid_q-empty txq\n");
674 spin_lock(&sc->nodes_lock);
680 "iface: %pM sta: %pM max-ampdu: %hu mpdu-density: %uus\n",
681 an->
vif->addr, an->
sta->addr, ma,
689 " tid: %p %s %s %i %p %p %hu\n",
690 tid, tid->
sched ?
"sched" :
"idle",
691 tid->
paused ?
"paused" :
"running",
692 skb_queue_empty(&tid->
buf_q),
701 " ac: %p %s %i %p\n",
702 ac, ac->
sched ?
"sched" :
"idle",
710 spin_unlock(&sc->nodes_lock);
720 static ssize_t read_file_misc(
struct file *file,
char __user *user_buf,
721 size_t count, loff_t *ppos)
728 unsigned int len = 0;
733 len +=
snprintf(buf + len,
sizeof(buf) - len,
735 len +=
snprintf(buf + len,
sizeof(buf) - len,
737 len +=
snprintf(buf + len,
sizeof(buf) - len,
744 len +=
snprintf(buf + len,
sizeof(buf) - len,
745 "RXFILTER: 0x%x", rxfilter);
748 len +=
snprintf(buf + len,
sizeof(buf) - len,
" UCAST");
750 len +=
snprintf(buf + len,
sizeof(buf) - len,
" MCAST");
752 len +=
snprintf(buf + len,
sizeof(buf) - len,
" BCAST");
754 len +=
snprintf(buf + len,
sizeof(buf) - len,
" CONTROL");
756 len +=
snprintf(buf + len,
sizeof(buf) - len,
" BEACON");
758 len +=
snprintf(buf + len,
sizeof(buf) - len,
" PROM");
760 len +=
snprintf(buf + len,
sizeof(buf) - len,
" PROBEREQ");
762 len +=
snprintf(buf + len,
sizeof(buf) - len,
" PHYERR");
764 len +=
snprintf(buf + len,
sizeof(buf) - len,
" MYBEACON");
766 len +=
snprintf(buf + len,
sizeof(buf) - len,
" COMP_BAR");
768 len +=
snprintf(buf + len,
sizeof(buf) - len,
" PSPOLL");
770 len +=
snprintf(buf + len,
sizeof(buf) - len,
" PHYRADAR");
772 len +=
snprintf(buf + len,
sizeof(buf) - len,
" MCAST_BCAST_ALL");
774 len +=
snprintf(buf + len,
sizeof(buf) - len,
" CONTROL_WRAPPER");
776 len +=
snprintf(buf + len,
sizeof(buf) - len,
"\n");
778 reg = sc->
sc_ah->imask;
780 len +=
snprintf(buf + len,
sizeof(buf) - len,
"INTERRUPT-MASK: 0x%x", reg);
783 len +=
snprintf(buf + len,
sizeof(buf) - len,
" SWBA");
785 len +=
snprintf(buf + len,
sizeof(buf) - len,
" BMISS");
787 len +=
snprintf(buf + len,
sizeof(buf) - len,
" CST");
789 len +=
snprintf(buf + len,
sizeof(buf) - len,
" RX");
791 len +=
snprintf(buf + len,
sizeof(buf) - len,
" RXHP");
793 len +=
snprintf(buf + len,
sizeof(buf) - len,
" RXLP");
795 len +=
snprintf(buf + len,
sizeof(buf) - len,
" BB_WATCHDOG");
797 len +=
snprintf(buf + len,
sizeof(buf) - len,
"\n");
801 len +=
snprintf(buf + len,
sizeof(buf) - len,
802 "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i"
803 " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n",
804 iter_data.naps, iter_data.nstations, iter_data.nmeshes,
805 iter_data.nwds, iter_data.nadhocs,
808 if (len >
sizeof(buf))
815 static ssize_t read_file_reset(
struct file *file,
char __user *user_buf,
816 size_t count, loff_t *ppos)
820 unsigned int len = 0;
822 len +=
snprintf(buf + len,
sizeof(buf) - len,
823 "%17s: %2d\n",
"Baseband Hang",
825 len +=
snprintf(buf + len,
sizeof(buf) - len,
826 "%17s: %2d\n",
"Baseband Watchdog",
828 len +=
snprintf(buf + len,
sizeof(buf) - len,
829 "%17s: %2d\n",
"Fatal HW Error",
831 len +=
snprintf(buf + len,
sizeof(buf) - len,
832 "%17s: %2d\n",
"TX HW error",
834 len +=
snprintf(buf + len,
sizeof(buf) - len,
835 "%17s: %2d\n",
"TX Path Hang",
837 len +=
snprintf(buf + len,
sizeof(buf) - len,
838 "%17s: %2d\n",
"PLL RX Hang",
841 if (len >
sizeof(buf))
851 #define TX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].ts\
856 sc->debug.stats.txstats[qnum].tx_bytes_all += bf->
bf_mpdu->len;
883 #ifdef CONFIG_ATH9K_MAC_DEBUG
884 spin_lock(&sc->debug.samp_lock);
908 sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES;
909 spin_unlock(&sc->debug.samp_lock);
916 .read = read_file_xmit,
923 .read = read_file_stations,
930 .read = read_file_misc,
937 .read = read_file_reset,
943 static ssize_t read_file_recv(
struct file *file,
char __user *user_buf,
944 size_t count, loff_t *ppos)
946 #define PHY_ERR(s, p) \
947 len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \
948 sc->debug.stats.rxstats.phy_err_stats[p]);
950 #define RXS_ERR(s, e) \
952 len += snprintf(buf + len, size - len, \
953 "%22s : %10u\n", s, \
954 sc->debug.stats.rxstats.e); \
959 unsigned int len = 0,
size = 1600;
967 RXS_ERR(
"DECRYPT CRC ERR", decrypt_crc_err);
970 RXS_ERR(
"PRE-DELIM CRC ERR", pre_delim_crc_err);
971 RXS_ERR(
"POST-DELIM CRC ERR", post_delim_crc_err);
972 RXS_ERR(
"DECRYPT BUSY ERR", decrypt_busy_err);
973 RXS_ERR(
"RX-LENGTH-ERR", rx_len_err);
974 RXS_ERR(
"RX-OOM-ERR", rx_oom_err);
975 RXS_ERR(
"RX-RATE-ERR", rx_rate_err);
976 RXS_ERR(
"RX-DROP-RXFLUSH", rx_drop_rxflush);
977 RXS_ERR(
"RX-TOO-MANY-FRAGS", rx_too_many_frags_err);
1006 RXS_ERR(
"RX-Pkts-All", rx_pkts_all);
1007 RXS_ERR(
"RX-Bytes-All", rx_bytes_all);
1008 RXS_ERR(
"RX-Beacons", rx_beacons);
1009 RXS_ERR(
"RX-Frags", rx_frags);
1025 #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
1026 #define RX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].rs\
1027 [sc->debug.rsidx].c)
1030 sc->debug.stats.rxstats.rx_bytes_all += rs->
rs_datalen;
1051 #ifdef CONFIG_ATH9K_MAC_DEBUG
1052 spin_lock(&sc->debug.samp_lock);
1065 sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES;
1066 spin_unlock(&sc->debug.samp_lock);
1070 #undef RX_PHY_ERR_INC
1075 .read = read_file_recv,
1081 static ssize_t read_file_regidx(
struct file *file,
char __user *user_buf,
1082 size_t count, loff_t *ppos)
1088 len =
sprintf(buf,
"0x%08x\n", sc->debug.regidx);
1092 static ssize_t write_file_regidx(
struct file *file,
const char __user *user_buf,
1093 size_t count, loff_t *ppos)
1096 unsigned long regidx;
1100 len =
min(count,
sizeof(buf) - 1);
1108 sc->debug.regidx = regidx;
1113 .read = read_file_regidx,
1114 .write = write_file_regidx,
1120 static ssize_t read_file_regval(
struct file *file,
char __user *user_buf,
1121 size_t count, loff_t *ppos)
1132 len =
sprintf(buf,
"0x%08x\n", regval);
1136 static ssize_t write_file_regval(
struct file *file,
const char __user *user_buf,
1137 size_t count, loff_t *ppos)
1145 len =
min(count,
sizeof(buf) - 1);
1160 .read = read_file_regval,
1161 .write = write_file_regval,
1167 #define REGDUMP_LINE_SIZE 20
1169 static int open_file_regdump(
struct inode *
inode,
struct file *file)
1172 unsigned int len = 0;
1175 unsigned long num_regs, regdump_len, max_reg_offset;
1178 num_regs = max_reg_offset / 4 + 1;
1185 for (i = 0; i < num_regs; i++)
1186 len +=
scnprintf(buf + len, regdump_len - len,
1196 .open = open_file_regdump,
1197 .read = ath9k_debugfs_read_buf,
1198 .release = ath9k_debugfs_release_buf,
1203 static ssize_t read_file_dump_nfcal(
struct file *file,
char __user *user_buf,
1204 size_t count, loff_t *ppos)
1209 struct ath_common *common = ath9k_hw_common(ah);
1223 "Channel Noise Floor : %d\n", ah->
noise);
1225 "Chain | privNF | # Readings | NF Readings\n");
1227 if (!(chainmask & (1 << i)) ||
1232 len +=
snprintf(buf + len,
size - len,
" %d\t %d\t %d\t\t",
1233 i, h[i].privNF, nread);
1234 for (j = 0; j < nread; j++)
1236 " %d", h[i].nfCalBuffer[j]);
1250 .read = read_file_dump_nfcal,
1256 static ssize_t read_file_base_eeprom(
struct file *file,
char __user *user_buf,
1257 size_t count, loff_t *ppos)
1269 len = ah->
eep_ops->dump_eeprom(ah,
true, buf, len,
size);
1278 .read = read_file_base_eeprom,
1284 static ssize_t read_file_modal_eeprom(
struct file *file,
char __user *user_buf,
1285 size_t count, loff_t *ppos)
1297 len = ah->
eep_ops->dump_eeprom(ah,
false, buf, len,
size);
1306 .read = read_file_modal_eeprom,
1312 #ifdef CONFIG_ATH9K_MAC_DEBUG
1314 void ath9k_debug_samp_bb_mac(
struct ath_softc *sc)
1316 #define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c)
1318 struct ath_common *common = ath9k_hw_common(ah);
1319 unsigned long flags;
1324 spin_lock_bh(&sc->debug.samp_lock);
1329 ATH_SAMP_DBG(
cc.cycles) = common->
cc_ani.cycles;
1330 ATH_SAMP_DBG(
cc.rx_busy) = common->
cc_ani.rx_busy;
1331 ATH_SAMP_DBG(
cc.rx_frame) = common->
cc_ani.rx_frame;
1332 ATH_SAMP_DBG(
cc.tx_frame) = common->
cc_ani.tx_frame;
1333 spin_unlock_irqrestore(&common->
cc_lock, flags);
1335 ATH_SAMP_DBG(noise) = ah->
noise;
1343 ATH_SAMP_DBG(dma_dbg_reg_vals[i]) =
REG_READ_D(ah,
1350 sizeof(ATH_SAMP_DBG(nfCalHist)));
1352 sc->debug.sampidx = (sc->debug.sampidx + 1) % ATH_DBG_MAX_SAMPLES;
1353 spin_unlock_bh(&sc->debug.samp_lock);
1359 static int open_file_bb_mac_samps(
struct inode *
inode,
struct file *file)
1361 #define ATH_SAMP_DBG(c) bb_mac_samp[sampidx].c
1364 struct ath_common *common = ath9k_hw_common(ah);
1366 struct ath_dbg_bb_mac_samp *bb_mac_samp;
1368 int i,
j, qcuOffset = 0, dcuOffset = 0;
1369 u32 *qcuBase, *dcuBase,
size = 30000, len = 0;
1381 bb_mac_samp =
vmalloc(
sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES);
1387 ath9k_debug_samp_bb_mac(sc);
1389 spin_lock_bh(&sc->debug.samp_lock);
1390 memcpy(bb_mac_samp, sc->debug.bb_mac_samp,
1391 sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES);
1392 len +=
snprintf(buf + len, size - len,
1393 "Current Sample Index: %d\n", sc->debug.sampidx);
1394 spin_unlock_bh(&sc->debug.samp_lock);
1396 len +=
snprintf(buf + len, size - len,
1397 "Raw DMA Debug Dump:\n");
1398 len +=
snprintf(buf + len, size - len,
"Sample |\t");
1400 len +=
snprintf(buf + len, size - len,
" DMA Reg%d |\t", i);
1401 len +=
snprintf(buf + len, size - len,
"\n");
1403 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1404 len +=
snprintf(buf + len, size - len,
"%d\t", sampidx);
1407 len +=
snprintf(buf + len, size - len,
" %08x\t",
1408 ATH_SAMP_DBG(dma_dbg_reg_vals[i]));
1409 len +=
snprintf(buf + len, size - len,
"\n");
1411 len +=
snprintf(buf + len, size - len,
"\n");
1413 len +=
snprintf(buf + len, size - len,
1414 "Sample Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
1415 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1416 qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]);
1417 dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]);
1420 qcuOffset += 4, dcuOffset += 5) {
1430 if (!sc->debug.stats.txstats[i].queued)
1433 len +=
snprintf(buf + len, size - len,
1434 "%4d %7d %2x %1x %2x %2x\n",
1436 (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
1437 (*qcuBase & (0x8 << qcuOffset)) >>
1439 ATH_SAMP_DBG(dma_dbg_reg_vals[2]) &
1440 (0x7 << (i * 3)) >> (i * 3),
1441 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
1443 len +=
snprintf(buf + len, size - len,
"\n");
1445 len +=
snprintf(buf + len, size - len,
1446 "samp qcu_sh qcu_fh qcu_comp dcu_comp dcu_arb dcu_fp "
1447 "ch_idle_dur ch_idle_dur_val txfifo_val0 txfifo_val1 "
1448 "txfifo_dcu0 txfifo_dcu1 pcu_obs AR_CR\n");
1450 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1451 qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]);
1452 dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]);
1454 len +=
snprintf(buf + len, size - len,
"%4d %5x %5x ", sampidx,
1455 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x003c0000) >> 18,
1456 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x03c00000) >> 22);
1457 len +=
snprintf(buf + len, size - len,
"%7x %8x ",
1458 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x1c000000) >> 26,
1459 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x3));
1460 len +=
snprintf(buf + len, size - len,
"%7x %7x ",
1461 (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x06000000) >> 25,
1462 (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x38000000) >> 27);
1463 len +=
snprintf(buf + len, size - len,
"%7d %12d ",
1464 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x000003fc) >> 2,
1465 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000400) >> 10);
1466 len +=
snprintf(buf + len, size - len,
"%12d %12d ",
1467 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000800) >> 11,
1468 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00001000) >> 12);
1469 len +=
snprintf(buf + len, size - len,
"%12d %12d ",
1470 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x0001e000) >> 13,
1471 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x001e0000) >> 17);
1472 len +=
snprintf(buf + len, size - len,
"0x%07x 0x%07x\n",
1473 ATH_SAMP_DBG(pcu_obs), ATH_SAMP_DBG(pcu_cr));
1476 len +=
snprintf(buf + len, size - len,
1477 "Sample ChNoise Chain privNF #Reading Readings\n");
1478 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1479 h = ATH_SAMP_DBG(nfCalHist);
1480 if (!ATH_SAMP_DBG(noise))
1484 if (!(chainmask & (1 << i)) ||
1490 len +=
snprintf(buf + len, size - len,
1491 "%4d %5d %4d\t %d\t %d\t",
1492 sampidx, ATH_SAMP_DBG(noise),
1494 for (j = 0; j < nread; j++)
1495 len +=
snprintf(buf + len, size - len,
1497 len +=
snprintf(buf + len, size - len,
"\n");
1500 len +=
snprintf(buf + len, size - len,
"\nCycle counters:\n"
1501 "Sample Total Rxbusy Rxframes Txframes\n");
1502 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1503 if (!ATH_SAMP_DBG(
cc.cycles))
1505 len +=
snprintf(buf + len, size - len,
1506 "%4d %08x %08x %08x %08x\n",
1507 sampidx, ATH_SAMP_DBG(
cc.cycles),
1508 ATH_SAMP_DBG(
cc.rx_busy),
1509 ATH_SAMP_DBG(
cc.rx_frame),
1510 ATH_SAMP_DBG(
cc.tx_frame));
1513 len +=
snprintf(buf + len, size - len,
"Tx status Dump :\n");
1514 len +=
snprintf(buf + len, size - len,
1515 "Sample rssi:- ctl0 ctl1 ctl2 ext0 ext1 ext2 comb "
1516 "isok rts_fail data_fail rate tid qid "
1517 "ba_low ba_high tx_before(ms)\n");
1518 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1519 for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) {
1520 if (!ATH_SAMP_DBG(
ts[i].jiffies))
1522 len +=
snprintf(buf + len, size - len,
"%-14d"
1523 "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-8d "
1524 "%-9d %-4d %-3d %-3d %08x %08x %-11d\n",
1526 ATH_SAMP_DBG(
ts[i].rssi_ctl0),
1527 ATH_SAMP_DBG(
ts[i].rssi_ctl1),
1528 ATH_SAMP_DBG(
ts[i].rssi_ctl2),
1529 ATH_SAMP_DBG(
ts[i].rssi_ext0),
1530 ATH_SAMP_DBG(
ts[i].rssi_ext1),
1531 ATH_SAMP_DBG(
ts[i].rssi_ext2),
1532 ATH_SAMP_DBG(
ts[i].rssi),
1533 ATH_SAMP_DBG(
ts[i].isok),
1534 ATH_SAMP_DBG(
ts[i].rts_fail_cnt),
1535 ATH_SAMP_DBG(
ts[i].data_fail_cnt),
1536 ATH_SAMP_DBG(
ts[i].rateindex),
1537 ATH_SAMP_DBG(
ts[i].tid),
1538 ATH_SAMP_DBG(
ts[i].
qid),
1539 ATH_SAMP_DBG(
ts[i].ba_low),
1540 ATH_SAMP_DBG(
ts[i].ba_high),
1542 ATH_SAMP_DBG(
ts[i].jiffies)));
1546 len +=
snprintf(buf + len, size - len,
"Rx status Dump :\n");
1547 len +=
snprintf(buf + len, size - len,
"Sample rssi:- ctl0 ctl1 ctl2 "
1548 "ext0 ext1 ext2 comb beacon ant rate rx_before(ms)\n");
1549 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1550 for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) {
1551 if (!ATH_SAMP_DBG(rs[i].jiffies))
1553 len +=
snprintf(buf + len, size - len,
"%-14d"
1554 "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-9s %-2d %02x %-13d\n",
1556 ATH_SAMP_DBG(rs[i].rssi_ctl0),
1557 ATH_SAMP_DBG(rs[i].rssi_ctl1),
1558 ATH_SAMP_DBG(rs[i].rssi_ctl2),
1559 ATH_SAMP_DBG(rs[i].rssi_ext0),
1560 ATH_SAMP_DBG(rs[i].rssi_ext1),
1561 ATH_SAMP_DBG(rs[i].rssi_ext2),
1562 ATH_SAMP_DBG(rs[i].rssi),
1563 ATH_SAMP_DBG(rs[i].is_mybeacon) ?
1566 ATH_SAMP_DBG(rs[i].
rate),
1568 ATH_SAMP_DBG(rs[i].jiffies)));
1580 .
open = open_file_bb_mac_samps,
1581 .read = ath9k_debugfs_read_buf,
1582 .release = ath9k_debugfs_release_buf,
1591 struct ath_common *common = ath9k_hw_common(ah);
1595 sc->
hw->wiphy->debugfsdir);
1596 if (!sc->debug.debugfs_phy)
1599 #ifdef CONFIG_ATH_DEBUG
1629 sc->debug.debugfs_phy, sc, &fops_rx_chainmask);
1631 sc->debug.debugfs_phy, sc, &fops_tx_chainmask);
1633 sc->debug.debugfs_phy, sc, &fops_disable_ani);
1635 &sc->
sc_ah->config.enable_paprd);
1641 sc->debug.debugfs_phy,
1642 &ah->
config.cwm_ignore_extcca);
1650 &fops_modal_eeprom);
1651 #ifdef CONFIG_ATH9K_MAC_DEBUG
1656 sc->debug.debugfs_phy, &sc->
sc_ah->gpio_mask);
1658 sc->debug.debugfs_phy, &sc->
sc_ah->gpio_val);
1660 sc->debug.debugfs_phy, sc, &fops_ant_diversity);