diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/debug.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/debug.c | 263 |
1 files changed, 163 insertions, 100 deletions
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 871e969409bf..50a2e0ac3b8b 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c | |||
@@ -403,7 +403,8 @@ static const struct file_operations fops_antenna_diversity = { | |||
403 | 403 | ||
404 | static int read_file_dma(struct seq_file *file, void *data) | 404 | static int read_file_dma(struct seq_file *file, void *data) |
405 | { | 405 | { |
406 | struct ath_softc *sc = file->private; | 406 | struct ieee80211_hw *hw = dev_get_drvdata(file->private); |
407 | struct ath_softc *sc = hw->priv; | ||
407 | struct ath_hw *ah = sc->sc_ah; | 408 | struct ath_hw *ah = sc->sc_ah; |
408 | u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; | 409 | u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; |
409 | int i, qcuOffset = 0, dcuOffset = 0; | 410 | int i, qcuOffset = 0, dcuOffset = 0; |
@@ -470,20 +471,6 @@ static int read_file_dma(struct seq_file *file, void *data) | |||
470 | return 0; | 471 | return 0; |
471 | } | 472 | } |
472 | 473 | ||
473 | static int open_file_dma(struct inode *inode, struct file *f) | ||
474 | { | ||
475 | return single_open(f, read_file_dma, inode->i_private); | ||
476 | } | ||
477 | |||
478 | static const struct file_operations fops_dma = { | ||
479 | .open = open_file_dma, | ||
480 | .read = seq_read, | ||
481 | .owner = THIS_MODULE, | ||
482 | .llseek = seq_lseek, | ||
483 | .release = single_release, | ||
484 | }; | ||
485 | |||
486 | |||
487 | void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) | 474 | void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) |
488 | { | 475 | { |
489 | if (status) | 476 | if (status) |
@@ -539,7 +526,8 @@ void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) | |||
539 | 526 | ||
540 | static int read_file_interrupt(struct seq_file *file, void *data) | 527 | static int read_file_interrupt(struct seq_file *file, void *data) |
541 | { | 528 | { |
542 | struct ath_softc *sc = file->private; | 529 | struct ieee80211_hw *hw = dev_get_drvdata(file->private); |
530 | struct ath_softc *sc = hw->priv; | ||
543 | 531 | ||
544 | #define PR_IS(a, s) \ | 532 | #define PR_IS(a, s) \ |
545 | do { \ | 533 | do { \ |
@@ -600,22 +588,10 @@ static int read_file_interrupt(struct seq_file *file, void *data) | |||
600 | return 0; | 588 | return 0; |
601 | } | 589 | } |
602 | 590 | ||
603 | static int open_file_interrupt(struct inode *inode, struct file *f) | ||
604 | { | ||
605 | return single_open(f, read_file_interrupt, inode->i_private); | ||
606 | } | ||
607 | |||
608 | static const struct file_operations fops_interrupt = { | ||
609 | .read = seq_read, | ||
610 | .open = open_file_interrupt, | ||
611 | .owner = THIS_MODULE, | ||
612 | .llseek = seq_lseek, | ||
613 | .release = single_release, | ||
614 | }; | ||
615 | |||
616 | static int read_file_xmit(struct seq_file *file, void *data) | 591 | static int read_file_xmit(struct seq_file *file, void *data) |
617 | { | 592 | { |
618 | struct ath_softc *sc = file->private; | 593 | struct ieee80211_hw *hw = dev_get_drvdata(file->private); |
594 | struct ath_softc *sc = hw->priv; | ||
619 | 595 | ||
620 | seq_printf(file, "%30s %10s%10s%10s\n\n", "BE", "BK", "VI", "VO"); | 596 | seq_printf(file, "%30s %10s%10s%10s\n\n", "BE", "BK", "VI", "VO"); |
621 | 597 | ||
@@ -661,7 +637,8 @@ static void print_queue(struct ath_softc *sc, struct ath_txq *txq, | |||
661 | 637 | ||
662 | static int read_file_queues(struct seq_file *file, void *data) | 638 | static int read_file_queues(struct seq_file *file, void *data) |
663 | { | 639 | { |
664 | struct ath_softc *sc = file->private; | 640 | struct ieee80211_hw *hw = dev_get_drvdata(file->private); |
641 | struct ath_softc *sc = hw->priv; | ||
665 | struct ath_txq *txq; | 642 | struct ath_txq *txq; |
666 | int i; | 643 | int i; |
667 | static const char *qname[4] = { | 644 | static const char *qname[4] = { |
@@ -682,7 +659,8 @@ static int read_file_queues(struct seq_file *file, void *data) | |||
682 | 659 | ||
683 | static int read_file_misc(struct seq_file *file, void *data) | 660 | static int read_file_misc(struct seq_file *file, void *data) |
684 | { | 661 | { |
685 | struct ath_softc *sc = file->private; | 662 | struct ieee80211_hw *hw = dev_get_drvdata(file->private); |
663 | struct ath_softc *sc = hw->priv; | ||
686 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | 664 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
687 | struct ath9k_vif_iter_data iter_data; | 665 | struct ath9k_vif_iter_data iter_data; |
688 | struct ath_chanctx *ctx; | 666 | struct ath_chanctx *ctx; |
@@ -773,7 +751,8 @@ static int read_file_misc(struct seq_file *file, void *data) | |||
773 | 751 | ||
774 | static int read_file_reset(struct seq_file *file, void *data) | 752 | static int read_file_reset(struct seq_file *file, void *data) |
775 | { | 753 | { |
776 | struct ath_softc *sc = file->private; | 754 | struct ieee80211_hw *hw = dev_get_drvdata(file->private); |
755 | struct ath_softc *sc = hw->priv; | ||
777 | static const char * const reset_cause[__RESET_TYPE_MAX] = { | 756 | static const char * const reset_cause[__RESET_TYPE_MAX] = { |
778 | [RESET_TYPE_BB_HANG] = "Baseband Hang", | 757 | [RESET_TYPE_BB_HANG] = "Baseband Hang", |
779 | [RESET_TYPE_BB_WATCHDOG] = "Baseband Watchdog", | 758 | [RESET_TYPE_BB_WATCHDOG] = "Baseband Watchdog", |
@@ -837,58 +816,6 @@ void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, | |||
837 | TX_STAT_INC(qnum, delim_underrun); | 816 | TX_STAT_INC(qnum, delim_underrun); |
838 | } | 817 | } |
839 | 818 | ||
840 | static int open_file_xmit(struct inode *inode, struct file *f) | ||
841 | { | ||
842 | return single_open(f, read_file_xmit, inode->i_private); | ||
843 | } | ||
844 | |||
845 | static const struct file_operations fops_xmit = { | ||
846 | .read = seq_read, | ||
847 | .open = open_file_xmit, | ||
848 | .owner = THIS_MODULE, | ||
849 | .llseek = seq_lseek, | ||
850 | .release = single_release, | ||
851 | }; | ||
852 | |||
853 | static int open_file_queues(struct inode *inode, struct file *f) | ||
854 | { | ||
855 | return single_open(f, read_file_queues, inode->i_private); | ||
856 | } | ||
857 | |||
858 | static const struct file_operations fops_queues = { | ||
859 | .read = seq_read, | ||
860 | .open = open_file_queues, | ||
861 | .owner = THIS_MODULE, | ||
862 | .llseek = seq_lseek, | ||
863 | .release = single_release, | ||
864 | }; | ||
865 | |||
866 | static int open_file_misc(struct inode *inode, struct file *f) | ||
867 | { | ||
868 | return single_open(f, read_file_misc, inode->i_private); | ||
869 | } | ||
870 | |||
871 | static const struct file_operations fops_misc = { | ||
872 | .read = seq_read, | ||
873 | .open = open_file_misc, | ||
874 | .owner = THIS_MODULE, | ||
875 | .llseek = seq_lseek, | ||
876 | .release = single_release, | ||
877 | }; | ||
878 | |||
879 | static int open_file_reset(struct inode *inode, struct file *f) | ||
880 | { | ||
881 | return single_open(f, read_file_reset, inode->i_private); | ||
882 | } | ||
883 | |||
884 | static const struct file_operations fops_reset = { | ||
885 | .read = seq_read, | ||
886 | .open = open_file_reset, | ||
887 | .owner = THIS_MODULE, | ||
888 | .llseek = seq_lseek, | ||
889 | .release = single_release, | ||
890 | }; | ||
891 | |||
892 | void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) | 819 | void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) |
893 | { | 820 | { |
894 | ath9k_cmn_debug_stat_rx(&sc->debug.stats.rxstats, rs); | 821 | ath9k_cmn_debug_stat_rx(&sc->debug.stats.rxstats, rs); |
@@ -1018,7 +945,8 @@ static const struct file_operations fops_regdump = { | |||
1018 | 945 | ||
1019 | static int read_file_dump_nfcal(struct seq_file *file, void *data) | 946 | static int read_file_dump_nfcal(struct seq_file *file, void *data) |
1020 | { | 947 | { |
1021 | struct ath_softc *sc = file->private; | 948 | struct ieee80211_hw *hw = dev_get_drvdata(file->private); |
949 | struct ath_softc *sc = hw->priv; | ||
1022 | struct ath_hw *ah = sc->sc_ah; | 950 | struct ath_hw *ah = sc->sc_ah; |
1023 | struct ath9k_nfcal_hist *h = sc->cur_chan->caldata.nfCalHist; | 951 | struct ath9k_nfcal_hist *h = sc->cur_chan->caldata.nfCalHist; |
1024 | struct ath_common *common = ath9k_hw_common(ah); | 952 | struct ath_common *common = ath9k_hw_common(ah); |
@@ -1115,6 +1043,133 @@ static const struct file_operations fops_ackto = { | |||
1115 | }; | 1043 | }; |
1116 | #endif | 1044 | #endif |
1117 | 1045 | ||
1046 | #ifdef CONFIG_ATH9K_WOW | ||
1047 | |||
1048 | static ssize_t read_file_wow(struct file *file, char __user *user_buf, | ||
1049 | size_t count, loff_t *ppos) | ||
1050 | { | ||
1051 | struct ath_softc *sc = file->private_data; | ||
1052 | unsigned int len = 0, size = 32; | ||
1053 | ssize_t retval; | ||
1054 | char *buf; | ||
1055 | |||
1056 | buf = kzalloc(size, GFP_KERNEL); | ||
1057 | if (!buf) | ||
1058 | return -ENOMEM; | ||
1059 | |||
1060 | len += scnprintf(buf + len, size - len, "WOW: %s\n", | ||
1061 | sc->force_wow ? "ENABLED" : "DISABLED"); | ||
1062 | |||
1063 | if (len > size) | ||
1064 | len = size; | ||
1065 | |||
1066 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
1067 | kfree(buf); | ||
1068 | |||
1069 | return retval; | ||
1070 | } | ||
1071 | |||
1072 | static ssize_t write_file_wow(struct file *file, const char __user *user_buf, | ||
1073 | size_t count, loff_t *ppos) | ||
1074 | { | ||
1075 | struct ath_softc *sc = file->private_data; | ||
1076 | unsigned long val; | ||
1077 | char buf[32]; | ||
1078 | ssize_t len; | ||
1079 | |||
1080 | len = min(count, sizeof(buf) - 1); | ||
1081 | if (copy_from_user(buf, user_buf, len)) | ||
1082 | return -EFAULT; | ||
1083 | |||
1084 | buf[len] = '\0'; | ||
1085 | if (kstrtoul(buf, 0, &val)) | ||
1086 | return -EINVAL; | ||
1087 | |||
1088 | if (val != 1) | ||
1089 | return -EINVAL; | ||
1090 | |||
1091 | if (!sc->force_wow) { | ||
1092 | sc->force_wow = true; | ||
1093 | ath9k_init_wow(sc->hw); | ||
1094 | } | ||
1095 | |||
1096 | return count; | ||
1097 | } | ||
1098 | |||
1099 | static const struct file_operations fops_wow = { | ||
1100 | .read = read_file_wow, | ||
1101 | .write = write_file_wow, | ||
1102 | .open = simple_open, | ||
1103 | .owner = THIS_MODULE, | ||
1104 | .llseek = default_llseek, | ||
1105 | }; | ||
1106 | |||
1107 | #endif | ||
1108 | |||
1109 | static ssize_t read_file_tpc(struct file *file, char __user *user_buf, | ||
1110 | size_t count, loff_t *ppos) | ||
1111 | { | ||
1112 | struct ath_softc *sc = file->private_data; | ||
1113 | struct ath_hw *ah = sc->sc_ah; | ||
1114 | unsigned int len = 0, size = 32; | ||
1115 | ssize_t retval; | ||
1116 | char *buf; | ||
1117 | |||
1118 | buf = kzalloc(size, GFP_KERNEL); | ||
1119 | if (!buf) | ||
1120 | return -ENOMEM; | ||
1121 | |||
1122 | len += scnprintf(buf + len, size - len, "%s\n", | ||
1123 | ah->tpc_enabled ? "ENABLED" : "DISABLED"); | ||
1124 | |||
1125 | if (len > size) | ||
1126 | len = size; | ||
1127 | |||
1128 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
1129 | kfree(buf); | ||
1130 | |||
1131 | return retval; | ||
1132 | } | ||
1133 | |||
1134 | static ssize_t write_file_tpc(struct file *file, const char __user *user_buf, | ||
1135 | size_t count, loff_t *ppos) | ||
1136 | { | ||
1137 | struct ath_softc *sc = file->private_data; | ||
1138 | struct ath_hw *ah = sc->sc_ah; | ||
1139 | unsigned long val; | ||
1140 | char buf[32]; | ||
1141 | ssize_t len; | ||
1142 | bool tpc_enabled; | ||
1143 | |||
1144 | len = min(count, sizeof(buf) - 1); | ||
1145 | if (copy_from_user(buf, user_buf, len)) | ||
1146 | return -EFAULT; | ||
1147 | |||
1148 | buf[len] = '\0'; | ||
1149 | if (kstrtoul(buf, 0, &val)) | ||
1150 | return -EINVAL; | ||
1151 | |||
1152 | if (val < 0 || val > 1) | ||
1153 | return -EINVAL; | ||
1154 | |||
1155 | tpc_enabled = !!val; | ||
1156 | |||
1157 | if (tpc_enabled != ah->tpc_enabled) { | ||
1158 | ah->tpc_enabled = tpc_enabled; | ||
1159 | ath9k_hw_set_txpowerlimit(ah, sc->cur_chan->txpower, false); | ||
1160 | } | ||
1161 | |||
1162 | return count; | ||
1163 | } | ||
1164 | |||
1165 | static const struct file_operations fops_tpc = { | ||
1166 | .read = read_file_tpc, | ||
1167 | .write = write_file_tpc, | ||
1168 | .open = simple_open, | ||
1169 | .owner = THIS_MODULE, | ||
1170 | .llseek = default_llseek, | ||
1171 | }; | ||
1172 | |||
1118 | /* Ethtool support for get-stats */ | 1173 | /* Ethtool support for get-stats */ |
1119 | 1174 | ||
1120 | #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO" | 1175 | #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO" |
@@ -1260,14 +1315,14 @@ int ath9k_init_debug(struct ath_hw *ah) | |||
1260 | ath9k_tx99_init_debug(sc); | 1315 | ath9k_tx99_init_debug(sc); |
1261 | ath9k_cmn_spectral_init_debug(&sc->spec_priv, sc->debug.debugfs_phy); | 1316 | ath9k_cmn_spectral_init_debug(&sc->spec_priv, sc->debug.debugfs_phy); |
1262 | 1317 | ||
1263 | debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, | 1318 | debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy, |
1264 | &fops_dma); | 1319 | read_file_dma); |
1265 | debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, | 1320 | debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy, |
1266 | &fops_interrupt); | 1321 | read_file_interrupt); |
1267 | debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, | 1322 | debugfs_create_devm_seqfile(sc->dev, "xmit", sc->debug.debugfs_phy, |
1268 | &fops_xmit); | 1323 | read_file_xmit); |
1269 | debugfs_create_file("queues", S_IRUSR, sc->debug.debugfs_phy, sc, | 1324 | debugfs_create_devm_seqfile(sc->dev, "queues", sc->debug.debugfs_phy, |
1270 | &fops_queues); | 1325 | read_file_queues); |
1271 | debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, | 1326 | debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
1272 | &sc->tx.txq_max_pending[IEEE80211_AC_BK]); | 1327 | &sc->tx.txq_max_pending[IEEE80211_AC_BK]); |
1273 | debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, | 1328 | debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
@@ -1276,10 +1331,10 @@ int ath9k_init_debug(struct ath_hw *ah) | |||
1276 | &sc->tx.txq_max_pending[IEEE80211_AC_VI]); | 1331 | &sc->tx.txq_max_pending[IEEE80211_AC_VI]); |
1277 | debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, | 1332 | debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
1278 | &sc->tx.txq_max_pending[IEEE80211_AC_VO]); | 1333 | &sc->tx.txq_max_pending[IEEE80211_AC_VO]); |
1279 | debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, | 1334 | debugfs_create_devm_seqfile(sc->dev, "misc", sc->debug.debugfs_phy, |
1280 | &fops_misc); | 1335 | read_file_misc); |
1281 | debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc, | 1336 | debugfs_create_devm_seqfile(sc->dev, "reset", sc->debug.debugfs_phy, |
1282 | &fops_reset); | 1337 | read_file_reset); |
1283 | 1338 | ||
1284 | ath9k_cmn_debug_recv(sc->debug.debugfs_phy, &sc->debug.stats.rxstats); | 1339 | ath9k_cmn_debug_recv(sc->debug.debugfs_phy, &sc->debug.stats.rxstats); |
1285 | ath9k_cmn_debug_phy_err(sc->debug.debugfs_phy, &sc->debug.stats.rxstats); | 1340 | ath9k_cmn_debug_phy_err(sc->debug.debugfs_phy, &sc->debug.stats.rxstats); |
@@ -1301,8 +1356,9 @@ int ath9k_init_debug(struct ath_hw *ah) | |||
1301 | &ah->config.cwm_ignore_extcca); | 1356 | &ah->config.cwm_ignore_extcca); |
1302 | debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, | 1357 | debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, |
1303 | &fops_regdump); | 1358 | &fops_regdump); |
1304 | debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc, | 1359 | debugfs_create_devm_seqfile(sc->dev, "dump_nfcal", |
1305 | &fops_dump_nfcal); | 1360 | sc->debug.debugfs_phy, |
1361 | read_file_dump_nfcal); | ||
1306 | 1362 | ||
1307 | ath9k_cmn_debug_base_eeprom(sc->debug.debugfs_phy, sc->sc_ah); | 1363 | ath9k_cmn_debug_base_eeprom(sc->debug.debugfs_phy, sc->sc_ah); |
1308 | ath9k_cmn_debug_modal_eeprom(sc->debug.debugfs_phy, sc->sc_ah); | 1364 | ath9k_cmn_debug_modal_eeprom(sc->debug.debugfs_phy, sc->sc_ah); |
@@ -1320,10 +1376,17 @@ int ath9k_init_debug(struct ath_hw *ah) | |||
1320 | &fops_btcoex); | 1376 | &fops_btcoex); |
1321 | #endif | 1377 | #endif |
1322 | 1378 | ||
1379 | #ifdef CONFIG_ATH9K_WOW | ||
1380 | debugfs_create_file("wow", S_IRUSR | S_IWUSR, | ||
1381 | sc->debug.debugfs_phy, sc, &fops_wow); | ||
1382 | #endif | ||
1383 | |||
1323 | #ifdef CONFIG_ATH9K_DYNACK | 1384 | #ifdef CONFIG_ATH9K_DYNACK |
1324 | debugfs_create_file("ack_to", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, | 1385 | debugfs_create_file("ack_to", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
1325 | sc, &fops_ackto); | 1386 | sc, &fops_ackto); |
1326 | #endif | 1387 | #endif |
1388 | debugfs_create_file("tpc", S_IRUSR | S_IWUSR, | ||
1389 | sc->debug.debugfs_phy, sc, &fops_tpc); | ||
1327 | 1390 | ||
1328 | return 0; | 1391 | return 0; |
1329 | } | 1392 | } |