4
* Dynamic (runtime) debug framework implementation.
9
#include <linux/string.h>
13
//--------------------------------------------------------------------------------
16
* Define valid TYPE (or category or code-path, however you like to think of it)
18
* Type and SubType are treated as bitmasks.
20
/*-----------------BEGIN TYPEs------------------------------------------*/
21
#define DBG_TYPE_INITEXIT (1 << 0) // 1
22
#define DBG_TYPE_TX (1 << 1) // 2
23
#define DBG_TYPE_RX (1 << 2) // 4
24
#define DBG_TYPE_OTHERS (1 << 3) // 8
25
/*-----------------END TYPEs------------------------------------------*/
26
#define NUMTYPES 4 // careful!
28
/*-----------------BEGIN SUBTYPEs---------------------------------------*/
30
/*-SUBTYPEs for TX : TYPE is DBG_TYPE_TX -----//
31
Transmit.c ,Arp.c, LeakyBucket.c, And Qos.c
35
#define MP_SEND (TX<<0)
36
#define NEXT_SEND (TX<<1)
37
#define TX_FIFO (TX<<2)
38
#define TX_CONTROL (TX<<3)
41
#define IP_ADDR (TX<<4)
42
#define ARP_REQ (TX<<5)
43
#define ARP_RESP (TX<<6)
47
//#define DHCP_REQ (DHCP<<7)
50
#define TOKEN_COUNTS (TX<<8)
51
#define CHECK_TOKENS (TX<<9)
52
#define TX_PACKETS (TX<<10)
53
#define TIMER (TX<<11)
57
#define QUEUE_INDEX (QOS<<12)
58
#define IPV4_DBG (QOS<<13)
59
#define IPV6_DBG (QOS<<14)
60
#define PRUNE_QUEUE (QOS<<15)
61
#define SEND_QUEUE (QOS<<16)
64
#define TX_OSAL_DBG (TX<<17)
67
//--SUBTYPEs for ------INIT & EXIT---------------------
68
/*------------ TYPE is DBG_TYPE_INITEXIT -----//
69
DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c */
71
#define DRV_ENTRY (MP<<0)
72
#define MP_INIT (MP<<1)
73
#define READ_REG (MP<<3)
74
#define DISPATCH (MP<<2)
75
#define CLAIM_ADAP (MP<<4)
76
#define REG_IO_PORT (MP<<5)
77
#define INIT_DISP (MP<<6)
78
#define RX_INIT (MP<<7)
81
//-SUBTYPEs for --RX----------------------------------
82
//------------RX : TYPE is DBG_TYPE_RX -----//
85
#define RX_DPC (RX<<0)
86
#define RX_CTRL (RX<<3)
87
#define RX_DATA (RX<<4)
88
#define MP_RETURN (RX<<1)
89
#define LINK_MSG (RX<<2)
92
//-SUBTYPEs for ----OTHER ROUTINES------------------
93
//------------OTHERS : TYPE is DBG_TYPE_OTHER -----//
94
// HaltnReset,CheckForHang,PnP,Misc,CmHost
100
#define MP_DPC (ISR<<0)
104
#define MP_HALT (HALT<<1)
105
#define CHECK_HANG (HALT<<2)
106
#define MP_RESET (HALT<<3)
107
#define MP_SHUTDOWN (HALT<<4)
111
#define MP_PNP (PNP<<5)
115
#define DUMP_INFO (MISC<<6)
116
#define CLASSIFY (MISC<<7)
117
#define LINK_UP_MSG (MISC<<8)
118
#define CP_CTRL_PKT (MISC<<9)
119
#define DUMP_CONTROL (MISC<<10)
120
#define LED_DUMP_INFO (MISC<<11)
123
#define CMHOST OTHERS
126
#define SERIAL (OTHERS<<12)
127
#define IDLE_MODE (OTHERS<<13)
129
#define WRM (OTHERS<<14)
130
#define RDM (OTHERS<<15)
132
// TODO - put PHS_SEND in Tx PHS_RECEIVE in Rx path ?
133
#define PHS_SEND (OTHERS<<16)
134
#define PHS_RECEIVE (OTHERS<<17)
135
#define PHS_MODULE (OTHERS<<18)
137
#define INTF_INIT (OTHERS<<19)
138
#define INTF_ERR (OTHERS<<20)
139
#define INTF_WARN (OTHERS<<21)
140
#define INTF_NORM (OTHERS<<22)
142
#define IRP_COMPLETION (OTHERS<<23)
143
#define SF_DESCRIPTOR_CNTS (OTHERS<<24)
144
#define PHS_DISPATCH (OTHERS << 25)
145
#define OSAL_DBG (OTHERS << 26)
146
#define NVM_RW (OTHERS << 27)
148
#define HOST_MIBS (OTHERS << 28)
149
#define CONN_MSG (CMHOST << 29)
150
//#define OTHERS_MISC (OTHERS << 29) // ProcSupport.c
151
/*-----------------END SUBTYPEs------------------------------------------*/
155
* We have 8 debug levels, in (numerical) increasing order of verbosity.
156
* IMP: Currently implementing ONLY DBG_LVL_ALL , i.e. , all debug prints will
157
* appear (of course, iff global debug flag is ON and we match the Type and SubType).
158
* Finer granularity debug levels are currently not in use, although the feature exists.
160
* Another way to say this:
161
* All the debug prints currently have 'debug_level' set to DBG_LVL_ALL .
162
* You can compile-time change that to any of the below, if you wish to. However, as of now, there's
163
* no dynamic facility to have the userspace 'TestApp' set debug_level. Slated for future expansion.
172
/* Not meant for developer in debug prints.
173
* To be used to disable all prints by setting the DBG_LVL_CURR to this value */
176
/* The current driver logging level.
177
* Everything at this level and (numerically) lower (meaning higher prio)
179
* Replace 'BCM_ALL' in the DBG_LVL_CURR macro with the logging level desired.
180
* For eg. to set the logging level to 'errors only' use:
181
* #define DBG_LVL_CURR (BCM_ERR)
184
#define DBG_LVL_CURR (BCM_ALL)
185
#define DBG_LVL_ALL BCM_ALL
187
/*---Userspace mapping of Debug State.
188
* Delibrately matches that of the Windows driver..
189
* The TestApp's ioctl passes this struct to us.
193
unsigned int Subtype, Type;
195
// unsigned int debug_level; /* future expansion */
196
} __attribute__((packed)) USER_BCM_DBG_STATE;
198
//---Kernel-space mapping of Debug State
199
typedef struct _S_BCM_DEBUG_STATE {
201
/* A bitmap of 32 bits for Subtype per Type.
202
* Valid indexes in 'subtype' array are *only* 1,2,4 and 8,
203
* corresponding to valid Type values. Hence we use the 'Type' field
204
* as the index value, ignoring the array entries 0,3,5,6,7 !
206
UINT subtype[(NUMTYPES*2)+1];
209
/* Instantiated in the Adapter structure */
210
/* We'll reuse the debug level parameter to include a bit (the MSB) to indicate whether or not
211
* we want the function's name printed. */
212
#define DBG_NO_FUNC_PRINT 1 << 31
213
#define DBG_LVL_BITMASK 0xFF
215
//--- Only for direct printk's; "hidden" to API.
216
#define DBG_TYPE_PRINTK 3
218
#define BCM_DEBUG_PRINT(Adapter, Type, SubType, dbg_level, string, args...) \
220
if (DBG_TYPE_PRINTK == Type) \
221
pr_info("%s:" string, __func__, ##args); \
222
else if (Adapter && \
223
(dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \
224
(Type & Adapter->stDebugState.type) && \
225
(SubType & Adapter->stDebugState.subtype[Type])) { \
226
if (dbg_level & DBG_NO_FUNC_PRINT) \
227
printk(KERN_DEBUG string, ##args); \
229
printk(KERN_DEBUG "%s:" string, __func__, ##args); \
233
#define BCM_DEBUG_PRINT_BUFFER(Adapter, Type, SubType, dbg_level, buffer, bufferlen) do { \
234
if (DBG_TYPE_PRINTK == Type || \
236
(dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level && \
237
(Type & Adapter->stDebugState.type) && \
238
(SubType & Adapter->stDebugState.subtype[Type]))) { \
239
printk(KERN_DEBUG "%s:\n", __func__); \
240
print_hex_dump(KERN_DEBUG, " ", DUMP_PREFIX_OFFSET, \
241
16, 1, buffer, bufferlen, false); \
246
#define BCM_SHOW_DEBUG_BITMAP(Adapter) do { \
248
for (i=0; i<(NUMTYPES*2)+1; i++) { \
249
if ((i == 1) || (i == 2) || (i == 4) || (i == 8)) { \
250
/* CAUTION! Forcefully turn on ALL debug paths and subpaths! \
251
Adapter->stDebugState.subtype[i] = 0xffffffff; */ \
252
BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "subtype[%d] = 0x%08x\n", \
253
i, Adapter->stDebugState.subtype[i]); \