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