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 | |
Gabor Juhos | 5210311 | 2009-03-06 09:57:39 +0100 | [diff] [blame] | 17 | #include <asm/unaligned.h> |
| 18 | |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 19 | #include "ath9k.h" |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 20 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 21 | #define REG_WRITE_D(_ah, _reg, _val) \ |
| 22 | ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) |
| 23 | #define REG_READ_D(_ah, _reg) \ |
| 24 | ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) |
| 25 | |
Gabor Juhos | 19d8bc2 | 2009-03-05 16:55:18 +0100 | [diff] [blame] | 26 | static struct dentry *ath9k_debugfs_root; |
| 27 | |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 28 | static int ath9k_debugfs_open(struct inode *inode, struct file *file) |
| 29 | { |
| 30 | file->private_data = inode->i_private; |
| 31 | return 0; |
| 32 | } |
| 33 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 34 | #ifdef CONFIG_ATH_DEBUG |
| 35 | |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 36 | static ssize_t read_file_debug(struct file *file, char __user *user_buf, |
| 37 | size_t count, loff_t *ppos) |
| 38 | { |
| 39 | struct ath_softc *sc = file->private_data; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 40 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 41 | char buf[32]; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 42 | unsigned int len; |
| 43 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 44 | len = snprintf(buf, sizeof(buf), "0x%08x\n", common->debug_mask); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 45 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 46 | } |
| 47 | |
| 48 | static ssize_t write_file_debug(struct file *file, const char __user *user_buf, |
| 49 | size_t count, loff_t *ppos) |
| 50 | { |
| 51 | struct ath_softc *sc = file->private_data; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 52 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 53 | unsigned long mask; |
| 54 | char buf[32]; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 55 | ssize_t len; |
| 56 | |
| 57 | len = min(count, sizeof(buf) - 1); |
| 58 | if (copy_from_user(buf, user_buf, len)) |
| 59 | return -EINVAL; |
| 60 | |
| 61 | buf[len] = '\0'; |
| 62 | if (strict_strtoul(buf, 0, &mask)) |
| 63 | return -EINVAL; |
| 64 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 65 | common->debug_mask = mask; |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 66 | return count; |
| 67 | } |
| 68 | |
| 69 | static const struct file_operations fops_debug = { |
| 70 | .read = read_file_debug, |
| 71 | .write = write_file_debug, |
| 72 | .open = ath9k_debugfs_open, |
| 73 | .owner = THIS_MODULE |
| 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 | |
| 88 | len = snprintf(buf, sizeof(buf), "0x%08x\n", common->tx_chainmask); |
| 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)) |
| 103 | return -EINVAL; |
| 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, |
| 118 | .owner = THIS_MODULE |
| 119 | }; |
| 120 | |
| 121 | |
| 122 | static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf, |
| 123 | size_t count, loff_t *ppos) |
| 124 | { |
| 125 | struct ath_softc *sc = file->private_data; |
| 126 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 127 | char buf[32]; |
| 128 | unsigned int len; |
| 129 | |
| 130 | len = snprintf(buf, sizeof(buf), "0x%08x\n", common->rx_chainmask); |
| 131 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 132 | } |
| 133 | |
| 134 | static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf, |
| 135 | size_t count, loff_t *ppos) |
| 136 | { |
| 137 | struct ath_softc *sc = file->private_data; |
| 138 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 139 | unsigned long mask; |
| 140 | char buf[32]; |
| 141 | ssize_t len; |
| 142 | |
| 143 | len = min(count, sizeof(buf) - 1); |
| 144 | if (copy_from_user(buf, user_buf, len)) |
| 145 | return -EINVAL; |
| 146 | |
| 147 | buf[len] = '\0'; |
| 148 | if (strict_strtoul(buf, 0, &mask)) |
| 149 | return -EINVAL; |
| 150 | |
| 151 | common->rx_chainmask = mask; |
| 152 | sc->sc_ah->caps.rx_chainmask = mask; |
| 153 | return count; |
| 154 | } |
| 155 | |
| 156 | static const struct file_operations fops_rx_chainmask = { |
| 157 | .read = read_file_rx_chainmask, |
| 158 | .write = write_file_rx_chainmask, |
| 159 | .open = ath9k_debugfs_open, |
| 160 | .owner = THIS_MODULE |
| 161 | }; |
| 162 | |
| 163 | |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 164 | static ssize_t read_file_dma(struct file *file, char __user *user_buf, |
| 165 | size_t count, loff_t *ppos) |
| 166 | { |
| 167 | struct ath_softc *sc = file->private_data; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 168 | struct ath_hw *ah = sc->sc_ah; |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 169 | char *buf; |
| 170 | int retval; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 171 | unsigned int len = 0; |
| 172 | u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; |
| 173 | int i, qcuOffset = 0, dcuOffset = 0; |
| 174 | u32 *qcuBase = &val[0], *dcuBase = &val[4]; |
| 175 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 176 | buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); |
| 177 | if (!buf) |
| 178 | return 0; |
| 179 | |
Sujith | 7cf4a2e | 2009-08-26 11:11:57 +0530 | [diff] [blame] | 180 | ath9k_ps_wakeup(sc); |
| 181 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 182 | REG_WRITE_D(ah, AR_MACMISC, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 183 | ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | |
| 184 | (AR_MACMISC_MISC_OBS_BUS_1 << |
| 185 | AR_MACMISC_MISC_OBS_BUS_MSB_S))); |
| 186 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 187 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 188 | "Raw DMA Debug values:\n"); |
| 189 | |
| 190 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { |
| 191 | if (i % 4 == 0) |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 192 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 193 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 194 | val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 195 | len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 196 | i, val[i]); |
| 197 | } |
| 198 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 199 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); |
| 200 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 201 | "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); |
| 202 | |
| 203 | for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { |
| 204 | if (i == 8) { |
| 205 | qcuOffset = 0; |
| 206 | qcuBase++; |
| 207 | } |
| 208 | |
| 209 | if (i == 6) { |
| 210 | dcuOffset = 0; |
| 211 | dcuBase++; |
| 212 | } |
| 213 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 214 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 215 | "%2d %2x %1x %2x %2x\n", |
| 216 | i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, |
| 217 | (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), |
| 218 | val[2] & (0x7 << (i * 3)) >> (i * 3), |
| 219 | (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); |
| 220 | } |
| 221 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 222 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 223 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 224 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 225 | "qcu_stitch state: %2x qcu_fetch state: %2x\n", |
| 226 | (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 227 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 228 | "qcu_complete state: %2x dcu_complete state: %2x\n", |
| 229 | (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 230 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 231 | "dcu_arb state: %2x dcu_fp state: %2x\n", |
| 232 | (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 233 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 234 | "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", |
| 235 | (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 236 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 237 | "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", |
| 238 | (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 239 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 240 | "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", |
| 241 | (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); |
| 242 | |
Frans Pop | 60ece40 | 2010-03-24 19:46:30 +0100 | [diff] [blame] | 243 | 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] | 244 | REG_READ_D(ah, AR_OBS_BUS_1)); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 245 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Frans Pop | 60ece40 | 2010-03-24 19:46:30 +0100 | [diff] [blame] | 246 | "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 247 | |
Sujith | 7cf4a2e | 2009-08-26 11:11:57 +0530 | [diff] [blame] | 248 | ath9k_ps_restore(sc); |
| 249 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 250 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 251 | kfree(buf); |
| 252 | return retval; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | static const struct file_operations fops_dma = { |
| 256 | .read = read_file_dma, |
| 257 | .open = ath9k_debugfs_open, |
| 258 | .owner = THIS_MODULE |
| 259 | }; |
| 260 | |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 261 | |
| 262 | void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) |
| 263 | { |
| 264 | if (status) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 265 | sc->debug.stats.istats.total++; |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 266 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
| 267 | if (status & ATH9K_INT_RXLP) |
| 268 | sc->debug.stats.istats.rxlp++; |
| 269 | if (status & ATH9K_INT_RXHP) |
| 270 | sc->debug.stats.istats.rxhp++; |
| 271 | } else { |
| 272 | if (status & ATH9K_INT_RX) |
| 273 | sc->debug.stats.istats.rxok++; |
| 274 | } |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 275 | if (status & ATH9K_INT_RXEOL) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 276 | sc->debug.stats.istats.rxeol++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 277 | if (status & ATH9K_INT_RXORN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 278 | sc->debug.stats.istats.rxorn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 279 | if (status & ATH9K_INT_TX) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 280 | sc->debug.stats.istats.txok++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 281 | if (status & ATH9K_INT_TXURN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 282 | sc->debug.stats.istats.txurn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 283 | if (status & ATH9K_INT_MIB) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 284 | sc->debug.stats.istats.mib++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 285 | if (status & ATH9K_INT_RXPHY) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 286 | sc->debug.stats.istats.rxphyerr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 287 | if (status & ATH9K_INT_RXKCM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 288 | sc->debug.stats.istats.rx_keycache_miss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 289 | if (status & ATH9K_INT_SWBA) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 290 | sc->debug.stats.istats.swba++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 291 | if (status & ATH9K_INT_BMISS) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 292 | sc->debug.stats.istats.bmiss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 293 | if (status & ATH9K_INT_BNR) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 294 | sc->debug.stats.istats.bnr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 295 | if (status & ATH9K_INT_CST) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 296 | sc->debug.stats.istats.cst++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 297 | if (status & ATH9K_INT_GTT) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 298 | sc->debug.stats.istats.gtt++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 299 | if (status & ATH9K_INT_TIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 300 | sc->debug.stats.istats.tim++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 301 | if (status & ATH9K_INT_CABEND) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 302 | sc->debug.stats.istats.cabend++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 303 | if (status & ATH9K_INT_DTIMSYNC) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 304 | sc->debug.stats.istats.dtimsync++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 305 | if (status & ATH9K_INT_DTIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 306 | sc->debug.stats.istats.dtim++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, |
| 310 | size_t count, loff_t *ppos) |
| 311 | { |
| 312 | struct ath_softc *sc = file->private_data; |
| 313 | char buf[512]; |
| 314 | unsigned int len = 0; |
| 315 | |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 316 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
| 317 | len += snprintf(buf + len, sizeof(buf) - len, |
| 318 | "%8s: %10u\n", "RXLP", sc->debug.stats.istats.rxlp); |
| 319 | len += snprintf(buf + len, sizeof(buf) - len, |
| 320 | "%8s: %10u\n", "RXHP", sc->debug.stats.istats.rxhp); |
| 321 | } else { |
| 322 | len += snprintf(buf + len, sizeof(buf) - len, |
| 323 | "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok); |
| 324 | } |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 325 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 326 | "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 327 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 328 | "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 329 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 330 | "%8s: %10u\n", "TX", sc->debug.stats.istats.txok); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 331 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 332 | "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 333 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 334 | "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 335 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 336 | "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 337 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 338 | "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 339 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 340 | "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 341 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 342 | "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 343 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 344 | "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 345 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 346 | "%8s: %10u\n", "CST", sc->debug.stats.istats.cst); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 347 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 348 | "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 349 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 350 | "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 351 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 352 | "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 353 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 354 | "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 355 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 356 | "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 357 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 358 | "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 359 | |
| 360 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 361 | } |
| 362 | |
| 363 | static const struct file_operations fops_interrupt = { |
| 364 | .read = read_file_interrupt, |
| 365 | .open = ath9k_debugfs_open, |
| 366 | .owner = THIS_MODULE |
| 367 | }; |
| 368 | |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 369 | void ath_debug_stat_rc(struct ath_softc *sc, int final_rate) |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 370 | { |
Jeff Hansen | bedf087 | 2009-05-27 12:48:28 +0000 | [diff] [blame] | 371 | struct ath_rc_stats *stats; |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 372 | |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 373 | stats = &sc->debug.stats.rcstats[final_rate]; |
Jeff Hansen | bedf087 | 2009-05-27 12:48:28 +0000 | [diff] [blame] | 374 | stats->success++; |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 375 | } |
| 376 | |
Sujith | 029bc43 | 2009-02-04 08:10:26 +0530 | [diff] [blame] | 377 | void ath_debug_stat_retries(struct ath_softc *sc, int rix, |
Sujith | 9e71279 | 2009-02-20 15:13:20 +0530 | [diff] [blame] | 378 | int xretries, int retries, u8 per) |
Sujith | 029bc43 | 2009-02-04 08:10:26 +0530 | [diff] [blame] | 379 | { |
Jeff Hansen | bedf087 | 2009-05-27 12:48:28 +0000 | [diff] [blame] | 380 | struct ath_rc_stats *stats = &sc->debug.stats.rcstats[rix]; |
Sujith | 029bc43 | 2009-02-04 08:10:26 +0530 | [diff] [blame] | 381 | |
Jeff Hansen | bedf087 | 2009-05-27 12:48:28 +0000 | [diff] [blame] | 382 | stats->xretries += xretries; |
| 383 | stats->retries += retries; |
| 384 | stats->per = per; |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | static ssize_t read_file_rcstat(struct file *file, char __user *user_buf, |
| 388 | size_t count, loff_t *ppos) |
| 389 | { |
| 390 | struct ath_softc *sc = file->private_data; |
Jeff Hansen | bedf087 | 2009-05-27 12:48:28 +0000 | [diff] [blame] | 391 | char *buf; |
| 392 | unsigned int len = 0, max; |
| 393 | int i = 0; |
| 394 | ssize_t retval; |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 395 | |
Sujith | 62b4fb6 | 2009-03-09 09:32:01 +0530 | [diff] [blame] | 396 | if (sc->cur_rate_table == NULL) |
| 397 | return 0; |
| 398 | |
Luis R. Rodriguez | c755ad3 | 2009-12-07 12:38:41 -0500 | [diff] [blame] | 399 | max = 80 + sc->cur_rate_table->rate_cnt * 1024; |
Jeff Hansen | bedf087 | 2009-05-27 12:48:28 +0000 | [diff] [blame] | 400 | buf = kmalloc(max + 1, GFP_KERNEL); |
| 401 | if (buf == NULL) |
| 402 | return 0; |
| 403 | buf[max] = 0; |
| 404 | |
Luis R. Rodriguez | c755ad3 | 2009-12-07 12:38:41 -0500 | [diff] [blame] | 405 | len += sprintf(buf, "%6s %6s %6s " |
| 406 | "%10s %10s %10s %10s\n", |
| 407 | "HT", "MCS", "Rate", |
| 408 | "Success", "Retries", "XRetries", "PER"); |
Jeff Hansen | bedf087 | 2009-05-27 12:48:28 +0000 | [diff] [blame] | 409 | |
| 410 | for (i = 0; i < sc->cur_rate_table->rate_cnt; i++) { |
| 411 | u32 ratekbps = sc->cur_rate_table->info[i].ratekbps; |
| 412 | struct ath_rc_stats *stats = &sc->debug.stats.rcstats[i]; |
Luis R. Rodriguez | c755ad3 | 2009-12-07 12:38:41 -0500 | [diff] [blame] | 413 | char mcs[5]; |
| 414 | char htmode[5]; |
| 415 | int used_mcs = 0, used_htmode = 0; |
| 416 | |
| 417 | if (WLAN_RC_PHY_HT(sc->cur_rate_table->info[i].phy)) { |
| 418 | used_mcs = snprintf(mcs, 5, "%d", |
| 419 | sc->cur_rate_table->info[i].ratecode); |
| 420 | |
| 421 | if (WLAN_RC_PHY_40(sc->cur_rate_table->info[i].phy)) |
| 422 | used_htmode = snprintf(htmode, 5, "HT40"); |
| 423 | else if (WLAN_RC_PHY_20(sc->cur_rate_table->info[i].phy)) |
| 424 | used_htmode = snprintf(htmode, 5, "HT20"); |
| 425 | else |
| 426 | used_htmode = snprintf(htmode, 5, "????"); |
| 427 | } |
| 428 | |
| 429 | mcs[used_mcs] = '\0'; |
| 430 | htmode[used_htmode] = '\0'; |
Jeff Hansen | bedf087 | 2009-05-27 12:48:28 +0000 | [diff] [blame] | 431 | |
| 432 | len += snprintf(buf + len, max - len, |
Luis R. Rodriguez | c755ad3 | 2009-12-07 12:38:41 -0500 | [diff] [blame] | 433 | "%6s %6s %3u.%d: " |
| 434 | "%10u %10u %10u %10u\n", |
| 435 | htmode, |
| 436 | mcs, |
| 437 | ratekbps / 1000, |
| 438 | (ratekbps % 1000) / 100, |
| 439 | stats->success, |
| 440 | stats->retries, |
| 441 | stats->xretries, |
Jeff Hansen | bedf087 | 2009-05-27 12:48:28 +0000 | [diff] [blame] | 442 | stats->per); |
| 443 | } |
| 444 | |
| 445 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 446 | kfree(buf); |
| 447 | return retval; |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | static const struct file_operations fops_rcstat = { |
| 451 | .read = read_file_rcstat, |
| 452 | .open = ath9k_debugfs_open, |
| 453 | .owner = THIS_MODULE |
| 454 | }; |
Alina Friedrichsen | 27abe06 | 2009-01-23 05:44:21 +0100 | [diff] [blame] | 455 | |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 456 | static const char * ath_wiphy_state_str(enum ath_wiphy_state state) |
| 457 | { |
| 458 | switch (state) { |
| 459 | case ATH_WIPHY_INACTIVE: |
| 460 | return "INACTIVE"; |
| 461 | case ATH_WIPHY_ACTIVE: |
| 462 | return "ACTIVE"; |
| 463 | case ATH_WIPHY_PAUSING: |
| 464 | return "PAUSING"; |
| 465 | case ATH_WIPHY_PAUSED: |
| 466 | return "PAUSED"; |
| 467 | case ATH_WIPHY_SCAN: |
| 468 | return "SCAN"; |
| 469 | } |
| 470 | return "?"; |
| 471 | } |
| 472 | |
| 473 | static ssize_t read_file_wiphy(struct file *file, char __user *user_buf, |
| 474 | size_t count, loff_t *ppos) |
| 475 | { |
| 476 | struct ath_softc *sc = file->private_data; |
| 477 | char buf[512]; |
| 478 | unsigned int len = 0; |
| 479 | int i; |
| 480 | u8 addr[ETH_ALEN]; |
| 481 | |
| 482 | len += snprintf(buf + len, sizeof(buf) - len, |
| 483 | "primary: %s (%s chan=%d ht=%d)\n", |
| 484 | wiphy_name(sc->pri_wiphy->hw->wiphy), |
| 485 | ath_wiphy_state_str(sc->pri_wiphy->state), |
| 486 | sc->pri_wiphy->chan_idx, sc->pri_wiphy->chan_is_ht); |
| 487 | for (i = 0; i < sc->num_sec_wiphy; i++) { |
| 488 | struct ath_wiphy *aphy = sc->sec_wiphy[i]; |
| 489 | if (aphy == NULL) |
| 490 | continue; |
| 491 | len += snprintf(buf + len, sizeof(buf) - len, |
| 492 | "secondary: %s (%s chan=%d ht=%d)\n", |
| 493 | wiphy_name(aphy->hw->wiphy), |
| 494 | ath_wiphy_state_str(aphy->state), |
| 495 | aphy->chan_idx, aphy->chan_is_ht); |
| 496 | } |
| 497 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 498 | put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr); |
| 499 | 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] | 500 | len += snprintf(buf + len, sizeof(buf) - len, |
| 501 | "addr: %pM\n", addr); |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 502 | put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr); |
| 503 | 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] | 504 | len += snprintf(buf + len, sizeof(buf) - len, |
| 505 | "addrmask: %pM\n", addr); |
| 506 | |
| 507 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 508 | } |
| 509 | |
| 510 | static struct ath_wiphy * get_wiphy(struct ath_softc *sc, const char *name) |
| 511 | { |
| 512 | int i; |
| 513 | if (strcmp(name, wiphy_name(sc->pri_wiphy->hw->wiphy)) == 0) |
| 514 | return sc->pri_wiphy; |
| 515 | for (i = 0; i < sc->num_sec_wiphy; i++) { |
| 516 | struct ath_wiphy *aphy = sc->sec_wiphy[i]; |
| 517 | if (aphy && strcmp(name, wiphy_name(aphy->hw->wiphy)) == 0) |
| 518 | return aphy; |
| 519 | } |
| 520 | return NULL; |
| 521 | } |
| 522 | |
| 523 | static int del_wiphy(struct ath_softc *sc, const char *name) |
| 524 | { |
| 525 | struct ath_wiphy *aphy = get_wiphy(sc, name); |
| 526 | if (!aphy) |
| 527 | return -ENOENT; |
| 528 | return ath9k_wiphy_del(aphy); |
| 529 | } |
| 530 | |
| 531 | static int pause_wiphy(struct ath_softc *sc, const char *name) |
| 532 | { |
| 533 | struct ath_wiphy *aphy = get_wiphy(sc, name); |
| 534 | if (!aphy) |
| 535 | return -ENOENT; |
| 536 | return ath9k_wiphy_pause(aphy); |
| 537 | } |
| 538 | |
| 539 | static int unpause_wiphy(struct ath_softc *sc, const char *name) |
| 540 | { |
| 541 | struct ath_wiphy *aphy = get_wiphy(sc, name); |
| 542 | if (!aphy) |
| 543 | return -ENOENT; |
| 544 | return ath9k_wiphy_unpause(aphy); |
| 545 | } |
| 546 | |
| 547 | static int select_wiphy(struct ath_softc *sc, const char *name) |
| 548 | { |
| 549 | struct ath_wiphy *aphy = get_wiphy(sc, name); |
| 550 | if (!aphy) |
| 551 | return -ENOENT; |
| 552 | return ath9k_wiphy_select(aphy); |
| 553 | } |
| 554 | |
| 555 | static int schedule_wiphy(struct ath_softc *sc, const char *msec) |
| 556 | { |
| 557 | ath9k_wiphy_set_scheduler(sc, simple_strtoul(msec, NULL, 0)); |
| 558 | return 0; |
| 559 | } |
| 560 | |
| 561 | static ssize_t write_file_wiphy(struct file *file, const char __user *user_buf, |
| 562 | size_t count, loff_t *ppos) |
| 563 | { |
| 564 | struct ath_softc *sc = file->private_data; |
| 565 | char buf[50]; |
| 566 | size_t len; |
| 567 | |
| 568 | len = min(count, sizeof(buf) - 1); |
| 569 | if (copy_from_user(buf, user_buf, len)) |
| 570 | return -EFAULT; |
| 571 | buf[len] = '\0'; |
| 572 | if (len > 0 && buf[len - 1] == '\n') |
| 573 | buf[len - 1] = '\0'; |
| 574 | |
| 575 | if (strncmp(buf, "add", 3) == 0) { |
| 576 | int res = ath9k_wiphy_add(sc); |
| 577 | if (res < 0) |
| 578 | return res; |
| 579 | } else if (strncmp(buf, "del=", 4) == 0) { |
| 580 | int res = del_wiphy(sc, buf + 4); |
| 581 | if (res < 0) |
| 582 | return res; |
| 583 | } else if (strncmp(buf, "pause=", 6) == 0) { |
| 584 | int res = pause_wiphy(sc, buf + 6); |
| 585 | if (res < 0) |
| 586 | return res; |
| 587 | } else if (strncmp(buf, "unpause=", 8) == 0) { |
| 588 | int res = unpause_wiphy(sc, buf + 8); |
| 589 | if (res < 0) |
| 590 | return res; |
| 591 | } else if (strncmp(buf, "select=", 7) == 0) { |
| 592 | int res = select_wiphy(sc, buf + 7); |
| 593 | if (res < 0) |
| 594 | return res; |
| 595 | } else if (strncmp(buf, "schedule=", 9) == 0) { |
| 596 | int res = schedule_wiphy(sc, buf + 9); |
| 597 | if (res < 0) |
| 598 | return res; |
| 599 | } else |
| 600 | return -EOPNOTSUPP; |
| 601 | |
| 602 | return count; |
| 603 | } |
| 604 | |
| 605 | static const struct file_operations fops_wiphy = { |
| 606 | .read = read_file_wiphy, |
| 607 | .write = write_file_wiphy, |
| 608 | .open = ath9k_debugfs_open, |
| 609 | .owner = THIS_MODULE |
| 610 | }; |
| 611 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 612 | #define PR(str, elem) \ |
| 613 | do { \ |
| 614 | len += snprintf(buf + len, size - len, \ |
| 615 | "%s%13u%11u%10u%10u\n", str, \ |
| 616 | sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_BE]].elem, \ |
| 617 | sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_BK]].elem, \ |
| 618 | sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_VI]].elem, \ |
| 619 | sc->debug.stats.txstats[sc->tx.hwq_map[ATH9K_WME_AC_VO]].elem); \ |
| 620 | } while(0) |
| 621 | |
| 622 | static ssize_t read_file_xmit(struct file *file, char __user *user_buf, |
| 623 | size_t count, loff_t *ppos) |
| 624 | { |
| 625 | struct ath_softc *sc = file->private_data; |
| 626 | char *buf; |
| 627 | unsigned int len = 0, size = 2048; |
| 628 | ssize_t retval = 0; |
| 629 | |
| 630 | buf = kzalloc(size, GFP_KERNEL); |
| 631 | if (buf == NULL) |
| 632 | return 0; |
| 633 | |
| 634 | len += sprintf(buf, "%30s %10s%10s%10s\n\n", "BE", "BK", "VI", "VO"); |
| 635 | |
| 636 | PR("MPDUs Queued: ", queued); |
| 637 | PR("MPDUs Completed: ", completed); |
| 638 | PR("Aggregates: ", a_aggr); |
| 639 | PR("AMPDUs Queued: ", a_queued); |
| 640 | PR("AMPDUs Completed:", a_completed); |
| 641 | PR("AMPDUs Retried: ", a_retries); |
| 642 | PR("AMPDUs XRetried: ", a_xretries); |
| 643 | PR("FIFO Underrun: ", fifo_underrun); |
| 644 | PR("TXOP Exceeded: ", xtxop); |
| 645 | PR("TXTIMER Expiry: ", timer_exp); |
| 646 | PR("DESC CFG Error: ", desc_cfg_err); |
| 647 | PR("DATA Underrun: ", data_underrun); |
| 648 | PR("DELIM Underrun: ", delim_underrun); |
| 649 | |
| 650 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 651 | kfree(buf); |
| 652 | |
| 653 | return retval; |
| 654 | } |
| 655 | |
| 656 | 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] | 657 | struct ath_buf *bf, struct ath_tx_status *ts) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 658 | { |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 659 | if (bf_isampdu(bf)) { |
| 660 | if (bf_isxretried(bf)) |
| 661 | TX_STAT_INC(txq->axq_qnum, a_xretries); |
| 662 | else |
| 663 | TX_STAT_INC(txq->axq_qnum, a_completed); |
| 664 | } else { |
| 665 | TX_STAT_INC(txq->axq_qnum, completed); |
| 666 | } |
| 667 | |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 668 | if (ts->ts_status & ATH9K_TXERR_FIFO) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 669 | TX_STAT_INC(txq->axq_qnum, fifo_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 670 | if (ts->ts_status & ATH9K_TXERR_XTXOP) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 671 | TX_STAT_INC(txq->axq_qnum, xtxop); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 672 | if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 673 | TX_STAT_INC(txq->axq_qnum, timer_exp); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 674 | if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 675 | TX_STAT_INC(txq->axq_qnum, desc_cfg_err); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 676 | if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 677 | TX_STAT_INC(txq->axq_qnum, data_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 678 | if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 679 | TX_STAT_INC(txq->axq_qnum, delim_underrun); |
| 680 | } |
| 681 | |
| 682 | static const struct file_operations fops_xmit = { |
| 683 | .read = read_file_xmit, |
| 684 | .open = ath9k_debugfs_open, |
| 685 | .owner = THIS_MODULE |
| 686 | }; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 687 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 688 | static ssize_t read_file_recv(struct file *file, char __user *user_buf, |
| 689 | size_t count, loff_t *ppos) |
| 690 | { |
| 691 | #define PHY_ERR(s, p) \ |
| 692 | len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \ |
| 693 | sc->debug.stats.rxstats.phy_err_stats[p]); |
| 694 | |
| 695 | struct ath_softc *sc = file->private_data; |
| 696 | char *buf; |
| 697 | unsigned int len = 0, size = 1152; |
| 698 | ssize_t retval = 0; |
| 699 | |
| 700 | buf = kzalloc(size, GFP_KERNEL); |
| 701 | if (buf == NULL) |
| 702 | return 0; |
| 703 | |
| 704 | len += snprintf(buf + len, size - len, |
| 705 | "%18s : %10u\n", "CRC ERR", |
| 706 | sc->debug.stats.rxstats.crc_err); |
| 707 | len += snprintf(buf + len, size - len, |
| 708 | "%18s : %10u\n", "DECRYPT CRC ERR", |
| 709 | sc->debug.stats.rxstats.decrypt_crc_err); |
| 710 | len += snprintf(buf + len, size - len, |
| 711 | "%18s : %10u\n", "PHY ERR", |
| 712 | sc->debug.stats.rxstats.phy_err); |
| 713 | len += snprintf(buf + len, size - len, |
| 714 | "%18s : %10u\n", "MIC ERR", |
| 715 | sc->debug.stats.rxstats.mic_err); |
| 716 | len += snprintf(buf + len, size - len, |
| 717 | "%18s : %10u\n", "PRE-DELIM CRC ERR", |
| 718 | sc->debug.stats.rxstats.pre_delim_crc_err); |
| 719 | len += snprintf(buf + len, size - len, |
| 720 | "%18s : %10u\n", "POST-DELIM CRC ERR", |
| 721 | sc->debug.stats.rxstats.post_delim_crc_err); |
| 722 | len += snprintf(buf + len, size - len, |
| 723 | "%18s : %10u\n", "DECRYPT BUSY ERR", |
| 724 | sc->debug.stats.rxstats.decrypt_busy_err); |
| 725 | |
| 726 | PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN); |
| 727 | PHY_ERR("TIMING", ATH9K_PHYERR_TIMING); |
| 728 | PHY_ERR("PARITY", ATH9K_PHYERR_PARITY); |
| 729 | PHY_ERR("RATE", ATH9K_PHYERR_RATE); |
| 730 | PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH); |
| 731 | PHY_ERR("RADAR", ATH9K_PHYERR_RADAR); |
| 732 | PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE); |
| 733 | PHY_ERR("TOR", ATH9K_PHYERR_TOR); |
| 734 | PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING); |
| 735 | PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); |
| 736 | PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); |
| 737 | PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); |
| 738 | PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP); |
| 739 | PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE); |
| 740 | PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART); |
| 741 | PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT); |
| 742 | PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING); |
| 743 | PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC); |
| 744 | PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL); |
| 745 | PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE); |
| 746 | PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART); |
| 747 | PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); |
| 748 | PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP); |
| 749 | PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR); |
| 750 | PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); |
| 751 | PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL); |
| 752 | |
| 753 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 754 | kfree(buf); |
| 755 | |
| 756 | return retval; |
| 757 | |
| 758 | #undef PHY_ERR |
| 759 | } |
| 760 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 761 | 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] | 762 | { |
| 763 | #define RX_STAT_INC(c) sc->debug.stats.rxstats.c++ |
| 764 | #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++ |
| 765 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 766 | u32 phyerr; |
| 767 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 768 | if (rs->rs_status & ATH9K_RXERR_CRC) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 769 | RX_STAT_INC(crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 770 | if (rs->rs_status & ATH9K_RXERR_DECRYPT) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 771 | RX_STAT_INC(decrypt_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 772 | if (rs->rs_status & ATH9K_RXERR_MIC) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 773 | RX_STAT_INC(mic_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 774 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 775 | RX_STAT_INC(pre_delim_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 776 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 777 | RX_STAT_INC(post_delim_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 778 | if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 779 | RX_STAT_INC(decrypt_busy_err); |
| 780 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 781 | if (rs->rs_status & ATH9K_RXERR_PHY) { |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 782 | RX_STAT_INC(phy_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 783 | phyerr = rs->rs_phyerr & 0x24; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 784 | RX_PHY_ERR_INC(phyerr); |
| 785 | } |
| 786 | |
| 787 | #undef RX_STAT_INC |
| 788 | #undef RX_PHY_ERR_INC |
| 789 | } |
| 790 | |
| 791 | static const struct file_operations fops_recv = { |
| 792 | .read = read_file_recv, |
| 793 | .open = ath9k_debugfs_open, |
| 794 | .owner = THIS_MODULE |
| 795 | }; |
| 796 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 797 | int ath9k_init_debug(struct ath_hw *ah) |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 798 | { |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 799 | struct ath_common *common = ath9k_hw_common(ah); |
| 800 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 801 | |
Sujith | 7dd5874 | 2009-03-30 15:28:42 +0530 | [diff] [blame] | 802 | if (!ath9k_debugfs_root) |
| 803 | return -ENOENT; |
| 804 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 805 | sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy), |
Gabor Juhos | 19d8bc2 | 2009-03-05 16:55:18 +0100 | [diff] [blame] | 806 | ath9k_debugfs_root); |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 807 | if (!sc->debug.debugfs_phy) |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 808 | return -ENOMEM; |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 809 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 810 | #ifdef CONFIG_ATH_DEBUG |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 811 | if (!debugfs_create_file("debug", S_IRUSR | S_IWUSR, |
| 812 | sc->debug.debugfs_phy, sc, &fops_debug)) |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 813 | goto err; |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 814 | #endif |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 815 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 816 | if (!debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, |
| 817 | sc, &fops_dma)) |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 818 | goto err; |
| 819 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 820 | if (!debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, |
| 821 | sc, &fops_interrupt)) |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 822 | goto err; |
| 823 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 824 | if (!debugfs_create_file("rcstat", S_IRUSR, sc->debug.debugfs_phy, |
| 825 | sc, &fops_rcstat)) |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 826 | goto err; |
| 827 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 828 | if (!debugfs_create_file("wiphy", S_IRUSR | S_IWUSR, |
| 829 | sc->debug.debugfs_phy, sc, &fops_wiphy)) |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 830 | goto err; |
| 831 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 832 | if (!debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, |
| 833 | sc, &fops_xmit)) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 834 | goto err; |
| 835 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 836 | if (!debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, |
| 837 | sc, &fops_recv)) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 838 | goto err; |
| 839 | |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame^] | 840 | if (!debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, |
| 841 | sc->debug.debugfs_phy, sc, &fops_rx_chainmask)) |
| 842 | goto err; |
| 843 | |
| 844 | if (!debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, |
| 845 | sc->debug.debugfs_phy, sc, &fops_tx_chainmask)) |
| 846 | goto err; |
| 847 | |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 848 | return 0; |
| 849 | err: |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 850 | ath9k_exit_debug(ah); |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 851 | return -ENOMEM; |
| 852 | } |
| 853 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 854 | void ath9k_exit_debug(struct ath_hw *ah) |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 855 | { |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 856 | struct ath_common *common = ath9k_hw_common(ah); |
| 857 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 858 | |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 859 | debugfs_remove_recursive(sc->debug.debugfs_phy); |
Gabor Juhos | 19d8bc2 | 2009-03-05 16:55:18 +0100 | [diff] [blame] | 860 | } |
| 861 | |
| 862 | int ath9k_debug_create_root(void) |
| 863 | { |
| 864 | ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL); |
| 865 | if (!ath9k_debugfs_root) |
| 866 | return -ENOENT; |
| 867 | |
| 868 | return 0; |
| 869 | } |
| 870 | |
| 871 | void ath9k_debug_remove_root(void) |
| 872 | { |
| 873 | debugfs_remove(ath9k_debugfs_root); |
| 874 | ath9k_debugfs_root = NULL; |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 875 | } |