blob: 8c5ce8b0c7346873a64c6ee9e8f358a2d5a565c6 [file] [log] [blame]
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001/*
Bruno Randolfbe9b7252008-01-23 10:27:51 +09002 * Copyright (c) 2007-2008 Bruno Randolf <bruno@thinktube.com>
Jiri Slabyfa1c1142007-08-12 17:33:16 +02003 *
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 */
Paul Gortmakeree40fa02011-05-27 16:14:23 -040060#include <linux/export.h>
Paul Gortmaker6eb07ca2011-09-15 19:46:05 -040061#include <linux/moduleparam.h>
Jiri Slabyfa1c1142007-08-12 17:33:16 +020062
Pavel Roskin931be262011-07-26 22:26:59 -040063#include <linux/seq_file.h>
64#include <linux/list.h>
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030065#include "debug.h"
Pavel Roskin931be262011-07-26 22:26:59 -040066#include "ath5k.h"
67#include "reg.h"
68#include "base.h"
Jiri Slabyfa1c1142007-08-12 17:33:16 +020069
70static unsigned int ath5k_debug;
71module_param_named(debug, ath5k_debug, uint, 0);
72
73
Jiri Slabyfa1c1142007-08-12 17:33:16 +020074static int ath5k_debugfs_open(struct inode *inode, struct file *file)
75{
76 file->private_data = inode->i_private;
77 return 0;
78}
79
80
81/* debugfs: registers */
82
83struct reg {
Jiri Slaby2c91108c2009-03-07 10:26:41 +010084 const char *name;
Jiri Slabyfa1c1142007-08-12 17:33:16 +020085 int addr;
86};
87
88#define REG_STRUCT_INIT(r) { #r, r }
89
90/* just a few random registers, might want to add more */
Jiri Slaby2c91108c2009-03-07 10:26:41 +010091static const struct reg regs[] = {
Jiri Slabyfa1c1142007-08-12 17:33:16 +020092 REG_STRUCT_INIT(AR5K_CR),
93 REG_STRUCT_INIT(AR5K_RXDP),
94 REG_STRUCT_INIT(AR5K_CFG),
95 REG_STRUCT_INIT(AR5K_IER),
96 REG_STRUCT_INIT(AR5K_BCR),
97 REG_STRUCT_INIT(AR5K_RTSD0),
98 REG_STRUCT_INIT(AR5K_RTSD1),
99 REG_STRUCT_INIT(AR5K_TXCFG),
100 REG_STRUCT_INIT(AR5K_RXCFG),
101 REG_STRUCT_INIT(AR5K_RXJLA),
102 REG_STRUCT_INIT(AR5K_MIBC),
103 REG_STRUCT_INIT(AR5K_TOPS),
104 REG_STRUCT_INIT(AR5K_RXNOFRM),
105 REG_STRUCT_INIT(AR5K_TXNOFRM),
106 REG_STRUCT_INIT(AR5K_RPGTO),
107 REG_STRUCT_INIT(AR5K_RFCNT),
108 REG_STRUCT_INIT(AR5K_MISC),
109 REG_STRUCT_INIT(AR5K_QCUDCU_CLKGT),
110 REG_STRUCT_INIT(AR5K_ISR),
111 REG_STRUCT_INIT(AR5K_PISR),
112 REG_STRUCT_INIT(AR5K_SISR0),
113 REG_STRUCT_INIT(AR5K_SISR1),
114 REG_STRUCT_INIT(AR5K_SISR2),
115 REG_STRUCT_INIT(AR5K_SISR3),
116 REG_STRUCT_INIT(AR5K_SISR4),
117 REG_STRUCT_INIT(AR5K_IMR),
118 REG_STRUCT_INIT(AR5K_PIMR),
119 REG_STRUCT_INIT(AR5K_SIMR0),
120 REG_STRUCT_INIT(AR5K_SIMR1),
121 REG_STRUCT_INIT(AR5K_SIMR2),
122 REG_STRUCT_INIT(AR5K_SIMR3),
123 REG_STRUCT_INIT(AR5K_SIMR4),
124 REG_STRUCT_INIT(AR5K_DCM_ADDR),
125 REG_STRUCT_INIT(AR5K_DCCFG),
126 REG_STRUCT_INIT(AR5K_CCFG),
127 REG_STRUCT_INIT(AR5K_CPC0),
128 REG_STRUCT_INIT(AR5K_CPC1),
129 REG_STRUCT_INIT(AR5K_CPC2),
130 REG_STRUCT_INIT(AR5K_CPC3),
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300131 REG_STRUCT_INIT(AR5K_CPCOVF),
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200132 REG_STRUCT_INIT(AR5K_RESET_CTL),
133 REG_STRUCT_INIT(AR5K_SLEEP_CTL),
134 REG_STRUCT_INIT(AR5K_INTPEND),
135 REG_STRUCT_INIT(AR5K_SFR),
136 REG_STRUCT_INIT(AR5K_PCICFG),
137 REG_STRUCT_INIT(AR5K_GPIOCR),
138 REG_STRUCT_INIT(AR5K_GPIODO),
139 REG_STRUCT_INIT(AR5K_SREV),
140};
141
142static void *reg_start(struct seq_file *seq, loff_t *pos)
143{
Jiri Slaby2c91108c2009-03-07 10:26:41 +0100144 return *pos < ARRAY_SIZE(regs) ? (void *)&regs[*pos] : NULL;
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200145}
146
147static void reg_stop(struct seq_file *seq, void *p)
148{
149 /* nothing to do */
150}
151
152static void *reg_next(struct seq_file *seq, void *p, loff_t *pos)
153{
154 ++*pos;
Jiri Slaby2c91108c2009-03-07 10:26:41 +0100155 return *pos < ARRAY_SIZE(regs) ? (void *)&regs[*pos] : NULL;
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200156}
157
158static int reg_show(struct seq_file *seq, void *p)
159{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400160 struct ath5k_hw *ah = seq->private;
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200161 struct reg *r = p;
162 seq_printf(seq, "%-25s0x%08x\n", r->name,
Pavel Roskine0d687b2011-07-14 20:21:55 -0400163 ath5k_hw_reg_read(ah, r->addr));
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200164 return 0;
165}
166
Jan Engelhardt4101dec2009-01-14 13:52:18 -0800167static const struct seq_operations register_seq_ops = {
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200168 .start = reg_start,
169 .next = reg_next,
170 .stop = reg_stop,
171 .show = reg_show
172};
173
174static int open_file_registers(struct inode *inode, struct file *file)
175{
176 struct seq_file *s;
177 int res;
178 res = seq_open(file, &register_seq_ops);
179 if (res == 0) {
180 s = file->private_data;
181 s->private = inode->i_private;
182 }
183 return res;
184}
185
186static const struct file_operations fops_registers = {
187 .open = open_file_registers,
188 .read = seq_read,
189 .llseek = seq_lseek,
190 .release = seq_release,
191 .owner = THIS_MODULE,
192};
193
194
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200195/* debugfs: beacons */
196
197static ssize_t read_file_beacon(struct file *file, char __user *user_buf,
198 size_t count, loff_t *ppos)
199{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400200 struct ath5k_hw *ah = file->private_data;
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900201 char buf[500];
202 unsigned int len = 0;
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200203 unsigned int v;
204 u64 tsf;
205
Pavel Roskine0d687b2011-07-14 20:21:55 -0400206 v = ath5k_hw_reg_read(ah, AR5K_BEACON);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400207 len += snprintf(buf + len, sizeof(buf) - len,
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200208 "%-24s0x%08x\tintval: %d\tTIM: 0x%x\n",
209 "AR5K_BEACON", v, v & AR5K_BEACON_PERIOD,
210 (v & AR5K_BEACON_TIM) >> AR5K_BEACON_TIM_S);
211
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400212 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\n",
Pavel Roskine0d687b2011-07-14 20:21:55 -0400213 "AR5K_LAST_TSTP", ath5k_hw_reg_read(ah, AR5K_LAST_TSTP));
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200214
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400215 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\n\n",
Pavel Roskine0d687b2011-07-14 20:21:55 -0400216 "AR5K_BEACON_CNT", ath5k_hw_reg_read(ah, AR5K_BEACON_CNT));
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200217
Pavel Roskine0d687b2011-07-14 20:21:55 -0400218 v = ath5k_hw_reg_read(ah, AR5K_TIMER0);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400219 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200220 "AR5K_TIMER0 (TBTT)", v, v);
221
Pavel Roskine0d687b2011-07-14 20:21:55 -0400222 v = ath5k_hw_reg_read(ah, AR5K_TIMER1);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400223 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200224 "AR5K_TIMER1 (DMA)", v, v >> 3);
225
Pavel Roskine0d687b2011-07-14 20:21:55 -0400226 v = ath5k_hw_reg_read(ah, AR5K_TIMER2);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400227 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200228 "AR5K_TIMER2 (SWBA)", v, v >> 3);
229
Pavel Roskine0d687b2011-07-14 20:21:55 -0400230 v = ath5k_hw_reg_read(ah, AR5K_TIMER3);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400231 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200232 "AR5K_TIMER3 (ATIM)", v, v);
233
Pavel Roskine0d687b2011-07-14 20:21:55 -0400234 tsf = ath5k_hw_get_tsf64(ah);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400235 len += snprintf(buf + len, sizeof(buf) - len,
John W. Linvillef868f4e2008-03-07 16:38:43 -0500236 "TSF\t\t0x%016llx\tTU: %08x\n",
237 (unsigned long long)tsf, TSF_TO_TU(tsf));
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200238
Dan Carpenter2189d132010-07-22 10:52:02 +0200239 if (len > sizeof(buf))
240 len = sizeof(buf);
241
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200242 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
243}
244
245static ssize_t write_file_beacon(struct file *file,
246 const char __user *userbuf,
247 size_t count, loff_t *ppos)
248{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400249 struct ath5k_hw *ah = file->private_data;
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900250 char buf[20];
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200251
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900252 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
253 return -EFAULT;
254
255 if (strncmp(buf, "disable", 7) == 0) {
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200256 AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
257 printk(KERN_INFO "debugfs disable beacons\n");
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900258 } else if (strncmp(buf, "enable", 6) == 0) {
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200259 AR5K_REG_ENABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
260 printk(KERN_INFO "debugfs enable beacons\n");
261 }
262 return count;
263}
264
265static const struct file_operations fops_beacon = {
266 .read = read_file_beacon,
267 .write = write_file_beacon,
268 .open = ath5k_debugfs_open,
269 .owner = THIS_MODULE,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200270 .llseek = default_llseek,
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200271};
272
273
274/* debugfs: reset */
275
276static ssize_t write_file_reset(struct file *file,
277 const char __user *userbuf,
278 size_t count, loff_t *ppos)
279{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400280 struct ath5k_hw *ah = file->private_data;
281 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "debug file triggered reset\n");
282 ieee80211_queue_work(ah->hw, &ah->reset_work);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200283 return count;
284}
285
286static const struct file_operations fops_reset = {
287 .write = write_file_reset,
288 .open = ath5k_debugfs_open,
289 .owner = THIS_MODULE,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200290 .llseek = noop_llseek,
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200291};
292
293
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900294/* debugfs: debug level */
295
Jiri Slaby2c91108c2009-03-07 10:26:41 +0100296static const struct {
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900297 enum ath5k_debug_level level;
298 const char *name;
299 const char *desc;
300} dbg_info[] = {
301 { ATH5K_DEBUG_RESET, "reset", "reset and initialization" },
302 { ATH5K_DEBUG_INTR, "intr", "interrupt handling" },
303 { ATH5K_DEBUG_MODE, "mode", "mode init/setup" },
304 { ATH5K_DEBUG_XMIT, "xmit", "basic xmit operation" },
305 { ATH5K_DEBUG_BEACON, "beacon", "beacon handling" },
306 { ATH5K_DEBUG_CALIBRATE, "calib", "periodic calibration" },
307 { ATH5K_DEBUG_TXPOWER, "txpower", "transmit power setting" },
Bob Copeland85519a62008-10-29 08:30:53 -0400308 { ATH5K_DEBUG_LED, "led", "LED management" },
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500309 { ATH5K_DEBUG_DUMPBANDS, "dumpbands", "dump bands" },
Nick Kossifidisb3a28e62010-11-23 20:47:31 +0200310 { ATH5K_DEBUG_DMA, "dma", "dma start/stop" },
Bruno Randolf2111ac02010-04-02 18:44:08 +0900311 { ATH5K_DEBUG_ANI, "ani", "adaptive noise immunity" },
Bob Copelandb4c52612010-08-21 16:39:03 -0400312 { ATH5K_DEBUG_DESC, "desc", "descriptor chains" },
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900313 { ATH5K_DEBUG_ANY, "all", "show all debug levels" },
314};
315
316static ssize_t read_file_debug(struct file *file, char __user *user_buf,
317 size_t count, loff_t *ppos)
318{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400319 struct ath5k_hw *ah = file->private_data;
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900320 char buf[700];
321 unsigned int len = 0;
322 unsigned int i;
323
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400324 len += snprintf(buf + len, sizeof(buf) - len,
Pavel Roskine0d687b2011-07-14 20:21:55 -0400325 "DEBUG LEVEL: 0x%08x\n\n", ah->debug.level);
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900326
327 for (i = 0; i < ARRAY_SIZE(dbg_info) - 1; i++) {
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400328 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900329 "%10s %c 0x%08x - %s\n", dbg_info[i].name,
Pavel Roskine0d687b2011-07-14 20:21:55 -0400330 ah->debug.level & dbg_info[i].level ? '+' : ' ',
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900331 dbg_info[i].level, dbg_info[i].desc);
332 }
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400333 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900334 "%10s %c 0x%08x - %s\n", dbg_info[i].name,
Pavel Roskine0d687b2011-07-14 20:21:55 -0400335 ah->debug.level == dbg_info[i].level ? '+' : ' ',
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900336 dbg_info[i].level, dbg_info[i].desc);
337
Dan Carpenter2189d132010-07-22 10:52:02 +0200338 if (len > sizeof(buf))
339 len = sizeof(buf);
340
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900341 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
342}
343
344static ssize_t write_file_debug(struct file *file,
345 const char __user *userbuf,
346 size_t count, loff_t *ppos)
347{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400348 struct ath5k_hw *ah = file->private_data;
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900349 unsigned int i;
350 char buf[20];
351
352 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
353 return -EFAULT;
354
355 for (i = 0; i < ARRAY_SIZE(dbg_info); i++) {
356 if (strncmp(buf, dbg_info[i].name,
357 strlen(dbg_info[i].name)) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400358 ah->debug.level ^= dbg_info[i].level; /* toggle bit */
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900359 break;
360 }
361 }
362 return count;
363}
364
365static const struct file_operations fops_debug = {
366 .read = read_file_debug,
367 .write = write_file_debug,
368 .open = ath5k_debugfs_open,
369 .owner = THIS_MODULE,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200370 .llseek = default_llseek,
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900371};
372
373
Bruno Randolf604eead2010-03-09 16:55:17 +0900374/* debugfs: antenna */
375
376static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
377 size_t count, loff_t *ppos)
378{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400379 struct ath5k_hw *ah = file->private_data;
Bruno Randolf604eead2010-03-09 16:55:17 +0900380 char buf[700];
381 unsigned int len = 0;
382 unsigned int i;
383 unsigned int v;
384
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400385 len += snprintf(buf + len, sizeof(buf) - len, "antenna mode\t%d\n",
Pavel Roskine0d687b2011-07-14 20:21:55 -0400386 ah->ah_ant_mode);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400387 len += snprintf(buf + len, sizeof(buf) - len, "default antenna\t%d\n",
Pavel Roskine0d687b2011-07-14 20:21:55 -0400388 ah->ah_def_ant);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400389 len += snprintf(buf + len, sizeof(buf) - len, "tx antenna\t%d\n",
Pavel Roskine0d687b2011-07-14 20:21:55 -0400390 ah->ah_tx_ant);
Bruno Randolf604eead2010-03-09 16:55:17 +0900391
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400392 len += snprintf(buf + len, sizeof(buf) - len, "\nANTENNA\t\tRX\tTX\n");
Pavel Roskine0d687b2011-07-14 20:21:55 -0400393 for (i = 1; i < ARRAY_SIZE(ah->stats.antenna_rx); i++) {
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400394 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf604eead2010-03-09 16:55:17 +0900395 "[antenna %d]\t%d\t%d\n",
Pavel Roskine0d687b2011-07-14 20:21:55 -0400396 i, ah->stats.antenna_rx[i], ah->stats.antenna_tx[i]);
Bruno Randolf604eead2010-03-09 16:55:17 +0900397 }
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400398 len += snprintf(buf + len, sizeof(buf) - len, "[invalid]\t%d\t%d\n",
Pavel Roskine0d687b2011-07-14 20:21:55 -0400399 ah->stats.antenna_rx[0], ah->stats.antenna_tx[0]);
Bruno Randolf604eead2010-03-09 16:55:17 +0900400
Pavel Roskine0d687b2011-07-14 20:21:55 -0400401 v = ath5k_hw_reg_read(ah, AR5K_DEFAULT_ANTENNA);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400402 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf604eead2010-03-09 16:55:17 +0900403 "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v);
404
Pavel Roskine0d687b2011-07-14 20:21:55 -0400405 v = ath5k_hw_reg_read(ah, AR5K_STA_ID1);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400406 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf604eead2010-03-09 16:55:17 +0900407 "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n",
408 (v & AR5K_STA_ID1_DEFAULT_ANTENNA) != 0);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400409 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf604eead2010-03-09 16:55:17 +0900410 "AR5K_STA_ID1_DESC_ANTENNA\t%d\n",
411 (v & AR5K_STA_ID1_DESC_ANTENNA) != 0);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400412 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf604eead2010-03-09 16:55:17 +0900413 "AR5K_STA_ID1_RTS_DEF_ANTENNA\t%d\n",
414 (v & AR5K_STA_ID1_RTS_DEF_ANTENNA) != 0);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400415 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf604eead2010-03-09 16:55:17 +0900416 "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n",
417 (v & AR5K_STA_ID1_SELFGEN_DEF_ANT) != 0);
418
Pavel Roskine0d687b2011-07-14 20:21:55 -0400419 v = ath5k_hw_reg_read(ah, AR5K_PHY_AGCCTL);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400420 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf604eead2010-03-09 16:55:17 +0900421 "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n",
422 (v & AR5K_PHY_AGCCTL_OFDM_DIV_DIS) != 0);
423
Pavel Roskine0d687b2011-07-14 20:21:55 -0400424 v = ath5k_hw_reg_read(ah, AR5K_PHY_RESTART);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400425 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf604eead2010-03-09 16:55:17 +0900426 "AR5K_PHY_RESTART_DIV_GC\t\t%x\n",
427 (v & AR5K_PHY_RESTART_DIV_GC) >> AR5K_PHY_RESTART_DIV_GC_S);
428
Pavel Roskine0d687b2011-07-14 20:21:55 -0400429 v = ath5k_hw_reg_read(ah, AR5K_PHY_FAST_ANT_DIV);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400430 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf604eead2010-03-09 16:55:17 +0900431 "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n",
432 (v & AR5K_PHY_FAST_ANT_DIV_EN) != 0);
433
Pavel Roskine0d687b2011-07-14 20:21:55 -0400434 v = ath5k_hw_reg_read(ah, AR5K_PHY_ANT_SWITCH_TABLE_0);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400435 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf0ca74022010-06-07 13:11:30 +0900436 "\nAR5K_PHY_ANT_SWITCH_TABLE_0\t0x%08x\n", v);
Pavel Roskine0d687b2011-07-14 20:21:55 -0400437 v = ath5k_hw_reg_read(ah, AR5K_PHY_ANT_SWITCH_TABLE_1);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400438 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf0ca74022010-06-07 13:11:30 +0900439 "AR5K_PHY_ANT_SWITCH_TABLE_1\t0x%08x\n", v);
440
Dan Carpenter2189d132010-07-22 10:52:02 +0200441 if (len > sizeof(buf))
442 len = sizeof(buf);
443
Bruno Randolf604eead2010-03-09 16:55:17 +0900444 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
445}
446
447static ssize_t write_file_antenna(struct file *file,
448 const char __user *userbuf,
449 size_t count, loff_t *ppos)
450{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400451 struct ath5k_hw *ah = file->private_data;
Bruno Randolf604eead2010-03-09 16:55:17 +0900452 unsigned int i;
453 char buf[20];
454
455 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
456 return -EFAULT;
457
458 if (strncmp(buf, "diversity", 9) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400459 ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_DEFAULT);
Bruno Randolf604eead2010-03-09 16:55:17 +0900460 printk(KERN_INFO "ath5k debug: enable diversity\n");
461 } else if (strncmp(buf, "fixed-a", 7) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400462 ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_FIXED_A);
Bruno Randolf604eead2010-03-09 16:55:17 +0900463 printk(KERN_INFO "ath5k debugfs: fixed antenna A\n");
464 } else if (strncmp(buf, "fixed-b", 7) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400465 ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_FIXED_B);
Bruno Randolf604eead2010-03-09 16:55:17 +0900466 printk(KERN_INFO "ath5k debug: fixed antenna B\n");
467 } else if (strncmp(buf, "clear", 5) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400468 for (i = 0; i < ARRAY_SIZE(ah->stats.antenna_rx); i++) {
469 ah->stats.antenna_rx[i] = 0;
470 ah->stats.antenna_tx[i] = 0;
Bruno Randolf604eead2010-03-09 16:55:17 +0900471 }
472 printk(KERN_INFO "ath5k debug: cleared antenna stats\n");
473 }
474 return count;
475}
476
477static const struct file_operations fops_antenna = {
478 .read = read_file_antenna,
479 .write = write_file_antenna,
480 .open = ath5k_debugfs_open,
481 .owner = THIS_MODULE,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200482 .llseek = default_llseek,
Bruno Randolf604eead2010-03-09 16:55:17 +0900483};
484
Ben Greear87fd2e62010-09-21 17:03:57 -0700485/* debugfs: misc */
486
487static ssize_t read_file_misc(struct file *file, char __user *user_buf,
488 size_t count, loff_t *ppos)
489{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400490 struct ath5k_hw *ah = file->private_data;
Ben Greear87fd2e62010-09-21 17:03:57 -0700491 char buf[700];
492 unsigned int len = 0;
Pavel Roskine0d687b2011-07-14 20:21:55 -0400493 u32 filt = ath5k_hw_get_rx_filter(ah);
Ben Greear87fd2e62010-09-21 17:03:57 -0700494
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400495 len += snprintf(buf + len, sizeof(buf) - len, "bssid-mask: %pM\n",
Pavel Roskine0d687b2011-07-14 20:21:55 -0400496 ah->bssidmask);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400497 len += snprintf(buf + len, sizeof(buf) - len, "filter-flags: 0x%x ",
Ben Greear87fd2e62010-09-21 17:03:57 -0700498 filt);
499 if (filt & AR5K_RX_FILTER_UCAST)
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400500 len += snprintf(buf + len, sizeof(buf) - len, " UCAST");
Ben Greear87fd2e62010-09-21 17:03:57 -0700501 if (filt & AR5K_RX_FILTER_MCAST)
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400502 len += snprintf(buf + len, sizeof(buf) - len, " MCAST");
Ben Greear87fd2e62010-09-21 17:03:57 -0700503 if (filt & AR5K_RX_FILTER_BCAST)
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400504 len += snprintf(buf + len, sizeof(buf) - len, " BCAST");
Ben Greear87fd2e62010-09-21 17:03:57 -0700505 if (filt & AR5K_RX_FILTER_CONTROL)
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400506 len += snprintf(buf + len, sizeof(buf) - len, " CONTROL");
Ben Greear87fd2e62010-09-21 17:03:57 -0700507 if (filt & AR5K_RX_FILTER_BEACON)
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400508 len += snprintf(buf + len, sizeof(buf) - len, " BEACON");
Ben Greear87fd2e62010-09-21 17:03:57 -0700509 if (filt & AR5K_RX_FILTER_PROM)
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400510 len += snprintf(buf + len, sizeof(buf) - len, " PROM");
Ben Greear87fd2e62010-09-21 17:03:57 -0700511 if (filt & AR5K_RX_FILTER_XRPOLL)
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400512 len += snprintf(buf + len, sizeof(buf) - len, " XRPOLL");
Ben Greear87fd2e62010-09-21 17:03:57 -0700513 if (filt & AR5K_RX_FILTER_PROBEREQ)
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400514 len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ");
Ben Greear87fd2e62010-09-21 17:03:57 -0700515 if (filt & AR5K_RX_FILTER_PHYERR_5212)
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400516 len += snprintf(buf + len, sizeof(buf) - len, " PHYERR-5212");
Ben Greear87fd2e62010-09-21 17:03:57 -0700517 if (filt & AR5K_RX_FILTER_RADARERR_5212)
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400518 len += snprintf(buf + len, sizeof(buf) - len, " RADARERR-5212");
Ben Greear87fd2e62010-09-21 17:03:57 -0700519 if (filt & AR5K_RX_FILTER_PHYERR_5211)
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400520 snprintf(buf + len, sizeof(buf) - len, " PHYERR-5211");
Ben Greear87fd2e62010-09-21 17:03:57 -0700521 if (filt & AR5K_RX_FILTER_RADARERR_5211)
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400522 len += snprintf(buf + len, sizeof(buf) - len, " RADARERR-5211");
Ben Greear87fd2e62010-09-21 17:03:57 -0700523
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400524 len += snprintf(buf + len, sizeof(buf) - len, "\nopmode: %s (%d)\n",
Pavel Roskine0d687b2011-07-14 20:21:55 -0400525 ath_opmode_to_string(ah->opmode), ah->opmode);
Ben Greear92c68a62010-10-08 09:43:29 -0700526
Ben Greear87fd2e62010-09-21 17:03:57 -0700527 if (len > sizeof(buf))
528 len = sizeof(buf);
529
530 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
531}
532
533static const struct file_operations fops_misc = {
534 .read = read_file_misc,
535 .open = ath5k_debugfs_open,
536 .owner = THIS_MODULE,
537};
538
Bruno Randolf604eead2010-03-09 16:55:17 +0900539
Bruno Randolf76443952010-03-09 16:56:00 +0900540/* debugfs: frameerrors */
541
542static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf,
543 size_t count, loff_t *ppos)
544{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400545 struct ath5k_hw *ah = file->private_data;
546 struct ath5k_statistics *st = &ah->stats;
Bruno Randolf76443952010-03-09 16:56:00 +0900547 char buf[700];
548 unsigned int len = 0;
Bruno Randolfda351112010-03-25 14:49:42 +0900549 int i;
Bruno Randolf76443952010-03-09 16:56:00 +0900550
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400551 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf76443952010-03-09 16:56:00 +0900552 "RX\n---------------------\n");
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400553 len += snprintf(buf + len, sizeof(buf) - len, "CRC\t%u\t(%u%%)\n",
Bruno Randolf76443952010-03-09 16:56:00 +0900554 st->rxerr_crc,
555 st->rx_all_count > 0 ?
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400556 st->rxerr_crc * 100 / st->rx_all_count : 0);
557 len += snprintf(buf + len, sizeof(buf) - len, "PHY\t%u\t(%u%%)\n",
Bruno Randolf76443952010-03-09 16:56:00 +0900558 st->rxerr_phy,
559 st->rx_all_count > 0 ?
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400560 st->rxerr_phy * 100 / st->rx_all_count : 0);
Bruno Randolfda351112010-03-25 14:49:42 +0900561 for (i = 0; i < 32; i++) {
562 if (st->rxerr_phy_code[i])
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400563 len += snprintf(buf + len, sizeof(buf) - len,
Ben Greear5d882c92010-11-08 10:50:03 -0800564 " phy_err[%u]\t%u\n",
Bruno Randolfda351112010-03-25 14:49:42 +0900565 i, st->rxerr_phy_code[i]);
566 }
567
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400568 len += snprintf(buf + len, sizeof(buf) - len, "FIFO\t%u\t(%u%%)\n",
Bruno Randolf76443952010-03-09 16:56:00 +0900569 st->rxerr_fifo,
570 st->rx_all_count > 0 ?
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400571 st->rxerr_fifo * 100 / st->rx_all_count : 0);
572 len += snprintf(buf + len, sizeof(buf) - len, "decrypt\t%u\t(%u%%)\n",
Bruno Randolf76443952010-03-09 16:56:00 +0900573 st->rxerr_decrypt,
574 st->rx_all_count > 0 ?
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400575 st->rxerr_decrypt * 100 / st->rx_all_count : 0);
576 len += snprintf(buf + len, sizeof(buf) - len, "MIC\t%u\t(%u%%)\n",
Bruno Randolf76443952010-03-09 16:56:00 +0900577 st->rxerr_mic,
578 st->rx_all_count > 0 ?
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400579 st->rxerr_mic * 100 / st->rx_all_count : 0);
580 len += snprintf(buf + len, sizeof(buf) - len, "process\t%u\t(%u%%)\n",
Bruno Randolf76443952010-03-09 16:56:00 +0900581 st->rxerr_proc,
582 st->rx_all_count > 0 ?
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400583 st->rxerr_proc * 100 / st->rx_all_count : 0);
584 len += snprintf(buf + len, sizeof(buf) - len, "jumbo\t%u\t(%u%%)\n",
Bruno Randolf76443952010-03-09 16:56:00 +0900585 st->rxerr_jumbo,
586 st->rx_all_count > 0 ?
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400587 st->rxerr_jumbo * 100 / st->rx_all_count : 0);
588 len += snprintf(buf + len, sizeof(buf) - len, "[RX all\t%u]\n",
Bruno Randolf76443952010-03-09 16:56:00 +0900589 st->rx_all_count);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400590 len += snprintf(buf + len, sizeof(buf) - len, "RX-all-bytes\t%u\n",
Ben Greearb72acdd2010-10-01 10:54:04 -0700591 st->rx_bytes_count);
Bruno Randolf76443952010-03-09 16:56:00 +0900592
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400593 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf76443952010-03-09 16:56:00 +0900594 "\nTX\n---------------------\n");
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400595 len += snprintf(buf + len, sizeof(buf) - len, "retry\t%u\t(%u%%)\n",
Bruno Randolf76443952010-03-09 16:56:00 +0900596 st->txerr_retry,
597 st->tx_all_count > 0 ?
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400598 st->txerr_retry * 100 / st->tx_all_count : 0);
599 len += snprintf(buf + len, sizeof(buf) - len, "FIFO\t%u\t(%u%%)\n",
Bruno Randolf76443952010-03-09 16:56:00 +0900600 st->txerr_fifo,
601 st->tx_all_count > 0 ?
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400602 st->txerr_fifo * 100 / st->tx_all_count : 0);
603 len += snprintf(buf + len, sizeof(buf) - len, "filter\t%u\t(%u%%)\n",
Bruno Randolf76443952010-03-09 16:56:00 +0900604 st->txerr_filt,
605 st->tx_all_count > 0 ?
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400606 st->txerr_filt * 100 / st->tx_all_count : 0);
607 len += snprintf(buf + len, sizeof(buf) - len, "[TX all\t%u]\n",
Bruno Randolf76443952010-03-09 16:56:00 +0900608 st->tx_all_count);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400609 len += snprintf(buf + len, sizeof(buf) - len, "TX-all-bytes\t%u\n",
Ben Greearb72acdd2010-10-01 10:54:04 -0700610 st->tx_bytes_count);
Bruno Randolf76443952010-03-09 16:56:00 +0900611
Dan Carpenter2189d132010-07-22 10:52:02 +0200612 if (len > sizeof(buf))
613 len = sizeof(buf);
614
Bruno Randolf76443952010-03-09 16:56:00 +0900615 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
616}
617
618static ssize_t write_file_frameerrors(struct file *file,
619 const char __user *userbuf,
620 size_t count, loff_t *ppos)
621{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400622 struct ath5k_hw *ah = file->private_data;
623 struct ath5k_statistics *st = &ah->stats;
Bruno Randolf76443952010-03-09 16:56:00 +0900624 char buf[20];
625
626 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
627 return -EFAULT;
628
629 if (strncmp(buf, "clear", 5) == 0) {
630 st->rxerr_crc = 0;
631 st->rxerr_phy = 0;
632 st->rxerr_fifo = 0;
633 st->rxerr_decrypt = 0;
634 st->rxerr_mic = 0;
635 st->rxerr_proc = 0;
636 st->rxerr_jumbo = 0;
637 st->rx_all_count = 0;
638 st->txerr_retry = 0;
639 st->txerr_fifo = 0;
640 st->txerr_filt = 0;
641 st->tx_all_count = 0;
642 printk(KERN_INFO "ath5k debug: cleared frameerrors stats\n");
643 }
644 return count;
645}
646
647static const struct file_operations fops_frameerrors = {
648 .read = read_file_frameerrors,
649 .write = write_file_frameerrors,
650 .open = ath5k_debugfs_open,
651 .owner = THIS_MODULE,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200652 .llseek = default_llseek,
Bruno Randolf76443952010-03-09 16:56:00 +0900653};
654
655
Bruno Randolf2111ac02010-04-02 18:44:08 +0900656/* debugfs: ani */
657
658static ssize_t read_file_ani(struct file *file, char __user *user_buf,
659 size_t count, loff_t *ppos)
660{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400661 struct ath5k_hw *ah = file->private_data;
662 struct ath5k_statistics *st = &ah->stats;
663 struct ath5k_ani_state *as = &ah->ani_state;
Bruno Randolf2111ac02010-04-02 18:44:08 +0900664
665 char buf[700];
666 unsigned int len = 0;
667
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400668 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900669 "HW has PHY error counters:\t%s\n",
Pavel Roskine0d687b2011-07-14 20:21:55 -0400670 ah->ah_capabilities.cap_has_phyerr_counters ?
Bruno Randolf2111ac02010-04-02 18:44:08 +0900671 "yes" : "no");
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400672 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900673 "HW max spur immunity level:\t%d\n",
674 as->max_spur_level);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400675 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900676 "\nANI state\n--------------------------------------------\n");
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400677 len += snprintf(buf + len, sizeof(buf) - len, "operating mode:\t\t\t");
Bruno Randolf2111ac02010-04-02 18:44:08 +0900678 switch (as->ani_mode) {
679 case ATH5K_ANI_MODE_OFF:
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400680 len += snprintf(buf + len, sizeof(buf) - len, "OFF\n");
Bruno Randolf2111ac02010-04-02 18:44:08 +0900681 break;
682 case ATH5K_ANI_MODE_MANUAL_LOW:
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400683 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900684 "MANUAL LOW\n");
685 break;
686 case ATH5K_ANI_MODE_MANUAL_HIGH:
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400687 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900688 "MANUAL HIGH\n");
689 break;
690 case ATH5K_ANI_MODE_AUTO:
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400691 len += snprintf(buf + len, sizeof(buf) - len, "AUTO\n");
Bruno Randolf2111ac02010-04-02 18:44:08 +0900692 break;
693 default:
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400694 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900695 "??? (not good)\n");
696 break;
697 }
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400698 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900699 "noise immunity level:\t\t%d\n",
700 as->noise_imm_level);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400701 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900702 "spur immunity level:\t\t%d\n",
703 as->spur_level);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400704 len += snprintf(buf + len, sizeof(buf) - len,
705 "firstep level:\t\t\t%d\n",
Bruno Randolf2111ac02010-04-02 18:44:08 +0900706 as->firstep_level);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400707 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900708 "OFDM weak signal detection:\t%s\n",
709 as->ofdm_weak_sig ? "on" : "off");
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400710 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900711 "CCK weak signal detection:\t%s\n",
712 as->cck_weak_sig ? "on" : "off");
713
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400714 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900715 "\nMIB INTERRUPTS:\t\t%u\n",
716 st->mib_intr);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400717 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900718 "beacon RSSI average:\t%d\n",
Pavel Roskine0d687b2011-07-14 20:21:55 -0400719 (int)ewma_read(&ah->ah_beacon_rssi_avg));
Felix Fietkau7109ca52010-10-08 22:13:54 +0200720
721#define CC_PRINT(_struct, _field) \
722 _struct._field, \
723 _struct.cycles > 0 ? \
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400724 _struct._field * 100 / _struct.cycles : 0
Felix Fietkau7109ca52010-10-08 22:13:54 +0200725
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400726 len += snprintf(buf + len, sizeof(buf) - len,
727 "profcnt tx\t\t%u\t(%d%%)\n",
Felix Fietkau7109ca52010-10-08 22:13:54 +0200728 CC_PRINT(as->last_cc, tx_frame));
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400729 len += snprintf(buf + len, sizeof(buf) - len,
730 "profcnt rx\t\t%u\t(%d%%)\n",
Felix Fietkau7109ca52010-10-08 22:13:54 +0200731 CC_PRINT(as->last_cc, rx_frame));
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400732 len += snprintf(buf + len, sizeof(buf) - len,
733 "profcnt busy\t\t%u\t(%d%%)\n",
Felix Fietkau7109ca52010-10-08 22:13:54 +0200734 CC_PRINT(as->last_cc, rx_busy));
735#undef CC_PRINT
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400736 len += snprintf(buf + len, sizeof(buf) - len, "profcnt cycles\t\t%u\n",
Felix Fietkau7109ca52010-10-08 22:13:54 +0200737 as->last_cc.cycles);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400738 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900739 "listen time\t\t%d\tlast: %d\n",
740 as->listen_time, as->last_listen);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400741 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900742 "OFDM errors\t\t%u\tlast: %u\tsum: %u\n",
743 as->ofdm_errors, as->last_ofdm_errors,
744 as->sum_ofdm_errors);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400745 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900746 "CCK errors\t\t%u\tlast: %u\tsum: %u\n",
747 as->cck_errors, as->last_cck_errors,
748 as->sum_cck_errors);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400749 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900750 "AR5K_PHYERR_CNT1\t%x\t(=%d)\n",
Pavel Roskine0d687b2011-07-14 20:21:55 -0400751 ath5k_hw_reg_read(ah, AR5K_PHYERR_CNT1),
Bruno Randolf2111ac02010-04-02 18:44:08 +0900752 ATH5K_ANI_OFDM_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
Pavel Roskine0d687b2011-07-14 20:21:55 -0400753 ath5k_hw_reg_read(ah, AR5K_PHYERR_CNT1)));
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400754 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900755 "AR5K_PHYERR_CNT2\t%x\t(=%d)\n",
Pavel Roskine0d687b2011-07-14 20:21:55 -0400756 ath5k_hw_reg_read(ah, AR5K_PHYERR_CNT2),
Bruno Randolf2111ac02010-04-02 18:44:08 +0900757 ATH5K_ANI_CCK_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
Pavel Roskine0d687b2011-07-14 20:21:55 -0400758 ath5k_hw_reg_read(ah, AR5K_PHYERR_CNT2)));
Bruno Randolf2111ac02010-04-02 18:44:08 +0900759
Dan Carpenter2189d132010-07-22 10:52:02 +0200760 if (len > sizeof(buf))
761 len = sizeof(buf);
762
Bruno Randolf2111ac02010-04-02 18:44:08 +0900763 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
764}
765
766static ssize_t write_file_ani(struct file *file,
767 const char __user *userbuf,
768 size_t count, loff_t *ppos)
769{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400770 struct ath5k_hw *ah = file->private_data;
Bruno Randolf2111ac02010-04-02 18:44:08 +0900771 char buf[20];
772
773 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
774 return -EFAULT;
775
776 if (strncmp(buf, "sens-low", 8) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400777 ath5k_ani_init(ah, ATH5K_ANI_MODE_MANUAL_HIGH);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900778 } else if (strncmp(buf, "sens-high", 9) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400779 ath5k_ani_init(ah, ATH5K_ANI_MODE_MANUAL_LOW);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900780 } else if (strncmp(buf, "ani-off", 7) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400781 ath5k_ani_init(ah, ATH5K_ANI_MODE_OFF);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900782 } else if (strncmp(buf, "ani-on", 6) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400783 ath5k_ani_init(ah, ATH5K_ANI_MODE_AUTO);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900784 } else if (strncmp(buf, "noise-low", 9) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400785 ath5k_ani_set_noise_immunity_level(ah, 0);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900786 } else if (strncmp(buf, "noise-high", 10) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400787 ath5k_ani_set_noise_immunity_level(ah,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900788 ATH5K_ANI_MAX_NOISE_IMM_LVL);
789 } else if (strncmp(buf, "spur-low", 8) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400790 ath5k_ani_set_spur_immunity_level(ah, 0);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900791 } else if (strncmp(buf, "spur-high", 9) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400792 ath5k_ani_set_spur_immunity_level(ah,
793 ah->ani_state.max_spur_level);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900794 } else if (strncmp(buf, "fir-low", 7) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400795 ath5k_ani_set_firstep_level(ah, 0);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900796 } else if (strncmp(buf, "fir-high", 8) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400797 ath5k_ani_set_firstep_level(ah, ATH5K_ANI_MAX_FIRSTEP_LVL);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900798 } else if (strncmp(buf, "ofdm-off", 8) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400799 ath5k_ani_set_ofdm_weak_signal_detection(ah, false);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900800 } else if (strncmp(buf, "ofdm-on", 7) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400801 ath5k_ani_set_ofdm_weak_signal_detection(ah, true);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900802 } else if (strncmp(buf, "cck-off", 7) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400803 ath5k_ani_set_cck_weak_signal_detection(ah, false);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900804 } else if (strncmp(buf, "cck-on", 6) == 0) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400805 ath5k_ani_set_cck_weak_signal_detection(ah, true);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900806 }
807 return count;
808}
809
810static const struct file_operations fops_ani = {
811 .read = read_file_ani,
812 .write = write_file_ani,
813 .open = ath5k_debugfs_open,
814 .owner = THIS_MODULE,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200815 .llseek = default_llseek,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900816};
817
818
Bruno Randolf3cfd43f2010-06-07 13:11:40 +0900819/* debugfs: queues etc */
820
821static ssize_t read_file_queue(struct file *file, char __user *user_buf,
822 size_t count, loff_t *ppos)
823{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400824 struct ath5k_hw *ah = file->private_data;
Bruno Randolf3cfd43f2010-06-07 13:11:40 +0900825 char buf[700];
826 unsigned int len = 0;
827
828 struct ath5k_txq *txq;
829 struct ath5k_buf *bf, *bf0;
Bruno Randolfcfddc112010-09-17 11:36:40 +0900830 int i, n;
Bruno Randolf3cfd43f2010-06-07 13:11:40 +0900831
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400832 len += snprintf(buf + len, sizeof(buf) - len,
Pavel Roskine0d687b2011-07-14 20:21:55 -0400833 "available txbuffers: %d\n", ah->txbuf_len);
Bruno Randolf3cfd43f2010-06-07 13:11:40 +0900834
Pavel Roskine0d687b2011-07-14 20:21:55 -0400835 for (i = 0; i < ARRAY_SIZE(ah->txqs); i++) {
836 txq = &ah->txqs[i];
Bruno Randolf3cfd43f2010-06-07 13:11:40 +0900837
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400838 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf3cfd43f2010-06-07 13:11:40 +0900839 "%02d: %ssetup\n", i, txq->setup ? "" : "not ");
840
841 if (!txq->setup)
842 continue;
843
Bruno Randolfcfddc112010-09-17 11:36:40 +0900844 n = 0;
845 spin_lock_bh(&txq->lock);
Bruno Randolf3cfd43f2010-06-07 13:11:40 +0900846 list_for_each_entry_safe(bf, bf0, &txq->q, list)
847 n++;
Bruno Randolfcfddc112010-09-17 11:36:40 +0900848 spin_unlock_bh(&txq->lock);
849
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400850 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolfcfddc112010-09-17 11:36:40 +0900851 " len: %d bufs: %d\n", txq->txq_len, n);
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400852 len += snprintf(buf + len, sizeof(buf) - len,
Bruno Randolf923e5b32010-09-17 11:37:02 +0900853 " stuck: %d\n", txq->txq_stuck);
Bruno Randolf3cfd43f2010-06-07 13:11:40 +0900854 }
855
Dan Carpenter2189d132010-07-22 10:52:02 +0200856 if (len > sizeof(buf))
857 len = sizeof(buf);
858
Bruno Randolf3cfd43f2010-06-07 13:11:40 +0900859 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
860}
861
862static ssize_t write_file_queue(struct file *file,
863 const char __user *userbuf,
864 size_t count, loff_t *ppos)
865{
Pavel Roskine0d687b2011-07-14 20:21:55 -0400866 struct ath5k_hw *ah = file->private_data;
Bruno Randolf3cfd43f2010-06-07 13:11:40 +0900867 char buf[20];
868
869 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
870 return -EFAULT;
871
872 if (strncmp(buf, "start", 5) == 0)
Pavel Roskine0d687b2011-07-14 20:21:55 -0400873 ieee80211_wake_queues(ah->hw);
Bruno Randolf3cfd43f2010-06-07 13:11:40 +0900874 else if (strncmp(buf, "stop", 4) == 0)
Pavel Roskine0d687b2011-07-14 20:21:55 -0400875 ieee80211_stop_queues(ah->hw);
Bruno Randolf3cfd43f2010-06-07 13:11:40 +0900876
877 return count;
878}
879
880
881static const struct file_operations fops_queue = {
882 .read = read_file_queue,
883 .write = write_file_queue,
884 .open = ath5k_debugfs_open,
885 .owner = THIS_MODULE,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200886 .llseek = default_llseek,
Bruno Randolf3cfd43f2010-06-07 13:11:40 +0900887};
888
889
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200890void
Pavel Roskine0d687b2011-07-14 20:21:55 -0400891ath5k_debug_init_device(struct ath5k_hw *ah)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200892{
Felix Fietkau5b7916a2011-04-10 18:32:18 +0200893 struct dentry *phydir;
894
Pavel Roskine0d687b2011-07-14 20:21:55 -0400895 ah->debug.level = ath5k_debug;
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900896
Pavel Roskine0d687b2011-07-14 20:21:55 -0400897 phydir = debugfs_create_dir("ath5k", ah->hw->wiphy->debugfsdir);
Felix Fietkau5b7916a2011-04-10 18:32:18 +0200898 if (!phydir)
Pavel Roskine4bbf2f2011-07-07 18:14:13 -0400899 return;
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900900
Pavel Roskine0d687b2011-07-14 20:21:55 -0400901 debugfs_create_file("debug", S_IWUSR | S_IRUSR, phydir, ah,
Felix Fietkau5b7916a2011-04-10 18:32:18 +0200902 &fops_debug);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200903
Pavel Roskine0d687b2011-07-14 20:21:55 -0400904 debugfs_create_file("registers", S_IRUSR, phydir, ah, &fops_registers);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200905
Pavel Roskine0d687b2011-07-14 20:21:55 -0400906 debugfs_create_file("beacon", S_IWUSR | S_IRUSR, phydir, ah,
Felix Fietkau5b7916a2011-04-10 18:32:18 +0200907 &fops_beacon);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200908
Pavel Roskine0d687b2011-07-14 20:21:55 -0400909 debugfs_create_file("reset", S_IWUSR, phydir, ah, &fops_reset);
Bruno Randolf604eead2010-03-09 16:55:17 +0900910
Pavel Roskine0d687b2011-07-14 20:21:55 -0400911 debugfs_create_file("antenna", S_IWUSR | S_IRUSR, phydir, ah,
Felix Fietkau5b7916a2011-04-10 18:32:18 +0200912 &fops_antenna);
Bruno Randolf76443952010-03-09 16:56:00 +0900913
Pavel Roskine0d687b2011-07-14 20:21:55 -0400914 debugfs_create_file("misc", S_IRUSR, phydir, ah, &fops_misc);
Ben Greear87fd2e62010-09-21 17:03:57 -0700915
Pavel Roskine0d687b2011-07-14 20:21:55 -0400916 debugfs_create_file("frameerrors", S_IWUSR | S_IRUSR, phydir, ah,
Felix Fietkau5b7916a2011-04-10 18:32:18 +0200917 &fops_frameerrors);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900918
Pavel Roskine0d687b2011-07-14 20:21:55 -0400919 debugfs_create_file("ani", S_IWUSR | S_IRUSR, phydir, ah, &fops_ani);
Bruno Randolf3cfd43f2010-06-07 13:11:40 +0900920
Pavel Roskine0d687b2011-07-14 20:21:55 -0400921 debugfs_create_file("queue", S_IWUSR | S_IRUSR, phydir, ah,
Felix Fietkau5b7916a2011-04-10 18:32:18 +0200922 &fops_queue);
Felix Fietkau63402112011-07-12 09:02:04 +0800923
924 debugfs_create_bool("32khz_clock", S_IWUSR | S_IRUSR, phydir,
Pavel Roskine0d687b2011-07-14 20:21:55 -0400925 &ah->ah_use_32khz_clock);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200926}
927
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200928/* functions used in other places */
929
930void
Pavel Roskine0d687b2011-07-14 20:21:55 -0400931ath5k_debug_dump_bands(struct ath5k_hw *ah)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200932{
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500933 unsigned int b, i;
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200934
Pavel Roskine0d687b2011-07-14 20:21:55 -0400935 if (likely(!(ah->debug.level & ATH5K_DEBUG_DUMPBANDS)))
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200936 return;
937
Pavel Roskine0d687b2011-07-14 20:21:55 -0400938 BUG_ON(!ah->sbands);
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500939
940 for (b = 0; b < IEEE80211_NUM_BANDS; b++) {
Pavel Roskine0d687b2011-07-14 20:21:55 -0400941 struct ieee80211_supported_band *band = &ah->sbands[b];
Bob Copelandb7fcb5c2009-04-27 22:12:43 -0400942 char bname[6];
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500943 switch (band->band) {
944 case IEEE80211_BAND_2GHZ:
945 strcpy(bname, "2 GHz");
946 break;
947 case IEEE80211_BAND_5GHZ:
948 strcpy(bname, "5 GHz");
949 break;
950 default:
951 printk(KERN_DEBUG "Band not supported: %d\n",
952 band->band);
953 return;
954 }
955 printk(KERN_DEBUG "Band %s: channels %d, rates %d\n", bname,
956 band->n_channels, band->n_bitrates);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200957 printk(KERN_DEBUG " channels:\n");
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500958 for (i = 0; i < band->n_channels; i++)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200959 printk(KERN_DEBUG " %3d %d %.4x %.4x\n",
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500960 ieee80211_frequency_to_channel(
961 band->channels[i].center_freq),
962 band->channels[i].center_freq,
963 band->channels[i].hw_value,
964 band->channels[i].flags);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200965 printk(KERN_DEBUG " rates:\n");
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500966 for (i = 0; i < band->n_bitrates; i++)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200967 printk(KERN_DEBUG " %4d %.4x %.4x %.4x\n",
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500968 band->bitrates[i].bitrate,
969 band->bitrates[i].hw_value,
970 band->bitrates[i].flags,
971 band->bitrates[i].hw_value_short);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200972 }
973}
974
975static inline void
Bruno Randolfb47f4072008-03-05 18:35:45 +0900976ath5k_debug_printrxbuf(struct ath5k_buf *bf, int done,
977 struct ath5k_rx_status *rs)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200978{
979 struct ath5k_desc *ds = bf->desc;
Bruno Randolf19fd6e52008-03-05 18:35:23 +0900980 struct ath5k_hw_all_rx_desc *rd = &ds->ud.ds_rx;
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200981
982 printk(KERN_DEBUG "R (%p %llx) %08x %08x %08x %08x %08x %08x %c\n",
983 ds, (unsigned long long)bf->daddr,
Bruno Randolf19fd6e52008-03-05 18:35:23 +0900984 ds->ds_link, ds->ds_data,
985 rd->rx_ctl.rx_control_0, rd->rx_ctl.rx_control_1,
Bruno Randolf62412a82010-06-16 19:12:12 +0900986 rd->rx_stat.rx_status_0, rd->rx_stat.rx_status_1,
Bruno Randolfb47f4072008-03-05 18:35:45 +0900987 !done ? ' ' : (rs->rs_status == 0) ? '*' : '!');
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200988}
989
990void
Pavel Roskine0d687b2011-07-14 20:21:55 -0400991ath5k_debug_printrxbuffs(struct ath5k_hw *ah)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200992{
993 struct ath5k_desc *ds;
994 struct ath5k_buf *bf;
Bruno Randolfb47f4072008-03-05 18:35:45 +0900995 struct ath5k_rx_status rs = {};
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200996 int status;
997
Pavel Roskine0d687b2011-07-14 20:21:55 -0400998 if (likely(!(ah->debug.level & ATH5K_DEBUG_DESC)))
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200999 return;
1000
Bruno Randolf265faad2010-06-16 19:11:30 +09001001 printk(KERN_DEBUG "rxdp %x, rxlink %p\n",
Pavel Roskine0d687b2011-07-14 20:21:55 -04001002 ath5k_hw_get_rxdp(ah), ah->rxlink);
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001003
Pavel Roskine0d687b2011-07-14 20:21:55 -04001004 spin_lock_bh(&ah->rxbuflock);
1005 list_for_each_entry(bf, &ah->rxbuf, list) {
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001006 ds = bf->desc;
Bruno Randolfb47f4072008-03-05 18:35:45 +09001007 status = ah->ah_proc_rx_desc(ah, ds, &rs);
Bruno Randolfbe9b7252008-01-23 10:27:51 +09001008 if (!status)
Bruno Randolfb47f4072008-03-05 18:35:45 +09001009 ath5k_debug_printrxbuf(bf, status == 0, &rs);
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001010 }
Pavel Roskine0d687b2011-07-14 20:21:55 -04001011 spin_unlock_bh(&ah->rxbuflock);
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001012}
1013
1014void
Pavel Roskine0d687b2011-07-14 20:21:55 -04001015ath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf)
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001016{
1017 struct ath5k_desc *ds = bf->desc;
Bruno Randolf19fd6e52008-03-05 18:35:23 +09001018 struct ath5k_hw_5212_tx_desc *td = &ds->ud.ds_tx5212;
Bruno Randolfb47f4072008-03-05 18:35:45 +09001019 struct ath5k_tx_status ts = {};
1020 int done;
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001021
Pavel Roskine0d687b2011-07-14 20:21:55 -04001022 if (likely(!(ah->debug.level & ATH5K_DEBUG_DESC)))
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001023 return;
1024
Pavel Roskine0d687b2011-07-14 20:21:55 -04001025 done = ah->ah_proc_tx_desc(ah, bf->desc, &ts);
Bruno Randolfb47f4072008-03-05 18:35:45 +09001026
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001027 printk(KERN_DEBUG "T (%p %llx) %08x %08x %08x %08x %08x %08x %08x "
1028 "%08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link,
Bruno Randolf19fd6e52008-03-05 18:35:23 +09001029 ds->ds_data, td->tx_ctl.tx_control_0, td->tx_ctl.tx_control_1,
1030 td->tx_ctl.tx_control_2, td->tx_ctl.tx_control_3,
1031 td->tx_stat.tx_status_0, td->tx_stat.tx_status_1,
Bruno Randolfb47f4072008-03-05 18:35:45 +09001032 done ? ' ' : (ts.ts_status == 0) ? '*' : '!');
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001033}