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 <linux/slab.h>
18 #include <asm/unaligned.h>
22 #define REG_WRITE_D(_ah, _reg, _val) \
23 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
24 #define REG_READ_D(_ah, _reg) \
25 ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
27 static struct dentry *ath9k_debugfs_root;
29 static int ath9k_debugfs_open(struct inode *inode, struct file *file)
31 file->private_data = inode->i_private;
35 #ifdef CONFIG_ATH_DEBUG
37 static ssize_t read_file_debug(struct file *file, char __user *user_buf,
38 size_t count, loff_t *ppos)
40 struct ath_softc *sc = file->private_data;
41 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
45 len = snprintf(buf, sizeof(buf), "0x%08x\n", common->debug_mask);
46 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
49 static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
50 size_t count, loff_t *ppos)
52 struct ath_softc *sc = file->private_data;
53 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
58 len = min(count, sizeof(buf) - 1);
59 if (copy_from_user(buf, user_buf, len))
63 if (strict_strtoul(buf, 0, &mask))
66 common->debug_mask = mask;
70 static const struct file_operations fops_debug = {
71 .read = read_file_debug,
72 .write = write_file_debug,
73 .open = ath9k_debugfs_open,
79 #define DMA_BUF_LEN 1024
81 static ssize_t read_file_dma(struct file *file, char __user *user_buf,
82 size_t count, loff_t *ppos)
84 struct ath_softc *sc = file->private_data;
85 struct ath_hw *ah = sc->sc_ah;
89 u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
90 int i, qcuOffset = 0, dcuOffset = 0;
91 u32 *qcuBase = &val[0], *dcuBase = &val[4];
93 buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL);
99 REG_WRITE_D(ah, AR_MACMISC,
100 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
101 (AR_MACMISC_MISC_OBS_BUS_1 <<
102 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
104 len += snprintf(buf + len, DMA_BUF_LEN - len,
105 "Raw DMA Debug values:\n");
107 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
109 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
111 val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
112 len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ",
116 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n");
117 len += snprintf(buf + len, DMA_BUF_LEN - len,
118 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
120 for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
131 len += snprintf(buf + len, DMA_BUF_LEN - len,
132 "%2d %2x %1x %2x %2x\n",
133 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
134 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
135 val[2] & (0x7 << (i * 3)) >> (i * 3),
136 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
139 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
141 len += snprintf(buf + len, DMA_BUF_LEN - len,
142 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
143 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
144 len += snprintf(buf + len, DMA_BUF_LEN - len,
145 "qcu_complete state: %2x dcu_complete state: %2x\n",
146 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
147 len += snprintf(buf + len, DMA_BUF_LEN - len,
148 "dcu_arb state: %2x dcu_fp state: %2x\n",
149 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
150 len += snprintf(buf + len, DMA_BUF_LEN - len,
151 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
152 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
153 len += snprintf(buf + len, DMA_BUF_LEN - len,
154 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
155 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
156 len += snprintf(buf + len, DMA_BUF_LEN - len,
157 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
158 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
160 len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n",
161 REG_READ_D(ah, AR_OBS_BUS_1));
162 len += snprintf(buf + len, DMA_BUF_LEN - len,
163 "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR));
165 ath9k_ps_restore(sc);
167 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
172 static const struct file_operations fops_dma = {
173 .read = read_file_dma,
174 .open = ath9k_debugfs_open,
179 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status)
182 sc->debug.stats.istats.total++;
183 if (status & ATH9K_INT_RX)
184 sc->debug.stats.istats.rxok++;
185 if (status & ATH9K_INT_RXEOL)
186 sc->debug.stats.istats.rxeol++;
187 if (status & ATH9K_INT_RXORN)
188 sc->debug.stats.istats.rxorn++;
189 if (status & ATH9K_INT_TX)
190 sc->debug.stats.istats.txok++;
191 if (status & ATH9K_INT_TXURN)
192 sc->debug.stats.istats.txurn++;
193 if (status & ATH9K_INT_MIB)
194 sc->debug.stats.istats.mib++;
195 if (status & ATH9K_INT_RXPHY)
196 sc->debug.stats.istats.rxphyerr++;
197 if (status & ATH9K_INT_RXKCM)
198 sc->debug.stats.istats.rx_keycache_miss++;
199 if (status & ATH9K_INT_SWBA)
200 sc->debug.stats.istats.swba++;
201 if (status & ATH9K_INT_BMISS)
202 sc->debug.stats.istats.bmiss++;
203 if (status & ATH9K_INT_BNR)
204 sc->debug.stats.istats.bnr++;
205 if (status & ATH9K_INT_CST)
206 sc->debug.stats.istats.cst++;
207 if (status & ATH9K_INT_GTT)
208 sc->debug.stats.istats.gtt++;
209 if (status & ATH9K_INT_TIM)
210 sc->debug.stats.istats.tim++;
211 if (status & ATH9K_INT_CABEND)
212 sc->debug.stats.istats.cabend++;
213 if (status & ATH9K_INT_DTIMSYNC)
214 sc->debug.stats.istats.dtimsync++;
215 if (status & ATH9K_INT_DTIM)
216 sc->debug.stats.istats.dtim++;
219 static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
220 size_t count, loff_t *ppos)
222 struct ath_softc *sc = file->private_data;
224 unsigned int len = 0;
226 len += snprintf(buf + len, sizeof(buf) - len,
227 "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok);
228 len += snprintf(buf + len, sizeof(buf) - len,
229 "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol);
230 len += snprintf(buf + len, sizeof(buf) - len,
231 "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn);
232 len += snprintf(buf + len, sizeof(buf) - len,
233 "%8s: %10u\n", "TX", sc->debug.stats.istats.txok);
234 len += snprintf(buf + len, sizeof(buf) - len,
235 "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn);
236 len += snprintf(buf + len, sizeof(buf) - len,
237 "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib);
238 len += snprintf(buf + len, sizeof(buf) - len,
239 "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr);
240 len += snprintf(buf + len, sizeof(buf) - len,
241 "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss);
242 len += snprintf(buf + len, sizeof(buf) - len,
243 "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba);
244 len += snprintf(buf + len, sizeof(buf) - len,
245 "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss);
246 len += snprintf(buf + len, sizeof(buf) - len,
247 "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr);
248 len += snprintf(buf + len, sizeof(buf) - len,
249 "%8s: %10u\n", "CST", sc->debug.stats.istats.cst);
250 len += snprintf(buf + len, sizeof(buf) - len,
251 "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt);
252 len += snprintf(buf + len, sizeof(buf) - len,
253 "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim);
254 len += snprintf(buf + len, sizeof(buf) - len,
255 "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend);
256 len += snprintf(buf + len, sizeof(buf) - len,
257 "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync);
258 len += snprintf(buf + len, sizeof(buf) - len,
259 "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim);
260 len += snprintf(buf + len, sizeof(buf) - len,
261 "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total);
263 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
266 static const struct file_operations fops_interrupt = {
267 .read = read_file_interrupt,
268 .open = ath9k_debugfs_open,
272 void ath_debug_stat_rc(struct ath_softc *sc, int final_rate)
274 struct ath_rc_stats *stats;
276 stats = &sc->debug.stats.rcstats[final_rate];
280 void ath_debug_stat_retries(struct ath_softc *sc, int rix,
281 int xretries, int retries, u8 per)
283 struct ath_rc_stats *stats = &sc->debug.stats.rcstats[rix];
285 stats->xretries += xretries;
286 stats->retries += retries;
290 static ssize_t read_file_rcstat(struct file *file, char __user *user_buf,
291 size_t count, loff_t *ppos)
293 struct ath_softc *sc = file->private_data;
295 unsigned int len = 0, max;
299 if (sc->cur_rate_table == NULL)
302 max = 80 + sc->cur_rate_table->rate_cnt * 1024;
303 buf = kmalloc(max + 1, GFP_KERNEL);
308 len += sprintf(buf, "%6s %6s %6s "
309 "%10s %10s %10s %10s\n",
311 "Success", "Retries", "XRetries", "PER");
313 for (i = 0; i < sc->cur_rate_table->rate_cnt; i++) {
314 u32 ratekbps = sc->cur_rate_table->info[i].ratekbps;
315 struct ath_rc_stats *stats = &sc->debug.stats.rcstats[i];
318 int used_mcs = 0, used_htmode = 0;
320 if (WLAN_RC_PHY_HT(sc->cur_rate_table->info[i].phy)) {
321 used_mcs = snprintf(mcs, 5, "%d",
322 sc->cur_rate_table->info[i].ratecode);
324 if (WLAN_RC_PHY_40(sc->cur_rate_table->info[i].phy))
325 used_htmode = snprintf(htmode, 5, "HT40");
326 else if (WLAN_RC_PHY_20(sc->cur_rate_table->info[i].phy))
327 used_htmode = snprintf(htmode, 5, "HT20");
329 used_htmode = snprintf(htmode, 5, "????");
332 mcs[used_mcs] = '\0';
333 htmode[used_htmode] = '\0';
335 len += snprintf(buf + len, max - len,
337 "%10u %10u %10u %10u\n",
341 (ratekbps % 1000) / 100,
348 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
353 static const struct file_operations fops_rcstat = {
354 .read = read_file_rcstat,
355 .open = ath9k_debugfs_open,
359 static const char * ath_wiphy_state_str(enum ath_wiphy_state state)
362 case ATH_WIPHY_INACTIVE:
364 case ATH_WIPHY_ACTIVE:
366 case ATH_WIPHY_PAUSING:
368 case ATH_WIPHY_PAUSED:
376 static ssize_t read_file_wiphy(struct file *file, char __user *user_buf,
377 size_t count, loff_t *ppos)
379 struct ath_softc *sc = file->private_data;
381 unsigned int len = 0;
385 len += snprintf(buf + len, sizeof(buf) - len,
386 "primary: %s (%s chan=%d ht=%d)\n",
387 wiphy_name(sc->pri_wiphy->hw->wiphy),
388 ath_wiphy_state_str(sc->pri_wiphy->state),
389 sc->pri_wiphy->chan_idx, sc->pri_wiphy->chan_is_ht);
390 for (i = 0; i < sc->num_sec_wiphy; i++) {
391 struct ath_wiphy *aphy = sc->sec_wiphy[i];
394 len += snprintf(buf + len, sizeof(buf) - len,
395 "secondary: %s (%s chan=%d ht=%d)\n",
396 wiphy_name(aphy->hw->wiphy),
397 ath_wiphy_state_str(aphy->state),
398 aphy->chan_idx, aphy->chan_is_ht);
401 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr);
402 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4);
403 len += snprintf(buf + len, sizeof(buf) - len,
404 "addr: %pM\n", addr);
405 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr);
406 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4);
407 len += snprintf(buf + len, sizeof(buf) - len,
408 "addrmask: %pM\n", addr);
410 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
413 static struct ath_wiphy * get_wiphy(struct ath_softc *sc, const char *name)
416 if (strcmp(name, wiphy_name(sc->pri_wiphy->hw->wiphy)) == 0)
417 return sc->pri_wiphy;
418 for (i = 0; i < sc->num_sec_wiphy; i++) {
419 struct ath_wiphy *aphy = sc->sec_wiphy[i];
420 if (aphy && strcmp(name, wiphy_name(aphy->hw->wiphy)) == 0)
426 static int del_wiphy(struct ath_softc *sc, const char *name)
428 struct ath_wiphy *aphy = get_wiphy(sc, name);
431 return ath9k_wiphy_del(aphy);
434 static int pause_wiphy(struct ath_softc *sc, const char *name)
436 struct ath_wiphy *aphy = get_wiphy(sc, name);
439 return ath9k_wiphy_pause(aphy);
442 static int unpause_wiphy(struct ath_softc *sc, const char *name)
444 struct ath_wiphy *aphy = get_wiphy(sc, name);
447 return ath9k_wiphy_unpause(aphy);
450 static int select_wiphy(struct ath_softc *sc, const char *name)
452 struct ath_wiphy *aphy = get_wiphy(sc, name);
455 return ath9k_wiphy_select(aphy);
458 static int schedule_wiphy(struct ath_softc *sc, const char *msec)
460 ath9k_wiphy_set_scheduler(sc, simple_strtoul(msec, NULL, 0));
464 static ssize_t write_file_wiphy(struct file *file, const char __user *user_buf,
465 size_t count, loff_t *ppos)
467 struct ath_softc *sc = file->private_data;
471 len = min(count, sizeof(buf) - 1);
472 if (copy_from_user(buf, user_buf, len))
475 if (len > 0 && buf[len - 1] == '\n')
478 if (strncmp(buf, "add", 3) == 0) {
479 int res = ath9k_wiphy_add(sc);
482 } else if (strncmp(buf, "del=", 4) == 0) {
483 int res = del_wiphy(sc, buf + 4);
486 } else if (strncmp(buf, "pause=", 6) == 0) {
487 int res = pause_wiphy(sc, buf + 6);
490 } else if (strncmp(buf, "unpause=", 8) == 0) {
491 int res = unpause_wiphy(sc, buf + 8);
494 } else if (strncmp(buf, "select=", 7) == 0) {
495 int res = select_wiphy(sc, buf + 7);
498 } else if (strncmp(buf, "schedule=", 9) == 0) {
499 int res = schedule_wiphy(sc, buf + 9);
508 static const struct file_operations fops_wiphy = {
509 .read = read_file_wiphy,
510 .write = write_file_wiphy,
511 .open = ath9k_debugfs_open,
515 #define PR(str, elem) \
517 len += snprintf(buf + len, size - len, \
518 "%s%13u%11u%10u%10u\n", str, \
519 sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_BE]].elem, \
520 sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_BK]].elem, \
521 sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_VI]].elem, \
522 sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_VO]].elem); \
525 static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
526 size_t count, loff_t *ppos)
528 struct ath_softc *sc = file->private_data;
530 unsigned int len = 0, size = 2048;
533 buf = kzalloc(size, GFP_KERNEL);
537 len += sprintf(buf, "%30s %10s%10s%10s\n\n", "BE", "BK", "VI", "VO");
539 PR("MPDUs Queued: ", queued);
540 PR("MPDUs Completed: ", completed);
541 PR("Aggregates: ", a_aggr);
542 PR("AMPDUs Queued: ", a_queued);
543 PR("AMPDUs Completed:", a_completed);
544 PR("AMPDUs Retried: ", a_retries);
545 PR("AMPDUs XRetried: ", a_xretries);
546 PR("FIFO Underrun: ", fifo_underrun);
547 PR("TXOP Exceeded: ", xtxop);
548 PR("TXTIMER Expiry: ", timer_exp);
549 PR("DESC CFG Error: ", desc_cfg_err);
550 PR("DATA Underrun: ", data_underrun);
551 PR("DELIM Underrun: ", delim_underrun);
553 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
559 void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
560 struct ath_buf *bf, struct ath_tx_status *ts)
562 if (bf_isampdu(bf)) {
563 if (bf_isxretried(bf))
564 TX_STAT_INC(txq->axq_qnum, a_xretries);
566 TX_STAT_INC(txq->axq_qnum, a_completed);
568 TX_STAT_INC(txq->axq_qnum, completed);
571 if (ts->ts_status & ATH9K_TXERR_FIFO)
572 TX_STAT_INC(txq->axq_qnum, fifo_underrun);
573 if (ts->ts_status & ATH9K_TXERR_XTXOP)
574 TX_STAT_INC(txq->axq_qnum, xtxop);
575 if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED)
576 TX_STAT_INC(txq->axq_qnum, timer_exp);
577 if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR)
578 TX_STAT_INC(txq->axq_qnum, desc_cfg_err);
579 if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN)
580 TX_STAT_INC(txq->axq_qnum, data_underrun);
581 if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
582 TX_STAT_INC(txq->axq_qnum, delim_underrun);
585 static const struct file_operations fops_xmit = {
586 .read = read_file_xmit,
587 .open = ath9k_debugfs_open,
591 static ssize_t read_file_recv(struct file *file, char __user *user_buf,
592 size_t count, loff_t *ppos)
594 #define PHY_ERR(s, p) \
595 len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \
596 sc->debug.stats.rxstats.phy_err_stats[p]);
598 struct ath_softc *sc = file->private_data;
600 unsigned int len = 0, size = 1152;
603 buf = kzalloc(size, GFP_KERNEL);
607 len += snprintf(buf + len, size - len,
608 "%18s : %10u\n", "CRC ERR",
609 sc->debug.stats.rxstats.crc_err);
610 len += snprintf(buf + len, size - len,
611 "%18s : %10u\n", "DECRYPT CRC ERR",
612 sc->debug.stats.rxstats.decrypt_crc_err);
613 len += snprintf(buf + len, size - len,
614 "%18s : %10u\n", "PHY ERR",
615 sc->debug.stats.rxstats.phy_err);
616 len += snprintf(buf + len, size - len,
617 "%18s : %10u\n", "MIC ERR",
618 sc->debug.stats.rxstats.mic_err);
619 len += snprintf(buf + len, size - len,
620 "%18s : %10u\n", "PRE-DELIM CRC ERR",
621 sc->debug.stats.rxstats.pre_delim_crc_err);
622 len += snprintf(buf + len, size - len,
623 "%18s : %10u\n", "POST-DELIM CRC ERR",
624 sc->debug.stats.rxstats.post_delim_crc_err);
625 len += snprintf(buf + len, size - len,
626 "%18s : %10u\n", "DECRYPT BUSY ERR",
627 sc->debug.stats.rxstats.decrypt_busy_err);
629 PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN);
630 PHY_ERR("TIMING", ATH9K_PHYERR_TIMING);
631 PHY_ERR("PARITY", ATH9K_PHYERR_PARITY);
632 PHY_ERR("RATE", ATH9K_PHYERR_RATE);
633 PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH);
634 PHY_ERR("RADAR", ATH9K_PHYERR_RADAR);
635 PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE);
636 PHY_ERR("TOR", ATH9K_PHYERR_TOR);
637 PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING);
638 PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY);
639 PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL);
640 PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL);
641 PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP);
642 PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE);
643 PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART);
644 PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT);
645 PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING);
646 PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC);
647 PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL);
648 PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE);
649 PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART);
650 PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL);
651 PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP);
652 PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR);
653 PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
654 PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL);
656 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
664 void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
666 #define RX_STAT_INC(c) sc->debug.stats.rxstats.c++
667 #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
671 if (rs->rs_status & ATH9K_RXERR_CRC)
672 RX_STAT_INC(crc_err);
673 if (rs->rs_status & ATH9K_RXERR_DECRYPT)
674 RX_STAT_INC(decrypt_crc_err);
675 if (rs->rs_status & ATH9K_RXERR_MIC)
676 RX_STAT_INC(mic_err);
677 if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE)
678 RX_STAT_INC(pre_delim_crc_err);
679 if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST)
680 RX_STAT_INC(post_delim_crc_err);
681 if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY)
682 RX_STAT_INC(decrypt_busy_err);
684 if (rs->rs_status & ATH9K_RXERR_PHY) {
685 RX_STAT_INC(phy_err);
686 phyerr = rs->rs_phyerr & 0x24;
687 RX_PHY_ERR_INC(phyerr);
691 #undef RX_PHY_ERR_INC
694 static const struct file_operations fops_recv = {
695 .read = read_file_recv,
696 .open = ath9k_debugfs_open,
700 int ath9k_init_debug(struct ath_hw *ah)
702 struct ath_common *common = ath9k_hw_common(ah);
703 struct ath_softc *sc = (struct ath_softc *) common->priv;
705 if (!ath9k_debugfs_root)
708 sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
710 if (!sc->debug.debugfs_phy)
713 #ifdef CONFIG_ATH_DEBUG
714 sc->debug.debugfs_debug = debugfs_create_file("debug",
715 S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_debug);
716 if (!sc->debug.debugfs_debug)
720 sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUSR,
721 sc->debug.debugfs_phy, sc, &fops_dma);
722 if (!sc->debug.debugfs_dma)
725 sc->debug.debugfs_interrupt = debugfs_create_file("interrupt",
727 sc->debug.debugfs_phy,
728 sc, &fops_interrupt);
729 if (!sc->debug.debugfs_interrupt)
732 sc->debug.debugfs_rcstat = debugfs_create_file("rcstat",
734 sc->debug.debugfs_phy,
736 if (!sc->debug.debugfs_rcstat)
739 sc->debug.debugfs_wiphy = debugfs_create_file(
740 "wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc,
742 if (!sc->debug.debugfs_wiphy)
745 sc->debug.debugfs_xmit = debugfs_create_file("xmit",
747 sc->debug.debugfs_phy,
749 if (!sc->debug.debugfs_xmit)
752 sc->debug.debugfs_recv = debugfs_create_file("recv",
754 sc->debug.debugfs_phy,
756 if (!sc->debug.debugfs_recv)
761 ath9k_exit_debug(ah);
765 void ath9k_exit_debug(struct ath_hw *ah)
767 struct ath_common *common = ath9k_hw_common(ah);
768 struct ath_softc *sc = (struct ath_softc *) common->priv;
770 debugfs_remove(sc->debug.debugfs_recv);
771 debugfs_remove(sc->debug.debugfs_xmit);
772 debugfs_remove(sc->debug.debugfs_wiphy);
773 debugfs_remove(sc->debug.debugfs_rcstat);
774 debugfs_remove(sc->debug.debugfs_interrupt);
775 debugfs_remove(sc->debug.debugfs_dma);
776 debugfs_remove(sc->debug.debugfs_debug);
777 debugfs_remove(sc->debug.debugfs_phy);
780 int ath9k_debug_create_root(void)
782 ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
783 if (!ath9k_debugfs_root)
789 void ath9k_debug_remove_root(void)
791 debugfs_remove(ath9k_debugfs_root);
792 ath9k_debugfs_root = NULL;