Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1 | /* |
Sujith | cee075a | 2009-03-13 09:07:23 +0530 | [diff] [blame] | 2 | * Copyright (c) 2008-2009 Atheros Communications Inc. |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 17 | #include <linux/slab.h> |
Vasanthakumar Thiagarajan | 582d006 | 2011-03-01 05:30:55 -0800 | [diff] [blame] | 18 | #include <linux/vmalloc.h> |
Gabor Juhos | 5210311 | 2009-03-06 09:57:39 +0100 | [diff] [blame] | 19 | #include <asm/unaligned.h> |
| 20 | |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 21 | #include "ath9k.h" |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 22 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 23 | #define REG_WRITE_D(_ah, _reg, _val) \ |
| 24 | ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) |
| 25 | #define REG_READ_D(_ah, _reg) \ |
| 26 | ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) |
| 27 | |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 28 | static int ath9k_debugfs_open(struct inode *inode, struct file *file) |
| 29 | { |
| 30 | file->private_data = inode->i_private; |
| 31 | return 0; |
| 32 | } |
| 33 | |
Vasanthakumar Thiagarajan | 582d006 | 2011-03-01 05:30:55 -0800 | [diff] [blame] | 34 | static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf, |
| 35 | size_t count, loff_t *ppos) |
| 36 | { |
| 37 | u8 *buf = file->private_data; |
| 38 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); |
| 39 | } |
| 40 | |
| 41 | static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file) |
| 42 | { |
| 43 | vfree(file->private_data); |
| 44 | return 0; |
| 45 | } |
| 46 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 47 | #ifdef CONFIG_ATH_DEBUG |
| 48 | |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 49 | static ssize_t read_file_debug(struct file *file, char __user *user_buf, |
| 50 | size_t count, loff_t *ppos) |
| 51 | { |
| 52 | struct ath_softc *sc = file->private_data; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 53 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 54 | char buf[32]; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 55 | unsigned int len; |
| 56 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 57 | len = sprintf(buf, "0x%08x\n", common->debug_mask); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 58 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 59 | } |
| 60 | |
| 61 | static ssize_t write_file_debug(struct file *file, const char __user *user_buf, |
| 62 | size_t count, loff_t *ppos) |
| 63 | { |
| 64 | struct ath_softc *sc = file->private_data; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 65 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 66 | unsigned long mask; |
| 67 | char buf[32]; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 68 | ssize_t len; |
| 69 | |
| 70 | len = min(count, sizeof(buf) - 1); |
| 71 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 72 | return -EFAULT; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 73 | |
| 74 | buf[len] = '\0'; |
| 75 | if (strict_strtoul(buf, 0, &mask)) |
| 76 | return -EINVAL; |
| 77 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 78 | common->debug_mask = mask; |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 79 | return count; |
| 80 | } |
| 81 | |
| 82 | static const struct file_operations fops_debug = { |
| 83 | .read = read_file_debug, |
| 84 | .write = write_file_debug, |
| 85 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 86 | .owner = THIS_MODULE, |
| 87 | .llseek = default_llseek, |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 88 | }; |
| 89 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 90 | #endif |
| 91 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 92 | #define DMA_BUF_LEN 1024 |
| 93 | |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 94 | static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf, |
| 95 | size_t count, loff_t *ppos) |
| 96 | { |
| 97 | struct ath_softc *sc = file->private_data; |
| 98 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 99 | char buf[32]; |
| 100 | unsigned int len; |
| 101 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 102 | len = sprintf(buf, "0x%08x\n", common->tx_chainmask); |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 103 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 104 | } |
| 105 | |
| 106 | static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf, |
| 107 | size_t count, loff_t *ppos) |
| 108 | { |
| 109 | struct ath_softc *sc = file->private_data; |
| 110 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 111 | unsigned long mask; |
| 112 | char buf[32]; |
| 113 | ssize_t len; |
| 114 | |
| 115 | len = min(count, sizeof(buf) - 1); |
| 116 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 117 | return -EFAULT; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 118 | |
| 119 | buf[len] = '\0'; |
| 120 | if (strict_strtoul(buf, 0, &mask)) |
| 121 | return -EINVAL; |
| 122 | |
| 123 | common->tx_chainmask = mask; |
| 124 | sc->sc_ah->caps.tx_chainmask = mask; |
| 125 | return count; |
| 126 | } |
| 127 | |
| 128 | static const struct file_operations fops_tx_chainmask = { |
| 129 | .read = read_file_tx_chainmask, |
| 130 | .write = write_file_tx_chainmask, |
| 131 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 132 | .owner = THIS_MODULE, |
| 133 | .llseek = default_llseek, |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | |
| 137 | static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf, |
| 138 | size_t count, loff_t *ppos) |
| 139 | { |
| 140 | struct ath_softc *sc = file->private_data; |
| 141 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 142 | char buf[32]; |
| 143 | unsigned int len; |
| 144 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 145 | len = sprintf(buf, "0x%08x\n", common->rx_chainmask); |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 146 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 147 | } |
| 148 | |
| 149 | static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf, |
| 150 | size_t count, loff_t *ppos) |
| 151 | { |
| 152 | struct ath_softc *sc = file->private_data; |
| 153 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 154 | unsigned long mask; |
| 155 | char buf[32]; |
| 156 | ssize_t len; |
| 157 | |
| 158 | len = min(count, sizeof(buf) - 1); |
| 159 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 160 | return -EFAULT; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 161 | |
| 162 | buf[len] = '\0'; |
| 163 | if (strict_strtoul(buf, 0, &mask)) |
| 164 | return -EINVAL; |
| 165 | |
| 166 | common->rx_chainmask = mask; |
| 167 | sc->sc_ah->caps.rx_chainmask = mask; |
| 168 | return count; |
| 169 | } |
| 170 | |
| 171 | static const struct file_operations fops_rx_chainmask = { |
| 172 | .read = read_file_rx_chainmask, |
| 173 | .write = write_file_rx_chainmask, |
| 174 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 175 | .owner = THIS_MODULE, |
| 176 | .llseek = default_llseek, |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 177 | }; |
| 178 | |
| 179 | |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 180 | static ssize_t read_file_dma(struct file *file, char __user *user_buf, |
| 181 | size_t count, loff_t *ppos) |
| 182 | { |
| 183 | struct ath_softc *sc = file->private_data; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 184 | struct ath_hw *ah = sc->sc_ah; |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 185 | char *buf; |
| 186 | int retval; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 187 | unsigned int len = 0; |
| 188 | u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; |
| 189 | int i, qcuOffset = 0, dcuOffset = 0; |
| 190 | u32 *qcuBase = &val[0], *dcuBase = &val[4]; |
| 191 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 192 | buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); |
| 193 | if (!buf) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 194 | return -ENOMEM; |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 195 | |
Sujith | 7cf4a2e | 2009-08-26 11:11:57 +0530 | [diff] [blame] | 196 | ath9k_ps_wakeup(sc); |
| 197 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 198 | REG_WRITE_D(ah, AR_MACMISC, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 199 | ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | |
| 200 | (AR_MACMISC_MISC_OBS_BUS_1 << |
| 201 | AR_MACMISC_MISC_OBS_BUS_MSB_S))); |
| 202 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 203 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 204 | "Raw DMA Debug values:\n"); |
| 205 | |
| 206 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { |
| 207 | if (i % 4 == 0) |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 208 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 209 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 210 | val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 211 | len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 212 | i, val[i]); |
| 213 | } |
| 214 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 215 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); |
| 216 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 217 | "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); |
| 218 | |
| 219 | for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { |
| 220 | if (i == 8) { |
| 221 | qcuOffset = 0; |
| 222 | qcuBase++; |
| 223 | } |
| 224 | |
| 225 | if (i == 6) { |
| 226 | dcuOffset = 0; |
| 227 | dcuBase++; |
| 228 | } |
| 229 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 230 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 231 | "%2d %2x %1x %2x %2x\n", |
| 232 | i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, |
| 233 | (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), |
| 234 | val[2] & (0x7 << (i * 3)) >> (i * 3), |
| 235 | (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); |
| 236 | } |
| 237 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 238 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 239 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 240 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 241 | "qcu_stitch state: %2x qcu_fetch state: %2x\n", |
| 242 | (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 243 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 244 | "qcu_complete state: %2x dcu_complete state: %2x\n", |
| 245 | (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 246 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 247 | "dcu_arb state: %2x dcu_fp state: %2x\n", |
| 248 | (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 249 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 250 | "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", |
| 251 | (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 252 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 253 | "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", |
| 254 | (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 255 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 256 | "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", |
| 257 | (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); |
| 258 | |
Frans Pop | 60ece40 | 2010-03-24 19:46:30 +0100 | [diff] [blame] | 259 | 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] | 260 | REG_READ_D(ah, AR_OBS_BUS_1)); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 261 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Frans Pop | 60ece40 | 2010-03-24 19:46:30 +0100 | [diff] [blame] | 262 | "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 263 | |
Sujith | 7cf4a2e | 2009-08-26 11:11:57 +0530 | [diff] [blame] | 264 | ath9k_ps_restore(sc); |
| 265 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 266 | if (len > DMA_BUF_LEN) |
| 267 | len = DMA_BUF_LEN; |
| 268 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 269 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 270 | kfree(buf); |
| 271 | return retval; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | static const struct file_operations fops_dma = { |
| 275 | .read = read_file_dma, |
| 276 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 277 | .owner = THIS_MODULE, |
| 278 | .llseek = default_llseek, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 279 | }; |
| 280 | |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 281 | |
| 282 | void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) |
| 283 | { |
| 284 | if (status) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 285 | sc->debug.stats.istats.total++; |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 286 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
| 287 | if (status & ATH9K_INT_RXLP) |
| 288 | sc->debug.stats.istats.rxlp++; |
| 289 | if (status & ATH9K_INT_RXHP) |
| 290 | sc->debug.stats.istats.rxhp++; |
Luis R. Rodriguez | 08578b8 | 2010-05-13 13:33:44 -0400 | [diff] [blame] | 291 | if (status & ATH9K_INT_BB_WATCHDOG) |
| 292 | sc->debug.stats.istats.bb_watchdog++; |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 293 | } else { |
| 294 | if (status & ATH9K_INT_RX) |
| 295 | sc->debug.stats.istats.rxok++; |
| 296 | } |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 297 | if (status & ATH9K_INT_RXEOL) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 298 | sc->debug.stats.istats.rxeol++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 299 | if (status & ATH9K_INT_RXORN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 300 | sc->debug.stats.istats.rxorn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 301 | if (status & ATH9K_INT_TX) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 302 | sc->debug.stats.istats.txok++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 303 | if (status & ATH9K_INT_TXURN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 304 | sc->debug.stats.istats.txurn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 305 | if (status & ATH9K_INT_MIB) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 306 | sc->debug.stats.istats.mib++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 307 | if (status & ATH9K_INT_RXPHY) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 308 | sc->debug.stats.istats.rxphyerr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 309 | if (status & ATH9K_INT_RXKCM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 310 | sc->debug.stats.istats.rx_keycache_miss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 311 | if (status & ATH9K_INT_SWBA) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 312 | sc->debug.stats.istats.swba++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 313 | if (status & ATH9K_INT_BMISS) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 314 | sc->debug.stats.istats.bmiss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 315 | if (status & ATH9K_INT_BNR) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 316 | sc->debug.stats.istats.bnr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 317 | if (status & ATH9K_INT_CST) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 318 | sc->debug.stats.istats.cst++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 319 | if (status & ATH9K_INT_GTT) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 320 | sc->debug.stats.istats.gtt++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 321 | if (status & ATH9K_INT_TIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 322 | sc->debug.stats.istats.tim++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 323 | if (status & ATH9K_INT_CABEND) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 324 | sc->debug.stats.istats.cabend++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 325 | if (status & ATH9K_INT_DTIMSYNC) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 326 | sc->debug.stats.istats.dtimsync++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 327 | if (status & ATH9K_INT_DTIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 328 | sc->debug.stats.istats.dtim++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, |
| 332 | size_t count, loff_t *ppos) |
| 333 | { |
| 334 | struct ath_softc *sc = file->private_data; |
| 335 | char buf[512]; |
| 336 | unsigned int len = 0; |
| 337 | |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 338 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
| 339 | len += snprintf(buf + len, sizeof(buf) - len, |
| 340 | "%8s: %10u\n", "RXLP", sc->debug.stats.istats.rxlp); |
| 341 | len += snprintf(buf + len, sizeof(buf) - len, |
| 342 | "%8s: %10u\n", "RXHP", sc->debug.stats.istats.rxhp); |
Luis R. Rodriguez | 08578b8 | 2010-05-13 13:33:44 -0400 | [diff] [blame] | 343 | len += snprintf(buf + len, sizeof(buf) - len, |
| 344 | "%8s: %10u\n", "WATCHDOG", |
| 345 | sc->debug.stats.istats.bb_watchdog); |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 346 | } else { |
| 347 | len += snprintf(buf + len, sizeof(buf) - len, |
| 348 | "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok); |
| 349 | } |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 350 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 351 | "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 352 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 353 | "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 354 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 355 | "%8s: %10u\n", "TX", sc->debug.stats.istats.txok); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 356 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 357 | "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 358 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 359 | "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 360 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 361 | "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 362 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 363 | "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 364 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 365 | "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 366 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 367 | "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 368 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 369 | "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 370 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 371 | "%8s: %10u\n", "CST", sc->debug.stats.istats.cst); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 372 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 373 | "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 374 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 375 | "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 376 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 377 | "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 378 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 379 | "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 380 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 381 | "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 382 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 383 | "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 384 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 385 | if (len > sizeof(buf)) |
| 386 | len = sizeof(buf); |
| 387 | |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 388 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 389 | } |
| 390 | |
| 391 | static const struct file_operations fops_interrupt = { |
| 392 | .read = read_file_interrupt, |
| 393 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 394 | .owner = THIS_MODULE, |
| 395 | .llseek = default_llseek, |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 396 | }; |
| 397 | |
Ben Greear | 4e6975f | 2011-01-31 10:37:36 -0800 | [diff] [blame] | 398 | static const char *channel_type_str(enum nl80211_channel_type t) |
| 399 | { |
| 400 | switch (t) { |
| 401 | case NL80211_CHAN_NO_HT: |
| 402 | return "no ht"; |
| 403 | case NL80211_CHAN_HT20: |
| 404 | return "ht20"; |
| 405 | case NL80211_CHAN_HT40MINUS: |
| 406 | return "ht40-"; |
| 407 | case NL80211_CHAN_HT40PLUS: |
| 408 | return "ht40+"; |
| 409 | default: |
| 410 | return "???"; |
| 411 | } |
| 412 | } |
| 413 | |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 414 | static ssize_t read_file_wiphy(struct file *file, char __user *user_buf, |
| 415 | size_t count, loff_t *ppos) |
| 416 | { |
| 417 | struct ath_softc *sc = file->private_data; |
Felix Fietkau | 3430239 | 2011-01-24 19:23:15 +0100 | [diff] [blame] | 418 | struct ieee80211_channel *chan = sc->hw->conf.channel; |
Ben Greear | 4e6975f | 2011-01-31 10:37:36 -0800 | [diff] [blame] | 419 | struct ieee80211_conf *conf = &(sc->hw->conf); |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 420 | char buf[512]; |
| 421 | unsigned int len = 0; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 422 | u8 addr[ETH_ALEN]; |
Ben Greear | 3905751 | 2010-09-14 12:46:04 -0700 | [diff] [blame] | 423 | u32 tmp; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 424 | |
| 425 | len += snprintf(buf + len, sizeof(buf) - len, |
Ben Greear | 4e6975f | 2011-01-31 10:37:36 -0800 | [diff] [blame] | 426 | "%s (chan=%d center-freq: %d MHz channel-type: %d (%s))\n", |
Felix Fietkau | 3430239 | 2011-01-24 19:23:15 +0100 | [diff] [blame] | 427 | wiphy_name(sc->hw->wiphy), |
Mohammed Shafi Shajakhan | 8e0167a | 2010-10-01 15:25:05 +0530 | [diff] [blame] | 428 | ieee80211_frequency_to_channel(chan->center_freq), |
Ben Greear | 4e6975f | 2011-01-31 10:37:36 -0800 | [diff] [blame] | 429 | chan->center_freq, |
| 430 | conf->channel_type, |
| 431 | channel_type_str(conf->channel_type)); |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 432 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 433 | put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr); |
| 434 | 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] | 435 | len += snprintf(buf + len, sizeof(buf) - len, |
| 436 | "addr: %pM\n", addr); |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 437 | put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr); |
| 438 | 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] | 439 | len += snprintf(buf + len, sizeof(buf) - len, |
| 440 | "addrmask: %pM\n", addr); |
Ben Greear | 3905751 | 2010-09-14 12:46:04 -0700 | [diff] [blame] | 441 | tmp = ath9k_hw_getrxfilter(sc->sc_ah); |
| 442 | len += snprintf(buf + len, sizeof(buf) - len, |
| 443 | "rfilt: 0x%x", tmp); |
| 444 | if (tmp & ATH9K_RX_FILTER_UCAST) |
| 445 | len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); |
| 446 | if (tmp & ATH9K_RX_FILTER_MCAST) |
| 447 | len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); |
| 448 | if (tmp & ATH9K_RX_FILTER_BCAST) |
| 449 | len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); |
| 450 | if (tmp & ATH9K_RX_FILTER_CONTROL) |
| 451 | len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); |
| 452 | if (tmp & ATH9K_RX_FILTER_BEACON) |
| 453 | len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); |
| 454 | if (tmp & ATH9K_RX_FILTER_PROM) |
| 455 | len += snprintf(buf + len, sizeof(buf) - len, " PROM"); |
| 456 | if (tmp & ATH9K_RX_FILTER_PROBEREQ) |
| 457 | len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); |
| 458 | if (tmp & ATH9K_RX_FILTER_PHYERR) |
| 459 | len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); |
| 460 | if (tmp & ATH9K_RX_FILTER_MYBEACON) |
| 461 | len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); |
| 462 | if (tmp & ATH9K_RX_FILTER_COMP_BAR) |
| 463 | len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); |
| 464 | if (tmp & ATH9K_RX_FILTER_PSPOLL) |
| 465 | len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); |
| 466 | if (tmp & ATH9K_RX_FILTER_PHYRADAR) |
| 467 | len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); |
| 468 | if (tmp & ATH9K_RX_FILTER_MCAST_BCAST_ALL) |
| 469 | len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL\n"); |
| 470 | else |
| 471 | len += snprintf(buf + len, sizeof(buf) - len, "\n"); |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 472 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 473 | if (len > sizeof(buf)) |
| 474 | len = sizeof(buf); |
| 475 | |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 476 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 477 | } |
| 478 | |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 479 | static const struct file_operations fops_wiphy = { |
| 480 | .read = read_file_wiphy, |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 481 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 482 | .owner = THIS_MODULE, |
| 483 | .llseek = default_llseek, |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 484 | }; |
| 485 | |
Felix Fietkau | 5bec3e5 | 2011-01-24 21:29:25 +0100 | [diff] [blame] | 486 | #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 487 | #define PR(str, elem) \ |
| 488 | do { \ |
| 489 | len += snprintf(buf + len, size - len, \ |
| 490 | "%s%13u%11u%10u%10u\n", str, \ |
Felix Fietkau | 5bec3e5 | 2011-01-24 21:29:25 +0100 | [diff] [blame] | 491 | sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem, \ |
| 492 | sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem, \ |
| 493 | sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem, \ |
| 494 | sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem); \ |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 495 | if (len >= size) \ |
| 496 | goto done; \ |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 497 | } while(0) |
| 498 | |
Ben Greear | 1f427dd | 2011-01-09 23:11:43 -0800 | [diff] [blame] | 499 | #define PRX(str, elem) \ |
| 500 | do { \ |
| 501 | len += snprintf(buf + len, size - len, \ |
| 502 | "%s%13u%11u%10u%10u\n", str, \ |
Felix Fietkau | 5bec3e5 | 2011-01-24 21:29:25 +0100 | [diff] [blame] | 503 | (unsigned int)(sc->tx.txq_map[WME_AC_BE]->elem), \ |
| 504 | (unsigned int)(sc->tx.txq_map[WME_AC_BK]->elem), \ |
| 505 | (unsigned int)(sc->tx.txq_map[WME_AC_VI]->elem), \ |
| 506 | (unsigned int)(sc->tx.txq_map[WME_AC_VO]->elem)); \ |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 507 | if (len >= size) \ |
| 508 | goto done; \ |
Ben Greear | 1f427dd | 2011-01-09 23:11:43 -0800 | [diff] [blame] | 509 | } while(0) |
| 510 | |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 511 | #define PRQLE(str, elem) \ |
| 512 | do { \ |
| 513 | len += snprintf(buf + len, size - len, \ |
| 514 | "%s%13i%11i%10i%10i\n", str, \ |
Felix Fietkau | 5bec3e5 | 2011-01-24 21:29:25 +0100 | [diff] [blame] | 515 | list_empty(&sc->tx.txq_map[WME_AC_BE]->elem), \ |
| 516 | list_empty(&sc->tx.txq_map[WME_AC_BK]->elem), \ |
| 517 | list_empty(&sc->tx.txq_map[WME_AC_VI]->elem), \ |
| 518 | list_empty(&sc->tx.txq_map[WME_AC_VO]->elem)); \ |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 519 | if (len >= size) \ |
| 520 | goto done; \ |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 521 | } while (0) |
| 522 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 523 | static ssize_t read_file_xmit(struct file *file, char __user *user_buf, |
| 524 | size_t count, loff_t *ppos) |
| 525 | { |
| 526 | struct ath_softc *sc = file->private_data; |
| 527 | char *buf; |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 528 | unsigned int len = 0, size = 8000; |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 529 | int i; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 530 | ssize_t retval = 0; |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 531 | char tmp[32]; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 532 | |
| 533 | buf = kzalloc(size, GFP_KERNEL); |
| 534 | if (buf == NULL) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 535 | return -ENOMEM; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 536 | |
Ben Greear | 60f2d1d | 2011-01-09 23:11:52 -0800 | [diff] [blame] | 537 | len += sprintf(buf, "Num-Tx-Queues: %i tx-queues-setup: 0x%x" |
| 538 | " poll-work-seen: %u\n" |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 539 | "%30s %10s%10s%10s\n\n", |
| 540 | ATH9K_NUM_TX_QUEUES, sc->tx.txqsetup, |
Ben Greear | 60f2d1d | 2011-01-09 23:11:52 -0800 | [diff] [blame] | 541 | sc->tx_complete_poll_work_seen, |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 542 | "BE", "BK", "VI", "VO"); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 543 | |
| 544 | PR("MPDUs Queued: ", queued); |
| 545 | PR("MPDUs Completed: ", completed); |
| 546 | PR("Aggregates: ", a_aggr); |
Ben Greear | bda8add | 2011-01-09 23:11:48 -0800 | [diff] [blame] | 547 | PR("AMPDUs Queued HW:", a_queued_hw); |
| 548 | PR("AMPDUs Queued SW:", a_queued_sw); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 549 | PR("AMPDUs Completed:", a_completed); |
| 550 | PR("AMPDUs Retried: ", a_retries); |
| 551 | PR("AMPDUs XRetried: ", a_xretries); |
| 552 | PR("FIFO Underrun: ", fifo_underrun); |
| 553 | PR("TXOP Exceeded: ", xtxop); |
| 554 | PR("TXTIMER Expiry: ", timer_exp); |
| 555 | PR("DESC CFG Error: ", desc_cfg_err); |
| 556 | PR("DATA Underrun: ", data_underrun); |
| 557 | PR("DELIM Underrun: ", delim_underrun); |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 558 | PR("TX-Pkts-All: ", tx_pkts_all); |
| 559 | PR("TX-Bytes-All: ", tx_bytes_all); |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 560 | PR("hw-put-tx-buf: ", puttxbuf); |
| 561 | PR("hw-tx-start: ", txstart); |
| 562 | PR("hw-tx-proc-desc: ", txprocdesc); |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 563 | len += snprintf(buf + len, size - len, |
| 564 | "%s%11p%11p%10p%10p\n", "txq-memory-address:", |
Ben Greear | db7889c | 2011-03-03 16:25:59 -0800 | [diff] [blame] | 565 | sc->tx.txq_map[WME_AC_BE], |
| 566 | sc->tx.txq_map[WME_AC_BK], |
| 567 | sc->tx.txq_map[WME_AC_VI], |
| 568 | sc->tx.txq_map[WME_AC_VO]); |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 569 | if (len >= size) |
| 570 | goto done; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 571 | |
Ben Greear | 1f427dd | 2011-01-09 23:11:43 -0800 | [diff] [blame] | 572 | PRX("axq-qnum: ", axq_qnum); |
| 573 | PRX("axq-depth: ", axq_depth); |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 574 | PRX("axq-ampdu_depth: ", axq_ampdu_depth); |
Ben Greear | 1f427dd | 2011-01-09 23:11:43 -0800 | [diff] [blame] | 575 | PRX("axq-stopped ", stopped); |
| 576 | PRX("tx-in-progress ", axq_tx_inprogress); |
| 577 | PRX("pending-frames ", pending_frames); |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 578 | PRX("txq_headidx: ", txq_headidx); |
| 579 | PRX("txq_tailidx: ", txq_headidx); |
Ben Greear | 1f427dd | 2011-01-09 23:11:43 -0800 | [diff] [blame] | 580 | |
Ben Greear | 2dac4fb | 2011-01-09 23:11:45 -0800 | [diff] [blame] | 581 | PRQLE("axq_q empty: ", axq_q); |
| 582 | PRQLE("axq_acq empty: ", axq_acq); |
| 583 | PRQLE("txq_fifo_pending: ", txq_fifo_pending); |
| 584 | for (i = 0; i < ATH_TXFIFO_DEPTH; i++) { |
| 585 | snprintf(tmp, sizeof(tmp) - 1, "txq_fifo[%i] empty: ", i); |
| 586 | PRQLE(tmp, txq_fifo[i]); |
| 587 | } |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 588 | |
Ben Greear | 71e025a | 2011-01-09 23:11:50 -0800 | [diff] [blame] | 589 | /* Print out more detailed queue-info */ |
| 590 | for (i = 0; i <= WME_AC_BK; i++) { |
| 591 | struct ath_txq *txq = &(sc->tx.txq[i]); |
| 592 | struct ath_atx_ac *ac; |
| 593 | struct ath_atx_tid *tid; |
| 594 | if (len >= size) |
| 595 | goto done; |
| 596 | spin_lock_bh(&txq->axq_lock); |
| 597 | if (!list_empty(&txq->axq_acq)) { |
| 598 | ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, |
| 599 | list); |
| 600 | len += snprintf(buf + len, size - len, |
| 601 | "txq[%i] first-ac: %p sched: %i\n", |
| 602 | i, ac, ac->sched); |
| 603 | if (list_empty(&ac->tid_q) || (len >= size)) |
| 604 | goto done_for; |
| 605 | tid = list_first_entry(&ac->tid_q, struct ath_atx_tid, |
| 606 | list); |
| 607 | len += snprintf(buf + len, size - len, |
| 608 | " first-tid: %p sched: %i paused: %i\n", |
| 609 | tid, tid->sched, tid->paused); |
| 610 | } |
| 611 | done_for: |
| 612 | spin_unlock_bh(&txq->axq_lock); |
| 613 | } |
| 614 | |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 615 | done: |
| 616 | if (len > size) |
| 617 | len = size; |
| 618 | |
| 619 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 620 | kfree(buf); |
| 621 | |
| 622 | return retval; |
| 623 | } |
| 624 | |
| 625 | static ssize_t read_file_stations(struct file *file, char __user *user_buf, |
| 626 | size_t count, loff_t *ppos) |
| 627 | { |
| 628 | struct ath_softc *sc = file->private_data; |
| 629 | char *buf; |
| 630 | unsigned int len = 0, size = 64000; |
| 631 | struct ath_node *an = NULL; |
| 632 | ssize_t retval = 0; |
| 633 | int q; |
| 634 | |
| 635 | buf = kzalloc(size, GFP_KERNEL); |
| 636 | if (buf == NULL) |
| 637 | return -ENOMEM; |
| 638 | |
| 639 | len += snprintf(buf + len, size - len, |
| 640 | "Stations:\n" |
| 641 | " tid: addr sched paused buf_q-empty an ac\n" |
| 642 | " ac: addr sched tid_q-empty txq\n"); |
| 643 | |
| 644 | spin_lock(&sc->nodes_lock); |
| 645 | list_for_each_entry(an, &sc->nodes, list) { |
| 646 | len += snprintf(buf + len, size - len, |
| 647 | "%pM\n", an->sta->addr); |
| 648 | if (len >= size) |
| 649 | goto done; |
| 650 | |
| 651 | for (q = 0; q < WME_NUM_TID; q++) { |
| 652 | struct ath_atx_tid *tid = &(an->tid[q]); |
| 653 | len += snprintf(buf + len, size - len, |
| 654 | " tid: %p %s %s %i %p %p\n", |
| 655 | tid, tid->sched ? "sched" : "idle", |
| 656 | tid->paused ? "paused" : "running", |
| 657 | list_empty(&tid->buf_q), |
| 658 | tid->an, tid->ac); |
| 659 | if (len >= size) |
| 660 | goto done; |
| 661 | } |
| 662 | |
| 663 | for (q = 0; q < WME_NUM_AC; q++) { |
| 664 | struct ath_atx_ac *ac = &(an->ac[q]); |
| 665 | len += snprintf(buf + len, size - len, |
| 666 | " ac: %p %s %i %p\n", |
| 667 | ac, ac->sched ? "sched" : "idle", |
| 668 | list_empty(&ac->tid_q), ac->txq); |
| 669 | if (len >= size) |
| 670 | goto done; |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | done: |
| 675 | spin_unlock(&sc->nodes_lock); |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 676 | if (len > size) |
| 677 | len = size; |
| 678 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 679 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 680 | kfree(buf); |
| 681 | |
| 682 | return retval; |
| 683 | } |
| 684 | |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 685 | static ssize_t read_file_misc(struct file *file, char __user *user_buf, |
| 686 | size_t count, loff_t *ppos) |
| 687 | { |
| 688 | struct ath_softc *sc = file->private_data; |
| 689 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 690 | struct ath_hw *ah = sc->sc_ah; |
| 691 | struct ieee80211_hw *hw = sc->hw; |
| 692 | char *buf; |
| 693 | unsigned int len = 0, size = 8000; |
| 694 | ssize_t retval = 0; |
| 695 | const char *tmp; |
| 696 | unsigned int reg; |
| 697 | struct ath9k_vif_iter_data iter_data; |
| 698 | |
| 699 | ath9k_calculate_iter_data(hw, NULL, &iter_data); |
| 700 | |
| 701 | buf = kzalloc(size, GFP_KERNEL); |
| 702 | if (buf == NULL) |
| 703 | return -ENOMEM; |
| 704 | |
| 705 | switch (sc->sc_ah->opmode) { |
| 706 | case NL80211_IFTYPE_ADHOC: |
| 707 | tmp = "ADHOC"; |
| 708 | break; |
| 709 | case NL80211_IFTYPE_MESH_POINT: |
| 710 | tmp = "MESH"; |
| 711 | break; |
| 712 | case NL80211_IFTYPE_AP: |
| 713 | tmp = "AP"; |
| 714 | break; |
| 715 | case NL80211_IFTYPE_STATION: |
| 716 | tmp = "STATION"; |
| 717 | break; |
| 718 | default: |
| 719 | tmp = "???"; |
| 720 | break; |
| 721 | } |
| 722 | |
| 723 | len += snprintf(buf + len, size - len, |
| 724 | "curbssid: %pM\n" |
| 725 | "OP-Mode: %s(%i)\n" |
| 726 | "Beacon-Timer-Register: 0x%x\n", |
| 727 | common->curbssid, |
| 728 | tmp, (int)(sc->sc_ah->opmode), |
| 729 | REG_READ(ah, AR_BEACON_PERIOD)); |
| 730 | |
| 731 | reg = REG_READ(ah, AR_TIMER_MODE); |
| 732 | len += snprintf(buf + len, size - len, "Timer-Mode-Register: 0x%x (", |
| 733 | reg); |
| 734 | if (reg & AR_TBTT_TIMER_EN) |
| 735 | len += snprintf(buf + len, size - len, "TBTT "); |
| 736 | if (reg & AR_DBA_TIMER_EN) |
| 737 | len += snprintf(buf + len, size - len, "DBA "); |
| 738 | if (reg & AR_SWBA_TIMER_EN) |
| 739 | len += snprintf(buf + len, size - len, "SWBA "); |
| 740 | if (reg & AR_HCF_TIMER_EN) |
| 741 | len += snprintf(buf + len, size - len, "HCF "); |
| 742 | if (reg & AR_TIM_TIMER_EN) |
| 743 | len += snprintf(buf + len, size - len, "TIM "); |
| 744 | if (reg & AR_DTIM_TIMER_EN) |
| 745 | len += snprintf(buf + len, size - len, "DTIM "); |
| 746 | len += snprintf(buf + len, size - len, ")\n"); |
| 747 | |
| 748 | reg = sc->sc_ah->imask; |
| 749 | len += snprintf(buf + len, size - len, "imask: 0x%x (", reg); |
| 750 | if (reg & ATH9K_INT_SWBA) |
| 751 | len += snprintf(buf + len, size - len, "SWBA "); |
| 752 | if (reg & ATH9K_INT_BMISS) |
| 753 | len += snprintf(buf + len, size - len, "BMISS "); |
| 754 | if (reg & ATH9K_INT_CST) |
| 755 | len += snprintf(buf + len, size - len, "CST "); |
| 756 | if (reg & ATH9K_INT_RX) |
| 757 | len += snprintf(buf + len, size - len, "RX "); |
| 758 | if (reg & ATH9K_INT_RXHP) |
| 759 | len += snprintf(buf + len, size - len, "RXHP "); |
| 760 | if (reg & ATH9K_INT_RXLP) |
| 761 | len += snprintf(buf + len, size - len, "RXLP "); |
| 762 | if (reg & ATH9K_INT_BB_WATCHDOG) |
| 763 | len += snprintf(buf + len, size - len, "BB_WATCHDOG "); |
| 764 | /* there are other IRQs if one wanted to add them. */ |
| 765 | len += snprintf(buf + len, size - len, ")\n"); |
| 766 | |
| 767 | len += snprintf(buf + len, size - len, |
| 768 | "VIF Counts: AP: %i STA: %i MESH: %i WDS: %i" |
| 769 | " ADHOC: %i OTHER: %i nvifs: %hi beacon-vifs: %hi\n", |
| 770 | iter_data.naps, iter_data.nstations, iter_data.nmeshes, |
| 771 | iter_data.nwds, iter_data.nadhocs, iter_data.nothers, |
| 772 | sc->nvifs, sc->nbcnvifs); |
| 773 | |
| 774 | len += snprintf(buf + len, size - len, |
| 775 | "Calculated-BSSID-Mask: %pM\n", |
| 776 | iter_data.mask); |
| 777 | |
| 778 | if (len > size) |
| 779 | len = size; |
| 780 | |
| 781 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 782 | kfree(buf); |
| 783 | |
| 784 | return retval; |
| 785 | } |
| 786 | |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 787 | void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, |
Felix Fietkau | 5bec3e5 | 2011-01-24 21:29:25 +0100 | [diff] [blame] | 788 | struct ath_tx_status *ts, struct ath_txq *txq) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 789 | { |
Felix Fietkau | 5bec3e5 | 2011-01-24 21:29:25 +0100 | [diff] [blame] | 790 | int qnum = txq->axq_qnum; |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 791 | |
| 792 | TX_STAT_INC(qnum, tx_pkts_all); |
| 793 | sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 794 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 795 | if (bf_isampdu(bf)) { |
| 796 | if (bf_isxretried(bf)) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 797 | TX_STAT_INC(qnum, a_xretries); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 798 | else |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 799 | TX_STAT_INC(qnum, a_completed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 800 | } else { |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 801 | TX_STAT_INC(qnum, completed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 802 | } |
| 803 | |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 804 | if (ts->ts_status & ATH9K_TXERR_FIFO) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 805 | TX_STAT_INC(qnum, fifo_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 806 | if (ts->ts_status & ATH9K_TXERR_XTXOP) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 807 | TX_STAT_INC(qnum, xtxop); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 808 | if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 809 | TX_STAT_INC(qnum, timer_exp); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 810 | if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 811 | TX_STAT_INC(qnum, desc_cfg_err); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 812 | if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 813 | TX_STAT_INC(qnum, data_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 814 | if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 815 | TX_STAT_INC(qnum, delim_underrun); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 816 | } |
| 817 | |
| 818 | static const struct file_operations fops_xmit = { |
| 819 | .read = read_file_xmit, |
| 820 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 821 | .owner = THIS_MODULE, |
| 822 | .llseek = default_llseek, |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 823 | }; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 824 | |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 825 | static const struct file_operations fops_stations = { |
| 826 | .read = read_file_stations, |
| 827 | .open = ath9k_debugfs_open, |
| 828 | .owner = THIS_MODULE, |
| 829 | .llseek = default_llseek, |
| 830 | }; |
| 831 | |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 832 | static const struct file_operations fops_misc = { |
| 833 | .read = read_file_misc, |
| 834 | .open = ath9k_debugfs_open, |
| 835 | .owner = THIS_MODULE, |
| 836 | .llseek = default_llseek, |
| 837 | }; |
| 838 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 839 | static ssize_t read_file_recv(struct file *file, char __user *user_buf, |
| 840 | size_t count, loff_t *ppos) |
| 841 | { |
| 842 | #define PHY_ERR(s, p) \ |
| 843 | len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \ |
| 844 | sc->debug.stats.rxstats.phy_err_stats[p]); |
| 845 | |
| 846 | struct ath_softc *sc = file->private_data; |
| 847 | char *buf; |
Senthil Balasubramanian | 7d75541 | 2011-04-08 15:30:34 +0530 | [diff] [blame] | 848 | unsigned int len = 0, size = 1400; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 849 | ssize_t retval = 0; |
| 850 | |
| 851 | buf = kzalloc(size, GFP_KERNEL); |
| 852 | if (buf == NULL) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 853 | return -ENOMEM; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 854 | |
| 855 | len += snprintf(buf + len, size - len, |
| 856 | "%18s : %10u\n", "CRC ERR", |
| 857 | sc->debug.stats.rxstats.crc_err); |
| 858 | len += snprintf(buf + len, size - len, |
| 859 | "%18s : %10u\n", "DECRYPT CRC ERR", |
| 860 | sc->debug.stats.rxstats.decrypt_crc_err); |
| 861 | len += snprintf(buf + len, size - len, |
| 862 | "%18s : %10u\n", "PHY ERR", |
| 863 | sc->debug.stats.rxstats.phy_err); |
| 864 | len += snprintf(buf + len, size - len, |
| 865 | "%18s : %10u\n", "MIC ERR", |
| 866 | sc->debug.stats.rxstats.mic_err); |
| 867 | len += snprintf(buf + len, size - len, |
| 868 | "%18s : %10u\n", "PRE-DELIM CRC ERR", |
| 869 | sc->debug.stats.rxstats.pre_delim_crc_err); |
| 870 | len += snprintf(buf + len, size - len, |
| 871 | "%18s : %10u\n", "POST-DELIM CRC ERR", |
| 872 | sc->debug.stats.rxstats.post_delim_crc_err); |
| 873 | len += snprintf(buf + len, size - len, |
| 874 | "%18s : %10u\n", "DECRYPT BUSY ERR", |
| 875 | sc->debug.stats.rxstats.decrypt_busy_err); |
| 876 | |
Senthil Balasubramanian | 7d75541 | 2011-04-08 15:30:34 +0530 | [diff] [blame] | 877 | len += snprintf(buf + len, size - len, |
| 878 | "%18s : %10d\n", "RSSI-CTL0", |
| 879 | sc->debug.stats.rxstats.rs_rssi_ctl0); |
| 880 | |
| 881 | len += snprintf(buf + len, size - len, |
| 882 | "%18s : %10d\n", "RSSI-CTL1", |
| 883 | sc->debug.stats.rxstats.rs_rssi_ctl1); |
| 884 | |
| 885 | len += snprintf(buf + len, size - len, |
| 886 | "%18s : %10d\n", "RSSI-CTL2", |
| 887 | sc->debug.stats.rxstats.rs_rssi_ctl2); |
| 888 | |
| 889 | len += snprintf(buf + len, size - len, |
| 890 | "%18s : %10d\n", "RSSI-EXT0", |
| 891 | sc->debug.stats.rxstats.rs_rssi_ext0); |
| 892 | |
| 893 | len += snprintf(buf + len, size - len, |
| 894 | "%18s : %10d\n", "RSSI-EXT1", |
| 895 | sc->debug.stats.rxstats.rs_rssi_ext1); |
| 896 | |
| 897 | len += snprintf(buf + len, size - len, |
| 898 | "%18s : %10d\n", "RSSI-EXT2", |
| 899 | sc->debug.stats.rxstats.rs_rssi_ext2); |
| 900 | |
| 901 | len += snprintf(buf + len, size - len, |
| 902 | "%18s : %10d\n", "Rx Antenna", |
| 903 | sc->debug.stats.rxstats.rs_antenna); |
| 904 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 905 | PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN); |
| 906 | PHY_ERR("TIMING", ATH9K_PHYERR_TIMING); |
| 907 | PHY_ERR("PARITY", ATH9K_PHYERR_PARITY); |
| 908 | PHY_ERR("RATE", ATH9K_PHYERR_RATE); |
| 909 | PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH); |
| 910 | PHY_ERR("RADAR", ATH9K_PHYERR_RADAR); |
| 911 | PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE); |
| 912 | PHY_ERR("TOR", ATH9K_PHYERR_TOR); |
| 913 | PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING); |
| 914 | PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); |
| 915 | PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); |
| 916 | PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); |
| 917 | PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP); |
| 918 | PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE); |
| 919 | PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART); |
| 920 | PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT); |
| 921 | PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING); |
| 922 | PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC); |
| 923 | PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL); |
| 924 | PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE); |
| 925 | PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART); |
| 926 | PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); |
| 927 | PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP); |
| 928 | PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR); |
| 929 | PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); |
| 930 | PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL); |
| 931 | |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 932 | len += snprintf(buf + len, size - len, |
| 933 | "%18s : %10u\n", "RX-Pkts-All", |
| 934 | sc->debug.stats.rxstats.rx_pkts_all); |
| 935 | len += snprintf(buf + len, size - len, |
| 936 | "%18s : %10u\n", "RX-Bytes-All", |
| 937 | sc->debug.stats.rxstats.rx_bytes_all); |
| 938 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 939 | if (len > size) |
| 940 | len = size; |
| 941 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 942 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 943 | kfree(buf); |
| 944 | |
| 945 | return retval; |
| 946 | |
| 947 | #undef PHY_ERR |
| 948 | } |
| 949 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 950 | 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] | 951 | { |
| 952 | #define RX_STAT_INC(c) sc->debug.stats.rxstats.c++ |
| 953 | #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++ |
| 954 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 955 | u32 phyerr; |
| 956 | |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 957 | RX_STAT_INC(rx_pkts_all); |
| 958 | sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; |
| 959 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 960 | if (rs->rs_status & ATH9K_RXERR_CRC) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 961 | RX_STAT_INC(crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 962 | if (rs->rs_status & ATH9K_RXERR_DECRYPT) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 963 | RX_STAT_INC(decrypt_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 964 | if (rs->rs_status & ATH9K_RXERR_MIC) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 965 | RX_STAT_INC(mic_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 966 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 967 | RX_STAT_INC(pre_delim_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 968 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 969 | RX_STAT_INC(post_delim_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 970 | if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 971 | RX_STAT_INC(decrypt_busy_err); |
| 972 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 973 | if (rs->rs_status & ATH9K_RXERR_PHY) { |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 974 | RX_STAT_INC(phy_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 975 | phyerr = rs->rs_phyerr & 0x24; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 976 | RX_PHY_ERR_INC(phyerr); |
| 977 | } |
| 978 | |
Senthil Balasubramanian | 7d75541 | 2011-04-08 15:30:34 +0530 | [diff] [blame] | 979 | sc->debug.stats.rxstats.rs_rssi_ctl0 = rs->rs_rssi_ctl0; |
| 980 | sc->debug.stats.rxstats.rs_rssi_ctl1 = rs->rs_rssi_ctl1; |
| 981 | sc->debug.stats.rxstats.rs_rssi_ctl2 = rs->rs_rssi_ctl2; |
| 982 | |
| 983 | sc->debug.stats.rxstats.rs_rssi_ext0 = rs->rs_rssi_ext0; |
| 984 | sc->debug.stats.rxstats.rs_rssi_ext1 = rs->rs_rssi_ext1; |
| 985 | sc->debug.stats.rxstats.rs_rssi_ext2 = rs->rs_rssi_ext2; |
| 986 | |
| 987 | sc->debug.stats.rxstats.rs_antenna = rs->rs_antenna; |
| 988 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 989 | #undef RX_STAT_INC |
| 990 | #undef RX_PHY_ERR_INC |
| 991 | } |
| 992 | |
| 993 | static const struct file_operations fops_recv = { |
| 994 | .read = read_file_recv, |
| 995 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 996 | .owner = THIS_MODULE, |
| 997 | .llseek = default_llseek, |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 998 | }; |
| 999 | |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1000 | static ssize_t read_file_regidx(struct file *file, char __user *user_buf, |
| 1001 | size_t count, loff_t *ppos) |
| 1002 | { |
| 1003 | struct ath_softc *sc = file->private_data; |
| 1004 | char buf[32]; |
| 1005 | unsigned int len; |
| 1006 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 1007 | len = sprintf(buf, "0x%08x\n", sc->debug.regidx); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1008 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1009 | } |
| 1010 | |
| 1011 | static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, |
| 1012 | size_t count, loff_t *ppos) |
| 1013 | { |
| 1014 | struct ath_softc *sc = file->private_data; |
| 1015 | unsigned long regidx; |
| 1016 | char buf[32]; |
| 1017 | ssize_t len; |
| 1018 | |
| 1019 | len = min(count, sizeof(buf) - 1); |
| 1020 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 1021 | return -EFAULT; |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1022 | |
| 1023 | buf[len] = '\0'; |
| 1024 | if (strict_strtoul(buf, 0, ®idx)) |
| 1025 | return -EINVAL; |
| 1026 | |
| 1027 | sc->debug.regidx = regidx; |
| 1028 | return count; |
| 1029 | } |
| 1030 | |
| 1031 | static const struct file_operations fops_regidx = { |
| 1032 | .read = read_file_regidx, |
| 1033 | .write = write_file_regidx, |
| 1034 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1035 | .owner = THIS_MODULE, |
| 1036 | .llseek = default_llseek, |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1037 | }; |
| 1038 | |
| 1039 | static ssize_t read_file_regval(struct file *file, char __user *user_buf, |
| 1040 | size_t count, loff_t *ppos) |
| 1041 | { |
| 1042 | struct ath_softc *sc = file->private_data; |
| 1043 | struct ath_hw *ah = sc->sc_ah; |
| 1044 | char buf[32]; |
| 1045 | unsigned int len; |
| 1046 | u32 regval; |
| 1047 | |
| 1048 | regval = REG_READ_D(ah, sc->debug.regidx); |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 1049 | len = sprintf(buf, "0x%08x\n", regval); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1050 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1051 | } |
| 1052 | |
| 1053 | static ssize_t write_file_regval(struct file *file, const char __user *user_buf, |
| 1054 | size_t count, loff_t *ppos) |
| 1055 | { |
| 1056 | struct ath_softc *sc = file->private_data; |
| 1057 | struct ath_hw *ah = sc->sc_ah; |
| 1058 | unsigned long regval; |
| 1059 | char buf[32]; |
| 1060 | ssize_t len; |
| 1061 | |
| 1062 | len = min(count, sizeof(buf) - 1); |
| 1063 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 1064 | return -EFAULT; |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1065 | |
| 1066 | buf[len] = '\0'; |
| 1067 | if (strict_strtoul(buf, 0, ®val)) |
| 1068 | return -EINVAL; |
| 1069 | |
| 1070 | REG_WRITE_D(ah, sc->debug.regidx, regval); |
| 1071 | return count; |
| 1072 | } |
| 1073 | |
| 1074 | static const struct file_operations fops_regval = { |
| 1075 | .read = read_file_regval, |
| 1076 | .write = write_file_regval, |
| 1077 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1078 | .owner = THIS_MODULE, |
| 1079 | .llseek = default_llseek, |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1080 | }; |
| 1081 | |
Vasanthakumar Thiagarajan | 582d006 | 2011-03-01 05:30:55 -0800 | [diff] [blame] | 1082 | #define REGDUMP_LINE_SIZE 20 |
| 1083 | |
| 1084 | static int open_file_regdump(struct inode *inode, struct file *file) |
| 1085 | { |
| 1086 | struct ath_softc *sc = inode->i_private; |
| 1087 | unsigned int len = 0; |
| 1088 | u8 *buf; |
| 1089 | int i; |
| 1090 | unsigned long num_regs, regdump_len, max_reg_offset; |
| 1091 | |
| 1092 | max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500; |
| 1093 | num_regs = max_reg_offset / 4 + 1; |
| 1094 | regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; |
| 1095 | buf = vmalloc(regdump_len); |
| 1096 | if (!buf) |
| 1097 | return -ENOMEM; |
| 1098 | |
| 1099 | ath9k_ps_wakeup(sc); |
| 1100 | for (i = 0; i < num_regs; i++) |
| 1101 | len += scnprintf(buf + len, regdump_len - len, |
| 1102 | "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); |
| 1103 | ath9k_ps_restore(sc); |
| 1104 | |
| 1105 | file->private_data = buf; |
| 1106 | |
| 1107 | return 0; |
| 1108 | } |
| 1109 | |
| 1110 | static const struct file_operations fops_regdump = { |
| 1111 | .open = open_file_regdump, |
| 1112 | .read = ath9k_debugfs_read_buf, |
| 1113 | .release = ath9k_debugfs_release_buf, |
| 1114 | .owner = THIS_MODULE, |
| 1115 | .llseek = default_llseek,/* read accesses f_pos */ |
| 1116 | }; |
| 1117 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1118 | int ath9k_init_debug(struct ath_hw *ah) |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1119 | { |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 1120 | struct ath_common *common = ath9k_hw_common(ah); |
| 1121 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1122 | |
Ben Greear | eb27244 | 2010-11-29 14:13:22 -0800 | [diff] [blame] | 1123 | sc->debug.debugfs_phy = debugfs_create_dir("ath9k", |
| 1124 | sc->hw->wiphy->debugfsdir); |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 1125 | if (!sc->debug.debugfs_phy) |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 1126 | return -ENOMEM; |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 1127 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 1128 | #ifdef CONFIG_ATH_DEBUG |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1129 | debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1130 | sc, &fops_debug); |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 1131 | #endif |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1132 | debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1133 | &fops_dma); |
| 1134 | debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1135 | &fops_interrupt); |
| 1136 | debugfs_create_file("wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1137 | sc, &fops_wiphy); |
| 1138 | debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1139 | &fops_xmit); |
| 1140 | debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1141 | &fops_stations); |
| 1142 | debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1143 | &fops_misc); |
| 1144 | debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1145 | &fops_recv); |
| 1146 | debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, |
| 1147 | sc->debug.debugfs_phy, sc, &fops_rx_chainmask); |
| 1148 | debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, |
| 1149 | sc->debug.debugfs_phy, sc, &fops_tx_chainmask); |
| 1150 | debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1151 | sc, &fops_regidx); |
| 1152 | debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1153 | sc, &fops_regval); |
| 1154 | debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, |
| 1155 | sc->debug.debugfs_phy, |
| 1156 | &ah->config.cwm_ignore_extcca); |
| 1157 | debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1158 | &fops_regdump); |
Vasanthakumar Thiagarajan | 582d006 | 2011-03-01 05:30:55 -0800 | [diff] [blame] | 1159 | |
Felix Fietkau | 691680b | 2011-03-19 13:55:38 +0100 | [diff] [blame] | 1160 | debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, |
| 1161 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); |
| 1162 | |
| 1163 | debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, |
| 1164 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); |
| 1165 | |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1166 | sc->debug.regidx = 0; |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 1167 | return 0; |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1168 | } |