Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 1 | /* |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 2 | * Copyright (c) 2007-2008 Bruno Randolf <bruno@thinktube.com> |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 3 | * |
| 4 | * This file is free software: you may copy, redistribute and/or modify it |
| 5 | * under the terms of the GNU General Public License as published by the |
| 6 | * Free Software Foundation, either version 2 of the License, or (at your |
| 7 | * option) any later version. |
| 8 | * |
| 9 | * This file is distributed in the hope that it will be useful, but |
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | * |
| 17 | * |
| 18 | * This file incorporates work covered by the following copyright and |
| 19 | * permission notice: |
| 20 | * |
| 21 | * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting |
| 22 | * Copyright (c) 2004-2005 Atheros Communications, Inc. |
| 23 | * Copyright (c) 2006 Devicescape Software, Inc. |
| 24 | * Copyright (c) 2007 Jiri Slaby <jirislaby@gmail.com> |
| 25 | * Copyright (c) 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu> |
| 26 | * |
| 27 | * All rights reserved. |
| 28 | * |
| 29 | * Redistribution and use in source and binary forms, with or without |
| 30 | * modification, are permitted provided that the following conditions |
| 31 | * are met: |
| 32 | * 1. Redistributions of source code must retain the above copyright |
| 33 | * notice, this list of conditions and the following disclaimer, |
| 34 | * without modification. |
| 35 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 36 | * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any |
| 37 | * redistribution must be conditioned upon including a substantially |
| 38 | * similar Disclaimer requirement for further binary redistribution. |
| 39 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 40 | * of any contributors may be used to endorse or promote products derived |
| 41 | * from this software without specific prior written permission. |
| 42 | * |
| 43 | * Alternatively, this software may be distributed under the terms of the |
| 44 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 45 | * Software Foundation. |
| 46 | * |
| 47 | * NO WARRANTY |
| 48 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 49 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 50 | * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY |
| 51 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
| 52 | * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, |
| 53 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 54 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 55 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
| 56 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 57 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 58 | * THE POSSIBILITY OF SUCH DAMAGES. |
| 59 | */ |
| 60 | |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 61 | #include "base.h" |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 62 | #include "debug.h" |
Ben Greear | 92c68a6 | 2010-10-08 09:43:29 -0700 | [diff] [blame] | 63 | #include "../debug.h" |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 64 | |
| 65 | static unsigned int ath5k_debug; |
| 66 | module_param_named(debug, ath5k_debug, uint, 0); |
| 67 | |
| 68 | |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 69 | #ifdef CONFIG_ATH5K_DEBUG |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 70 | |
| 71 | #include <linux/seq_file.h> |
| 72 | #include "reg.h" |
Bruno Randolf | 2111ac0 | 2010-04-02 18:44:08 +0900 | [diff] [blame] | 73 | #include "ani.h" |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 74 | |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 75 | static int ath5k_debugfs_open(struct inode *inode, struct file *file) |
| 76 | { |
| 77 | file->private_data = inode->i_private; |
| 78 | return 0; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | /* debugfs: registers */ |
| 83 | |
| 84 | struct reg { |
Jiri Slaby | 2c91108c | 2009-03-07 10:26:41 +0100 | [diff] [blame] | 85 | const char *name; |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 86 | int addr; |
| 87 | }; |
| 88 | |
| 89 | #define REG_STRUCT_INIT(r) { #r, r } |
| 90 | |
| 91 | /* just a few random registers, might want to add more */ |
Jiri Slaby | 2c91108c | 2009-03-07 10:26:41 +0100 | [diff] [blame] | 92 | static const struct reg regs[] = { |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 93 | REG_STRUCT_INIT(AR5K_CR), |
| 94 | REG_STRUCT_INIT(AR5K_RXDP), |
| 95 | REG_STRUCT_INIT(AR5K_CFG), |
| 96 | REG_STRUCT_INIT(AR5K_IER), |
| 97 | REG_STRUCT_INIT(AR5K_BCR), |
| 98 | REG_STRUCT_INIT(AR5K_RTSD0), |
| 99 | REG_STRUCT_INIT(AR5K_RTSD1), |
| 100 | REG_STRUCT_INIT(AR5K_TXCFG), |
| 101 | REG_STRUCT_INIT(AR5K_RXCFG), |
| 102 | REG_STRUCT_INIT(AR5K_RXJLA), |
| 103 | REG_STRUCT_INIT(AR5K_MIBC), |
| 104 | REG_STRUCT_INIT(AR5K_TOPS), |
| 105 | REG_STRUCT_INIT(AR5K_RXNOFRM), |
| 106 | REG_STRUCT_INIT(AR5K_TXNOFRM), |
| 107 | REG_STRUCT_INIT(AR5K_RPGTO), |
| 108 | REG_STRUCT_INIT(AR5K_RFCNT), |
| 109 | REG_STRUCT_INIT(AR5K_MISC), |
| 110 | REG_STRUCT_INIT(AR5K_QCUDCU_CLKGT), |
| 111 | REG_STRUCT_INIT(AR5K_ISR), |
| 112 | REG_STRUCT_INIT(AR5K_PISR), |
| 113 | REG_STRUCT_INIT(AR5K_SISR0), |
| 114 | REG_STRUCT_INIT(AR5K_SISR1), |
| 115 | REG_STRUCT_INIT(AR5K_SISR2), |
| 116 | REG_STRUCT_INIT(AR5K_SISR3), |
| 117 | REG_STRUCT_INIT(AR5K_SISR4), |
| 118 | REG_STRUCT_INIT(AR5K_IMR), |
| 119 | REG_STRUCT_INIT(AR5K_PIMR), |
| 120 | REG_STRUCT_INIT(AR5K_SIMR0), |
| 121 | REG_STRUCT_INIT(AR5K_SIMR1), |
| 122 | REG_STRUCT_INIT(AR5K_SIMR2), |
| 123 | REG_STRUCT_INIT(AR5K_SIMR3), |
| 124 | REG_STRUCT_INIT(AR5K_SIMR4), |
| 125 | REG_STRUCT_INIT(AR5K_DCM_ADDR), |
| 126 | REG_STRUCT_INIT(AR5K_DCCFG), |
| 127 | REG_STRUCT_INIT(AR5K_CCFG), |
| 128 | REG_STRUCT_INIT(AR5K_CPC0), |
| 129 | REG_STRUCT_INIT(AR5K_CPC1), |
| 130 | REG_STRUCT_INIT(AR5K_CPC2), |
| 131 | REG_STRUCT_INIT(AR5K_CPC3), |
Nick Kossifidis | 0bacdf3 | 2008-07-30 13:18:59 +0300 | [diff] [blame] | 132 | REG_STRUCT_INIT(AR5K_CPCOVF), |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 133 | REG_STRUCT_INIT(AR5K_RESET_CTL), |
| 134 | REG_STRUCT_INIT(AR5K_SLEEP_CTL), |
| 135 | REG_STRUCT_INIT(AR5K_INTPEND), |
| 136 | REG_STRUCT_INIT(AR5K_SFR), |
| 137 | REG_STRUCT_INIT(AR5K_PCICFG), |
| 138 | REG_STRUCT_INIT(AR5K_GPIOCR), |
| 139 | REG_STRUCT_INIT(AR5K_GPIODO), |
| 140 | REG_STRUCT_INIT(AR5K_SREV), |
| 141 | }; |
| 142 | |
| 143 | static void *reg_start(struct seq_file *seq, loff_t *pos) |
| 144 | { |
Jiri Slaby | 2c91108c | 2009-03-07 10:26:41 +0100 | [diff] [blame] | 145 | return *pos < ARRAY_SIZE(regs) ? (void *)®s[*pos] : NULL; |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | static void reg_stop(struct seq_file *seq, void *p) |
| 149 | { |
| 150 | /* nothing to do */ |
| 151 | } |
| 152 | |
| 153 | static void *reg_next(struct seq_file *seq, void *p, loff_t *pos) |
| 154 | { |
| 155 | ++*pos; |
Jiri Slaby | 2c91108c | 2009-03-07 10:26:41 +0100 | [diff] [blame] | 156 | return *pos < ARRAY_SIZE(regs) ? (void *)®s[*pos] : NULL; |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | static int reg_show(struct seq_file *seq, void *p) |
| 160 | { |
| 161 | struct ath5k_softc *sc = seq->private; |
| 162 | struct reg *r = p; |
| 163 | seq_printf(seq, "%-25s0x%08x\n", r->name, |
| 164 | ath5k_hw_reg_read(sc->ah, r->addr)); |
| 165 | return 0; |
| 166 | } |
| 167 | |
Jan Engelhardt | 4101dec | 2009-01-14 13:52:18 -0800 | [diff] [blame] | 168 | static const struct seq_operations register_seq_ops = { |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 169 | .start = reg_start, |
| 170 | .next = reg_next, |
| 171 | .stop = reg_stop, |
| 172 | .show = reg_show |
| 173 | }; |
| 174 | |
| 175 | static int open_file_registers(struct inode *inode, struct file *file) |
| 176 | { |
| 177 | struct seq_file *s; |
| 178 | int res; |
| 179 | res = seq_open(file, ®ister_seq_ops); |
| 180 | if (res == 0) { |
| 181 | s = file->private_data; |
| 182 | s->private = inode->i_private; |
| 183 | } |
| 184 | return res; |
| 185 | } |
| 186 | |
| 187 | static const struct file_operations fops_registers = { |
| 188 | .open = open_file_registers, |
| 189 | .read = seq_read, |
| 190 | .llseek = seq_lseek, |
| 191 | .release = seq_release, |
| 192 | .owner = THIS_MODULE, |
| 193 | }; |
| 194 | |
| 195 | |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 196 | /* debugfs: beacons */ |
| 197 | |
| 198 | static ssize_t read_file_beacon(struct file *file, char __user *user_buf, |
| 199 | size_t count, loff_t *ppos) |
| 200 | { |
| 201 | struct ath5k_softc *sc = file->private_data; |
| 202 | struct ath5k_hw *ah = sc->ah; |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 203 | char buf[500]; |
| 204 | unsigned int len = 0; |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 205 | unsigned int v; |
| 206 | u64 tsf; |
| 207 | |
| 208 | v = ath5k_hw_reg_read(sc->ah, AR5K_BEACON); |
| 209 | len += snprintf(buf+len, sizeof(buf)-len, |
| 210 | "%-24s0x%08x\tintval: %d\tTIM: 0x%x\n", |
| 211 | "AR5K_BEACON", v, v & AR5K_BEACON_PERIOD, |
| 212 | (v & AR5K_BEACON_TIM) >> AR5K_BEACON_TIM_S); |
| 213 | |
| 214 | len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n", |
| 215 | "AR5K_LAST_TSTP", ath5k_hw_reg_read(sc->ah, AR5K_LAST_TSTP)); |
| 216 | |
| 217 | len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n\n", |
| 218 | "AR5K_BEACON_CNT", ath5k_hw_reg_read(sc->ah, AR5K_BEACON_CNT)); |
| 219 | |
| 220 | v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER0); |
| 221 | len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n", |
| 222 | "AR5K_TIMER0 (TBTT)", v, v); |
| 223 | |
| 224 | v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER1); |
| 225 | len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n", |
| 226 | "AR5K_TIMER1 (DMA)", v, v >> 3); |
| 227 | |
| 228 | v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER2); |
| 229 | len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n", |
| 230 | "AR5K_TIMER2 (SWBA)", v, v >> 3); |
| 231 | |
| 232 | v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER3); |
| 233 | len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n", |
| 234 | "AR5K_TIMER3 (ATIM)", v, v); |
| 235 | |
| 236 | tsf = ath5k_hw_get_tsf64(sc->ah); |
| 237 | len += snprintf(buf+len, sizeof(buf)-len, |
John W. Linville | f868f4e | 2008-03-07 16:38:43 -0500 | [diff] [blame] | 238 | "TSF\t\t0x%016llx\tTU: %08x\n", |
| 239 | (unsigned long long)tsf, TSF_TO_TU(tsf)); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 240 | |
Dan Carpenter | 2189d13 | 2010-07-22 10:52:02 +0200 | [diff] [blame] | 241 | if (len > sizeof(buf)) |
| 242 | len = sizeof(buf); |
| 243 | |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 244 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 245 | } |
| 246 | |
| 247 | static ssize_t write_file_beacon(struct file *file, |
| 248 | const char __user *userbuf, |
| 249 | size_t count, loff_t *ppos) |
| 250 | { |
| 251 | struct ath5k_softc *sc = file->private_data; |
| 252 | struct ath5k_hw *ah = sc->ah; |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 253 | char buf[20]; |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 254 | |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 255 | if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) |
| 256 | return -EFAULT; |
| 257 | |
| 258 | if (strncmp(buf, "disable", 7) == 0) { |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 259 | AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE); |
| 260 | printk(KERN_INFO "debugfs disable beacons\n"); |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 261 | } else if (strncmp(buf, "enable", 6) == 0) { |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 262 | AR5K_REG_ENABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE); |
| 263 | printk(KERN_INFO "debugfs enable beacons\n"); |
| 264 | } |
| 265 | return count; |
| 266 | } |
| 267 | |
| 268 | static const struct file_operations fops_beacon = { |
| 269 | .read = read_file_beacon, |
| 270 | .write = write_file_beacon, |
| 271 | .open = ath5k_debugfs_open, |
| 272 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 273 | .llseek = default_llseek, |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 274 | }; |
| 275 | |
| 276 | |
| 277 | /* debugfs: reset */ |
| 278 | |
| 279 | static ssize_t write_file_reset(struct file *file, |
| 280 | const char __user *userbuf, |
| 281 | size_t count, loff_t *ppos) |
| 282 | { |
| 283 | struct ath5k_softc *sc = file->private_data; |
Bruno Randolf | 8d67a03 | 2010-06-16 19:11:12 +0900 | [diff] [blame] | 284 | ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "debug file triggered reset\n"); |
Bob Copeland | 5faaff7 | 2010-07-13 11:32:40 -0400 | [diff] [blame] | 285 | ieee80211_queue_work(sc->hw, &sc->reset_work); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 286 | return count; |
| 287 | } |
| 288 | |
| 289 | static const struct file_operations fops_reset = { |
| 290 | .write = write_file_reset, |
| 291 | .open = ath5k_debugfs_open, |
| 292 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 293 | .llseek = noop_llseek, |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 294 | }; |
| 295 | |
| 296 | |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 297 | /* debugfs: debug level */ |
| 298 | |
Jiri Slaby | 2c91108c | 2009-03-07 10:26:41 +0100 | [diff] [blame] | 299 | static const struct { |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 300 | enum ath5k_debug_level level; |
| 301 | const char *name; |
| 302 | const char *desc; |
| 303 | } dbg_info[] = { |
| 304 | { ATH5K_DEBUG_RESET, "reset", "reset and initialization" }, |
| 305 | { ATH5K_DEBUG_INTR, "intr", "interrupt handling" }, |
| 306 | { ATH5K_DEBUG_MODE, "mode", "mode init/setup" }, |
| 307 | { ATH5K_DEBUG_XMIT, "xmit", "basic xmit operation" }, |
| 308 | { ATH5K_DEBUG_BEACON, "beacon", "beacon handling" }, |
| 309 | { ATH5K_DEBUG_CALIBRATE, "calib", "periodic calibration" }, |
| 310 | { ATH5K_DEBUG_TXPOWER, "txpower", "transmit power setting" }, |
Bob Copeland | 85519a6 | 2008-10-29 08:30:53 -0400 | [diff] [blame] | 311 | { ATH5K_DEBUG_LED, "led", "LED management" }, |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 312 | { ATH5K_DEBUG_DUMP_RX, "dumprx", "print received skb content" }, |
| 313 | { ATH5K_DEBUG_DUMP_TX, "dumptx", "print transmit skb content" }, |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 314 | { ATH5K_DEBUG_DUMPBANDS, "dumpbands", "dump bands" }, |
Nick Kossifidis | b3a28e6 | 2010-11-23 20:47:31 +0200 | [diff] [blame] | 315 | { ATH5K_DEBUG_DMA, "dma", "dma start/stop" }, |
Bruno Randolf | 2111ac0 | 2010-04-02 18:44:08 +0900 | [diff] [blame] | 316 | { ATH5K_DEBUG_ANI, "ani", "adaptive noise immunity" }, |
Bob Copeland | b4c5261 | 2010-08-21 16:39:03 -0400 | [diff] [blame] | 317 | { ATH5K_DEBUG_DESC, "desc", "descriptor chains" }, |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 318 | { ATH5K_DEBUG_ANY, "all", "show all debug levels" }, |
| 319 | }; |
| 320 | |
| 321 | static ssize_t read_file_debug(struct file *file, char __user *user_buf, |
| 322 | size_t count, loff_t *ppos) |
| 323 | { |
| 324 | struct ath5k_softc *sc = file->private_data; |
| 325 | char buf[700]; |
| 326 | unsigned int len = 0; |
| 327 | unsigned int i; |
| 328 | |
| 329 | len += snprintf(buf+len, sizeof(buf)-len, |
| 330 | "DEBUG LEVEL: 0x%08x\n\n", sc->debug.level); |
| 331 | |
| 332 | for (i = 0; i < ARRAY_SIZE(dbg_info) - 1; i++) { |
| 333 | len += snprintf(buf+len, sizeof(buf)-len, |
| 334 | "%10s %c 0x%08x - %s\n", dbg_info[i].name, |
| 335 | sc->debug.level & dbg_info[i].level ? '+' : ' ', |
| 336 | dbg_info[i].level, dbg_info[i].desc); |
| 337 | } |
| 338 | len += snprintf(buf+len, sizeof(buf)-len, |
| 339 | "%10s %c 0x%08x - %s\n", dbg_info[i].name, |
| 340 | sc->debug.level == dbg_info[i].level ? '+' : ' ', |
| 341 | dbg_info[i].level, dbg_info[i].desc); |
| 342 | |
Dan Carpenter | 2189d13 | 2010-07-22 10:52:02 +0200 | [diff] [blame] | 343 | if (len > sizeof(buf)) |
| 344 | len = sizeof(buf); |
| 345 | |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 346 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 347 | } |
| 348 | |
| 349 | static ssize_t write_file_debug(struct file *file, |
| 350 | const char __user *userbuf, |
| 351 | size_t count, loff_t *ppos) |
| 352 | { |
| 353 | struct ath5k_softc *sc = file->private_data; |
| 354 | unsigned int i; |
| 355 | char buf[20]; |
| 356 | |
| 357 | if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) |
| 358 | return -EFAULT; |
| 359 | |
| 360 | for (i = 0; i < ARRAY_SIZE(dbg_info); i++) { |
| 361 | if (strncmp(buf, dbg_info[i].name, |
| 362 | strlen(dbg_info[i].name)) == 0) { |
| 363 | sc->debug.level ^= dbg_info[i].level; /* toggle bit */ |
| 364 | break; |
| 365 | } |
| 366 | } |
| 367 | return count; |
| 368 | } |
| 369 | |
| 370 | static const struct file_operations fops_debug = { |
| 371 | .read = read_file_debug, |
| 372 | .write = write_file_debug, |
| 373 | .open = ath5k_debugfs_open, |
| 374 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 375 | .llseek = default_llseek, |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 376 | }; |
| 377 | |
| 378 | |
Bruno Randolf | 604eead | 2010-03-09 16:55:17 +0900 | [diff] [blame] | 379 | /* debugfs: antenna */ |
| 380 | |
| 381 | static ssize_t read_file_antenna(struct file *file, char __user *user_buf, |
| 382 | size_t count, loff_t *ppos) |
| 383 | { |
| 384 | struct ath5k_softc *sc = file->private_data; |
| 385 | char buf[700]; |
| 386 | unsigned int len = 0; |
| 387 | unsigned int i; |
| 388 | unsigned int v; |
| 389 | |
| 390 | len += snprintf(buf+len, sizeof(buf)-len, "antenna mode\t%d\n", |
| 391 | sc->ah->ah_ant_mode); |
| 392 | len += snprintf(buf+len, sizeof(buf)-len, "default antenna\t%d\n", |
| 393 | sc->ah->ah_def_ant); |
| 394 | len += snprintf(buf+len, sizeof(buf)-len, "tx antenna\t%d\n", |
| 395 | sc->ah->ah_tx_ant); |
| 396 | |
| 397 | len += snprintf(buf+len, sizeof(buf)-len, "\nANTENNA\t\tRX\tTX\n"); |
| 398 | for (i = 1; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) { |
| 399 | len += snprintf(buf+len, sizeof(buf)-len, |
| 400 | "[antenna %d]\t%d\t%d\n", |
| 401 | i, sc->stats.antenna_rx[i], sc->stats.antenna_tx[i]); |
| 402 | } |
| 403 | len += snprintf(buf+len, sizeof(buf)-len, "[invalid]\t%d\t%d\n", |
| 404 | sc->stats.antenna_rx[0], sc->stats.antenna_tx[0]); |
| 405 | |
| 406 | v = ath5k_hw_reg_read(sc->ah, AR5K_DEFAULT_ANTENNA); |
| 407 | len += snprintf(buf+len, sizeof(buf)-len, |
| 408 | "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v); |
| 409 | |
| 410 | v = ath5k_hw_reg_read(sc->ah, AR5K_STA_ID1); |
| 411 | len += snprintf(buf+len, sizeof(buf)-len, |
| 412 | "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n", |
| 413 | (v & AR5K_STA_ID1_DEFAULT_ANTENNA) != 0); |
| 414 | len += snprintf(buf+len, sizeof(buf)-len, |
| 415 | "AR5K_STA_ID1_DESC_ANTENNA\t%d\n", |
| 416 | (v & AR5K_STA_ID1_DESC_ANTENNA) != 0); |
| 417 | len += snprintf(buf+len, sizeof(buf)-len, |
| 418 | "AR5K_STA_ID1_RTS_DEF_ANTENNA\t%d\n", |
| 419 | (v & AR5K_STA_ID1_RTS_DEF_ANTENNA) != 0); |
| 420 | len += snprintf(buf+len, sizeof(buf)-len, |
| 421 | "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n", |
| 422 | (v & AR5K_STA_ID1_SELFGEN_DEF_ANT) != 0); |
| 423 | |
| 424 | v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_AGCCTL); |
| 425 | len += snprintf(buf+len, sizeof(buf)-len, |
| 426 | "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n", |
| 427 | (v & AR5K_PHY_AGCCTL_OFDM_DIV_DIS) != 0); |
| 428 | |
| 429 | v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_RESTART); |
| 430 | len += snprintf(buf+len, sizeof(buf)-len, |
| 431 | "AR5K_PHY_RESTART_DIV_GC\t\t%x\n", |
| 432 | (v & AR5K_PHY_RESTART_DIV_GC) >> AR5K_PHY_RESTART_DIV_GC_S); |
| 433 | |
| 434 | v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_FAST_ANT_DIV); |
| 435 | len += snprintf(buf+len, sizeof(buf)-len, |
| 436 | "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n", |
| 437 | (v & AR5K_PHY_FAST_ANT_DIV_EN) != 0); |
| 438 | |
Bruno Randolf | 0ca7402 | 2010-06-07 13:11:30 +0900 | [diff] [blame] | 439 | v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_ANT_SWITCH_TABLE_0); |
| 440 | len += snprintf(buf+len, sizeof(buf)-len, |
| 441 | "\nAR5K_PHY_ANT_SWITCH_TABLE_0\t0x%08x\n", v); |
| 442 | v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_ANT_SWITCH_TABLE_1); |
| 443 | len += snprintf(buf+len, sizeof(buf)-len, |
| 444 | "AR5K_PHY_ANT_SWITCH_TABLE_1\t0x%08x\n", v); |
| 445 | |
Dan Carpenter | 2189d13 | 2010-07-22 10:52:02 +0200 | [diff] [blame] | 446 | if (len > sizeof(buf)) |
| 447 | len = sizeof(buf); |
| 448 | |
Bruno Randolf | 604eead | 2010-03-09 16:55:17 +0900 | [diff] [blame] | 449 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 450 | } |
| 451 | |
| 452 | static ssize_t write_file_antenna(struct file *file, |
| 453 | const char __user *userbuf, |
| 454 | size_t count, loff_t *ppos) |
| 455 | { |
| 456 | struct ath5k_softc *sc = file->private_data; |
| 457 | unsigned int i; |
| 458 | char buf[20]; |
| 459 | |
| 460 | if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) |
| 461 | return -EFAULT; |
| 462 | |
| 463 | if (strncmp(buf, "diversity", 9) == 0) { |
| 464 | ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_DEFAULT); |
| 465 | printk(KERN_INFO "ath5k debug: enable diversity\n"); |
| 466 | } else if (strncmp(buf, "fixed-a", 7) == 0) { |
| 467 | ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_A); |
| 468 | printk(KERN_INFO "ath5k debugfs: fixed antenna A\n"); |
| 469 | } else if (strncmp(buf, "fixed-b", 7) == 0) { |
| 470 | ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_B); |
| 471 | printk(KERN_INFO "ath5k debug: fixed antenna B\n"); |
| 472 | } else if (strncmp(buf, "clear", 5) == 0) { |
| 473 | for (i = 0; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) { |
| 474 | sc->stats.antenna_rx[i] = 0; |
| 475 | sc->stats.antenna_tx[i] = 0; |
| 476 | } |
| 477 | printk(KERN_INFO "ath5k debug: cleared antenna stats\n"); |
| 478 | } |
| 479 | return count; |
| 480 | } |
| 481 | |
| 482 | static const struct file_operations fops_antenna = { |
| 483 | .read = read_file_antenna, |
| 484 | .write = write_file_antenna, |
| 485 | .open = ath5k_debugfs_open, |
| 486 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 487 | .llseek = default_llseek, |
Bruno Randolf | 604eead | 2010-03-09 16:55:17 +0900 | [diff] [blame] | 488 | }; |
| 489 | |
Ben Greear | 87fd2e6 | 2010-09-21 17:03:57 -0700 | [diff] [blame] | 490 | /* debugfs: misc */ |
| 491 | |
| 492 | static ssize_t read_file_misc(struct file *file, char __user *user_buf, |
| 493 | size_t count, loff_t *ppos) |
| 494 | { |
| 495 | struct ath5k_softc *sc = file->private_data; |
| 496 | char buf[700]; |
| 497 | unsigned int len = 0; |
| 498 | u32 filt = ath5k_hw_get_rx_filter(sc->ah); |
| 499 | |
| 500 | len += snprintf(buf+len, sizeof(buf)-len, "bssid-mask: %pM\n", |
| 501 | sc->bssidmask); |
| 502 | len += snprintf(buf+len, sizeof(buf)-len, "filter-flags: 0x%x ", |
| 503 | filt); |
| 504 | if (filt & AR5K_RX_FILTER_UCAST) |
| 505 | len += snprintf(buf+len, sizeof(buf)-len, " UCAST"); |
| 506 | if (filt & AR5K_RX_FILTER_MCAST) |
| 507 | len += snprintf(buf+len, sizeof(buf)-len, " MCAST"); |
| 508 | if (filt & AR5K_RX_FILTER_BCAST) |
| 509 | len += snprintf(buf+len, sizeof(buf)-len, " BCAST"); |
| 510 | if (filt & AR5K_RX_FILTER_CONTROL) |
| 511 | len += snprintf(buf+len, sizeof(buf)-len, " CONTROL"); |
| 512 | if (filt & AR5K_RX_FILTER_BEACON) |
| 513 | len += snprintf(buf+len, sizeof(buf)-len, " BEACON"); |
| 514 | if (filt & AR5K_RX_FILTER_PROM) |
| 515 | len += snprintf(buf+len, sizeof(buf)-len, " PROM"); |
| 516 | if (filt & AR5K_RX_FILTER_XRPOLL) |
| 517 | len += snprintf(buf+len, sizeof(buf)-len, " XRPOLL"); |
| 518 | if (filt & AR5K_RX_FILTER_PROBEREQ) |
| 519 | len += snprintf(buf+len, sizeof(buf)-len, " PROBEREQ"); |
| 520 | if (filt & AR5K_RX_FILTER_PHYERR_5212) |
| 521 | len += snprintf(buf+len, sizeof(buf)-len, " PHYERR-5212"); |
| 522 | if (filt & AR5K_RX_FILTER_RADARERR_5212) |
| 523 | len += snprintf(buf+len, sizeof(buf)-len, " RADARERR-5212"); |
| 524 | if (filt & AR5K_RX_FILTER_PHYERR_5211) |
| 525 | snprintf(buf+len, sizeof(buf)-len, " PHYERR-5211"); |
| 526 | if (filt & AR5K_RX_FILTER_RADARERR_5211) |
Joe Perches | 908ebfb | 2010-10-12 11:07:44 -0700 | [diff] [blame] | 527 | len += snprintf(buf+len, sizeof(buf)-len, " RADARERR-5211"); |
Ben Greear | 87fd2e6 | 2010-09-21 17:03:57 -0700 | [diff] [blame] | 528 | |
Joe Perches | 908ebfb | 2010-10-12 11:07:44 -0700 | [diff] [blame] | 529 | len += snprintf(buf+len, sizeof(buf)-len, "\nopmode: %s (%d)\n", |
| 530 | ath_opmode_to_string(sc->opmode), sc->opmode); |
Ben Greear | 92c68a6 | 2010-10-08 09:43:29 -0700 | [diff] [blame] | 531 | |
Ben Greear | 87fd2e6 | 2010-09-21 17:03:57 -0700 | [diff] [blame] | 532 | if (len > sizeof(buf)) |
| 533 | len = sizeof(buf); |
| 534 | |
| 535 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 536 | } |
| 537 | |
| 538 | static const struct file_operations fops_misc = { |
| 539 | .read = read_file_misc, |
| 540 | .open = ath5k_debugfs_open, |
| 541 | .owner = THIS_MODULE, |
| 542 | }; |
| 543 | |
Bruno Randolf | 604eead | 2010-03-09 16:55:17 +0900 | [diff] [blame] | 544 | |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 545 | /* debugfs: frameerrors */ |
| 546 | |
| 547 | static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf, |
| 548 | size_t count, loff_t *ppos) |
| 549 | { |
| 550 | struct ath5k_softc *sc = file->private_data; |
| 551 | struct ath5k_statistics *st = &sc->stats; |
| 552 | char buf[700]; |
| 553 | unsigned int len = 0; |
Bruno Randolf | da35111 | 2010-03-25 14:49:42 +0900 | [diff] [blame] | 554 | int i; |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 555 | |
| 556 | len += snprintf(buf+len, sizeof(buf)-len, |
| 557 | "RX\n---------------------\n"); |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 558 | len += snprintf(buf+len, sizeof(buf)-len, "CRC\t%u\t(%u%%)\n", |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 559 | st->rxerr_crc, |
| 560 | st->rx_all_count > 0 ? |
| 561 | st->rxerr_crc*100/st->rx_all_count : 0); |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 562 | len += snprintf(buf+len, sizeof(buf)-len, "PHY\t%u\t(%u%%)\n", |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 563 | st->rxerr_phy, |
| 564 | st->rx_all_count > 0 ? |
| 565 | st->rxerr_phy*100/st->rx_all_count : 0); |
Bruno Randolf | da35111 | 2010-03-25 14:49:42 +0900 | [diff] [blame] | 566 | for (i = 0; i < 32; i++) { |
| 567 | if (st->rxerr_phy_code[i]) |
| 568 | len += snprintf(buf+len, sizeof(buf)-len, |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 569 | " phy_err[%u]\t%u\n", |
Bruno Randolf | da35111 | 2010-03-25 14:49:42 +0900 | [diff] [blame] | 570 | i, st->rxerr_phy_code[i]); |
| 571 | } |
| 572 | |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 573 | len += snprintf(buf+len, sizeof(buf)-len, "FIFO\t%u\t(%u%%)\n", |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 574 | st->rxerr_fifo, |
| 575 | st->rx_all_count > 0 ? |
| 576 | st->rxerr_fifo*100/st->rx_all_count : 0); |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 577 | len += snprintf(buf+len, sizeof(buf)-len, "decrypt\t%u\t(%u%%)\n", |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 578 | st->rxerr_decrypt, |
| 579 | st->rx_all_count > 0 ? |
| 580 | st->rxerr_decrypt*100/st->rx_all_count : 0); |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 581 | len += snprintf(buf+len, sizeof(buf)-len, "MIC\t%u\t(%u%%)\n", |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 582 | st->rxerr_mic, |
| 583 | st->rx_all_count > 0 ? |
| 584 | st->rxerr_mic*100/st->rx_all_count : 0); |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 585 | len += snprintf(buf+len, sizeof(buf)-len, "process\t%u\t(%u%%)\n", |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 586 | st->rxerr_proc, |
| 587 | st->rx_all_count > 0 ? |
| 588 | st->rxerr_proc*100/st->rx_all_count : 0); |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 589 | len += snprintf(buf+len, sizeof(buf)-len, "jumbo\t%u\t(%u%%)\n", |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 590 | st->rxerr_jumbo, |
| 591 | st->rx_all_count > 0 ? |
| 592 | st->rxerr_jumbo*100/st->rx_all_count : 0); |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 593 | len += snprintf(buf+len, sizeof(buf)-len, "[RX all\t%u]\n", |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 594 | st->rx_all_count); |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 595 | len += snprintf(buf+len, sizeof(buf)-len, "RX-all-bytes\t%u\n", |
Ben Greear | b72acdd | 2010-10-01 10:54:04 -0700 | [diff] [blame] | 596 | st->rx_bytes_count); |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 597 | |
| 598 | len += snprintf(buf+len, sizeof(buf)-len, |
| 599 | "\nTX\n---------------------\n"); |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 600 | len += snprintf(buf+len, sizeof(buf)-len, "retry\t%u\t(%u%%)\n", |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 601 | st->txerr_retry, |
| 602 | st->tx_all_count > 0 ? |
| 603 | st->txerr_retry*100/st->tx_all_count : 0); |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 604 | len += snprintf(buf+len, sizeof(buf)-len, "FIFO\t%u\t(%u%%)\n", |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 605 | st->txerr_fifo, |
| 606 | st->tx_all_count > 0 ? |
| 607 | st->txerr_fifo*100/st->tx_all_count : 0); |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 608 | len += snprintf(buf+len, sizeof(buf)-len, "filter\t%u\t(%u%%)\n", |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 609 | st->txerr_filt, |
| 610 | st->tx_all_count > 0 ? |
| 611 | st->txerr_filt*100/st->tx_all_count : 0); |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 612 | len += snprintf(buf+len, sizeof(buf)-len, "[TX all\t%u]\n", |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 613 | st->tx_all_count); |
Ben Greear | 5d882c9 | 2010-11-08 10:50:03 -0800 | [diff] [blame] | 614 | len += snprintf(buf+len, sizeof(buf)-len, "TX-all-bytes\t%u\n", |
Ben Greear | b72acdd | 2010-10-01 10:54:04 -0700 | [diff] [blame] | 615 | st->tx_bytes_count); |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 616 | |
Dan Carpenter | 2189d13 | 2010-07-22 10:52:02 +0200 | [diff] [blame] | 617 | if (len > sizeof(buf)) |
| 618 | len = sizeof(buf); |
| 619 | |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 620 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 621 | } |
| 622 | |
| 623 | static ssize_t write_file_frameerrors(struct file *file, |
| 624 | const char __user *userbuf, |
| 625 | size_t count, loff_t *ppos) |
| 626 | { |
| 627 | struct ath5k_softc *sc = file->private_data; |
| 628 | struct ath5k_statistics *st = &sc->stats; |
| 629 | char buf[20]; |
| 630 | |
| 631 | if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) |
| 632 | return -EFAULT; |
| 633 | |
| 634 | if (strncmp(buf, "clear", 5) == 0) { |
| 635 | st->rxerr_crc = 0; |
| 636 | st->rxerr_phy = 0; |
| 637 | st->rxerr_fifo = 0; |
| 638 | st->rxerr_decrypt = 0; |
| 639 | st->rxerr_mic = 0; |
| 640 | st->rxerr_proc = 0; |
| 641 | st->rxerr_jumbo = 0; |
| 642 | st->rx_all_count = 0; |
| 643 | st->txerr_retry = 0; |
| 644 | st->txerr_fifo = 0; |
| 645 | st->txerr_filt = 0; |
| 646 | st->tx_all_count = 0; |
| 647 | printk(KERN_INFO "ath5k debug: cleared frameerrors stats\n"); |
| 648 | } |
| 649 | return count; |
| 650 | } |
| 651 | |
| 652 | static const struct file_operations fops_frameerrors = { |
| 653 | .read = read_file_frameerrors, |
| 654 | .write = write_file_frameerrors, |
| 655 | .open = ath5k_debugfs_open, |
| 656 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 657 | .llseek = default_llseek, |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 658 | }; |
| 659 | |
| 660 | |
Bruno Randolf | 2111ac0 | 2010-04-02 18:44:08 +0900 | [diff] [blame] | 661 | /* debugfs: ani */ |
| 662 | |
| 663 | static ssize_t read_file_ani(struct file *file, char __user *user_buf, |
| 664 | size_t count, loff_t *ppos) |
| 665 | { |
| 666 | struct ath5k_softc *sc = file->private_data; |
| 667 | struct ath5k_statistics *st = &sc->stats; |
| 668 | struct ath5k_ani_state *as = &sc->ani_state; |
| 669 | |
| 670 | char buf[700]; |
| 671 | unsigned int len = 0; |
| 672 | |
| 673 | len += snprintf(buf+len, sizeof(buf)-len, |
| 674 | "HW has PHY error counters:\t%s\n", |
| 675 | sc->ah->ah_capabilities.cap_has_phyerr_counters ? |
| 676 | "yes" : "no"); |
| 677 | len += snprintf(buf+len, sizeof(buf)-len, |
| 678 | "HW max spur immunity level:\t%d\n", |
| 679 | as->max_spur_level); |
| 680 | len += snprintf(buf+len, sizeof(buf)-len, |
| 681 | "\nANI state\n--------------------------------------------\n"); |
| 682 | len += snprintf(buf+len, sizeof(buf)-len, "operating mode:\t\t\t"); |
| 683 | switch (as->ani_mode) { |
| 684 | case ATH5K_ANI_MODE_OFF: |
| 685 | len += snprintf(buf+len, sizeof(buf)-len, "OFF\n"); |
| 686 | break; |
| 687 | case ATH5K_ANI_MODE_MANUAL_LOW: |
| 688 | len += snprintf(buf+len, sizeof(buf)-len, |
| 689 | "MANUAL LOW\n"); |
| 690 | break; |
| 691 | case ATH5K_ANI_MODE_MANUAL_HIGH: |
| 692 | len += snprintf(buf+len, sizeof(buf)-len, |
| 693 | "MANUAL HIGH\n"); |
| 694 | break; |
| 695 | case ATH5K_ANI_MODE_AUTO: |
| 696 | len += snprintf(buf+len, sizeof(buf)-len, "AUTO\n"); |
| 697 | break; |
| 698 | default: |
| 699 | len += snprintf(buf+len, sizeof(buf)-len, |
| 700 | "??? (not good)\n"); |
| 701 | break; |
| 702 | } |
| 703 | len += snprintf(buf+len, sizeof(buf)-len, |
| 704 | "noise immunity level:\t\t%d\n", |
| 705 | as->noise_imm_level); |
| 706 | len += snprintf(buf+len, sizeof(buf)-len, |
| 707 | "spur immunity level:\t\t%d\n", |
| 708 | as->spur_level); |
| 709 | len += snprintf(buf+len, sizeof(buf)-len, "firstep level:\t\t\t%d\n", |
| 710 | as->firstep_level); |
| 711 | len += snprintf(buf+len, sizeof(buf)-len, |
| 712 | "OFDM weak signal detection:\t%s\n", |
| 713 | as->ofdm_weak_sig ? "on" : "off"); |
| 714 | len += snprintf(buf+len, sizeof(buf)-len, |
| 715 | "CCK weak signal detection:\t%s\n", |
| 716 | as->cck_weak_sig ? "on" : "off"); |
| 717 | |
| 718 | len += snprintf(buf+len, sizeof(buf)-len, |
| 719 | "\nMIB INTERRUPTS:\t\t%u\n", |
| 720 | st->mib_intr); |
| 721 | len += snprintf(buf+len, sizeof(buf)-len, |
| 722 | "beacon RSSI average:\t%d\n", |
Bruno Randolf | eef39be | 2010-11-16 10:58:43 +0900 | [diff] [blame] | 723 | (int)ewma_read(&sc->ah->ah_beacon_rssi_avg)); |
Felix Fietkau | 7109ca5 | 2010-10-08 22:13:54 +0200 | [diff] [blame] | 724 | |
| 725 | #define CC_PRINT(_struct, _field) \ |
| 726 | _struct._field, \ |
| 727 | _struct.cycles > 0 ? \ |
| 728 | _struct._field*100/_struct.cycles : 0 |
| 729 | |
Bruno Randolf | 2111ac0 | 2010-04-02 18:44:08 +0900 | [diff] [blame] | 730 | len += snprintf(buf+len, sizeof(buf)-len, "profcnt tx\t\t%u\t(%d%%)\n", |
Felix Fietkau | 7109ca5 | 2010-10-08 22:13:54 +0200 | [diff] [blame] | 731 | CC_PRINT(as->last_cc, tx_frame)); |
Bruno Randolf | 2111ac0 | 2010-04-02 18:44:08 +0900 | [diff] [blame] | 732 | len += snprintf(buf+len, sizeof(buf)-len, "profcnt rx\t\t%u\t(%d%%)\n", |
Felix Fietkau | 7109ca5 | 2010-10-08 22:13:54 +0200 | [diff] [blame] | 733 | CC_PRINT(as->last_cc, rx_frame)); |
Bruno Randolf | 2111ac0 | 2010-04-02 18:44:08 +0900 | [diff] [blame] | 734 | len += snprintf(buf+len, sizeof(buf)-len, "profcnt busy\t\t%u\t(%d%%)\n", |
Felix Fietkau | 7109ca5 | 2010-10-08 22:13:54 +0200 | [diff] [blame] | 735 | CC_PRINT(as->last_cc, rx_busy)); |
| 736 | #undef CC_PRINT |
Bruno Randolf | 2111ac0 | 2010-04-02 18:44:08 +0900 | [diff] [blame] | 737 | len += snprintf(buf+len, sizeof(buf)-len, "profcnt cycles\t\t%u\n", |
Felix Fietkau | 7109ca5 | 2010-10-08 22:13:54 +0200 | [diff] [blame] | 738 | as->last_cc.cycles); |
Bruno Randolf | 2111ac0 | 2010-04-02 18:44:08 +0900 | [diff] [blame] | 739 | len += snprintf(buf+len, sizeof(buf)-len, |
| 740 | "listen time\t\t%d\tlast: %d\n", |
| 741 | as->listen_time, as->last_listen); |
| 742 | len += snprintf(buf+len, sizeof(buf)-len, |
| 743 | "OFDM errors\t\t%u\tlast: %u\tsum: %u\n", |
| 744 | as->ofdm_errors, as->last_ofdm_errors, |
| 745 | as->sum_ofdm_errors); |
| 746 | len += snprintf(buf+len, sizeof(buf)-len, |
| 747 | "CCK errors\t\t%u\tlast: %u\tsum: %u\n", |
| 748 | as->cck_errors, as->last_cck_errors, |
| 749 | as->sum_cck_errors); |
| 750 | len += snprintf(buf+len, sizeof(buf)-len, |
| 751 | "AR5K_PHYERR_CNT1\t%x\t(=%d)\n", |
| 752 | ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1), |
| 753 | ATH5K_ANI_OFDM_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX - |
| 754 | ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1))); |
| 755 | len += snprintf(buf+len, sizeof(buf)-len, |
| 756 | "AR5K_PHYERR_CNT2\t%x\t(=%d)\n", |
| 757 | ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2), |
| 758 | ATH5K_ANI_CCK_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX - |
| 759 | ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2))); |
| 760 | |
Dan Carpenter | 2189d13 | 2010-07-22 10:52:02 +0200 | [diff] [blame] | 761 | if (len > sizeof(buf)) |
| 762 | len = sizeof(buf); |
| 763 | |
Bruno Randolf | 2111ac0 | 2010-04-02 18:44:08 +0900 | [diff] [blame] | 764 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 765 | } |
| 766 | |
| 767 | static ssize_t write_file_ani(struct file *file, |
| 768 | const char __user *userbuf, |
| 769 | size_t count, loff_t *ppos) |
| 770 | { |
| 771 | struct ath5k_softc *sc = file->private_data; |
| 772 | char buf[20]; |
| 773 | |
| 774 | if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) |
| 775 | return -EFAULT; |
| 776 | |
| 777 | if (strncmp(buf, "sens-low", 8) == 0) { |
| 778 | ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_MANUAL_HIGH); |
| 779 | } else if (strncmp(buf, "sens-high", 9) == 0) { |
| 780 | ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_MANUAL_LOW); |
| 781 | } else if (strncmp(buf, "ani-off", 7) == 0) { |
| 782 | ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_OFF); |
| 783 | } else if (strncmp(buf, "ani-on", 6) == 0) { |
| 784 | ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_AUTO); |
| 785 | } else if (strncmp(buf, "noise-low", 9) == 0) { |
| 786 | ath5k_ani_set_noise_immunity_level(sc->ah, 0); |
| 787 | } else if (strncmp(buf, "noise-high", 10) == 0) { |
| 788 | ath5k_ani_set_noise_immunity_level(sc->ah, |
| 789 | ATH5K_ANI_MAX_NOISE_IMM_LVL); |
| 790 | } else if (strncmp(buf, "spur-low", 8) == 0) { |
| 791 | ath5k_ani_set_spur_immunity_level(sc->ah, 0); |
| 792 | } else if (strncmp(buf, "spur-high", 9) == 0) { |
| 793 | ath5k_ani_set_spur_immunity_level(sc->ah, |
| 794 | sc->ani_state.max_spur_level); |
| 795 | } else if (strncmp(buf, "fir-low", 7) == 0) { |
| 796 | ath5k_ani_set_firstep_level(sc->ah, 0); |
| 797 | } else if (strncmp(buf, "fir-high", 8) == 0) { |
| 798 | ath5k_ani_set_firstep_level(sc->ah, ATH5K_ANI_MAX_FIRSTEP_LVL); |
| 799 | } else if (strncmp(buf, "ofdm-off", 8) == 0) { |
| 800 | ath5k_ani_set_ofdm_weak_signal_detection(sc->ah, false); |
| 801 | } else if (strncmp(buf, "ofdm-on", 7) == 0) { |
| 802 | ath5k_ani_set_ofdm_weak_signal_detection(sc->ah, true); |
| 803 | } else if (strncmp(buf, "cck-off", 7) == 0) { |
| 804 | ath5k_ani_set_cck_weak_signal_detection(sc->ah, false); |
| 805 | } else if (strncmp(buf, "cck-on", 6) == 0) { |
| 806 | ath5k_ani_set_cck_weak_signal_detection(sc->ah, true); |
| 807 | } |
| 808 | return count; |
| 809 | } |
| 810 | |
| 811 | static const struct file_operations fops_ani = { |
| 812 | .read = read_file_ani, |
| 813 | .write = write_file_ani, |
| 814 | .open = ath5k_debugfs_open, |
| 815 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 816 | .llseek = default_llseek, |
Bruno Randolf | 2111ac0 | 2010-04-02 18:44:08 +0900 | [diff] [blame] | 817 | }; |
| 818 | |
| 819 | |
Bruno Randolf | 3cfd43f | 2010-06-07 13:11:40 +0900 | [diff] [blame] | 820 | /* debugfs: queues etc */ |
| 821 | |
| 822 | static ssize_t read_file_queue(struct file *file, char __user *user_buf, |
| 823 | size_t count, loff_t *ppos) |
| 824 | { |
| 825 | struct ath5k_softc *sc = file->private_data; |
| 826 | char buf[700]; |
| 827 | unsigned int len = 0; |
| 828 | |
| 829 | struct ath5k_txq *txq; |
| 830 | struct ath5k_buf *bf, *bf0; |
Bruno Randolf | cfddc11 | 2010-09-17 11:36:40 +0900 | [diff] [blame] | 831 | int i, n; |
Bruno Randolf | 3cfd43f | 2010-06-07 13:11:40 +0900 | [diff] [blame] | 832 | |
| 833 | len += snprintf(buf+len, sizeof(buf)-len, |
| 834 | "available txbuffers: %d\n", sc->txbuf_len); |
| 835 | |
| 836 | for (i = 0; i < ARRAY_SIZE(sc->txqs); i++) { |
| 837 | txq = &sc->txqs[i]; |
| 838 | |
| 839 | len += snprintf(buf+len, sizeof(buf)-len, |
| 840 | "%02d: %ssetup\n", i, txq->setup ? "" : "not "); |
| 841 | |
| 842 | if (!txq->setup) |
| 843 | continue; |
| 844 | |
Bruno Randolf | cfddc11 | 2010-09-17 11:36:40 +0900 | [diff] [blame] | 845 | n = 0; |
| 846 | spin_lock_bh(&txq->lock); |
Bruno Randolf | 3cfd43f | 2010-06-07 13:11:40 +0900 | [diff] [blame] | 847 | list_for_each_entry_safe(bf, bf0, &txq->q, list) |
| 848 | n++; |
Bruno Randolf | cfddc11 | 2010-09-17 11:36:40 +0900 | [diff] [blame] | 849 | spin_unlock_bh(&txq->lock); |
| 850 | |
| 851 | len += snprintf(buf+len, sizeof(buf)-len, |
| 852 | " len: %d bufs: %d\n", txq->txq_len, n); |
Bruno Randolf | 923e5b3 | 2010-09-17 11:37:02 +0900 | [diff] [blame] | 853 | len += snprintf(buf+len, sizeof(buf)-len, |
| 854 | " stuck: %d\n", txq->txq_stuck); |
Bruno Randolf | 3cfd43f | 2010-06-07 13:11:40 +0900 | [diff] [blame] | 855 | } |
| 856 | |
Dan Carpenter | 2189d13 | 2010-07-22 10:52:02 +0200 | [diff] [blame] | 857 | if (len > sizeof(buf)) |
| 858 | len = sizeof(buf); |
| 859 | |
Bruno Randolf | 3cfd43f | 2010-06-07 13:11:40 +0900 | [diff] [blame] | 860 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 861 | } |
| 862 | |
| 863 | static ssize_t write_file_queue(struct file *file, |
| 864 | const char __user *userbuf, |
| 865 | size_t count, loff_t *ppos) |
| 866 | { |
| 867 | struct ath5k_softc *sc = file->private_data; |
| 868 | char buf[20]; |
| 869 | |
| 870 | if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) |
| 871 | return -EFAULT; |
| 872 | |
| 873 | if (strncmp(buf, "start", 5) == 0) |
| 874 | ieee80211_wake_queues(sc->hw); |
| 875 | else if (strncmp(buf, "stop", 4) == 0) |
| 876 | ieee80211_stop_queues(sc->hw); |
| 877 | |
| 878 | return count; |
| 879 | } |
| 880 | |
| 881 | |
| 882 | static const struct file_operations fops_queue = { |
| 883 | .read = read_file_queue, |
| 884 | .write = write_file_queue, |
| 885 | .open = ath5k_debugfs_open, |
| 886 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 887 | .llseek = default_llseek, |
Bruno Randolf | 3cfd43f | 2010-06-07 13:11:40 +0900 | [diff] [blame] | 888 | }; |
| 889 | |
| 890 | |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 891 | void |
| 892 | ath5k_debug_init_device(struct ath5k_softc *sc) |
| 893 | { |
| 894 | sc->debug.level = ath5k_debug; |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 895 | |
Ben Greear | d84a35d | 2010-10-12 10:55:38 -0700 | [diff] [blame] | 896 | sc->debug.debugfs_phydir = debugfs_create_dir("ath5k", |
| 897 | sc->hw->wiphy->debugfsdir); |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 898 | |
Jiri Slaby | 3167007 | 2009-06-28 23:25:27 +0200 | [diff] [blame] | 899 | sc->debug.debugfs_debug = debugfs_create_file("debug", |
| 900 | S_IWUSR | S_IRUSR, |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 901 | sc->debug.debugfs_phydir, sc, &fops_debug); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 902 | |
Jiri Slaby | 3167007 | 2009-06-28 23:25:27 +0200 | [diff] [blame] | 903 | sc->debug.debugfs_registers = debugfs_create_file("registers", S_IRUSR, |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 904 | sc->debug.debugfs_phydir, sc, &fops_registers); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 905 | |
Jiri Slaby | 3167007 | 2009-06-28 23:25:27 +0200 | [diff] [blame] | 906 | sc->debug.debugfs_beacon = debugfs_create_file("beacon", |
| 907 | S_IWUSR | S_IRUSR, |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 908 | sc->debug.debugfs_phydir, sc, &fops_beacon); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 909 | |
Cheng Renquan | 33ab625 | 2008-11-22 11:22:49 +0800 | [diff] [blame] | 910 | sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR, |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 911 | sc->debug.debugfs_phydir, sc, &fops_reset); |
Bruno Randolf | 604eead | 2010-03-09 16:55:17 +0900 | [diff] [blame] | 912 | |
| 913 | sc->debug.debugfs_antenna = debugfs_create_file("antenna", |
| 914 | S_IWUSR | S_IRUSR, |
| 915 | sc->debug.debugfs_phydir, sc, &fops_antenna); |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 916 | |
Ben Greear | 87fd2e6 | 2010-09-21 17:03:57 -0700 | [diff] [blame] | 917 | sc->debug.debugfs_misc = debugfs_create_file("misc", |
| 918 | S_IRUSR, |
| 919 | sc->debug.debugfs_phydir, sc, &fops_misc); |
| 920 | |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 921 | sc->debug.debugfs_frameerrors = debugfs_create_file("frameerrors", |
| 922 | S_IWUSR | S_IRUSR, |
| 923 | sc->debug.debugfs_phydir, sc, |
| 924 | &fops_frameerrors); |
Bruno Randolf | 2111ac0 | 2010-04-02 18:44:08 +0900 | [diff] [blame] | 925 | |
| 926 | sc->debug.debugfs_ani = debugfs_create_file("ani", |
| 927 | S_IWUSR | S_IRUSR, |
| 928 | sc->debug.debugfs_phydir, sc, |
| 929 | &fops_ani); |
Bruno Randolf | 3cfd43f | 2010-06-07 13:11:40 +0900 | [diff] [blame] | 930 | |
| 931 | sc->debug.debugfs_queue = debugfs_create_file("queue", |
| 932 | S_IWUSR | S_IRUSR, |
| 933 | sc->debug.debugfs_phydir, sc, |
| 934 | &fops_queue); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 935 | } |
| 936 | |
| 937 | void |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 938 | ath5k_debug_finish_device(struct ath5k_softc *sc) |
| 939 | { |
| 940 | debugfs_remove(sc->debug.debugfs_debug); |
| 941 | debugfs_remove(sc->debug.debugfs_registers); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 942 | debugfs_remove(sc->debug.debugfs_beacon); |
| 943 | debugfs_remove(sc->debug.debugfs_reset); |
Bruno Randolf | 604eead | 2010-03-09 16:55:17 +0900 | [diff] [blame] | 944 | debugfs_remove(sc->debug.debugfs_antenna); |
Ben Greear | 87fd2e6 | 2010-09-21 17:03:57 -0700 | [diff] [blame] | 945 | debugfs_remove(sc->debug.debugfs_misc); |
Bruno Randolf | 7644395 | 2010-03-09 16:56:00 +0900 | [diff] [blame] | 946 | debugfs_remove(sc->debug.debugfs_frameerrors); |
Bruno Randolf | 2111ac0 | 2010-04-02 18:44:08 +0900 | [diff] [blame] | 947 | debugfs_remove(sc->debug.debugfs_ani); |
Bruno Randolf | 3cfd43f | 2010-06-07 13:11:40 +0900 | [diff] [blame] | 948 | debugfs_remove(sc->debug.debugfs_queue); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 949 | debugfs_remove(sc->debug.debugfs_phydir); |
| 950 | } |
| 951 | |
| 952 | |
| 953 | /* functions used in other places */ |
| 954 | |
| 955 | void |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 956 | ath5k_debug_dump_bands(struct ath5k_softc *sc) |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 957 | { |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 958 | unsigned int b, i; |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 959 | |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 960 | if (likely(!(sc->debug.level & ATH5K_DEBUG_DUMPBANDS))) |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 961 | return; |
| 962 | |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 963 | BUG_ON(!sc->sbands); |
| 964 | |
| 965 | for (b = 0; b < IEEE80211_NUM_BANDS; b++) { |
| 966 | struct ieee80211_supported_band *band = &sc->sbands[b]; |
Bob Copeland | b7fcb5c | 2009-04-27 22:12:43 -0400 | [diff] [blame] | 967 | char bname[6]; |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 968 | switch (band->band) { |
| 969 | case IEEE80211_BAND_2GHZ: |
| 970 | strcpy(bname, "2 GHz"); |
| 971 | break; |
| 972 | case IEEE80211_BAND_5GHZ: |
| 973 | strcpy(bname, "5 GHz"); |
| 974 | break; |
| 975 | default: |
| 976 | printk(KERN_DEBUG "Band not supported: %d\n", |
| 977 | band->band); |
| 978 | return; |
| 979 | } |
| 980 | printk(KERN_DEBUG "Band %s: channels %d, rates %d\n", bname, |
| 981 | band->n_channels, band->n_bitrates); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 982 | printk(KERN_DEBUG " channels:\n"); |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 983 | for (i = 0; i < band->n_channels; i++) |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 984 | printk(KERN_DEBUG " %3d %d %.4x %.4x\n", |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 985 | ieee80211_frequency_to_channel( |
| 986 | band->channels[i].center_freq), |
| 987 | band->channels[i].center_freq, |
| 988 | band->channels[i].hw_value, |
| 989 | band->channels[i].flags); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 990 | printk(KERN_DEBUG " rates:\n"); |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 991 | for (i = 0; i < band->n_bitrates; i++) |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 992 | printk(KERN_DEBUG " %4d %.4x %.4x %.4x\n", |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 993 | band->bitrates[i].bitrate, |
| 994 | band->bitrates[i].hw_value, |
| 995 | band->bitrates[i].flags, |
| 996 | band->bitrates[i].hw_value_short); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 997 | } |
| 998 | } |
| 999 | |
| 1000 | static inline void |
Bruno Randolf | b47f407 | 2008-03-05 18:35:45 +0900 | [diff] [blame] | 1001 | ath5k_debug_printrxbuf(struct ath5k_buf *bf, int done, |
| 1002 | struct ath5k_rx_status *rs) |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 1003 | { |
| 1004 | struct ath5k_desc *ds = bf->desc; |
Bruno Randolf | 19fd6e5 | 2008-03-05 18:35:23 +0900 | [diff] [blame] | 1005 | struct ath5k_hw_all_rx_desc *rd = &ds->ud.ds_rx; |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 1006 | |
| 1007 | printk(KERN_DEBUG "R (%p %llx) %08x %08x %08x %08x %08x %08x %c\n", |
| 1008 | ds, (unsigned long long)bf->daddr, |
Bruno Randolf | 19fd6e5 | 2008-03-05 18:35:23 +0900 | [diff] [blame] | 1009 | ds->ds_link, ds->ds_data, |
| 1010 | rd->rx_ctl.rx_control_0, rd->rx_ctl.rx_control_1, |
Bruno Randolf | 62412a8 | 2010-06-16 19:12:12 +0900 | [diff] [blame] | 1011 | rd->rx_stat.rx_status_0, rd->rx_stat.rx_status_1, |
Bruno Randolf | b47f407 | 2008-03-05 18:35:45 +0900 | [diff] [blame] | 1012 | !done ? ' ' : (rs->rs_status == 0) ? '*' : '!'); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 1013 | } |
| 1014 | |
| 1015 | void |
| 1016 | ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah) |
| 1017 | { |
| 1018 | struct ath5k_desc *ds; |
| 1019 | struct ath5k_buf *bf; |
Bruno Randolf | b47f407 | 2008-03-05 18:35:45 +0900 | [diff] [blame] | 1020 | struct ath5k_rx_status rs = {}; |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 1021 | int status; |
| 1022 | |
Bob Copeland | b4c5261 | 2010-08-21 16:39:03 -0400 | [diff] [blame] | 1023 | if (likely(!(sc->debug.level & ATH5K_DEBUG_DESC))) |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 1024 | return; |
| 1025 | |
Bruno Randolf | 265faad | 2010-06-16 19:11:30 +0900 | [diff] [blame] | 1026 | printk(KERN_DEBUG "rxdp %x, rxlink %p\n", |
Nick Kossifidis | c6e387a | 2008-08-29 22:45:39 +0300 | [diff] [blame] | 1027 | ath5k_hw_get_rxdp(ah), sc->rxlink); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 1028 | |
| 1029 | spin_lock_bh(&sc->rxbuflock); |
| 1030 | list_for_each_entry(bf, &sc->rxbuf, list) { |
| 1031 | ds = bf->desc; |
Bruno Randolf | b47f407 | 2008-03-05 18:35:45 +0900 | [diff] [blame] | 1032 | status = ah->ah_proc_rx_desc(ah, ds, &rs); |
Bruno Randolf | be9b725 | 2008-01-23 10:27:51 +0900 | [diff] [blame] | 1033 | if (!status) |
Bruno Randolf | b47f407 | 2008-03-05 18:35:45 +0900 | [diff] [blame] | 1034 | ath5k_debug_printrxbuf(bf, status == 0, &rs); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 1035 | } |
| 1036 | spin_unlock_bh(&sc->rxbuflock); |
| 1037 | } |
| 1038 | |
| 1039 | void |
| 1040 | ath5k_debug_dump_skb(struct ath5k_softc *sc, |
| 1041 | struct sk_buff *skb, const char *prefix, int tx) |
| 1042 | { |
| 1043 | char buf[16]; |
| 1044 | |
| 1045 | if (likely(!((tx && (sc->debug.level & ATH5K_DEBUG_DUMP_TX)) || |
| 1046 | (!tx && (sc->debug.level & ATH5K_DEBUG_DUMP_RX))))) |
| 1047 | return; |
| 1048 | |
| 1049 | snprintf(buf, sizeof(buf), "%s %s", wiphy_name(sc->hw->wiphy), prefix); |
| 1050 | |
| 1051 | print_hex_dump_bytes(buf, DUMP_PREFIX_NONE, skb->data, |
| 1052 | min(200U, skb->len)); |
| 1053 | |
| 1054 | printk(KERN_DEBUG "\n"); |
| 1055 | } |
| 1056 | |
| 1057 | void |
Bruno Randolf | b47f407 | 2008-03-05 18:35:45 +0900 | [diff] [blame] | 1058 | ath5k_debug_printtxbuf(struct ath5k_softc *sc, struct ath5k_buf *bf) |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 1059 | { |
| 1060 | struct ath5k_desc *ds = bf->desc; |
Bruno Randolf | 19fd6e5 | 2008-03-05 18:35:23 +0900 | [diff] [blame] | 1061 | struct ath5k_hw_5212_tx_desc *td = &ds->ud.ds_tx5212; |
Bruno Randolf | b47f407 | 2008-03-05 18:35:45 +0900 | [diff] [blame] | 1062 | struct ath5k_tx_status ts = {}; |
| 1063 | int done; |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 1064 | |
Bob Copeland | b4c5261 | 2010-08-21 16:39:03 -0400 | [diff] [blame] | 1065 | if (likely(!(sc->debug.level & ATH5K_DEBUG_DESC))) |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 1066 | return; |
| 1067 | |
Bruno Randolf | b47f407 | 2008-03-05 18:35:45 +0900 | [diff] [blame] | 1068 | done = sc->ah->ah_proc_tx_desc(sc->ah, bf->desc, &ts); |
| 1069 | |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 1070 | printk(KERN_DEBUG "T (%p %llx) %08x %08x %08x %08x %08x %08x %08x " |
| 1071 | "%08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link, |
Bruno Randolf | 19fd6e5 | 2008-03-05 18:35:23 +0900 | [diff] [blame] | 1072 | ds->ds_data, td->tx_ctl.tx_control_0, td->tx_ctl.tx_control_1, |
| 1073 | td->tx_ctl.tx_control_2, td->tx_ctl.tx_control_3, |
| 1074 | td->tx_stat.tx_status_0, td->tx_stat.tx_status_1, |
Bruno Randolf | b47f407 | 2008-03-05 18:35:45 +0900 | [diff] [blame] | 1075 | done ? ' ' : (ts.ts_status == 0) ? '*' : '!'); |
Jiri Slaby | fa1c114 | 2007-08-12 17:33:16 +0200 | [diff] [blame] | 1076 | } |
| 1077 | |
Luis R. Rodriguez | b446197 | 2008-02-04 10:03:54 -0500 | [diff] [blame] | 1078 | #endif /* ifdef CONFIG_ATH5K_DEBUG */ |