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 | |
Gabor Juhos | 19d8bc2 | 2009-03-05 16:55:18 +0100 | [diff] [blame] | 27 | static struct dentry *ath9k_debugfs_root; |
| 28 | |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 29 | static int ath9k_debugfs_open(struct inode *inode, struct file *file) |
| 30 | { |
| 31 | file->private_data = inode->i_private; |
| 32 | return 0; |
| 33 | } |
| 34 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 35 | #ifdef CONFIG_ATH_DEBUG |
| 36 | |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 37 | static ssize_t read_file_debug(struct file *file, char __user *user_buf, |
| 38 | size_t count, loff_t *ppos) |
| 39 | { |
| 40 | struct ath_softc *sc = file->private_data; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 41 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 42 | char buf[32]; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 43 | unsigned int len; |
| 44 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 45 | len = sprintf(buf, "0x%08x\n", common->debug_mask); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 46 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 47 | } |
| 48 | |
| 49 | static ssize_t write_file_debug(struct file *file, const char __user *user_buf, |
| 50 | size_t count, loff_t *ppos) |
| 51 | { |
| 52 | struct ath_softc *sc = file->private_data; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 53 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 54 | unsigned long mask; |
| 55 | char buf[32]; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 56 | ssize_t len; |
| 57 | |
| 58 | len = min(count, sizeof(buf) - 1); |
| 59 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 60 | return -EFAULT; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 61 | |
| 62 | buf[len] = '\0'; |
| 63 | if (strict_strtoul(buf, 0, &mask)) |
| 64 | return -EINVAL; |
| 65 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 66 | common->debug_mask = mask; |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 67 | return count; |
| 68 | } |
| 69 | |
| 70 | static const struct file_operations fops_debug = { |
| 71 | .read = read_file_debug, |
| 72 | .write = write_file_debug, |
| 73 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 74 | .owner = THIS_MODULE, |
| 75 | .llseek = default_llseek, |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 78 | #endif |
| 79 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 80 | #define DMA_BUF_LEN 1024 |
| 81 | |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 82 | static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf, |
| 83 | size_t count, loff_t *ppos) |
| 84 | { |
| 85 | struct ath_softc *sc = file->private_data; |
| 86 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 87 | char buf[32]; |
| 88 | unsigned int len; |
| 89 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 90 | len = sprintf(buf, "0x%08x\n", common->tx_chainmask); |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 91 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 92 | } |
| 93 | |
| 94 | static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf, |
| 95 | size_t count, loff_t *ppos) |
| 96 | { |
| 97 | struct ath_softc *sc = file->private_data; |
| 98 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 99 | unsigned long mask; |
| 100 | char buf[32]; |
| 101 | ssize_t len; |
| 102 | |
| 103 | len = min(count, sizeof(buf) - 1); |
| 104 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 105 | return -EFAULT; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 106 | |
| 107 | buf[len] = '\0'; |
| 108 | if (strict_strtoul(buf, 0, &mask)) |
| 109 | return -EINVAL; |
| 110 | |
| 111 | common->tx_chainmask = mask; |
| 112 | sc->sc_ah->caps.tx_chainmask = mask; |
| 113 | return count; |
| 114 | } |
| 115 | |
| 116 | static const struct file_operations fops_tx_chainmask = { |
| 117 | .read = read_file_tx_chainmask, |
| 118 | .write = write_file_tx_chainmask, |
| 119 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 120 | .owner = THIS_MODULE, |
| 121 | .llseek = default_llseek, |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | |
| 125 | static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf, |
| 126 | size_t count, loff_t *ppos) |
| 127 | { |
| 128 | struct ath_softc *sc = file->private_data; |
| 129 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 130 | char buf[32]; |
| 131 | unsigned int len; |
| 132 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 133 | len = sprintf(buf, "0x%08x\n", common->rx_chainmask); |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 134 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 135 | } |
| 136 | |
| 137 | static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf, |
| 138 | size_t count, loff_t *ppos) |
| 139 | { |
| 140 | struct ath_softc *sc = file->private_data; |
| 141 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 142 | unsigned long mask; |
| 143 | char buf[32]; |
| 144 | ssize_t len; |
| 145 | |
| 146 | len = min(count, sizeof(buf) - 1); |
| 147 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 148 | return -EFAULT; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 149 | |
| 150 | buf[len] = '\0'; |
| 151 | if (strict_strtoul(buf, 0, &mask)) |
| 152 | return -EINVAL; |
| 153 | |
| 154 | common->rx_chainmask = mask; |
| 155 | sc->sc_ah->caps.rx_chainmask = mask; |
| 156 | return count; |
| 157 | } |
| 158 | |
| 159 | static const struct file_operations fops_rx_chainmask = { |
| 160 | .read = read_file_rx_chainmask, |
| 161 | .write = write_file_rx_chainmask, |
| 162 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 163 | .owner = THIS_MODULE, |
| 164 | .llseek = default_llseek, |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 165 | }; |
| 166 | |
| 167 | |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 168 | static ssize_t read_file_dma(struct file *file, char __user *user_buf, |
| 169 | size_t count, loff_t *ppos) |
| 170 | { |
| 171 | struct ath_softc *sc = file->private_data; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 172 | struct ath_hw *ah = sc->sc_ah; |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 173 | char *buf; |
| 174 | int retval; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 175 | unsigned int len = 0; |
| 176 | u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; |
| 177 | int i, qcuOffset = 0, dcuOffset = 0; |
| 178 | u32 *qcuBase = &val[0], *dcuBase = &val[4]; |
| 179 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 180 | buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); |
| 181 | if (!buf) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 182 | return -ENOMEM; |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 183 | |
Sujith | 7cf4a2e | 2009-08-26 11:11:57 +0530 | [diff] [blame] | 184 | ath9k_ps_wakeup(sc); |
| 185 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 186 | REG_WRITE_D(ah, AR_MACMISC, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 187 | ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | |
| 188 | (AR_MACMISC_MISC_OBS_BUS_1 << |
| 189 | AR_MACMISC_MISC_OBS_BUS_MSB_S))); |
| 190 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 191 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 192 | "Raw DMA Debug values:\n"); |
| 193 | |
| 194 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { |
| 195 | if (i % 4 == 0) |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 196 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 197 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 198 | val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 199 | len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 200 | i, val[i]); |
| 201 | } |
| 202 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 203 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); |
| 204 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 205 | "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); |
| 206 | |
| 207 | for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { |
| 208 | if (i == 8) { |
| 209 | qcuOffset = 0; |
| 210 | qcuBase++; |
| 211 | } |
| 212 | |
| 213 | if (i == 6) { |
| 214 | dcuOffset = 0; |
| 215 | dcuBase++; |
| 216 | } |
| 217 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 218 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 219 | "%2d %2x %1x %2x %2x\n", |
| 220 | i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, |
| 221 | (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), |
| 222 | val[2] & (0x7 << (i * 3)) >> (i * 3), |
| 223 | (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); |
| 224 | } |
| 225 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 226 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 227 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 228 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 229 | "qcu_stitch state: %2x qcu_fetch state: %2x\n", |
| 230 | (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 231 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 232 | "qcu_complete state: %2x dcu_complete state: %2x\n", |
| 233 | (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 234 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 235 | "dcu_arb state: %2x dcu_fp state: %2x\n", |
| 236 | (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 237 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 238 | "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", |
| 239 | (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 240 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 241 | "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", |
| 242 | (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 243 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 244 | "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", |
| 245 | (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); |
| 246 | |
Frans Pop | 60ece40 | 2010-03-24 19:46:30 +0100 | [diff] [blame] | 247 | 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] | 248 | REG_READ_D(ah, AR_OBS_BUS_1)); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 249 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Frans Pop | 60ece40 | 2010-03-24 19:46:30 +0100 | [diff] [blame] | 250 | "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 251 | |
Sujith | 7cf4a2e | 2009-08-26 11:11:57 +0530 | [diff] [blame] | 252 | ath9k_ps_restore(sc); |
| 253 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 254 | if (len > DMA_BUF_LEN) |
| 255 | len = DMA_BUF_LEN; |
| 256 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 257 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 258 | kfree(buf); |
| 259 | return retval; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | static const struct file_operations fops_dma = { |
| 263 | .read = read_file_dma, |
| 264 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 265 | .owner = THIS_MODULE, |
| 266 | .llseek = default_llseek, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 267 | }; |
| 268 | |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 269 | |
| 270 | void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) |
| 271 | { |
| 272 | if (status) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 273 | sc->debug.stats.istats.total++; |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 274 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
| 275 | if (status & ATH9K_INT_RXLP) |
| 276 | sc->debug.stats.istats.rxlp++; |
| 277 | if (status & ATH9K_INT_RXHP) |
| 278 | sc->debug.stats.istats.rxhp++; |
Luis R. Rodriguez | 08578b8 | 2010-05-13 13:33:44 -0400 | [diff] [blame] | 279 | if (status & ATH9K_INT_BB_WATCHDOG) |
| 280 | sc->debug.stats.istats.bb_watchdog++; |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 281 | } else { |
| 282 | if (status & ATH9K_INT_RX) |
| 283 | sc->debug.stats.istats.rxok++; |
| 284 | } |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 285 | if (status & ATH9K_INT_RXEOL) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 286 | sc->debug.stats.istats.rxeol++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 287 | if (status & ATH9K_INT_RXORN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 288 | sc->debug.stats.istats.rxorn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 289 | if (status & ATH9K_INT_TX) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 290 | sc->debug.stats.istats.txok++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 291 | if (status & ATH9K_INT_TXURN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 292 | sc->debug.stats.istats.txurn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 293 | if (status & ATH9K_INT_MIB) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 294 | sc->debug.stats.istats.mib++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 295 | if (status & ATH9K_INT_RXPHY) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 296 | sc->debug.stats.istats.rxphyerr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 297 | if (status & ATH9K_INT_RXKCM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 298 | sc->debug.stats.istats.rx_keycache_miss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 299 | if (status & ATH9K_INT_SWBA) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 300 | sc->debug.stats.istats.swba++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 301 | if (status & ATH9K_INT_BMISS) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 302 | sc->debug.stats.istats.bmiss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 303 | if (status & ATH9K_INT_BNR) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 304 | sc->debug.stats.istats.bnr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 305 | if (status & ATH9K_INT_CST) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 306 | sc->debug.stats.istats.cst++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 307 | if (status & ATH9K_INT_GTT) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 308 | sc->debug.stats.istats.gtt++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 309 | if (status & ATH9K_INT_TIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 310 | sc->debug.stats.istats.tim++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 311 | if (status & ATH9K_INT_CABEND) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 312 | sc->debug.stats.istats.cabend++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 313 | if (status & ATH9K_INT_DTIMSYNC) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 314 | sc->debug.stats.istats.dtimsync++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 315 | if (status & ATH9K_INT_DTIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 316 | sc->debug.stats.istats.dtim++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, |
| 320 | size_t count, loff_t *ppos) |
| 321 | { |
| 322 | struct ath_softc *sc = file->private_data; |
| 323 | char buf[512]; |
| 324 | unsigned int len = 0; |
| 325 | |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 326 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
| 327 | len += snprintf(buf + len, sizeof(buf) - len, |
| 328 | "%8s: %10u\n", "RXLP", sc->debug.stats.istats.rxlp); |
| 329 | len += snprintf(buf + len, sizeof(buf) - len, |
| 330 | "%8s: %10u\n", "RXHP", sc->debug.stats.istats.rxhp); |
Luis R. Rodriguez | 08578b8 | 2010-05-13 13:33:44 -0400 | [diff] [blame] | 331 | len += snprintf(buf + len, sizeof(buf) - len, |
| 332 | "%8s: %10u\n", "WATCHDOG", |
| 333 | sc->debug.stats.istats.bb_watchdog); |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 334 | } else { |
| 335 | len += snprintf(buf + len, sizeof(buf) - len, |
| 336 | "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok); |
| 337 | } |
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", "RXEOL", sc->debug.stats.istats.rxeol); |
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", "RXORN", sc->debug.stats.istats.rxorn); |
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", "TX", sc->debug.stats.istats.txok); |
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", "TXURN", sc->debug.stats.istats.txurn); |
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", "MIB", sc->debug.stats.istats.mib); |
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", "RXPHY", sc->debug.stats.istats.rxphyerr); |
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", "RXKCM", sc->debug.stats.istats.rx_keycache_miss); |
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", "SWBA", sc->debug.stats.istats.swba); |
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", "BMISS", sc->debug.stats.istats.bmiss); |
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", "BNR", sc->debug.stats.istats.bnr); |
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", "CST", sc->debug.stats.istats.cst); |
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", "GTT", sc->debug.stats.istats.gtt); |
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", "TIM", sc->debug.stats.istats.tim); |
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", "CABEND", sc->debug.stats.istats.cabend); |
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", "DTIMSYNC", sc->debug.stats.istats.dtimsync); |
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", "DTIM", sc->debug.stats.istats.dtim); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 370 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 371 | "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 372 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 373 | if (len > sizeof(buf)) |
| 374 | len = sizeof(buf); |
| 375 | |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 376 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 377 | } |
| 378 | |
| 379 | static const struct file_operations fops_interrupt = { |
| 380 | .read = read_file_interrupt, |
| 381 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 382 | .owner = THIS_MODULE, |
| 383 | .llseek = default_llseek, |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 384 | }; |
| 385 | |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 386 | static const char * ath_wiphy_state_str(enum ath_wiphy_state state) |
| 387 | { |
| 388 | switch (state) { |
| 389 | case ATH_WIPHY_INACTIVE: |
| 390 | return "INACTIVE"; |
| 391 | case ATH_WIPHY_ACTIVE: |
| 392 | return "ACTIVE"; |
| 393 | case ATH_WIPHY_PAUSING: |
| 394 | return "PAUSING"; |
| 395 | case ATH_WIPHY_PAUSED: |
| 396 | return "PAUSED"; |
| 397 | case ATH_WIPHY_SCAN: |
| 398 | return "SCAN"; |
| 399 | } |
| 400 | return "?"; |
| 401 | } |
| 402 | |
| 403 | static ssize_t read_file_wiphy(struct file *file, char __user *user_buf, |
| 404 | size_t count, loff_t *ppos) |
| 405 | { |
| 406 | struct ath_softc *sc = file->private_data; |
Mohammed Shafi Shajakhan | 8e0167a | 2010-10-01 15:25:05 +0530 | [diff] [blame] | 407 | struct ath_wiphy *aphy = sc->pri_wiphy; |
| 408 | struct ieee80211_channel *chan = aphy->hw->conf.channel; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 409 | char buf[512]; |
| 410 | unsigned int len = 0; |
| 411 | int i; |
| 412 | u8 addr[ETH_ALEN]; |
Ben Greear | 3905751 | 2010-09-14 12:46:04 -0700 | [diff] [blame] | 413 | u32 tmp; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 414 | |
| 415 | len += snprintf(buf + len, sizeof(buf) - len, |
| 416 | "primary: %s (%s chan=%d ht=%d)\n", |
| 417 | wiphy_name(sc->pri_wiphy->hw->wiphy), |
| 418 | ath_wiphy_state_str(sc->pri_wiphy->state), |
Mohammed Shafi Shajakhan | 8e0167a | 2010-10-01 15:25:05 +0530 | [diff] [blame] | 419 | ieee80211_frequency_to_channel(chan->center_freq), |
| 420 | aphy->chan_is_ht); |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 421 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 422 | put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr); |
| 423 | 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] | 424 | len += snprintf(buf + len, sizeof(buf) - len, |
| 425 | "addr: %pM\n", addr); |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 426 | put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr); |
| 427 | 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] | 428 | len += snprintf(buf + len, sizeof(buf) - len, |
| 429 | "addrmask: %pM\n", addr); |
Ben Greear | 3905751 | 2010-09-14 12:46:04 -0700 | [diff] [blame] | 430 | tmp = ath9k_hw_getrxfilter(sc->sc_ah); |
| 431 | len += snprintf(buf + len, sizeof(buf) - len, |
| 432 | "rfilt: 0x%x", tmp); |
| 433 | if (tmp & ATH9K_RX_FILTER_UCAST) |
| 434 | len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); |
| 435 | if (tmp & ATH9K_RX_FILTER_MCAST) |
| 436 | len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); |
| 437 | if (tmp & ATH9K_RX_FILTER_BCAST) |
| 438 | len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); |
| 439 | if (tmp & ATH9K_RX_FILTER_CONTROL) |
| 440 | len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); |
| 441 | if (tmp & ATH9K_RX_FILTER_BEACON) |
| 442 | len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); |
| 443 | if (tmp & ATH9K_RX_FILTER_PROM) |
| 444 | len += snprintf(buf + len, sizeof(buf) - len, " PROM"); |
| 445 | if (tmp & ATH9K_RX_FILTER_PROBEREQ) |
| 446 | len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); |
| 447 | if (tmp & ATH9K_RX_FILTER_PHYERR) |
| 448 | len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); |
| 449 | if (tmp & ATH9K_RX_FILTER_MYBEACON) |
| 450 | len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); |
| 451 | if (tmp & ATH9K_RX_FILTER_COMP_BAR) |
| 452 | len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); |
| 453 | if (tmp & ATH9K_RX_FILTER_PSPOLL) |
| 454 | len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); |
| 455 | if (tmp & ATH9K_RX_FILTER_PHYRADAR) |
| 456 | len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); |
| 457 | if (tmp & ATH9K_RX_FILTER_MCAST_BCAST_ALL) |
| 458 | len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL\n"); |
| 459 | else |
| 460 | len += snprintf(buf + len, sizeof(buf) - len, "\n"); |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 461 | |
Ben Greear | 3905751 | 2010-09-14 12:46:04 -0700 | [diff] [blame] | 462 | /* Put variable-length stuff down here, and check for overflows. */ |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 463 | for (i = 0; i < sc->num_sec_wiphy; i++) { |
| 464 | struct ath_wiphy *aphy = sc->sec_wiphy[i]; |
| 465 | if (aphy == NULL) |
| 466 | continue; |
Mohammed Shafi Shajakhan | 8e0167a | 2010-10-01 15:25:05 +0530 | [diff] [blame] | 467 | chan = aphy->hw->conf.channel; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 468 | len += snprintf(buf + len, sizeof(buf) - len, |
Mohammed Shafi Shajakhan | 8e0167a | 2010-10-01 15:25:05 +0530 | [diff] [blame] | 469 | "secondary: %s (%s chan=%d ht=%d)\n", |
| 470 | wiphy_name(aphy->hw->wiphy), |
| 471 | ath_wiphy_state_str(aphy->state), |
| 472 | ieee80211_frequency_to_channel(chan->center_freq), |
| 473 | aphy->chan_is_ht); |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 474 | } |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 475 | if (len > sizeof(buf)) |
| 476 | len = sizeof(buf); |
| 477 | |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 478 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 479 | } |
| 480 | |
| 481 | static struct ath_wiphy * get_wiphy(struct ath_softc *sc, const char *name) |
| 482 | { |
| 483 | int i; |
| 484 | if (strcmp(name, wiphy_name(sc->pri_wiphy->hw->wiphy)) == 0) |
| 485 | return sc->pri_wiphy; |
| 486 | for (i = 0; i < sc->num_sec_wiphy; i++) { |
| 487 | struct ath_wiphy *aphy = sc->sec_wiphy[i]; |
| 488 | if (aphy && strcmp(name, wiphy_name(aphy->hw->wiphy)) == 0) |
| 489 | return aphy; |
| 490 | } |
| 491 | return NULL; |
| 492 | } |
| 493 | |
| 494 | static int del_wiphy(struct ath_softc *sc, const char *name) |
| 495 | { |
| 496 | struct ath_wiphy *aphy = get_wiphy(sc, name); |
| 497 | if (!aphy) |
| 498 | return -ENOENT; |
| 499 | return ath9k_wiphy_del(aphy); |
| 500 | } |
| 501 | |
| 502 | static int pause_wiphy(struct ath_softc *sc, const char *name) |
| 503 | { |
| 504 | struct ath_wiphy *aphy = get_wiphy(sc, name); |
| 505 | if (!aphy) |
| 506 | return -ENOENT; |
| 507 | return ath9k_wiphy_pause(aphy); |
| 508 | } |
| 509 | |
| 510 | static int unpause_wiphy(struct ath_softc *sc, const char *name) |
| 511 | { |
| 512 | struct ath_wiphy *aphy = get_wiphy(sc, name); |
| 513 | if (!aphy) |
| 514 | return -ENOENT; |
| 515 | return ath9k_wiphy_unpause(aphy); |
| 516 | } |
| 517 | |
| 518 | static int select_wiphy(struct ath_softc *sc, const char *name) |
| 519 | { |
| 520 | struct ath_wiphy *aphy = get_wiphy(sc, name); |
| 521 | if (!aphy) |
| 522 | return -ENOENT; |
| 523 | return ath9k_wiphy_select(aphy); |
| 524 | } |
| 525 | |
| 526 | static int schedule_wiphy(struct ath_softc *sc, const char *msec) |
| 527 | { |
| 528 | ath9k_wiphy_set_scheduler(sc, simple_strtoul(msec, NULL, 0)); |
| 529 | return 0; |
| 530 | } |
| 531 | |
| 532 | static ssize_t write_file_wiphy(struct file *file, const char __user *user_buf, |
| 533 | size_t count, loff_t *ppos) |
| 534 | { |
| 535 | struct ath_softc *sc = file->private_data; |
| 536 | char buf[50]; |
| 537 | size_t len; |
| 538 | |
| 539 | len = min(count, sizeof(buf) - 1); |
| 540 | if (copy_from_user(buf, user_buf, len)) |
| 541 | return -EFAULT; |
| 542 | buf[len] = '\0'; |
| 543 | if (len > 0 && buf[len - 1] == '\n') |
| 544 | buf[len - 1] = '\0'; |
| 545 | |
| 546 | if (strncmp(buf, "add", 3) == 0) { |
| 547 | int res = ath9k_wiphy_add(sc); |
| 548 | if (res < 0) |
| 549 | return res; |
| 550 | } else if (strncmp(buf, "del=", 4) == 0) { |
| 551 | int res = del_wiphy(sc, buf + 4); |
| 552 | if (res < 0) |
| 553 | return res; |
| 554 | } else if (strncmp(buf, "pause=", 6) == 0) { |
| 555 | int res = pause_wiphy(sc, buf + 6); |
| 556 | if (res < 0) |
| 557 | return res; |
| 558 | } else if (strncmp(buf, "unpause=", 8) == 0) { |
| 559 | int res = unpause_wiphy(sc, buf + 8); |
| 560 | if (res < 0) |
| 561 | return res; |
| 562 | } else if (strncmp(buf, "select=", 7) == 0) { |
| 563 | int res = select_wiphy(sc, buf + 7); |
| 564 | if (res < 0) |
| 565 | return res; |
| 566 | } else if (strncmp(buf, "schedule=", 9) == 0) { |
| 567 | int res = schedule_wiphy(sc, buf + 9); |
| 568 | if (res < 0) |
| 569 | return res; |
| 570 | } else |
| 571 | return -EOPNOTSUPP; |
| 572 | |
| 573 | return count; |
| 574 | } |
| 575 | |
| 576 | static const struct file_operations fops_wiphy = { |
| 577 | .read = read_file_wiphy, |
| 578 | .write = write_file_wiphy, |
| 579 | .open = ath9k_debugfs_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 580 | .owner = THIS_MODULE, |
| 581 | .llseek = default_llseek, |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 582 | }; |
| 583 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 584 | #define PR(str, elem) \ |
| 585 | do { \ |
| 586 | len += snprintf(buf + len, size - len, \ |
| 587 | "%s%13u%11u%10u%10u\n", str, \ |
Felix Fietkau | 1d2231e | 2010-06-12 00:33:51 -0400 | [diff] [blame] | 588 | sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_BE]].elem, \ |
| 589 | sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_BK]].elem, \ |
| 590 | sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_VI]].elem, \ |
| 591 | sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_VO]].elem); \ |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 592 | } while(0) |
| 593 | |
| 594 | static ssize_t read_file_xmit(struct file *file, char __user *user_buf, |
| 595 | size_t count, loff_t *ppos) |
| 596 | { |
| 597 | struct ath_softc *sc = file->private_data; |
| 598 | char *buf; |
| 599 | unsigned int len = 0, size = 2048; |
| 600 | ssize_t retval = 0; |
| 601 | |
| 602 | buf = kzalloc(size, GFP_KERNEL); |
| 603 | if (buf == NULL) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 604 | return -ENOMEM; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 605 | |
| 606 | len += sprintf(buf, "%30s %10s%10s%10s\n\n", "BE", "BK", "VI", "VO"); |
| 607 | |
| 608 | PR("MPDUs Queued: ", queued); |
| 609 | PR("MPDUs Completed: ", completed); |
| 610 | PR("Aggregates: ", a_aggr); |
| 611 | PR("AMPDUs Queued: ", a_queued); |
| 612 | PR("AMPDUs Completed:", a_completed); |
| 613 | PR("AMPDUs Retried: ", a_retries); |
| 614 | PR("AMPDUs XRetried: ", a_xretries); |
| 615 | PR("FIFO Underrun: ", fifo_underrun); |
| 616 | PR("TXOP Exceeded: ", xtxop); |
| 617 | PR("TXTIMER Expiry: ", timer_exp); |
| 618 | PR("DESC CFG Error: ", desc_cfg_err); |
| 619 | PR("DATA Underrun: ", data_underrun); |
| 620 | PR("DELIM Underrun: ", delim_underrun); |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 621 | PR("TX-Pkts-All: ", tx_pkts_all); |
| 622 | PR("TX-Bytes-All: ", tx_bytes_all); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 623 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 624 | if (len > size) |
| 625 | len = size; |
| 626 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 627 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 628 | kfree(buf); |
| 629 | |
| 630 | return retval; |
| 631 | } |
| 632 | |
| 633 | void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq, |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 634 | struct ath_buf *bf, struct ath_tx_status *ts) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 635 | { |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 636 | TX_STAT_INC(txq->axq_qnum, tx_pkts_all); |
| 637 | sc->debug.stats.txstats[txq->axq_qnum].tx_bytes_all += bf->bf_mpdu->len; |
| 638 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 639 | if (bf_isampdu(bf)) { |
| 640 | if (bf_isxretried(bf)) |
| 641 | TX_STAT_INC(txq->axq_qnum, a_xretries); |
| 642 | else |
| 643 | TX_STAT_INC(txq->axq_qnum, a_completed); |
| 644 | } else { |
| 645 | TX_STAT_INC(txq->axq_qnum, completed); |
| 646 | } |
| 647 | |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 648 | if (ts->ts_status & ATH9K_TXERR_FIFO) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 649 | TX_STAT_INC(txq->axq_qnum, fifo_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 650 | if (ts->ts_status & ATH9K_TXERR_XTXOP) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 651 | TX_STAT_INC(txq->axq_qnum, xtxop); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 652 | if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 653 | TX_STAT_INC(txq->axq_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) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 655 | TX_STAT_INC(txq->axq_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) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 657 | TX_STAT_INC(txq->axq_qnum, data_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 658 | if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 659 | TX_STAT_INC(txq->axq_qnum, delim_underrun); |
| 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 | |
Sujith | 7dd5874 | 2009-03-30 15:28:42 +0530 | [diff] [blame] | 879 | if (!ath9k_debugfs_root) |
| 880 | return -ENOENT; |
| 881 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 882 | sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy), |
Gabor Juhos | 19d8bc2 | 2009-03-05 16:55:18 +0100 | [diff] [blame] | 883 | ath9k_debugfs_root); |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 884 | if (!sc->debug.debugfs_phy) |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 885 | return -ENOMEM; |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 886 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 887 | #ifdef CONFIG_ATH_DEBUG |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 888 | if (!debugfs_create_file("debug", S_IRUSR | S_IWUSR, |
| 889 | sc->debug.debugfs_phy, sc, &fops_debug)) |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 890 | goto err; |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 891 | #endif |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 892 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 893 | if (!debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, |
| 894 | sc, &fops_dma)) |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 895 | goto err; |
| 896 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 897 | if (!debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, |
| 898 | sc, &fops_interrupt)) |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 899 | goto err; |
| 900 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 901 | if (!debugfs_create_file("wiphy", S_IRUSR | S_IWUSR, |
| 902 | sc->debug.debugfs_phy, sc, &fops_wiphy)) |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 903 | goto err; |
| 904 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 905 | if (!debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, |
| 906 | sc, &fops_xmit)) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 907 | goto err; |
| 908 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 909 | if (!debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, |
| 910 | sc, &fops_recv)) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 911 | goto err; |
| 912 | |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 913 | if (!debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, |
| 914 | sc->debug.debugfs_phy, sc, &fops_rx_chainmask)) |
| 915 | goto err; |
| 916 | |
| 917 | if (!debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, |
| 918 | sc->debug.debugfs_phy, sc, &fops_tx_chainmask)) |
| 919 | goto err; |
| 920 | |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 921 | if (!debugfs_create_file("regidx", S_IRUSR | S_IWUSR, |
| 922 | sc->debug.debugfs_phy, sc, &fops_regidx)) |
| 923 | goto err; |
| 924 | |
| 925 | if (!debugfs_create_file("regval", S_IRUSR | S_IWUSR, |
| 926 | sc->debug.debugfs_phy, sc, &fops_regval)) |
| 927 | goto err; |
| 928 | |
Felix Fietkau | 41f3e54 | 2010-06-12 00:33:56 -0400 | [diff] [blame] | 929 | if (!debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, |
| 930 | sc->debug.debugfs_phy, &ah->config.cwm_ignore_extcca)) |
| 931 | goto err; |
| 932 | |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 933 | sc->debug.regidx = 0; |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 934 | return 0; |
| 935 | err: |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 936 | ath9k_exit_debug(ah); |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 937 | return -ENOMEM; |
| 938 | } |
| 939 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 940 | void ath9k_exit_debug(struct ath_hw *ah) |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 941 | { |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 942 | struct ath_common *common = ath9k_hw_common(ah); |
| 943 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 944 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 945 | debugfs_remove_recursive(sc->debug.debugfs_phy); |
Gabor Juhos | 19d8bc2 | 2009-03-05 16:55:18 +0100 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | int ath9k_debug_create_root(void) |
| 949 | { |
| 950 | ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL); |
| 951 | if (!ath9k_debugfs_root) |
| 952 | return -ENOENT; |
| 953 | |
| 954 | return 0; |
| 955 | } |
| 956 | |
| 957 | void ath9k_debug_remove_root(void) |
| 958 | { |
| 959 | debugfs_remove(ath9k_debugfs_root); |
| 960 | ath9k_debugfs_root = NULL; |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 961 | } |