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 | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 225 | static ssize_t read_file_dma(struct file *file, char __user *user_buf, |
| 226 | size_t count, loff_t *ppos) |
| 227 | { |
| 228 | struct ath_softc *sc = file->private_data; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 229 | struct ath_hw *ah = sc->sc_ah; |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 230 | char *buf; |
| 231 | int retval; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 232 | unsigned int len = 0; |
| 233 | u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; |
| 234 | int i, qcuOffset = 0, dcuOffset = 0; |
| 235 | u32 *qcuBase = &val[0], *dcuBase = &val[4]; |
| 236 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 237 | buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); |
| 238 | if (!buf) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 239 | return -ENOMEM; |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 240 | |
Sujith | 7cf4a2e | 2009-08-26 11:11:57 +0530 | [diff] [blame] | 241 | ath9k_ps_wakeup(sc); |
| 242 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 243 | REG_WRITE_D(ah, AR_MACMISC, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 244 | ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | |
| 245 | (AR_MACMISC_MISC_OBS_BUS_1 << |
| 246 | AR_MACMISC_MISC_OBS_BUS_MSB_S))); |
| 247 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 248 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 249 | "Raw DMA Debug values:\n"); |
| 250 | |
| 251 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { |
| 252 | if (i % 4 == 0) |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 253 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 254 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 255 | val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 256 | len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 257 | i, val[i]); |
| 258 | } |
| 259 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 260 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); |
| 261 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 262 | "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); |
| 263 | |
| 264 | for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { |
| 265 | if (i == 8) { |
| 266 | qcuOffset = 0; |
| 267 | qcuBase++; |
| 268 | } |
| 269 | |
| 270 | if (i == 6) { |
| 271 | dcuOffset = 0; |
| 272 | dcuBase++; |
| 273 | } |
| 274 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 275 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 276 | "%2d %2x %1x %2x %2x\n", |
| 277 | i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, |
| 278 | (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), |
| 279 | val[2] & (0x7 << (i * 3)) >> (i * 3), |
| 280 | (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); |
| 281 | } |
| 282 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 283 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 284 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 285 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 286 | "qcu_stitch state: %2x qcu_fetch state: %2x\n", |
| 287 | (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 288 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 289 | "qcu_complete state: %2x dcu_complete state: %2x\n", |
| 290 | (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 291 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 292 | "dcu_arb state: %2x dcu_fp state: %2x\n", |
| 293 | (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 294 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 295 | "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", |
| 296 | (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 297 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 298 | "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", |
| 299 | (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 300 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 301 | "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", |
| 302 | (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); |
| 303 | |
Frans Pop | 60ece40 | 2010-03-24 19:46:30 +0100 | [diff] [blame] | 304 | 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] | 305 | REG_READ_D(ah, AR_OBS_BUS_1)); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 306 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Frans Pop | 60ece40 | 2010-03-24 19:46:30 +0100 | [diff] [blame] | 307 | "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 308 | |
Sujith | 7cf4a2e | 2009-08-26 11:11:57 +0530 | [diff] [blame] | 309 | ath9k_ps_restore(sc); |
| 310 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 311 | if (len > DMA_BUF_LEN) |
| 312 | len = DMA_BUF_LEN; |
| 313 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 314 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 315 | kfree(buf); |
| 316 | return retval; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | static const struct file_operations fops_dma = { |
| 320 | .read = read_file_dma, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 321 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 322 | .owner = THIS_MODULE, |
| 323 | .llseek = default_llseek, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 324 | }; |
| 325 | |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 326 | |
| 327 | void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) |
| 328 | { |
| 329 | if (status) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 330 | sc->debug.stats.istats.total++; |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 331 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
| 332 | if (status & ATH9K_INT_RXLP) |
| 333 | sc->debug.stats.istats.rxlp++; |
| 334 | if (status & ATH9K_INT_RXHP) |
| 335 | sc->debug.stats.istats.rxhp++; |
Luis R. Rodriguez | 08578b8 | 2010-05-13 13:33:44 -0400 | [diff] [blame] | 336 | if (status & ATH9K_INT_BB_WATCHDOG) |
| 337 | sc->debug.stats.istats.bb_watchdog++; |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 338 | } else { |
| 339 | if (status & ATH9K_INT_RX) |
| 340 | sc->debug.stats.istats.rxok++; |
| 341 | } |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 342 | if (status & ATH9K_INT_RXEOL) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 343 | sc->debug.stats.istats.rxeol++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 344 | if (status & ATH9K_INT_RXORN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 345 | sc->debug.stats.istats.rxorn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 346 | if (status & ATH9K_INT_TX) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 347 | sc->debug.stats.istats.txok++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 348 | if (status & ATH9K_INT_TXURN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 349 | sc->debug.stats.istats.txurn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 350 | if (status & ATH9K_INT_RXPHY) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 351 | sc->debug.stats.istats.rxphyerr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 352 | if (status & ATH9K_INT_RXKCM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 353 | sc->debug.stats.istats.rx_keycache_miss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 354 | if (status & ATH9K_INT_SWBA) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 355 | sc->debug.stats.istats.swba++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 356 | if (status & ATH9K_INT_BMISS) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 357 | sc->debug.stats.istats.bmiss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 358 | if (status & ATH9K_INT_BNR) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 359 | sc->debug.stats.istats.bnr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 360 | if (status & ATH9K_INT_CST) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 361 | sc->debug.stats.istats.cst++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 362 | if (status & ATH9K_INT_GTT) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 363 | sc->debug.stats.istats.gtt++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 364 | if (status & ATH9K_INT_TIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 365 | sc->debug.stats.istats.tim++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 366 | if (status & ATH9K_INT_CABEND) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 367 | sc->debug.stats.istats.cabend++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 368 | if (status & ATH9K_INT_DTIMSYNC) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 369 | sc->debug.stats.istats.dtimsync++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 370 | if (status & ATH9K_INT_DTIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 371 | sc->debug.stats.istats.dtim++; |
Mohammed Shafi Shajakhan | 6dde1aa | 2011-04-22 17:27:01 +0530 | [diff] [blame] | 372 | if (status & ATH9K_INT_TSFOOR) |
| 373 | sc->debug.stats.istats.tsfoor++; |
Sujith Manoharan | 97ba515 | 2012-06-04 16:27:41 +0530 | [diff] [blame] | 374 | if (status & ATH9K_INT_MCI) |
| 375 | sc->debug.stats.istats.mci++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, |
| 379 | size_t count, loff_t *ppos) |
| 380 | { |
| 381 | struct ath_softc *sc = file->private_data; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 382 | unsigned int len = 0; |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 383 | int rv; |
| 384 | int mxlen = 4000; |
| 385 | char *buf = kmalloc(mxlen, GFP_KERNEL); |
| 386 | if (!buf) |
| 387 | return -ENOMEM; |
| 388 | |
| 389 | #define PR_IS(a, s) \ |
| 390 | do { \ |
| 391 | len += snprintf(buf + len, mxlen - len, \ |
| 392 | "%21s: %10u\n", a, \ |
| 393 | sc->debug.stats.istats.s); \ |
| 394 | } while (0) |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 395 | |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 396 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 397 | PR_IS("RXLP", rxlp); |
| 398 | PR_IS("RXHP", rxhp); |
| 399 | PR_IS("WATHDOG", bb_watchdog); |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 400 | } else { |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 401 | PR_IS("RX", rxok); |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 402 | } |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 403 | PR_IS("RXEOL", rxeol); |
| 404 | PR_IS("RXORN", rxorn); |
| 405 | PR_IS("TX", txok); |
| 406 | PR_IS("TXURN", txurn); |
| 407 | PR_IS("MIB", mib); |
| 408 | PR_IS("RXPHY", rxphyerr); |
| 409 | PR_IS("RXKCM", rx_keycache_miss); |
| 410 | PR_IS("SWBA", swba); |
| 411 | PR_IS("BMISS", bmiss); |
| 412 | PR_IS("BNR", bnr); |
| 413 | PR_IS("CST", cst); |
| 414 | PR_IS("GTT", gtt); |
| 415 | PR_IS("TIM", tim); |
| 416 | PR_IS("CABEND", cabend); |
| 417 | PR_IS("DTIMSYNC", dtimsync); |
| 418 | PR_IS("DTIM", dtim); |
| 419 | PR_IS("TSFOOR", tsfoor); |
Sujith Manoharan | 97ba515 | 2012-06-04 16:27:41 +0530 | [diff] [blame] | 420 | PR_IS("MCI", mci); |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 421 | PR_IS("TOTAL", total); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 422 | |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 423 | len += snprintf(buf + len, mxlen - len, |
| 424 | "SYNC_CAUSE stats:\n"); |
Mohammed Shafi Shajakhan | 6dde1aa | 2011-04-22 17:27:01 +0530 | [diff] [blame] | 425 | |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 426 | PR_IS("Sync-All", sync_cause_all); |
| 427 | PR_IS("RTC-IRQ", sync_rtc_irq); |
| 428 | PR_IS("MAC-IRQ", sync_mac_irq); |
| 429 | PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access); |
| 430 | PR_IS("APB-Timeout", apb_timeout); |
| 431 | PR_IS("PCI-Mode-Conflict", pci_mode_conflict); |
| 432 | PR_IS("HOST1-Fatal", host1_fatal); |
| 433 | PR_IS("HOST1-Perr", host1_perr); |
| 434 | PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr); |
| 435 | PR_IS("RADM-CPL-EP", radm_cpl_ep); |
| 436 | PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort); |
| 437 | PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort); |
| 438 | PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err); |
| 439 | PR_IS("RADM-CPL-Timeout", radm_cpl_timeout); |
| 440 | PR_IS("Local-Bus-Timeout", local_timeout); |
| 441 | PR_IS("PM-Access", pm_access); |
| 442 | PR_IS("MAC-Awake", mac_awake); |
| 443 | PR_IS("MAC-Asleep", mac_asleep); |
| 444 | PR_IS("MAC-Sleep-Access", mac_sleep_access); |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 445 | |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 446 | if (len > mxlen) |
| 447 | len = mxlen; |
| 448 | |
| 449 | rv = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 450 | kfree(buf); |
| 451 | return rv; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | static const struct file_operations fops_interrupt = { |
| 455 | .read = read_file_interrupt, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 456 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 457 | .owner = THIS_MODULE, |
| 458 | .llseek = default_llseek, |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 459 | }; |
| 460 | |
Felix Fietkau | 5bec3e5 | 2011-01-24 21:29:25 +0100 | [diff] [blame] | 461 | #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 462 | #define PR(str, elem) \ |
| 463 | do { \ |
| 464 | len += snprintf(buf + len, size - len, \ |
| 465 | "%s%13u%11u%10u%10u\n", str, \ |
Felix Fietkau | 5bec3e5 | 2011-01-24 21:29:25 +0100 | [diff] [blame] | 466 | sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem, \ |
| 467 | sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem, \ |
| 468 | sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem, \ |
| 469 | sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem); \ |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 470 | if (len >= size) \ |
| 471 | goto done; \ |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 472 | } while(0) |
| 473 | |
Ben Greear | 1f427dd | 2011-01-09 23:11:43 -0800 | [diff] [blame] | 474 | #define PRX(str, elem) \ |
| 475 | do { \ |
| 476 | len += snprintf(buf + len, size - len, \ |
| 477 | "%s%13u%11u%10u%10u\n", str, \ |
Felix Fietkau | 5bec3e5 | 2011-01-24 21:29:25 +0100 | [diff] [blame] | 478 | (unsigned int)(sc->tx.txq_map[WME_AC_BE]->elem), \ |
| 479 | (unsigned int)(sc->tx.txq_map[WME_AC_BK]->elem), \ |
| 480 | (unsigned int)(sc->tx.txq_map[WME_AC_VI]->elem), \ |
| 481 | (unsigned int)(sc->tx.txq_map[WME_AC_VO]->elem)); \ |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 482 | if (len >= size) \ |
| 483 | goto done; \ |
Ben Greear | 1f427dd | 2011-01-09 23:11:43 -0800 | [diff] [blame] | 484 | } while(0) |
| 485 | |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 486 | #define PRQLE(str, elem) \ |
| 487 | do { \ |
| 488 | len += snprintf(buf + len, size - len, \ |
| 489 | "%s%13i%11i%10i%10i\n", str, \ |
Felix Fietkau | 5bec3e5 | 2011-01-24 21:29:25 +0100 | [diff] [blame] | 490 | list_empty(&sc->tx.txq_map[WME_AC_BE]->elem), \ |
| 491 | list_empty(&sc->tx.txq_map[WME_AC_BK]->elem), \ |
| 492 | list_empty(&sc->tx.txq_map[WME_AC_VI]->elem), \ |
| 493 | list_empty(&sc->tx.txq_map[WME_AC_VO]->elem)); \ |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 494 | if (len >= size) \ |
| 495 | goto done; \ |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 496 | } while (0) |
| 497 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 498 | static ssize_t read_file_xmit(struct file *file, char __user *user_buf, |
| 499 | size_t count, loff_t *ppos) |
| 500 | { |
| 501 | struct ath_softc *sc = file->private_data; |
| 502 | char *buf; |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 503 | unsigned int len = 0, size = 8000; |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 504 | int i; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 505 | ssize_t retval = 0; |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 506 | char tmp[32]; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 507 | |
| 508 | buf = kzalloc(size, GFP_KERNEL); |
| 509 | if (buf == NULL) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 510 | return -ENOMEM; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 511 | |
Ben Greear | 60f2d1d | 2011-01-09 23:11:52 -0800 | [diff] [blame] | 512 | len += sprintf(buf, "Num-Tx-Queues: %i tx-queues-setup: 0x%x" |
| 513 | " poll-work-seen: %u\n" |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 514 | "%30s %10s%10s%10s\n\n", |
| 515 | ATH9K_NUM_TX_QUEUES, sc->tx.txqsetup, |
Ben Greear | 60f2d1d | 2011-01-09 23:11:52 -0800 | [diff] [blame] | 516 | sc->tx_complete_poll_work_seen, |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 517 | "BE", "BK", "VI", "VO"); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 518 | |
| 519 | PR("MPDUs Queued: ", queued); |
| 520 | PR("MPDUs Completed: ", completed); |
Felix Fietkau | 5a6f78a | 2011-05-31 21:21:41 +0200 | [diff] [blame] | 521 | PR("MPDUs XRetried: ", xretries); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 522 | PR("Aggregates: ", a_aggr); |
Ben Greear | bda8add | 2011-01-09 23:11:48 -0800 | [diff] [blame] | 523 | PR("AMPDUs Queued HW:", a_queued_hw); |
| 524 | PR("AMPDUs Queued SW:", a_queued_sw); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 525 | PR("AMPDUs Completed:", a_completed); |
| 526 | PR("AMPDUs Retried: ", a_retries); |
| 527 | PR("AMPDUs XRetried: ", a_xretries); |
| 528 | PR("FIFO Underrun: ", fifo_underrun); |
| 529 | PR("TXOP Exceeded: ", xtxop); |
| 530 | PR("TXTIMER Expiry: ", timer_exp); |
| 531 | PR("DESC CFG Error: ", desc_cfg_err); |
| 532 | PR("DATA Underrun: ", data_underrun); |
| 533 | PR("DELIM Underrun: ", delim_underrun); |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 534 | PR("TX-Pkts-All: ", tx_pkts_all); |
| 535 | PR("TX-Bytes-All: ", tx_bytes_all); |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 536 | PR("hw-put-tx-buf: ", puttxbuf); |
| 537 | PR("hw-tx-start: ", txstart); |
| 538 | PR("hw-tx-proc-desc: ", txprocdesc); |
Ben Greear | a5a0bca | 2012-04-03 09:16:55 -0700 | [diff] [blame] | 539 | PR("TX-Failed: ", txfailed); |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 540 | len += snprintf(buf + len, size - len, |
| 541 | "%s%11p%11p%10p%10p\n", "txq-memory-address:", |
Ben Greear | db7889c | 2011-03-03 16:25:59 -0800 | [diff] [blame] | 542 | sc->tx.txq_map[WME_AC_BE], |
| 543 | sc->tx.txq_map[WME_AC_BK], |
| 544 | sc->tx.txq_map[WME_AC_VI], |
| 545 | sc->tx.txq_map[WME_AC_VO]); |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 546 | if (len >= size) |
| 547 | goto done; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 548 | |
Ben Greear | 1f427dd | 2011-01-09 23:11:43 -0800 | [diff] [blame] | 549 | PRX("axq-qnum: ", axq_qnum); |
| 550 | PRX("axq-depth: ", axq_depth); |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 551 | PRX("axq-ampdu_depth: ", axq_ampdu_depth); |
Ben Greear | 1f427dd | 2011-01-09 23:11:43 -0800 | [diff] [blame] | 552 | PRX("axq-stopped ", stopped); |
| 553 | PRX("tx-in-progress ", axq_tx_inprogress); |
| 554 | PRX("pending-frames ", pending_frames); |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 555 | PRX("txq_headidx: ", txq_headidx); |
| 556 | PRX("txq_tailidx: ", txq_headidx); |
Ben Greear | 1f427dd | 2011-01-09 23:11:43 -0800 | [diff] [blame] | 557 | |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 558 | PRQLE("axq_q empty: ", axq_q); |
| 559 | PRQLE("axq_acq empty: ", axq_acq); |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 560 | for (i = 0; i < ATH_TXFIFO_DEPTH; i++) { |
| 561 | snprintf(tmp, sizeof(tmp) - 1, "txq_fifo[%i] empty: ", i); |
| 562 | PRQLE(tmp, txq_fifo[i]); |
| 563 | } |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 564 | |
Ben Greear | 71e025a | 2011-01-09 23:11:50 -0800 | [diff] [blame] | 565 | /* Print out more detailed queue-info */ |
| 566 | for (i = 0; i <= WME_AC_BK; i++) { |
| 567 | struct ath_txq *txq = &(sc->tx.txq[i]); |
| 568 | struct ath_atx_ac *ac; |
| 569 | struct ath_atx_tid *tid; |
| 570 | if (len >= size) |
| 571 | goto done; |
| 572 | spin_lock_bh(&txq->axq_lock); |
| 573 | if (!list_empty(&txq->axq_acq)) { |
| 574 | ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, |
| 575 | list); |
| 576 | len += snprintf(buf + len, size - len, |
| 577 | "txq[%i] first-ac: %p sched: %i\n", |
| 578 | i, ac, ac->sched); |
| 579 | if (list_empty(&ac->tid_q) || (len >= size)) |
| 580 | goto done_for; |
| 581 | tid = list_first_entry(&ac->tid_q, struct ath_atx_tid, |
| 582 | list); |
| 583 | len += snprintf(buf + len, size - len, |
| 584 | " first-tid: %p sched: %i paused: %i\n", |
| 585 | tid, tid->sched, tid->paused); |
| 586 | } |
| 587 | done_for: |
| 588 | spin_unlock_bh(&txq->axq_lock); |
| 589 | } |
| 590 | |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 591 | done: |
| 592 | if (len > size) |
| 593 | len = size; |
| 594 | |
| 595 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 596 | kfree(buf); |
| 597 | |
| 598 | return retval; |
| 599 | } |
| 600 | |
| 601 | static ssize_t read_file_stations(struct file *file, char __user *user_buf, |
| 602 | size_t count, loff_t *ppos) |
| 603 | { |
| 604 | struct ath_softc *sc = file->private_data; |
| 605 | char *buf; |
| 606 | unsigned int len = 0, size = 64000; |
| 607 | struct ath_node *an = NULL; |
| 608 | ssize_t retval = 0; |
| 609 | int q; |
| 610 | |
| 611 | buf = kzalloc(size, GFP_KERNEL); |
| 612 | if (buf == NULL) |
| 613 | return -ENOMEM; |
| 614 | |
| 615 | len += snprintf(buf + len, size - len, |
| 616 | "Stations:\n" |
Ben Greear | 7e1e386 | 2011-11-03 11:33:13 -0700 | [diff] [blame] | 617 | " tid: addr sched paused buf_q-empty an ac baw\n" |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 618 | " ac: addr sched tid_q-empty txq\n"); |
| 619 | |
| 620 | spin_lock(&sc->nodes_lock); |
| 621 | list_for_each_entry(an, &sc->nodes, list) { |
Ben Greear | 7e1e386 | 2011-11-03 11:33:13 -0700 | [diff] [blame] | 622 | unsigned short ma = an->maxampdu; |
| 623 | if (ma == 0) |
| 624 | ma = 65535; /* see ath_lookup_rate */ |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 625 | len += snprintf(buf + len, size - len, |
Ben Greear | 7e1e386 | 2011-11-03 11:33:13 -0700 | [diff] [blame] | 626 | "iface: %pM sta: %pM max-ampdu: %hu mpdu-density: %uus\n", |
| 627 | an->vif->addr, an->sta->addr, ma, |
| 628 | (unsigned int)(an->mpdudensity)); |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 629 | if (len >= size) |
| 630 | goto done; |
| 631 | |
| 632 | for (q = 0; q < WME_NUM_TID; q++) { |
| 633 | struct ath_atx_tid *tid = &(an->tid[q]); |
| 634 | len += snprintf(buf + len, size - len, |
Ben Greear | 7e1e386 | 2011-11-03 11:33:13 -0700 | [diff] [blame] | 635 | " tid: %p %s %s %i %p %p %hu\n", |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 636 | tid, tid->sched ? "sched" : "idle", |
| 637 | tid->paused ? "paused" : "running", |
Felix Fietkau | 56dc633 | 2011-08-28 00:32:22 +0200 | [diff] [blame] | 638 | skb_queue_empty(&tid->buf_q), |
Ben Greear | 7e1e386 | 2011-11-03 11:33:13 -0700 | [diff] [blame] | 639 | tid->an, tid->ac, tid->baw_size); |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 640 | if (len >= size) |
| 641 | goto done; |
| 642 | } |
| 643 | |
| 644 | for (q = 0; q < WME_NUM_AC; q++) { |
| 645 | struct ath_atx_ac *ac = &(an->ac[q]); |
| 646 | len += snprintf(buf + len, size - len, |
| 647 | " ac: %p %s %i %p\n", |
| 648 | ac, ac->sched ? "sched" : "idle", |
| 649 | list_empty(&ac->tid_q), ac->txq); |
| 650 | if (len >= size) |
| 651 | goto done; |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | done: |
| 656 | spin_unlock(&sc->nodes_lock); |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 657 | if (len > size) |
| 658 | len = size; |
| 659 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 660 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 661 | kfree(buf); |
| 662 | |
| 663 | return retval; |
| 664 | } |
| 665 | |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 666 | static ssize_t read_file_misc(struct file *file, char __user *user_buf, |
| 667 | size_t count, loff_t *ppos) |
| 668 | { |
| 669 | struct ath_softc *sc = file->private_data; |
| 670 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 671 | struct ieee80211_hw *hw = sc->hw; |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 672 | struct ath9k_vif_iter_data iter_data; |
| 673 | char buf[512]; |
| 674 | unsigned int len = 0; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 675 | ssize_t retval = 0; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 676 | unsigned int reg; |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 677 | u32 rxfilter; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 678 | |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 679 | len += snprintf(buf + len, sizeof(buf) - len, |
| 680 | "BSSID: %pM\n", common->curbssid); |
| 681 | len += snprintf(buf + len, sizeof(buf) - len, |
| 682 | "BSSID-MASK: %pM\n", common->bssidmask); |
| 683 | len += snprintf(buf + len, sizeof(buf) - len, |
| 684 | "OPMODE: %s\n", ath_opmode_to_string(sc->sc_ah->opmode)); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 685 | |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 686 | ath9k_ps_wakeup(sc); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 687 | rxfilter = ath9k_hw_getrxfilter(sc->sc_ah); |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 688 | ath9k_ps_restore(sc); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 689 | |
| 690 | len += snprintf(buf + len, sizeof(buf) - len, |
| 691 | "RXFILTER: 0x%x", rxfilter); |
| 692 | |
| 693 | if (rxfilter & ATH9K_RX_FILTER_UCAST) |
| 694 | len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); |
| 695 | if (rxfilter & ATH9K_RX_FILTER_MCAST) |
| 696 | len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); |
| 697 | if (rxfilter & ATH9K_RX_FILTER_BCAST) |
| 698 | len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); |
| 699 | if (rxfilter & ATH9K_RX_FILTER_CONTROL) |
| 700 | len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); |
| 701 | if (rxfilter & ATH9K_RX_FILTER_BEACON) |
| 702 | len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); |
| 703 | if (rxfilter & ATH9K_RX_FILTER_PROM) |
| 704 | len += snprintf(buf + len, sizeof(buf) - len, " PROM"); |
| 705 | if (rxfilter & ATH9K_RX_FILTER_PROBEREQ) |
| 706 | len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); |
| 707 | if (rxfilter & ATH9K_RX_FILTER_PHYERR) |
| 708 | len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); |
| 709 | if (rxfilter & ATH9K_RX_FILTER_MYBEACON) |
| 710 | len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); |
| 711 | if (rxfilter & ATH9K_RX_FILTER_COMP_BAR) |
| 712 | len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); |
| 713 | if (rxfilter & ATH9K_RX_FILTER_PSPOLL) |
| 714 | len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); |
| 715 | if (rxfilter & ATH9K_RX_FILTER_PHYRADAR) |
| 716 | len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); |
| 717 | if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL) |
| 718 | len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); |
| 719 | if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER) |
| 720 | len += snprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER"); |
| 721 | |
| 722 | len += snprintf(buf + len, sizeof(buf) - len, "\n"); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 723 | |
| 724 | reg = sc->sc_ah->imask; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 725 | |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 726 | len += snprintf(buf + len, sizeof(buf) - len, "INTERRUPT-MASK: 0x%x", reg); |
| 727 | |
| 728 | if (reg & ATH9K_INT_SWBA) |
| 729 | len += snprintf(buf + len, sizeof(buf) - len, " SWBA"); |
| 730 | if (reg & ATH9K_INT_BMISS) |
| 731 | len += snprintf(buf + len, sizeof(buf) - len, " BMISS"); |
| 732 | if (reg & ATH9K_INT_CST) |
| 733 | len += snprintf(buf + len, sizeof(buf) - len, " CST"); |
| 734 | if (reg & ATH9K_INT_RX) |
| 735 | len += snprintf(buf + len, sizeof(buf) - len, " RX"); |
| 736 | if (reg & ATH9K_INT_RXHP) |
| 737 | len += snprintf(buf + len, sizeof(buf) - len, " RXHP"); |
| 738 | if (reg & ATH9K_INT_RXLP) |
| 739 | len += snprintf(buf + len, sizeof(buf) - len, " RXLP"); |
| 740 | if (reg & ATH9K_INT_BB_WATCHDOG) |
| 741 | len += snprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG"); |
| 742 | |
| 743 | len += snprintf(buf + len, sizeof(buf) - len, "\n"); |
| 744 | |
| 745 | ath9k_calculate_iter_data(hw, NULL, &iter_data); |
| 746 | |
| 747 | len += snprintf(buf + len, sizeof(buf) - len, |
| 748 | "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i" |
Sujith Manoharan | bcf6f96 | 2012-03-14 14:40:38 +0530 | [diff] [blame] | 749 | " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n", |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 750 | iter_data.naps, iter_data.nstations, iter_data.nmeshes, |
Sujith Manoharan | bcf6f96 | 2012-03-14 14:40:38 +0530 | [diff] [blame] | 751 | iter_data.nwds, iter_data.nadhocs, |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 752 | sc->nvifs, sc->nbcnvifs); |
| 753 | |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 754 | if (len > sizeof(buf)) |
| 755 | len = sizeof(buf); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 756 | |
| 757 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 758 | return retval; |
| 759 | } |
| 760 | |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 761 | static ssize_t read_file_reset(struct file *file, char __user *user_buf, |
| 762 | size_t count, loff_t *ppos) |
| 763 | { |
| 764 | struct ath_softc *sc = file->private_data; |
| 765 | char buf[512]; |
| 766 | unsigned int len = 0; |
| 767 | |
| 768 | len += snprintf(buf + len, sizeof(buf) - len, |
| 769 | "%17s: %2d\n", "Baseband Hang", |
| 770 | sc->debug.stats.reset[RESET_TYPE_BB_HANG]); |
| 771 | len += snprintf(buf + len, sizeof(buf) - len, |
| 772 | "%17s: %2d\n", "Baseband Watchdog", |
| 773 | sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]); |
| 774 | len += snprintf(buf + len, sizeof(buf) - len, |
| 775 | "%17s: %2d\n", "Fatal HW Error", |
| 776 | sc->debug.stats.reset[RESET_TYPE_FATAL_INT]); |
| 777 | len += snprintf(buf + len, sizeof(buf) - len, |
| 778 | "%17s: %2d\n", "TX HW error", |
| 779 | sc->debug.stats.reset[RESET_TYPE_TX_ERROR]); |
| 780 | len += snprintf(buf + len, sizeof(buf) - len, |
| 781 | "%17s: %2d\n", "TX Path Hang", |
| 782 | sc->debug.stats.reset[RESET_TYPE_TX_HANG]); |
| 783 | len += snprintf(buf + len, sizeof(buf) - len, |
| 784 | "%17s: %2d\n", "PLL RX Hang", |
| 785 | sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); |
| 786 | |
| 787 | if (len > sizeof(buf)) |
| 788 | len = sizeof(buf); |
| 789 | |
| 790 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 791 | } |
| 792 | |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 793 | 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] | 794 | struct ath_tx_status *ts, struct ath_txq *txq, |
| 795 | unsigned int flags) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 796 | { |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 797 | #define TX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].ts\ |
| 798 | [sc->debug.tsidx].c) |
Felix Fietkau | 5bec3e5 | 2011-01-24 21:29:25 +0100 | [diff] [blame] | 799 | int qnum = txq->axq_qnum; |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 800 | |
| 801 | TX_STAT_INC(qnum, tx_pkts_all); |
| 802 | sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 803 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 804 | if (bf_isampdu(bf)) { |
Felix Fietkau | 156369f | 2011-12-14 22:08:04 +0100 | [diff] [blame] | 805 | if (flags & ATH_TX_ERROR) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 806 | TX_STAT_INC(qnum, a_xretries); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 807 | else |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 808 | TX_STAT_INC(qnum, a_completed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 809 | } else { |
Felix Fietkau | 55797b1 | 2011-09-14 21:24:16 +0200 | [diff] [blame] | 810 | if (ts->ts_status & ATH9K_TXERR_XRETRY) |
Felix Fietkau | 5a6f78a | 2011-05-31 21:21:41 +0200 | [diff] [blame] | 811 | TX_STAT_INC(qnum, xretries); |
| 812 | else |
| 813 | TX_STAT_INC(qnum, completed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 814 | } |
| 815 | |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 816 | if (ts->ts_status & ATH9K_TXERR_FIFO) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 817 | TX_STAT_INC(qnum, fifo_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 818 | if (ts->ts_status & ATH9K_TXERR_XTXOP) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 819 | TX_STAT_INC(qnum, xtxop); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 820 | if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 821 | TX_STAT_INC(qnum, timer_exp); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 822 | if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 823 | TX_STAT_INC(qnum, desc_cfg_err); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 824 | if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 825 | TX_STAT_INC(qnum, data_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 826 | if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 827 | TX_STAT_INC(qnum, delim_underrun); |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 828 | |
Felix Fietkau | 5baec74 | 2012-03-03 15:17:03 +0100 | [diff] [blame] | 829 | #ifdef CONFIG_ATH9K_MAC_DEBUG |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 830 | spin_lock(&sc->debug.samp_lock); |
| 831 | TX_SAMP_DBG(jiffies) = jiffies; |
| 832 | TX_SAMP_DBG(rssi_ctl0) = ts->ts_rssi_ctl0; |
| 833 | TX_SAMP_DBG(rssi_ctl1) = ts->ts_rssi_ctl1; |
| 834 | TX_SAMP_DBG(rssi_ctl2) = ts->ts_rssi_ctl2; |
| 835 | TX_SAMP_DBG(rssi_ext0) = ts->ts_rssi_ext0; |
| 836 | TX_SAMP_DBG(rssi_ext1) = ts->ts_rssi_ext1; |
| 837 | TX_SAMP_DBG(rssi_ext2) = ts->ts_rssi_ext2; |
| 838 | TX_SAMP_DBG(rateindex) = ts->ts_rateindex; |
| 839 | TX_SAMP_DBG(isok) = !!(ts->ts_status & ATH9K_TXERR_MASK); |
| 840 | TX_SAMP_DBG(rts_fail_cnt) = ts->ts_shortretry; |
| 841 | TX_SAMP_DBG(data_fail_cnt) = ts->ts_longretry; |
| 842 | TX_SAMP_DBG(rssi) = ts->ts_rssi; |
| 843 | TX_SAMP_DBG(tid) = ts->tid; |
| 844 | TX_SAMP_DBG(qid) = ts->qid; |
Mohammed Shafi Shajakhan | 12932180 | 2011-09-21 14:22:49 +0530 | [diff] [blame] | 845 | |
| 846 | if (ts->ts_flags & ATH9K_TX_BA) { |
| 847 | TX_SAMP_DBG(ba_low) = ts->ba_low; |
| 848 | TX_SAMP_DBG(ba_high) = ts->ba_high; |
| 849 | } else { |
| 850 | TX_SAMP_DBG(ba_low) = 0; |
| 851 | TX_SAMP_DBG(ba_high) = 0; |
| 852 | } |
| 853 | |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 854 | sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES; |
| 855 | spin_unlock(&sc->debug.samp_lock); |
Felix Fietkau | 5baec74 | 2012-03-03 15:17:03 +0100 | [diff] [blame] | 856 | #endif |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 857 | |
| 858 | #undef TX_SAMP_DBG |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 859 | } |
| 860 | |
| 861 | static const struct file_operations fops_xmit = { |
| 862 | .read = read_file_xmit, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 863 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 864 | .owner = THIS_MODULE, |
| 865 | .llseek = default_llseek, |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 866 | }; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 867 | |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 868 | static const struct file_operations fops_stations = { |
| 869 | .read = read_file_stations, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 870 | .open = simple_open, |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 871 | .owner = THIS_MODULE, |
| 872 | .llseek = default_llseek, |
| 873 | }; |
| 874 | |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 875 | static const struct file_operations fops_misc = { |
| 876 | .read = read_file_misc, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 877 | .open = simple_open, |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 878 | .owner = THIS_MODULE, |
| 879 | .llseek = default_llseek, |
| 880 | }; |
| 881 | |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 882 | static const struct file_operations fops_reset = { |
| 883 | .read = read_file_reset, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 884 | .open = simple_open, |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 885 | .owner = THIS_MODULE, |
| 886 | .llseek = default_llseek, |
| 887 | }; |
| 888 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 889 | static ssize_t read_file_recv(struct file *file, char __user *user_buf, |
| 890 | size_t count, loff_t *ppos) |
| 891 | { |
| 892 | #define PHY_ERR(s, p) \ |
Sujith Manoharan | 4203214 | 2012-02-16 11:51:23 +0530 | [diff] [blame] | 893 | len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \ |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 894 | sc->debug.stats.rxstats.phy_err_stats[p]); |
| 895 | |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 896 | #define RXS_ERR(s, e) \ |
| 897 | do { \ |
| 898 | len += snprintf(buf + len, size - len, \ |
| 899 | "%22s : %10u\n", s, \ |
| 900 | sc->debug.stats.rxstats.e); \ |
| 901 | } while (0) |
| 902 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 903 | struct ath_softc *sc = file->private_data; |
| 904 | char *buf; |
Sujith Manoharan | 4203214 | 2012-02-16 11:51:23 +0530 | [diff] [blame] | 905 | unsigned int len = 0, size = 1600; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 906 | ssize_t retval = 0; |
| 907 | |
| 908 | buf = kzalloc(size, GFP_KERNEL); |
| 909 | if (buf == NULL) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 910 | return -ENOMEM; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 911 | |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 912 | RXS_ERR("CRC ERR", crc_err); |
| 913 | RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err); |
| 914 | RXS_ERR("PHY ERR", phy_err); |
| 915 | RXS_ERR("MIC ERR", mic_err); |
| 916 | RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err); |
| 917 | RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err); |
| 918 | RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err); |
| 919 | RXS_ERR("RX-LENGTH-ERR", rx_len_err); |
| 920 | RXS_ERR("RX-OOM-ERR", rx_oom_err); |
| 921 | RXS_ERR("RX-RATE-ERR", rx_rate_err); |
| 922 | RXS_ERR("RX-DROP-RXFLUSH", rx_drop_rxflush); |
| 923 | RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err); |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 924 | |
Sujith Manoharan | 4203214 | 2012-02-16 11:51:23 +0530 | [diff] [blame] | 925 | PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN); |
| 926 | PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING); |
| 927 | PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY); |
| 928 | PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE); |
| 929 | PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH); |
| 930 | PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR); |
| 931 | PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE); |
| 932 | PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR); |
| 933 | PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING); |
| 934 | PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); |
| 935 | PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); |
| 936 | PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); |
| 937 | PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP); |
| 938 | PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE); |
| 939 | PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART); |
| 940 | PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT); |
| 941 | PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING); |
| 942 | PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC); |
| 943 | PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL); |
| 944 | PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE); |
| 945 | PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART); |
| 946 | PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); |
| 947 | PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP); |
| 948 | PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR); |
| 949 | PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); |
| 950 | PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL); |
| 951 | |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 952 | RXS_ERR("RX-Pkts-All", rx_pkts_all); |
| 953 | RXS_ERR("RX-Bytes-All", rx_bytes_all); |
| 954 | RXS_ERR("RX-Beacons", rx_beacons); |
| 955 | RXS_ERR("RX-Frags", rx_frags); |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 956 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 957 | if (len > size) |
| 958 | len = size; |
| 959 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 960 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 961 | kfree(buf); |
| 962 | |
| 963 | return retval; |
| 964 | |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 965 | #undef RXS_ERR |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 966 | #undef PHY_ERR |
| 967 | } |
| 968 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 969 | 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] | 970 | { |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 971 | #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] | 972 | #define RX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].rs\ |
| 973 | [sc->debug.rsidx].c) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 974 | |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 975 | RX_STAT_INC(rx_pkts_all); |
| 976 | sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; |
| 977 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 978 | if (rs->rs_status & ATH9K_RXERR_CRC) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 979 | RX_STAT_INC(crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 980 | if (rs->rs_status & ATH9K_RXERR_DECRYPT) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 981 | RX_STAT_INC(decrypt_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 982 | if (rs->rs_status & ATH9K_RXERR_MIC) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 983 | RX_STAT_INC(mic_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 984 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 985 | RX_STAT_INC(pre_delim_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 986 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 987 | RX_STAT_INC(post_delim_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 988 | if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 989 | RX_STAT_INC(decrypt_busy_err); |
| 990 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 991 | if (rs->rs_status & ATH9K_RXERR_PHY) { |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 992 | RX_STAT_INC(phy_err); |
Sujith Manoharan | dbb07f0 | 2012-02-16 11:52:25 +0530 | [diff] [blame] | 993 | if (rs->rs_phyerr < ATH9K_PHYERR_MAX) |
| 994 | RX_PHY_ERR_INC(rs->rs_phyerr); |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 995 | } |
| 996 | |
Felix Fietkau | 5baec74 | 2012-03-03 15:17:03 +0100 | [diff] [blame] | 997 | #ifdef CONFIG_ATH9K_MAC_DEBUG |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 998 | spin_lock(&sc->debug.samp_lock); |
| 999 | RX_SAMP_DBG(jiffies) = jiffies; |
| 1000 | RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0; |
| 1001 | RX_SAMP_DBG(rssi_ctl1) = rs->rs_rssi_ctl1; |
| 1002 | RX_SAMP_DBG(rssi_ctl2) = rs->rs_rssi_ctl2; |
| 1003 | RX_SAMP_DBG(rssi_ext0) = rs->rs_rssi_ext0; |
| 1004 | RX_SAMP_DBG(rssi_ext1) = rs->rs_rssi_ext1; |
| 1005 | RX_SAMP_DBG(rssi_ext2) = rs->rs_rssi_ext2; |
| 1006 | RX_SAMP_DBG(antenna) = rs->rs_antenna; |
| 1007 | RX_SAMP_DBG(rssi) = rs->rs_rssi; |
| 1008 | RX_SAMP_DBG(rate) = rs->rs_rate; |
| 1009 | RX_SAMP_DBG(is_mybeacon) = rs->is_mybeacon; |
| 1010 | |
| 1011 | sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES; |
| 1012 | spin_unlock(&sc->debug.samp_lock); |
| 1013 | |
Felix Fietkau | 5baec74 | 2012-03-03 15:17:03 +0100 | [diff] [blame] | 1014 | #endif |
| 1015 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1016 | #undef RX_PHY_ERR_INC |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 1017 | #undef RX_SAMP_DBG |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1018 | } |
| 1019 | |
| 1020 | static const struct file_operations fops_recv = { |
| 1021 | .read = read_file_recv, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1022 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1023 | .owner = THIS_MODULE, |
| 1024 | .llseek = default_llseek, |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1025 | }; |
| 1026 | |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1027 | static ssize_t read_file_regidx(struct file *file, char __user *user_buf, |
| 1028 | size_t count, loff_t *ppos) |
| 1029 | { |
| 1030 | struct ath_softc *sc = file->private_data; |
| 1031 | char buf[32]; |
| 1032 | unsigned int len; |
| 1033 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 1034 | len = sprintf(buf, "0x%08x\n", sc->debug.regidx); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1035 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1036 | } |
| 1037 | |
| 1038 | static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, |
| 1039 | size_t count, loff_t *ppos) |
| 1040 | { |
| 1041 | struct ath_softc *sc = file->private_data; |
| 1042 | unsigned long regidx; |
| 1043 | char buf[32]; |
| 1044 | ssize_t len; |
| 1045 | |
| 1046 | len = min(count, sizeof(buf) - 1); |
| 1047 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 1048 | return -EFAULT; |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1049 | |
| 1050 | buf[len] = '\0'; |
| 1051 | if (strict_strtoul(buf, 0, ®idx)) |
| 1052 | return -EINVAL; |
| 1053 | |
| 1054 | sc->debug.regidx = regidx; |
| 1055 | return count; |
| 1056 | } |
| 1057 | |
| 1058 | static const struct file_operations fops_regidx = { |
| 1059 | .read = read_file_regidx, |
| 1060 | .write = write_file_regidx, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1061 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1062 | .owner = THIS_MODULE, |
| 1063 | .llseek = default_llseek, |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1064 | }; |
| 1065 | |
| 1066 | static ssize_t read_file_regval(struct file *file, char __user *user_buf, |
| 1067 | size_t count, loff_t *ppos) |
| 1068 | { |
| 1069 | struct ath_softc *sc = file->private_data; |
| 1070 | struct ath_hw *ah = sc->sc_ah; |
| 1071 | char buf[32]; |
| 1072 | unsigned int len; |
| 1073 | u32 regval; |
| 1074 | |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1075 | ath9k_ps_wakeup(sc); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1076 | regval = REG_READ_D(ah, sc->debug.regidx); |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1077 | ath9k_ps_restore(sc); |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 1078 | len = sprintf(buf, "0x%08x\n", regval); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1079 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1080 | } |
| 1081 | |
| 1082 | static ssize_t write_file_regval(struct file *file, const char __user *user_buf, |
| 1083 | size_t count, loff_t *ppos) |
| 1084 | { |
| 1085 | struct ath_softc *sc = file->private_data; |
| 1086 | struct ath_hw *ah = sc->sc_ah; |
| 1087 | unsigned long regval; |
| 1088 | char buf[32]; |
| 1089 | ssize_t len; |
| 1090 | |
| 1091 | len = min(count, sizeof(buf) - 1); |
| 1092 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 1093 | return -EFAULT; |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1094 | |
| 1095 | buf[len] = '\0'; |
| 1096 | if (strict_strtoul(buf, 0, ®val)) |
| 1097 | return -EINVAL; |
| 1098 | |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1099 | ath9k_ps_wakeup(sc); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1100 | REG_WRITE_D(ah, sc->debug.regidx, regval); |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1101 | ath9k_ps_restore(sc); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1102 | return count; |
| 1103 | } |
| 1104 | |
| 1105 | static const struct file_operations fops_regval = { |
| 1106 | .read = read_file_regval, |
| 1107 | .write = write_file_regval, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1108 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1109 | .owner = THIS_MODULE, |
| 1110 | .llseek = default_llseek, |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1111 | }; |
| 1112 | |
Vasanthakumar Thiagarajan | 582d006 | 2011-03-01 05:30:55 -0800 | [diff] [blame] | 1113 | #define REGDUMP_LINE_SIZE 20 |
| 1114 | |
| 1115 | static int open_file_regdump(struct inode *inode, struct file *file) |
| 1116 | { |
| 1117 | struct ath_softc *sc = inode->i_private; |
| 1118 | unsigned int len = 0; |
| 1119 | u8 *buf; |
| 1120 | int i; |
| 1121 | unsigned long num_regs, regdump_len, max_reg_offset; |
| 1122 | |
| 1123 | max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500; |
| 1124 | num_regs = max_reg_offset / 4 + 1; |
| 1125 | regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; |
| 1126 | buf = vmalloc(regdump_len); |
| 1127 | if (!buf) |
| 1128 | return -ENOMEM; |
| 1129 | |
| 1130 | ath9k_ps_wakeup(sc); |
| 1131 | for (i = 0; i < num_regs; i++) |
| 1132 | len += scnprintf(buf + len, regdump_len - len, |
| 1133 | "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); |
| 1134 | ath9k_ps_restore(sc); |
| 1135 | |
| 1136 | file->private_data = buf; |
| 1137 | |
| 1138 | return 0; |
| 1139 | } |
| 1140 | |
| 1141 | static const struct file_operations fops_regdump = { |
| 1142 | .open = open_file_regdump, |
| 1143 | .read = ath9k_debugfs_read_buf, |
| 1144 | .release = ath9k_debugfs_release_buf, |
| 1145 | .owner = THIS_MODULE, |
| 1146 | .llseek = default_llseek,/* read accesses f_pos */ |
| 1147 | }; |
| 1148 | |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1149 | static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf, |
| 1150 | size_t count, loff_t *ppos) |
| 1151 | { |
| 1152 | struct ath_softc *sc = file->private_data; |
| 1153 | struct ath_hw *ah = sc->sc_ah; |
| 1154 | struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist; |
| 1155 | struct ath_common *common = ath9k_hw_common(ah); |
| 1156 | struct ieee80211_conf *conf = &common->hw->conf; |
| 1157 | u32 len = 0, size = 1500; |
| 1158 | u32 i, j; |
| 1159 | ssize_t retval = 0; |
| 1160 | char *buf; |
| 1161 | u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; |
| 1162 | u8 nread; |
| 1163 | |
| 1164 | buf = kzalloc(size, GFP_KERNEL); |
| 1165 | if (!buf) |
| 1166 | return -ENOMEM; |
| 1167 | |
| 1168 | len += snprintf(buf + len, size - len, |
| 1169 | "Channel Noise Floor : %d\n", ah->noise); |
| 1170 | len += snprintf(buf + len, size - len, |
| 1171 | "Chain | privNF | # Readings | NF Readings\n"); |
| 1172 | for (i = 0; i < NUM_NF_READINGS; i++) { |
| 1173 | if (!(chainmask & (1 << i)) || |
| 1174 | ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) |
| 1175 | continue; |
| 1176 | |
| 1177 | nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; |
| 1178 | len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t", |
| 1179 | i, h[i].privNF, nread); |
| 1180 | for (j = 0; j < nread; j++) |
| 1181 | len += snprintf(buf + len, size - len, |
| 1182 | " %d", h[i].nfCalBuffer[j]); |
| 1183 | len += snprintf(buf + len, size - len, "\n"); |
| 1184 | } |
| 1185 | |
| 1186 | if (len > size) |
| 1187 | len = size; |
| 1188 | |
| 1189 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1190 | kfree(buf); |
| 1191 | |
| 1192 | return retval; |
| 1193 | } |
| 1194 | |
| 1195 | static const struct file_operations fops_dump_nfcal = { |
| 1196 | .read = read_file_dump_nfcal, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1197 | .open = simple_open, |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1198 | .owner = THIS_MODULE, |
| 1199 | .llseek = default_llseek, |
| 1200 | }; |
| 1201 | |
Rajkumar Manoharan | 580f010 | 2011-07-29 17:38:12 +0530 | [diff] [blame] | 1202 | static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf, |
| 1203 | size_t count, loff_t *ppos) |
| 1204 | { |
| 1205 | struct ath_softc *sc = file->private_data; |
| 1206 | struct ath_hw *ah = sc->sc_ah; |
| 1207 | u32 len = 0, size = 1500; |
| 1208 | ssize_t retval = 0; |
| 1209 | char *buf; |
| 1210 | |
| 1211 | buf = kzalloc(size, GFP_KERNEL); |
| 1212 | if (!buf) |
| 1213 | return -ENOMEM; |
| 1214 | |
| 1215 | len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size); |
| 1216 | |
| 1217 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1218 | kfree(buf); |
| 1219 | |
| 1220 | return retval; |
| 1221 | } |
| 1222 | |
| 1223 | static const struct file_operations fops_base_eeprom = { |
| 1224 | .read = read_file_base_eeprom, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1225 | .open = simple_open, |
Rajkumar Manoharan | 580f010 | 2011-07-29 17:38:12 +0530 | [diff] [blame] | 1226 | .owner = THIS_MODULE, |
| 1227 | .llseek = default_llseek, |
| 1228 | }; |
| 1229 | |
Rajkumar Manoharan | 3f4c4bd | 2011-07-29 17:38:13 +0530 | [diff] [blame] | 1230 | static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf, |
| 1231 | size_t count, loff_t *ppos) |
| 1232 | { |
| 1233 | struct ath_softc *sc = file->private_data; |
| 1234 | struct ath_hw *ah = sc->sc_ah; |
| 1235 | u32 len = 0, size = 6000; |
| 1236 | char *buf; |
| 1237 | size_t retval; |
| 1238 | |
| 1239 | buf = kzalloc(size, GFP_KERNEL); |
| 1240 | if (buf == NULL) |
| 1241 | return -ENOMEM; |
| 1242 | |
| 1243 | len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size); |
| 1244 | |
| 1245 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1246 | kfree(buf); |
| 1247 | |
| 1248 | return retval; |
| 1249 | } |
| 1250 | |
| 1251 | static const struct file_operations fops_modal_eeprom = { |
| 1252 | .read = read_file_modal_eeprom, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1253 | .open = simple_open, |
Rajkumar Manoharan | 3f4c4bd | 2011-07-29 17:38:13 +0530 | [diff] [blame] | 1254 | .owner = THIS_MODULE, |
| 1255 | .llseek = default_llseek, |
| 1256 | }; |
| 1257 | |
Felix Fietkau | 5baec74 | 2012-03-03 15:17:03 +0100 | [diff] [blame] | 1258 | #ifdef CONFIG_ATH9K_MAC_DEBUG |
| 1259 | |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 1260 | void ath9k_debug_samp_bb_mac(struct ath_softc *sc) |
| 1261 | { |
| 1262 | #define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c) |
| 1263 | struct ath_hw *ah = sc->sc_ah; |
| 1264 | struct ath_common *common = ath9k_hw_common(ah); |
| 1265 | unsigned long flags; |
| 1266 | int i; |
| 1267 | |
| 1268 | ath9k_ps_wakeup(sc); |
| 1269 | |
Rajkumar Manoharan | 6bc05a9 | 2011-09-06 21:00:07 +0530 | [diff] [blame] | 1270 | spin_lock_bh(&sc->debug.samp_lock); |
| 1271 | |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 1272 | spin_lock_irqsave(&common->cc_lock, flags); |
| 1273 | ath_hw_cycle_counters_update(common); |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 1274 | |
| 1275 | ATH_SAMP_DBG(cc.cycles) = common->cc_ani.cycles; |
| 1276 | ATH_SAMP_DBG(cc.rx_busy) = common->cc_ani.rx_busy; |
| 1277 | ATH_SAMP_DBG(cc.rx_frame) = common->cc_ani.rx_frame; |
| 1278 | ATH_SAMP_DBG(cc.tx_frame) = common->cc_ani.tx_frame; |
Rajkumar Manoharan | 6bc05a9 | 2011-09-06 21:00:07 +0530 | [diff] [blame] | 1279 | spin_unlock_irqrestore(&common->cc_lock, flags); |
| 1280 | |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 1281 | ATH_SAMP_DBG(noise) = ah->noise; |
| 1282 | |
| 1283 | REG_WRITE_D(ah, AR_MACMISC, |
| 1284 | ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | |
| 1285 | (AR_MACMISC_MISC_OBS_BUS_1 << |
| 1286 | AR_MACMISC_MISC_OBS_BUS_MSB_S))); |
| 1287 | |
| 1288 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) |
| 1289 | ATH_SAMP_DBG(dma_dbg_reg_vals[i]) = REG_READ_D(ah, |
| 1290 | AR_DMADBG_0 + (i * sizeof(u32))); |
| 1291 | |
| 1292 | ATH_SAMP_DBG(pcu_obs) = REG_READ_D(ah, AR_OBS_BUS_1); |
| 1293 | ATH_SAMP_DBG(pcu_cr) = REG_READ_D(ah, AR_CR); |
| 1294 | |
| 1295 | memcpy(ATH_SAMP_DBG(nfCalHist), sc->caldata.nfCalHist, |
| 1296 | sizeof(ATH_SAMP_DBG(nfCalHist))); |
| 1297 | |
| 1298 | sc->debug.sampidx = (sc->debug.sampidx + 1) % ATH_DBG_MAX_SAMPLES; |
| 1299 | spin_unlock_bh(&sc->debug.samp_lock); |
| 1300 | ath9k_ps_restore(sc); |
| 1301 | |
| 1302 | #undef ATH_SAMP_DBG |
| 1303 | } |
| 1304 | |
| 1305 | static int open_file_bb_mac_samps(struct inode *inode, struct file *file) |
| 1306 | { |
| 1307 | #define ATH_SAMP_DBG(c) bb_mac_samp[sampidx].c |
| 1308 | struct ath_softc *sc = inode->i_private; |
| 1309 | struct ath_hw *ah = sc->sc_ah; |
| 1310 | struct ath_common *common = ath9k_hw_common(ah); |
| 1311 | struct ieee80211_conf *conf = &common->hw->conf; |
| 1312 | struct ath_dbg_bb_mac_samp *bb_mac_samp; |
| 1313 | struct ath9k_nfcal_hist *h; |
| 1314 | int i, j, qcuOffset = 0, dcuOffset = 0; |
| 1315 | u32 *qcuBase, *dcuBase, size = 30000, len = 0; |
| 1316 | u32 sampidx = 0; |
| 1317 | u8 *buf; |
| 1318 | u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; |
| 1319 | u8 nread; |
| 1320 | |
Sujith Manoharan | 781b14a | 2012-06-04 20:23:55 +0530 | [diff] [blame] | 1321 | if (test_bit(SC_OP_INVALID, &sc->sc_flags)) |
Rajkumar Manoharan | f7e014d | 2011-09-06 21:00:06 +0530 | [diff] [blame] | 1322 | return -EAGAIN; |
| 1323 | |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 1324 | buf = vmalloc(size); |
| 1325 | if (!buf) |
| 1326 | return -ENOMEM; |
| 1327 | bb_mac_samp = vmalloc(sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES); |
| 1328 | if (!bb_mac_samp) { |
| 1329 | vfree(buf); |
| 1330 | return -ENOMEM; |
| 1331 | } |
Rajkumar Manoharan | f7e014d | 2011-09-06 21:00:06 +0530 | [diff] [blame] | 1332 | /* Account the current state too */ |
| 1333 | ath9k_debug_samp_bb_mac(sc); |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 1334 | |
| 1335 | spin_lock_bh(&sc->debug.samp_lock); |
| 1336 | memcpy(bb_mac_samp, sc->debug.bb_mac_samp, |
| 1337 | sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES); |
Rajkumar Manoharan | 6bc05a9 | 2011-09-06 21:00:07 +0530 | [diff] [blame] | 1338 | len += snprintf(buf + len, size - len, |
| 1339 | "Current Sample Index: %d\n", sc->debug.sampidx); |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 1340 | spin_unlock_bh(&sc->debug.samp_lock); |
| 1341 | |
| 1342 | len += snprintf(buf + len, size - len, |
| 1343 | "Raw DMA Debug Dump:\n"); |
| 1344 | len += snprintf(buf + len, size - len, "Sample |\t"); |
| 1345 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) |
| 1346 | len += snprintf(buf + len, size - len, " DMA Reg%d |\t", i); |
| 1347 | len += snprintf(buf + len, size - len, "\n"); |
| 1348 | |
| 1349 | for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { |
| 1350 | len += snprintf(buf + len, size - len, "%d\t", sampidx); |
| 1351 | |
| 1352 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) |
| 1353 | len += snprintf(buf + len, size - len, " %08x\t", |
| 1354 | ATH_SAMP_DBG(dma_dbg_reg_vals[i])); |
| 1355 | len += snprintf(buf + len, size - len, "\n"); |
| 1356 | } |
| 1357 | len += snprintf(buf + len, size - len, "\n"); |
| 1358 | |
| 1359 | len += snprintf(buf + len, size - len, |
| 1360 | "Sample Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); |
| 1361 | for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { |
| 1362 | qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]); |
| 1363 | dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]); |
| 1364 | |
| 1365 | for (i = 0; i < ATH9K_NUM_QUEUES; i++, |
| 1366 | qcuOffset += 4, dcuOffset += 5) { |
| 1367 | if (i == 8) { |
| 1368 | qcuOffset = 0; |
| 1369 | qcuBase++; |
| 1370 | } |
| 1371 | |
| 1372 | if (i == 6) { |
| 1373 | dcuOffset = 0; |
| 1374 | dcuBase++; |
| 1375 | } |
| 1376 | if (!sc->debug.stats.txstats[i].queued) |
| 1377 | continue; |
| 1378 | |
| 1379 | len += snprintf(buf + len, size - len, |
| 1380 | "%4d %7d %2x %1x %2x %2x\n", |
| 1381 | sampidx, i, |
| 1382 | (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, |
| 1383 | (*qcuBase & (0x8 << qcuOffset)) >> |
| 1384 | (qcuOffset + 3), |
| 1385 | ATH_SAMP_DBG(dma_dbg_reg_vals[2]) & |
| 1386 | (0x7 << (i * 3)) >> (i * 3), |
| 1387 | (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); |
| 1388 | } |
| 1389 | len += snprintf(buf + len, size - len, "\n"); |
| 1390 | } |
| 1391 | len += snprintf(buf + len, size - len, |
| 1392 | "samp qcu_sh qcu_fh qcu_comp dcu_comp dcu_arb dcu_fp " |
| 1393 | "ch_idle_dur ch_idle_dur_val txfifo_val0 txfifo_val1 " |
| 1394 | "txfifo_dcu0 txfifo_dcu1 pcu_obs AR_CR\n"); |
| 1395 | |
| 1396 | for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { |
| 1397 | qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]); |
| 1398 | dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]); |
| 1399 | |
| 1400 | len += snprintf(buf + len, size - len, "%4d %5x %5x ", sampidx, |
| 1401 | (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x003c0000) >> 18, |
| 1402 | (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x03c00000) >> 22); |
| 1403 | len += snprintf(buf + len, size - len, "%7x %8x ", |
| 1404 | (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x1c000000) >> 26, |
| 1405 | (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x3)); |
| 1406 | len += snprintf(buf + len, size - len, "%7x %7x ", |
| 1407 | (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x06000000) >> 25, |
| 1408 | (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x38000000) >> 27); |
| 1409 | len += snprintf(buf + len, size - len, "%7d %12d ", |
| 1410 | (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x000003fc) >> 2, |
| 1411 | (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000400) >> 10); |
| 1412 | len += snprintf(buf + len, size - len, "%12d %12d ", |
| 1413 | (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000800) >> 11, |
| 1414 | (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00001000) >> 12); |
| 1415 | len += snprintf(buf + len, size - len, "%12d %12d ", |
| 1416 | (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x0001e000) >> 13, |
| 1417 | (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x001e0000) >> 17); |
| 1418 | len += snprintf(buf + len, size - len, "0x%07x 0x%07x\n", |
| 1419 | ATH_SAMP_DBG(pcu_obs), ATH_SAMP_DBG(pcu_cr)); |
| 1420 | } |
| 1421 | |
| 1422 | len += snprintf(buf + len, size - len, |
| 1423 | "Sample ChNoise Chain privNF #Reading Readings\n"); |
| 1424 | for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { |
| 1425 | h = ATH_SAMP_DBG(nfCalHist); |
| 1426 | if (!ATH_SAMP_DBG(noise)) |
| 1427 | continue; |
| 1428 | |
| 1429 | for (i = 0; i < NUM_NF_READINGS; i++) { |
| 1430 | if (!(chainmask & (1 << i)) || |
| 1431 | ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) |
| 1432 | continue; |
| 1433 | |
| 1434 | nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - |
| 1435 | h[i].invalidNFcount; |
| 1436 | len += snprintf(buf + len, size - len, |
| 1437 | "%4d %5d %4d\t %d\t %d\t", |
| 1438 | sampidx, ATH_SAMP_DBG(noise), |
| 1439 | i, h[i].privNF, nread); |
| 1440 | for (j = 0; j < nread; j++) |
| 1441 | len += snprintf(buf + len, size - len, |
| 1442 | " %d", h[i].nfCalBuffer[j]); |
| 1443 | len += snprintf(buf + len, size - len, "\n"); |
| 1444 | } |
| 1445 | } |
| 1446 | len += snprintf(buf + len, size - len, "\nCycle counters:\n" |
| 1447 | "Sample Total Rxbusy Rxframes Txframes\n"); |
| 1448 | for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { |
| 1449 | if (!ATH_SAMP_DBG(cc.cycles)) |
| 1450 | continue; |
| 1451 | len += snprintf(buf + len, size - len, |
| 1452 | "%4d %08x %08x %08x %08x\n", |
| 1453 | sampidx, ATH_SAMP_DBG(cc.cycles), |
| 1454 | ATH_SAMP_DBG(cc.rx_busy), |
| 1455 | ATH_SAMP_DBG(cc.rx_frame), |
| 1456 | ATH_SAMP_DBG(cc.tx_frame)); |
| 1457 | } |
| 1458 | |
| 1459 | len += snprintf(buf + len, size - len, "Tx status Dump :\n"); |
| 1460 | len += snprintf(buf + len, size - len, |
| 1461 | "Sample rssi:- ctl0 ctl1 ctl2 ext0 ext1 ext2 comb " |
Mohammed Shafi Shajakhan | 12932180 | 2011-09-21 14:22:49 +0530 | [diff] [blame] | 1462 | "isok rts_fail data_fail rate tid qid " |
| 1463 | "ba_low ba_high tx_before(ms)\n"); |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 1464 | for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { |
| 1465 | for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) { |
| 1466 | if (!ATH_SAMP_DBG(ts[i].jiffies)) |
| 1467 | continue; |
Mohammed Shafi Shajakhan | 12932180 | 2011-09-21 14:22:49 +0530 | [diff] [blame] | 1468 | len += snprintf(buf + len, size - len, "%-14d" |
| 1469 | "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-8d " |
| 1470 | "%-9d %-4d %-3d %-3d %08x %08x %-11d\n", |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 1471 | sampidx, |
| 1472 | ATH_SAMP_DBG(ts[i].rssi_ctl0), |
| 1473 | ATH_SAMP_DBG(ts[i].rssi_ctl1), |
| 1474 | ATH_SAMP_DBG(ts[i].rssi_ctl2), |
| 1475 | ATH_SAMP_DBG(ts[i].rssi_ext0), |
| 1476 | ATH_SAMP_DBG(ts[i].rssi_ext1), |
| 1477 | ATH_SAMP_DBG(ts[i].rssi_ext2), |
| 1478 | ATH_SAMP_DBG(ts[i].rssi), |
| 1479 | ATH_SAMP_DBG(ts[i].isok), |
| 1480 | ATH_SAMP_DBG(ts[i].rts_fail_cnt), |
| 1481 | ATH_SAMP_DBG(ts[i].data_fail_cnt), |
| 1482 | ATH_SAMP_DBG(ts[i].rateindex), |
| 1483 | ATH_SAMP_DBG(ts[i].tid), |
| 1484 | ATH_SAMP_DBG(ts[i].qid), |
Mohammed Shafi Shajakhan | 12932180 | 2011-09-21 14:22:49 +0530 | [diff] [blame] | 1485 | ATH_SAMP_DBG(ts[i].ba_low), |
| 1486 | ATH_SAMP_DBG(ts[i].ba_high), |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 1487 | jiffies_to_msecs(jiffies - |
| 1488 | ATH_SAMP_DBG(ts[i].jiffies))); |
| 1489 | } |
| 1490 | } |
| 1491 | |
| 1492 | len += snprintf(buf + len, size - len, "Rx status Dump :\n"); |
| 1493 | len += snprintf(buf + len, size - len, "Sample rssi:- ctl0 ctl1 ctl2 " |
| 1494 | "ext0 ext1 ext2 comb beacon ant rate rx_before(ms)\n"); |
| 1495 | for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { |
| 1496 | for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) { |
| 1497 | if (!ATH_SAMP_DBG(rs[i].jiffies)) |
| 1498 | continue; |
Mohammed Shafi Shajakhan | 12932180 | 2011-09-21 14:22:49 +0530 | [diff] [blame] | 1499 | len += snprintf(buf + len, size - len, "%-14d" |
| 1500 | "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-9s %-2d %02x %-13d\n", |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 1501 | sampidx, |
| 1502 | ATH_SAMP_DBG(rs[i].rssi_ctl0), |
| 1503 | ATH_SAMP_DBG(rs[i].rssi_ctl1), |
| 1504 | ATH_SAMP_DBG(rs[i].rssi_ctl2), |
| 1505 | ATH_SAMP_DBG(rs[i].rssi_ext0), |
| 1506 | ATH_SAMP_DBG(rs[i].rssi_ext1), |
| 1507 | ATH_SAMP_DBG(rs[i].rssi_ext2), |
| 1508 | ATH_SAMP_DBG(rs[i].rssi), |
| 1509 | ATH_SAMP_DBG(rs[i].is_mybeacon) ? |
| 1510 | "True" : "False", |
| 1511 | ATH_SAMP_DBG(rs[i].antenna), |
| 1512 | ATH_SAMP_DBG(rs[i].rate), |
| 1513 | jiffies_to_msecs(jiffies - |
| 1514 | ATH_SAMP_DBG(rs[i].jiffies))); |
| 1515 | } |
| 1516 | } |
| 1517 | |
| 1518 | vfree(bb_mac_samp); |
| 1519 | file->private_data = buf; |
| 1520 | |
| 1521 | return 0; |
| 1522 | #undef ATH_SAMP_DBG |
| 1523 | } |
| 1524 | |
| 1525 | static const struct file_operations fops_samps = { |
| 1526 | .open = open_file_bb_mac_samps, |
| 1527 | .read = ath9k_debugfs_read_buf, |
| 1528 | .release = ath9k_debugfs_release_buf, |
| 1529 | .owner = THIS_MODULE, |
| 1530 | .llseek = default_llseek, |
| 1531 | }; |
| 1532 | |
Felix Fietkau | 5baec74 | 2012-03-03 15:17:03 +0100 | [diff] [blame] | 1533 | #endif |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 1534 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1535 | int ath9k_init_debug(struct ath_hw *ah) |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1536 | { |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 1537 | struct ath_common *common = ath9k_hw_common(ah); |
| 1538 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1539 | |
Ben Greear | eb27244 | 2010-11-29 14:13:22 -0800 | [diff] [blame] | 1540 | sc->debug.debugfs_phy = debugfs_create_dir("ath9k", |
| 1541 | sc->hw->wiphy->debugfsdir); |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 1542 | if (!sc->debug.debugfs_phy) |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 1543 | return -ENOMEM; |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 1544 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 1545 | #ifdef CONFIG_ATH_DEBUG |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1546 | debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1547 | sc, &fops_debug); |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 1548 | #endif |
Zefir Kurtisi | 29942bc | 2011-12-14 20:16:34 -0800 | [diff] [blame] | 1549 | |
| 1550 | ath9k_dfs_init_debug(sc); |
| 1551 | |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1552 | debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1553 | &fops_dma); |
| 1554 | debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1555 | &fops_interrupt); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1556 | debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1557 | &fops_xmit); |
Felix Fietkau | 7702e78 | 2012-07-15 19:53:35 +0200 | [diff] [blame] | 1558 | debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1559 | &sc->tx.txq_max_pending[WME_AC_BK]); |
| 1560 | debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1561 | &sc->tx.txq_max_pending[WME_AC_BE]); |
| 1562 | debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1563 | &sc->tx.txq_max_pending[WME_AC_VI]); |
| 1564 | debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1565 | &sc->tx.txq_max_pending[WME_AC_VO]); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1566 | debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1567 | &fops_stations); |
| 1568 | debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1569 | &fops_misc); |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 1570 | debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1571 | &fops_reset); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1572 | debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1573 | &fops_recv); |
| 1574 | debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, |
| 1575 | sc->debug.debugfs_phy, sc, &fops_rx_chainmask); |
| 1576 | debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, |
| 1577 | sc->debug.debugfs_phy, sc, &fops_tx_chainmask); |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 1578 | debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR, |
| 1579 | sc->debug.debugfs_phy, sc, &fops_disable_ani); |
Felix Fietkau | 74673db | 2012-09-08 15:24:17 +0200 | [diff] [blame^] | 1580 | debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1581 | &sc->sc_ah->config.enable_paprd); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1582 | debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1583 | sc, &fops_regidx); |
| 1584 | debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1585 | sc, &fops_regval); |
| 1586 | debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, |
| 1587 | sc->debug.debugfs_phy, |
| 1588 | &ah->config.cwm_ignore_extcca); |
| 1589 | debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1590 | &fops_regdump); |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1591 | debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1592 | &fops_dump_nfcal); |
Rajkumar Manoharan | 580f010 | 2011-07-29 17:38:12 +0530 | [diff] [blame] | 1593 | debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1594 | &fops_base_eeprom); |
Rajkumar Manoharan | 3f4c4bd | 2011-07-29 17:38:13 +0530 | [diff] [blame] | 1595 | debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1596 | &fops_modal_eeprom); |
Felix Fietkau | 5baec74 | 2012-03-03 15:17:03 +0100 | [diff] [blame] | 1597 | #ifdef CONFIG_ATH9K_MAC_DEBUG |
Rajkumar Manoharan | cf3af74 | 2011-08-27 16:17:47 +0530 | [diff] [blame] | 1598 | debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1599 | &fops_samps); |
Felix Fietkau | 5baec74 | 2012-03-03 15:17:03 +0100 | [diff] [blame] | 1600 | #endif |
Vasanthakumar Thiagarajan | 582d006 | 2011-03-01 05:30:55 -0800 | [diff] [blame] | 1601 | |
Felix Fietkau | 691680b | 2011-03-19 13:55:38 +0100 | [diff] [blame] | 1602 | debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, |
| 1603 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); |
| 1604 | |
| 1605 | debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, |
| 1606 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); |
| 1607 | |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 1608 | return 0; |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1609 | } |