Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
debug.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2011 Atheros Communications Inc.
3  *
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.
7  *
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.
15  */
16 
17 #include <linux/slab.h>
18 #include <linux/vmalloc.h>
19 #include <linux/export.h>
20 #include <asm/unaligned.h>
21 
22 #include "ath9k.h"
23 
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))
28 
29 
30 static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf,
31  size_t count, loff_t *ppos)
32 {
33  u8 *buf = file->private_data;
34  return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
35 }
36 
37 static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file)
38 {
39  vfree(file->private_data);
40  return 0;
41 }
42 
43 #ifdef CONFIG_ATH_DEBUG
44 
45 static ssize_t read_file_debug(struct file *file, char __user *user_buf,
46  size_t count, loff_t *ppos)
47 {
48  struct ath_softc *sc = file->private_data;
49  struct ath_common *common = ath9k_hw_common(sc->sc_ah);
50  char buf[32];
51  unsigned int len;
52 
53  len = sprintf(buf, "0x%08x\n", common->debug_mask);
54  return simple_read_from_buffer(user_buf, count, ppos, buf, len);
55 }
56 
57 static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
58  size_t count, loff_t *ppos)
59 {
60  struct ath_softc *sc = file->private_data;
61  struct ath_common *common = ath9k_hw_common(sc->sc_ah);
62  unsigned long mask;
63  char buf[32];
64  ssize_t len;
65 
66  len = min(count, sizeof(buf) - 1);
67  if (copy_from_user(buf, user_buf, len))
68  return -EFAULT;
69 
70  buf[len] = '\0';
71  if (strict_strtoul(buf, 0, &mask))
72  return -EINVAL;
73 
74  common->debug_mask = mask;
75  return count;
76 }
77 
78 static const struct file_operations fops_debug = {
79  .read = read_file_debug,
80  .write = write_file_debug,
81  .open = simple_open,
82  .owner = THIS_MODULE,
83  .llseek = default_llseek,
84 };
85 
86 #endif
87 
88 #define DMA_BUF_LEN 1024
89 
90 static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf,
91  size_t count, loff_t *ppos)
92 {
93  struct ath_softc *sc = file->private_data;
94  struct ath_hw *ah = sc->sc_ah;
95  char buf[32];
96  unsigned int len;
97 
98  len = sprintf(buf, "0x%08x\n", ah->txchainmask);
99  return simple_read_from_buffer(user_buf, count, ppos, buf, len);
100 }
101 
102 static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf,
103  size_t count, loff_t *ppos)
104 {
105  struct ath_softc *sc = file->private_data;
106  struct ath_hw *ah = sc->sc_ah;
107  unsigned long mask;
108  char buf[32];
109  ssize_t len;
110 
111  len = min(count, sizeof(buf) - 1);
112  if (copy_from_user(buf, user_buf, len))
113  return -EFAULT;
114 
115  buf[len] = '\0';
116  if (strict_strtoul(buf, 0, &mask))
117  return -EINVAL;
118 
119  ah->txchainmask = mask;
120  ah->caps.tx_chainmask = mask;
121  return count;
122 }
123 
124 static const struct file_operations fops_tx_chainmask = {
125  .read = read_file_tx_chainmask,
126  .write = write_file_tx_chainmask,
127  .open = simple_open,
128  .owner = THIS_MODULE,
129  .llseek = default_llseek,
130 };
131 
132 
133 static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf,
134  size_t count, loff_t *ppos)
135 {
136  struct ath_softc *sc = file->private_data;
137  struct ath_hw *ah = sc->sc_ah;
138  char buf[32];
139  unsigned int len;
140 
141  len = sprintf(buf, "0x%08x\n", ah->rxchainmask);
142  return simple_read_from_buffer(user_buf, count, ppos, buf, len);
143 }
144 
145 static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf,
146  size_t count, loff_t *ppos)
147 {
148  struct ath_softc *sc = file->private_data;
149  struct ath_hw *ah = sc->sc_ah;
150  unsigned long mask;
151  char buf[32];
152  ssize_t len;
153 
154  len = min(count, sizeof(buf) - 1);
155  if (copy_from_user(buf, user_buf, len))
156  return -EFAULT;
157 
158  buf[len] = '\0';
159  if (strict_strtoul(buf, 0, &mask))
160  return -EINVAL;
161 
162  ah->rxchainmask = mask;
163  ah->caps.rx_chainmask = mask;
164  return count;
165 }
166 
167 static const struct file_operations fops_rx_chainmask = {
168  .read = read_file_rx_chainmask,
169  .write = write_file_rx_chainmask,
170  .open = simple_open,
171  .owner = THIS_MODULE,
172  .llseek = default_llseek,
173 };
174 
175 static ssize_t read_file_disable_ani(struct file *file, char __user *user_buf,
176  size_t count, loff_t *ppos)
177 {
178  struct ath_softc *sc = file->private_data;
179  struct ath_common *common = ath9k_hw_common(sc->sc_ah);
180  char buf[32];
181  unsigned int len;
182 
183  len = sprintf(buf, "%d\n", common->disable_ani);
184  return simple_read_from_buffer(user_buf, count, ppos, buf, len);
185 }
186 
187 static ssize_t write_file_disable_ani(struct file *file,
188  const char __user *user_buf,
189  size_t count, loff_t *ppos)
190 {
191  struct ath_softc *sc = file->private_data;
192  struct ath_common *common = ath9k_hw_common(sc->sc_ah);
193  unsigned long disable_ani;
194  char buf[32];
195  ssize_t len;
196 
197  len = min(count, sizeof(buf) - 1);
198  if (copy_from_user(buf, user_buf, len))
199  return -EFAULT;
200 
201  buf[len] = '\0';
202  if (strict_strtoul(buf, 0, &disable_ani))
203  return -EINVAL;
204 
205  common->disable_ani = !!disable_ani;
206 
207  if (disable_ani) {
209  ath_stop_ani(sc);
210  } else {
211  ath_check_ani(sc);
212  }
213 
214  return count;
215 }
216 
217 static const struct file_operations fops_disable_ani = {
218  .read = read_file_disable_ani,
219  .write = write_file_disable_ani,
220  .open = simple_open,
221  .owner = THIS_MODULE,
222  .llseek = default_llseek,
223 };
224 
225 static ssize_t read_file_ant_diversity(struct file *file, char __user *user_buf,
226  size_t count, loff_t *ppos)
227 {
228  struct ath_softc *sc = file->private_data;
229  struct ath_common *common = ath9k_hw_common(sc->sc_ah);
230  char buf[32];
231  unsigned int len;
232 
233  len = sprintf(buf, "%d\n", common->antenna_diversity);
234  return simple_read_from_buffer(user_buf, count, ppos, buf, len);
235 }
236 
237 static ssize_t write_file_ant_diversity(struct file *file,
238  const char __user *user_buf,
239  size_t count, loff_t *ppos)
240 {
241  struct ath_softc *sc = file->private_data;
242  struct ath_common *common = ath9k_hw_common(sc->sc_ah);
243  unsigned long antenna_diversity;
244  char buf[32];
245  ssize_t len;
246 
247  len = min(count, sizeof(buf) - 1);
248  if (copy_from_user(buf, user_buf, len))
249  return -EFAULT;
250 
251  if (!AR_SREV_9565(sc->sc_ah))
252  goto exit;
253 
254  buf[len] = '\0';
255  if (strict_strtoul(buf, 0, &antenna_diversity))
256  return -EINVAL;
257 
259  ath9k_ps_wakeup(sc);
261  ath_dbg(common, CONFIG, "Antenna diversity: %d\n",
262  common->antenna_diversity);
263  ath9k_ps_restore(sc);
264 exit:
265  return count;
266 }
267 
268 static const struct file_operations fops_ant_diversity = {
269  .read = read_file_ant_diversity,
270  .write = write_file_ant_diversity,
271  .open = simple_open,
272  .owner = THIS_MODULE,
273  .llseek = default_llseek,
274 };
275 
276 static ssize_t read_file_dma(struct file *file, char __user *user_buf,
277  size_t count, loff_t *ppos)
278 {
279  struct ath_softc *sc = file->private_data;
280  struct ath_hw *ah = sc->sc_ah;
281  char *buf;
282  int retval;
283  unsigned int len = 0;
285  int i, qcuOffset = 0, dcuOffset = 0;
286  u32 *qcuBase = &val[0], *dcuBase = &val[4];
287 
289  if (!buf)
290  return -ENOMEM;
291 
292  ath9k_ps_wakeup(sc);
293 
298 
299  len += snprintf(buf + len, DMA_BUF_LEN - len,
300  "Raw DMA Debug values:\n");
301 
302  for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
303  if (i % 4 == 0)
304  len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
305 
306  val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
307  len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ",
308  i, val[i]);
309  }
310 
311  len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n");
312  len += snprintf(buf + len, DMA_BUF_LEN - len,
313  "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
314 
315  for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
316  if (i == 8) {
317  qcuOffset = 0;
318  qcuBase++;
319  }
320 
321  if (i == 6) {
322  dcuOffset = 0;
323  dcuBase++;
324  }
325 
326  len += snprintf(buf + len, DMA_BUF_LEN - len,
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);
332  }
333 
334  len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
335 
336  len += snprintf(buf + len, DMA_BUF_LEN - len,
337  "qcu_stitch state: %2x qcu_fetch state: %2x\n",
338  (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
339  len += snprintf(buf + len, DMA_BUF_LEN - len,
340  "qcu_complete state: %2x dcu_complete state: %2x\n",
341  (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
342  len += snprintf(buf + len, DMA_BUF_LEN - len,
343  "dcu_arb state: %2x dcu_fp state: %2x\n",
344  (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
345  len += snprintf(buf + len, DMA_BUF_LEN - len,
346  "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
347  (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
348  len += snprintf(buf + len, DMA_BUF_LEN - len,
349  "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
350  (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
351  len += snprintf(buf + len, DMA_BUF_LEN - len,
352  "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
353  (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
354 
355  len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n",
356  REG_READ_D(ah, AR_OBS_BUS_1));
357  len += snprintf(buf + len, DMA_BUF_LEN - len,
358  "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR));
359 
360  ath9k_ps_restore(sc);
361 
362  if (len > DMA_BUF_LEN)
363  len = DMA_BUF_LEN;
364 
365  retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
366  kfree(buf);
367  return retval;
368 }
369 
370 static const struct file_operations fops_dma = {
371  .read = read_file_dma,
372  .open = simple_open,
373  .owner = THIS_MODULE,
374  .llseek = default_llseek,
375 };
376 
377 
379 {
380  if (status)
381  sc->debug.stats.istats.total++;
382  if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
383  if (status & ATH9K_INT_RXLP)
384  sc->debug.stats.istats.rxlp++;
385  if (status & ATH9K_INT_RXHP)
386  sc->debug.stats.istats.rxhp++;
387  if (status & ATH9K_INT_BB_WATCHDOG)
388  sc->debug.stats.istats.bb_watchdog++;
389  } else {
390  if (status & ATH9K_INT_RX)
391  sc->debug.stats.istats.rxok++;
392  }
393  if (status & ATH9K_INT_RXEOL)
394  sc->debug.stats.istats.rxeol++;
395  if (status & ATH9K_INT_RXORN)
396  sc->debug.stats.istats.rxorn++;
397  if (status & ATH9K_INT_TX)
398  sc->debug.stats.istats.txok++;
399  if (status & ATH9K_INT_TXURN)
400  sc->debug.stats.istats.txurn++;
401  if (status & ATH9K_INT_RXPHY)
402  sc->debug.stats.istats.rxphyerr++;
403  if (status & ATH9K_INT_RXKCM)
404  sc->debug.stats.istats.rx_keycache_miss++;
405  if (status & ATH9K_INT_SWBA)
406  sc->debug.stats.istats.swba++;
407  if (status & ATH9K_INT_BMISS)
408  sc->debug.stats.istats.bmiss++;
409  if (status & ATH9K_INT_BNR)
410  sc->debug.stats.istats.bnr++;
411  if (status & ATH9K_INT_CST)
412  sc->debug.stats.istats.cst++;
413  if (status & ATH9K_INT_GTT)
414  sc->debug.stats.istats.gtt++;
415  if (status & ATH9K_INT_TIM)
416  sc->debug.stats.istats.tim++;
417  if (status & ATH9K_INT_CABEND)
418  sc->debug.stats.istats.cabend++;
419  if (status & ATH9K_INT_DTIMSYNC)
420  sc->debug.stats.istats.dtimsync++;
421  if (status & ATH9K_INT_DTIM)
422  sc->debug.stats.istats.dtim++;
423  if (status & ATH9K_INT_TSFOOR)
424  sc->debug.stats.istats.tsfoor++;
425  if (status & ATH9K_INT_MCI)
426  sc->debug.stats.istats.mci++;
427  if (status & ATH9K_INT_GENTIMER)
428  sc->debug.stats.istats.gen_timer++;
429 }
430 
431 static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
432  size_t count, loff_t *ppos)
433 {
434  struct ath_softc *sc = file->private_data;
435  unsigned int len = 0;
436  int rv;
437  int mxlen = 4000;
438  char *buf = kmalloc(mxlen, GFP_KERNEL);
439  if (!buf)
440  return -ENOMEM;
441 
442 #define PR_IS(a, s) \
443  do { \
444  len += snprintf(buf + len, mxlen - len, \
445  "%21s: %10u\n", a, \
446  sc->debug.stats.istats.s); \
447  } while (0)
448 
449  if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
450  PR_IS("RXLP", rxlp);
451  PR_IS("RXHP", rxhp);
452  PR_IS("WATHDOG", bb_watchdog);
453  } else {
454  PR_IS("RX", rxok);
455  }
456  PR_IS("RXEOL", rxeol);
457  PR_IS("RXORN", rxorn);
458  PR_IS("TX", txok);
459  PR_IS("TXURN", txurn);
460  PR_IS("MIB", mib);
461  PR_IS("RXPHY", rxphyerr);
462  PR_IS("RXKCM", rx_keycache_miss);
463  PR_IS("SWBA", swba);
464  PR_IS("BMISS", bmiss);
465  PR_IS("BNR", bnr);
466  PR_IS("CST", cst);
467  PR_IS("GTT", gtt);
468  PR_IS("TIM", tim);
469  PR_IS("CABEND", cabend);
470  PR_IS("DTIMSYNC", dtimsync);
471  PR_IS("DTIM", dtim);
472  PR_IS("TSFOOR", tsfoor);
473  PR_IS("MCI", mci);
474  PR_IS("GENTIMER", gen_timer);
475  PR_IS("TOTAL", total);
476 
477  len += snprintf(buf + len, mxlen - len,
478  "SYNC_CAUSE stats:\n");
479 
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);
499 
500  if (len > mxlen)
501  len = mxlen;
502 
503  rv = simple_read_from_buffer(user_buf, count, ppos, buf, len);
504  kfree(buf);
505  return rv;
506 }
507 
508 static const struct file_operations fops_interrupt = {
509  .read = read_file_interrupt,
510  .open = simple_open,
511  .owner = THIS_MODULE,
512  .llseek = default_llseek,
513 };
514 
515 #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum
516 #define PR(str, elem) \
517  do { \
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); \
524  if (len >= size) \
525  goto done; \
526 } while(0)
527 
528 #define PRX(str, elem) \
529 do { \
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)); \
536  if (len >= size) \
537  goto done; \
538 } while(0)
539 
540 #define PRQLE(str, elem) \
541 do { \
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)); \
548  if (len >= size) \
549  goto done; \
550 } while (0)
551 
552 static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
553  size_t count, loff_t *ppos)
554 {
555  struct ath_softc *sc = file->private_data;
556  char *buf;
557  unsigned int len = 0, size = 8000;
558  int i;
559  ssize_t retval = 0;
560  char tmp[32];
561 
562  buf = kzalloc(size, GFP_KERNEL);
563  if (buf == NULL)
564  return -ENOMEM;
565 
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",
569  ATH9K_NUM_TX_QUEUES, sc->tx.txqsetup,
570  sc->tx_complete_poll_work_seen,
571  "BE", "BK", "VI", "VO");
572 
573  PR("MPDUs Queued: ", queued);
574  PR("MPDUs Completed: ", completed);
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);
594  len += snprintf(buf + len, size - len,
595  "%s%11p%11p%10p%10p\n", "txq-memory-address:",
596  sc->tx.txq_map[WME_AC_BE],
597  sc->tx.txq_map[WME_AC_BK],
598  sc->tx.txq_map[WME_AC_VI],
599  sc->tx.txq_map[WME_AC_VO]);
600  if (len >= size)
601  goto done;
602 
603  PRX("axq-qnum: ", axq_qnum);
604  PRX("axq-depth: ", axq_depth);
605  PRX("axq-ampdu_depth: ", axq_ampdu_depth);
606  PRX("axq-stopped ", stopped);
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);
611 
612  PRQLE("axq_q empty: ", axq_q);
613  PRQLE("axq_acq empty: ", axq_acq);
614  for (i = 0; i < ATH_TXFIFO_DEPTH; i++) {
615  snprintf(tmp, sizeof(tmp) - 1, "txq_fifo[%i] empty: ", i);
616  PRQLE(tmp, txq_fifo[i]);
617  }
618 
619  /* Print out more detailed queue-info */
620  for (i = 0; i <= WME_AC_BK; i++) {
621  struct ath_txq *txq = &(sc->tx.txq[i]);
622  struct ath_atx_ac *ac;
623  struct ath_atx_tid *tid;
624  if (len >= size)
625  goto done;
626  spin_lock_bh(&txq->axq_lock);
627  if (!list_empty(&txq->axq_acq)) {
628  ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac,
629  list);
630  len += snprintf(buf + len, size - len,
631  "txq[%i] first-ac: %p sched: %i\n",
632  i, ac, ac->sched);
633  if (list_empty(&ac->tid_q) || (len >= size))
634  goto done_for;
635  tid = list_first_entry(&ac->tid_q, struct ath_atx_tid,
636  list);
637  len += snprintf(buf + len, size - len,
638  " first-tid: %p sched: %i paused: %i\n",
639  tid, tid->sched, tid->paused);
640  }
641  done_for:
642  spin_unlock_bh(&txq->axq_lock);
643  }
644 
645 done:
646  if (len > size)
647  len = size;
648 
649  retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
650  kfree(buf);
651 
652  return retval;
653 }
654 
655 static ssize_t read_file_stations(struct file *file, char __user *user_buf,
656  size_t count, loff_t *ppos)
657 {
658  struct ath_softc *sc = file->private_data;
659  char *buf;
660  unsigned int len = 0, size = 64000;
661  struct ath_node *an = NULL;
662  ssize_t retval = 0;
663  int q;
664 
665  buf = kzalloc(size, GFP_KERNEL);
666  if (buf == NULL)
667  return -ENOMEM;
668 
669  len += snprintf(buf + len, size - len,
670  "Stations:\n"
671  " tid: addr sched paused buf_q-empty an ac baw\n"
672  " ac: addr sched tid_q-empty txq\n");
673 
674  spin_lock(&sc->nodes_lock);
675  list_for_each_entry(an, &sc->nodes, list) {
676  unsigned short ma = an->maxampdu;
677  if (ma == 0)
678  ma = 65535; /* see ath_lookup_rate */
679  len += snprintf(buf + len, size - len,
680  "iface: %pM sta: %pM max-ampdu: %hu mpdu-density: %uus\n",
681  an->vif->addr, an->sta->addr, ma,
682  (unsigned int)(an->mpdudensity));
683  if (len >= size)
684  goto done;
685 
686  for (q = 0; q < WME_NUM_TID; q++) {
687  struct ath_atx_tid *tid = &(an->tid[q]);
688  len += snprintf(buf + len, size - len,
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),
693  tid->an, tid->ac, tid->baw_size);
694  if (len >= size)
695  goto done;
696  }
697 
698  for (q = 0; q < WME_NUM_AC; q++) {
699  struct ath_atx_ac *ac = &(an->ac[q]);
700  len += snprintf(buf + len, size - len,
701  " ac: %p %s %i %p\n",
702  ac, ac->sched ? "sched" : "idle",
703  list_empty(&ac->tid_q), ac->txq);
704  if (len >= size)
705  goto done;
706  }
707  }
708 
709 done:
710  spin_unlock(&sc->nodes_lock);
711  if (len > size)
712  len = size;
713 
714  retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
715  kfree(buf);
716 
717  return retval;
718 }
719 
720 static ssize_t read_file_misc(struct file *file, char __user *user_buf,
721  size_t count, loff_t *ppos)
722 {
723  struct ath_softc *sc = file->private_data;
724  struct ath_common *common = ath9k_hw_common(sc->sc_ah);
725  struct ieee80211_hw *hw = sc->hw;
726  struct ath9k_vif_iter_data iter_data;
727  char buf[512];
728  unsigned int len = 0;
729  ssize_t retval = 0;
730  unsigned int reg;
731  u32 rxfilter;
732 
733  len += snprintf(buf + len, sizeof(buf) - len,
734  "BSSID: %pM\n", common->curbssid);
735  len += snprintf(buf + len, sizeof(buf) - len,
736  "BSSID-MASK: %pM\n", common->bssidmask);
737  len += snprintf(buf + len, sizeof(buf) - len,
738  "OPMODE: %s\n", ath_opmode_to_string(sc->sc_ah->opmode));
739 
740  ath9k_ps_wakeup(sc);
741  rxfilter = ath9k_hw_getrxfilter(sc->sc_ah);
742  ath9k_ps_restore(sc);
743 
744  len += snprintf(buf + len, sizeof(buf) - len,
745  "RXFILTER: 0x%x", rxfilter);
746 
747  if (rxfilter & ATH9K_RX_FILTER_UCAST)
748  len += snprintf(buf + len, sizeof(buf) - len, " UCAST");
749  if (rxfilter & ATH9K_RX_FILTER_MCAST)
750  len += snprintf(buf + len, sizeof(buf) - len, " MCAST");
751  if (rxfilter & ATH9K_RX_FILTER_BCAST)
752  len += snprintf(buf + len, sizeof(buf) - len, " BCAST");
753  if (rxfilter & ATH9K_RX_FILTER_CONTROL)
754  len += snprintf(buf + len, sizeof(buf) - len, " CONTROL");
755  if (rxfilter & ATH9K_RX_FILTER_BEACON)
756  len += snprintf(buf + len, sizeof(buf) - len, " BEACON");
757  if (rxfilter & ATH9K_RX_FILTER_PROM)
758  len += snprintf(buf + len, sizeof(buf) - len, " PROM");
759  if (rxfilter & ATH9K_RX_FILTER_PROBEREQ)
760  len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ");
761  if (rxfilter & ATH9K_RX_FILTER_PHYERR)
762  len += snprintf(buf + len, sizeof(buf) - len, " PHYERR");
763  if (rxfilter & ATH9K_RX_FILTER_MYBEACON)
764  len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON");
765  if (rxfilter & ATH9K_RX_FILTER_COMP_BAR)
766  len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR");
767  if (rxfilter & ATH9K_RX_FILTER_PSPOLL)
768  len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL");
769  if (rxfilter & ATH9K_RX_FILTER_PHYRADAR)
770  len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR");
771  if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL)
772  len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL");
773  if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER)
774  len += snprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER");
775 
776  len += snprintf(buf + len, sizeof(buf) - len, "\n");
777 
778  reg = sc->sc_ah->imask;
779 
780  len += snprintf(buf + len, sizeof(buf) - len, "INTERRUPT-MASK: 0x%x", reg);
781 
782  if (reg & ATH9K_INT_SWBA)
783  len += snprintf(buf + len, sizeof(buf) - len, " SWBA");
784  if (reg & ATH9K_INT_BMISS)
785  len += snprintf(buf + len, sizeof(buf) - len, " BMISS");
786  if (reg & ATH9K_INT_CST)
787  len += snprintf(buf + len, sizeof(buf) - len, " CST");
788  if (reg & ATH9K_INT_RX)
789  len += snprintf(buf + len, sizeof(buf) - len, " RX");
790  if (reg & ATH9K_INT_RXHP)
791  len += snprintf(buf + len, sizeof(buf) - len, " RXHP");
792  if (reg & ATH9K_INT_RXLP)
793  len += snprintf(buf + len, sizeof(buf) - len, " RXLP");
794  if (reg & ATH9K_INT_BB_WATCHDOG)
795  len += snprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG");
796 
797  len += snprintf(buf + len, sizeof(buf) - len, "\n");
798 
799  ath9k_calculate_iter_data(hw, NULL, &iter_data);
800 
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,
806  sc->nvifs, sc->nbcnvifs);
807 
808  if (len > sizeof(buf))
809  len = sizeof(buf);
810 
811  retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
812  return retval;
813 }
814 
815 static ssize_t read_file_reset(struct file *file, char __user *user_buf,
816  size_t count, loff_t *ppos)
817 {
818  struct ath_softc *sc = file->private_data;
819  char buf[512];
820  unsigned int len = 0;
821 
822  len += snprintf(buf + len, sizeof(buf) - len,
823  "%17s: %2d\n", "Baseband Hang",
824  sc->debug.stats.reset[RESET_TYPE_BB_HANG]);
825  len += snprintf(buf + len, sizeof(buf) - len,
826  "%17s: %2d\n", "Baseband Watchdog",
827  sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]);
828  len += snprintf(buf + len, sizeof(buf) - len,
829  "%17s: %2d\n", "Fatal HW Error",
830  sc->debug.stats.reset[RESET_TYPE_FATAL_INT]);
831  len += snprintf(buf + len, sizeof(buf) - len,
832  "%17s: %2d\n", "TX HW error",
833  sc->debug.stats.reset[RESET_TYPE_TX_ERROR]);
834  len += snprintf(buf + len, sizeof(buf) - len,
835  "%17s: %2d\n", "TX Path Hang",
836  sc->debug.stats.reset[RESET_TYPE_TX_HANG]);
837  len += snprintf(buf + len, sizeof(buf) - len,
838  "%17s: %2d\n", "PLL RX Hang",
839  sc->debug.stats.reset[RESET_TYPE_PLL_HANG]);
840 
841  if (len > sizeof(buf))
842  len = sizeof(buf);
843 
844  return simple_read_from_buffer(user_buf, count, ppos, buf, len);
845 }
846 
847 void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
848  struct ath_tx_status *ts, struct ath_txq *txq,
849  unsigned int flags)
850 {
851 #define TX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].ts\
852  [sc->debug.tsidx].c)
853  int qnum = txq->axq_qnum;
854 
855  TX_STAT_INC(qnum, tx_pkts_all);
856  sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len;
857 
858  if (bf_isampdu(bf)) {
859  if (flags & ATH_TX_ERROR)
860  TX_STAT_INC(qnum, a_xretries);
861  else
862  TX_STAT_INC(qnum, a_completed);
863  } else {
864  if (ts->ts_status & ATH9K_TXERR_XRETRY)
865  TX_STAT_INC(qnum, xretries);
866  else
867  TX_STAT_INC(qnum, completed);
868  }
869 
870  if (ts->ts_status & ATH9K_TXERR_FIFO)
871  TX_STAT_INC(qnum, fifo_underrun);
872  if (ts->ts_status & ATH9K_TXERR_XTXOP)
873  TX_STAT_INC(qnum, xtxop);
875  TX_STAT_INC(qnum, timer_exp);
877  TX_STAT_INC(qnum, desc_cfg_err);
879  TX_STAT_INC(qnum, data_underrun);
881  TX_STAT_INC(qnum, delim_underrun);
882 
883 #ifdef CONFIG_ATH9K_MAC_DEBUG
884  spin_lock(&sc->debug.samp_lock);
886  TX_SAMP_DBG(rssi_ctl0) = ts->ts_rssi_ctl0;
887  TX_SAMP_DBG(rssi_ctl1) = ts->ts_rssi_ctl1;
888  TX_SAMP_DBG(rssi_ctl2) = ts->ts_rssi_ctl2;
889  TX_SAMP_DBG(rssi_ext0) = ts->ts_rssi_ext0;
890  TX_SAMP_DBG(rssi_ext1) = ts->ts_rssi_ext1;
891  TX_SAMP_DBG(rssi_ext2) = ts->ts_rssi_ext2;
892  TX_SAMP_DBG(rateindex) = ts->ts_rateindex;
893  TX_SAMP_DBG(isok) = !!(ts->ts_status & ATH9K_TXERR_MASK);
894  TX_SAMP_DBG(rts_fail_cnt) = ts->ts_shortretry;
895  TX_SAMP_DBG(data_fail_cnt) = ts->ts_longretry;
896  TX_SAMP_DBG(rssi) = ts->ts_rssi;
897  TX_SAMP_DBG(tid) = ts->tid;
898  TX_SAMP_DBG(qid) = ts->qid;
899 
900  if (ts->ts_flags & ATH9K_TX_BA) {
901  TX_SAMP_DBG(ba_low) = ts->ba_low;
902  TX_SAMP_DBG(ba_high) = ts->ba_high;
903  } else {
904  TX_SAMP_DBG(ba_low) = 0;
905  TX_SAMP_DBG(ba_high) = 0;
906  }
907 
908  sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES;
909  spin_unlock(&sc->debug.samp_lock);
910 #endif
911 
912 #undef TX_SAMP_DBG
913 }
914 
915 static const struct file_operations fops_xmit = {
916  .read = read_file_xmit,
917  .open = simple_open,
918  .owner = THIS_MODULE,
919  .llseek = default_llseek,
920 };
921 
922 static const struct file_operations fops_stations = {
923  .read = read_file_stations,
924  .open = simple_open,
925  .owner = THIS_MODULE,
926  .llseek = default_llseek,
927 };
928 
929 static const struct file_operations fops_misc = {
930  .read = read_file_misc,
931  .open = simple_open,
932  .owner = THIS_MODULE,
933  .llseek = default_llseek,
934 };
935 
936 static const struct file_operations fops_reset = {
937  .read = read_file_reset,
938  .open = simple_open,
939  .owner = THIS_MODULE,
940  .llseek = default_llseek,
941 };
942 
943 static ssize_t read_file_recv(struct file *file, char __user *user_buf,
944  size_t count, loff_t *ppos)
945 {
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]);
949 
950 #define RXS_ERR(s, e) \
951  do { \
952  len += snprintf(buf + len, size - len, \
953  "%22s : %10u\n", s, \
954  sc->debug.stats.rxstats.e); \
955  } while (0)
956 
957  struct ath_softc *sc = file->private_data;
958  char *buf;
959  unsigned int len = 0, size = 1600;
960  ssize_t retval = 0;
961 
962  buf = kzalloc(size, GFP_KERNEL);
963  if (buf == NULL)
964  return -ENOMEM;
965 
966  RXS_ERR("CRC ERR", crc_err);
967  RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err);
968  RXS_ERR("PHY ERR", phy_err);
969  RXS_ERR("MIC ERR", mic_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);
978 
979  PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN);
980  PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING);
981  PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY);
982  PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE);
983  PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH);
984  PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR);
985  PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE);
986  PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR);
987  PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING);
988  PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY);
989  PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL);
990  PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL);
991  PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP);
992  PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE);
993  PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART);
994  PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT);
995  PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING);
996  PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC);
997  PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL);
998  PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE);
999  PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART);
1000  PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL);
1001  PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP);
1002  PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR);
1003  PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
1004  PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL);
1005 
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);
1010 
1011  if (len > size)
1012  len = size;
1013 
1014  retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1015  kfree(buf);
1016 
1017  return retval;
1018 
1019 #undef RXS_ERR
1020 #undef PHY_ERR
1021 }
1022 
1023 void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
1024 {
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)
1028 
1029  RX_STAT_INC(rx_pkts_all);
1030  sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen;
1031 
1032  if (rs->rs_status & ATH9K_RXERR_CRC)
1033  RX_STAT_INC(crc_err);
1034  if (rs->rs_status & ATH9K_RXERR_DECRYPT)
1035  RX_STAT_INC(decrypt_crc_err);
1036  if (rs->rs_status & ATH9K_RXERR_MIC)
1037  RX_STAT_INC(mic_err);
1039  RX_STAT_INC(pre_delim_crc_err);
1041  RX_STAT_INC(post_delim_crc_err);
1042  if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY)
1043  RX_STAT_INC(decrypt_busy_err);
1044 
1045  if (rs->rs_status & ATH9K_RXERR_PHY) {
1046  RX_STAT_INC(phy_err);
1047  if (rs->rs_phyerr < ATH9K_PHYERR_MAX)
1049  }
1050 
1051 #ifdef CONFIG_ATH9K_MAC_DEBUG
1052  spin_lock(&sc->debug.samp_lock);
1054  RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0;
1055  RX_SAMP_DBG(rssi_ctl1) = rs->rs_rssi_ctl1;
1056  RX_SAMP_DBG(rssi_ctl2) = rs->rs_rssi_ctl2;
1057  RX_SAMP_DBG(rssi_ext0) = rs->rs_rssi_ext0;
1058  RX_SAMP_DBG(rssi_ext1) = rs->rs_rssi_ext1;
1059  RX_SAMP_DBG(rssi_ext2) = rs->rs_rssi_ext2;
1061  RX_SAMP_DBG(rssi) = rs->rs_rssi;
1062  RX_SAMP_DBG(rate) = rs->rs_rate;
1063  RX_SAMP_DBG(is_mybeacon) = rs->is_mybeacon;
1064 
1065  sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES;
1066  spin_unlock(&sc->debug.samp_lock);
1067 
1068 #endif
1069 
1070 #undef RX_PHY_ERR_INC
1071 #undef RX_SAMP_DBG
1072 }
1073 
1074 static const struct file_operations fops_recv = {
1075  .read = read_file_recv,
1076  .open = simple_open,
1077  .owner = THIS_MODULE,
1078  .llseek = default_llseek,
1079 };
1080 
1081 static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
1082  size_t count, loff_t *ppos)
1083 {
1084  struct ath_softc *sc = file->private_data;
1085  char buf[32];
1086  unsigned int len;
1087 
1088  len = sprintf(buf, "0x%08x\n", sc->debug.regidx);
1089  return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1090 }
1091 
1092 static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
1093  size_t count, loff_t *ppos)
1094 {
1095  struct ath_softc *sc = file->private_data;
1096  unsigned long regidx;
1097  char buf[32];
1098  ssize_t len;
1099 
1100  len = min(count, sizeof(buf) - 1);
1101  if (copy_from_user(buf, user_buf, len))
1102  return -EFAULT;
1103 
1104  buf[len] = '\0';
1105  if (strict_strtoul(buf, 0, &regidx))
1106  return -EINVAL;
1107 
1108  sc->debug.regidx = regidx;
1109  return count;
1110 }
1111 
1112 static const struct file_operations fops_regidx = {
1113  .read = read_file_regidx,
1114  .write = write_file_regidx,
1115  .open = simple_open,
1116  .owner = THIS_MODULE,
1117  .llseek = default_llseek,
1118 };
1119 
1120 static ssize_t read_file_regval(struct file *file, char __user *user_buf,
1121  size_t count, loff_t *ppos)
1122 {
1123  struct ath_softc *sc = file->private_data;
1124  struct ath_hw *ah = sc->sc_ah;
1125  char buf[32];
1126  unsigned int len;
1127  u32 regval;
1128 
1129  ath9k_ps_wakeup(sc);
1130  regval = REG_READ_D(ah, sc->debug.regidx);
1131  ath9k_ps_restore(sc);
1132  len = sprintf(buf, "0x%08x\n", regval);
1133  return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1134 }
1135 
1136 static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
1137  size_t count, loff_t *ppos)
1138 {
1139  struct ath_softc *sc = file->private_data;
1140  struct ath_hw *ah = sc->sc_ah;
1141  unsigned long regval;
1142  char buf[32];
1143  ssize_t len;
1144 
1145  len = min(count, sizeof(buf) - 1);
1146  if (copy_from_user(buf, user_buf, len))
1147  return -EFAULT;
1148 
1149  buf[len] = '\0';
1150  if (strict_strtoul(buf, 0, &regval))
1151  return -EINVAL;
1152 
1153  ath9k_ps_wakeup(sc);
1154  REG_WRITE_D(ah, sc->debug.regidx, regval);
1155  ath9k_ps_restore(sc);
1156  return count;
1157 }
1158 
1159 static const struct file_operations fops_regval = {
1160  .read = read_file_regval,
1161  .write = write_file_regval,
1162  .open = simple_open,
1163  .owner = THIS_MODULE,
1164  .llseek = default_llseek,
1165 };
1166 
1167 #define REGDUMP_LINE_SIZE 20
1168 
1169 static int open_file_regdump(struct inode *inode, struct file *file)
1170 {
1171  struct ath_softc *sc = inode->i_private;
1172  unsigned int len = 0;
1173  u8 *buf;
1174  int i;
1175  unsigned long num_regs, regdump_len, max_reg_offset;
1176 
1177  max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500;
1178  num_regs = max_reg_offset / 4 + 1;
1179  regdump_len = num_regs * REGDUMP_LINE_SIZE + 1;
1180  buf = vmalloc(regdump_len);
1181  if (!buf)
1182  return -ENOMEM;
1183 
1184  ath9k_ps_wakeup(sc);
1185  for (i = 0; i < num_regs; i++)
1186  len += scnprintf(buf + len, regdump_len - len,
1187  "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2));
1188  ath9k_ps_restore(sc);
1189 
1190  file->private_data = buf;
1191 
1192  return 0;
1193 }
1194 
1195 static const struct file_operations fops_regdump = {
1196  .open = open_file_regdump,
1197  .read = ath9k_debugfs_read_buf,
1198  .release = ath9k_debugfs_release_buf,
1199  .owner = THIS_MODULE,
1200  .llseek = default_llseek,/* read accesses f_pos */
1201 };
1202 
1203 static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf,
1204  size_t count, loff_t *ppos)
1205 {
1206  struct ath_softc *sc = file->private_data;
1207  struct ath_hw *ah = sc->sc_ah;
1208  struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist;
1209  struct ath_common *common = ath9k_hw_common(ah);
1210  struct ieee80211_conf *conf = &common->hw->conf;
1211  u32 len = 0, size = 1500;
1212  u32 i, j;
1213  ssize_t retval = 0;
1214  char *buf;
1215  u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
1216  u8 nread;
1217 
1218  buf = kzalloc(size, GFP_KERNEL);
1219  if (!buf)
1220  return -ENOMEM;
1221 
1222  len += snprintf(buf + len, size - len,
1223  "Channel Noise Floor : %d\n", ah->noise);
1224  len += snprintf(buf + len, size - len,
1225  "Chain | privNF | # Readings | NF Readings\n");
1226  for (i = 0; i < NUM_NF_READINGS; i++) {
1227  if (!(chainmask & (1 << i)) ||
1228  ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
1229  continue;
1230 
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++)
1235  len += snprintf(buf + len, size - len,
1236  " %d", h[i].nfCalBuffer[j]);
1237  len += snprintf(buf + len, size - len, "\n");
1238  }
1239 
1240  if (len > size)
1241  len = size;
1242 
1243  retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1244  kfree(buf);
1245 
1246  return retval;
1247 }
1248 
1249 static const struct file_operations fops_dump_nfcal = {
1250  .read = read_file_dump_nfcal,
1251  .open = simple_open,
1252  .owner = THIS_MODULE,
1253  .llseek = default_llseek,
1254 };
1255 
1256 static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
1257  size_t count, loff_t *ppos)
1258 {
1259  struct ath_softc *sc = file->private_data;
1260  struct ath_hw *ah = sc->sc_ah;
1261  u32 len = 0, size = 1500;
1262  ssize_t retval = 0;
1263  char *buf;
1264 
1265  buf = kzalloc(size, GFP_KERNEL);
1266  if (!buf)
1267  return -ENOMEM;
1268 
1269  len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size);
1270 
1271  retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1272  kfree(buf);
1273 
1274  return retval;
1275 }
1276 
1277 static const struct file_operations fops_base_eeprom = {
1278  .read = read_file_base_eeprom,
1279  .open = simple_open,
1280  .owner = THIS_MODULE,
1281  .llseek = default_llseek,
1282 };
1283 
1284 static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf,
1285  size_t count, loff_t *ppos)
1286 {
1287  struct ath_softc *sc = file->private_data;
1288  struct ath_hw *ah = sc->sc_ah;
1289  u32 len = 0, size = 6000;
1290  char *buf;
1291  size_t retval;
1292 
1293  buf = kzalloc(size, GFP_KERNEL);
1294  if (buf == NULL)
1295  return -ENOMEM;
1296 
1297  len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size);
1298 
1299  retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1300  kfree(buf);
1301 
1302  return retval;
1303 }
1304 
1305 static const struct file_operations fops_modal_eeprom = {
1306  .read = read_file_modal_eeprom,
1307  .open = simple_open,
1308  .owner = THIS_MODULE,
1309  .llseek = default_llseek,
1310 };
1311 
1312 #ifdef CONFIG_ATH9K_MAC_DEBUG
1313 
1314 void ath9k_debug_samp_bb_mac(struct ath_softc *sc)
1315 {
1316 #define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c)
1317  struct ath_hw *ah = sc->sc_ah;
1318  struct ath_common *common = ath9k_hw_common(ah);
1319  unsigned long flags;
1320  int i;
1321 
1322  ath9k_ps_wakeup(sc);
1323 
1324  spin_lock_bh(&sc->debug.samp_lock);
1325 
1326  spin_lock_irqsave(&common->cc_lock, flags);
1328 
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);
1334 
1335  ATH_SAMP_DBG(noise) = ah->noise;
1336 
1337  REG_WRITE_D(ah, AR_MACMISC,
1341 
1342  for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++)
1343  ATH_SAMP_DBG(dma_dbg_reg_vals[i]) = REG_READ_D(ah,
1344  AR_DMADBG_0 + (i * sizeof(u32)));
1345 
1346  ATH_SAMP_DBG(pcu_obs) = REG_READ_D(ah, AR_OBS_BUS_1);
1347  ATH_SAMP_DBG(pcu_cr) = REG_READ_D(ah, AR_CR);
1348 
1349  memcpy(ATH_SAMP_DBG(nfCalHist), sc->caldata.nfCalHist,
1350  sizeof(ATH_SAMP_DBG(nfCalHist)));
1351 
1352  sc->debug.sampidx = (sc->debug.sampidx + 1) % ATH_DBG_MAX_SAMPLES;
1353  spin_unlock_bh(&sc->debug.samp_lock);
1354  ath9k_ps_restore(sc);
1355 
1356 #undef ATH_SAMP_DBG
1357 }
1358 
1359 static int open_file_bb_mac_samps(struct inode *inode, struct file *file)
1360 {
1361 #define ATH_SAMP_DBG(c) bb_mac_samp[sampidx].c
1362  struct ath_softc *sc = inode->i_private;
1363  struct ath_hw *ah = sc->sc_ah;
1364  struct ath_common *common = ath9k_hw_common(ah);
1365  struct ieee80211_conf *conf = &common->hw->conf;
1366  struct ath_dbg_bb_mac_samp *bb_mac_samp;
1367  struct ath9k_nfcal_hist *h;
1368  int i, j, qcuOffset = 0, dcuOffset = 0;
1369  u32 *qcuBase, *dcuBase, size = 30000, len = 0;
1370  u32 sampidx = 0;
1371  u8 *buf;
1372  u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
1373  u8 nread;
1374 
1376  return -EAGAIN;
1377 
1378  buf = vmalloc(size);
1379  if (!buf)
1380  return -ENOMEM;
1381  bb_mac_samp = vmalloc(sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES);
1382  if (!bb_mac_samp) {
1383  vfree(buf);
1384  return -ENOMEM;
1385  }
1386  /* Account the current state too */
1387  ath9k_debug_samp_bb_mac(sc);
1388 
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);
1395 
1396  len += snprintf(buf + len, size - len,
1397  "Raw DMA Debug Dump:\n");
1398  len += snprintf(buf + len, size - len, "Sample |\t");
1399  for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++)
1400  len += snprintf(buf + len, size - len, " DMA Reg%d |\t", i);
1401  len += snprintf(buf + len, size - len, "\n");
1402 
1403  for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) {
1404  len += snprintf(buf + len, size - len, "%d\t", sampidx);
1405 
1406  for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++)
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");
1410  }
1411  len += snprintf(buf + len, size - len, "\n");
1412 
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]);
1418 
1419  for (i = 0; i < ATH9K_NUM_QUEUES; i++,
1420  qcuOffset += 4, dcuOffset += 5) {
1421  if (i == 8) {
1422  qcuOffset = 0;
1423  qcuBase++;
1424  }
1425 
1426  if (i == 6) {
1427  dcuOffset = 0;
1428  dcuBase++;
1429  }
1430  if (!sc->debug.stats.txstats[i].queued)
1431  continue;
1432 
1433  len += snprintf(buf + len, size - len,
1434  "%4d %7d %2x %1x %2x %2x\n",
1435  sampidx, i,
1436  (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
1437  (*qcuBase & (0x8 << qcuOffset)) >>
1438  (qcuOffset + 3),
1439  ATH_SAMP_DBG(dma_dbg_reg_vals[2]) &
1440  (0x7 << (i * 3)) >> (i * 3),
1441  (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
1442  }
1443  len += snprintf(buf + len, size - len, "\n");
1444  }
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");
1449 
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]);
1453 
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));
1474  }
1475 
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))
1481  continue;
1482 
1483  for (i = 0; i < NUM_NF_READINGS; i++) {
1484  if (!(chainmask & (1 << i)) ||
1485  ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
1486  continue;
1487 
1489  h[i].invalidNFcount;
1490  len += snprintf(buf + len, size - len,
1491  "%4d %5d %4d\t %d\t %d\t",
1492  sampidx, ATH_SAMP_DBG(noise),
1493  i, h[i].privNF, nread);
1494  for (j = 0; j < nread; j++)
1495  len += snprintf(buf + len, size - len,
1496  " %d", h[i].nfCalBuffer[j]);
1497  len += snprintf(buf + len, size - len, "\n");
1498  }
1499  }
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))
1504  continue;
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));
1511  }
1512 
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))
1521  continue;
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",
1525  sampidx,
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),
1541  jiffies_to_msecs(jiffies -
1542  ATH_SAMP_DBG(ts[i].jiffies)));
1543  }
1544  }
1545 
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))
1552  continue;
1553  len += snprintf(buf + len, size - len, "%-14d"
1554  "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-9s %-2d %02x %-13d\n",
1555  sampidx,
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) ?
1564  "True" : "False",
1565  ATH_SAMP_DBG(rs[i].antenna),
1566  ATH_SAMP_DBG(rs[i].rate),
1567  jiffies_to_msecs(jiffies -
1568  ATH_SAMP_DBG(rs[i].jiffies)));
1569  }
1570  }
1571 
1572  vfree(bb_mac_samp);
1573  file->private_data = buf;
1574 
1575  return 0;
1576 #undef ATH_SAMP_DBG
1577 }
1578 
1579 static const struct file_operations fops_samps = {
1580  .open = open_file_bb_mac_samps,
1581  .read = ath9k_debugfs_read_buf,
1582  .release = ath9k_debugfs_release_buf,
1583  .owner = THIS_MODULE,
1584  .llseek = default_llseek,
1585 };
1586 
1587 #endif
1588 
1589 int ath9k_init_debug(struct ath_hw *ah)
1590 {
1591  struct ath_common *common = ath9k_hw_common(ah);
1592  struct ath_softc *sc = (struct ath_softc *) common->priv;
1593 
1594  sc->debug.debugfs_phy = debugfs_create_dir("ath9k",
1595  sc->hw->wiphy->debugfsdir);
1596  if (!sc->debug.debugfs_phy)
1597  return -ENOMEM;
1598 
1599 #ifdef CONFIG_ATH_DEBUG
1600  debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1601  sc, &fops_debug);
1602 #endif
1603 
1605 
1606  debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
1607  &fops_dma);
1608  debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
1609  &fops_interrupt);
1610  debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc,
1611  &fops_xmit);
1612  debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1613  &sc->tx.txq_max_pending[WME_AC_BK]);
1614  debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1615  &sc->tx.txq_max_pending[WME_AC_BE]);
1616  debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1617  &sc->tx.txq_max_pending[WME_AC_VI]);
1618  debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1619  &sc->tx.txq_max_pending[WME_AC_VO]);
1620  debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc,
1621  &fops_stations);
1622  debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc,
1623  &fops_misc);
1624  debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc,
1625  &fops_reset);
1626  debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc,
1627  &fops_recv);
1628  debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR,
1629  sc->debug.debugfs_phy, sc, &fops_rx_chainmask);
1630  debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR,
1631  sc->debug.debugfs_phy, sc, &fops_tx_chainmask);
1632  debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR,
1633  sc->debug.debugfs_phy, sc, &fops_disable_ani);
1634  debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1635  &sc->sc_ah->config.enable_paprd);
1636  debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1637  sc, &fops_regidx);
1638  debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1639  sc, &fops_regval);
1640  debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR,
1641  sc->debug.debugfs_phy,
1642  &ah->config.cwm_ignore_extcca);
1643  debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc,
1644  &fops_regdump);
1645  debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc,
1646  &fops_dump_nfcal);
1647  debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
1648  &fops_base_eeprom);
1649  debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
1650  &fops_modal_eeprom);
1651 #ifdef CONFIG_ATH9K_MAC_DEBUG
1652  debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc,
1653  &fops_samps);
1654 #endif
1655  debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
1656  sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
1657  debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
1658  sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
1659  debugfs_create_file("diversity", S_IRUSR | S_IWUSR,
1660  sc->debug.debugfs_phy, sc, &fops_ant_diversity);
1661 
1662  return 0;
1663 }