]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/staging/et131x/et131x_debug.h
Staging: add et131x network driver
[linux-2.6-omap-h63xx.git] / 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)        {if (DBG_FLAGS(A) & DBG_TRACE_ON) \
112                                 _DBG_ENTER(A);}
113
114 #define DBG_LEAVE(A)        {if (DBG_FLAGS(A) & DBG_TRACE_ON) \
115                                 _DBG_LEAVE(A);}
116
117 #define DBG_PARAM(A,N,F,S...)   {if (DBG_FLAGS(A) & DBG_PARAM_ON) \
118                                     DBG_PRINT("  %s -- "F"\n",N,S);}
119
120 #define DBG_ERROR(A,S...)       \
121         if (DBG_FLAGS(A) & DBG_ERROR_ON) {                              \
122                 DBG_PRINT("%s:ERROR:%s ",DBG_NAME(A), __func__);        \
123                 DBG_PRINTC(S);                                          \
124                 DBG_TRAP;                                               \
125         }
126
127 #define DBG_WARNING(A,S...) {if (DBG_FLAGS(A) & DBG_WARNING_ON) \
128                                 {DBG_PRINT("%s:WARNING:%s ",DBG_NAME(A),__func__);DBG_PRINTC(S);}}
129
130 #define DBG_NOTICE(A,S...)  {if (DBG_FLAGS(A) & DBG_NOTICE_ON) \
131                                 {DBG_PRINT("%s:NOTICE:%s ",DBG_NAME(A),__func__);DBG_PRINTC(S);}}
132
133 #define DBG_TRACE(A,S...)   {if (DBG_FLAGS(A) & DBG_TRACE_ON) \
134                                 {DBG_PRINT("%s:TRACE:%s ",DBG_NAME(A), __func__);DBG_PRINTC(S);}}
135
136 #define DBG_VERBOSE(A,S...) {if (DBG_FLAGS(A) & DBG_VERBOSE_ON) \
137                                 {DBG_PRINT("%s:VERBOSE:%s ",DBG_NAME(A), __func__);DBG_PRINTC(S);}}
138
139 #define DBG_RX(A,S...)      {if (DBG_FLAGS(A) & DBG_RX_ON) \
140                                 {DBG_PRINT(S);}}
141
142 #define DBG_RX_ENTER(A)     {if (DBG_FLAGS(A) & DBG_RX_ON) \
143                                 _DBG_ENTER(A);}
144
145 #define DBG_RX_LEAVE(A)     {if (DBG_FLAGS(A) & DBG_RX_ON) \
146                                 _DBG_LEAVE(A);}
147
148 #define DBG_TX(A,S...)      {if (DBG_FLAGS(A) & DBG_TX_ON) \
149                                 {DBG_PRINT(S);}}
150
151 #define DBG_TX_ENTER(A)     {if (DBG_FLAGS(A) & DBG_TX_ON) \
152                                 _DBG_ENTER(A);}
153
154 #define DBG_TX_LEAVE(A)     {if (DBG_FLAGS(A) & DBG_TX_ON) \
155                                 _DBG_LEAVE(A);}
156
157 #define DBG_ASSERT(C)       {if (!(C)) \
158                                 {DBG_PRINT("ASSERT(%s) -- %s#%d (%s)\n", \
159                                     #C,__FILE__,__LINE__,__func__); \
160                                 DBG_TRAP;}}
161 #define STATIC
162
163 typedef struct {
164         char *dbgName;
165         int dbgLevel;
166         unsigned long dbgFlags;
167 } dbg_info_t;
168
169 #else /* CONFIG_ET131X_DEBUG */
170
171 #define DBG_DEFN
172 #define DBG_TRAP
173 #define DBG_PRINT(S...)
174 #define DBG_ENTER(A)
175 #define DBG_LEAVE(A)
176 #define DBG_PARAM(A,N,F,S...)
177 #define DBG_ERROR(A,S...)
178 #define DBG_WARNING(A,S...)
179 #define DBG_NOTICE(A,S...)
180 #define DBG_TRACE(A,S...)
181 #define DBG_VERBOSE(A,S...)
182 #define DBG_RX(A,S...)
183 #define DBG_RX_ENTER(A)
184 #define DBG_RX_LEAVE(A)
185 #define DBG_TX(A,S...)
186 #define DBG_TX_ENTER(A)
187 #define DBG_TX_LEAVE(A)
188 #define DBG_ASSERT(C)
189 #define STATIC static
190
191 #endif /* CONFIG_ET131X_DEBUG */
192
193 /* Forward declaration of the private adapter structure */
194 struct et131x_adapter;
195
196 void DumpTxQueueContents(int dbgLvl, struct et131x_adapter *adapter);
197 void DumpDeviceBlock(int dbgLvl, struct et131x_adapter *adapter,
198                      unsigned int Block);
199 void DumpDeviceReg(int dbgLvl, struct et131x_adapter *adapter);
200
201 #endif /* __ET131X_DBG_H__ */