blob: 7c70e230ccd2c612458d5f132c4bca598e907975 [file] [log] [blame]
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -07001/*
2 * Agere Systems Inc.
3 * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
4 *
Alan Cox64f93032009-06-10 17:30:41 +01005 * Copyright © 2005 Agere Systems Inc.
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -07006 * 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 *
Alan Cox64f93032009-06-10 17:30:41 +010024 * Copyright © 2005 Agere Systems Inc.
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -070025 * 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 *
Alan Cox64f93032009-06-10 17:30:41 +010045 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -070046 * 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
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +000085#define DBG_DEFAULTS (DBG_ERROR_ON | DBG_WARNING_ON | DBG_BREAK_ON)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -070086
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +000087#define DBG_FLAGS(A) ((A)->dbgFlags)
88#define DBG_NAME(A) ((A)->dbgName)
89#define DBG_LEVEL(A) ((A)->dbgLevel)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -070090
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
Alan Cox64f93032009-06-10 17:30:41 +0100100#define DBG_TRAP do {} while (0) /* BUG() */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700101#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
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000111#define DBG_ENTER(A) \
112 do { \
113 if (DBG_FLAGS(A) & DBG_TRACE_ON) \
114 _DBG_ENTER(A); \
115 } while (0)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700116
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000117#define DBG_LEAVE(A) \
118 do { \
119 if (DBG_FLAGS(A) & DBG_TRACE_ON) \
120 _DBG_LEAVE(A); \
121 } while (0)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700122
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000123#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)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700128
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000129#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)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700137
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000138#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)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700145
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000146#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)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700153
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000154#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)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700161
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000162#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)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700169
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000170#define DBG_RX(A, S...) \
171 do { \
172 if (DBG_FLAGS(A) & DBG_RX_ON) \
173 DBG_PRINT(S); \
174 } while (0)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700175
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000176#define DBG_RX_ENTER(A) \
177 do { \
178 if (DBG_FLAGS(A) & DBG_RX_ON) \
179 _DBG_ENTER(A); \
180 } while (0)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700181
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000182#define DBG_RX_LEAVE(A) \
183 do { \
184 if (DBG_FLAGS(A) & DBG_RX_ON) \
185 _DBG_LEAVE(A); \
186 } while (0)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700187
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000188#define DBG_TX(A, S...) \
189 do { \
190 if (DBG_FLAGS(A) & DBG_TX_ON) \
191 DBG_PRINT(S); \
192 } while (0)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700193
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000194#define DBG_TX_ENTER(A) \
195 do { \
196 if (DBG_FLAGS(A) & DBG_TX_ON) \
197 _DBG_ENTER(A); \
198 } while (0)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700199
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000200#define DBG_TX_LEAVE(A) \
201 do { \
202 if (DBG_FLAGS(A) & DBG_TX_ON) \
203 _DBG_LEAVE(A); \
204 } while (0)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700205
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000206#define DBG_ASSERT(C) \
207 do { \
208 if (!(C)) { \
J.R. Mauro1352b4b2008-11-13 19:11:22 -0500209 DBG_PRINT("ASSERT(%s) -- %s#%d (%s) ", \
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000210 #C, __FILE__, __LINE__, __func__); \
211 DBG_TRAP; \
J.R. Mauro1352b4b2008-11-13 19:11:22 -0500212 } \
Stoyan Gaydarovbb9eacc2008-07-17 10:29:06 +0000213 } while (0)
214
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700215#define STATIC
216
217typedef 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)
Alan Cox64f93032009-06-10 17:30:41 +0100230#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...)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700237#define DBG_RX_ENTER(A)
238#define DBG_RX_LEAVE(A)
Alan Cox64f93032009-06-10 17:30:41 +0100239#define DBG_TX(A, S...)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700240#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 */
248struct et131x_adapter;
249
250void DumpTxQueueContents(int dbgLvl, struct et131x_adapter *adapter);
251void DumpDeviceBlock(int dbgLvl, struct et131x_adapter *adapter,
252 unsigned int Block);
253void DumpDeviceReg(int dbgLvl, struct et131x_adapter *adapter);
254
255#endif /* __ET131X_DBG_H__ */