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