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