Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Agere Systems Inc. |
| 3 | * Wireless device driver for Linux (wlags49). |
| 4 | * |
| 5 | * Copyright (c) 1998-2003 Agere Systems Inc. |
| 6 | * All rights reserved. |
| 7 | * http://www.agere.com |
| 8 | * |
| 9 | * Initially developed by TriplePoint, Inc. |
| 10 | * http://www.triplepoint.com |
| 11 | * |
| 12 | *------------------------------------------------------------------------------ |
| 13 | * |
| 14 | * This file contains definitions and macros for debugging. |
| 15 | * |
| 16 | *------------------------------------------------------------------------------ |
| 17 | * |
| 18 | * SOFTWARE LICENSE |
| 19 | * |
| 20 | * This software is provided subject to the following terms and conditions, |
| 21 | * which you should read carefully before using the software. Using this |
| 22 | * software indicates your acceptance of these terms and conditions. If you do |
| 23 | * not agree with these terms and conditions, do not use the software. |
| 24 | * |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 25 | * Copyright (c) 2003 Agere Systems Inc. |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 26 | * All rights reserved. |
| 27 | * |
| 28 | * Redistribution and use in source or binary forms, with or without |
| 29 | * modifications, are permitted provided that the following conditions are met: |
| 30 | * |
| 31 | * . Redistributions of source code must retain the above copyright notice, this |
| 32 | * list of conditions and the following Disclaimer as comments in the code as |
| 33 | * well as in the documentation and/or other materials provided with the |
| 34 | * distribution. |
| 35 | * |
| 36 | * . Redistributions in binary form must reproduce the above copyright notice, |
| 37 | * this list of conditions and the following Disclaimer in the documentation |
| 38 | * and/or other materials provided with the distribution. |
| 39 | * |
| 40 | * . Neither the name of Agere Systems Inc. nor the names of the contributors |
| 41 | * may be used to endorse or promote products derived from this software |
| 42 | * without specific prior written permission. |
| 43 | * |
| 44 | * Disclaimer |
| 45 | * |
Al Viro | d36b691 | 2011-12-29 17:09:01 -0500 | [diff] [blame] | 46 | * THIS SOFTWARE IS PROVIDED AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 47 | * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF |
| 48 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY |
| 49 | * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN |
| 50 | * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY |
| 51 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 52 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 53 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 54 | * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT |
| 55 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 56 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 57 | * DAMAGE. |
| 58 | * |
| 59 | ******************************************************************************/ |
| 60 | |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 61 | #ifndef _DEBUG_H |
| 62 | #define _DEBUG_H |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | /* Turn on debugging here if not done with a preprocessor define */ |
| 68 | #ifndef DBG |
| 69 | #define DBG 0 |
| 70 | #else |
| 71 | #undef DBG |
| 72 | #define DBG 1 |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 73 | #endif /* DBG */ |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | #if DBG |
| 79 | /****************************************************************************/ |
| 80 | |
| 81 | /* Set the level of debugging if not done with a preprocessor define. See |
| 82 | wl_main.c, init_module() for how the debug level translates into the |
| 83 | the types of messages displayed */ |
| 84 | #ifndef DBG_LVL |
| 85 | #define DBG_LVL 5 /* yields nothing via init_module, |
| 86 | original value of 5 yields DBG_TRACE_ON and DBG_VERBOSE_ON */ |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 87 | #endif /* DBG_LVL*/ |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 88 | |
| 89 | |
| 90 | #define DBG_ERROR_ON 0x00000001L |
| 91 | #define DBG_WARNING_ON 0x00000002L |
| 92 | #define DBG_NOTICE_ON 0x00000004L |
| 93 | #define DBG_TRACE_ON 0x00000008L |
| 94 | #define DBG_VERBOSE_ON 0x00000010L |
| 95 | #define DBG_PARAM_ON 0x00000020L |
| 96 | #define DBG_BREAK_ON 0x00000040L |
| 97 | #define DBG_RX_ON 0x00000100L |
| 98 | #define DBG_TX_ON 0x00000200L |
| 99 | #define DBG_DS_ON 0x00000400L |
| 100 | |
| 101 | #define DBG_DEFAULTS (DBG_ERROR_ON | DBG_WARNING_ON | DBG_BREAK_ON) |
| 102 | |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 103 | #define DBG_FLAGS(A) ((A)->DebugFlag) |
| 104 | #define DBG_NAME(A) ((A)->dbgName) |
| 105 | #define DBG_LEVEL(A) ((A)->dbgLevel) |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 106 | |
| 107 | |
| 108 | #ifndef PRINTK |
| 109 | # define PRINTK(S...) printk(S) |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 110 | #endif /* PRINTK */ |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 111 | |
| 112 | |
| 113 | #ifndef DBG_PRINT |
| 114 | # define DBG_PRINT(S...) PRINTK(KERN_DEBUG S) |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 115 | #endif /* DBG_PRINT */ |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 116 | |
| 117 | |
| 118 | #ifndef DBG_PRINTC |
| 119 | # define DBG_PRINTC(S...) PRINTK(S) |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 120 | #endif /* DBG_PRINTC */ |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 121 | |
| 122 | |
| 123 | #ifndef DBG_TRAP |
| 124 | # define DBG_TRAP {} |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 125 | #endif /* DBG_TRAP */ |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 126 | |
| 127 | |
| 128 | #define _ENTER_STR ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" |
| 129 | #define _LEAVE_STR "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" |
| 130 | |
| 131 | |
David Kilroy | 8bf9053 | 2011-10-01 09:43:48 +0100 | [diff] [blame] | 132 | #define _DBG_ENTER(A) \ |
| 133 | DBG_PRINT("%s:%.*s:%s\n", DBG_NAME(A), ++DBG_LEVEL(A), \ |
| 134 | _ENTER_STR, __func__) |
| 135 | #define _DBG_LEAVE(A) \ |
| 136 | DBG_PRINT("%s:%.*s:%s\n", DBG_NAME(A), DBG_LEVEL(A)--, \ |
| 137 | _LEAVE_STR, __func__) |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 138 | |
| 139 | |
David Kilroy | 8bf9053 | 2011-10-01 09:43:48 +0100 | [diff] [blame] | 140 | #define DBG_FUNC(F) |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 141 | |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 142 | #define DBG_ENTER(A) {if (DBG_FLAGS(A) & DBG_TRACE_ON) \ |
| 143 | _DBG_ENTER(A); } |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 144 | |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 145 | #define DBG_LEAVE(A) {if (DBG_FLAGS(A) & DBG_TRACE_ON) \ |
| 146 | _DBG_LEAVE(A); } |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 147 | |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 148 | #define DBG_PARAM(A, N, F, S...) {if (DBG_FLAGS(A) & DBG_PARAM_ON) \ |
| 149 | DBG_PRINT(" %s -- "F"\n", N, S); } |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 150 | |
| 151 | |
David Kilroy | 8bf9053 | 2011-10-01 09:43:48 +0100 | [diff] [blame] | 152 | #define DBG_ERROR(A, S...) do { \ |
| 153 | if (DBG_FLAGS(A) & DBG_ERROR_ON) { \ |
| 154 | DBG_PRINT("%s:ERROR:%s ", DBG_NAME(A), __func__); \ |
| 155 | DBG_PRINTC(S); \ |
| 156 | DBG_TRAP; \ |
| 157 | } } while (0) |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 158 | |
| 159 | |
David Kilroy | 8bf9053 | 2011-10-01 09:43:48 +0100 | [diff] [blame] | 160 | #define DBG_WARNING(A, S...) do { \ |
| 161 | if (DBG_FLAGS(A) & DBG_WARNING_ON) { \ |
| 162 | DBG_PRINT("%s:WARNING:%s ", DBG_NAME(A), __func__); \ |
| 163 | DBG_PRINTC(S); \ |
| 164 | } } while (0) |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 165 | |
| 166 | |
David Kilroy | 8bf9053 | 2011-10-01 09:43:48 +0100 | [diff] [blame] | 167 | #define DBG_NOTICE(A, S...) do { \ |
| 168 | if (DBG_FLAGS(A) & DBG_NOTICE_ON) { \ |
| 169 | DBG_PRINT("%s:NOTICE:%s ", DBG_NAME(A), __func__); \ |
| 170 | DBG_PRINTC(S); \ |
| 171 | } } while (0) |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 172 | |
| 173 | |
David Kilroy | 8bf9053 | 2011-10-01 09:43:48 +0100 | [diff] [blame] | 174 | #define DBG_TRACE(A, S...) do { \ |
| 175 | if (DBG_FLAGS(A) & DBG_TRACE_ON) { \ |
| 176 | DBG_PRINT("%s:%s ", DBG_NAME(A), __func__); \ |
| 177 | DBG_PRINTC(S); \ |
| 178 | } } while (0) |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 179 | |
| 180 | |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 181 | #define DBG_RX(A, S...) {if (DBG_FLAGS(A) & DBG_RX_ON) {\ |
| 182 | DBG_PRINT(S); } } |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 183 | |
| 184 | |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 185 | #define DBG_TX(A, S...) {if (DBG_FLAGS(A) & DBG_TX_ON) {\ |
| 186 | DBG_PRINT(S); } } |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 187 | |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 188 | #define DBG_DS(A, S...) {if (DBG_FLAGS(A) & DBG_DS_ON) {\ |
| 189 | DBG_PRINT(S); } } |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 190 | |
| 191 | |
David Kilroy | 8bf9053 | 2011-10-01 09:43:48 +0100 | [diff] [blame] | 192 | #define DBG_ASSERT(C) do { \ |
| 193 | if (!(C)) { \ |
| 194 | DBG_PRINT("ASSERT(%s) -- %s#%d (%s)\n", \ |
| 195 | #C, __FILE__, __LINE__, __func__); \ |
| 196 | DBG_TRAP; \ |
| 197 | } } while (0) |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 198 | |
| 199 | typedef struct { |
| 200 | char *dbgName; |
| 201 | int dbgLevel; |
| 202 | unsigned long DebugFlag; |
| 203 | } dbg_info_t; |
| 204 | |
| 205 | |
| 206 | /****************************************************************************/ |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 207 | #else /* DBG */ |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 208 | /****************************************************************************/ |
| 209 | |
| 210 | #define DBG_DEFN |
| 211 | #define DBG_TRAP |
| 212 | #define DBG_FUNC(F) |
| 213 | #define DBG_PRINT(S...) |
| 214 | #define DBG_ENTER(A) |
| 215 | #define DBG_LEAVE(A) |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 216 | #define DBG_PARAM(A, N, F, S...) |
| 217 | #define DBG_ERROR(A, S...) |
| 218 | #define DBG_WARNING(A, S...) |
| 219 | #define DBG_NOTICE(A, S...) |
| 220 | #define DBG_TRACE(A, S...) |
| 221 | #define DBG_RX(A, S...) |
| 222 | #define DBG_TX(A, S...) |
| 223 | #define DBG_DS(A, S...) |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 224 | #define DBG_ASSERT(C) |
| 225 | |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 226 | #endif /* DBG */ |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 227 | /****************************************************************************/ |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
Ruslan Pisarev | b93634c | 2010-03-15 22:46:24 +0200 | [diff] [blame] | 232 | #endif /* _DEBUG_H */ |
Henk de Groot | 68c0bdf | 2009-09-27 11:12:52 +0200 | [diff] [blame] | 233 | |