13526Sxy150489 /* 23526Sxy150489 * This file is provided under a CDDLv1 license. When using or 33526Sxy150489 * redistributing this file, you may do so under this license. 43526Sxy150489 * In redistributing this file this license must be included 53526Sxy150489 * and no other modification of this header file is permitted. 63526Sxy150489 * 73526Sxy150489 * CDDL LICENSE SUMMARY 83526Sxy150489 * 9*6735Scc210113 * Copyright(c) 1999 - 2008 Intel Corporation. All rights reserved. 103526Sxy150489 * 113526Sxy150489 * The contents of this file are subject to the terms of Version 123526Sxy150489 * 1.0 of the Common Development and Distribution License (the "License"). 133526Sxy150489 * 143526Sxy150489 * You should have received a copy of the License with this software. 153526Sxy150489 * You can obtain a copy of the License at 163526Sxy150489 * http://www.opensolaris.org/os/licensing. 173526Sxy150489 * See the License for the specific language governing permissions 183526Sxy150489 * and limitations under the License. 193526Sxy150489 */ 203526Sxy150489 213526Sxy150489 /* 22*6735Scc210113 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 233526Sxy150489 * Use is subject to license terms of the CDDLv1. 243526Sxy150489 */ 253526Sxy150489 263526Sxy150489 #ifndef _E1000G_DEBUG_H 273526Sxy150489 #define _E1000G_DEBUG_H 283526Sxy150489 293526Sxy150489 #pragma ident "%Z%%M% %I% %E% SMI" 303526Sxy150489 313526Sxy150489 #ifdef __cplusplus 323526Sxy150489 extern "C" { 333526Sxy150489 #endif 343526Sxy150489 353526Sxy150489 /* 363526Sxy150489 * Debug message control 373526Sxy150489 * Debug Levels: 383526Sxy150489 * 0x000 - (0) no messages 393526Sxy150489 * 0x001 - (1) Errors 403526Sxy150489 * 0x002 - (2) Warnings 413526Sxy150489 * 0x004 - (4) Information 423526Sxy150489 * 0x008 - (8) Subroutine calls and control flow 433526Sxy150489 * 0x010 - (16) I/O Data (verbose!) 443526Sxy150489 * Variables can be set with entries in the /etc/system file with 454919Sxy150489 * "set e1000g:e1000g_debug=<value>" 464919Sxy150489 * "set e1000g:e1000g_log_mode=<value>" 473526Sxy150489 * The /etc/system file is read only once at boot time, if you change 483526Sxy150489 * it you must reboot for the change to take effect. 493526Sxy150489 * 503526Sxy150489 * It turns on diagnostics if DEBUG is defined (DEBUG also 513526Sxy150489 * enables other debugging code as ASSERT statements... 523526Sxy150489 */ 533526Sxy150489 54*6735Scc210113 #include <sys/types.h> 55*6735Scc210113 564919Sxy150489 #ifdef DEBUG 574919Sxy150489 #define E1000G_DEBUG 584919Sxy150489 #endif 593526Sxy150489 604919Sxy150489 /* 614919Sxy150489 * By default it will print only to log 624919Sxy150489 */ 634919Sxy150489 #define E1000G_LOG_DISPLAY 0x1 644919Sxy150489 #define E1000G_LOG_PRINT 0x2 654919Sxy150489 #define E1000G_LOG_ALL 0x3 663526Sxy150489 674919Sxy150489 #ifdef E1000G_DEBUG 684919Sxy150489 694919Sxy150489 #define E1000G_ERRS_LEVEL 0x001 /* (1) Errors */ 704919Sxy150489 #define E1000G_WARN_LEVEL 0x002 /* (2) Warnings */ 714919Sxy150489 #define E1000G_INFO_LEVEL 0x004 /* (4) Information */ 724919Sxy150489 #define E1000G_TRACE_LEVEL 0x008 /* (8) Subroutine calls */ 734919Sxy150489 #define E1000G_VERBOSE_LEVEL 0x010 /* (16) I/O Data (verbose!) */ 744919Sxy150489 754919Sxy150489 #define E1000G_DEBUGLOG_0(Adapter, Level, fmt) \ 763526Sxy150489 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt)) 773526Sxy150489 784919Sxy150489 #define E1000G_DEBUGLOG_1(Adapter, Level, fmt, d1) \ 793526Sxy150489 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1)) 803526Sxy150489 814919Sxy150489 #define E1000G_DEBUGLOG_2(Adapter, Level, fmt, d1, d2) \ 823526Sxy150489 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1), (d2)) 833526Sxy150489 844919Sxy150489 #define E1000G_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3) \ 853526Sxy150489 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\ 863526Sxy150489 (d2), (d3)) 873526Sxy150489 884919Sxy150489 #define E1000G_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4) \ 893526Sxy150489 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\ 903526Sxy150489 (d2), (d3), (d4)) 913526Sxy150489 924919Sxy150489 #define E1000G_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5) \ 933526Sxy150489 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\ 943526Sxy150489 (d2), (d3), (d4), (d5)) 953526Sxy150489 964919Sxy150489 #define E1000G_DEBUG_STAT_COND(val, cond) if (cond) (val)++; 974919Sxy150489 #define E1000G_DEBUG_STAT(val) (val)++; 983526Sxy150489 993526Sxy150489 #else 1003526Sxy150489 1014919Sxy150489 #define E1000G_DEBUGLOG_0(Adapter, Level, fmt) 1024919Sxy150489 #define E1000G_DEBUGLOG_1(Adapter, Level, fmt, d1) 1034919Sxy150489 #define E1000G_DEBUGLOG_2(Adapter, Level, fmt, d1, d2) 1044919Sxy150489 #define E1000G_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3) 1054919Sxy150489 #define E1000G_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4) 1064919Sxy150489 #define E1000G_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5) 1073526Sxy150489 1084919Sxy150489 #define E1000G_DEBUG_STAT_COND(val, cond) 1094919Sxy150489 #define E1000G_DEBUG_STAT(val) 1103526Sxy150489 1114919Sxy150489 #endif /* E1000G_DEBUG */ 1123526Sxy150489 1133526Sxy150489 #define NAMELEN 31 1143526Sxy150489 #define BUFSZ 256 1153526Sxy150489 1164919Sxy150489 #define E1000G_STAT(val) (val)++; 1174919Sxy150489 1185082Syy150190 void e1000g_log(void *, int, char *, ...); 1195082Syy150190 1205082Syy150190 #ifdef E1000G_DEBUG 1215082Syy150190 void eeprom_dump(void *); 1225082Syy150190 void phy_dump(void *); 1235082Syy150190 void mac_dump(void *); 1245082Syy150190 void pciconfig_dump(void *); 125*6735Scc210113 void pciconfig_bar(void *, uint32_t, char *); 1265082Syy150190 #endif 1273526Sxy150489 1284919Sxy150489 #ifdef E1000G_DEBUG 1294919Sxy150489 extern int e1000g_debug; 1304919Sxy150489 #endif 1314919Sxy150489 extern int e1000g_log_mode; 1324061Sxy150489 1333526Sxy150489 #ifdef __cplusplus 1343526Sxy150489 } 1353526Sxy150489 #endif 1363526Sxy150489 1373526Sxy150489 #endif /* _E1000G_DEBUG_H */ 138