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