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