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 | |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 384 | static const char * ath_wiphy_state_str(enum ath_wiphy_state state) |
| 385 | { |
| 386 | switch (state) { |
| 387 | case ATH_WIPHY_INACTIVE: |
| 388 | return "INACTIVE"; |
| 389 | case ATH_WIPHY_ACTIVE: |
| 390 | return "ACTIVE"; |
| 391 | case ATH_WIPHY_PAUSING: |
| 392 | return "PAUSING"; |
| 393 | case ATH_WIPHY_PAUSED: |
| 394 | return "PAUSED"; |
| 395 | case ATH_WIPHY_SCAN: |
| 396 | return "SCAN"; |
| 397 | } |
| 398 | return "?"; |
| 399 | } |
| 400 | |
| 401 | static ssize_t read_file_wiphy(struct file *file, char __user *user_buf, |
| 402 | size_t count, loff_t *ppos) |
| 403 | { |
| 404 | struct ath_softc *sc = file->private_data; |
Mohammed Shafi Shajakhan | 8e0167a | 2010-10-01 15:25:05 +0530 | [diff] [blame] | 405 | struct ath_wiphy *aphy = sc->pri_wiphy; |
| 406 | struct ieee80211_channel *chan = aphy->hw->conf.channel; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 407 | char buf[512]; |
| 408 | unsigned int len = 0; |
| 409 | int i; |
| 410 | u8 addr[ETH_ALEN]; |
Ben Greear | 3905751 | 2010-09-14 12:46:04 -0700 | [diff] [blame] | 411 | u32 tmp; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 412 | |
| 413 | len += snprintf(buf + len, sizeof(buf) - len, |
| 414 | "primary: %s (%s chan=%d ht=%d)\n", |
| 415 | wiphy_name(sc->pri_wiphy->hw->wiphy), |
| 416 | ath_wiphy_state_str(sc->pri_wiphy->state), |
Mohammed Shafi Shajakhan | 8e0167a | 2010-10-01 15:25:05 +0530 | [diff] [blame] | 417 | ieee80211_frequency_to_channel(chan->center_freq), |
| 418 | aphy->chan_is_ht); |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 419 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 420 | put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr); |
| 421 | 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] | 422 | len += snprintf(buf + len, sizeof(buf) - len, |
| 423 | "addr: %pM\n", addr); |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 424 | put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr); |
| 425 | 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] | 426 | len += snprintf(buf + len, sizeof(buf) - len, |
| 427 | "addrmask: %pM\n", addr); |
Ben Greear | 3905751 | 2010-09-14 12:46:04 -0700 | [diff] [blame] | 428 | tmp = ath9k_hw_getrxfilter(sc->sc_ah); |
| 429 | len += snprintf(buf + len, sizeof(buf) - len, |
| 430 | "rfilt: 0x%x", tmp); |
| 431 | if (tmp & ATH9K_RX_FILTER_UCAST) |
| 432 | len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); |
| 433 | if (tmp & ATH9K_RX_FILTER_MCAST) |
| 434 | len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); |
| 435 | if (tmp & ATH9K_RX_FILTER_BCAST) |
| 436 | len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); |
| 437 | if (tmp & ATH9K_RX_FILTER_CONTROL) |
| 438 | len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); |
| 439 | if (tmp & ATH9K_RX_FILTER_BEACON) |
| 440 | len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); |
| 441 | if (tmp & ATH9K_RX_FILTER_PROM) |
| 442 | len += snprintf(buf + len, sizeof(buf) - len, " PROM"); |
| 443 | if (tmp & ATH9K_RX_FILTER_PROBEREQ) |
| 444 | len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); |
| 445 | if (tmp & ATH9K_RX_FILTER_PHYERR) |
| 446 | len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); |
| 447 | if (tmp & ATH9K_RX_FILTER_MYBEACON) |
| 448 | len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); |
| 449 | if (tmp & ATH9K_RX_FILTER_COMP_BAR) |
| 450 | len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); |
| 451 | if (tmp & ATH9K_RX_FILTER_PSPOLL) |
| 452 | len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); |
| 453 | if (tmp & ATH9K_RX_FILTER_PHYRADAR) |
| 454 | len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); |
| 455 | if (tmp & ATH9K_RX_FILTER_MCAST_BCAST_ALL) |
| 456 | len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL\n"); |
| 457 | else |
| 458 | len += snprintf(buf + len, sizeof(buf) - len, "\n"); |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 459 | |
Ben Greear | 3905751 | 2010-09-14 12:46:04 -0700 | [diff] [blame] | 460 | /* Put variable-length stuff down here, and check for overflows. */ |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 461 | for (i = 0; i < sc->num_sec_wiphy; i++) { |
Luis R. Rodriguez | 191d6a1 | 2010-10-15 13:27:49 -0700 | [diff] [blame] | 462 | struct ath_wiphy *aphy_tmp = sc->sec_wiphy[i]; |
| 463 | if (aphy_tmp == NULL) |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 464 | continue; |
Luis R. Rodriguez | 191d6a1 | 2010-10-15 13:27:49 -0700 | [diff] [blame] | 465 | chan = aphy_tmp->hw->conf.channel; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 466 | len += snprintf(buf + len, sizeof(buf) - len, |
Mohammed Shafi Shajakhan | 8e0167a | 2010-10-01 15:25:05 +0530 | [diff] [blame] | 467 | "secondary: %s (%s chan=%d ht=%d)\n", |
Luis R. Rodriguez | 191d6a1 | 2010-10-15 13:27:49 -0700 | [diff] [blame] | 468 | wiphy_name(aphy_tmp->hw->wiphy), |
| 469 | ath_wiphy_state_str(aphy_tmp->state), |
Mohammed Shafi Shajakhan | 8e0167a | 2010-10-01 15:25:05 +0530 | [diff] [blame] | 470 | ieee80211_frequency_to_channel(chan->center_freq), |
Luis R. Rodriguez | 191d6a1 | 2010-10-15 13:27:49 -0700 | [diff] [blame] | 471 | aphy_tmp->chan_is_ht); |
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 | |
| 479 | static struct ath_wiphy * get_wiphy(struct ath_softc *sc, const char *name) |
| 480 | { |
| 481 | int i; |
| 482 | if (strcmp(name, wiphy_name(sc->pri_wiphy->hw->wiphy)) == 0) |
| 483 | return sc->pri_wiphy; |
| 484 | for (i = 0; i < sc->num_sec_wiphy; i++) { |
| 485 | struct ath_wiphy *aphy = sc->sec_wiphy[i]; |
| 486 | if (aphy && strcmp(name, wiphy_name(aphy->hw->wiphy)) == 0) |
| 487 | return aphy; |
| 488 | } |
| 489 | return NULL; |
| 490 | } |
| 491 | |
| 492 | static int del_wiphy(struct ath_softc *sc, const char *name) |
| 493 | { |
| 494 | struct ath_wiphy *aphy = get_wiphy(sc, name); |
| 495 | if (!aphy) |
| 496 | return -ENOENT; |
| 497 | return ath9k_wiphy_del(aphy); |
| 498 | } |
| 499 | |
| 500 | static int pause_wiphy(struct ath_softc *sc, const char *name) |
| 501 | { |
| 502 | struct ath_wiphy *aphy = get_wiphy(sc, name); |
| 503 | if (!aphy) |
| 504 | return -ENOENT; |
| 505 | return ath9k_wiphy_pause(aphy); |
| 506 | } |
| 507 | |
| 508 | static int unpause_wiphy(struct ath_softc *sc, const char *name) |
| 509 | { |
| 510 | struct ath_wiphy *aphy = get_wiphy(sc, name); |
| 511 | if (!aphy) |
| 512 | return -ENOENT; |
| 513 | return ath9k_wiphy_unpause(aphy); |
| 514 | } |
| 515 | |
| 516 | static int select_wiphy(struct ath_softc *sc, const char *name) |
| 517 | { |
| 518 | struct ath_wiphy *aphy = get_wiphy(sc, name); |
| 519 | if (!aphy) |
| 520 | return -ENOENT; |
| 521 | return ath9k_wiphy_select(aphy); |
| 522 | } |
| 523 | |
| 524 | static int schedule_wiphy(struct ath_softc *sc, const char *msec) |
| 525 | { |
| 526 | ath9k_wiphy_set_scheduler(sc, simple_strtoul(msec, NULL, 0)); |
| 527 | return 0; |
| 528 | } |
| 529 | |
| 530 | static ssize_t write_file_wiphy(struct file *file, const char __user *user_buf, |
| 531 | size_t count, loff_t *ppos) |
| 532 | { |
| 533 | struct ath_softc *sc = file->private_data; |
| 534 | char buf[50]; |
| 535 | size_t len; |
| 536 | |
| 537 | len = min(count, sizeof(buf) - 1); |
| 538 | if (copy_from_user(buf, user_buf, len)) |
| 539 | return -EFAULT; |
| 540 | buf[len] = '\0'; |
| 541 | if (len > 0 && buf[len - 1] == '\n') |
| 542 | buf[len - 1] = '\0'; |
| 543 | |
| 544 | if (strncmp(buf, "add", 3) == 0) { |
| 545 | int res = ath9k_wiphy_add(sc); |
| 546 | if (res < 0) |
| 547 | return res; |
| 548 | } else if (strncmp(buf, "del=", 4) == 0) { |
| 549 | int res = del_wiphy(sc, buf + 4); |
| 550 | if (res < 0) |
| 551 | return res; |
| 552 | } else if (strncmp(buf, "pause=", 6) == 0) { |
| 553 | int res = pause_wiphy(sc, buf + 6); |
| 554 | if (res < 0) |
| 555 | return res; |
| 556 | } else if (strncmp(buf, "unpause=", 8) == 0) { |
| 557 | int res = unpause_wiphy(sc, buf + 8); |
| 558 | if (res < 0) |
| 559 | return res; |
| 560 | } else if (strncmp(buf, "select=", 7) == 0) { |
| 561 | int res = select_wiphy(sc, buf + 7); |
| 562 | if (res < 0) |
| 563 | return res; |
| 564 | } else if (strncmp(buf, "schedule=", 9) == 0) { |
| 565 | int res = schedule_wiphy(sc, buf + 9); |
| 566 | if (res < 0) |
| 567 | return res; |
| 568 | } else |
| 569 | return -EOPNOTSUPP; |
| 570 | |
| 571 | return count; |
| 572 | } |
| 573 | |
| 574 | static const struct file_operations fops_wiphy = { |
| 575 | .read = read_file_wiphy, |
| 576 | .write = write_file_wiphy, |
| 577 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 578 | .owner = THIS_MODULE, |
| 579 | .llseek = default_llseek, |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 580 | }; |
| 581 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 582 | #define PR(str, elem) \ |
| 583 | do { \ |
| 584 | len += snprintf(buf + len, size - len, \ |
| 585 | "%s%13u%11u%10u%10u\n", str, \ |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 586 | sc->debug.stats.txstats[WME_AC_BE].elem, \ |
| 587 | sc->debug.stats.txstats[WME_AC_BK].elem, \ |
| 588 | sc->debug.stats.txstats[WME_AC_VI].elem, \ |
| 589 | sc->debug.stats.txstats[WME_AC_VO].elem); \ |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 590 | } while(0) |
| 591 | |
| 592 | static ssize_t read_file_xmit(struct file *file, char __user *user_buf, |
| 593 | size_t count, loff_t *ppos) |
| 594 | { |
| 595 | struct ath_softc *sc = file->private_data; |
| 596 | char *buf; |
| 597 | unsigned int len = 0, size = 2048; |
| 598 | ssize_t retval = 0; |
| 599 | |
| 600 | buf = kzalloc(size, GFP_KERNEL); |
| 601 | if (buf == NULL) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 602 | return -ENOMEM; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 603 | |
| 604 | len += sprintf(buf, "%30s %10s%10s%10s\n\n", "BE", "BK", "VI", "VO"); |
| 605 | |
| 606 | PR("MPDUs Queued: ", queued); |
| 607 | PR("MPDUs Completed: ", completed); |
| 608 | PR("Aggregates: ", a_aggr); |
| 609 | PR("AMPDUs Queued: ", a_queued); |
| 610 | PR("AMPDUs Completed:", a_completed); |
| 611 | PR("AMPDUs Retried: ", a_retries); |
| 612 | PR("AMPDUs XRetried: ", a_xretries); |
| 613 | PR("FIFO Underrun: ", fifo_underrun); |
| 614 | PR("TXOP Exceeded: ", xtxop); |
| 615 | PR("TXTIMER Expiry: ", timer_exp); |
| 616 | PR("DESC CFG Error: ", desc_cfg_err); |
| 617 | PR("DATA Underrun: ", data_underrun); |
| 618 | PR("DELIM Underrun: ", delim_underrun); |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 619 | PR("TX-Pkts-All: ", tx_pkts_all); |
| 620 | PR("TX-Bytes-All: ", tx_bytes_all); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 621 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 622 | if (len > size) |
| 623 | len = size; |
| 624 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 625 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 626 | kfree(buf); |
| 627 | |
| 628 | return retval; |
| 629 | } |
| 630 | |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 631 | void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, |
| 632 | struct ath_tx_status *ts) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 633 | { |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 634 | int qnum = skb_get_queue_mapping(bf->bf_mpdu); |
| 635 | |
| 636 | TX_STAT_INC(qnum, tx_pkts_all); |
| 637 | sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 638 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 639 | if (bf_isampdu(bf)) { |
| 640 | if (bf_isxretried(bf)) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 641 | TX_STAT_INC(qnum, a_xretries); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 642 | else |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 643 | TX_STAT_INC(qnum, a_completed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 644 | } else { |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 645 | TX_STAT_INC(qnum, completed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 646 | } |
| 647 | |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 648 | if (ts->ts_status & ATH9K_TXERR_FIFO) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 649 | TX_STAT_INC(qnum, fifo_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 650 | if (ts->ts_status & ATH9K_TXERR_XTXOP) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 651 | TX_STAT_INC(qnum, xtxop); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 652 | if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 653 | TX_STAT_INC(qnum, timer_exp); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 654 | if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 655 | TX_STAT_INC(qnum, desc_cfg_err); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 656 | if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 657 | TX_STAT_INC(qnum, data_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 658 | if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 659 | TX_STAT_INC(qnum, delim_underrun); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | static const struct file_operations fops_xmit = { |
| 663 | .read = read_file_xmit, |
| 664 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 665 | .owner = THIS_MODULE, |
| 666 | .llseek = default_llseek, |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 667 | }; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 668 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 669 | static ssize_t read_file_recv(struct file *file, char __user *user_buf, |
| 670 | size_t count, loff_t *ppos) |
| 671 | { |
| 672 | #define PHY_ERR(s, p) \ |
| 673 | len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \ |
| 674 | sc->debug.stats.rxstats.phy_err_stats[p]); |
| 675 | |
| 676 | struct ath_softc *sc = file->private_data; |
| 677 | char *buf; |
| 678 | unsigned int len = 0, size = 1152; |
| 679 | ssize_t retval = 0; |
| 680 | |
| 681 | buf = kzalloc(size, GFP_KERNEL); |
| 682 | if (buf == NULL) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 683 | return -ENOMEM; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 684 | |
| 685 | len += snprintf(buf + len, size - len, |
| 686 | "%18s : %10u\n", "CRC ERR", |
| 687 | sc->debug.stats.rxstats.crc_err); |
| 688 | len += snprintf(buf + len, size - len, |
| 689 | "%18s : %10u\n", "DECRYPT CRC ERR", |
| 690 | sc->debug.stats.rxstats.decrypt_crc_err); |
| 691 | len += snprintf(buf + len, size - len, |
| 692 | "%18s : %10u\n", "PHY ERR", |
| 693 | sc->debug.stats.rxstats.phy_err); |
| 694 | len += snprintf(buf + len, size - len, |
| 695 | "%18s : %10u\n", "MIC ERR", |
| 696 | sc->debug.stats.rxstats.mic_err); |
| 697 | len += snprintf(buf + len, size - len, |
| 698 | "%18s : %10u\n", "PRE-DELIM CRC ERR", |
| 699 | sc->debug.stats.rxstats.pre_delim_crc_err); |
| 700 | len += snprintf(buf + len, size - len, |
| 701 | "%18s : %10u\n", "POST-DELIM CRC ERR", |
| 702 | sc->debug.stats.rxstats.post_delim_crc_err); |
| 703 | len += snprintf(buf + len, size - len, |
| 704 | "%18s : %10u\n", "DECRYPT BUSY ERR", |
| 705 | sc->debug.stats.rxstats.decrypt_busy_err); |
| 706 | |
| 707 | PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN); |
| 708 | PHY_ERR("TIMING", ATH9K_PHYERR_TIMING); |
| 709 | PHY_ERR("PARITY", ATH9K_PHYERR_PARITY); |
| 710 | PHY_ERR("RATE", ATH9K_PHYERR_RATE); |
| 711 | PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH); |
| 712 | PHY_ERR("RADAR", ATH9K_PHYERR_RADAR); |
| 713 | PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE); |
| 714 | PHY_ERR("TOR", ATH9K_PHYERR_TOR); |
| 715 | PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING); |
| 716 | PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); |
| 717 | PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); |
| 718 | PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); |
| 719 | PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP); |
| 720 | PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE); |
| 721 | PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART); |
| 722 | PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT); |
| 723 | PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING); |
| 724 | PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC); |
| 725 | PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL); |
| 726 | PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE); |
| 727 | PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART); |
| 728 | PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); |
| 729 | PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP); |
| 730 | PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR); |
| 731 | PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); |
| 732 | PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL); |
| 733 | |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 734 | len += snprintf(buf + len, size - len, |
| 735 | "%18s : %10u\n", "RX-Pkts-All", |
| 736 | sc->debug.stats.rxstats.rx_pkts_all); |
| 737 | len += snprintf(buf + len, size - len, |
| 738 | "%18s : %10u\n", "RX-Bytes-All", |
| 739 | sc->debug.stats.rxstats.rx_bytes_all); |
| 740 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 741 | if (len > size) |
| 742 | len = size; |
| 743 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 744 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 745 | kfree(buf); |
| 746 | |
| 747 | return retval; |
| 748 | |
| 749 | #undef PHY_ERR |
| 750 | } |
| 751 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 752 | 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] | 753 | { |
| 754 | #define RX_STAT_INC(c) sc->debug.stats.rxstats.c++ |
| 755 | #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++ |
| 756 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 757 | u32 phyerr; |
| 758 | |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 759 | RX_STAT_INC(rx_pkts_all); |
| 760 | sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; |
| 761 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 762 | if (rs->rs_status & ATH9K_RXERR_CRC) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 763 | RX_STAT_INC(crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 764 | if (rs->rs_status & ATH9K_RXERR_DECRYPT) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 765 | RX_STAT_INC(decrypt_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 766 | if (rs->rs_status & ATH9K_RXERR_MIC) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 767 | RX_STAT_INC(mic_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 768 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 769 | RX_STAT_INC(pre_delim_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 770 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 771 | RX_STAT_INC(post_delim_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 772 | if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 773 | RX_STAT_INC(decrypt_busy_err); |
| 774 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 775 | if (rs->rs_status & ATH9K_RXERR_PHY) { |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 776 | RX_STAT_INC(phy_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 777 | phyerr = rs->rs_phyerr & 0x24; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 778 | RX_PHY_ERR_INC(phyerr); |
| 779 | } |
| 780 | |
| 781 | #undef RX_STAT_INC |
| 782 | #undef RX_PHY_ERR_INC |
| 783 | } |
| 784 | |
| 785 | static const struct file_operations fops_recv = { |
| 786 | .read = read_file_recv, |
| 787 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 788 | .owner = THIS_MODULE, |
| 789 | .llseek = default_llseek, |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 790 | }; |
| 791 | |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 792 | static ssize_t read_file_regidx(struct file *file, char __user *user_buf, |
| 793 | size_t count, loff_t *ppos) |
| 794 | { |
| 795 | struct ath_softc *sc = file->private_data; |
| 796 | char buf[32]; |
| 797 | unsigned int len; |
| 798 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 799 | len = sprintf(buf, "0x%08x\n", sc->debug.regidx); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 800 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 801 | } |
| 802 | |
| 803 | static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, |
| 804 | size_t count, loff_t *ppos) |
| 805 | { |
| 806 | struct ath_softc *sc = file->private_data; |
| 807 | unsigned long regidx; |
| 808 | char buf[32]; |
| 809 | ssize_t len; |
| 810 | |
| 811 | len = min(count, sizeof(buf) - 1); |
| 812 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 813 | return -EFAULT; |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 814 | |
| 815 | buf[len] = '\0'; |
| 816 | if (strict_strtoul(buf, 0, ®idx)) |
| 817 | return -EINVAL; |
| 818 | |
| 819 | sc->debug.regidx = regidx; |
| 820 | return count; |
| 821 | } |
| 822 | |
| 823 | static const struct file_operations fops_regidx = { |
| 824 | .read = read_file_regidx, |
| 825 | .write = write_file_regidx, |
| 826 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 827 | .owner = THIS_MODULE, |
| 828 | .llseek = default_llseek, |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 829 | }; |
| 830 | |
| 831 | static ssize_t read_file_regval(struct file *file, char __user *user_buf, |
| 832 | size_t count, loff_t *ppos) |
| 833 | { |
| 834 | struct ath_softc *sc = file->private_data; |
| 835 | struct ath_hw *ah = sc->sc_ah; |
| 836 | char buf[32]; |
| 837 | unsigned int len; |
| 838 | u32 regval; |
| 839 | |
| 840 | regval = REG_READ_D(ah, sc->debug.regidx); |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 841 | len = sprintf(buf, "0x%08x\n", regval); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 842 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 843 | } |
| 844 | |
| 845 | static ssize_t write_file_regval(struct file *file, const char __user *user_buf, |
| 846 | size_t count, loff_t *ppos) |
| 847 | { |
| 848 | struct ath_softc *sc = file->private_data; |
| 849 | struct ath_hw *ah = sc->sc_ah; |
| 850 | unsigned long regval; |
| 851 | char buf[32]; |
| 852 | ssize_t len; |
| 853 | |
| 854 | len = min(count, sizeof(buf) - 1); |
| 855 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 856 | return -EFAULT; |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 857 | |
| 858 | buf[len] = '\0'; |
| 859 | if (strict_strtoul(buf, 0, ®val)) |
| 860 | return -EINVAL; |
| 861 | |
| 862 | REG_WRITE_D(ah, sc->debug.regidx, regval); |
| 863 | return count; |
| 864 | } |
| 865 | |
| 866 | static const struct file_operations fops_regval = { |
| 867 | .read = read_file_regval, |
| 868 | .write = write_file_regval, |
| 869 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 870 | .owner = THIS_MODULE, |
| 871 | .llseek = default_llseek, |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 872 | }; |
| 873 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 874 | int ath9k_init_debug(struct ath_hw *ah) |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 875 | { |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 876 | struct ath_common *common = ath9k_hw_common(ah); |
| 877 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 878 | |
Ben Greear | eb27244 | 2010-11-29 14:13:22 -0800 | [diff] [blame^] | 879 | sc->debug.debugfs_phy = debugfs_create_dir("ath9k", |
| 880 | sc->hw->wiphy->debugfsdir); |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 881 | if (!sc->debug.debugfs_phy) |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 882 | return -ENOMEM; |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 883 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 884 | #ifdef CONFIG_ATH_DEBUG |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 885 | if (!debugfs_create_file("debug", S_IRUSR | S_IWUSR, |
| 886 | sc->debug.debugfs_phy, sc, &fops_debug)) |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 887 | goto err; |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 888 | #endif |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 889 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 890 | if (!debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, |
| 891 | sc, &fops_dma)) |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 892 | goto err; |
| 893 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 894 | if (!debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, |
| 895 | sc, &fops_interrupt)) |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 896 | goto err; |
| 897 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 898 | if (!debugfs_create_file("wiphy", S_IRUSR | S_IWUSR, |
| 899 | sc->debug.debugfs_phy, sc, &fops_wiphy)) |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 900 | goto err; |
| 901 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 902 | if (!debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, |
| 903 | sc, &fops_xmit)) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 904 | goto err; |
| 905 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 906 | if (!debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, |
| 907 | sc, &fops_recv)) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 908 | goto err; |
| 909 | |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 910 | if (!debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, |
| 911 | sc->debug.debugfs_phy, sc, &fops_rx_chainmask)) |
| 912 | goto err; |
| 913 | |
| 914 | if (!debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, |
| 915 | sc->debug.debugfs_phy, sc, &fops_tx_chainmask)) |
| 916 | goto err; |
| 917 | |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 918 | if (!debugfs_create_file("regidx", S_IRUSR | S_IWUSR, |
| 919 | sc->debug.debugfs_phy, sc, &fops_regidx)) |
| 920 | goto err; |
| 921 | |
| 922 | if (!debugfs_create_file("regval", S_IRUSR | S_IWUSR, |
| 923 | sc->debug.debugfs_phy, sc, &fops_regval)) |
| 924 | goto err; |
| 925 | |
Felix Fietkau | 41f3e54 | 2010-06-12 00:33:56 -0400 | [diff] [blame] | 926 | if (!debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, |
| 927 | sc->debug.debugfs_phy, &ah->config.cwm_ignore_extcca)) |
| 928 | goto err; |
| 929 | |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 930 | sc->debug.regidx = 0; |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 931 | return 0; |
| 932 | err: |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 933 | debugfs_remove_recursive(sc->debug.debugfs_phy); |
Ben Greear | eb27244 | 2010-11-29 14:13:22 -0800 | [diff] [blame^] | 934 | sc->debug.debugfs_phy = NULL; |
| 935 | return -ENOMEM; |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 936 | } |