blob: 9b22722a95f04a420da49ff22395d3629cc965ca [file] [log] [blame]
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001/*
2 * Copyright (c) 2007 Bruno Randolf <bruno@thinktube.com>
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
61#ifndef _ATH5K_DEBUG_H
62#define _ATH5K_DEBUG_H
63
Jiri Slabyfa1c1142007-08-12 17:33:16 +020064struct ath5k_softc;
65struct ath5k_hw;
Jiri Slabyfa1c1142007-08-12 17:33:16 +020066struct sk_buff;
67struct ath5k_buf;
68
69struct ath5k_dbg_info {
70 unsigned int level; /* debug level */
71 /* debugfs entries */
72 struct dentry *debugfs_phydir;
73 struct dentry *debugfs_debug;
74 struct dentry *debugfs_registers;
Jiri Slabyfa1c1142007-08-12 17:33:16 +020075 struct dentry *debugfs_beacon;
76 struct dentry *debugfs_reset;
Bruno Randolf604eead2010-03-09 16:55:17 +090077 struct dentry *debugfs_antenna;
Bruno Randolf76443952010-03-09 16:56:00 +090078 struct dentry *debugfs_frameerrors;
Bruno Randolf2111ac02010-04-02 18:44:08 +090079 struct dentry *debugfs_ani;
Bruno Randolf3cfd43f2010-06-07 13:11:40 +090080 struct dentry *debugfs_queue;
Jiri Slabyfa1c1142007-08-12 17:33:16 +020081};
82
83/**
84 * enum ath5k_debug_level - ath5k debug level
85 *
86 * @ATH5K_DEBUG_RESET: reset processing
87 * @ATH5K_DEBUG_INTR: interrupt handling
88 * @ATH5K_DEBUG_MODE: mode init/setup
89 * @ATH5K_DEBUG_XMIT: basic xmit operation
90 * @ATH5K_DEBUG_BEACON: beacon handling
Jiri Slabyfa1c1142007-08-12 17:33:16 +020091 * @ATH5K_DEBUG_CALIBRATE: periodic calibration
92 * @ATH5K_DEBUG_TXPOWER: transmit power setting
93 * @ATH5K_DEBUG_LED: led management
94 * @ATH5K_DEBUG_DUMP_RX: print received skb content
95 * @ATH5K_DEBUG_DUMP_TX: print transmit skb content
Luis R. Rodriguezb4461972008-02-04 10:03:54 -050096 * @ATH5K_DEBUG_DUMPBANDS: dump bands
Jiri Slabyfa1c1142007-08-12 17:33:16 +020097 * @ATH5K_DEBUG_TRACE: trace function calls
Bob Copelandb4c52612010-08-21 16:39:03 -040098 * @ATH5K_DEBUG_DESC: descriptor setup
Jiri Slabyfa1c1142007-08-12 17:33:16 +020099 * @ATH5K_DEBUG_ANY: show at any debug level
100 *
101 * The debug level is used to control the amount and type of debugging output
102 * we want to see. The debug level is given in calls to ATH5K_DBG to specify
103 * where the message should appear, and the user can control the debugging
104 * messages he wants to see, either by the module parameter 'debug' on module
105 * load, or dynamically by using debugfs 'ath5k/phyX/debug'. these levels can
106 * be combined together by bitwise OR.
107 */
108enum ath5k_debug_level {
109 ATH5K_DEBUG_RESET = 0x00000001,
110 ATH5K_DEBUG_INTR = 0x00000002,
111 ATH5K_DEBUG_MODE = 0x00000004,
112 ATH5K_DEBUG_XMIT = 0x00000008,
113 ATH5K_DEBUG_BEACON = 0x00000010,
Bruno Randolfbe9b7252008-01-23 10:27:51 +0900114 ATH5K_DEBUG_CALIBRATE = 0x00000020,
115 ATH5K_DEBUG_TXPOWER = 0x00000040,
116 ATH5K_DEBUG_LED = 0x00000080,
117 ATH5K_DEBUG_DUMP_RX = 0x00000100,
118 ATH5K_DEBUG_DUMP_TX = 0x00000200,
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500119 ATH5K_DEBUG_DUMPBANDS = 0x00000400,
Bruno Randolf2111ac02010-04-02 18:44:08 +0900120 ATH5K_DEBUG_ANI = 0x00002000,
Bob Copelandb4c52612010-08-21 16:39:03 -0400121 ATH5K_DEBUG_DESC = 0x00004000,
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200122 ATH5K_DEBUG_ANY = 0xffffffff
123};
124
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500125#ifdef CONFIG_ATH5K_DEBUG
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200126
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200127#define ATH5K_DBG(_sc, _m, _fmt, ...) do { \
128 if (unlikely((_sc)->debug.level & (_m) && net_ratelimit())) \
129 ATH5K_PRINTK(_sc, KERN_DEBUG, "(%s:%d): " _fmt, \
130 __func__, __LINE__, ##__VA_ARGS__); \
131 } while (0)
132
133#define ATH5K_DBG_UNLIMIT(_sc, _m, _fmt, ...) do { \
134 if (unlikely((_sc)->debug.level & (_m))) \
135 ATH5K_PRINTK(_sc, KERN_DEBUG, "(%s:%d): " _fmt, \
136 __func__, __LINE__, ##__VA_ARGS__); \
137 } while (0)
138
139void
140ath5k_debug_init(void);
141
142void
143ath5k_debug_init_device(struct ath5k_softc *sc);
144
145void
146ath5k_debug_finish(void);
147
148void
149ath5k_debug_finish_device(struct ath5k_softc *sc);
150
151void
152ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah);
153
154void
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500155ath5k_debug_dump_bands(struct ath5k_softc *sc);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200156
157void
158ath5k_debug_dump_skb(struct ath5k_softc *sc,
159 struct sk_buff *skb, const char *prefix, int tx);
160
161void
Bruno Randolfb47f4072008-03-05 18:35:45 +0900162ath5k_debug_printtxbuf(struct ath5k_softc *sc, struct ath5k_buf *bf);
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200163
164#else /* no debugging */
165
Jiri Slaby6cd74e32008-02-15 21:58:53 +0100166#include <linux/compiler.h>
167
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200168static inline void __attribute__ ((format (printf, 3, 4)))
169ATH5K_DBG(struct ath5k_softc *sc, unsigned int m, const char *fmt, ...) {}
170
171static inline void __attribute__ ((format (printf, 3, 4)))
172ATH5K_DBG_UNLIMIT(struct ath5k_softc *sc, unsigned int m, const char *fmt, ...)
173{}
174
175static inline void
176ath5k_debug_init(void) {}
177
178static inline void
179ath5k_debug_init_device(struct ath5k_softc *sc) {}
180
181static inline void
182ath5k_debug_finish(void) {}
183
184static inline void
185ath5k_debug_finish_device(struct ath5k_softc *sc) {}
186
187static inline void
188ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah) {}
189
190static inline void
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500191ath5k_debug_dump_bands(struct ath5k_softc *sc) {}
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200192
193static inline void
194ath5k_debug_dump_skb(struct ath5k_softc *sc,
195 struct sk_buff *skb, const char *prefix, int tx) {}
196
197static inline void
Bruno Randolfb47f4072008-03-05 18:35:45 +0900198ath5k_debug_printtxbuf(struct ath5k_softc *sc, struct ath5k_buf *bf) {}
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200199
Luis R. Rodriguezb4461972008-02-04 10:03:54 -0500200#endif /* ifdef CONFIG_ATH5K_DEBUG */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200201
202#endif /* ifndef _ATH5K_DEBUG_H */