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