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 * 96735Scc210113 * 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 /* 226735Scc210113 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 233526Sxy150489 * Use is subject to license terms of the CDDLv1. 243526Sxy150489 */ 253526Sxy150489 263526Sxy150489 #pragma ident "%Z%%M% %I% %E% SMI" 273526Sxy150489 283526Sxy150489 /* 293526Sxy150489 * ********************************************************************** 303526Sxy150489 * * 313526Sxy150489 * Module Name: * 324919Sxy150489 * e1000g_debug.c * 333526Sxy150489 * * 343526Sxy150489 * Abstract: * 354919Sxy150489 * This module includes the debug routines * 363526Sxy150489 * * 373526Sxy150489 * ********************************************************************** 383526Sxy150489 */ 393526Sxy150489 #ifdef GCC 403526Sxy150489 #ifdef __STDC__ 413526Sxy150489 #include <stdarg.h> 423526Sxy150489 #else 433526Sxy150489 #include <varargs.h> 443526Sxy150489 #endif 453526Sxy150489 #define _SYS_VARARGS_H 463526Sxy150489 #endif 473526Sxy150489 484919Sxy150489 #include "e1000g_debug.h" 493526Sxy150489 #include "e1000g_sw.h" 505082Syy150190 #ifdef E1000G_DEBUG 515082Syy150190 #include <sys/pcie.h> 525082Syy150190 #endif 534919Sxy150489 544919Sxy150489 #ifdef E1000G_DEBUG 555082Syy150190 #define WPL 8 /* 8 16-bit words per line */ 566735Scc210113 #define NUM_REGS 155 /* must match the array initializer */ 575082Syy150190 typedef struct { 585082Syy150190 char name[10]; 595082Syy150190 uint32_t offset; 605082Syy150190 } Regi_t; 614919Sxy150489 int e1000g_debug = E1000G_WARN_LEVEL; 624919Sxy150489 #endif 634919Sxy150489 int e1000g_log_mode = E1000G_LOG_PRINT; 643526Sxy150489 653526Sxy150489 void 664919Sxy150489 e1000g_log(void *instance, int level, char *fmt, ...) 673526Sxy150489 { 684919Sxy150489 struct e1000g *Adapter = (struct e1000g *)instance; 693526Sxy150489 auto char name[NAMELEN]; 703526Sxy150489 auto char buf[BUFSZ]; 713526Sxy150489 va_list ap; 723526Sxy150489 734919Sxy150489 switch (level) { 744919Sxy150489 #ifdef E1000G_DEBUG 754919Sxy150489 case E1000G_VERBOSE_LEVEL: /* 16 or 0x010 */ 764919Sxy150489 if (e1000g_debug < E1000G_VERBOSE_LEVEL) 774919Sxy150489 return; 784919Sxy150489 level = CE_CONT; 794919Sxy150489 break; 804919Sxy150489 814919Sxy150489 case E1000G_TRACE_LEVEL: /* 8 or 0x008 */ 824919Sxy150489 if (e1000g_debug < E1000G_TRACE_LEVEL) 834919Sxy150489 return; 844919Sxy150489 level = CE_CONT; 854919Sxy150489 break; 864919Sxy150489 874919Sxy150489 case E1000G_INFO_LEVEL: /* 4 or 0x004 */ 884919Sxy150489 if (e1000g_debug < E1000G_INFO_LEVEL) 894919Sxy150489 return; 904919Sxy150489 level = CE_CONT; 914919Sxy150489 break; 924919Sxy150489 934919Sxy150489 case E1000G_WARN_LEVEL: /* 2 or 0x002 */ 944919Sxy150489 if (e1000g_debug < E1000G_WARN_LEVEL) 954919Sxy150489 return; 964919Sxy150489 level = CE_CONT; 974919Sxy150489 break; 984919Sxy150489 994919Sxy150489 case E1000G_ERRS_LEVEL: /* 1 or 0x001 */ 1004919Sxy150489 level = CE_CONT; 1014919Sxy150489 break; 1024919Sxy150489 #else 1034919Sxy150489 case CE_CONT: 1044919Sxy150489 case CE_NOTE: 1054919Sxy150489 case CE_WARN: 1064919Sxy150489 case CE_PANIC: 1074919Sxy150489 break; 1084919Sxy150489 #endif 1094919Sxy150489 default: 1104919Sxy150489 level = CE_CONT; 1114919Sxy150489 break; 1124919Sxy150489 } 1134919Sxy150489 1143526Sxy150489 if (Adapter != NULL) { 1153526Sxy150489 (void) sprintf(name, "%s - e1000g[%d] ", 1163526Sxy150489 ddi_get_name(Adapter->dip), ddi_get_instance(Adapter->dip)); 1173526Sxy150489 } else { 1183526Sxy150489 (void) sprintf(name, "e1000g"); 1193526Sxy150489 } 1203526Sxy150489 /* 1213526Sxy150489 * va_start uses built in macro __builtin_va_alist from the 1223526Sxy150489 * compiler libs which requires compiler system to have 1233526Sxy150489 * __BUILTIN_VA_ARG_INCR defined. 1243526Sxy150489 */ 1253526Sxy150489 /* 1263526Sxy150489 * Many compilation systems depend upon the use of special functions 1273526Sxy150489 * built into the the compilation system to handle variable argument 1283526Sxy150489 * lists and stack allocations. The method to obtain this in SunOS 1293526Sxy150489 * is to define the feature test macro "__BUILTIN_VA_ARG_INCR" which 1303526Sxy150489 * enables the following special built-in functions: 1313526Sxy150489 * __builtin_alloca 1323526Sxy150489 * __builtin_va_alist 1333526Sxy150489 * __builtin_va_arg_incr 1343526Sxy150489 * It is intended that the compilation system define this feature test 1353526Sxy150489 * macro, not the user of the system. 1363526Sxy150489 * 1373526Sxy150489 * The tests on the processor type are to provide a transitional period 1383526Sxy150489 * for existing compilation systems, and may be removed in a future 1393526Sxy150489 * release. 1403526Sxy150489 */ 1413526Sxy150489 /* 1423526Sxy150489 * Using GNU gcc compiler it doesn't expand to va_start.... 1433526Sxy150489 */ 1443526Sxy150489 va_start(ap, fmt); 1453526Sxy150489 (void) vsprintf(buf, fmt, ap); 1463526Sxy150489 va_end(ap); 1473526Sxy150489 1484919Sxy150489 if ((e1000g_log_mode & E1000G_LOG_ALL) == E1000G_LOG_ALL) 1493526Sxy150489 cmn_err(level, "%s: %s", name, buf); 1504919Sxy150489 else if (e1000g_log_mode & E1000G_LOG_DISPLAY) 1514919Sxy150489 cmn_err(level, "^%s: %s", name, buf); 1524919Sxy150489 else if (e1000g_log_mode & E1000G_LOG_PRINT) 1534919Sxy150489 cmn_err(level, "!%s: %s", name, buf); 1544919Sxy150489 else /* if they are not set properly then do both */ 1554919Sxy150489 cmn_err(level, "%s: %s", name, buf); 1563526Sxy150489 } 1575082Syy150190 1585082Syy150190 1595082Syy150190 1605082Syy150190 #ifdef E1000G_DEBUG 161*7133Scc210113 extern kmutex_t e1000g_nvm_lock; 162*7133Scc210113 1635082Syy150190 void 1645082Syy150190 eeprom_dump(void *instance) 1655082Syy150190 { 1665082Syy150190 struct e1000g *Adapter = (struct e1000g *)instance; 1675082Syy150190 struct e1000_hw *hw = &Adapter->shared; 1685082Syy150190 uint16_t eeprom[WPL], size_field; 1695082Syy150190 int i, ret, sign, size, lines, offset = 0; 1705082Syy150190 int ee_size[] = 1715082Syy150190 {128, 256, 512, 1024, 2048, 4096, 16 * 1024, 32 * 1024, 64 * 1024}; 1725082Syy150190 173*7133Scc210113 mutex_enter(&e1000g_nvm_lock); 174*7133Scc210113 1755082Syy150190 if (ret = e1000_read_nvm(hw, 0x12, 1, &size_field)) { 1765082Syy150190 e1000g_log(Adapter, CE_WARN, 1775082Syy150190 "e1000_read_nvm failed to read size: %d", ret); 178*7133Scc210113 goto eeprom_dump_end; 1795082Syy150190 } 1805082Syy150190 1815082Syy150190 sign = (size_field & 0xc000) >> 14; 1825082Syy150190 if (sign != 1) { 1835082Syy150190 e1000g_log(Adapter, CE_WARN, 1845082Syy150190 "eeprom_dump invalid signature: %d", sign); 1855082Syy150190 } 1865082Syy150190 1875082Syy150190 size = (size_field & 0x3c00) >> 10; 1885082Syy150190 if (size < 0 || size > 11) { 1895082Syy150190 e1000g_log(Adapter, CE_WARN, 1905082Syy150190 "eeprom_dump invalid size: %d", size); 1915082Syy150190 } 1925082Syy150190 1935082Syy150190 e1000g_log(Adapter, CE_CONT, 1945082Syy150190 "eeprom_dump size field: %d eeprom bytes: %d\n", 1955082Syy150190 size, ee_size[size]); 1965082Syy150190 1975082Syy150190 e1000g_log(Adapter, CE_CONT, 1985082Syy150190 "e1000_read_nvm hebs: %d\n", ((size_field & 0x000f) >> 10)); 1995082Syy150190 2005082Syy150190 lines = ee_size[size] / WPL / 2; 2015082Syy150190 e1000g_log(Adapter, CE_CONT, 2025082Syy150190 "dump eeprom %d lines of %d words per line\n", lines, WPL); 2035082Syy150190 2045082Syy150190 for (i = 0; i < lines; i++) { 2055082Syy150190 if (ret = e1000_read_nvm(hw, offset, WPL, eeprom)) { 2065082Syy150190 e1000g_log(Adapter, CE_WARN, 2075082Syy150190 "e1000_read_nvm failed: %d", ret); 208*7133Scc210113 goto eeprom_dump_end; 2095082Syy150190 } 2105082Syy150190 2115082Syy150190 e1000g_log(Adapter, CE_CONT, 2125082Syy150190 "0x%04x %04x %04x %04x %04x %04x %04x %04x %04x\n", 2135082Syy150190 offset, 2145082Syy150190 eeprom[0], eeprom[1], eeprom[2], eeprom[3], 2155082Syy150190 eeprom[4], eeprom[5], eeprom[6], eeprom[7]); 2165082Syy150190 offset += WPL; 2175082Syy150190 } 218*7133Scc210113 219*7133Scc210113 eeprom_dump_end: 220*7133Scc210113 mutex_exit(&e1000g_nvm_lock); 2215082Syy150190 } 2225082Syy150190 2235082Syy150190 /* 2245082Syy150190 * phy_dump - dump important phy registers 2255082Syy150190 */ 2265082Syy150190 void 2275082Syy150190 phy_dump(void *instance) 2285082Syy150190 { 2295082Syy150190 struct e1000g *Adapter = (struct e1000g *)instance; 2305082Syy150190 struct e1000_hw *hw = &Adapter->shared; 2315082Syy150190 /* offset to each phy register */ 2325082Syy150190 int32_t offset[] = 2335082Syy150190 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 2345082Syy150190 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 2355082Syy150190 30, 31, 0x1796, 0x187A, 0x1895, 0x1F30, 0x1F35, 0x1F3E, 0x1F54, 2365082Syy150190 0x1F55, 0x1F56, 0x1F72, 0x1F76, 0x1F77, 0x1F78, 0x1F79, 0x1F98, 2375082Syy150190 0x2010, 0x2011, 0x20DC, 0x20DD, 0x20DE, 0x28B4, 0x2F52, 0x2F5B, 2385082Syy150190 0x2F70, 0x2F90, 0x2FB1, 0x2FB2 }; 2395082Syy150190 uint16_t value; /* register value */ 2405082Syy150190 uint32_t stat; /* status from e1000_read_phy_reg */ 2415082Syy150190 int i; 2425082Syy150190 2435082Syy150190 e1000g_log(Adapter, CE_CONT, "Begin PHY dump\n"); 2445082Syy150190 for (i = 0; i < ((sizeof (offset)) / sizeof (offset[0])); i++) { 2455082Syy150190 2465082Syy150190 stat = e1000_read_phy_reg(hw, offset[i], &value); 2475082Syy150190 if (stat == 0) { 2485082Syy150190 e1000g_log(Adapter, CE_CONT, 2495082Syy150190 "phyreg offset: %d value: 0x%x\n", 2505082Syy150190 offset[i], value); 2515082Syy150190 } else { 2525082Syy150190 e1000g_log(Adapter, CE_WARN, 2535082Syy150190 "phyreg offset: %d ERROR: 0x%x\n", 2545082Syy150190 offset[i], stat); 2555082Syy150190 } 2565082Syy150190 } 2575082Syy150190 } 2585082Syy150190 2595082Syy150190 uint32_t 2605082Syy150190 e1000_read_reg(struct e1000_hw *hw, uint32_t offset) 2615082Syy150190 { 2625082Syy150190 return (ddi_get32(((struct e1000g_osdep *)(hw)->back)->reg_handle, 2635082Syy150190 (uint32_t *)((hw)->hw_addr + offset))); 2645082Syy150190 } 2655082Syy150190 2665082Syy150190 2675082Syy150190 /* 2685082Syy150190 * mac_dump - dump important mac registers 2695082Syy150190 */ 2705082Syy150190 void 2715082Syy150190 mac_dump(void *instance) 2725082Syy150190 { 2735082Syy150190 struct e1000g *Adapter = (struct e1000g *)instance; 2745082Syy150190 struct e1000_hw *hw = &Adapter->shared; 2755082Syy150190 int i; 2765082Syy150190 2775082Syy150190 /* {name, offset} for each mac register */ 2785082Syy150190 Regi_t macreg[NUM_REGS] = { 2795082Syy150190 {"CTRL", E1000_CTRL}, {"STATUS", E1000_STATUS}, 2805082Syy150190 {"EECD", E1000_EECD}, {"EERD", E1000_EERD}, 2815082Syy150190 {"CTRL_EXT", E1000_CTRL_EXT}, {"FLA", E1000_FLA}, 2825082Syy150190 {"MDIC", E1000_MDIC}, {"SCTL", E1000_SCTL}, 2835082Syy150190 {"FCAL", E1000_FCAL}, {"FCAH", E1000_FCAH}, 2845082Syy150190 {"FCT", E1000_FCT}, {"VET", E1000_VET}, 2855082Syy150190 {"ICR", E1000_ICR}, {"ITR", E1000_ITR}, 2865082Syy150190 {"ICS", E1000_ICS}, {"IMS", E1000_IMS}, 2875082Syy150190 {"IMC", E1000_IMC}, {"IAM", E1000_IAM}, 2885082Syy150190 {"RCTL", E1000_RCTL}, {"FCTTV", E1000_FCTTV}, 2895082Syy150190 {"TXCW", E1000_TXCW}, {"RXCW", E1000_RXCW}, 2905082Syy150190 {"TCTL", E1000_TCTL}, {"TIPG", E1000_TIPG}, 2915082Syy150190 {"AIT", E1000_AIT}, {"LEDCTL", E1000_LEDCTL}, 2925082Syy150190 {"PBA", E1000_PBA}, {"PBS", E1000_PBS}, 2935082Syy150190 {"EEMNGCTL", E1000_EEMNGCTL}, {"ERT", E1000_ERT}, 2945082Syy150190 {"FCRTL", E1000_FCRTL}, {"FCRTH", E1000_FCRTH}, 2956735Scc210113 {"PSRCTL", E1000_PSRCTL}, {"RDBAL(0)", E1000_RDBAL(0)}, 2966735Scc210113 {"RDBAH(0)", E1000_RDBAH(0)}, {"RDLEN(0)", E1000_RDLEN(0)}, 2976735Scc210113 {"RDH(0)", E1000_RDH(0)}, {"RDT(0)", E1000_RDT(0)}, 2986735Scc210113 {"RDTR", E1000_RDTR}, {"RXDCTL(0)", E1000_RXDCTL(0)}, 2996735Scc210113 {"RADV", E1000_RADV}, {"RDBAL(1)", E1000_RDBAL(1)}, 3006735Scc210113 {"RDBAH(1)", E1000_RDBAH(1)}, {"RDLEN(1)", E1000_RDLEN(1)}, 3016735Scc210113 {"RDH(1)", E1000_RDH(1)}, {"RDT(1)", E1000_RDT(1)}, 3026735Scc210113 {"RXDCTL(1)", E1000_RXDCTL(1)}, {"RSRPD", E1000_RSRPD}, 3035082Syy150190 {"RAID", E1000_RAID}, {"CPUVEC", E1000_CPUVEC}, 3045082Syy150190 {"TDFH", E1000_TDFH}, {"TDFT", E1000_TDFT}, 3055082Syy150190 {"TDFHS", E1000_TDFHS}, {"TDFTS", E1000_TDFTS}, 3066735Scc210113 {"TDFPC", E1000_TDFPC}, {"TDBAL(0)", E1000_TDBAL(0)}, 3076735Scc210113 {"TDBAH(0)", E1000_TDBAH(0)}, {"TDLEN(0)", E1000_TDLEN(0)}, 3086735Scc210113 {"TDH(0)", E1000_TDH(0)}, {"TDT(0)", E1000_TDT(0)}, 3096735Scc210113 {"TIDV", E1000_TIDV}, {"TXDCTL(0)", E1000_TXDCTL(0)}, 3106735Scc210113 {"TADV", E1000_TADV}, {"TARC(0)", E1000_TARC(0)}, 3116735Scc210113 {"TDBAL(1)", E1000_TDBAL(1)}, {"TDBAH(1)", E1000_TDBAH(1)}, 3126735Scc210113 {"TDLEN(1)", E1000_TDLEN(1)}, {"TDH(1)", E1000_TDH(1)}, 3136735Scc210113 {"TDT(1)", E1000_TDT(1)}, {"TXDCTL(1)", E1000_TXDCTL(1)}, 3146735Scc210113 {"TARC(1)", E1000_TARC(1)}, {"ALGNERRC", E1000_ALGNERRC}, 3155082Syy150190 {"RXERRC", E1000_RXERRC}, {"MPC", E1000_MPC}, 3165082Syy150190 {"SCC", E1000_SCC}, {"ECOL", E1000_ECOL}, 3175082Syy150190 {"MCC", E1000_MCC}, {"LATECOL", E1000_LATECOL}, 3185082Syy150190 {"COLC", E1000_COLC}, {"DC", E1000_DC}, 3195082Syy150190 {"TNCRS", E1000_TNCRS}, {"SEC", E1000_SEC}, 3205082Syy150190 {"CEXTERR", E1000_CEXTERR}, {"RLEC", E1000_RLEC}, 3215082Syy150190 {"XONRXC", E1000_XONRXC}, {"XONTXC", E1000_XONTXC}, 3225082Syy150190 {"XOFFRXC", E1000_XOFFRXC}, {"XOFFTXC", E1000_XOFFTXC}, 3235082Syy150190 {"FCRUC", E1000_FCRUC}, {"PRC64", E1000_PRC64}, 3245082Syy150190 {"PRC127", E1000_PRC127}, {"PRC255", E1000_PRC255}, 3255082Syy150190 {"PRC511", E1000_PRC511}, {"PRC1023", E1000_PRC1023}, 3265082Syy150190 {"PRC1522", E1000_PRC1522}, {"GPRC", E1000_GPRC}, 3275082Syy150190 {"BPRC", E1000_BPRC}, {"MPRC", E1000_MPRC}, 3285082Syy150190 {"GPTC", E1000_GPTC}, {"GORCL", E1000_GORCL}, 3295082Syy150190 {"GORCH", E1000_GORCH}, {"GOTCL", E1000_GOTCL}, 3305082Syy150190 {"GOTCH", E1000_GOTCH}, {"RNBC", E1000_RNBC}, 3315082Syy150190 {"RUC", E1000_RUC}, {"RFC", E1000_RFC}, 3325082Syy150190 {"ROC", E1000_ROC}, {"RJC", E1000_RJC}, 3335082Syy150190 {"MGTPRC", E1000_MGTPRC}, {"MGTPDC", E1000_MGTPDC}, 3345082Syy150190 {"MGTPTC", E1000_MGTPTC}, {"TORL", E1000_TORL}, 3355082Syy150190 {"TORH", E1000_TORH}, {"TOTL", E1000_TOTL}, 3365082Syy150190 {"TOTH", E1000_TOTH}, {"TPR", E1000_TPR}, 3375082Syy150190 {"TPT", E1000_TPT}, {"PTC64", E1000_PTC64}, 3385082Syy150190 {"PTC127", E1000_PTC127}, {"PTC255", E1000_PTC255}, 3395082Syy150190 {"PTC511", E1000_PTC511}, {"PTC1023", E1000_PTC1023}, 3405082Syy150190 {"PTC1522", E1000_PTC1522}, {"MPTC", E1000_MPTC}, 3415082Syy150190 {"BPTC", E1000_BPTC}, {"TSCTC", E1000_TSCTC}, 3425082Syy150190 {"TSCTFC", E1000_TSCTFC}, {"IAC", E1000_IAC}, 3435082Syy150190 {"ICRXPTC", E1000_ICRXPTC}, {"ICRXATC", E1000_ICRXATC}, 3445082Syy150190 {"ICTXPTC", E1000_ICTXPTC}, {"ICTXATC", E1000_ICTXATC}, 3455082Syy150190 {"ICTXQEC", E1000_ICTXQEC}, {"ICTXQMTC", E1000_ICTXQMTC}, 3465082Syy150190 {"ICRXDMTC", E1000_ICRXDMTC}, {"ICRXOC", E1000_ICRXOC}, 3475082Syy150190 {"RXCSUM", E1000_RXCSUM}, {"RFCTL", E1000_RFCTL}, 3485082Syy150190 {"WUC", E1000_WUC}, {"WUFC", E1000_WUFC}, 3495082Syy150190 {"WUS", E1000_WUS}, {"MRQC", E1000_MRQC}, 3505082Syy150190 {"MANC", E1000_MANC}, {"IPAV", E1000_IPAV}, 3515082Syy150190 {"MANC2H", E1000_MANC2H}, {"RSSIM", E1000_RSSIM}, 3525082Syy150190 {"RSSIR", E1000_RSSIR}, {"WUPL", E1000_WUPL}, 3535082Syy150190 {"GCR", E1000_GCR}, {"GSCL_1", E1000_GSCL_1}, 3545082Syy150190 {"GSCL_2", E1000_GSCL_2}, {"GSCL_3", E1000_GSCL_3}, 3555082Syy150190 {"GSCL_4", E1000_GSCL_4}, {"FACTPS", E1000_FACTPS}, 3565082Syy150190 {"FWSM", E1000_FWSM}, 3575082Syy150190 }; 3585082Syy150190 3595082Syy150190 e1000g_log(Adapter, CE_CONT, "Begin MAC dump\n"); 3605082Syy150190 3615082Syy150190 for (i = 0; i < NUM_REGS; i++) { 3625082Syy150190 e1000g_log(Adapter, CE_CONT, 3635082Syy150190 "macreg %10s offset: 0x%x value: 0x%x\n", 3645082Syy150190 macreg[i].name, macreg[i].offset, 3655082Syy150190 e1000_read_reg(hw, macreg[i].offset)); 3665082Syy150190 } 3675082Syy150190 } 3685082Syy150190 3695082Syy150190 void 3705082Syy150190 pciconfig_dump(void *instance) 3715082Syy150190 { 3725082Syy150190 struct e1000g *Adapter = (struct e1000g *)instance; 3735082Syy150190 ddi_acc_handle_t handle; 3745082Syy150190 uint8_t cap_ptr; 3755082Syy150190 uint8_t next_ptr; 3765082Syy150190 off_t offset; 3775082Syy150190 3785082Syy150190 handle = Adapter->osdep.cfg_handle; 3795082Syy150190 3805082Syy150190 e1000g_log(Adapter, CE_CONT, "Begin dump PCI config space\n"); 3815082Syy150190 3825082Syy150190 e1000g_log(Adapter, CE_CONT, 3835082Syy150190 "PCI_CONF_VENID:\t0x%x\n", 3845082Syy150190 pci_config_get16(handle, PCI_CONF_VENID)); 3855082Syy150190 e1000g_log(Adapter, CE_CONT, 3865082Syy150190 "PCI_CONF_DEVID:\t0x%x\n", 3875082Syy150190 pci_config_get16(handle, PCI_CONF_DEVID)); 3885082Syy150190 e1000g_log(Adapter, CE_CONT, 3895082Syy150190 "PCI_CONF_COMMAND:\t0x%x\n", 3905082Syy150190 pci_config_get16(handle, PCI_CONF_COMM)); 3915082Syy150190 e1000g_log(Adapter, CE_CONT, 3925082Syy150190 "PCI_CONF_STATUS:\t0x%x\n", 3935082Syy150190 pci_config_get16(handle, PCI_CONF_STAT)); 3945082Syy150190 e1000g_log(Adapter, CE_CONT, 3955082Syy150190 "PCI_CONF_REVID:\t0x%x\n", 3965082Syy150190 pci_config_get8(handle, PCI_CONF_REVID)); 3975082Syy150190 e1000g_log(Adapter, CE_CONT, 3985082Syy150190 "PCI_CONF_PROG_CLASS:\t0x%x\n", 3995082Syy150190 pci_config_get8(handle, PCI_CONF_PROGCLASS)); 4005082Syy150190 e1000g_log(Adapter, CE_CONT, 4015082Syy150190 "PCI_CONF_SUB_CLASS:\t0x%x\n", 4025082Syy150190 pci_config_get8(handle, PCI_CONF_SUBCLASS)); 4035082Syy150190 e1000g_log(Adapter, CE_CONT, 4045082Syy150190 "PCI_CONF_BAS_CLASS:\t0x%x\n", 4055082Syy150190 pci_config_get8(handle, PCI_CONF_BASCLASS)); 4065082Syy150190 e1000g_log(Adapter, CE_CONT, 4075082Syy150190 "PCI_CONF_CACHE_LINESZ:\t0x%x\n", 4085082Syy150190 pci_config_get8(handle, PCI_CONF_CACHE_LINESZ)); 4095082Syy150190 e1000g_log(Adapter, CE_CONT, 4105082Syy150190 "PCI_CONF_LATENCY_TIMER:\t0x%x\n", 4115082Syy150190 pci_config_get8(handle, PCI_CONF_LATENCY_TIMER)); 4125082Syy150190 e1000g_log(Adapter, CE_CONT, 4135082Syy150190 "PCI_CONF_HEADER_TYPE:\t0x%x\n", 4145082Syy150190 pci_config_get8(handle, PCI_CONF_HEADER)); 4155082Syy150190 e1000g_log(Adapter, CE_CONT, 4165082Syy150190 "PCI_CONF_BIST:\t0x%x\n", 4175082Syy150190 pci_config_get8(handle, PCI_CONF_BIST)); 4186735Scc210113 4196735Scc210113 pciconfig_bar(Adapter, PCI_CONF_BASE0, "PCI_CONF_BASE0"); 4206735Scc210113 pciconfig_bar(Adapter, PCI_CONF_BASE1, "PCI_CONF_BASE1"); 4216735Scc210113 pciconfig_bar(Adapter, PCI_CONF_BASE2, "PCI_CONF_BASE2"); 4226735Scc210113 pciconfig_bar(Adapter, PCI_CONF_BASE3, "PCI_CONF_BASE3"); 4236735Scc210113 pciconfig_bar(Adapter, PCI_CONF_BASE4, "PCI_CONF_BASE4"); 4246735Scc210113 pciconfig_bar(Adapter, PCI_CONF_BASE5, "PCI_CONF_BASE5"); 4256735Scc210113 4265082Syy150190 e1000g_log(Adapter, CE_CONT, 4275082Syy150190 "PCI_CONF_CIS:\t0x%x\n", 4285082Syy150190 pci_config_get32(handle, PCI_CONF_CIS)); 4295082Syy150190 e1000g_log(Adapter, CE_CONT, 4305082Syy150190 "PCI_CONF_SUBVENID:\t0x%x\n", 4315082Syy150190 pci_config_get16(handle, PCI_CONF_SUBVENID)); 4325082Syy150190 e1000g_log(Adapter, CE_CONT, 4335082Syy150190 "PCI_CONF_SUBSYSID:\t0x%x\n", 4345082Syy150190 pci_config_get16(handle, PCI_CONF_SUBSYSID)); 4355082Syy150190 e1000g_log(Adapter, CE_CONT, 4365082Syy150190 "PCI_CONF_ROM:\t0x%x\n", 4375082Syy150190 pci_config_get32(handle, PCI_CONF_ROM)); 4385082Syy150190 4395082Syy150190 cap_ptr = pci_config_get8(handle, PCI_CONF_CAP_PTR); 4405082Syy150190 4415082Syy150190 e1000g_log(Adapter, CE_CONT, 4425082Syy150190 "PCI_CONF_CAP_PTR:\t0x%x\n", cap_ptr); 4435082Syy150190 e1000g_log(Adapter, CE_CONT, 4445082Syy150190 "PCI_CONF_ILINE:\t0x%x\n", 4455082Syy150190 pci_config_get8(handle, PCI_CONF_ILINE)); 4465082Syy150190 e1000g_log(Adapter, CE_CONT, 4475082Syy150190 "PCI_CONF_IPIN:\t0x%x\n", 4485082Syy150190 pci_config_get8(handle, PCI_CONF_IPIN)); 4495082Syy150190 e1000g_log(Adapter, CE_CONT, 4505082Syy150190 "PCI_CONF_MIN_G:\t0x%x\n", 4515082Syy150190 pci_config_get8(handle, PCI_CONF_MIN_G)); 4525082Syy150190 e1000g_log(Adapter, CE_CONT, 4535082Syy150190 "PCI_CONF_MAX_L:\t0x%x\n", 4545082Syy150190 pci_config_get8(handle, PCI_CONF_MAX_L)); 4555082Syy150190 4565082Syy150190 /* Power Management */ 4575082Syy150190 offset = cap_ptr; 4585082Syy150190 4595082Syy150190 e1000g_log(Adapter, CE_CONT, 4605082Syy150190 "PCI_PM_CAP_ID:\t0x%x\n", 4615082Syy150190 pci_config_get8(handle, offset)); 4625082Syy150190 4635082Syy150190 next_ptr = pci_config_get8(handle, offset + 1); 4645082Syy150190 4655082Syy150190 e1000g_log(Adapter, CE_CONT, 4665082Syy150190 "PCI_PM_NEXT_PTR:\t0x%x\n", next_ptr); 4675082Syy150190 e1000g_log(Adapter, CE_CONT, 4685082Syy150190 "PCI_PM_CAP:\t0x%x\n", 4695082Syy150190 pci_config_get16(handle, offset + PCI_PMCAP)); 4705082Syy150190 e1000g_log(Adapter, CE_CONT, 4715082Syy150190 "PCI_PM_CSR:\t0x%x\n", 4725082Syy150190 pci_config_get16(handle, offset + PCI_PMCSR)); 4735082Syy150190 e1000g_log(Adapter, CE_CONT, 4745082Syy150190 "PCI_PM_CSR_BSE:\t0x%x\n", 4755082Syy150190 pci_config_get8(handle, offset + PCI_PMCSR_BSE)); 4765082Syy150190 e1000g_log(Adapter, CE_CONT, 4775082Syy150190 "PCI_PM_DATA:\t0x%x\n", 4785082Syy150190 pci_config_get8(handle, offset + PCI_PMDATA)); 4795082Syy150190 4805082Syy150190 /* MSI Configuration */ 4815082Syy150190 offset = next_ptr; 4825082Syy150190 4835082Syy150190 e1000g_log(Adapter, CE_CONT, 4845082Syy150190 "PCI_MSI_CAP_ID:\t0x%x\n", 4855082Syy150190 pci_config_get8(handle, offset)); 4865082Syy150190 4875082Syy150190 next_ptr = pci_config_get8(handle, offset + 1); 4885082Syy150190 4895082Syy150190 e1000g_log(Adapter, CE_CONT, 4905082Syy150190 "PCI_MSI_NEXT_PTR:\t0x%x\n", next_ptr); 4915082Syy150190 e1000g_log(Adapter, CE_CONT, 4925082Syy150190 "PCI_MSI_CTRL:\t0x%x\n", 4935082Syy150190 pci_config_get16(handle, offset + PCI_MSI_CTRL)); 4945082Syy150190 e1000g_log(Adapter, CE_CONT, 4955082Syy150190 "PCI_MSI_ADDR:\t0x%x\n", 4965082Syy150190 pci_config_get32(handle, offset + PCI_MSI_ADDR_OFFSET)); 4975082Syy150190 e1000g_log(Adapter, CE_CONT, 4985082Syy150190 "PCI_MSI_ADDR_HI:\t0x%x\n", 4995082Syy150190 pci_config_get32(handle, offset + 0x8)); 5005082Syy150190 e1000g_log(Adapter, CE_CONT, 5015082Syy150190 "PCI_MSI_DATA:\t0x%x\n", 5025082Syy150190 pci_config_get16(handle, offset + 0xC)); 5035082Syy150190 5045082Syy150190 /* PCI Express Configuration */ 5055082Syy150190 offset = next_ptr; 5065082Syy150190 5075082Syy150190 e1000g_log(Adapter, CE_CONT, 5085082Syy150190 "PCIE_CAP_ID:\t0x%x\n", 5095082Syy150190 pci_config_get8(handle, offset + PCIE_CAP_ID)); 5105082Syy150190 5115082Syy150190 next_ptr = pci_config_get8(handle, offset + PCIE_CAP_NEXT_PTR); 5125082Syy150190 5135082Syy150190 e1000g_log(Adapter, CE_CONT, 5145082Syy150190 "PCIE_CAP_NEXT_PTR:\t0x%x\n", next_ptr); 5155082Syy150190 e1000g_log(Adapter, CE_CONT, 5165082Syy150190 "PCIE_PCIECAP:\t0x%x\n", 5175082Syy150190 pci_config_get16(handle, offset + PCIE_PCIECAP)); 5185082Syy150190 e1000g_log(Adapter, CE_CONT, 5195082Syy150190 "PCIE_DEVCAP:\t0x%x\n", 5205082Syy150190 pci_config_get32(handle, offset + PCIE_DEVCAP)); 5215082Syy150190 e1000g_log(Adapter, CE_CONT, 5225082Syy150190 "PCIE_DEVCTL:\t0x%x\n", 5235082Syy150190 pci_config_get16(handle, offset + PCIE_DEVCTL)); 5245082Syy150190 e1000g_log(Adapter, CE_CONT, 5255082Syy150190 "PCIE_DEVSTS:\t0x%x\n", 5265082Syy150190 pci_config_get16(handle, offset + PCIE_DEVSTS)); 5275082Syy150190 e1000g_log(Adapter, CE_CONT, 5285082Syy150190 "PCIE_LINKCAP:\t0x%x\n", 5295082Syy150190 pci_config_get32(handle, offset + PCIE_LINKCAP)); 5305082Syy150190 e1000g_log(Adapter, CE_CONT, 5315082Syy150190 "PCIE_LINKCTL:\t0x%x\n", 5325082Syy150190 pci_config_get16(handle, offset + PCIE_LINKCTL)); 5335082Syy150190 e1000g_log(Adapter, CE_CONT, 5345082Syy150190 "PCIE_LINKSTS:\t0x%x\n", 5355082Syy150190 pci_config_get16(handle, offset + PCIE_LINKSTS)); 5365082Syy150190 } 5376735Scc210113 5386735Scc210113 void 5396735Scc210113 pciconfig_bar(void *instance, uint32_t offset, char *name) 5406735Scc210113 { 5416735Scc210113 struct e1000g *Adapter = (struct e1000g *)instance; 5426735Scc210113 ddi_acc_handle_t handle = Adapter->osdep.cfg_handle; 5436735Scc210113 uint32_t base = pci_config_get32(handle, offset); 5446735Scc210113 uint16_t comm = pci_config_get16(handle, PCI_CONF_COMM); 5456735Scc210113 uint32_t size; /* derived size of the region */ 5466735Scc210113 uint32_t bits_comm; /* command word bits to disable */ 5476735Scc210113 uint32_t size_mask; /* mask for size extraction */ 5486735Scc210113 char tag_type[32]; /* tag to show memory vs. i/o */ 5496735Scc210113 char tag_mem[32]; /* tag to show memory characteristiccs */ 5506735Scc210113 5516735Scc210113 /* base address zero, simple print */ 5526735Scc210113 if (base == 0) { 5536735Scc210113 e1000g_log(Adapter, CE_CONT, "%s:\t0x%x\n", name, base); 5546735Scc210113 5556735Scc210113 /* base address non-zero, get size */ 5566735Scc210113 } else { 5576735Scc210113 /* i/o factors that decode from the base address */ 5586735Scc210113 if (base & PCI_BASE_SPACE_IO) { 5596735Scc210113 bits_comm = PCI_COMM_IO; 5606735Scc210113 size_mask = PCI_BASE_IO_ADDR_M; 5616735Scc210113 strcpy(tag_type, "i/o port size:"); 5626735Scc210113 strcpy(tag_mem, ""); 5636735Scc210113 /* memory factors that decode from the base address */ 5646735Scc210113 } else { 5656735Scc210113 bits_comm = PCI_COMM_MAE; 5666735Scc210113 size_mask = PCI_BASE_M_ADDR_M; 5676735Scc210113 strcpy(tag_type, "memory size:"); 5686735Scc210113 if (base & PCI_BASE_TYPE_ALL) 5696735Scc210113 strcpy(tag_mem, "64bit "); 5706735Scc210113 else 5716735Scc210113 strcpy(tag_mem, "32bit "); 5726735Scc210113 if (base & PCI_BASE_PREF_M) 5736735Scc210113 strcat(tag_mem, "prefetchable"); 5746735Scc210113 else 5756735Scc210113 strcat(tag_mem, "non-prefetchable"); 5766735Scc210113 } 5776735Scc210113 5786735Scc210113 /* disable memory decode */ 5796735Scc210113 pci_config_put16(handle, PCI_CONF_COMM, (comm & ~bits_comm)); 5806735Scc210113 5816735Scc210113 /* write to base register */ 5826735Scc210113 pci_config_put32(handle, offset, 0xffffffff); 5836735Scc210113 5846735Scc210113 /* read back & compute size */ 5856735Scc210113 size = pci_config_get32(handle, offset); 5866735Scc210113 size &= size_mask; 5876735Scc210113 size = (~size) + 1; 5886735Scc210113 5896735Scc210113 /* restore base register */ 5906735Scc210113 pci_config_put32(handle, offset, base); 5916735Scc210113 5926735Scc210113 /* re-enable memory decode */ 5936735Scc210113 pci_config_put16(handle, PCI_CONF_COMM, comm); 5946735Scc210113 5956735Scc210113 /* print results */ 5966735Scc210113 e1000g_log(Adapter, CE_CONT, "%s:\t0x%x %s 0x%x %s\n", 5976735Scc210113 name, base, tag_type, size, tag_mem); 5986735Scc210113 } 5996735Scc210113 } 6005082Syy150190 #endif 601