V4L/DVB (11204): pvrusb2: Remove old i2c layer; we use v4l2-subdev now
[linux-2.6] / drivers / staging / et131x / et131x_debug.h
1 /*
2  * Agere Systems Inc.
3  * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
4  *
5  * Copyright © 2005 Agere Systems Inc.
6  * All rights reserved.
7  *   http://www.agere.com
8  *
9  *------------------------------------------------------------------------------
10  *
11  * et131x_debug.h - Defines, structs, enums, prototypes, etc. used for
12  *                  outputting debug messages to the system logging facility
13  *                  (ksyslogd)
14  *
15  *------------------------------------------------------------------------------
16  *
17  * SOFTWARE LICENSE
18  *
19  * This software is provided subject to the following terms and conditions,
20  * which you should read carefully before using the software.  Using this
21  * software indicates your acceptance of these terms and conditions.  If you do
22  * not agree with these terms and conditions, do not use the software.
23  *
24  * Copyright © 2005 Agere Systems Inc.
25  * All rights reserved.
26  *
27  * Redistribution and use in source or binary forms, with or without
28  * modifications, are permitted provided that the following conditions are met:
29  *
30  * . Redistributions of source code must retain the above copyright notice, this
31  *    list of conditions and the following Disclaimer as comments in the code as
32  *    well as in the documentation and/or other materials provided with the
33  *    distribution.
34  *
35  * . Redistributions in binary form must reproduce the above copyright notice,
36  *    this list of conditions and the following Disclaimer in the documentation
37  *    and/or other materials provided with the distribution.
38  *
39  * . Neither the name of Agere Systems Inc. nor the names of the contributors
40  *    may be used to endorse or promote products derived from this software
41  *    without specific prior written permission.
42  *
43  * Disclaimer
44  *
45  * THIS SOFTWARE IS PROVIDED \93AS IS\94 AND ANY EXPRESS OR IMPLIED WARRANTIES,
46  * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
47  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  ANY
48  * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
49  * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
50  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
51  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
52  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
53  * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
54  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
55  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
56  * DAMAGE.
57  *
58  */
59
60 #ifndef __ET131X_DBG_H__
61 #define __ET131X_DBG_H__
62
63 /* Define Masks for debugging types/levels */
64 #define DBG_ERROR_ON        0x00000001L
65 #define DBG_WARNING_ON      0x00000002L
66 #define DBG_NOTICE_ON       0x00000004L
67 #define DBG_TRACE_ON        0x00000008L
68 #define DBG_VERBOSE_ON      0x00000010L
69 #define DBG_PARAM_ON        0x00000020L
70 #define DBG_BREAK_ON        0x00000040L
71 #define DBG_RX_ON           0x00000100L
72 #define DBG_TX_ON           0x00000200L
73
74 #ifdef CONFIG_ET131X_DEBUG
75
76 /*
77  * Set the level of debugging if not done with a preprocessor define. See
78  * et131x_main.c, function et131x_init_module() for how the debug level
79  * translates into the types of messages displayed.
80  */
81 #ifndef DBG_LVL
82 #define DBG_LVL 3
83 #endif /* DBG_LVL */
84
85 #define DBG_DEFAULTS            (DBG_ERROR_ON | DBG_WARNING_ON | DBG_BREAK_ON)
86
87 #define DBG_FLAGS(A)            ((A)->dbgFlags)
88 #define DBG_NAME(A)             ((A)->dbgName)
89 #define DBG_LEVEL(A)            ((A)->dbgLevel)
90
91 #ifndef DBG_PRINT
92 #define DBG_PRINT(S...)         printk(KERN_DEBUG S)
93 #endif /* DBG_PRINT */
94
95 #ifndef DBG_PRINTC
96 #define DBG_PRINTC(S...)        printk(S)
97 #endif /* DBG_PRINTC */
98
99 #ifndef DBG_TRAP
100 #define DBG_TRAP                {}      /* BUG() */
101 #endif /* DBG_TRAP */
102
103 #define _ENTER_STR      ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
104 #define _LEAVE_STR      "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
105
106 #define _DBG_ENTER(A)   printk(KERN_DEBUG "%s:%.*s:%s\n", DBG_NAME(A),  \
107                                 ++DBG_LEVEL(A), _ENTER_STR, __func__)
108 #define _DBG_LEAVE(A)   printk(KERN_DEBUG "%s:%.*s:%s\n", DBG_NAME(A),  \
109                                 DBG_LEVEL(A)--, _LEAVE_STR, __func__)
110
111 #define DBG_ENTER(A)                                                    \
112         do {                                                            \
113                 if (DBG_FLAGS(A) & DBG_TRACE_ON)                        \
114                         _DBG_ENTER(A);                                  \
115         } while (0)
116
117 #define DBG_LEAVE(A)                                                    \
118         do {                                                            \
119                 if (DBG_FLAGS(A) & DBG_TRACE_ON)                        \
120                         _DBG_LEAVE(A);                                  \
121         } while (0)
122
123 #define DBG_PARAM(A, N, F, S...)                                        \
124         do {                                                            \
125                 if (DBG_FLAGS(A) & DBG_PARAM_ON)                        \
126                         DBG_PRINT("  %s -- "F" ", N, S);                \
127         } while (0)
128
129 #define DBG_ERROR(A, S...)                                               \
130         do {                                                             \
131                 if (DBG_FLAGS(A) & DBG_ERROR_ON) {                       \
132                         DBG_PRINT("%s:ERROR:%s ", DBG_NAME(A), __func__);\
133                         DBG_PRINTC(S);                                   \
134                         DBG_TRAP;                                        \
135                 }                                                        \
136         } while (0)
137
138 #define DBG_WARNING(A, S...)                                                \
139         do {                                                                \
140                 if (DBG_FLAGS(A) & DBG_WARNING_ON) {                        \
141                         DBG_PRINT("%s:WARNING:%s ", DBG_NAME(A), __func__); \
142                         DBG_PRINTC(S);                                      \
143                 }                                                           \
144         } while (0)
145
146 #define DBG_NOTICE(A, S...)                                                \
147         do {                                                               \
148                 if (DBG_FLAGS(A) & DBG_NOTICE_ON) {                        \
149                         DBG_PRINT("%s:NOTICE:%s ", DBG_NAME(A), __func__); \
150                         DBG_PRINTC(S);                                     \
151                 }                                                          \
152         } while (0)
153
154 #define DBG_TRACE(A, S...)                                                \
155         do {                                                              \
156                 if (DBG_FLAGS(A) & DBG_TRACE_ON) {                        \
157                         DBG_PRINT("%s:TRACE:%s ", DBG_NAME(A), __func__); \
158                         DBG_PRINTC(S);                                    \
159                 }                                                         \
160         } while (0)
161
162 #define DBG_VERBOSE(A, S...)                                                \
163         do {                                                                \
164                 if (DBG_FLAGS(A) & DBG_VERBOSE_ON) {                        \
165                         DBG_PRINT("%s:VERBOSE:%s ", DBG_NAME(A), __func__); \
166                         DBG_PRINTC(S);                                      \
167                 }                                                           \
168         } while (0)
169
170 #define DBG_RX(A, S...)                         \
171         do {                                    \
172                 if (DBG_FLAGS(A) & DBG_RX_ON)   \
173                         DBG_PRINT(S);           \
174         } while (0)
175
176 #define DBG_RX_ENTER(A)                         \
177         do {                                    \
178                 if (DBG_FLAGS(A) & DBG_RX_ON)   \
179                         _DBG_ENTER(A);          \
180         } while (0)
181
182 #define DBG_RX_LEAVE(A)                         \
183         do {                                    \
184                 if (DBG_FLAGS(A) & DBG_RX_ON)   \
185                         _DBG_LEAVE(A);          \
186         } while (0)
187
188 #define DBG_TX(A, S...)                         \
189         do {                                    \
190                 if (DBG_FLAGS(A) & DBG_TX_ON)   \
191                         DBG_PRINT(S);           \
192         } while (0)
193
194 #define DBG_TX_ENTER(A)                         \
195         do {                                    \
196                 if (DBG_FLAGS(A) & DBG_TX_ON)   \
197                         _DBG_ENTER(A);          \
198         } while (0)
199
200 #define DBG_TX_LEAVE(A)                         \
201         do {                                    \
202                 if (DBG_FLAGS(A) & DBG_TX_ON)   \
203                         _DBG_LEAVE(A);          \
204         } while (0)
205
206 #define DBG_ASSERT(C)                                           \
207         do {                                                    \
208                 if (!(C)) {                                     \
209                         DBG_PRINT("ASSERT(%s) -- %s#%d (%s) ",  \
210                              #C, __FILE__, __LINE__, __func__); \
211                         DBG_TRAP;                               \
212                 }                                               \
213         } while (0)
214
215 #define STATIC
216
217 typedef struct {
218         char *dbgName;
219         int dbgLevel;
220         unsigned long dbgFlags;
221 } dbg_info_t;
222
223 #else /* CONFIG_ET131X_DEBUG */
224
225 #define DBG_DEFN
226 #define DBG_TRAP
227 #define DBG_PRINT(S...)
228 #define DBG_ENTER(A)
229 #define DBG_LEAVE(A)
230 #define DBG_PARAM(A,N,F,S...)
231 #define DBG_ERROR(A,S...)
232 #define DBG_WARNING(A,S...)
233 #define DBG_NOTICE(A,S...)
234 #define DBG_TRACE(A,S...)
235 #define DBG_VERBOSE(A,S...)
236 #define DBG_RX(A,S...)
237 #define DBG_RX_ENTER(A)
238 #define DBG_RX_LEAVE(A)
239 #define DBG_TX(A,S...)
240 #define DBG_TX_ENTER(A)
241 #define DBG_TX_LEAVE(A)
242 #define DBG_ASSERT(C)
243 #define STATIC static
244
245 #endif /* CONFIG_ET131X_DEBUG */
246
247 /* Forward declaration of the private adapter structure */
248 struct et131x_adapter;
249
250 void DumpTxQueueContents(int dbgLvl, struct et131x_adapter *adapter);
251 void DumpDeviceBlock(int dbgLvl, struct et131x_adapter *adapter,
252                      unsigned int Block);
253 void DumpDeviceReg(int dbgLvl, struct et131x_adapter *adapter);
254
255 #endif /* __ET131X_DBG_H__ */