at v2.6.37-rc2 297 lines 8.8 kB view raw
1/* 2 * Debug.h 3 * 4 * Dynamic (runtime) debug framework implementation. 5 * -kaiwan. 6 */ 7#ifndef _DEBUG_H 8#define _DEBUG_H 9#include <linux/string.h> 10#define NONE 0xFFFF 11 12typedef enum _BASE_TYPE 13{ 14 BCM_BASE_TYPE_DEC, 15 BCM_BASE_TYPE_OCT, 16 BCM_BASE_TYPE_BIN, 17 BCM_BASE_TYPE_HEX, 18 BCM_BASE_TYPE_NONE, 19} BASE_TYPE, *PBASE_TYPE; 20 21int bcm_print_buffer( UINT debug_level, const char *function_name, 22 char *file_name, int line_number, unsigned char *buffer, int bufferlen, BASE_TYPE base); 23 24#ifdef BCM_SHM_INTERFACE 25#define CPE_VIRTUAL_ERROR_CODE_BASE_ADDR (0xBFC02E00 + 0x4C) 26// ERROR codes for debugging 27extern unsigned char u32ErrorCounter ; 28#define ERROR_DEVICE_REMOVED 0x1 29#define ERROR_LEADER_LENGTH_ZERO 0x2 30#define ERROR_LEADER_LENGTH_CORRUPTED 0x3 31#define ERROR_NO_SKBUFF 0x4 32 33#define ERROR_DL_MODULE 0xaa000000 34extern void CPE_ERROR_LOG(unsigned int module,unsigned int code); 35 36#endif 37 38 39 40 41//-------------------------------------------------------------------------------- 42 43/* TYPE and SUBTYPE 44 * Define valid TYPE (or category or code-path, however you like to think of it) 45 * and SUBTYPE s. 46 * Type and SubType are treated as bitmasks. 47 */ 48/*-----------------BEGIN TYPEs------------------------------------------*/ 49#define DBG_TYPE_INITEXIT (1 << 0) // 1 50#define DBG_TYPE_TX (1 << 1) // 2 51#define DBG_TYPE_RX (1 << 2) // 4 52#define DBG_TYPE_OTHERS (1 << 3) // 8 53/*-----------------END TYPEs------------------------------------------*/ 54#define NUMTYPES 4 // careful! 55 56/*-----------------BEGIN SUBTYPEs---------------------------------------*/ 57 58/*-SUBTYPEs for TX : TYPE is DBG_TYPE_TX -----// 59 Transmit.c ,Arp.c, LeakyBucket.c, And Qos.c 60 total 17 macros */ 61// Transmit.c 62#define TX 1 63#define MP_SEND (TX<<0) 64#define NEXT_SEND (TX<<1) 65#define TX_FIFO (TX<<2) 66#define TX_CONTROL (TX<<3) 67 68// Arp.c 69#define IP_ADDR (TX<<4) 70#define ARP_REQ (TX<<5) 71#define ARP_RESP (TX<<6) 72 73// dhcp.c 74//#define DHCP TX 75//#define DHCP_REQ (DHCP<<7) 76 77// Leakybucket.c 78#define TOKEN_COUNTS (TX<<8) 79#define CHECK_TOKENS (TX<<9) 80#define TX_PACKETS (TX<<10) 81#define TIMER (TX<<11) 82 83// Qos.c 84#define QOS TX 85#define QUEUE_INDEX (QOS<<12) 86#define IPV4_DBG (QOS<<13) 87#define IPV6_DBG (QOS<<14) 88#define PRUNE_QUEUE (QOS<<15) 89#define SEND_QUEUE (QOS<<16) 90 91//TX_Misc 92#define TX_OSAL_DBG (TX<<17) 93 94 95//--SUBTYPEs for ------INIT & EXIT--------------------- 96/*------------ TYPE is DBG_TYPE_INITEXIT -----// 97DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c */ 98#define MP 1 99#define DRV_ENTRY (MP<<0) 100#define MP_INIT (MP<<1) 101#define READ_REG (MP<<3) 102#define DISPATCH (MP<<2) 103#define CLAIM_ADAP (MP<<4) 104#define REG_IO_PORT (MP<<5) 105#define INIT_DISP (MP<<6) 106#define RX_INIT (MP<<7) 107 108 109//-SUBTYPEs for --RX---------------------------------- 110//------------RX : TYPE is DBG_TYPE_RX -----// 111// Receive.c 112#define RX 1 113#define RX_DPC (RX<<0) 114#define RX_CTRL (RX<<3) 115#define RX_DATA (RX<<4) 116#define MP_RETURN (RX<<1) 117#define LINK_MSG (RX<<2) 118 119 120//-SUBTYPEs for ----OTHER ROUTINES------------------ 121//------------OTHERS : TYPE is DBG_TYPE_OTHER -----// 122// HaltnReset,CheckForHang,PnP,Misc,CmHost 123// total 12 macros 124#define OTHERS 1 125// ??ISR.C 126 127#define ISR OTHERS 128#define MP_DPC (ISR<<0) 129 130// HaltnReset.c 131#define HALT OTHERS 132#define MP_HALT (HALT<<1) 133#define CHECK_HANG (HALT<<2) 134#define MP_RESET (HALT<<3) 135#define MP_SHUTDOWN (HALT<<4) 136 137// pnp.c 138#define PNP OTHERS 139#define MP_PNP (PNP<<5) 140 141// Misc.c 142#define MISC OTHERS 143#define DUMP_INFO (MISC<<6) 144#define CLASSIFY (MISC<<7) 145#define LINK_UP_MSG (MISC<<8) 146#define CP_CTRL_PKT (MISC<<9) 147#define DUMP_CONTROL (MISC<<10) 148#define LED_DUMP_INFO (MISC<<11) 149 150// CmHost.c 151#define CMHOST OTHERS 152 153 154#define SERIAL (OTHERS<<12) 155#define IDLE_MODE (OTHERS<<13) 156 157#define WRM (OTHERS<<14) 158#define RDM (OTHERS<<15) 159 160// TODO - put PHS_SEND in Tx PHS_RECEIVE in Rx path ? 161#define PHS_SEND (OTHERS<<16) 162#define PHS_RECIEVE (OTHERS<<17) 163#define PHS_MODULE (OTHERS<<18) 164 165#define INTF_INIT (OTHERS<<19) 166#define INTF_ERR (OTHERS<<20) 167#define INTF_WARN (OTHERS<<21) 168#define INTF_NORM (OTHERS<<22) 169 170#define IRP_COMPLETION (OTHERS<<23) 171#define SF_DESCRIPTOR_CNTS (OTHERS<<24) 172#define PHS_DISPATCH (OTHERS << 25) 173#define OSAL_DBG (OTHERS << 26) 174#define NVM_RW (OTHERS << 27) 175 176#define HOST_MIBS (OTHERS << 28) 177#define CONN_MSG (CMHOST << 29) 178//#define OTHERS_MISC (OTHERS << 29) // ProcSupport.c 179/*-----------------END SUBTYPEs------------------------------------------*/ 180 181 182/* Debug level 183 * We have 8 debug levels, in (numerical) increasing order of verbosity. 184 * IMP: Currently implementing ONLY DBG_LVL_ALL , i.e. , all debug prints will 185 * appear (of course, iff global debug flag is ON and we match the Type and SubType). 186 * Finer granularity debug levels are currently not in use, although the feature exists. 187 * 188 * Another way to say this: 189 * All the debug prints currently have 'debug_level' set to DBG_LVL_ALL . 190 * You can compile-time change that to any of the below, if you wish to. However, as of now, there's 191 * no dynamic facility to have the userspace 'TestApp' set debug_level. Slated for future expansion. 192 */ 193#define BCM_ALL 7 194#define BCM_LOW 6 195#define BCM_PRINT 5 196#define BCM_NORMAL 4 197#define BCM_MEDIUM 3 198#define BCM_SCREAM 2 199#define BCM_ERR 1 200/* Not meant for developer in debug prints. 201 * To be used to disable all prints by setting the DBG_LVL_CURR to this value */ 202#define BCM_NONE 0 203 204/* The current driver logging level. 205 * Everything at this level and (numerically) lower (meaning higher prio) 206 * is logged. 207* Replace 'BCM_ALL' in the DBG_LVL_CURR macro with the logging level desired. 208 * For eg. to set the logging level to 'errors only' use: 209 * #define DBG_LVL_CURR (BCM_ERR) 210 */ 211 212#define DBG_LVL_CURR (BCM_ALL) 213#define DBG_LVL_ALL BCM_ALL 214 215/*---Userspace mapping of Debug State. 216 * Delibrately matches that of the Windows driver.. 217 * The TestApp's ioctl passes this struct to us. 218 */ 219typedef struct 220{ 221 unsigned int Subtype, Type; 222 unsigned int OnOff; 223// unsigned int debug_level; /* future expansion */ 224} __attribute__((packed)) USER_BCM_DBG_STATE; 225 226//---Kernel-space mapping of Debug State 227typedef struct _S_BCM_DEBUG_STATE { 228 UINT type; 229 /* A bitmap of 32 bits for Subtype per Type. 230 * Valid indexes in 'subtype' array are *only* 1,2,4 and 8, 231 * corresponding to valid Type values. Hence we use the 'Type' field 232 * as the index value, ignoring the array entries 0,3,5,6,7 ! 233 */ 234 UINT subtype[(NUMTYPES*2)+1]; 235 UINT debug_level; 236} S_BCM_DEBUG_STATE; 237/* Instantiated in the Adapter structure */ 238/* We'll reuse the debug level parameter to include a bit (the MSB) to indicate whether or not 239 * we want the function's name printed. */ 240#define DBG_NO_FUNC_PRINT 1 << 31 241#define DBG_LVL_BITMASK 0xFF 242 243//--- Only for direct printk's; "hidden" to API. 244#define DBG_TYPE_PRINTK 3 245#define PRINTKS_ON 1 // "hidden" from API, set to 0 to turn off all printk's 246 247#define BCM_DEBUG_PRINT(Adapter, Type, SubType, dbg_level, string, args...) do { \ 248 if ((DBG_TYPE_PRINTK == Type) && (PRINTKS_ON)) { \ 249 printk ("%s:" string, __FUNCTION__, ##args); \ 250 printk("\n"); \ 251 } else if (!Adapter) \ 252 ; \ 253 else { \ 254 if (((dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level) && \ 255 ((Type & Adapter->stDebugState.type) && (SubType & Adapter->stDebugState.subtype[Type]))) { \ 256 if (dbg_level & DBG_NO_FUNC_PRINT) \ 257 printk (string, ##args); \ 258 else \ 259 { \ 260 printk ("%s:" string, __FUNCTION__, ##args); \ 261 printk("\n"); \ 262 } \ 263 } \ 264 } \ 265} while (0) 266 267#define BCM_DEBUG_PRINT_BUFFER(Adapter, Type, SubType, dbg_level, buffer, bufferlen) do { \ 268 if ((DBG_TYPE_PRINTK == Type) && (PRINTKS_ON)) { \ 269 bcm_print_buffer( dbg_level, __FUNCTION__, __FILE__, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \ 270 } else if (!Adapter) \ 271 ; \ 272 else { \ 273 if (((dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level) && \ 274 ((Type & Adapter->stDebugState.type) && (SubType & Adapter->stDebugState.subtype[Type]))) { \ 275 if (dbg_level & DBG_NO_FUNC_PRINT) \ 276 bcm_print_buffer( dbg_level, NULL, NULL, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \ 277 else \ 278 bcm_print_buffer( dbg_level, __FUNCTION__, __FILE__, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \ 279 } \ 280 } \ 281 } while (0) 282 283 284#define BCM_SHOW_DEBUG_BITMAP(Adapter) do { \ 285 int i; \ 286 for (i=0; i<(NUMTYPES*2)+1; i++) { \ 287 if ((i == 1) || (i == 2) || (i == 4) || (i == 8)) { \ 288 /* CAUTION! Forcefully turn on ALL debug paths and subpaths! \ 289 Adapter->stDebugState.subtype[i] = 0xffffffff; */ \ 290 BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "subtype[%d] = 0x%08x\n", \ 291 i, Adapter->stDebugState.subtype[i]); \ 292 } \ 293 } \ 294} while (0) 295 296#endif 297