Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1 | /* |
Sujith Manoharan | 5b68138 | 2011-05-17 13:36:18 +0530 | [diff] [blame] | 2 | * Copyright (c) 2008-2011 Atheros Communications Inc. |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 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 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 17 | #include <linux/slab.h> |
Vasanthakumar Thiagarajan | 582d006 | 2011-03-01 05:30:55 -0800 | [diff] [blame] | 18 | #include <linux/vmalloc.h> |
Paul Gortmaker | ee40fa0 | 2011-05-27 16:14:23 -0400 | [diff] [blame] | 19 | #include <linux/export.h> |
Gabor Juhos | 5210311 | 2009-03-06 09:57:39 +0100 | [diff] [blame] | 20 | #include <asm/unaligned.h> |
| 21 | |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 22 | #include "ath9k.h" |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 23 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 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 | |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 29 | |
Vasanthakumar Thiagarajan | 582d006 | 2011-03-01 05:30:55 -0800 | [diff] [blame] | 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 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 43 | #ifdef CONFIG_ATH_DEBUG |
| 44 | |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 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; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 49 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 50 | char buf[32]; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 51 | unsigned int len; |
| 52 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 53 | len = sprintf(buf, "0x%08x\n", common->debug_mask); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 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; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 61 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 62 | unsigned long mask; |
| 63 | char buf[32]; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 64 | ssize_t len; |
| 65 | |
| 66 | len = min(count, sizeof(buf) - 1); |
| 67 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 68 | return -EFAULT; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 69 | |
| 70 | buf[len] = '\0'; |
Jingoo Han | 27d7f47 | 2013-05-31 21:24:06 +0000 | [diff] [blame] | 71 | if (kstrtoul(buf, 0, &mask)) |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 72 | return -EINVAL; |
| 73 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 74 | common->debug_mask = mask; |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 75 | return count; |
| 76 | } |
| 77 | |
| 78 | static const struct file_operations fops_debug = { |
| 79 | .read = read_file_debug, |
| 80 | .write = write_file_debug, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 81 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 82 | .owner = THIS_MODULE, |
| 83 | .llseek = default_llseek, |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 86 | #endif |
| 87 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 88 | #define DMA_BUF_LEN 1024 |
| 89 | |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 90 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 91 | static ssize_t read_file_ani(struct file *file, char __user *user_buf, |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 92 | size_t count, loff_t *ppos) |
| 93 | { |
| 94 | struct ath_softc *sc = file->private_data; |
| 95 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 96 | struct ath_hw *ah = sc->sc_ah; |
| 97 | unsigned int len = 0, size = 1024; |
| 98 | ssize_t retval = 0; |
| 99 | char *buf; |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 100 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 101 | buf = kzalloc(size, GFP_KERNEL); |
| 102 | if (buf == NULL) |
| 103 | return -ENOMEM; |
| 104 | |
| 105 | if (common->disable_ani) { |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 106 | len += scnprintf(buf + len, size - len, "%s: %s\n", |
| 107 | "ANI", "DISABLED"); |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 108 | goto exit; |
| 109 | } |
| 110 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 111 | len += scnprintf(buf + len, size - len, "%15s: %s\n", |
| 112 | "ANI", "ENABLED"); |
| 113 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 114 | "ANI RESET", ah->stats.ast_ani_reset); |
| 115 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 116 | "SPUR UP", ah->stats.ast_ani_spurup); |
| 117 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 118 | "SPUR DOWN", ah->stats.ast_ani_spurup); |
| 119 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 120 | "OFDM WS-DET ON", ah->stats.ast_ani_ofdmon); |
| 121 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 122 | "OFDM WS-DET OFF", ah->stats.ast_ani_ofdmoff); |
| 123 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 124 | "MRC-CCK ON", ah->stats.ast_ani_ccklow); |
| 125 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 126 | "MRC-CCK OFF", ah->stats.ast_ani_cckhigh); |
| 127 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 128 | "FIR-STEP UP", ah->stats.ast_ani_stepup); |
| 129 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 130 | "FIR-STEP DOWN", ah->stats.ast_ani_stepdown); |
| 131 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 132 | "INV LISTENTIME", ah->stats.ast_ani_lneg_or_lzero); |
| 133 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 134 | "OFDM ERRORS", ah->stats.ast_ani_ofdmerrs); |
| 135 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 136 | "CCK ERRORS", ah->stats.ast_ani_cckerrs); |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 137 | exit: |
| 138 | if (len > size) |
| 139 | len = size; |
| 140 | |
| 141 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 142 | kfree(buf); |
| 143 | |
| 144 | return retval; |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 145 | } |
| 146 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 147 | static ssize_t write_file_ani(struct file *file, |
| 148 | const char __user *user_buf, |
| 149 | size_t count, loff_t *ppos) |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 150 | { |
| 151 | struct ath_softc *sc = file->private_data; |
| 152 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 153 | unsigned long ani; |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 154 | char buf[32]; |
| 155 | ssize_t len; |
| 156 | |
| 157 | len = min(count, sizeof(buf) - 1); |
| 158 | if (copy_from_user(buf, user_buf, len)) |
| 159 | return -EFAULT; |
| 160 | |
| 161 | buf[len] = '\0'; |
John W. Linville | 3899ba9 | 2013-06-11 14:48:32 -0400 | [diff] [blame] | 162 | if (kstrtoul(buf, 0, &ani)) |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 163 | return -EINVAL; |
| 164 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 165 | if (ani < 0 || ani > 1) |
| 166 | return -EINVAL; |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 167 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 168 | common->disable_ani = !ani; |
| 169 | |
| 170 | if (common->disable_ani) { |
Sujith Manoharan | 781b14a | 2012-06-04 20:23:55 +0530 | [diff] [blame] | 171 | clear_bit(SC_OP_ANI_RUN, &sc->sc_flags); |
Sujith Manoharan | da0d45f | 2012-07-17 17:16:29 +0530 | [diff] [blame] | 172 | ath_stop_ani(sc); |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 173 | } else { |
Sujith Manoharan | da0d45f | 2012-07-17 17:16:29 +0530 | [diff] [blame] | 174 | ath_check_ani(sc); |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | return count; |
| 178 | } |
| 179 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 180 | static const struct file_operations fops_ani = { |
| 181 | .read = read_file_ani, |
| 182 | .write = write_file_ani, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 183 | .open = simple_open, |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 184 | .owner = THIS_MODULE, |
| 185 | .llseek = default_llseek, |
| 186 | }; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 187 | |
Sujith Manoharan | 36e8825 | 2013-08-06 12:44:15 +0530 | [diff] [blame] | 188 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT |
| 189 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 190 | static ssize_t read_file_bt_ant_diversity(struct file *file, |
| 191 | char __user *user_buf, |
| 192 | size_t count, loff_t *ppos) |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 193 | { |
| 194 | struct ath_softc *sc = file->private_data; |
| 195 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 196 | char buf[32]; |
| 197 | unsigned int len; |
| 198 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 199 | len = sprintf(buf, "%d\n", common->bt_ant_diversity); |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 200 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 201 | } |
| 202 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 203 | static ssize_t write_file_bt_ant_diversity(struct file *file, |
| 204 | const char __user *user_buf, |
| 205 | size_t count, loff_t *ppos) |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 206 | { |
| 207 | struct ath_softc *sc = file->private_data; |
| 208 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 209 | struct ath9k_hw_capabilities *pCap = &sc->sc_ah->caps; |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 210 | unsigned long bt_ant_diversity; |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 211 | char buf[32]; |
| 212 | ssize_t len; |
| 213 | |
| 214 | len = min(count, sizeof(buf) - 1); |
| 215 | if (copy_from_user(buf, user_buf, len)) |
| 216 | return -EFAULT; |
| 217 | |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 218 | if (!(pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV)) |
| 219 | goto exit; |
| 220 | |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 221 | buf[len] = '\0'; |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 222 | if (kstrtoul(buf, 0, &bt_ant_diversity)) |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 223 | return -EINVAL; |
| 224 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 225 | common->bt_ant_diversity = !!bt_ant_diversity; |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 226 | ath9k_ps_wakeup(sc); |
Sujith Manoharan | 047dc3a | 2013-08-05 15:08:26 +0530 | [diff] [blame] | 227 | ath9k_hw_set_bt_ant_diversity(sc->sc_ah, common->bt_ant_diversity); |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 228 | ath_dbg(common, CONFIG, "Enable WLAN/BT RX Antenna diversity: %d\n", |
| 229 | common->bt_ant_diversity); |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 230 | ath9k_ps_restore(sc); |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 231 | exit: |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 232 | return count; |
| 233 | } |
| 234 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 235 | static const struct file_operations fops_bt_ant_diversity = { |
| 236 | .read = read_file_bt_ant_diversity, |
| 237 | .write = write_file_bt_ant_diversity, |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 238 | .open = simple_open, |
| 239 | .owner = THIS_MODULE, |
| 240 | .llseek = default_llseek, |
| 241 | }; |
| 242 | |
Sujith Manoharan | 36e8825 | 2013-08-06 12:44:15 +0530 | [diff] [blame] | 243 | #endif |
| 244 | |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 245 | void ath9k_debug_stat_ant(struct ath_softc *sc, |
| 246 | struct ath_hw_antcomb_conf *div_ant_conf, |
| 247 | int main_rssi_avg, int alt_rssi_avg) |
| 248 | { |
| 249 | struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN]; |
| 250 | struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT]; |
| 251 | |
| 252 | as_main->lna_attempt_cnt[div_ant_conf->main_lna_conf]++; |
| 253 | as_alt->lna_attempt_cnt[div_ant_conf->alt_lna_conf]++; |
| 254 | |
| 255 | as_main->rssi_avg = main_rssi_avg; |
| 256 | as_alt->rssi_avg = alt_rssi_avg; |
| 257 | } |
| 258 | |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 259 | static ssize_t read_file_antenna_diversity(struct file *file, |
| 260 | char __user *user_buf, |
| 261 | size_t count, loff_t *ppos) |
| 262 | { |
| 263 | struct ath_softc *sc = file->private_data; |
| 264 | struct ath_hw *ah = sc->sc_ah; |
| 265 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
| 266 | struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN]; |
| 267 | struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT]; |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 268 | struct ath_hw_antcomb_conf div_ant_conf; |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 269 | unsigned int len = 0, size = 1024; |
| 270 | ssize_t retval = 0; |
| 271 | char *buf; |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 272 | char *lna_conf_str[4] = {"LNA1_MINUS_LNA2", |
| 273 | "LNA2", |
| 274 | "LNA1", |
| 275 | "LNA1_PLUS_LNA2"}; |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 276 | |
| 277 | buf = kzalloc(size, GFP_KERNEL); |
| 278 | if (buf == NULL) |
| 279 | return -ENOMEM; |
| 280 | |
| 281 | if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) { |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 282 | len += scnprintf(buf + len, size - len, "%s\n", |
| 283 | "Antenna Diversity Combining is disabled"); |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 284 | goto exit; |
| 285 | } |
| 286 | |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 287 | ath9k_ps_wakeup(sc); |
| 288 | ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 289 | len += scnprintf(buf + len, size - len, "Current MAIN config : %s\n", |
| 290 | lna_conf_str[div_ant_conf.main_lna_conf]); |
| 291 | len += scnprintf(buf + len, size - len, "Current ALT config : %s\n", |
| 292 | lna_conf_str[div_ant_conf.alt_lna_conf]); |
| 293 | len += scnprintf(buf + len, size - len, "Average MAIN RSSI : %d\n", |
| 294 | as_main->rssi_avg); |
| 295 | len += scnprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n", |
| 296 | as_alt->rssi_avg); |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 297 | ath9k_ps_restore(sc); |
| 298 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 299 | len += scnprintf(buf + len, size - len, "Packet Receive Cnt:\n"); |
| 300 | len += scnprintf(buf + len, size - len, "-------------------\n"); |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 301 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 302 | len += scnprintf(buf + len, size - len, "%30s%15s\n", |
| 303 | "MAIN", "ALT"); |
| 304 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 305 | "TOTAL COUNT", |
| 306 | as_main->recv_cnt, |
| 307 | as_alt->recv_cnt); |
| 308 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 309 | "LNA1", |
| 310 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1], |
| 311 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]); |
| 312 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 313 | "LNA2", |
| 314 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2], |
| 315 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2]); |
| 316 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 317 | "LNA1 + LNA2", |
| 318 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2], |
| 319 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); |
| 320 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 321 | "LNA1 - LNA2", |
| 322 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], |
| 323 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 324 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 325 | len += scnprintf(buf + len, size - len, "\nLNA Config Attempts:\n"); |
| 326 | len += scnprintf(buf + len, size - len, "--------------------\n"); |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 327 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 328 | len += scnprintf(buf + len, size - len, "%30s%15s\n", |
| 329 | "MAIN", "ALT"); |
| 330 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 331 | "LNA1", |
| 332 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1], |
| 333 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]); |
| 334 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 335 | "LNA2", |
| 336 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2], |
| 337 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2]); |
| 338 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 339 | "LNA1 + LNA2", |
| 340 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2], |
| 341 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); |
| 342 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 343 | "LNA1 - LNA2", |
| 344 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], |
| 345 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 346 | |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 347 | exit: |
| 348 | if (len > size) |
| 349 | len = size; |
| 350 | |
| 351 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 352 | kfree(buf); |
| 353 | |
| 354 | return retval; |
| 355 | } |
| 356 | |
| 357 | static const struct file_operations fops_antenna_diversity = { |
| 358 | .read = read_file_antenna_diversity, |
| 359 | .open = simple_open, |
| 360 | .owner = THIS_MODULE, |
| 361 | .llseek = default_llseek, |
| 362 | }; |
| 363 | |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 364 | static ssize_t read_file_dma(struct file *file, char __user *user_buf, |
| 365 | size_t count, loff_t *ppos) |
| 366 | { |
| 367 | struct ath_softc *sc = file->private_data; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 368 | struct ath_hw *ah = sc->sc_ah; |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 369 | char *buf; |
| 370 | int retval; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 371 | unsigned int len = 0; |
| 372 | u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; |
| 373 | int i, qcuOffset = 0, dcuOffset = 0; |
| 374 | u32 *qcuBase = &val[0], *dcuBase = &val[4]; |
| 375 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 376 | buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); |
| 377 | if (!buf) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 378 | return -ENOMEM; |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 379 | |
Sujith | 7cf4a2e | 2009-08-26 11:11:57 +0530 | [diff] [blame] | 380 | ath9k_ps_wakeup(sc); |
| 381 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 382 | REG_WRITE_D(ah, AR_MACMISC, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 383 | ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | |
| 384 | (AR_MACMISC_MISC_OBS_BUS_1 << |
| 385 | AR_MACMISC_MISC_OBS_BUS_MSB_S))); |
| 386 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 387 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
| 388 | "Raw DMA Debug values:\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 389 | |
| 390 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { |
| 391 | if (i % 4 == 0) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 392 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 393 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 394 | val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 395 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", |
| 396 | i, val[i]); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 397 | } |
| 398 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 399 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); |
| 400 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
| 401 | "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 402 | |
| 403 | for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { |
| 404 | if (i == 8) { |
| 405 | qcuOffset = 0; |
| 406 | qcuBase++; |
| 407 | } |
| 408 | |
| 409 | if (i == 6) { |
| 410 | dcuOffset = 0; |
| 411 | dcuBase++; |
| 412 | } |
| 413 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 414 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
| 415 | "%2d %2x %1x %2x %2x\n", |
| 416 | i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, |
| 417 | (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), |
| 418 | val[2] & (0x7 << (i * 3)) >> (i * 3), |
| 419 | (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 420 | } |
| 421 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 422 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 423 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 424 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 425 | "qcu_stitch state: %2x qcu_fetch state: %2x\n", |
| 426 | (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 427 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 428 | "qcu_complete state: %2x dcu_complete state: %2x\n", |
| 429 | (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 430 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 431 | "dcu_arb state: %2x dcu_fp state: %2x\n", |
| 432 | (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 433 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 434 | "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", |
| 435 | (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 436 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 437 | "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", |
| 438 | (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 439 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 440 | "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", |
| 441 | (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); |
| 442 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 443 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n", |
| 444 | REG_READ_D(ah, AR_OBS_BUS_1)); |
| 445 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
| 446 | "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 447 | |
Sujith | 7cf4a2e | 2009-08-26 11:11:57 +0530 | [diff] [blame] | 448 | ath9k_ps_restore(sc); |
| 449 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 450 | if (len > DMA_BUF_LEN) |
| 451 | len = DMA_BUF_LEN; |
| 452 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 453 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 454 | kfree(buf); |
| 455 | return retval; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | static const struct file_operations fops_dma = { |
| 459 | .read = read_file_dma, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 460 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 461 | .owner = THIS_MODULE, |
| 462 | .llseek = default_llseek, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 463 | }; |
| 464 | |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 465 | |
| 466 | void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) |
| 467 | { |
| 468 | if (status) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 469 | sc->debug.stats.istats.total++; |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 470 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
| 471 | if (status & ATH9K_INT_RXLP) |
| 472 | sc->debug.stats.istats.rxlp++; |
| 473 | if (status & ATH9K_INT_RXHP) |
| 474 | sc->debug.stats.istats.rxhp++; |
Luis R. Rodriguez | 08578b8 | 2010-05-13 13:33:44 -0400 | [diff] [blame] | 475 | if (status & ATH9K_INT_BB_WATCHDOG) |
| 476 | sc->debug.stats.istats.bb_watchdog++; |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 477 | } else { |
| 478 | if (status & ATH9K_INT_RX) |
| 479 | sc->debug.stats.istats.rxok++; |
| 480 | } |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 481 | if (status & ATH9K_INT_RXEOL) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 482 | sc->debug.stats.istats.rxeol++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 483 | if (status & ATH9K_INT_RXORN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 484 | sc->debug.stats.istats.rxorn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 485 | if (status & ATH9K_INT_TX) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 486 | sc->debug.stats.istats.txok++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 487 | if (status & ATH9K_INT_TXURN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 488 | sc->debug.stats.istats.txurn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 489 | if (status & ATH9K_INT_RXPHY) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 490 | sc->debug.stats.istats.rxphyerr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 491 | if (status & ATH9K_INT_RXKCM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 492 | sc->debug.stats.istats.rx_keycache_miss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 493 | if (status & ATH9K_INT_SWBA) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 494 | sc->debug.stats.istats.swba++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 495 | if (status & ATH9K_INT_BMISS) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 496 | sc->debug.stats.istats.bmiss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 497 | if (status & ATH9K_INT_BNR) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 498 | sc->debug.stats.istats.bnr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 499 | if (status & ATH9K_INT_CST) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 500 | sc->debug.stats.istats.cst++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 501 | if (status & ATH9K_INT_GTT) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 502 | sc->debug.stats.istats.gtt++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 503 | if (status & ATH9K_INT_TIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 504 | sc->debug.stats.istats.tim++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 505 | if (status & ATH9K_INT_CABEND) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 506 | sc->debug.stats.istats.cabend++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 507 | if (status & ATH9K_INT_DTIMSYNC) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 508 | sc->debug.stats.istats.dtimsync++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 509 | if (status & ATH9K_INT_DTIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 510 | sc->debug.stats.istats.dtim++; |
Mohammed Shafi Shajakhan | 6dde1aa | 2011-04-22 17:27:01 +0530 | [diff] [blame] | 511 | if (status & ATH9K_INT_TSFOOR) |
| 512 | sc->debug.stats.istats.tsfoor++; |
Sujith Manoharan | 97ba515 | 2012-06-04 16:27:41 +0530 | [diff] [blame] | 513 | if (status & ATH9K_INT_MCI) |
| 514 | sc->debug.stats.istats.mci++; |
Mohammed Shafi Shajakhan | c9e6e98 | 2012-09-07 15:54:13 +0530 | [diff] [blame] | 515 | if (status & ATH9K_INT_GENTIMER) |
| 516 | sc->debug.stats.istats.gen_timer++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, |
| 520 | size_t count, loff_t *ppos) |
| 521 | { |
| 522 | struct ath_softc *sc = file->private_data; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 523 | unsigned int len = 0; |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 524 | int rv; |
| 525 | int mxlen = 4000; |
| 526 | char *buf = kmalloc(mxlen, GFP_KERNEL); |
| 527 | if (!buf) |
| 528 | return -ENOMEM; |
| 529 | |
| 530 | #define PR_IS(a, s) \ |
| 531 | do { \ |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 532 | len += scnprintf(buf + len, mxlen - len, \ |
| 533 | "%21s: %10u\n", a, \ |
| 534 | sc->debug.stats.istats.s); \ |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 535 | } while (0) |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 536 | |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 537 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 538 | PR_IS("RXLP", rxlp); |
| 539 | PR_IS("RXHP", rxhp); |
| 540 | PR_IS("WATHDOG", bb_watchdog); |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 541 | } else { |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 542 | PR_IS("RX", rxok); |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 543 | } |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 544 | PR_IS("RXEOL", rxeol); |
| 545 | PR_IS("RXORN", rxorn); |
| 546 | PR_IS("TX", txok); |
| 547 | PR_IS("TXURN", txurn); |
| 548 | PR_IS("MIB", mib); |
| 549 | PR_IS("RXPHY", rxphyerr); |
| 550 | PR_IS("RXKCM", rx_keycache_miss); |
| 551 | PR_IS("SWBA", swba); |
| 552 | PR_IS("BMISS", bmiss); |
| 553 | PR_IS("BNR", bnr); |
| 554 | PR_IS("CST", cst); |
| 555 | PR_IS("GTT", gtt); |
| 556 | PR_IS("TIM", tim); |
| 557 | PR_IS("CABEND", cabend); |
| 558 | PR_IS("DTIMSYNC", dtimsync); |
| 559 | PR_IS("DTIM", dtim); |
| 560 | PR_IS("TSFOOR", tsfoor); |
Sujith Manoharan | 97ba515 | 2012-06-04 16:27:41 +0530 | [diff] [blame] | 561 | PR_IS("MCI", mci); |
Mohammed Shafi Shajakhan | c9e6e98 | 2012-09-07 15:54:13 +0530 | [diff] [blame] | 562 | PR_IS("GENTIMER", gen_timer); |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 563 | PR_IS("TOTAL", total); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 564 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 565 | len += scnprintf(buf + len, mxlen - len, |
| 566 | "SYNC_CAUSE stats:\n"); |
Mohammed Shafi Shajakhan | 6dde1aa | 2011-04-22 17:27:01 +0530 | [diff] [blame] | 567 | |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 568 | PR_IS("Sync-All", sync_cause_all); |
| 569 | PR_IS("RTC-IRQ", sync_rtc_irq); |
| 570 | PR_IS("MAC-IRQ", sync_mac_irq); |
| 571 | PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access); |
| 572 | PR_IS("APB-Timeout", apb_timeout); |
| 573 | PR_IS("PCI-Mode-Conflict", pci_mode_conflict); |
| 574 | PR_IS("HOST1-Fatal", host1_fatal); |
| 575 | PR_IS("HOST1-Perr", host1_perr); |
| 576 | PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr); |
| 577 | PR_IS("RADM-CPL-EP", radm_cpl_ep); |
| 578 | PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort); |
| 579 | PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort); |
| 580 | PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err); |
| 581 | PR_IS("RADM-CPL-Timeout", radm_cpl_timeout); |
| 582 | PR_IS("Local-Bus-Timeout", local_timeout); |
| 583 | PR_IS("PM-Access", pm_access); |
| 584 | PR_IS("MAC-Awake", mac_awake); |
| 585 | PR_IS("MAC-Asleep", mac_asleep); |
| 586 | PR_IS("MAC-Sleep-Access", mac_sleep_access); |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 587 | |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 588 | if (len > mxlen) |
| 589 | len = mxlen; |
| 590 | |
| 591 | rv = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 592 | kfree(buf); |
| 593 | return rv; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | static const struct file_operations fops_interrupt = { |
| 597 | .read = read_file_interrupt, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 598 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 599 | .owner = THIS_MODULE, |
| 600 | .llseek = default_llseek, |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 601 | }; |
| 602 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 603 | static ssize_t read_file_xmit(struct file *file, char __user *user_buf, |
| 604 | size_t count, loff_t *ppos) |
| 605 | { |
| 606 | struct ath_softc *sc = file->private_data; |
| 607 | char *buf; |
Sujith Manoharan | 78ef731 | 2012-11-21 18:13:11 +0530 | [diff] [blame] | 608 | unsigned int len = 0, size = 2048; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 609 | ssize_t retval = 0; |
| 610 | |
| 611 | buf = kzalloc(size, GFP_KERNEL); |
| 612 | if (buf == NULL) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 613 | return -ENOMEM; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 614 | |
Sujith Manoharan | 78ef731 | 2012-11-21 18:13:11 +0530 | [diff] [blame] | 615 | len += sprintf(buf, "%30s %10s%10s%10s\n\n", |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 616 | "BE", "BK", "VI", "VO"); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 617 | |
| 618 | PR("MPDUs Queued: ", queued); |
| 619 | PR("MPDUs Completed: ", completed); |
Felix Fietkau | 5a6f78a | 2011-05-31 21:21:41 +0200 | [diff] [blame] | 620 | PR("MPDUs XRetried: ", xretries); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 621 | PR("Aggregates: ", a_aggr); |
Ben Greear | bda8add | 2011-01-09 23:11:48 -0800 | [diff] [blame] | 622 | PR("AMPDUs Queued HW:", a_queued_hw); |
| 623 | PR("AMPDUs Queued SW:", a_queued_sw); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 624 | PR("AMPDUs Completed:", a_completed); |
| 625 | PR("AMPDUs Retried: ", a_retries); |
| 626 | PR("AMPDUs XRetried: ", a_xretries); |
Ben Greear | 4d90038 | 2013-03-04 15:31:16 -0800 | [diff] [blame] | 627 | PR("TXERR Filtered: ", txerr_filtered); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 628 | PR("FIFO Underrun: ", fifo_underrun); |
| 629 | PR("TXOP Exceeded: ", xtxop); |
| 630 | PR("TXTIMER Expiry: ", timer_exp); |
| 631 | PR("DESC CFG Error: ", desc_cfg_err); |
| 632 | PR("DATA Underrun: ", data_underrun); |
| 633 | PR("DELIM Underrun: ", delim_underrun); |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 634 | PR("TX-Pkts-All: ", tx_pkts_all); |
| 635 | PR("TX-Bytes-All: ", tx_bytes_all); |
Sujith Manoharan | 78ef731 | 2012-11-21 18:13:11 +0530 | [diff] [blame] | 636 | PR("HW-put-tx-buf: ", puttxbuf); |
| 637 | PR("HW-tx-start: ", txstart); |
| 638 | PR("HW-tx-proc-desc: ", txprocdesc); |
Ben Greear | a5a0bca | 2012-04-03 09:16:55 -0700 | [diff] [blame] | 639 | PR("TX-Failed: ", txfailed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 640 | |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 641 | if (len > size) |
| 642 | len = size; |
| 643 | |
| 644 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 645 | kfree(buf); |
| 646 | |
| 647 | return retval; |
| 648 | } |
| 649 | |
Felix Fietkau | 18fcf1c | 2013-08-06 14:18:05 +0200 | [diff] [blame] | 650 | static ssize_t print_queue(struct ath_softc *sc, struct ath_txq *txq, |
| 651 | char *buf, ssize_t size) |
| 652 | { |
| 653 | ssize_t len = 0; |
| 654 | |
| 655 | ath_txq_lock(sc, txq); |
| 656 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 657 | len += scnprintf(buf + len, size - len, "%s: %d ", |
| 658 | "qnum", txq->axq_qnum); |
| 659 | len += scnprintf(buf + len, size - len, "%s: %2d ", |
| 660 | "qdepth", txq->axq_depth); |
| 661 | len += scnprintf(buf + len, size - len, "%s: %2d ", |
| 662 | "ampdu-depth", txq->axq_ampdu_depth); |
| 663 | len += scnprintf(buf + len, size - len, "%s: %3d ", |
| 664 | "pending", txq->pending_frames); |
| 665 | len += scnprintf(buf + len, size - len, "%s: %d\n", |
| 666 | "stopped", txq->stopped); |
Felix Fietkau | 18fcf1c | 2013-08-06 14:18:05 +0200 | [diff] [blame] | 667 | |
| 668 | ath_txq_unlock(sc, txq); |
| 669 | return len; |
| 670 | } |
| 671 | |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 672 | static ssize_t read_file_queues(struct file *file, char __user *user_buf, |
| 673 | size_t count, loff_t *ppos) |
| 674 | { |
| 675 | struct ath_softc *sc = file->private_data; |
| 676 | struct ath_txq *txq; |
| 677 | char *buf; |
| 678 | unsigned int len = 0, size = 1024; |
| 679 | ssize_t retval = 0; |
| 680 | int i; |
| 681 | char *qname[4] = {"VO", "VI", "BE", "BK"}; |
| 682 | |
| 683 | buf = kzalloc(size, GFP_KERNEL); |
| 684 | if (buf == NULL) |
| 685 | return -ENOMEM; |
| 686 | |
| 687 | for (i = 0; i < IEEE80211_NUM_ACS; i++) { |
| 688 | txq = sc->tx.txq_map[i]; |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 689 | len += scnprintf(buf + len, size - len, "(%s): ", qname[i]); |
Felix Fietkau | 18fcf1c | 2013-08-06 14:18:05 +0200 | [diff] [blame] | 690 | len += print_queue(sc, txq, buf + len, size - len); |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 691 | } |
| 692 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 693 | len += scnprintf(buf + len, size - len, "(CAB): "); |
Felix Fietkau | 18fcf1c | 2013-08-06 14:18:05 +0200 | [diff] [blame] | 694 | len += print_queue(sc, sc->beacon.cabq, buf + len, size - len); |
| 695 | |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 696 | if (len > size) |
| 697 | len = size; |
| 698 | |
| 699 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 700 | kfree(buf); |
| 701 | |
| 702 | return retval; |
| 703 | } |
| 704 | |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 705 | static ssize_t read_file_misc(struct file *file, char __user *user_buf, |
| 706 | size_t count, loff_t *ppos) |
| 707 | { |
| 708 | struct ath_softc *sc = file->private_data; |
| 709 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 710 | struct ieee80211_hw *hw = sc->hw; |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 711 | struct ath9k_vif_iter_data iter_data; |
| 712 | char buf[512]; |
| 713 | unsigned int len = 0; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 714 | ssize_t retval = 0; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 715 | unsigned int reg; |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 716 | u32 rxfilter; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 717 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 718 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 719 | "BSSID: %pM\n", common->curbssid); |
| 720 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 721 | "BSSID-MASK: %pM\n", common->bssidmask); |
| 722 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 723 | "OPMODE: %s\n", |
| 724 | ath_opmode_to_string(sc->sc_ah->opmode)); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 725 | |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 726 | ath9k_ps_wakeup(sc); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 727 | rxfilter = ath9k_hw_getrxfilter(sc->sc_ah); |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 728 | ath9k_ps_restore(sc); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 729 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 730 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 731 | "RXFILTER: 0x%x", rxfilter); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 732 | |
| 733 | if (rxfilter & ATH9K_RX_FILTER_UCAST) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 734 | len += scnprintf(buf + len, sizeof(buf) - len, " UCAST"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 735 | if (rxfilter & ATH9K_RX_FILTER_MCAST) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 736 | len += scnprintf(buf + len, sizeof(buf) - len, " MCAST"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 737 | if (rxfilter & ATH9K_RX_FILTER_BCAST) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 738 | len += scnprintf(buf + len, sizeof(buf) - len, " BCAST"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 739 | if (rxfilter & ATH9K_RX_FILTER_CONTROL) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 740 | len += scnprintf(buf + len, sizeof(buf) - len, " CONTROL"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 741 | if (rxfilter & ATH9K_RX_FILTER_BEACON) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 742 | len += scnprintf(buf + len, sizeof(buf) - len, " BEACON"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 743 | if (rxfilter & ATH9K_RX_FILTER_PROM) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 744 | len += scnprintf(buf + len, sizeof(buf) - len, " PROM"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 745 | if (rxfilter & ATH9K_RX_FILTER_PROBEREQ) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 746 | len += scnprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 747 | if (rxfilter & ATH9K_RX_FILTER_PHYERR) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 748 | len += scnprintf(buf + len, sizeof(buf) - len, " PHYERR"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 749 | if (rxfilter & ATH9K_RX_FILTER_MYBEACON) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 750 | len += scnprintf(buf + len, sizeof(buf) - len, " MYBEACON"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 751 | if (rxfilter & ATH9K_RX_FILTER_COMP_BAR) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 752 | len += scnprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 753 | if (rxfilter & ATH9K_RX_FILTER_PSPOLL) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 754 | len += scnprintf(buf + len, sizeof(buf) - len, " PSPOLL"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 755 | if (rxfilter & ATH9K_RX_FILTER_PHYRADAR) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 756 | len += scnprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 757 | if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 758 | len += scnprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 759 | if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 760 | len += scnprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 761 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 762 | len += scnprintf(buf + len, sizeof(buf) - len, "\n"); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 763 | |
| 764 | reg = sc->sc_ah->imask; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 765 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 766 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 767 | "INTERRUPT-MASK: 0x%x", reg); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 768 | |
| 769 | if (reg & ATH9K_INT_SWBA) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 770 | len += scnprintf(buf + len, sizeof(buf) - len, " SWBA"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 771 | if (reg & ATH9K_INT_BMISS) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 772 | len += scnprintf(buf + len, sizeof(buf) - len, " BMISS"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 773 | if (reg & ATH9K_INT_CST) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 774 | len += scnprintf(buf + len, sizeof(buf) - len, " CST"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 775 | if (reg & ATH9K_INT_RX) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 776 | len += scnprintf(buf + len, sizeof(buf) - len, " RX"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 777 | if (reg & ATH9K_INT_RXHP) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 778 | len += scnprintf(buf + len, sizeof(buf) - len, " RXHP"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 779 | if (reg & ATH9K_INT_RXLP) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 780 | len += scnprintf(buf + len, sizeof(buf) - len, " RXLP"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 781 | if (reg & ATH9K_INT_BB_WATCHDOG) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 782 | len += scnprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 783 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 784 | len += scnprintf(buf + len, sizeof(buf) - len, "\n"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 785 | |
| 786 | ath9k_calculate_iter_data(hw, NULL, &iter_data); |
| 787 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 788 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 789 | "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i" |
| 790 | " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n", |
| 791 | iter_data.naps, iter_data.nstations, iter_data.nmeshes, |
| 792 | iter_data.nwds, iter_data.nadhocs, |
| 793 | sc->nvifs, sc->nbcnvifs); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 794 | |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 795 | if (len > sizeof(buf)) |
| 796 | len = sizeof(buf); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 797 | |
| 798 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 799 | return retval; |
| 800 | } |
| 801 | |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 802 | static ssize_t read_file_reset(struct file *file, char __user *user_buf, |
| 803 | size_t count, loff_t *ppos) |
| 804 | { |
| 805 | struct ath_softc *sc = file->private_data; |
| 806 | char buf[512]; |
| 807 | unsigned int len = 0; |
| 808 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 809 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 810 | "%17s: %2d\n", "Baseband Hang", |
| 811 | sc->debug.stats.reset[RESET_TYPE_BB_HANG]); |
| 812 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 813 | "%17s: %2d\n", "Baseband Watchdog", |
| 814 | sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]); |
| 815 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 816 | "%17s: %2d\n", "Fatal HW Error", |
| 817 | sc->debug.stats.reset[RESET_TYPE_FATAL_INT]); |
| 818 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 819 | "%17s: %2d\n", "TX HW error", |
| 820 | sc->debug.stats.reset[RESET_TYPE_TX_ERROR]); |
| 821 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 822 | "%17s: %2d\n", "TX Path Hang", |
| 823 | sc->debug.stats.reset[RESET_TYPE_TX_HANG]); |
| 824 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 825 | "%17s: %2d\n", "PLL RX Hang", |
| 826 | sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); |
| 827 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 828 | "%17s: %2d\n", "MCI Reset", |
| 829 | sc->debug.stats.reset[RESET_TYPE_MCI]); |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 830 | |
| 831 | if (len > sizeof(buf)) |
| 832 | len = sizeof(buf); |
| 833 | |
| 834 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 835 | } |
| 836 | |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 837 | void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, |
Felix Fietkau | 55797b1 | 2011-09-14 21:24:16 +0200 | [diff] [blame] | 838 | struct ath_tx_status *ts, struct ath_txq *txq, |
| 839 | unsigned int flags) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 840 | { |
Felix Fietkau | 5bec3e5 | 2011-01-24 21:29:25 +0100 | [diff] [blame] | 841 | int qnum = txq->axq_qnum; |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 842 | |
| 843 | TX_STAT_INC(qnum, tx_pkts_all); |
| 844 | sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 845 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 846 | if (bf_isampdu(bf)) { |
Felix Fietkau | 156369f | 2011-12-14 22:08:04 +0100 | [diff] [blame] | 847 | if (flags & ATH_TX_ERROR) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 848 | TX_STAT_INC(qnum, a_xretries); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 849 | else |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 850 | TX_STAT_INC(qnum, a_completed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 851 | } else { |
Felix Fietkau | 55797b1 | 2011-09-14 21:24:16 +0200 | [diff] [blame] | 852 | if (ts->ts_status & ATH9K_TXERR_XRETRY) |
Felix Fietkau | 5a6f78a | 2011-05-31 21:21:41 +0200 | [diff] [blame] | 853 | TX_STAT_INC(qnum, xretries); |
| 854 | else |
| 855 | TX_STAT_INC(qnum, completed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 856 | } |
| 857 | |
Ben Greear | 4d90038 | 2013-03-04 15:31:16 -0800 | [diff] [blame] | 858 | if (ts->ts_status & ATH9K_TXERR_FILT) |
| 859 | TX_STAT_INC(qnum, txerr_filtered); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 860 | if (ts->ts_status & ATH9K_TXERR_FIFO) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 861 | TX_STAT_INC(qnum, fifo_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 862 | if (ts->ts_status & ATH9K_TXERR_XTXOP) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 863 | TX_STAT_INC(qnum, xtxop); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 864 | if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 865 | TX_STAT_INC(qnum, timer_exp); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 866 | if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 867 | TX_STAT_INC(qnum, desc_cfg_err); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 868 | if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 869 | TX_STAT_INC(qnum, data_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 870 | if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 871 | TX_STAT_INC(qnum, delim_underrun); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 872 | } |
| 873 | |
| 874 | static const struct file_operations fops_xmit = { |
| 875 | .read = read_file_xmit, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 876 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 877 | .owner = THIS_MODULE, |
| 878 | .llseek = default_llseek, |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 879 | }; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 880 | |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 881 | static const struct file_operations fops_queues = { |
| 882 | .read = read_file_queues, |
| 883 | .open = simple_open, |
| 884 | .owner = THIS_MODULE, |
| 885 | .llseek = default_llseek, |
| 886 | }; |
| 887 | |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 888 | static const struct file_operations fops_misc = { |
| 889 | .read = read_file_misc, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 890 | .open = simple_open, |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 891 | .owner = THIS_MODULE, |
| 892 | .llseek = default_llseek, |
| 893 | }; |
| 894 | |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 895 | static const struct file_operations fops_reset = { |
| 896 | .read = read_file_reset, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 897 | .open = simple_open, |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 898 | .owner = THIS_MODULE, |
| 899 | .llseek = default_llseek, |
| 900 | }; |
| 901 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 902 | static ssize_t read_file_recv(struct file *file, char __user *user_buf, |
| 903 | size_t count, loff_t *ppos) |
| 904 | { |
| 905 | #define PHY_ERR(s, p) \ |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 906 | len += scnprintf(buf + len, size - len, "%22s : %10u\n", s, \ |
| 907 | sc->debug.stats.rxstats.phy_err_stats[p]); |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 908 | |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 909 | #define RXS_ERR(s, e) \ |
| 910 | do { \ |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 911 | len += scnprintf(buf + len, size - len, \ |
| 912 | "%22s : %10u\n", s, \ |
| 913 | sc->debug.stats.rxstats.e);\ |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 914 | } while (0) |
| 915 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 916 | struct ath_softc *sc = file->private_data; |
| 917 | char *buf; |
Sujith Manoharan | 4203214 | 2012-02-16 11:51:23 +0530 | [diff] [blame] | 918 | unsigned int len = 0, size = 1600; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 919 | ssize_t retval = 0; |
| 920 | |
| 921 | buf = kzalloc(size, GFP_KERNEL); |
| 922 | if (buf == NULL) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 923 | return -ENOMEM; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 924 | |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 925 | RXS_ERR("CRC ERR", crc_err); |
| 926 | RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err); |
| 927 | RXS_ERR("PHY ERR", phy_err); |
| 928 | RXS_ERR("MIC ERR", mic_err); |
| 929 | RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err); |
| 930 | RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err); |
| 931 | RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err); |
| 932 | RXS_ERR("RX-LENGTH-ERR", rx_len_err); |
| 933 | RXS_ERR("RX-OOM-ERR", rx_oom_err); |
| 934 | RXS_ERR("RX-RATE-ERR", rx_rate_err); |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 935 | RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err); |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 936 | |
Sujith Manoharan | 4203214 | 2012-02-16 11:51:23 +0530 | [diff] [blame] | 937 | PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN); |
| 938 | PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING); |
| 939 | PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY); |
| 940 | PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE); |
| 941 | PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH); |
| 942 | PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR); |
| 943 | PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE); |
| 944 | PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR); |
| 945 | PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING); |
| 946 | PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); |
| 947 | PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); |
| 948 | PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); |
| 949 | PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP); |
| 950 | PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE); |
| 951 | PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART); |
| 952 | PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT); |
| 953 | PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING); |
| 954 | PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC); |
| 955 | PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL); |
| 956 | PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE); |
| 957 | PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART); |
| 958 | PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); |
| 959 | PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP); |
| 960 | PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR); |
| 961 | PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); |
| 962 | PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL); |
| 963 | |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 964 | RXS_ERR("RX-Pkts-All", rx_pkts_all); |
| 965 | RXS_ERR("RX-Bytes-All", rx_bytes_all); |
| 966 | RXS_ERR("RX-Beacons", rx_beacons); |
| 967 | RXS_ERR("RX-Frags", rx_frags); |
Simon Wunderlich | 9b99e66 | 2013-01-23 17:38:05 +0100 | [diff] [blame] | 968 | RXS_ERR("RX-Spectral", rx_spectral); |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 969 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 970 | if (len > size) |
| 971 | len = size; |
| 972 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 973 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 974 | kfree(buf); |
| 975 | |
| 976 | return retval; |
| 977 | |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 978 | #undef RXS_ERR |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 979 | #undef PHY_ERR |
| 980 | } |
| 981 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 982 | void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 983 | { |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 984 | #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++ |
| 985 | |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 986 | RX_STAT_INC(rx_pkts_all); |
| 987 | sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; |
| 988 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 989 | if (rs->rs_status & ATH9K_RXERR_CRC) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 990 | RX_STAT_INC(crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 991 | if (rs->rs_status & ATH9K_RXERR_DECRYPT) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 992 | RX_STAT_INC(decrypt_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 993 | if (rs->rs_status & ATH9K_RXERR_MIC) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 994 | RX_STAT_INC(mic_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 995 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 996 | RX_STAT_INC(pre_delim_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 997 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 998 | RX_STAT_INC(post_delim_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 999 | if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1000 | RX_STAT_INC(decrypt_busy_err); |
| 1001 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1002 | if (rs->rs_status & ATH9K_RXERR_PHY) { |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1003 | RX_STAT_INC(phy_err); |
Sujith Manoharan | dbb07f0 | 2012-02-16 11:52:25 +0530 | [diff] [blame] | 1004 | if (rs->rs_phyerr < ATH9K_PHYERR_MAX) |
| 1005 | RX_PHY_ERR_INC(rs->rs_phyerr); |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1006 | } |
| 1007 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1008 | #undef RX_PHY_ERR_INC |
| 1009 | } |
| 1010 | |
| 1011 | static const struct file_operations fops_recv = { |
| 1012 | .read = read_file_recv, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1013 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1014 | .owner = THIS_MODULE, |
| 1015 | .llseek = default_llseek, |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1016 | }; |
| 1017 | |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1018 | static ssize_t read_file_regidx(struct file *file, char __user *user_buf, |
| 1019 | size_t count, loff_t *ppos) |
| 1020 | { |
| 1021 | struct ath_softc *sc = file->private_data; |
| 1022 | char buf[32]; |
| 1023 | unsigned int len; |
| 1024 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 1025 | len = sprintf(buf, "0x%08x\n", sc->debug.regidx); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1026 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1027 | } |
| 1028 | |
| 1029 | static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, |
| 1030 | size_t count, loff_t *ppos) |
| 1031 | { |
| 1032 | struct ath_softc *sc = file->private_data; |
| 1033 | unsigned long regidx; |
| 1034 | char buf[32]; |
| 1035 | ssize_t len; |
| 1036 | |
| 1037 | len = min(count, sizeof(buf) - 1); |
| 1038 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 1039 | return -EFAULT; |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1040 | |
| 1041 | buf[len] = '\0'; |
Jingoo Han | 27d7f47 | 2013-05-31 21:24:06 +0000 | [diff] [blame] | 1042 | if (kstrtoul(buf, 0, ®idx)) |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1043 | return -EINVAL; |
| 1044 | |
| 1045 | sc->debug.regidx = regidx; |
| 1046 | return count; |
| 1047 | } |
| 1048 | |
| 1049 | static const struct file_operations fops_regidx = { |
| 1050 | .read = read_file_regidx, |
| 1051 | .write = write_file_regidx, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1052 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1053 | .owner = THIS_MODULE, |
| 1054 | .llseek = default_llseek, |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1055 | }; |
| 1056 | |
| 1057 | static ssize_t read_file_regval(struct file *file, char __user *user_buf, |
| 1058 | size_t count, loff_t *ppos) |
| 1059 | { |
| 1060 | struct ath_softc *sc = file->private_data; |
| 1061 | struct ath_hw *ah = sc->sc_ah; |
| 1062 | char buf[32]; |
| 1063 | unsigned int len; |
| 1064 | u32 regval; |
| 1065 | |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1066 | ath9k_ps_wakeup(sc); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1067 | regval = REG_READ_D(ah, sc->debug.regidx); |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1068 | ath9k_ps_restore(sc); |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 1069 | len = sprintf(buf, "0x%08x\n", regval); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1070 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1071 | } |
| 1072 | |
| 1073 | static ssize_t write_file_regval(struct file *file, const char __user *user_buf, |
| 1074 | size_t count, loff_t *ppos) |
| 1075 | { |
| 1076 | struct ath_softc *sc = file->private_data; |
| 1077 | struct ath_hw *ah = sc->sc_ah; |
| 1078 | unsigned long regval; |
| 1079 | char buf[32]; |
| 1080 | ssize_t len; |
| 1081 | |
| 1082 | len = min(count, sizeof(buf) - 1); |
| 1083 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 1084 | return -EFAULT; |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1085 | |
| 1086 | buf[len] = '\0'; |
Jingoo Han | 27d7f47 | 2013-05-31 21:24:06 +0000 | [diff] [blame] | 1087 | if (kstrtoul(buf, 0, ®val)) |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1088 | return -EINVAL; |
| 1089 | |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1090 | ath9k_ps_wakeup(sc); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1091 | REG_WRITE_D(ah, sc->debug.regidx, regval); |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1092 | ath9k_ps_restore(sc); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1093 | return count; |
| 1094 | } |
| 1095 | |
| 1096 | static const struct file_operations fops_regval = { |
| 1097 | .read = read_file_regval, |
| 1098 | .write = write_file_regval, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1099 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1100 | .owner = THIS_MODULE, |
| 1101 | .llseek = default_llseek, |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1102 | }; |
| 1103 | |
Vasanthakumar Thiagarajan | 582d006 | 2011-03-01 05:30:55 -0800 | [diff] [blame] | 1104 | #define REGDUMP_LINE_SIZE 20 |
| 1105 | |
| 1106 | static int open_file_regdump(struct inode *inode, struct file *file) |
| 1107 | { |
| 1108 | struct ath_softc *sc = inode->i_private; |
| 1109 | unsigned int len = 0; |
| 1110 | u8 *buf; |
| 1111 | int i; |
| 1112 | unsigned long num_regs, regdump_len, max_reg_offset; |
| 1113 | |
| 1114 | max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500; |
| 1115 | num_regs = max_reg_offset / 4 + 1; |
| 1116 | regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; |
| 1117 | buf = vmalloc(regdump_len); |
| 1118 | if (!buf) |
| 1119 | return -ENOMEM; |
| 1120 | |
| 1121 | ath9k_ps_wakeup(sc); |
| 1122 | for (i = 0; i < num_regs; i++) |
| 1123 | len += scnprintf(buf + len, regdump_len - len, |
| 1124 | "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); |
| 1125 | ath9k_ps_restore(sc); |
| 1126 | |
| 1127 | file->private_data = buf; |
| 1128 | |
| 1129 | return 0; |
| 1130 | } |
| 1131 | |
| 1132 | static const struct file_operations fops_regdump = { |
| 1133 | .open = open_file_regdump, |
| 1134 | .read = ath9k_debugfs_read_buf, |
| 1135 | .release = ath9k_debugfs_release_buf, |
| 1136 | .owner = THIS_MODULE, |
| 1137 | .llseek = default_llseek,/* read accesses f_pos */ |
| 1138 | }; |
| 1139 | |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1140 | static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf, |
| 1141 | size_t count, loff_t *ppos) |
| 1142 | { |
| 1143 | struct ath_softc *sc = file->private_data; |
| 1144 | struct ath_hw *ah = sc->sc_ah; |
| 1145 | struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist; |
| 1146 | struct ath_common *common = ath9k_hw_common(ah); |
| 1147 | struct ieee80211_conf *conf = &common->hw->conf; |
| 1148 | u32 len = 0, size = 1500; |
| 1149 | u32 i, j; |
| 1150 | ssize_t retval = 0; |
| 1151 | char *buf; |
| 1152 | u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; |
| 1153 | u8 nread; |
| 1154 | |
| 1155 | buf = kzalloc(size, GFP_KERNEL); |
| 1156 | if (!buf) |
| 1157 | return -ENOMEM; |
| 1158 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 1159 | len += scnprintf(buf + len, size - len, |
| 1160 | "Channel Noise Floor : %d\n", ah->noise); |
| 1161 | len += scnprintf(buf + len, size - len, |
| 1162 | "Chain | privNF | # Readings | NF Readings\n"); |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1163 | for (i = 0; i < NUM_NF_READINGS; i++) { |
| 1164 | if (!(chainmask & (1 << i)) || |
| 1165 | ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) |
| 1166 | continue; |
| 1167 | |
| 1168 | nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 1169 | len += scnprintf(buf + len, size - len, " %d\t %d\t %d\t\t", |
| 1170 | i, h[i].privNF, nread); |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1171 | for (j = 0; j < nread; j++) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 1172 | len += scnprintf(buf + len, size - len, |
| 1173 | " %d", h[i].nfCalBuffer[j]); |
| 1174 | len += scnprintf(buf + len, size - len, "\n"); |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1175 | } |
| 1176 | |
| 1177 | if (len > size) |
| 1178 | len = size; |
| 1179 | |
| 1180 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1181 | kfree(buf); |
| 1182 | |
| 1183 | return retval; |
| 1184 | } |
| 1185 | |
| 1186 | static const struct file_operations fops_dump_nfcal = { |
| 1187 | .read = read_file_dump_nfcal, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1188 | .open = simple_open, |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1189 | .owner = THIS_MODULE, |
| 1190 | .llseek = default_llseek, |
| 1191 | }; |
| 1192 | |
Rajkumar Manoharan | 580f010 | 2011-07-29 17:38:12 +0530 | [diff] [blame] | 1193 | static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf, |
| 1194 | size_t count, loff_t *ppos) |
| 1195 | { |
| 1196 | struct ath_softc *sc = file->private_data; |
| 1197 | struct ath_hw *ah = sc->sc_ah; |
| 1198 | u32 len = 0, size = 1500; |
| 1199 | ssize_t retval = 0; |
| 1200 | char *buf; |
| 1201 | |
| 1202 | buf = kzalloc(size, GFP_KERNEL); |
| 1203 | if (!buf) |
| 1204 | return -ENOMEM; |
| 1205 | |
| 1206 | len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size); |
| 1207 | |
| 1208 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1209 | kfree(buf); |
| 1210 | |
| 1211 | return retval; |
| 1212 | } |
| 1213 | |
| 1214 | static const struct file_operations fops_base_eeprom = { |
| 1215 | .read = read_file_base_eeprom, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1216 | .open = simple_open, |
Rajkumar Manoharan | 580f010 | 2011-07-29 17:38:12 +0530 | [diff] [blame] | 1217 | .owner = THIS_MODULE, |
| 1218 | .llseek = default_llseek, |
| 1219 | }; |
| 1220 | |
Rajkumar Manoharan | 3f4c4bd | 2011-07-29 17:38:13 +0530 | [diff] [blame] | 1221 | static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf, |
| 1222 | size_t count, loff_t *ppos) |
| 1223 | { |
| 1224 | struct ath_softc *sc = file->private_data; |
| 1225 | struct ath_hw *ah = sc->sc_ah; |
| 1226 | u32 len = 0, size = 6000; |
| 1227 | char *buf; |
| 1228 | size_t retval; |
| 1229 | |
| 1230 | buf = kzalloc(size, GFP_KERNEL); |
| 1231 | if (buf == NULL) |
| 1232 | return -ENOMEM; |
| 1233 | |
| 1234 | len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size); |
| 1235 | |
| 1236 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1237 | kfree(buf); |
| 1238 | |
| 1239 | return retval; |
| 1240 | } |
| 1241 | |
| 1242 | static const struct file_operations fops_modal_eeprom = { |
| 1243 | .read = read_file_modal_eeprom, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1244 | .open = simple_open, |
Rajkumar Manoharan | 3f4c4bd | 2011-07-29 17:38:13 +0530 | [diff] [blame] | 1245 | .owner = THIS_MODULE, |
| 1246 | .llseek = default_llseek, |
| 1247 | }; |
| 1248 | |
Rajkumar Manoharan | 4df50ca | 2012-10-25 17:16:54 +0530 | [diff] [blame] | 1249 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT |
| 1250 | static ssize_t read_file_btcoex(struct file *file, char __user *user_buf, |
| 1251 | size_t count, loff_t *ppos) |
| 1252 | { |
| 1253 | struct ath_softc *sc = file->private_data; |
| 1254 | u32 len = 0, size = 1500; |
| 1255 | char *buf; |
| 1256 | size_t retval; |
| 1257 | |
| 1258 | buf = kzalloc(size, GFP_KERNEL); |
| 1259 | if (buf == NULL) |
| 1260 | return -ENOMEM; |
| 1261 | |
Sujith Manoharan | ac46ba4 | 2012-11-19 14:24:46 +0530 | [diff] [blame] | 1262 | if (!sc->sc_ah->common.btcoex_enabled) { |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 1263 | len = scnprintf(buf, size, "%s\n", |
| 1264 | "BTCOEX is disabled"); |
Sujith Manoharan | ac46ba4 | 2012-11-19 14:24:46 +0530 | [diff] [blame] | 1265 | goto exit; |
| 1266 | } |
Rajkumar Manoharan | 4df50ca | 2012-10-25 17:16:54 +0530 | [diff] [blame] | 1267 | |
Sujith Manoharan | ac46ba4 | 2012-11-19 14:24:46 +0530 | [diff] [blame] | 1268 | len = ath9k_dump_btcoex(sc, buf, size); |
| 1269 | exit: |
Rajkumar Manoharan | 4df50ca | 2012-10-25 17:16:54 +0530 | [diff] [blame] | 1270 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1271 | kfree(buf); |
| 1272 | |
| 1273 | return retval; |
| 1274 | } |
| 1275 | |
| 1276 | static const struct file_operations fops_btcoex = { |
| 1277 | .read = read_file_btcoex, |
| 1278 | .open = simple_open, |
| 1279 | .owner = THIS_MODULE, |
| 1280 | .llseek = default_llseek, |
| 1281 | }; |
| 1282 | #endif |
| 1283 | |
Sujith Manoharan | a145daf | 2012-11-28 15:08:54 +0530 | [diff] [blame] | 1284 | static ssize_t read_file_node_stat(struct file *file, char __user *user_buf, |
| 1285 | size_t count, loff_t *ppos) |
| 1286 | { |
| 1287 | struct ath_node *an = file->private_data; |
| 1288 | struct ath_softc *sc = an->sc; |
| 1289 | struct ath_atx_tid *tid; |
| 1290 | struct ath_atx_ac *ac; |
| 1291 | struct ath_txq *txq; |
| 1292 | u32 len = 0, size = 4096; |
| 1293 | char *buf; |
| 1294 | size_t retval; |
| 1295 | int tidno, acno; |
| 1296 | |
| 1297 | buf = kzalloc(size, GFP_KERNEL); |
| 1298 | if (buf == NULL) |
| 1299 | return -ENOMEM; |
| 1300 | |
| 1301 | if (!an->sta->ht_cap.ht_supported) { |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 1302 | len = scnprintf(buf, size, "%s\n", |
| 1303 | "HT not supported"); |
Sujith Manoharan | a145daf | 2012-11-28 15:08:54 +0530 | [diff] [blame] | 1304 | goto exit; |
| 1305 | } |
| 1306 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 1307 | len = scnprintf(buf, size, "Max-AMPDU: %d\n", |
| 1308 | an->maxampdu); |
| 1309 | len += scnprintf(buf + len, size - len, "MPDU Density: %d\n\n", |
| 1310 | an->mpdudensity); |
Sujith Manoharan | a145daf | 2012-11-28 15:08:54 +0530 | [diff] [blame] | 1311 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 1312 | len += scnprintf(buf + len, size - len, |
| 1313 | "%2s%7s\n", "AC", "SCHED"); |
Sujith Manoharan | a145daf | 2012-11-28 15:08:54 +0530 | [diff] [blame] | 1314 | |
| 1315 | for (acno = 0, ac = &an->ac[acno]; |
| 1316 | acno < IEEE80211_NUM_ACS; acno++, ac++) { |
| 1317 | txq = ac->txq; |
| 1318 | ath_txq_lock(sc, txq); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 1319 | len += scnprintf(buf + len, size - len, |
| 1320 | "%2d%7d\n", |
| 1321 | acno, ac->sched); |
Sujith Manoharan | a145daf | 2012-11-28 15:08:54 +0530 | [diff] [blame] | 1322 | ath_txq_unlock(sc, txq); |
| 1323 | } |
| 1324 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 1325 | len += scnprintf(buf + len, size - len, |
| 1326 | "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n", |
| 1327 | "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE", |
| 1328 | "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED"); |
Sujith Manoharan | a145daf | 2012-11-28 15:08:54 +0530 | [diff] [blame] | 1329 | |
| 1330 | for (tidno = 0, tid = &an->tid[tidno]; |
| 1331 | tidno < IEEE80211_NUM_TIDS; tidno++, tid++) { |
| 1332 | txq = tid->ac->txq; |
| 1333 | ath_txq_lock(sc, txq); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 1334 | len += scnprintf(buf + len, size - len, |
| 1335 | "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n", |
| 1336 | tid->tidno, tid->seq_start, tid->seq_next, |
| 1337 | tid->baw_size, tid->baw_head, tid->baw_tail, |
| 1338 | tid->bar_index, tid->sched, tid->paused); |
Sujith Manoharan | a145daf | 2012-11-28 15:08:54 +0530 | [diff] [blame] | 1339 | ath_txq_unlock(sc, txq); |
| 1340 | } |
| 1341 | exit: |
| 1342 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1343 | kfree(buf); |
| 1344 | |
| 1345 | return retval; |
| 1346 | } |
| 1347 | |
| 1348 | static const struct file_operations fops_node_stat = { |
| 1349 | .read = read_file_node_stat, |
| 1350 | .open = simple_open, |
| 1351 | .owner = THIS_MODULE, |
| 1352 | .llseek = default_llseek, |
| 1353 | }; |
| 1354 | |
| 1355 | void ath9k_sta_add_debugfs(struct ieee80211_hw *hw, |
| 1356 | struct ieee80211_vif *vif, |
| 1357 | struct ieee80211_sta *sta, |
| 1358 | struct dentry *dir) |
| 1359 | { |
| 1360 | struct ath_node *an = (struct ath_node *)sta->drv_priv; |
Felix Fietkau | f5bde5b | 2013-08-13 12:33:26 +0200 | [diff] [blame] | 1361 | debugfs_create_file("node_stat", S_IRUGO, dir, an, &fops_node_stat); |
Sujith Manoharan | a145daf | 2012-11-28 15:08:54 +0530 | [diff] [blame] | 1362 | } |
| 1363 | |
Sujith Manoharan | c175db8 | 2012-11-28 15:08:52 +0530 | [diff] [blame] | 1364 | /* Ethtool support for get-stats */ |
| 1365 | |
| 1366 | #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO" |
| 1367 | static const char ath9k_gstrings_stats[][ETH_GSTRING_LEN] = { |
| 1368 | "tx_pkts_nic", |
| 1369 | "tx_bytes_nic", |
| 1370 | "rx_pkts_nic", |
| 1371 | "rx_bytes_nic", |
| 1372 | AMKSTR(d_tx_pkts), |
| 1373 | AMKSTR(d_tx_bytes), |
| 1374 | AMKSTR(d_tx_mpdus_queued), |
| 1375 | AMKSTR(d_tx_mpdus_completed), |
| 1376 | AMKSTR(d_tx_mpdu_xretries), |
| 1377 | AMKSTR(d_tx_aggregates), |
| 1378 | AMKSTR(d_tx_ampdus_queued_hw), |
| 1379 | AMKSTR(d_tx_ampdus_queued_sw), |
| 1380 | AMKSTR(d_tx_ampdus_completed), |
| 1381 | AMKSTR(d_tx_ampdu_retries), |
| 1382 | AMKSTR(d_tx_ampdu_xretries), |
| 1383 | AMKSTR(d_tx_fifo_underrun), |
| 1384 | AMKSTR(d_tx_op_exceeded), |
| 1385 | AMKSTR(d_tx_timer_expiry), |
| 1386 | AMKSTR(d_tx_desc_cfg_err), |
| 1387 | AMKSTR(d_tx_data_underrun), |
| 1388 | AMKSTR(d_tx_delim_underrun), |
Ben Greear | 18c45b1 | 2013-03-04 15:31:17 -0800 | [diff] [blame] | 1389 | "d_rx_crc_err", |
Sujith Manoharan | c175db8 | 2012-11-28 15:08:52 +0530 | [diff] [blame] | 1390 | "d_rx_decrypt_crc_err", |
| 1391 | "d_rx_phy_err", |
| 1392 | "d_rx_mic_err", |
| 1393 | "d_rx_pre_delim_crc_err", |
| 1394 | "d_rx_post_delim_crc_err", |
| 1395 | "d_rx_decrypt_busy_err", |
| 1396 | |
| 1397 | "d_rx_phyerr_radar", |
| 1398 | "d_rx_phyerr_ofdm_timing", |
| 1399 | "d_rx_phyerr_cck_timing", |
| 1400 | |
| 1401 | }; |
| 1402 | #define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats) |
| 1403 | |
| 1404 | void ath9k_get_et_strings(struct ieee80211_hw *hw, |
| 1405 | struct ieee80211_vif *vif, |
| 1406 | u32 sset, u8 *data) |
| 1407 | { |
| 1408 | if (sset == ETH_SS_STATS) |
| 1409 | memcpy(data, *ath9k_gstrings_stats, |
| 1410 | sizeof(ath9k_gstrings_stats)); |
| 1411 | } |
| 1412 | |
| 1413 | int ath9k_get_et_sset_count(struct ieee80211_hw *hw, |
| 1414 | struct ieee80211_vif *vif, int sset) |
| 1415 | { |
| 1416 | if (sset == ETH_SS_STATS) |
| 1417 | return ATH9K_SSTATS_LEN; |
| 1418 | return 0; |
| 1419 | } |
| 1420 | |
| 1421 | #define AWDATA(elem) \ |
| 1422 | do { \ |
| 1423 | data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].elem; \ |
| 1424 | data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].elem; \ |
| 1425 | data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].elem; \ |
| 1426 | data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].elem; \ |
| 1427 | } while (0) |
| 1428 | |
| 1429 | #define AWDATA_RX(elem) \ |
| 1430 | do { \ |
| 1431 | data[i++] = sc->debug.stats.rxstats.elem; \ |
| 1432 | } while (0) |
| 1433 | |
| 1434 | void ath9k_get_et_stats(struct ieee80211_hw *hw, |
| 1435 | struct ieee80211_vif *vif, |
| 1436 | struct ethtool_stats *stats, u64 *data) |
| 1437 | { |
| 1438 | struct ath_softc *sc = hw->priv; |
| 1439 | int i = 0; |
| 1440 | |
| 1441 | data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_pkts_all + |
| 1442 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_pkts_all + |
| 1443 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_pkts_all + |
| 1444 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_pkts_all); |
| 1445 | data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_bytes_all + |
| 1446 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_bytes_all + |
| 1447 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_bytes_all + |
| 1448 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_bytes_all); |
| 1449 | AWDATA_RX(rx_pkts_all); |
| 1450 | AWDATA_RX(rx_bytes_all); |
| 1451 | |
| 1452 | AWDATA(tx_pkts_all); |
| 1453 | AWDATA(tx_bytes_all); |
| 1454 | AWDATA(queued); |
| 1455 | AWDATA(completed); |
| 1456 | AWDATA(xretries); |
| 1457 | AWDATA(a_aggr); |
| 1458 | AWDATA(a_queued_hw); |
| 1459 | AWDATA(a_queued_sw); |
| 1460 | AWDATA(a_completed); |
| 1461 | AWDATA(a_retries); |
| 1462 | AWDATA(a_xretries); |
| 1463 | AWDATA(fifo_underrun); |
| 1464 | AWDATA(xtxop); |
| 1465 | AWDATA(timer_exp); |
| 1466 | AWDATA(desc_cfg_err); |
| 1467 | AWDATA(data_underrun); |
| 1468 | AWDATA(delim_underrun); |
| 1469 | |
Ben Greear | 18c45b1 | 2013-03-04 15:31:17 -0800 | [diff] [blame] | 1470 | AWDATA_RX(crc_err); |
Sujith Manoharan | c175db8 | 2012-11-28 15:08:52 +0530 | [diff] [blame] | 1471 | AWDATA_RX(decrypt_crc_err); |
| 1472 | AWDATA_RX(phy_err); |
| 1473 | AWDATA_RX(mic_err); |
| 1474 | AWDATA_RX(pre_delim_crc_err); |
| 1475 | AWDATA_RX(post_delim_crc_err); |
| 1476 | AWDATA_RX(decrypt_busy_err); |
| 1477 | |
| 1478 | AWDATA_RX(phy_err_stats[ATH9K_PHYERR_RADAR]); |
| 1479 | AWDATA_RX(phy_err_stats[ATH9K_PHYERR_OFDM_TIMING]); |
| 1480 | AWDATA_RX(phy_err_stats[ATH9K_PHYERR_CCK_TIMING]); |
| 1481 | |
| 1482 | WARN_ON(i != ATH9K_SSTATS_LEN); |
| 1483 | } |
| 1484 | |
Sujith Manoharan | af69009 | 2013-05-10 18:41:06 +0530 | [diff] [blame] | 1485 | void ath9k_deinit_debug(struct ath_softc *sc) |
| 1486 | { |
Sujith Manoharan | f65c082 | 2013-12-18 09:53:18 +0530 | [diff] [blame^] | 1487 | ath9k_spectral_deinit_debug(sc); |
Sujith Manoharan | af69009 | 2013-05-10 18:41:06 +0530 | [diff] [blame] | 1488 | } |
| 1489 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1490 | int ath9k_init_debug(struct ath_hw *ah) |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1491 | { |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 1492 | struct ath_common *common = ath9k_hw_common(ah); |
| 1493 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1494 | |
Ben Greear | eb27244 | 2010-11-29 14:13:22 -0800 | [diff] [blame] | 1495 | sc->debug.debugfs_phy = debugfs_create_dir("ath9k", |
| 1496 | sc->hw->wiphy->debugfsdir); |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 1497 | if (!sc->debug.debugfs_phy) |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 1498 | return -ENOMEM; |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 1499 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 1500 | #ifdef CONFIG_ATH_DEBUG |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1501 | debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1502 | sc, &fops_debug); |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 1503 | #endif |
Zefir Kurtisi | 29942bc | 2011-12-14 20:16:34 -0800 | [diff] [blame] | 1504 | |
| 1505 | ath9k_dfs_init_debug(sc); |
Sujith Manoharan | ef6b19e | 2013-10-24 12:04:39 +0530 | [diff] [blame] | 1506 | ath9k_tx99_init_debug(sc); |
Sujith Manoharan | f65c082 | 2013-12-18 09:53:18 +0530 | [diff] [blame^] | 1507 | ath9k_spectral_init_debug(sc); |
Zefir Kurtisi | 29942bc | 2011-12-14 20:16:34 -0800 | [diff] [blame] | 1508 | |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1509 | debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1510 | &fops_dma); |
| 1511 | debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1512 | &fops_interrupt); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1513 | debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1514 | &fops_xmit); |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 1515 | debugfs_create_file("queues", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1516 | &fops_queues); |
Felix Fietkau | 7702e78 | 2012-07-15 19:53:35 +0200 | [diff] [blame] | 1517 | debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
Sujith Manoharan | bea843c | 2012-11-21 18:13:10 +0530 | [diff] [blame] | 1518 | &sc->tx.txq_max_pending[IEEE80211_AC_BK]); |
Felix Fietkau | 7702e78 | 2012-07-15 19:53:35 +0200 | [diff] [blame] | 1519 | debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
Sujith Manoharan | bea843c | 2012-11-21 18:13:10 +0530 | [diff] [blame] | 1520 | &sc->tx.txq_max_pending[IEEE80211_AC_BE]); |
Felix Fietkau | 7702e78 | 2012-07-15 19:53:35 +0200 | [diff] [blame] | 1521 | debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
Sujith Manoharan | bea843c | 2012-11-21 18:13:10 +0530 | [diff] [blame] | 1522 | &sc->tx.txq_max_pending[IEEE80211_AC_VI]); |
Felix Fietkau | 7702e78 | 2012-07-15 19:53:35 +0200 | [diff] [blame] | 1523 | debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
Sujith Manoharan | bea843c | 2012-11-21 18:13:10 +0530 | [diff] [blame] | 1524 | &sc->tx.txq_max_pending[IEEE80211_AC_VO]); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1525 | debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1526 | &fops_misc); |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 1527 | debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1528 | &fops_reset); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1529 | debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1530 | &fops_recv); |
Felix Fietkau | ca6d4a7 | 2013-08-13 12:33:27 +0200 | [diff] [blame] | 1531 | debugfs_create_u8("rx_chainmask", S_IRUSR, sc->debug.debugfs_phy, |
| 1532 | &ah->rxchainmask); |
| 1533 | debugfs_create_u8("tx_chainmask", S_IRUSR, sc->debug.debugfs_phy, |
| 1534 | &ah->txchainmask); |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 1535 | debugfs_create_file("ani", S_IRUSR | S_IWUSR, |
| 1536 | sc->debug.debugfs_phy, sc, &fops_ani); |
Felix Fietkau | 74673db | 2012-09-08 15:24:17 +0200 | [diff] [blame] | 1537 | debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1538 | &sc->sc_ah->config.enable_paprd); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1539 | debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1540 | sc, &fops_regidx); |
| 1541 | debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1542 | sc, &fops_regval); |
| 1543 | debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, |
| 1544 | sc->debug.debugfs_phy, |
| 1545 | &ah->config.cwm_ignore_extcca); |
| 1546 | debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1547 | &fops_regdump); |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1548 | debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1549 | &fops_dump_nfcal); |
Rajkumar Manoharan | 580f010 | 2011-07-29 17:38:12 +0530 | [diff] [blame] | 1550 | debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1551 | &fops_base_eeprom); |
Rajkumar Manoharan | 3f4c4bd | 2011-07-29 17:38:13 +0530 | [diff] [blame] | 1552 | debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1553 | &fops_modal_eeprom); |
Felix Fietkau | 691680b | 2011-03-19 13:55:38 +0100 | [diff] [blame] | 1554 | debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, |
| 1555 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); |
Felix Fietkau | 691680b | 2011-03-19 13:55:38 +0100 | [diff] [blame] | 1556 | debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, |
| 1557 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 1558 | debugfs_create_file("antenna_diversity", S_IRUSR, |
| 1559 | sc->debug.debugfs_phy, sc, &fops_antenna_diversity); |
Rajkumar Manoharan | 4df50ca | 2012-10-25 17:16:54 +0530 | [diff] [blame] | 1560 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT |
Sujith Manoharan | 36e8825 | 2013-08-06 12:44:15 +0530 | [diff] [blame] | 1561 | debugfs_create_file("bt_ant_diversity", S_IRUSR | S_IWUSR, |
| 1562 | sc->debug.debugfs_phy, sc, &fops_bt_ant_diversity); |
Rajkumar Manoharan | 4df50ca | 2012-10-25 17:16:54 +0530 | [diff] [blame] | 1563 | debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1564 | &fops_btcoex); |
| 1565 | #endif |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 1566 | |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 1567 | return 0; |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1568 | } |