61 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
63 #include <linux/export.h>
67 #include <linux/list.h>
73 static unsigned int ath5k_debug;
84 #define REG_STRUCT_INIT(r) { #r, r }
87 static const struct reg regs[] = {
138 static void *reg_start(
struct seq_file *seq, loff_t *
pos)
143 static void reg_stop(
struct seq_file *seq,
void *
p)
148 static void *reg_next(
struct seq_file *seq,
void *
p, loff_t *
pos)
154 static int reg_show(
struct seq_file *seq,
void *
p)
159 ath5k_hw_reg_read(ah, r->
addr));
174 res =
seq_open(file, ®ister_seq_ops);
183 .open = open_file_registers,
193 static ssize_t read_file_beacon(
struct file *file,
char __user *user_buf,
194 size_t count, loff_t *ppos)
198 unsigned int len = 0;
203 len +=
snprintf(buf + len,
sizeof(buf) - len,
204 "%-24s0x%08x\tintval: %d\tTIM: 0x%x\n",
208 len +=
snprintf(buf + len,
sizeof(buf) - len,
"%-24s0x%08x\n",
211 len +=
snprintf(buf + len,
sizeof(buf) - len,
"%-24s0x%08x\n\n",
215 len +=
snprintf(buf + len,
sizeof(buf) - len,
"%-24s0x%08x\tTU: %08x\n",
216 "AR5K_TIMER0 (TBTT)", v, v);
219 len +=
snprintf(buf + len,
sizeof(buf) - len,
"%-24s0x%08x\tTU: %08x\n",
220 "AR5K_TIMER1 (DMA)", v, v >> 3);
223 len +=
snprintf(buf + len,
sizeof(buf) - len,
"%-24s0x%08x\tTU: %08x\n",
224 "AR5K_TIMER2 (SWBA)", v, v >> 3);
227 len +=
snprintf(buf + len,
sizeof(buf) - len,
"%-24s0x%08x\tTU: %08x\n",
228 "AR5K_TIMER3 (ATIM)", v, v);
231 len +=
snprintf(buf + len,
sizeof(buf) - len,
232 "TSF\t\t0x%016llx\tTU: %08x\n",
233 (
unsigned long long)tsf,
TSF_TO_TU(tsf));
235 if (len >
sizeof(buf))
241 static ssize_t write_file_beacon(
struct file *file,
242 const char __user *userbuf,
243 size_t count, loff_t *ppos)
251 if (
strncmp(buf,
"disable", 7) == 0) {
253 pr_info(
"debugfs disable beacons\n");
254 }
else if (
strncmp(buf,
"enable", 6) == 0) {
256 pr_info(
"debugfs enable beacons\n");
262 .read = read_file_beacon,
263 .write = write_file_beacon,
272 static ssize_t write_file_reset(
struct file *file,
273 const char __user *userbuf,
274 size_t count, loff_t *ppos)
283 .write = write_file_reset,
292 static const struct {
312 static ssize_t read_file_debug(
struct file *file,
char __user *user_buf,
313 size_t count, loff_t *ppos)
317 unsigned int len = 0;
320 len +=
snprintf(buf + len,
sizeof(buf) - len,
321 "DEBUG LEVEL: 0x%08x\n\n", ah->debug.level);
324 len +=
snprintf(buf + len,
sizeof(buf) - len,
326 ah->debug.level &
dbg_info[i].level ?
'+' :
' ',
329 len +=
snprintf(buf + len,
sizeof(buf) - len,
331 ah->debug.level ==
dbg_info[i].level ?
'+' :
' ',
334 if (len >
sizeof(buf))
340 static ssize_t write_file_debug(
struct file *file,
341 const char __user *userbuf,
342 size_t count, loff_t *ppos)
362 .read = read_file_debug,
363 .write = write_file_debug,
372 static ssize_t read_file_antenna(
struct file *file,
char __user *user_buf,
373 size_t count, loff_t *ppos)
377 unsigned int len = 0;
381 len +=
snprintf(buf + len,
sizeof(buf) - len,
"antenna mode\t%d\n",
383 len +=
snprintf(buf + len,
sizeof(buf) - len,
"default antenna\t%d\n",
385 len +=
snprintf(buf + len,
sizeof(buf) - len,
"tx antenna\t%d\n",
388 len +=
snprintf(buf + len,
sizeof(buf) - len,
"\nANTENNA\t\tRX\tTX\n");
390 len +=
snprintf(buf + len,
sizeof(buf) - len,
391 "[antenna %d]\t%d\t%d\n",
392 i, ah->
stats.antenna_rx[i], ah->
stats.antenna_tx[i]);
394 len +=
snprintf(buf + len,
sizeof(buf) - len,
"[invalid]\t%d\t%d\n",
395 ah->
stats.antenna_rx[0], ah->
stats.antenna_tx[0]);
398 len +=
snprintf(buf + len,
sizeof(buf) - len,
399 "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v);
402 len +=
snprintf(buf + len,
sizeof(buf) - len,
403 "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n",
405 len +=
snprintf(buf + len,
sizeof(buf) - len,
406 "AR5K_STA_ID1_DESC_ANTENNA\t%d\n",
408 len +=
snprintf(buf + len,
sizeof(buf) - len,
409 "AR5K_STA_ID1_RTS_DEF_ANTENNA\t%d\n",
411 len +=
snprintf(buf + len,
sizeof(buf) - len,
412 "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n",
416 len +=
snprintf(buf + len,
sizeof(buf) - len,
417 "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n",
421 len +=
snprintf(buf + len,
sizeof(buf) - len,
422 "AR5K_PHY_RESTART_DIV_GC\t\t%x\n",
426 len +=
snprintf(buf + len,
sizeof(buf) - len,
427 "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n",
431 len +=
snprintf(buf + len,
sizeof(buf) - len,
432 "\nAR5K_PHY_ANT_SWITCH_TABLE_0\t0x%08x\n", v);
434 len +=
snprintf(buf + len,
sizeof(buf) - len,
435 "AR5K_PHY_ANT_SWITCH_TABLE_1\t0x%08x\n", v);
437 if (len >
sizeof(buf))
443 static ssize_t write_file_antenna(
struct file *file,
444 const char __user *userbuf,
445 size_t count, loff_t *ppos)
454 if (
strncmp(buf,
"diversity", 9) == 0) {
456 pr_info(
"debug: enable diversity\n");
457 }
else if (
strncmp(buf,
"fixed-a", 7) == 0) {
459 pr_info(
"debug: fixed antenna A\n");
460 }
else if (
strncmp(buf,
"fixed-b", 7) == 0) {
462 pr_info(
"debug: fixed antenna B\n");
463 }
else if (
strncmp(buf,
"clear", 5) == 0) {
465 ah->
stats.antenna_rx[
i] = 0;
466 ah->
stats.antenna_tx[
i] = 0;
468 pr_info(
"debug: cleared antenna stats\n");
474 .read = read_file_antenna,
475 .write = write_file_antenna,
483 static ssize_t read_file_misc(
struct file *file,
char __user *user_buf,
484 size_t count, loff_t *ppos)
488 unsigned int len = 0;
491 len +=
snprintf(buf + len,
sizeof(buf) - len,
"bssid-mask: %pM\n",
493 len +=
snprintf(buf + len,
sizeof(buf) - len,
"filter-flags: 0x%x ",
496 len +=
snprintf(buf + len,
sizeof(buf) - len,
" UCAST");
498 len +=
snprintf(buf + len,
sizeof(buf) - len,
" MCAST");
500 len +=
snprintf(buf + len,
sizeof(buf) - len,
" BCAST");
502 len +=
snprintf(buf + len,
sizeof(buf) - len,
" CONTROL");
504 len +=
snprintf(buf + len,
sizeof(buf) - len,
" BEACON");
506 len +=
snprintf(buf + len,
sizeof(buf) - len,
" PROM");
508 len +=
snprintf(buf + len,
sizeof(buf) - len,
" XRPOLL");
510 len +=
snprintf(buf + len,
sizeof(buf) - len,
" PROBEREQ");
512 len +=
snprintf(buf + len,
sizeof(buf) - len,
" PHYERR-5212");
514 len +=
snprintf(buf + len,
sizeof(buf) - len,
" RADARERR-5212");
516 snprintf(buf + len,
sizeof(buf) - len,
" PHYERR-5211");
518 len +=
snprintf(buf + len,
sizeof(buf) - len,
" RADARERR-5211");
520 len +=
snprintf(buf + len,
sizeof(buf) - len,
"\nopmode: %s (%d)\n",
523 if (len >
sizeof(buf))
530 .read = read_file_misc,
538 static ssize_t read_file_frameerrors(
struct file *file,
char __user *user_buf,
539 size_t count, loff_t *ppos)
544 unsigned int len = 0;
547 len +=
snprintf(buf + len,
sizeof(buf) - len,
548 "RX\n---------------------\n");
549 len +=
snprintf(buf + len,
sizeof(buf) - len,
"CRC\t%u\t(%u%%)\n",
553 len +=
snprintf(buf + len,
sizeof(buf) - len,
"PHY\t%u\t(%u%%)\n",
557 for (i = 0; i < 32; i++) {
559 len +=
snprintf(buf + len,
sizeof(buf) - len,
560 " phy_err[%u]\t%u\n",
564 len +=
snprintf(buf + len,
sizeof(buf) - len,
"FIFO\t%u\t(%u%%)\n",
568 len +=
snprintf(buf + len,
sizeof(buf) - len,
"decrypt\t%u\t(%u%%)\n",
572 len +=
snprintf(buf + len,
sizeof(buf) - len,
"MIC\t%u\t(%u%%)\n",
576 len +=
snprintf(buf + len,
sizeof(buf) - len,
"process\t%u\t(%u%%)\n",
580 len +=
snprintf(buf + len,
sizeof(buf) - len,
"jumbo\t%u\t(%u%%)\n",
584 len +=
snprintf(buf + len,
sizeof(buf) - len,
"[RX all\t%u]\n",
586 len +=
snprintf(buf + len,
sizeof(buf) - len,
"RX-all-bytes\t%u\n",
589 len +=
snprintf(buf + len,
sizeof(buf) - len,
590 "\nTX\n---------------------\n");
591 len +=
snprintf(buf + len,
sizeof(buf) - len,
"retry\t%u\t(%u%%)\n",
595 len +=
snprintf(buf + len,
sizeof(buf) - len,
"FIFO\t%u\t(%u%%)\n",
599 len +=
snprintf(buf + len,
sizeof(buf) - len,
"filter\t%u\t(%u%%)\n",
603 len +=
snprintf(buf + len,
sizeof(buf) - len,
"[TX all\t%u]\n",
605 len +=
snprintf(buf + len,
sizeof(buf) - len,
"TX-all-bytes\t%u\n",
608 if (len >
sizeof(buf))
614 static ssize_t write_file_frameerrors(
struct file *file,
615 const char __user *userbuf,
616 size_t count, loff_t *ppos)
625 if (
strncmp(buf,
"clear", 5) == 0) {
638 pr_info(
"debug: cleared frameerrors stats\n");
644 .read = read_file_frameerrors,
645 .write = write_file_frameerrors,
654 static ssize_t read_file_ani(
struct file *file,
char __user *user_buf,
655 size_t count, loff_t *ppos)
662 unsigned int len = 0;
664 len +=
snprintf(buf + len,
sizeof(buf) - len,
665 "HW has PHY error counters:\t%s\n",
668 len +=
snprintf(buf + len,
sizeof(buf) - len,
669 "HW max spur immunity level:\t%d\n",
671 len +=
snprintf(buf + len,
sizeof(buf) - len,
672 "\nANI state\n--------------------------------------------\n");
673 len +=
snprintf(buf + len,
sizeof(buf) - len,
"operating mode:\t\t\t");
676 len +=
snprintf(buf + len,
sizeof(buf) - len,
"OFF\n");
679 len +=
snprintf(buf + len,
sizeof(buf) - len,
683 len +=
snprintf(buf + len,
sizeof(buf) - len,
687 len +=
snprintf(buf + len,
sizeof(buf) - len,
"AUTO\n");
690 len +=
snprintf(buf + len,
sizeof(buf) - len,
694 len +=
snprintf(buf + len,
sizeof(buf) - len,
695 "noise immunity level:\t\t%d\n",
697 len +=
snprintf(buf + len,
sizeof(buf) - len,
698 "spur immunity level:\t\t%d\n",
700 len +=
snprintf(buf + len,
sizeof(buf) - len,
701 "firstep level:\t\t\t%d\n",
703 len +=
snprintf(buf + len,
sizeof(buf) - len,
704 "OFDM weak signal detection:\t%s\n",
706 len +=
snprintf(buf + len,
sizeof(buf) - len,
707 "CCK weak signal detection:\t%s\n",
710 len +=
snprintf(buf + len,
sizeof(buf) - len,
711 "\nMIB INTERRUPTS:\t\t%u\n",
713 len +=
snprintf(buf + len,
sizeof(buf) - len,
714 "beacon RSSI average:\t%d\n",
717 #define CC_PRINT(_struct, _field) \
719 _struct.cycles > 0 ? \
720 _struct._field * 100 / _struct.cycles : 0
722 len +=
snprintf(buf + len,
sizeof(buf) - len,
723 "profcnt tx\t\t%u\t(%d%%)\n",
725 len +=
snprintf(buf + len,
sizeof(buf) - len,
726 "profcnt rx\t\t%u\t(%d%%)\n",
728 len +=
snprintf(buf + len,
sizeof(buf) - len,
729 "profcnt busy\t\t%u\t(%d%%)\n",
732 len +=
snprintf(buf + len,
sizeof(buf) - len,
"profcnt cycles\t\t%u\n",
734 len +=
snprintf(buf + len,
sizeof(buf) - len,
735 "listen time\t\t%d\tlast: %d\n",
737 len +=
snprintf(buf + len,
sizeof(buf) - len,
738 "OFDM errors\t\t%u\tlast: %u\tsum: %u\n",
741 len +=
snprintf(buf + len,
sizeof(buf) - len,
742 "CCK errors\t\t%u\tlast: %u\tsum: %u\n",
745 len +=
snprintf(buf + len,
sizeof(buf) - len,
746 "AR5K_PHYERR_CNT1\t%x\t(=%d)\n",
750 len +=
snprintf(buf + len,
sizeof(buf) - len,
751 "AR5K_PHYERR_CNT2\t%x\t(=%d)\n",
756 if (len >
sizeof(buf))
762 static ssize_t write_file_ani(
struct file *file,
763 const char __user *userbuf,
764 size_t count, loff_t *ppos)
772 if (
strncmp(buf,
"sens-low", 8) == 0) {
774 }
else if (
strncmp(buf,
"sens-high", 9) == 0) {
776 }
else if (
strncmp(buf,
"ani-off", 7) == 0) {
778 }
else if (
strncmp(buf,
"ani-on", 6) == 0) {
780 }
else if (
strncmp(buf,
"noise-low", 9) == 0) {
782 }
else if (
strncmp(buf,
"noise-high", 10) == 0) {
785 }
else if (
strncmp(buf,
"spur-low", 8) == 0) {
787 }
else if (
strncmp(buf,
"spur-high", 9) == 0) {
790 }
else if (
strncmp(buf,
"fir-low", 7) == 0) {
792 }
else if (
strncmp(buf,
"fir-high", 8) == 0) {
794 }
else if (
strncmp(buf,
"ofdm-off", 8) == 0) {
796 }
else if (
strncmp(buf,
"ofdm-on", 7) == 0) {
798 }
else if (
strncmp(buf,
"cck-off", 7) == 0) {
800 }
else if (
strncmp(buf,
"cck-on", 6) == 0) {
807 .read = read_file_ani,
808 .write = write_file_ani,
817 static ssize_t read_file_queue(
struct file *file,
char __user *user_buf,
818 size_t count, loff_t *ppos)
822 unsigned int len = 0;
828 len +=
snprintf(buf + len,
sizeof(buf) - len,
829 "available txbuffers: %d\n", ah->
txbuf_len);
834 len +=
snprintf(buf + len,
sizeof(buf) - len,
835 "%02d: %ssetup\n", i, txq->
setup ?
"" :
"not ");
841 spin_lock_bh(&txq->
lock);
844 spin_unlock_bh(&txq->lock);
847 " len: %
d bufs: %
d\n", txq->txq_len, n);
849 " stuck: %
d\n", txq->txq_stuck);
859 const char __user *userbuf,
860 size_t count, loff_t *ppos)
862 struct ath5k_hw *ah = file->private_data;
868 if (
strncmp(buf,
"start", 5) == 0)
870 else if (
strncmp(buf,
"stop", 4) == 0)
878 .read = read_file_queue,
879 .write = write_file_queue,
891 ah->debug.level = ath5k_debug;
939 switch (band->
band) {
979 ds, (
unsigned long long)bf->
daddr,
983 !done ?
' ' : (rs->
rs_status == 0) ?
'*' :
'!');
1005 ath5k_debug_printrxbuf(bf, status == 0, &rs);
1024 "%08x %c\n", ds, (
unsigned long long)bf->
daddr, ds->
ds_link,
1028 done ?
' ' : (ts.
ts_status == 0) ?
'*' :
'!');