108057504Sxy150489 /* 208057504Sxy150489 * This file is provided under a CDDLv1 license. When using or 308057504Sxy150489 * redistributing this file, you may do so under this license. 408057504Sxy150489 * In redistributing this file this license must be included 508057504Sxy150489 * and no other modification of this header file is permitted. 608057504Sxy150489 * 708057504Sxy150489 * CDDL LICENSE SUMMARY 808057504Sxy150489 * 9*592a4d85Scc210113 * Copyright(c) 1999 - 2008 Intel Corporation. All rights reserved. 1008057504Sxy150489 * 1108057504Sxy150489 * The contents of this file are subject to the terms of Version 1208057504Sxy150489 * 1.0 of the Common Development and Distribution License (the "License"). 1308057504Sxy150489 * 1408057504Sxy150489 * You should have received a copy of the License with this software. 1508057504Sxy150489 * You can obtain a copy of the License at 1608057504Sxy150489 * http://www.opensolaris.org/os/licensing. 1708057504Sxy150489 * See the License for the specific language governing permissions 1808057504Sxy150489 * and limitations under the License. 1908057504Sxy150489 */ 2008057504Sxy150489 2108057504Sxy150489 /* 22*592a4d85Scc210113 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 2308057504Sxy150489 * Use is subject to license terms of the CDDLv1. 2408057504Sxy150489 */ 2508057504Sxy150489 2608057504Sxy150489 #ifndef _E1000G_DEBUG_H 2708057504Sxy150489 #define _E1000G_DEBUG_H 2808057504Sxy150489 2908057504Sxy150489 #pragma ident "%Z%%M% %I% %E% SMI" 3008057504Sxy150489 3108057504Sxy150489 #ifdef __cplusplus 3208057504Sxy150489 extern "C" { 3308057504Sxy150489 #endif 3408057504Sxy150489 3508057504Sxy150489 /* 3608057504Sxy150489 * Debug message control 3708057504Sxy150489 * Debug Levels: 3808057504Sxy150489 * 0x000 - (0) no messages 3908057504Sxy150489 * 0x001 - (1) Errors 4008057504Sxy150489 * 0x002 - (2) Warnings 4108057504Sxy150489 * 0x004 - (4) Information 4208057504Sxy150489 * 0x008 - (8) Subroutine calls and control flow 4308057504Sxy150489 * 0x010 - (16) I/O Data (verbose!) 4408057504Sxy150489 * Variables can be set with entries in the /etc/system file with 4508057504Sxy150489 * "set e1000g:e1000g_debug=<value>" 4625f2d433Sxy150489 * "set e1000g:e1000g_log_mode=<value>" 4708057504Sxy150489 * The /etc/system file is read only once at boot time, if you change 4808057504Sxy150489 * it you must reboot for the change to take effect. 4908057504Sxy150489 * 5008057504Sxy150489 * It turns on diagnostics if DEBUG is defined (DEBUG also 5108057504Sxy150489 * enables other debugging code as ASSERT statements... 5208057504Sxy150489 */ 5308057504Sxy150489 54*592a4d85Scc210113 #include <sys/types.h> 55*592a4d85Scc210113 5625f2d433Sxy150489 #ifdef DEBUG 5725f2d433Sxy150489 #define E1000G_DEBUG 5825f2d433Sxy150489 #endif 5908057504Sxy150489 6025f2d433Sxy150489 /* 6125f2d433Sxy150489 * By default it will print only to log 6225f2d433Sxy150489 */ 6325f2d433Sxy150489 #define E1000G_LOG_DISPLAY 0x1 6425f2d433Sxy150489 #define E1000G_LOG_PRINT 0x2 6525f2d433Sxy150489 #define E1000G_LOG_ALL 0x3 6608057504Sxy150489 6725f2d433Sxy150489 #ifdef E1000G_DEBUG 6808057504Sxy150489 6925f2d433Sxy150489 #define E1000G_ERRS_LEVEL 0x001 /* (1) Errors */ 7025f2d433Sxy150489 #define E1000G_WARN_LEVEL 0x002 /* (2) Warnings */ 7125f2d433Sxy150489 #define E1000G_INFO_LEVEL 0x004 /* (4) Information */ 7225f2d433Sxy150489 #define E1000G_TRACE_LEVEL 0x008 /* (8) Subroutine calls */ 7325f2d433Sxy150489 #define E1000G_VERBOSE_LEVEL 0x010 /* (16) I/O Data (verbose!) */ 7425f2d433Sxy150489 7525f2d433Sxy150489 #define E1000G_DEBUGLOG_0(Adapter, Level, fmt) \ 7608057504Sxy150489 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt)) 7708057504Sxy150489 7825f2d433Sxy150489 #define E1000G_DEBUGLOG_1(Adapter, Level, fmt, d1) \ 7908057504Sxy150489 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1)) 8008057504Sxy150489 8125f2d433Sxy150489 #define E1000G_DEBUGLOG_2(Adapter, Level, fmt, d1, d2) \ 8208057504Sxy150489 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1), (d2)) 8308057504Sxy150489 8425f2d433Sxy150489 #define E1000G_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3) \ 8508057504Sxy150489 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\ 8608057504Sxy150489 (d2), (d3)) 8708057504Sxy150489 8825f2d433Sxy150489 #define E1000G_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4) \ 8908057504Sxy150489 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\ 9008057504Sxy150489 (d2), (d3), (d4)) 9108057504Sxy150489 9225f2d433Sxy150489 #define E1000G_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5) \ 9308057504Sxy150489 if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\ 9408057504Sxy150489 (d2), (d3), (d4), (d5)) 9508057504Sxy150489 9625f2d433Sxy150489 #define E1000G_DEBUG_STAT_COND(val, cond) if (cond) (val)++; 9725f2d433Sxy150489 #define E1000G_DEBUG_STAT(val) (val)++; 9808057504Sxy150489 9908057504Sxy150489 #else 10008057504Sxy150489 10125f2d433Sxy150489 #define E1000G_DEBUGLOG_0(Adapter, Level, fmt) 10225f2d433Sxy150489 #define E1000G_DEBUGLOG_1(Adapter, Level, fmt, d1) 10325f2d433Sxy150489 #define E1000G_DEBUGLOG_2(Adapter, Level, fmt, d1, d2) 10425f2d433Sxy150489 #define E1000G_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3) 10525f2d433Sxy150489 #define E1000G_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4) 10625f2d433Sxy150489 #define E1000G_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5) 10708057504Sxy150489 10825f2d433Sxy150489 #define E1000G_DEBUG_STAT_COND(val, cond) 10925f2d433Sxy150489 #define E1000G_DEBUG_STAT(val) 11008057504Sxy150489 11125f2d433Sxy150489 #endif /* E1000G_DEBUG */ 11208057504Sxy150489 11308057504Sxy150489 #define NAMELEN 31 11408057504Sxy150489 #define BUFSZ 256 11508057504Sxy150489 11625f2d433Sxy150489 #define E1000G_STAT(val) (val)++; 11708057504Sxy150489 1184914a7d0Syy150190 void e1000g_log(void *, int, char *, ...); 1194914a7d0Syy150190 1204914a7d0Syy150190 #ifdef E1000G_DEBUG 1214914a7d0Syy150190 void eeprom_dump(void *); 1224914a7d0Syy150190 void phy_dump(void *); 1234914a7d0Syy150190 void mac_dump(void *); 1244914a7d0Syy150190 void pciconfig_dump(void *); 125*592a4d85Scc210113 void pciconfig_bar(void *, uint32_t, char *); 1264914a7d0Syy150190 #endif 12725f2d433Sxy150489 12825f2d433Sxy150489 #ifdef E1000G_DEBUG 12925f2d433Sxy150489 extern int e1000g_debug; 13025f2d433Sxy150489 #endif 13125f2d433Sxy150489 extern int e1000g_log_mode; 1327941757cSxy150489 13308057504Sxy150489 #ifdef __cplusplus 13408057504Sxy150489 } 13508057504Sxy150489 #endif 13608057504Sxy150489 13708057504Sxy150489 #endif /* _E1000G_DEBUG_H */ 138