debug.c (da35111ad970081bdf6e848d1861c7d16e71079b) | debug.c (2111ac0d888767999c7dd6d1309dcc1fb8012022) |
---|---|
1/* 2 * Copyright (c) 2007-2008 Bruno Randolf <bruno@thinktube.com> 3 * 4 * This file is free software: you may copy, redistribute and/or modify it 5 * under the terms of the GNU General Public License as published by the 6 * Free Software Foundation, either version 2 of the License, or (at your 7 * option) any later version. 8 * --- 55 unchanged lines hidden (view full) --- 64static unsigned int ath5k_debug; 65module_param_named(debug, ath5k_debug, uint, 0); 66 67 68#ifdef CONFIG_ATH5K_DEBUG 69 70#include <linux/seq_file.h> 71#include "reg.h" | 1/* 2 * Copyright (c) 2007-2008 Bruno Randolf <bruno@thinktube.com> 3 * 4 * This file is free software: you may copy, redistribute and/or modify it 5 * under the terms of the GNU General Public License as published by the 6 * Free Software Foundation, either version 2 of the License, or (at your 7 * option) any later version. 8 * --- 55 unchanged lines hidden (view full) --- 64static unsigned int ath5k_debug; 65module_param_named(debug, ath5k_debug, uint, 0); 66 67 68#ifdef CONFIG_ATH5K_DEBUG 69 70#include <linux/seq_file.h> 71#include "reg.h" |
72#include "ani.h" |
|
72 73static struct dentry *ath5k_global_debugfs; 74 75static int ath5k_debugfs_open(struct inode *inode, struct file *file) 76{ 77 file->private_data = inode->i_private; 78 return 0; 79} --- 222 unchanged lines hidden (view full) --- 302 { ATH5K_DEBUG_BEACON, "beacon", "beacon handling" }, 303 { ATH5K_DEBUG_CALIBRATE, "calib", "periodic calibration" }, 304 { ATH5K_DEBUG_TXPOWER, "txpower", "transmit power setting" }, 305 { ATH5K_DEBUG_LED, "led", "LED management" }, 306 { ATH5K_DEBUG_DUMP_RX, "dumprx", "print received skb content" }, 307 { ATH5K_DEBUG_DUMP_TX, "dumptx", "print transmit skb content" }, 308 { ATH5K_DEBUG_DUMPBANDS, "dumpbands", "dump bands" }, 309 { ATH5K_DEBUG_TRACE, "trace", "trace function calls" }, | 73 74static struct dentry *ath5k_global_debugfs; 75 76static int ath5k_debugfs_open(struct inode *inode, struct file *file) 77{ 78 file->private_data = inode->i_private; 79 return 0; 80} --- 222 unchanged lines hidden (view full) --- 303 { ATH5K_DEBUG_BEACON, "beacon", "beacon handling" }, 304 { ATH5K_DEBUG_CALIBRATE, "calib", "periodic calibration" }, 305 { ATH5K_DEBUG_TXPOWER, "txpower", "transmit power setting" }, 306 { ATH5K_DEBUG_LED, "led", "LED management" }, 307 { ATH5K_DEBUG_DUMP_RX, "dumprx", "print received skb content" }, 308 { ATH5K_DEBUG_DUMP_TX, "dumptx", "print transmit skb content" }, 309 { ATH5K_DEBUG_DUMPBANDS, "dumpbands", "dump bands" }, 310 { ATH5K_DEBUG_TRACE, "trace", "trace function calls" }, |
311 { ATH5K_DEBUG_ANI, "ani", "adaptive noise immunity" }, |
|
310 { ATH5K_DEBUG_ANY, "all", "show all debug levels" }, 311}; 312 313static ssize_t read_file_debug(struct file *file, char __user *user_buf, 314 size_t count, loff_t *ppos) 315{ 316 struct ath5k_softc *sc = file->private_data; 317 char buf[700]; --- 250 unchanged lines hidden (view full) --- 568static const struct file_operations fops_frameerrors = { 569 .read = read_file_frameerrors, 570 .write = write_file_frameerrors, 571 .open = ath5k_debugfs_open, 572 .owner = THIS_MODULE, 573}; 574 575 | 312 { ATH5K_DEBUG_ANY, "all", "show all debug levels" }, 313}; 314 315static ssize_t read_file_debug(struct file *file, char __user *user_buf, 316 size_t count, loff_t *ppos) 317{ 318 struct ath5k_softc *sc = file->private_data; 319 char buf[700]; --- 250 unchanged lines hidden (view full) --- 570static const struct file_operations fops_frameerrors = { 571 .read = read_file_frameerrors, 572 .write = write_file_frameerrors, 573 .open = ath5k_debugfs_open, 574 .owner = THIS_MODULE, 575}; 576 577 |
578/* debugfs: ani */ 579 580static ssize_t read_file_ani(struct file *file, char __user *user_buf, 581 size_t count, loff_t *ppos) 582{ 583 struct ath5k_softc *sc = file->private_data; 584 struct ath5k_statistics *st = &sc->stats; 585 struct ath5k_ani_state *as = &sc->ani_state; 586 587 char buf[700]; 588 unsigned int len = 0; 589 590 len += snprintf(buf+len, sizeof(buf)-len, 591 "HW has PHY error counters:\t%s\n", 592 sc->ah->ah_capabilities.cap_has_phyerr_counters ? 593 "yes" : "no"); 594 len += snprintf(buf+len, sizeof(buf)-len, 595 "HW max spur immunity level:\t%d\n", 596 as->max_spur_level); 597 len += snprintf(buf+len, sizeof(buf)-len, 598 "\nANI state\n--------------------------------------------\n"); 599 len += snprintf(buf+len, sizeof(buf)-len, "operating mode:\t\t\t"); 600 switch (as->ani_mode) { 601 case ATH5K_ANI_MODE_OFF: 602 len += snprintf(buf+len, sizeof(buf)-len, "OFF\n"); 603 break; 604 case ATH5K_ANI_MODE_MANUAL_LOW: 605 len += snprintf(buf+len, sizeof(buf)-len, 606 "MANUAL LOW\n"); 607 break; 608 case ATH5K_ANI_MODE_MANUAL_HIGH: 609 len += snprintf(buf+len, sizeof(buf)-len, 610 "MANUAL HIGH\n"); 611 break; 612 case ATH5K_ANI_MODE_AUTO: 613 len += snprintf(buf+len, sizeof(buf)-len, "AUTO\n"); 614 break; 615 default: 616 len += snprintf(buf+len, sizeof(buf)-len, 617 "??? (not good)\n"); 618 break; 619 } 620 len += snprintf(buf+len, sizeof(buf)-len, 621 "noise immunity level:\t\t%d\n", 622 as->noise_imm_level); 623 len += snprintf(buf+len, sizeof(buf)-len, 624 "spur immunity level:\t\t%d\n", 625 as->spur_level); 626 len += snprintf(buf+len, sizeof(buf)-len, "firstep level:\t\t\t%d\n", 627 as->firstep_level); 628 len += snprintf(buf+len, sizeof(buf)-len, 629 "OFDM weak signal detection:\t%s\n", 630 as->ofdm_weak_sig ? "on" : "off"); 631 len += snprintf(buf+len, sizeof(buf)-len, 632 "CCK weak signal detection:\t%s\n", 633 as->cck_weak_sig ? "on" : "off"); 634 635 len += snprintf(buf+len, sizeof(buf)-len, 636 "\nMIB INTERRUPTS:\t\t%u\n", 637 st->mib_intr); 638 len += snprintf(buf+len, sizeof(buf)-len, 639 "beacon RSSI average:\t%d\n", 640 sc->ah->ah_beacon_rssi_avg.avg); 641 len += snprintf(buf+len, sizeof(buf)-len, "profcnt tx\t\t%u\t(%d%%)\n", 642 as->pfc_tx, 643 as->pfc_cycles > 0 ? 644 as->pfc_tx*100/as->pfc_cycles : 0); 645 len += snprintf(buf+len, sizeof(buf)-len, "profcnt rx\t\t%u\t(%d%%)\n", 646 as->pfc_rx, 647 as->pfc_cycles > 0 ? 648 as->pfc_rx*100/as->pfc_cycles : 0); 649 len += snprintf(buf+len, sizeof(buf)-len, "profcnt busy\t\t%u\t(%d%%)\n", 650 as->pfc_busy, 651 as->pfc_cycles > 0 ? 652 as->pfc_busy*100/as->pfc_cycles : 0); 653 len += snprintf(buf+len, sizeof(buf)-len, "profcnt cycles\t\t%u\n", 654 as->pfc_cycles); 655 len += snprintf(buf+len, sizeof(buf)-len, 656 "listen time\t\t%d\tlast: %d\n", 657 as->listen_time, as->last_listen); 658 len += snprintf(buf+len, sizeof(buf)-len, 659 "OFDM errors\t\t%u\tlast: %u\tsum: %u\n", 660 as->ofdm_errors, as->last_ofdm_errors, 661 as->sum_ofdm_errors); 662 len += snprintf(buf+len, sizeof(buf)-len, 663 "CCK errors\t\t%u\tlast: %u\tsum: %u\n", 664 as->cck_errors, as->last_cck_errors, 665 as->sum_cck_errors); 666 len += snprintf(buf+len, sizeof(buf)-len, 667 "AR5K_PHYERR_CNT1\t%x\t(=%d)\n", 668 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1), 669 ATH5K_ANI_OFDM_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX - 670 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1))); 671 len += snprintf(buf+len, sizeof(buf)-len, 672 "AR5K_PHYERR_CNT2\t%x\t(=%d)\n", 673 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2), 674 ATH5K_ANI_CCK_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX - 675 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2))); 676 677 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 678} 679 680static ssize_t write_file_ani(struct file *file, 681 const char __user *userbuf, 682 size_t count, loff_t *ppos) 683{ 684 struct ath5k_softc *sc = file->private_data; 685 char buf[20]; 686 687 if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) 688 return -EFAULT; 689 690 if (strncmp(buf, "sens-low", 8) == 0) { 691 ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_MANUAL_HIGH); 692 } else if (strncmp(buf, "sens-high", 9) == 0) { 693 ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_MANUAL_LOW); 694 } else if (strncmp(buf, "ani-off", 7) == 0) { 695 ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_OFF); 696 } else if (strncmp(buf, "ani-on", 6) == 0) { 697 ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_AUTO); 698 } else if (strncmp(buf, "noise-low", 9) == 0) { 699 ath5k_ani_set_noise_immunity_level(sc->ah, 0); 700 } else if (strncmp(buf, "noise-high", 10) == 0) { 701 ath5k_ani_set_noise_immunity_level(sc->ah, 702 ATH5K_ANI_MAX_NOISE_IMM_LVL); 703 } else if (strncmp(buf, "spur-low", 8) == 0) { 704 ath5k_ani_set_spur_immunity_level(sc->ah, 0); 705 } else if (strncmp(buf, "spur-high", 9) == 0) { 706 ath5k_ani_set_spur_immunity_level(sc->ah, 707 sc->ani_state.max_spur_level); 708 } else if (strncmp(buf, "fir-low", 7) == 0) { 709 ath5k_ani_set_firstep_level(sc->ah, 0); 710 } else if (strncmp(buf, "fir-high", 8) == 0) { 711 ath5k_ani_set_firstep_level(sc->ah, ATH5K_ANI_MAX_FIRSTEP_LVL); 712 } else if (strncmp(buf, "ofdm-off", 8) == 0) { 713 ath5k_ani_set_ofdm_weak_signal_detection(sc->ah, false); 714 } else if (strncmp(buf, "ofdm-on", 7) == 0) { 715 ath5k_ani_set_ofdm_weak_signal_detection(sc->ah, true); 716 } else if (strncmp(buf, "cck-off", 7) == 0) { 717 ath5k_ani_set_cck_weak_signal_detection(sc->ah, false); 718 } else if (strncmp(buf, "cck-on", 6) == 0) { 719 ath5k_ani_set_cck_weak_signal_detection(sc->ah, true); 720 } 721 return count; 722} 723 724static const struct file_operations fops_ani = { 725 .read = read_file_ani, 726 .write = write_file_ani, 727 .open = ath5k_debugfs_open, 728 .owner = THIS_MODULE, 729}; 730 731 |
|
576/* init */ 577 578void 579ath5k_debug_init(void) 580{ 581 ath5k_global_debugfs = debugfs_create_dir("ath5k", NULL); 582} 583 --- 22 unchanged lines hidden (view full) --- 606 sc->debug.debugfs_antenna = debugfs_create_file("antenna", 607 S_IWUSR | S_IRUSR, 608 sc->debug.debugfs_phydir, sc, &fops_antenna); 609 610 sc->debug.debugfs_frameerrors = debugfs_create_file("frameerrors", 611 S_IWUSR | S_IRUSR, 612 sc->debug.debugfs_phydir, sc, 613 &fops_frameerrors); | 732/* init */ 733 734void 735ath5k_debug_init(void) 736{ 737 ath5k_global_debugfs = debugfs_create_dir("ath5k", NULL); 738} 739 --- 22 unchanged lines hidden (view full) --- 762 sc->debug.debugfs_antenna = debugfs_create_file("antenna", 763 S_IWUSR | S_IRUSR, 764 sc->debug.debugfs_phydir, sc, &fops_antenna); 765 766 sc->debug.debugfs_frameerrors = debugfs_create_file("frameerrors", 767 S_IWUSR | S_IRUSR, 768 sc->debug.debugfs_phydir, sc, 769 &fops_frameerrors); |
770 771 sc->debug.debugfs_ani = debugfs_create_file("ani", 772 S_IWUSR | S_IRUSR, 773 sc->debug.debugfs_phydir, sc, 774 &fops_ani); |
|
614} 615 616void 617ath5k_debug_finish(void) 618{ 619 debugfs_remove(ath5k_global_debugfs); 620} 621 622void 623ath5k_debug_finish_device(struct ath5k_softc *sc) 624{ 625 debugfs_remove(sc->debug.debugfs_debug); 626 debugfs_remove(sc->debug.debugfs_registers); 627 debugfs_remove(sc->debug.debugfs_beacon); 628 debugfs_remove(sc->debug.debugfs_reset); 629 debugfs_remove(sc->debug.debugfs_antenna); 630 debugfs_remove(sc->debug.debugfs_frameerrors); | 775} 776 777void 778ath5k_debug_finish(void) 779{ 780 debugfs_remove(ath5k_global_debugfs); 781} 782 783void 784ath5k_debug_finish_device(struct ath5k_softc *sc) 785{ 786 debugfs_remove(sc->debug.debugfs_debug); 787 debugfs_remove(sc->debug.debugfs_registers); 788 debugfs_remove(sc->debug.debugfs_beacon); 789 debugfs_remove(sc->debug.debugfs_reset); 790 debugfs_remove(sc->debug.debugfs_antenna); 791 debugfs_remove(sc->debug.debugfs_frameerrors); |
792 debugfs_remove(sc->debug.debugfs_ani); |
|
631 debugfs_remove(sc->debug.debugfs_phydir); 632} 633 634 635/* functions used in other places */ 636 637void 638ath5k_debug_dump_bands(struct ath5k_softc *sc) --- 122 unchanged lines hidden --- | 793 debugfs_remove(sc->debug.debugfs_phydir); 794} 795 796 797/* functions used in other places */ 798 799void 800ath5k_debug_dump_bands(struct ath5k_softc *sc) --- 122 unchanged lines hidden --- |