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