1 /* 2 * This file is provided under a CDDLv1 license. When using or 3 * redistributing this file, you may do so under this license. 4 * In redistributing this file this license must be included 5 * and no other modification of this header file is permitted. 6 * 7 * CDDL LICENSE SUMMARY 8 * 9 * Copyright(c) 1999 - 2008 Intel Corporation. All rights reserved. 10 * 11 * The contents of this file are subject to the terms of Version 12 * 1.0 of the Common Development and Distribution License (the "License"). 13 * 14 * You should have received a copy of the License with this software. 15 * You can obtain a copy of the License at 16 * http://www.opensolaris.org/os/licensing. 17 * See the License for the specific language governing permissions 18 * and limitations under the License. 19 */ 20 21 /* 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms of the CDDLv1. 24 */ 25 26 #ifndef _E1000G_DEBUG_H 27 #define _E1000G_DEBUG_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 /* 34 * Debug message control 35 * Debug Levels: 36 * 0x000 - (0) no messages 37 * 0x001 - (1) Errors 38 * 0x002 - (2) Warnings 39 * 0x004 - (4) Information 40 * 0x008 - (8) Subroutine calls and control flow 41 * 0x010 - (16) I/O Data (verbose!) 42 * Variables can be set with entries in the /etc/system file with 43 * "set e1000g:e1000g_debug=<value>" 44 * "set e1000g:e1000g_log_mode=<value>" 45 * The /etc/system file is read only once at boot time, if you change 46 * it you must reboot for the change to take effect. 47 * 48 * It turns on diagnostics if DEBUG is defined (DEBUG also 49 * enables other debugging code as ASSERT statements... 50 */ 51 52 #include <sys/types.h> 53 54 #ifdef DEBUG 55 #define E1000G_DEBUG 56 #endif 57 58 /* 59 * By default it will print only to log 60 */ 61 #define E1000G_LOG_DISPLAY 0x1 62 #define E1000G_LOG_PRINT 0x2 63 #define E1000G_LOG_ALL 0x3 64 65 #ifdef E1000G_DEBUG 66 67 #define E1000G_ERRS_LEVEL 0x001 /* (1) Errors */ 68 #define E1000G_WARN_LEVEL 0x002 /* (2) Warnings */ 69 #define E1000G_INFO_LEVEL 0x004 /* (4) Information */ 70 #define E1000G_TRACE_LEVEL 0x008 /* (8) Subroutine calls */ 71 #define E1000G_VERBOSE_LEVEL 0x010 /* (16) I/O Data (verbose!) */ 72 73 #define E1000G_DEBUGLOG_0(Adapter, Level, fmt) \ 74 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt)) 75 76 #define E1000G_DEBUGLOG_1(Adapter, Level, fmt, d1) \ 77 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1)) 78 79 #define E1000G_DEBUGLOG_2(Adapter, Level, fmt, d1, d2) \ 80 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1), (d2)) 81 82 #define E1000G_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3) \ 83 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\ 84 (d2), (d3)) 85 86 #define E1000G_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4) \ 87 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\ 88 (d2), (d3), (d4)) 89 90 #define E1000G_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5) \ 91 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\ 92 (d2), (d3), (d4), (d5)) 93 94 #define E1000G_DEBUG_STAT_COND(val, cond) if (cond) (val)++; 95 #define E1000G_DEBUG_STAT(val) (val)++; 96 97 #else 98 99 #define E1000G_DEBUGLOG_0(Adapter, Level, fmt) 100 #define E1000G_DEBUGLOG_1(Adapter, Level, fmt, d1) 101 #define E1000G_DEBUGLOG_2(Adapter, Level, fmt, d1, d2) 102 #define E1000G_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3) 103 #define E1000G_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4) 104 #define E1000G_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5) 105 106 #define E1000G_DEBUG_STAT_COND(val, cond) 107 #define E1000G_DEBUG_STAT(val) 108 109 #endif /* E1000G_DEBUG */ 110 111 #define NAMELEN 31 112 #define BUFSZ 256 113 114 #define E1000G_STAT(val) (val)++; 115 116 void e1000g_log(void *, int, char *, ...); 117 118 #ifdef E1000G_DEBUG 119 void eeprom_dump(void *); 120 void phy_dump(void *); 121 void mac_dump(void *); 122 void pciconfig_dump(void *); 123 void pciconfig_bar(void *, uint32_t, char *); 124 #endif 125 126 #ifdef E1000G_DEBUG 127 extern int e1000g_debug; 128 #endif 129 extern int e1000g_log_mode; 130 131 #ifdef __cplusplus 132 } 133 #endif 134 135 #endif /* _E1000G_DEBUG_H */ 136