1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright (c) 2007 Bruno Randolf <bruno@thinktube.com>
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * This file is free software: you may copy, redistribute and/or modify it
5*4882a593Smuzhiyun * under the terms of the GNU General Public License as published by the
6*4882a593Smuzhiyun * Free Software Foundation, either version 2 of the License, or (at your
7*4882a593Smuzhiyun * option) any later version.
8*4882a593Smuzhiyun *
9*4882a593Smuzhiyun * This file is distributed in the hope that it will be useful, but
10*4882a593Smuzhiyun * WITHOUT ANY WARRANTY; without even the implied warranty of
11*4882a593Smuzhiyun * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12*4882a593Smuzhiyun * General Public License for more details.
13*4882a593Smuzhiyun *
14*4882a593Smuzhiyun * You should have received a copy of the GNU General Public License
15*4882a593Smuzhiyun * along with this program. If not, see <http://www.gnu.org/licenses/>.
16*4882a593Smuzhiyun *
17*4882a593Smuzhiyun *
18*4882a593Smuzhiyun * This file incorporates work covered by the following copyright and
19*4882a593Smuzhiyun * permission notice:
20*4882a593Smuzhiyun *
21*4882a593Smuzhiyun * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
22*4882a593Smuzhiyun * Copyright (c) 2004-2005 Atheros Communications, Inc.
23*4882a593Smuzhiyun * Copyright (c) 2006 Devicescape Software, Inc.
24*4882a593Smuzhiyun * Copyright (c) 2007 Jiri Slaby <jirislaby@gmail.com>
25*4882a593Smuzhiyun * Copyright (c) 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
26*4882a593Smuzhiyun *
27*4882a593Smuzhiyun * All rights reserved.
28*4882a593Smuzhiyun *
29*4882a593Smuzhiyun * Redistribution and use in source and binary forms, with or without
30*4882a593Smuzhiyun * modification, are permitted provided that the following conditions
31*4882a593Smuzhiyun * are met:
32*4882a593Smuzhiyun * 1. Redistributions of source code must retain the above copyright
33*4882a593Smuzhiyun * notice, this list of conditions and the following disclaimer,
34*4882a593Smuzhiyun * without modification.
35*4882a593Smuzhiyun * 2. Redistributions in binary form must reproduce at minimum a disclaimer
36*4882a593Smuzhiyun * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
37*4882a593Smuzhiyun * redistribution must be conditioned upon including a substantially
38*4882a593Smuzhiyun * similar Disclaimer requirement for further binary redistribution.
39*4882a593Smuzhiyun * 3. Neither the names of the above-listed copyright holders nor the names
40*4882a593Smuzhiyun * of any contributors may be used to endorse or promote products derived
41*4882a593Smuzhiyun * from this software without specific prior written permission.
42*4882a593Smuzhiyun *
43*4882a593Smuzhiyun * Alternatively, this software may be distributed under the terms of the
44*4882a593Smuzhiyun * GNU General Public License ("GPL") version 2 as published by the Free
45*4882a593Smuzhiyun * Software Foundation.
46*4882a593Smuzhiyun *
47*4882a593Smuzhiyun * NO WARRANTY
48*4882a593Smuzhiyun * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
49*4882a593Smuzhiyun * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
50*4882a593Smuzhiyun * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
51*4882a593Smuzhiyun * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
52*4882a593Smuzhiyun * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
53*4882a593Smuzhiyun * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
54*4882a593Smuzhiyun * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
55*4882a593Smuzhiyun * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
56*4882a593Smuzhiyun * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
57*4882a593Smuzhiyun * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
58*4882a593Smuzhiyun * THE POSSIBILITY OF SUCH DAMAGES.
59*4882a593Smuzhiyun */
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun #ifndef _ATH5K_DEBUG_H
62*4882a593Smuzhiyun #define _ATH5K_DEBUG_H
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun struct ath5k_hw;
65*4882a593Smuzhiyun struct sk_buff;
66*4882a593Smuzhiyun struct ath5k_buf;
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun struct ath5k_dbg_info {
69*4882a593Smuzhiyun unsigned int level; /* debug level */
70*4882a593Smuzhiyun };
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun /**
73*4882a593Smuzhiyun * enum ath5k_debug_level - ath5k debug level
74*4882a593Smuzhiyun *
75*4882a593Smuzhiyun * @ATH5K_DEBUG_RESET: reset processing
76*4882a593Smuzhiyun * @ATH5K_DEBUG_INTR: interrupt handling
77*4882a593Smuzhiyun * @ATH5K_DEBUG_MODE: mode init/setup
78*4882a593Smuzhiyun * @ATH5K_DEBUG_XMIT: basic xmit operation
79*4882a593Smuzhiyun * @ATH5K_DEBUG_BEACON: beacon handling
80*4882a593Smuzhiyun * @ATH5K_DEBUG_CALIBRATE: periodic calibration
81*4882a593Smuzhiyun * @ATH5K_DEBUG_TXPOWER: transmit power setting
82*4882a593Smuzhiyun * @ATH5K_DEBUG_LED: led management
83*4882a593Smuzhiyun * @ATH5K_DEBUG_DUMP_RX: print received skb content
84*4882a593Smuzhiyun * @ATH5K_DEBUG_DUMP_TX: print transmit skb content
85*4882a593Smuzhiyun * @ATH5K_DEBUG_DUMPBANDS: dump bands
86*4882a593Smuzhiyun * @ATH5K_DEBUG_DMA: debug dma start/stop
87*4882a593Smuzhiyun * @ATH5K_DEBUG_TRACE: trace function calls
88*4882a593Smuzhiyun * @ATH5K_DEBUG_DESC: descriptor setup
89*4882a593Smuzhiyun * @ATH5K_DEBUG_ANY: show at any debug level
90*4882a593Smuzhiyun *
91*4882a593Smuzhiyun * The debug level is used to control the amount and type of debugging output
92*4882a593Smuzhiyun * we want to see. The debug level is given in calls to ATH5K_DBG to specify
93*4882a593Smuzhiyun * where the message should appear, and the user can control the debugging
94*4882a593Smuzhiyun * messages he wants to see, either by the module parameter 'debug' on module
95*4882a593Smuzhiyun * load, or dynamically by using debugfs 'ath5k/phyX/debug'. these levels can
96*4882a593Smuzhiyun * be combined together by bitwise OR.
97*4882a593Smuzhiyun */
98*4882a593Smuzhiyun enum ath5k_debug_level {
99*4882a593Smuzhiyun ATH5K_DEBUG_RESET = 0x00000001,
100*4882a593Smuzhiyun ATH5K_DEBUG_INTR = 0x00000002,
101*4882a593Smuzhiyun ATH5K_DEBUG_MODE = 0x00000004,
102*4882a593Smuzhiyun ATH5K_DEBUG_XMIT = 0x00000008,
103*4882a593Smuzhiyun ATH5K_DEBUG_BEACON = 0x00000010,
104*4882a593Smuzhiyun ATH5K_DEBUG_CALIBRATE = 0x00000020,
105*4882a593Smuzhiyun ATH5K_DEBUG_TXPOWER = 0x00000040,
106*4882a593Smuzhiyun ATH5K_DEBUG_LED = 0x00000080,
107*4882a593Smuzhiyun ATH5K_DEBUG_DUMPBANDS = 0x00000400,
108*4882a593Smuzhiyun ATH5K_DEBUG_DMA = 0x00000800,
109*4882a593Smuzhiyun ATH5K_DEBUG_ANI = 0x00002000,
110*4882a593Smuzhiyun ATH5K_DEBUG_DESC = 0x00004000,
111*4882a593Smuzhiyun ATH5K_DEBUG_ANY = 0xffffffff
112*4882a593Smuzhiyun };
113*4882a593Smuzhiyun
114*4882a593Smuzhiyun #ifdef CONFIG_ATH5K_DEBUG
115*4882a593Smuzhiyun
116*4882a593Smuzhiyun #define ATH5K_DBG(_sc, _m, _fmt, ...) do { \
117*4882a593Smuzhiyun if (unlikely((_sc)->debug.level & (_m) && net_ratelimit())) \
118*4882a593Smuzhiyun ATH5K_PRINTK(_sc, KERN_DEBUG, "(%s:%d): " _fmt, \
119*4882a593Smuzhiyun __func__, __LINE__, ##__VA_ARGS__); \
120*4882a593Smuzhiyun } while (0)
121*4882a593Smuzhiyun
122*4882a593Smuzhiyun #define ATH5K_DBG_UNLIMIT(_sc, _m, _fmt, ...) do { \
123*4882a593Smuzhiyun if (unlikely((_sc)->debug.level & (_m))) \
124*4882a593Smuzhiyun ATH5K_PRINTK(_sc, KERN_DEBUG, "(%s:%d): " _fmt, \
125*4882a593Smuzhiyun __func__, __LINE__, ##__VA_ARGS__); \
126*4882a593Smuzhiyun } while (0)
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun void
129*4882a593Smuzhiyun ath5k_debug_init_device(struct ath5k_hw *ah);
130*4882a593Smuzhiyun
131*4882a593Smuzhiyun void
132*4882a593Smuzhiyun ath5k_debug_printrxbuffs(struct ath5k_hw *ah);
133*4882a593Smuzhiyun
134*4882a593Smuzhiyun void
135*4882a593Smuzhiyun ath5k_debug_dump_bands(struct ath5k_hw *ah);
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun void
138*4882a593Smuzhiyun ath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf);
139*4882a593Smuzhiyun
140*4882a593Smuzhiyun #else /* no debugging */
141*4882a593Smuzhiyun
142*4882a593Smuzhiyun #include <linux/compiler.h>
143*4882a593Smuzhiyun
144*4882a593Smuzhiyun static inline __printf(3, 4) void
ATH5K_DBG(struct ath5k_hw * ah,unsigned int m,const char * fmt,...)145*4882a593Smuzhiyun ATH5K_DBG(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) {}
146*4882a593Smuzhiyun
147*4882a593Smuzhiyun static inline __printf(3, 4) void
ATH5K_DBG_UNLIMIT(struct ath5k_hw * ah,unsigned int m,const char * fmt,...)148*4882a593Smuzhiyun ATH5K_DBG_UNLIMIT(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...)
149*4882a593Smuzhiyun {}
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun static inline void
ath5k_debug_init_device(struct ath5k_hw * ah)152*4882a593Smuzhiyun ath5k_debug_init_device(struct ath5k_hw *ah) {}
153*4882a593Smuzhiyun
154*4882a593Smuzhiyun static inline void
ath5k_debug_printrxbuffs(struct ath5k_hw * ah)155*4882a593Smuzhiyun ath5k_debug_printrxbuffs(struct ath5k_hw *ah) {}
156*4882a593Smuzhiyun
157*4882a593Smuzhiyun static inline void
ath5k_debug_dump_bands(struct ath5k_hw * ah)158*4882a593Smuzhiyun ath5k_debug_dump_bands(struct ath5k_hw *ah) {}
159*4882a593Smuzhiyun
160*4882a593Smuzhiyun static inline void
ath5k_debug_printtxbuf(struct ath5k_hw * ah,struct ath5k_buf * bf)161*4882a593Smuzhiyun ath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf) {}
162*4882a593Smuzhiyun
163*4882a593Smuzhiyun #endif /* ifdef CONFIG_ATH5K_DEBUG */
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun #endif /* ifndef _ATH5K_DEBUG_H */
166