blob: c58503c3d0d10fb0774fdafeb1b9291ee0a783df [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 */
60
Jiri Slabyfa1c1142007-08-12 17:33:16 +020061#include "base.h"
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030062#include "debug.h"
Jiri Slabyfa1c1142007-08-12 17:33:16 +020063
64static unsigned int ath5k_debug;
65module_param_named(debug, ath5k_debug, uint, 0);
66
67
Luis R. Rodriguezb4461972008-02-04 10:03:54 -050068#ifdef CONFIG_ATH5K_DEBUG
Jiri Slabyfa1c1142007-08-12 17:33:16 +020069
70#include <linux/seq_file.h>
71#include "reg.h"
Bruno Randolf2111ac02010-04-02 18:44:08 +090072#include "ani.h"
Jiri Slabyfa1c1142007-08-12 17:33:16 +020073
74static struct dentry *ath5k_global_debugfs;
75
76static int ath5k_debugfs_open(struct inode *inode, struct file *file)
77{
78 file->private_data = inode->i_private;
79 return 0;
80}
81
82
83/* debugfs: registers */
84
85struct reg {
Jiri Slaby2c91108c2009-03-07 10:26:41 +010086 const char *name;
Jiri Slabyfa1c1142007-08-12 17:33:16 +020087 int addr;
88};
89
90#define REG_STRUCT_INIT(r) { #r, r }
91
92/* just a few random registers, might want to add more */
Jiri Slaby2c91108c2009-03-07 10:26:41 +010093static const struct reg regs[] = {
Jiri Slabyfa1c1142007-08-12 17:33:16 +020094 REG_STRUCT_INIT(AR5K_CR),
95 REG_STRUCT_INIT(AR5K_RXDP),
96 REG_STRUCT_INIT(AR5K_CFG),
97 REG_STRUCT_INIT(AR5K_IER),
98 REG_STRUCT_INIT(AR5K_BCR),
99 REG_STRUCT_INIT(AR5K_RTSD0),
100 REG_STRUCT_INIT(AR5K_RTSD1),
101 REG_STRUCT_INIT(AR5K_TXCFG),
102 REG_STRUCT_INIT(AR5K_RXCFG),
103 REG_STRUCT_INIT(AR5K_RXJLA),
104 REG_STRUCT_INIT(AR5K_MIBC),
105 REG_STRUCT_INIT(AR5K_TOPS),
106 REG_STRUCT_INIT(AR5K_RXNOFRM),
107 REG_STRUCT_INIT(AR5K_TXNOFRM),
108 REG_STRUCT_INIT(AR5K_RPGTO),
109 REG_STRUCT_INIT(AR5K_RFCNT),
110 REG_STRUCT_INIT(AR5K_MISC),
111 REG_STRUCT_INIT(AR5K_QCUDCU_CLKGT),
112 REG_STRUCT_INIT(AR5K_ISR),
113 REG_STRUCT_INIT(AR5K_PISR),
114 REG_STRUCT_INIT(AR5K_SISR0),
115 REG_STRUCT_INIT(AR5K_SISR1),
116 REG_STRUCT_INIT(AR5K_SISR2),
117 REG_STRUCT_INIT(AR5K_SISR3),
118 REG_STRUCT_INIT(AR5K_SISR4),
119 REG_STRUCT_INIT(AR5K_IMR),
120 REG_STRUCT_INIT(AR5K_PIMR),
121 REG_STRUCT_INIT(AR5K_SIMR0),
122 REG_STRUCT_INIT(AR5K_SIMR1),
123 REG_STRUCT_INIT(AR5K_SIMR2),
124 REG_STRUCT_INIT(AR5K_SIMR3),
125 REG_STRUCT_INIT(AR5K_SIMR4),
126 REG_STRUCT_INIT(AR5K_DCM_ADDR),
127 REG_STRUCT_INIT(AR5K_DCCFG),
128 REG_STRUCT_INIT(AR5K_CCFG),
129 REG_STRUCT_INIT(AR5K_CPC0),
130 REG_STRUCT_INIT(AR5K_CPC1),
131 REG_STRUCT_INIT(AR5K_CPC2),
132 REG_STRUCT_INIT(AR5K_CPC3),
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300133 REG_STRUCT_INIT(AR5K_CPCOVF),
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200134 REG_STRUCT_INIT(AR5K_RESET_CTL),
135 REG_STRUCT_INIT(AR5K_SLEEP_CTL),
136 REG_STRUCT_INIT(AR5K_INTPEND),
137 REG_STRUCT_INIT(AR5K_SFR),
138 REG_STRUCT_INIT(AR5K_PCICFG),
139 REG_STRUCT_INIT(AR5K_GPIOCR),
140 REG_STRUCT_INIT(AR5K_GPIODO),
141 REG_STRUCT_INIT(AR5K_SREV),
142};
143
144static void *reg_start(struct seq_file *seq, loff_t *pos)
145{
Jiri Slaby2c91108c2009-03-07 10:26:41 +0100146 return *pos < ARRAY_SIZE(regs) ? (void *)&regs[*pos] : NULL;
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200147}
148
149static void reg_stop(struct seq_file *seq, void *p)
150{
151 /* nothing to do */
152}
153
154static void *reg_next(struct seq_file *seq, void *p, loff_t *pos)
155{
156 ++*pos;
Jiri Slaby2c91108c2009-03-07 10:26:41 +0100157 return *pos < ARRAY_SIZE(regs) ? (void *)&regs[*pos] : NULL;
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200158}
159
160static int reg_show(struct seq_file *seq, void *p)
161{
162 struct ath5k_softc *sc = seq->private;
163 struct reg *r = p;
164 seq_printf(seq, "%-25s0x%08x\n", r->name,
165 ath5k_hw_reg_read(sc->ah, r->addr));
166 return 0;
167}
168
Jan Engelhardt4101dec2009-01-14 13:52:18 -0800169static const struct seq_operations register_seq_ops = {
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200170 .start = reg_start,
171 .next = reg_next,
172 .stop = reg_stop,
173 .show = reg_show
174};
175
176static int open_file_registers(struct inode *inode, struct file *file)
177{
178 struct seq_file *s;
179 int res;
180 res = seq_open(file, &register_seq_ops);
181 if (res == 0) {
182 s = file->private_data;
183 s->private = inode->i_private;
184 }
185 return res;
186}
187
188static const struct file_operations fops_registers = {
189 .open = open_file_registers,
190 .read = seq_read,
191 .llseek = seq_lseek,
192 .release = seq_release,
193 .owner = THIS_MODULE,
194};
195
196
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200197/* debugfs: beacons */
198
199static ssize_t read_file_beacon(struct file *file, char __user *user_buf,
200 size_t count, loff_t *ppos)
201{
202 struct ath5k_softc *sc = file->private_data;
203 struct ath5k_hw *ah = sc->ah;
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900204 char buf[500];
205 unsigned int len = 0;
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200206 unsigned int v;
207 u64 tsf;
208
209 v = ath5k_hw_reg_read(sc->ah, AR5K_BEACON);
210 len += snprintf(buf+len, sizeof(buf)-len,
211 "%-24s0x%08x\tintval: %d\tTIM: 0x%x\n",
212 "AR5K_BEACON", v, v & AR5K_BEACON_PERIOD,
213 (v & AR5K_BEACON_TIM) >> AR5K_BEACON_TIM_S);
214
215 len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n",
216 "AR5K_LAST_TSTP", ath5k_hw_reg_read(sc->ah, AR5K_LAST_TSTP));
217
218 len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n\n",
219 "AR5K_BEACON_CNT", ath5k_hw_reg_read(sc->ah, AR5K_BEACON_CNT));
220
221 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER0);
222 len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
223 "AR5K_TIMER0 (TBTT)", v, v);
224
225 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER1);
226 len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
227 "AR5K_TIMER1 (DMA)", v, v >> 3);
228
229 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER2);
230 len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
231 "AR5K_TIMER2 (SWBA)", v, v >> 3);
232
233 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER3);
234 len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
235 "AR5K_TIMER3 (ATIM)", v, v);
236
237 tsf = ath5k_hw_get_tsf64(sc->ah);
238 len += snprintf(buf+len, sizeof(buf)-len,
John W. Linvillef868f4e2008-03-07 16:38:43 -0500239 "TSF\t\t0x%016llx\tTU: %08x\n",
240 (unsigned long long)tsf, TSF_TO_TU(tsf));
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200241
242 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{
249 struct ath5k_softc *sc = file->private_data;
250 struct ath5k_hw *ah = sc->ah;
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900251 char buf[20];
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200252
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900253 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
254 return -EFAULT;
255
256 if (strncmp(buf, "disable", 7) == 0) {
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200257 AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
258 printk(KERN_INFO "debugfs disable beacons\n");
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900259 } else if (strncmp(buf, "enable", 6) == 0) {
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200260 AR5K_REG_ENABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
261 printk(KERN_INFO "debugfs enable beacons\n");
262 }
263 return count;
264}
265
266static const struct file_operations fops_beacon = {
267 .read = read_file_beacon,
268 .write = write_file_beacon,
269 .open = ath5k_debugfs_open,
270 .owner = THIS_MODULE,
271};
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{
280 struct ath5k_softc *sc = file->private_data;
281 tasklet_schedule(&sc->restq);
282 return count;
283}
284
285static const struct file_operations fops_reset = {
286 .write = write_file_reset,
287 .open = ath5k_debugfs_open,
288 .owner = THIS_MODULE,
289};
290
291
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900292/* debugfs: debug level */
293
Jiri Slaby2c91108c2009-03-07 10:26:41 +0100294static const struct {
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900295 enum ath5k_debug_level level;
296 const char *name;
297 const char *desc;
298} dbg_info[] = {
299 { ATH5K_DEBUG_RESET, "reset", "reset and initialization" },
300 { ATH5K_DEBUG_INTR, "intr", "interrupt handling" },
301 { ATH5K_DEBUG_MODE, "mode", "mode init/setup" },
302 { ATH5K_DEBUG_XMIT, "xmit", "basic xmit operation" },
303 { ATH5K_DEBUG_BEACON, "beacon", "beacon handling" },
304 { ATH5K_DEBUG_CALIBRATE, "calib", "periodic calibration" },
305 { ATH5K_DEBUG_TXPOWER, "txpower", "transmit power setting" },
Bob Copeland85519a62008-10-29 08:30:53 -0400306 { ATH5K_DEBUG_LED, "led", "LED management" },
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900307 { ATH5K_DEBUG_DUMP_RX, "dumprx", "print received skb content" },
308 { ATH5K_DEBUG_DUMP_TX, "dumptx", "print transmit skb content" },
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500309 { ATH5K_DEBUG_DUMPBANDS, "dumpbands", "dump bands" },
Bruno Randolf2111ac02010-04-02 18:44:08 +0900310 { ATH5K_DEBUG_ANI, "ani", "adaptive noise immunity" },
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900311 { ATH5K_DEBUG_ANY, "all", "show all debug levels" },
312};
313
314static ssize_t read_file_debug(struct file *file, char __user *user_buf,
315 size_t count, loff_t *ppos)
316{
317 struct ath5k_softc *sc = file->private_data;
318 char buf[700];
319 unsigned int len = 0;
320 unsigned int i;
321
322 len += snprintf(buf+len, sizeof(buf)-len,
323 "DEBUG LEVEL: 0x%08x\n\n", sc->debug.level);
324
325 for (i = 0; i < ARRAY_SIZE(dbg_info) - 1; i++) {
326 len += snprintf(buf+len, sizeof(buf)-len,
327 "%10s %c 0x%08x - %s\n", dbg_info[i].name,
328 sc->debug.level & dbg_info[i].level ? '+' : ' ',
329 dbg_info[i].level, dbg_info[i].desc);
330 }
331 len += snprintf(buf+len, sizeof(buf)-len,
332 "%10s %c 0x%08x - %s\n", dbg_info[i].name,
333 sc->debug.level == dbg_info[i].level ? '+' : ' ',
334 dbg_info[i].level, dbg_info[i].desc);
335
336 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
337}
338
339static ssize_t write_file_debug(struct file *file,
340 const char __user *userbuf,
341 size_t count, loff_t *ppos)
342{
343 struct ath5k_softc *sc = file->private_data;
344 unsigned int i;
345 char buf[20];
346
347 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
348 return -EFAULT;
349
350 for (i = 0; i < ARRAY_SIZE(dbg_info); i++) {
351 if (strncmp(buf, dbg_info[i].name,
352 strlen(dbg_info[i].name)) == 0) {
353 sc->debug.level ^= dbg_info[i].level; /* toggle bit */
354 break;
355 }
356 }
357 return count;
358}
359
360static const struct file_operations fops_debug = {
361 .read = read_file_debug,
362 .write = write_file_debug,
363 .open = ath5k_debugfs_open,
364 .owner = THIS_MODULE,
365};
366
367
Bruno Randolf604eead2010-03-09 16:55:17 +0900368/* debugfs: antenna */
369
370static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
371 size_t count, loff_t *ppos)
372{
373 struct ath5k_softc *sc = file->private_data;
374 char buf[700];
375 unsigned int len = 0;
376 unsigned int i;
377 unsigned int v;
378
379 len += snprintf(buf+len, sizeof(buf)-len, "antenna mode\t%d\n",
380 sc->ah->ah_ant_mode);
381 len += snprintf(buf+len, sizeof(buf)-len, "default antenna\t%d\n",
382 sc->ah->ah_def_ant);
383 len += snprintf(buf+len, sizeof(buf)-len, "tx antenna\t%d\n",
384 sc->ah->ah_tx_ant);
385
386 len += snprintf(buf+len, sizeof(buf)-len, "\nANTENNA\t\tRX\tTX\n");
387 for (i = 1; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) {
388 len += snprintf(buf+len, sizeof(buf)-len,
389 "[antenna %d]\t%d\t%d\n",
390 i, sc->stats.antenna_rx[i], sc->stats.antenna_tx[i]);
391 }
392 len += snprintf(buf+len, sizeof(buf)-len, "[invalid]\t%d\t%d\n",
393 sc->stats.antenna_rx[0], sc->stats.antenna_tx[0]);
394
395 v = ath5k_hw_reg_read(sc->ah, AR5K_DEFAULT_ANTENNA);
396 len += snprintf(buf+len, sizeof(buf)-len,
397 "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v);
398
399 v = ath5k_hw_reg_read(sc->ah, AR5K_STA_ID1);
400 len += snprintf(buf+len, sizeof(buf)-len,
401 "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n",
402 (v & AR5K_STA_ID1_DEFAULT_ANTENNA) != 0);
403 len += snprintf(buf+len, sizeof(buf)-len,
404 "AR5K_STA_ID1_DESC_ANTENNA\t%d\n",
405 (v & AR5K_STA_ID1_DESC_ANTENNA) != 0);
406 len += snprintf(buf+len, sizeof(buf)-len,
407 "AR5K_STA_ID1_RTS_DEF_ANTENNA\t%d\n",
408 (v & AR5K_STA_ID1_RTS_DEF_ANTENNA) != 0);
409 len += snprintf(buf+len, sizeof(buf)-len,
410 "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n",
411 (v & AR5K_STA_ID1_SELFGEN_DEF_ANT) != 0);
412
413 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_AGCCTL);
414 len += snprintf(buf+len, sizeof(buf)-len,
415 "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n",
416 (v & AR5K_PHY_AGCCTL_OFDM_DIV_DIS) != 0);
417
418 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_RESTART);
419 len += snprintf(buf+len, sizeof(buf)-len,
420 "AR5K_PHY_RESTART_DIV_GC\t\t%x\n",
421 (v & AR5K_PHY_RESTART_DIV_GC) >> AR5K_PHY_RESTART_DIV_GC_S);
422
423 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_FAST_ANT_DIV);
424 len += snprintf(buf+len, sizeof(buf)-len,
425 "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n",
426 (v & AR5K_PHY_FAST_ANT_DIV_EN) != 0);
427
428 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
429}
430
431static ssize_t write_file_antenna(struct file *file,
432 const char __user *userbuf,
433 size_t count, loff_t *ppos)
434{
435 struct ath5k_softc *sc = file->private_data;
436 unsigned int i;
437 char buf[20];
438
439 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
440 return -EFAULT;
441
442 if (strncmp(buf, "diversity", 9) == 0) {
443 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_DEFAULT);
444 printk(KERN_INFO "ath5k debug: enable diversity\n");
445 } else if (strncmp(buf, "fixed-a", 7) == 0) {
446 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_A);
447 printk(KERN_INFO "ath5k debugfs: fixed antenna A\n");
448 } else if (strncmp(buf, "fixed-b", 7) == 0) {
449 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_B);
450 printk(KERN_INFO "ath5k debug: fixed antenna B\n");
451 } else if (strncmp(buf, "clear", 5) == 0) {
452 for (i = 0; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) {
453 sc->stats.antenna_rx[i] = 0;
454 sc->stats.antenna_tx[i] = 0;
455 }
456 printk(KERN_INFO "ath5k debug: cleared antenna stats\n");
457 }
458 return count;
459}
460
461static const struct file_operations fops_antenna = {
462 .read = read_file_antenna,
463 .write = write_file_antenna,
464 .open = ath5k_debugfs_open,
465 .owner = THIS_MODULE,
466};
467
468
Bruno Randolf76443952010-03-09 16:56:00 +0900469/* debugfs: frameerrors */
470
471static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf,
472 size_t count, loff_t *ppos)
473{
474 struct ath5k_softc *sc = file->private_data;
475 struct ath5k_statistics *st = &sc->stats;
476 char buf[700];
477 unsigned int len = 0;
Bruno Randolfda351112010-03-25 14:49:42 +0900478 int i;
Bruno Randolf76443952010-03-09 16:56:00 +0900479
480 len += snprintf(buf+len, sizeof(buf)-len,
481 "RX\n---------------------\n");
482 len += snprintf(buf+len, sizeof(buf)-len, "CRC\t%d\t(%d%%)\n",
483 st->rxerr_crc,
484 st->rx_all_count > 0 ?
485 st->rxerr_crc*100/st->rx_all_count : 0);
486 len += snprintf(buf+len, sizeof(buf)-len, "PHY\t%d\t(%d%%)\n",
487 st->rxerr_phy,
488 st->rx_all_count > 0 ?
489 st->rxerr_phy*100/st->rx_all_count : 0);
Bruno Randolfda351112010-03-25 14:49:42 +0900490 for (i = 0; i < 32; i++) {
491 if (st->rxerr_phy_code[i])
492 len += snprintf(buf+len, sizeof(buf)-len,
493 " phy_err[%d]\t%d\n",
494 i, st->rxerr_phy_code[i]);
495 }
496
Bruno Randolf76443952010-03-09 16:56:00 +0900497 len += snprintf(buf+len, sizeof(buf)-len, "FIFO\t%d\t(%d%%)\n",
498 st->rxerr_fifo,
499 st->rx_all_count > 0 ?
500 st->rxerr_fifo*100/st->rx_all_count : 0);
501 len += snprintf(buf+len, sizeof(buf)-len, "decrypt\t%d\t(%d%%)\n",
502 st->rxerr_decrypt,
503 st->rx_all_count > 0 ?
504 st->rxerr_decrypt*100/st->rx_all_count : 0);
505 len += snprintf(buf+len, sizeof(buf)-len, "MIC\t%d\t(%d%%)\n",
506 st->rxerr_mic,
507 st->rx_all_count > 0 ?
508 st->rxerr_mic*100/st->rx_all_count : 0);
509 len += snprintf(buf+len, sizeof(buf)-len, "process\t%d\t(%d%%)\n",
510 st->rxerr_proc,
511 st->rx_all_count > 0 ?
512 st->rxerr_proc*100/st->rx_all_count : 0);
513 len += snprintf(buf+len, sizeof(buf)-len, "jumbo\t%d\t(%d%%)\n",
514 st->rxerr_jumbo,
515 st->rx_all_count > 0 ?
516 st->rxerr_jumbo*100/st->rx_all_count : 0);
517 len += snprintf(buf+len, sizeof(buf)-len, "[RX all\t%d]\n",
518 st->rx_all_count);
519
520 len += snprintf(buf+len, sizeof(buf)-len,
521 "\nTX\n---------------------\n");
522 len += snprintf(buf+len, sizeof(buf)-len, "retry\t%d\t(%d%%)\n",
523 st->txerr_retry,
524 st->tx_all_count > 0 ?
525 st->txerr_retry*100/st->tx_all_count : 0);
526 len += snprintf(buf+len, sizeof(buf)-len, "FIFO\t%d\t(%d%%)\n",
527 st->txerr_fifo,
528 st->tx_all_count > 0 ?
529 st->txerr_fifo*100/st->tx_all_count : 0);
530 len += snprintf(buf+len, sizeof(buf)-len, "filter\t%d\t(%d%%)\n",
531 st->txerr_filt,
532 st->tx_all_count > 0 ?
533 st->txerr_filt*100/st->tx_all_count : 0);
534 len += snprintf(buf+len, sizeof(buf)-len, "[TX all\t%d]\n",
535 st->tx_all_count);
536
537 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
538}
539
540static ssize_t write_file_frameerrors(struct file *file,
541 const char __user *userbuf,
542 size_t count, loff_t *ppos)
543{
544 struct ath5k_softc *sc = file->private_data;
545 struct ath5k_statistics *st = &sc->stats;
546 char buf[20];
547
548 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
549 return -EFAULT;
550
551 if (strncmp(buf, "clear", 5) == 0) {
552 st->rxerr_crc = 0;
553 st->rxerr_phy = 0;
554 st->rxerr_fifo = 0;
555 st->rxerr_decrypt = 0;
556 st->rxerr_mic = 0;
557 st->rxerr_proc = 0;
558 st->rxerr_jumbo = 0;
559 st->rx_all_count = 0;
560 st->txerr_retry = 0;
561 st->txerr_fifo = 0;
562 st->txerr_filt = 0;
563 st->tx_all_count = 0;
564 printk(KERN_INFO "ath5k debug: cleared frameerrors stats\n");
565 }
566 return count;
567}
568
569static const struct file_operations fops_frameerrors = {
570 .read = read_file_frameerrors,
571 .write = write_file_frameerrors,
572 .open = ath5k_debugfs_open,
573 .owner = THIS_MODULE,
574};
575
576
Bruno Randolf2111ac02010-04-02 18:44:08 +0900577/* debugfs: ani */
578
579static ssize_t read_file_ani(struct file *file, char __user *user_buf,
580 size_t count, loff_t *ppos)
581{
582 struct ath5k_softc *sc = file->private_data;
583 struct ath5k_statistics *st = &sc->stats;
584 struct ath5k_ani_state *as = &sc->ani_state;
585
586 char buf[700];
587 unsigned int len = 0;
588
589 len += snprintf(buf+len, sizeof(buf)-len,
590 "HW has PHY error counters:\t%s\n",
591 sc->ah->ah_capabilities.cap_has_phyerr_counters ?
592 "yes" : "no");
593 len += snprintf(buf+len, sizeof(buf)-len,
594 "HW max spur immunity level:\t%d\n",
595 as->max_spur_level);
596 len += snprintf(buf+len, sizeof(buf)-len,
597 "\nANI state\n--------------------------------------------\n");
598 len += snprintf(buf+len, sizeof(buf)-len, "operating mode:\t\t\t");
599 switch (as->ani_mode) {
600 case ATH5K_ANI_MODE_OFF:
601 len += snprintf(buf+len, sizeof(buf)-len, "OFF\n");
602 break;
603 case ATH5K_ANI_MODE_MANUAL_LOW:
604 len += snprintf(buf+len, sizeof(buf)-len,
605 "MANUAL LOW\n");
606 break;
607 case ATH5K_ANI_MODE_MANUAL_HIGH:
608 len += snprintf(buf+len, sizeof(buf)-len,
609 "MANUAL HIGH\n");
610 break;
611 case ATH5K_ANI_MODE_AUTO:
612 len += snprintf(buf+len, sizeof(buf)-len, "AUTO\n");
613 break;
614 default:
615 len += snprintf(buf+len, sizeof(buf)-len,
616 "??? (not good)\n");
617 break;
618 }
619 len += snprintf(buf+len, sizeof(buf)-len,
620 "noise immunity level:\t\t%d\n",
621 as->noise_imm_level);
622 len += snprintf(buf+len, sizeof(buf)-len,
623 "spur immunity level:\t\t%d\n",
624 as->spur_level);
625 len += snprintf(buf+len, sizeof(buf)-len, "firstep level:\t\t\t%d\n",
626 as->firstep_level);
627 len += snprintf(buf+len, sizeof(buf)-len,
628 "OFDM weak signal detection:\t%s\n",
629 as->ofdm_weak_sig ? "on" : "off");
630 len += snprintf(buf+len, sizeof(buf)-len,
631 "CCK weak signal detection:\t%s\n",
632 as->cck_weak_sig ? "on" : "off");
633
634 len += snprintf(buf+len, sizeof(buf)-len,
635 "\nMIB INTERRUPTS:\t\t%u\n",
636 st->mib_intr);
637 len += snprintf(buf+len, sizeof(buf)-len,
638 "beacon RSSI average:\t%d\n",
639 sc->ah->ah_beacon_rssi_avg.avg);
640 len += snprintf(buf+len, sizeof(buf)-len, "profcnt tx\t\t%u\t(%d%%)\n",
641 as->pfc_tx,
642 as->pfc_cycles > 0 ?
643 as->pfc_tx*100/as->pfc_cycles : 0);
644 len += snprintf(buf+len, sizeof(buf)-len, "profcnt rx\t\t%u\t(%d%%)\n",
645 as->pfc_rx,
646 as->pfc_cycles > 0 ?
647 as->pfc_rx*100/as->pfc_cycles : 0);
648 len += snprintf(buf+len, sizeof(buf)-len, "profcnt busy\t\t%u\t(%d%%)\n",
649 as->pfc_busy,
650 as->pfc_cycles > 0 ?
651 as->pfc_busy*100/as->pfc_cycles : 0);
652 len += snprintf(buf+len, sizeof(buf)-len, "profcnt cycles\t\t%u\n",
653 as->pfc_cycles);
654 len += snprintf(buf+len, sizeof(buf)-len,
655 "listen time\t\t%d\tlast: %d\n",
656 as->listen_time, as->last_listen);
657 len += snprintf(buf+len, sizeof(buf)-len,
658 "OFDM errors\t\t%u\tlast: %u\tsum: %u\n",
659 as->ofdm_errors, as->last_ofdm_errors,
660 as->sum_ofdm_errors);
661 len += snprintf(buf+len, sizeof(buf)-len,
662 "CCK errors\t\t%u\tlast: %u\tsum: %u\n",
663 as->cck_errors, as->last_cck_errors,
664 as->sum_cck_errors);
665 len += snprintf(buf+len, sizeof(buf)-len,
666 "AR5K_PHYERR_CNT1\t%x\t(=%d)\n",
667 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1),
668 ATH5K_ANI_OFDM_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
669 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1)));
670 len += snprintf(buf+len, sizeof(buf)-len,
671 "AR5K_PHYERR_CNT2\t%x\t(=%d)\n",
672 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2),
673 ATH5K_ANI_CCK_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
674 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2)));
675
676 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
677}
678
679static ssize_t write_file_ani(struct file *file,
680 const char __user *userbuf,
681 size_t count, loff_t *ppos)
682{
683 struct ath5k_softc *sc = file->private_data;
684 char buf[20];
685
686 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
687 return -EFAULT;
688
689 if (strncmp(buf, "sens-low", 8) == 0) {
690 ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_MANUAL_HIGH);
691 } else if (strncmp(buf, "sens-high", 9) == 0) {
692 ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_MANUAL_LOW);
693 } else if (strncmp(buf, "ani-off", 7) == 0) {
694 ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_OFF);
695 } else if (strncmp(buf, "ani-on", 6) == 0) {
696 ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_AUTO);
697 } else if (strncmp(buf, "noise-low", 9) == 0) {
698 ath5k_ani_set_noise_immunity_level(sc->ah, 0);
699 } else if (strncmp(buf, "noise-high", 10) == 0) {
700 ath5k_ani_set_noise_immunity_level(sc->ah,
701 ATH5K_ANI_MAX_NOISE_IMM_LVL);
702 } else if (strncmp(buf, "spur-low", 8) == 0) {
703 ath5k_ani_set_spur_immunity_level(sc->ah, 0);
704 } else if (strncmp(buf, "spur-high", 9) == 0) {
705 ath5k_ani_set_spur_immunity_level(sc->ah,
706 sc->ani_state.max_spur_level);
707 } else if (strncmp(buf, "fir-low", 7) == 0) {
708 ath5k_ani_set_firstep_level(sc->ah, 0);
709 } else if (strncmp(buf, "fir-high", 8) == 0) {
710 ath5k_ani_set_firstep_level(sc->ah, ATH5K_ANI_MAX_FIRSTEP_LVL);
711 } else if (strncmp(buf, "ofdm-off", 8) == 0) {
712 ath5k_ani_set_ofdm_weak_signal_detection(sc->ah, false);
713 } else if (strncmp(buf, "ofdm-on", 7) == 0) {
714 ath5k_ani_set_ofdm_weak_signal_detection(sc->ah, true);
715 } else if (strncmp(buf, "cck-off", 7) == 0) {
716 ath5k_ani_set_cck_weak_signal_detection(sc->ah, false);
717 } else if (strncmp(buf, "cck-on", 6) == 0) {
718 ath5k_ani_set_cck_weak_signal_detection(sc->ah, true);
719 }
720 return count;
721}
722
723static const struct file_operations fops_ani = {
724 .read = read_file_ani,
725 .write = write_file_ani,
726 .open = ath5k_debugfs_open,
727 .owner = THIS_MODULE,
728};
729
730
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200731/* init */
732
733void
734ath5k_debug_init(void)
735{
736 ath5k_global_debugfs = debugfs_create_dir("ath5k", NULL);
737}
738
739void
740ath5k_debug_init_device(struct ath5k_softc *sc)
741{
742 sc->debug.level = ath5k_debug;
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900743
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200744 sc->debug.debugfs_phydir = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900745 ath5k_global_debugfs);
746
Jiri Slaby31670072009-06-28 23:25:27 +0200747 sc->debug.debugfs_debug = debugfs_create_file("debug",
748 S_IWUSR | S_IRUSR,
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900749 sc->debug.debugfs_phydir, sc, &fops_debug);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200750
Jiri Slaby31670072009-06-28 23:25:27 +0200751 sc->debug.debugfs_registers = debugfs_create_file("registers", S_IRUSR,
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900752 sc->debug.debugfs_phydir, sc, &fops_registers);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200753
Jiri Slaby31670072009-06-28 23:25:27 +0200754 sc->debug.debugfs_beacon = debugfs_create_file("beacon",
755 S_IWUSR | S_IRUSR,
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900756 sc->debug.debugfs_phydir, sc, &fops_beacon);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200757
Cheng Renquan33ab6252008-11-22 11:22:49 +0800758 sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR,
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900759 sc->debug.debugfs_phydir, sc, &fops_reset);
Bruno Randolf604eead2010-03-09 16:55:17 +0900760
761 sc->debug.debugfs_antenna = debugfs_create_file("antenna",
762 S_IWUSR | S_IRUSR,
763 sc->debug.debugfs_phydir, sc, &fops_antenna);
Bruno Randolf76443952010-03-09 16:56:00 +0900764
765 sc->debug.debugfs_frameerrors = debugfs_create_file("frameerrors",
766 S_IWUSR | S_IRUSR,
767 sc->debug.debugfs_phydir, sc,
768 &fops_frameerrors);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900769
770 sc->debug.debugfs_ani = debugfs_create_file("ani",
771 S_IWUSR | S_IRUSR,
772 sc->debug.debugfs_phydir, sc,
773 &fops_ani);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200774}
775
776void
777ath5k_debug_finish(void)
778{
779 debugfs_remove(ath5k_global_debugfs);
780}
781
782void
783ath5k_debug_finish_device(struct ath5k_softc *sc)
784{
785 debugfs_remove(sc->debug.debugfs_debug);
786 debugfs_remove(sc->debug.debugfs_registers);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200787 debugfs_remove(sc->debug.debugfs_beacon);
788 debugfs_remove(sc->debug.debugfs_reset);
Bruno Randolf604eead2010-03-09 16:55:17 +0900789 debugfs_remove(sc->debug.debugfs_antenna);
Bruno Randolf76443952010-03-09 16:56:00 +0900790 debugfs_remove(sc->debug.debugfs_frameerrors);
Bruno Randolf2111ac02010-04-02 18:44:08 +0900791 debugfs_remove(sc->debug.debugfs_ani);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200792 debugfs_remove(sc->debug.debugfs_phydir);
793}
794
795
796/* functions used in other places */
797
798void
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500799ath5k_debug_dump_bands(struct ath5k_softc *sc)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200800{
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500801 unsigned int b, i;
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200802
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500803 if (likely(!(sc->debug.level & ATH5K_DEBUG_DUMPBANDS)))
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200804 return;
805
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500806 BUG_ON(!sc->sbands);
807
808 for (b = 0; b < IEEE80211_NUM_BANDS; b++) {
809 struct ieee80211_supported_band *band = &sc->sbands[b];
Bob Copelandb7fcb5c2009-04-27 22:12:43 -0400810 char bname[6];
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500811 switch (band->band) {
812 case IEEE80211_BAND_2GHZ:
813 strcpy(bname, "2 GHz");
814 break;
815 case IEEE80211_BAND_5GHZ:
816 strcpy(bname, "5 GHz");
817 break;
818 default:
819 printk(KERN_DEBUG "Band not supported: %d\n",
820 band->band);
821 return;
822 }
823 printk(KERN_DEBUG "Band %s: channels %d, rates %d\n", bname,
824 band->n_channels, band->n_bitrates);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200825 printk(KERN_DEBUG " channels:\n");
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500826 for (i = 0; i < band->n_channels; i++)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200827 printk(KERN_DEBUG " %3d %d %.4x %.4x\n",
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500828 ieee80211_frequency_to_channel(
829 band->channels[i].center_freq),
830 band->channels[i].center_freq,
831 band->channels[i].hw_value,
832 band->channels[i].flags);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200833 printk(KERN_DEBUG " rates:\n");
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500834 for (i = 0; i < band->n_bitrates; i++)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200835 printk(KERN_DEBUG " %4d %.4x %.4x %.4x\n",
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500836 band->bitrates[i].bitrate,
837 band->bitrates[i].hw_value,
838 band->bitrates[i].flags,
839 band->bitrates[i].hw_value_short);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200840 }
841}
842
843static inline void
Bruno Randolfb47f4072008-03-05 18:35:45 +0900844ath5k_debug_printrxbuf(struct ath5k_buf *bf, int done,
845 struct ath5k_rx_status *rs)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200846{
847 struct ath5k_desc *ds = bf->desc;
Bruno Randolf19fd6e52008-03-05 18:35:23 +0900848 struct ath5k_hw_all_rx_desc *rd = &ds->ud.ds_rx;
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200849
850 printk(KERN_DEBUG "R (%p %llx) %08x %08x %08x %08x %08x %08x %c\n",
851 ds, (unsigned long long)bf->daddr,
Bruno Randolf19fd6e52008-03-05 18:35:23 +0900852 ds->ds_link, ds->ds_data,
853 rd->rx_ctl.rx_control_0, rd->rx_ctl.rx_control_1,
854 rd->u.rx_stat.rx_status_0, rd->u.rx_stat.rx_status_0,
Bruno Randolfb47f4072008-03-05 18:35:45 +0900855 !done ? ' ' : (rs->rs_status == 0) ? '*' : '!');
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200856}
857
858void
859ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah)
860{
861 struct ath5k_desc *ds;
862 struct ath5k_buf *bf;
Bruno Randolfb47f4072008-03-05 18:35:45 +0900863 struct ath5k_rx_status rs = {};
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200864 int status;
865
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900866 if (likely(!(sc->debug.level & ATH5K_DEBUG_RESET)))
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200867 return;
868
869 printk(KERN_DEBUG "rx queue %x, link %p\n",
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300870 ath5k_hw_get_rxdp(ah), sc->rxlink);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200871
872 spin_lock_bh(&sc->rxbuflock);
873 list_for_each_entry(bf, &sc->rxbuf, list) {
874 ds = bf->desc;
Bruno Randolfb47f4072008-03-05 18:35:45 +0900875 status = ah->ah_proc_rx_desc(ah, ds, &rs);
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900876 if (!status)
Bruno Randolfb47f4072008-03-05 18:35:45 +0900877 ath5k_debug_printrxbuf(bf, status == 0, &rs);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200878 }
879 spin_unlock_bh(&sc->rxbuflock);
880}
881
882void
883ath5k_debug_dump_skb(struct ath5k_softc *sc,
884 struct sk_buff *skb, const char *prefix, int tx)
885{
886 char buf[16];
887
888 if (likely(!((tx && (sc->debug.level & ATH5K_DEBUG_DUMP_TX)) ||
889 (!tx && (sc->debug.level & ATH5K_DEBUG_DUMP_RX)))))
890 return;
891
892 snprintf(buf, sizeof(buf), "%s %s", wiphy_name(sc->hw->wiphy), prefix);
893
894 print_hex_dump_bytes(buf, DUMP_PREFIX_NONE, skb->data,
895 min(200U, skb->len));
896
897 printk(KERN_DEBUG "\n");
898}
899
900void
Bruno Randolfb47f4072008-03-05 18:35:45 +0900901ath5k_debug_printtxbuf(struct ath5k_softc *sc, struct ath5k_buf *bf)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200902{
903 struct ath5k_desc *ds = bf->desc;
Bruno Randolf19fd6e52008-03-05 18:35:23 +0900904 struct ath5k_hw_5212_tx_desc *td = &ds->ud.ds_tx5212;
Bruno Randolfb47f4072008-03-05 18:35:45 +0900905 struct ath5k_tx_status ts = {};
906 int done;
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200907
908 if (likely(!(sc->debug.level & ATH5K_DEBUG_RESET)))
909 return;
910
Bruno Randolfb47f4072008-03-05 18:35:45 +0900911 done = sc->ah->ah_proc_tx_desc(sc->ah, bf->desc, &ts);
912
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200913 printk(KERN_DEBUG "T (%p %llx) %08x %08x %08x %08x %08x %08x %08x "
914 "%08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link,
Bruno Randolf19fd6e52008-03-05 18:35:23 +0900915 ds->ds_data, td->tx_ctl.tx_control_0, td->tx_ctl.tx_control_1,
916 td->tx_ctl.tx_control_2, td->tx_ctl.tx_control_3,
917 td->tx_stat.tx_status_0, td->tx_stat.tx_status_1,
Bruno Randolfb47f4072008-03-05 18:35:45 +0900918 done ? ' ' : (ts.ts_status == 0) ? '*' : '!');
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200919}
920
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500921#endif /* ifdef CONFIG_ATH5K_DEBUG */