2 * Copyright (c) 2008-2009 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 <asm/unaligned.h>
21 #define REG_WRITE_D(_ah, _reg, _val) \
22 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
23 #define REG_READ_D(_ah, _reg) \
24 ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
26 static struct dentry *ath9k_debugfs_root;
28 static int ath9k_debugfs_open(struct inode *inode, struct file *file)
30 file->private_data = inode->i_private;
34 #ifdef CONFIG_ATH_DEBUG
36 static ssize_t read_file_debug(struct file *file, char __user *user_buf,
37 size_t count, loff_t *ppos)
39 struct ath_softc *sc = file->private_data;
40 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
44 len = snprintf(buf, sizeof(buf), "0x%08x\n", common->debug_mask);
45 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
48 static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
49 size_t count, loff_t *ppos)
51 struct ath_softc *sc = file->private_data;
52 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
57 len = min(count, sizeof(buf) - 1);
58 if (copy_from_user(buf, user_buf, len))
62 if (strict_strtoul(buf, 0, &mask))
65 common->debug_mask = mask;
69 static const struct file_operations fops_debug = {
70 .read = read_file_debug,
71 .write = write_file_debug,
72 .open = ath9k_debugfs_open,
78 #define DMA_BUF_LEN 1024
80 static ssize_t read_file_dma(struct file *file, char __user *user_buf,
81 size_t count, loff_t *ppos)
83 struct ath_softc *sc = file->private_data;
84 struct ath_hw *ah = sc->sc_ah;
88 u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
89 int i, qcuOffset = 0, dcuOffset = 0;
90 u32 *qcuBase = &val[0], *dcuBase = &val[4];
92 buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL);
98 REG_WRITE_D(ah, AR_MACMISC,
99 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
100 (AR_MACMISC_MISC_OBS_BUS_1 <<
101 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
103 len += snprintf(buf + len, DMA_BUF_LEN - len,
104 "Raw DMA Debug values:\n");
106 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
108 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
110 val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
111 len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ",
115 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n");
116 len += snprintf(buf + len, DMA_BUF_LEN - len,
117 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
119 for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
130 len += snprintf(buf + len, DMA_BUF_LEN - len,
131 "%2d %2x %1x %2x %2x\n",
132 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
133 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
134 val[2] & (0x7 << (i * 3)) >> (i * 3),
135 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
138 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
140 len += snprintf(buf + len, DMA_BUF_LEN - len,
141 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
142 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
143 len += snprintf(buf + len, DMA_BUF_LEN - len,
144 "qcu_complete state: %2x dcu_complete state: %2x\n",
145 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
146 len += snprintf(buf + len, DMA_BUF_LEN - len,
147 "dcu_arb state: %2x dcu_fp state: %2x\n",
148 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
149 len += snprintf(buf + len, DMA_BUF_LEN - len,
150 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
151 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
152 len += snprintf(buf + len, DMA_BUF_LEN - len,
153 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
154 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
155 len += snprintf(buf + len, DMA_BUF_LEN - len,
156 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
157 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
159 len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x \n",
160 REG_READ_D(ah, AR_OBS_BUS_1));
161 len += snprintf(buf + len, DMA_BUF_LEN - len,
162 "AR_CR: 0x%x \n", REG_READ_D(ah, AR_CR));
164 ath9k_ps_restore(sc);
166 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
171 static const struct file_operations fops_dma = {
172 .read = read_file_dma,
173 .open = ath9k_debugfs_open,
178 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status)
181 sc->debug.stats.istats.total++;
182 if (status & ATH9K_INT_RX)
183 sc->debug.stats.istats.rxok++;
184 if (status & ATH9K_INT_RXEOL)
185 sc->debug.stats.istats.rxeol++;
186 if (status & ATH9K_INT_RXORN)
187 sc->debug.stats.istats.rxorn++;
188 if (status & ATH9K_INT_TX)
189 sc->debug.stats.istats.txok++;
190 if (status & ATH9K_INT_TXURN)
191 sc->debug.stats.istats.txurn++;
192 if (status & ATH9K_INT_MIB)
193 sc->debug.stats.istats.mib++;
194 if (status & ATH9K_INT_RXPHY)
195 sc->debug.stats.istats.rxphyerr++;
196 if (status & ATH9K_INT_RXKCM)
197 sc->debug.stats.istats.rx_keycache_miss++;
198 if (status & ATH9K_INT_SWBA)
199 sc->debug.stats.istats.swba++;
200 if (status & ATH9K_INT_BMISS)
201 sc->debug.stats.istats.bmiss++;
202 if (status & ATH9K_INT_BNR)
203 sc->debug.stats.istats.bnr++;
204 if (status & ATH9K_INT_CST)
205 sc->debug.stats.istats.cst++;
206 if (status & ATH9K_INT_GTT)
207 sc->debug.stats.istats.gtt++;
208 if (status & ATH9K_INT_TIM)
209 sc->debug.stats.istats.tim++;
210 if (status & ATH9K_INT_CABEND)
211 sc->debug.stats.istats.cabend++;
212 if (status & ATH9K_INT_DTIMSYNC)
213 sc->debug.stats.istats.dtimsync++;
214 if (status & ATH9K_INT_DTIM)
215 sc->debug.stats.istats.dtim++;
218 static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
219 size_t count, loff_t *ppos)
221 struct ath_softc *sc = file->private_data;
223 unsigned int len = 0;
225 len += snprintf(buf + len, sizeof(buf) - len,
226 "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok);
227 len += snprintf(buf + len, sizeof(buf) - len,
228 "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol);
229 len += snprintf(buf + len, sizeof(buf) - len,
230 "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn);
231 len += snprintf(buf + len, sizeof(buf) - len,
232 "%8s: %10u\n", "TX", sc->debug.stats.istats.txok);
233 len += snprintf(buf + len, sizeof(buf) - len,
234 "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn);
235 len += snprintf(buf + len, sizeof(buf) - len,
236 "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib);
237 len += snprintf(buf + len, sizeof(buf) - len,
238 "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr);
239 len += snprintf(buf + len, sizeof(buf) - len,
240 "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss);
241 len += snprintf(buf + len, sizeof(buf) - len,
242 "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba);
243 len += snprintf(buf + len, sizeof(buf) - len,
244 "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss);
245 len += snprintf(buf + len, sizeof(buf) - len,
246 "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr);
247 len += snprintf(buf + len, sizeof(buf) - len,
248 "%8s: %10u\n", "CST", sc->debug.stats.istats.cst);
249 len += snprintf(buf + len, sizeof(buf) - len,
250 "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt);
251 len += snprintf(buf + len, sizeof(buf) - len,
252 "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim);
253 len += snprintf(buf + len, sizeof(buf) - len,
254 "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend);
255 len += snprintf(buf + len, sizeof(buf) - len,
256 "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync);
257 len += snprintf(buf + len, sizeof(buf) - len,
258 "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim);
259 len += snprintf(buf + len, sizeof(buf) - len,
260 "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total);
262 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
265 static const struct file_operations fops_interrupt = {
266 .read = read_file_interrupt,
267 .open = ath9k_debugfs_open,
271 void ath_debug_stat_rc(struct ath_softc *sc, int final_rate)
273 struct ath_rc_stats *stats;
275 stats = &sc->debug.stats.rcstats[final_rate];
279 void ath_debug_stat_retries(struct ath_softc *sc, int rix,
280 int xretries, int retries, u8 per)
282 struct ath_rc_stats *stats = &sc->debug.stats.rcstats[rix];
284 stats->xretries += xretries;
285 stats->retries += retries;
289 static ssize_t read_file_rcstat(struct file *file, char __user *user_buf,
290 size_t count, loff_t *ppos)
292 struct ath_softc *sc = file->private_data;
294 unsigned int len = 0, max;
298 if (sc->cur_rate_table == NULL)
301 max = 80 + sc->cur_rate_table->rate_cnt * 1024;
302 buf = kmalloc(max + 1, GFP_KERNEL);
307 len += sprintf(buf, "%6s %6s %6s "
308 "%10s %10s %10s %10s\n",
310 "Success", "Retries", "XRetries", "PER");
312 for (i = 0; i < sc->cur_rate_table->rate_cnt; i++) {
313 u32 ratekbps = sc->cur_rate_table->info[i].ratekbps;
314 struct ath_rc_stats *stats = &sc->debug.stats.rcstats[i];
317 int used_mcs = 0, used_htmode = 0;
319 if (WLAN_RC_PHY_HT(sc->cur_rate_table->info[i].phy)) {
320 used_mcs = snprintf(mcs, 5, "%d",
321 sc->cur_rate_table->info[i].ratecode);
323 if (WLAN_RC_PHY_40(sc->cur_rate_table->info[i].phy))
324 used_htmode = snprintf(htmode, 5, "HT40");
325 else if (WLAN_RC_PHY_20(sc->cur_rate_table->info[i].phy))
326 used_htmode = snprintf(htmode, 5, "HT20");
328 used_htmode = snprintf(htmode, 5, "????");
331 mcs[used_mcs] = '\0';
332 htmode[used_htmode] = '\0';
334 len += snprintf(buf + len, max - len,
336 "%10u %10u %10u %10u\n",
340 (ratekbps % 1000) / 100,
347 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
352 static const struct file_operations fops_rcstat = {
353 .read = read_file_rcstat,
354 .open = ath9k_debugfs_open,
358 static const char * ath_wiphy_state_str(enum ath_wiphy_state state)
361 case ATH_WIPHY_INACTIVE:
363 case ATH_WIPHY_ACTIVE:
365 case ATH_WIPHY_PAUSING:
367 case ATH_WIPHY_PAUSED:
375 static ssize_t read_file_wiphy(struct file *file, char __user *user_buf,
376 size_t count, loff_t *ppos)
378 struct ath_softc *sc = file->private_data;
380 unsigned int len = 0;
384 len += snprintf(buf + len, sizeof(buf) - len,
385 "primary: %s (%s chan=%d ht=%d)\n",
386 wiphy_name(sc->pri_wiphy->hw->wiphy),
387 ath_wiphy_state_str(sc->pri_wiphy->state),
388 sc->pri_wiphy->chan_idx, sc->pri_wiphy->chan_is_ht);
389 for (i = 0; i < sc->num_sec_wiphy; i++) {
390 struct ath_wiphy *aphy = sc->sec_wiphy[i];
393 len += snprintf(buf + len, sizeof(buf) - len,
394 "secondary: %s (%s chan=%d ht=%d)\n",
395 wiphy_name(aphy->hw->wiphy),
396 ath_wiphy_state_str(aphy->state),
397 aphy->chan_idx, aphy->chan_is_ht);
400 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr);
401 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4);
402 len += snprintf(buf + len, sizeof(buf) - len,
403 "addr: %pM\n", addr);
404 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr);
405 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4);
406 len += snprintf(buf + len, sizeof(buf) - len,
407 "addrmask: %pM\n", addr);
409 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
412 static struct ath_wiphy * get_wiphy(struct ath_softc *sc, const char *name)
415 if (strcmp(name, wiphy_name(sc->pri_wiphy->hw->wiphy)) == 0)
416 return sc->pri_wiphy;
417 for (i = 0; i < sc->num_sec_wiphy; i++) {
418 struct ath_wiphy *aphy = sc->sec_wiphy[i];
419 if (aphy && strcmp(name, wiphy_name(aphy->hw->wiphy)) == 0)
425 static int del_wiphy(struct ath_softc *sc, const char *name)
427 struct ath_wiphy *aphy = get_wiphy(sc, name);
430 return ath9k_wiphy_del(aphy);
433 static int pause_wiphy(struct ath_softc *sc, const char *name)
435 struct ath_wiphy *aphy = get_wiphy(sc, name);
438 return ath9k_wiphy_pause(aphy);
441 static int unpause_wiphy(struct ath_softc *sc, const char *name)
443 struct ath_wiphy *aphy = get_wiphy(sc, name);
446 return ath9k_wiphy_unpause(aphy);
449 static int select_wiphy(struct ath_softc *sc, const char *name)
451 struct ath_wiphy *aphy = get_wiphy(sc, name);
454 return ath9k_wiphy_select(aphy);
457 static int schedule_wiphy(struct ath_softc *sc, const char *msec)
459 ath9k_wiphy_set_scheduler(sc, simple_strtoul(msec, NULL, 0));
463 static ssize_t write_file_wiphy(struct file *file, const char __user *user_buf,
464 size_t count, loff_t *ppos)
466 struct ath_softc *sc = file->private_data;
470 len = min(count, sizeof(buf) - 1);
471 if (copy_from_user(buf, user_buf, len))
474 if (len > 0 && buf[len - 1] == '\n')
477 if (strncmp(buf, "add", 3) == 0) {
478 int res = ath9k_wiphy_add(sc);
481 } else if (strncmp(buf, "del=", 4) == 0) {
482 int res = del_wiphy(sc, buf + 4);
485 } else if (strncmp(buf, "pause=", 6) == 0) {
486 int res = pause_wiphy(sc, buf + 6);
489 } else if (strncmp(buf, "unpause=", 8) == 0) {
490 int res = unpause_wiphy(sc, buf + 8);
493 } else if (strncmp(buf, "select=", 7) == 0) {
494 int res = select_wiphy(sc, buf + 7);
497 } else if (strncmp(buf, "schedule=", 9) == 0) {
498 int res = schedule_wiphy(sc, buf + 9);
507 static const struct file_operations fops_wiphy = {
508 .read = read_file_wiphy,
509 .write = write_file_wiphy,
510 .open = ath9k_debugfs_open,
514 #define PR(str, elem) \
516 len += snprintf(buf + len, size - len, \
517 "%s%13u%11u%10u%10u\n", str, \
518 sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_BE]].elem, \
519 sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_BK]].elem, \
520 sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_VI]].elem, \
521 sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_VO]].elem); \
524 static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
525 size_t count, loff_t *ppos)
527 struct ath_softc *sc = file->private_data;
529 unsigned int len = 0, size = 2048;
532 buf = kzalloc(size, GFP_KERNEL);
536 len += sprintf(buf, "%30s %10s%10s%10s\n\n", "BE", "BK", "VI", "VO");
538 PR("MPDUs Queued: ", queued);
539 PR("MPDUs Completed: ", completed);
540 PR("Aggregates: ", a_aggr);
541 PR("AMPDUs Queued: ", a_queued);
542 PR("AMPDUs Completed:", a_completed);
543 PR("AMPDUs Retried: ", a_retries);
544 PR("AMPDUs XRetried: ", a_xretries);
545 PR("FIFO Underrun: ", fifo_underrun);
546 PR("TXOP Exceeded: ", xtxop);
547 PR("TXTIMER Expiry: ", timer_exp);
548 PR("DESC CFG Error: ", desc_cfg_err);
549 PR("DATA Underrun: ", data_underrun);
550 PR("DELIM Underrun: ", delim_underrun);
552 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
558 void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
561 struct ath_desc *ds = bf->bf_desc;
563 if (bf_isampdu(bf)) {
564 if (bf_isxretried(bf))
565 TX_STAT_INC(txq->axq_qnum, a_xretries);
567 TX_STAT_INC(txq->axq_qnum, a_completed);
569 TX_STAT_INC(txq->axq_qnum, completed);
572 if (ds->ds_txstat.ts_status & ATH9K_TXERR_FIFO)
573 TX_STAT_INC(txq->axq_qnum, fifo_underrun);
574 if (ds->ds_txstat.ts_status & ATH9K_TXERR_XTXOP)
575 TX_STAT_INC(txq->axq_qnum, xtxop);
576 if (ds->ds_txstat.ts_status & ATH9K_TXERR_TIMER_EXPIRED)
577 TX_STAT_INC(txq->axq_qnum, timer_exp);
578 if (ds->ds_txstat.ts_flags & ATH9K_TX_DESC_CFG_ERR)
579 TX_STAT_INC(txq->axq_qnum, desc_cfg_err);
580 if (ds->ds_txstat.ts_flags & ATH9K_TX_DATA_UNDERRUN)
581 TX_STAT_INC(txq->axq_qnum, data_underrun);
582 if (ds->ds_txstat.ts_flags & ATH9K_TX_DELIM_UNDERRUN)
583 TX_STAT_INC(txq->axq_qnum, delim_underrun);
586 static const struct file_operations fops_xmit = {
587 .read = read_file_xmit,
588 .open = ath9k_debugfs_open,
592 static ssize_t read_file_recv(struct file *file, char __user *user_buf,
593 size_t count, loff_t *ppos)
595 #define PHY_ERR(s, p) \
596 len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \
597 sc->debug.stats.rxstats.phy_err_stats[p]);
599 struct ath_softc *sc = file->private_data;
601 unsigned int len = 0, size = 1152;
604 buf = kzalloc(size, GFP_KERNEL);
608 len += snprintf(buf + len, size - len,
609 "%18s : %10u\n", "CRC ERR",
610 sc->debug.stats.rxstats.crc_err);
611 len += snprintf(buf + len, size - len,
612 "%18s : %10u\n", "DECRYPT CRC ERR",
613 sc->debug.stats.rxstats.decrypt_crc_err);
614 len += snprintf(buf + len, size - len,
615 "%18s : %10u\n", "PHY ERR",
616 sc->debug.stats.rxstats.phy_err);
617 len += snprintf(buf + len, size - len,
618 "%18s : %10u\n", "MIC ERR",
619 sc->debug.stats.rxstats.mic_err);
620 len += snprintf(buf + len, size - len,
621 "%18s : %10u\n", "PRE-DELIM CRC ERR",
622 sc->debug.stats.rxstats.pre_delim_crc_err);
623 len += snprintf(buf + len, size - len,
624 "%18s : %10u\n", "POST-DELIM CRC ERR",
625 sc->debug.stats.rxstats.post_delim_crc_err);
626 len += snprintf(buf + len, size - len,
627 "%18s : %10u\n", "DECRYPT BUSY ERR",
628 sc->debug.stats.rxstats.decrypt_busy_err);
630 PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN);
631 PHY_ERR("TIMING", ATH9K_PHYERR_TIMING);
632 PHY_ERR("PARITY", ATH9K_PHYERR_PARITY);
633 PHY_ERR("RATE", ATH9K_PHYERR_RATE);
634 PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH);
635 PHY_ERR("RADAR", ATH9K_PHYERR_RADAR);
636 PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE);
637 PHY_ERR("TOR", ATH9K_PHYERR_TOR);
638 PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING);
639 PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY);
640 PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL);
641 PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL);
642 PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP);
643 PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE);
644 PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART);
645 PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT);
646 PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING);
647 PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC);
648 PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL);
649 PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE);
650 PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART);
651 PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL);
652 PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP);
653 PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR);
654 PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
655 PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL);
657 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
665 void ath_debug_stat_rx(struct ath_softc *sc, struct ath_buf *bf)
667 #define RX_STAT_INC(c) sc->debug.stats.rxstats.c++
668 #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
670 struct ath_desc *ds = bf->bf_desc;
673 if (ds->ds_rxstat.rs_status & ATH9K_RXERR_CRC)
674 RX_STAT_INC(crc_err);
675 if (ds->ds_rxstat.rs_status & ATH9K_RXERR_DECRYPT)
676 RX_STAT_INC(decrypt_crc_err);
677 if (ds->ds_rxstat.rs_status & ATH9K_RXERR_MIC)
678 RX_STAT_INC(mic_err);
679 if (ds->ds_rxstat.rs_status & ATH9K_RX_DELIM_CRC_PRE)
680 RX_STAT_INC(pre_delim_crc_err);
681 if (ds->ds_rxstat.rs_status & ATH9K_RX_DELIM_CRC_POST)
682 RX_STAT_INC(post_delim_crc_err);
683 if (ds->ds_rxstat.rs_status & ATH9K_RX_DECRYPT_BUSY)
684 RX_STAT_INC(decrypt_busy_err);
686 if (ds->ds_rxstat.rs_status & ATH9K_RXERR_PHY) {
687 RX_STAT_INC(phy_err);
688 phyerr = ds->ds_rxstat.rs_phyerr & 0x24;
689 RX_PHY_ERR_INC(phyerr);
693 #undef RX_PHY_ERR_INC
696 static const struct file_operations fops_recv = {
697 .read = read_file_recv,
698 .open = ath9k_debugfs_open,
702 int ath9k_init_debug(struct ath_hw *ah)
704 struct ath_common *common = ath9k_hw_common(ah);
705 struct ath_softc *sc = (struct ath_softc *) common->priv;
707 if (!ath9k_debugfs_root)
710 sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
712 if (!sc->debug.debugfs_phy)
715 #ifdef CONFIG_ATH_DEBUG
716 sc->debug.debugfs_debug = debugfs_create_file("debug",
717 S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_debug);
718 if (!sc->debug.debugfs_debug)
722 sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUSR,
723 sc->debug.debugfs_phy, sc, &fops_dma);
724 if (!sc->debug.debugfs_dma)
727 sc->debug.debugfs_interrupt = debugfs_create_file("interrupt",
729 sc->debug.debugfs_phy,
730 sc, &fops_interrupt);
731 if (!sc->debug.debugfs_interrupt)
734 sc->debug.debugfs_rcstat = debugfs_create_file("rcstat",
736 sc->debug.debugfs_phy,
738 if (!sc->debug.debugfs_rcstat)
741 sc->debug.debugfs_wiphy = debugfs_create_file(
742 "wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc,
744 if (!sc->debug.debugfs_wiphy)
747 sc->debug.debugfs_xmit = debugfs_create_file("xmit",
749 sc->debug.debugfs_phy,
751 if (!sc->debug.debugfs_xmit)
754 sc->debug.debugfs_recv = debugfs_create_file("recv",
756 sc->debug.debugfs_phy,
758 if (!sc->debug.debugfs_recv)
763 ath9k_exit_debug(ah);
767 void ath9k_exit_debug(struct ath_hw *ah)
769 struct ath_common *common = ath9k_hw_common(ah);
770 struct ath_softc *sc = (struct ath_softc *) common->priv;
772 debugfs_remove(sc->debug.debugfs_recv);
773 debugfs_remove(sc->debug.debugfs_xmit);
774 debugfs_remove(sc->debug.debugfs_wiphy);
775 debugfs_remove(sc->debug.debugfs_rcstat);
776 debugfs_remove(sc->debug.debugfs_interrupt);
777 debugfs_remove(sc->debug.debugfs_dma);
778 debugfs_remove(sc->debug.debugfs_debug);
779 debugfs_remove(sc->debug.debugfs_phy);
782 int ath9k_debug_create_root(void)
784 ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
785 if (!ath9k_debugfs_root)
791 void ath9k_debug_remove_root(void)
793 debugfs_remove(ath9k_debugfs_root);
794 ath9k_debugfs_root = NULL;