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