xref: /onnv-gate/usr/src/uts/common/io/igb/igb_debug.c (revision 8571:60e408ef19cc)
15779Sxy150489 /*
25779Sxy150489  * CDDL HEADER START
35779Sxy150489  *
4*8571SChenlu.Chen@Sun.COM  * Copyright(c) 2007-2009 Intel Corporation. All rights reserved.
55779Sxy150489  * The contents of this file are subject to the terms of the
65779Sxy150489  * Common Development and Distribution License (the "License").
75779Sxy150489  * You may not use this file except in compliance with the License.
85779Sxy150489  *
95779Sxy150489  * You can obtain a copy of the license at:
105779Sxy150489  *	http://www.opensolaris.org/os/licensing.
115779Sxy150489  * See the License for the specific language governing permissions
125779Sxy150489  * and limitations under the License.
135779Sxy150489  *
145779Sxy150489  * When using or redistributing this file, you may do so under the
155779Sxy150489  * License only. No other modification of this header is permitted.
165779Sxy150489  *
175779Sxy150489  * If applicable, add the following below this CDDL HEADER, with the
185779Sxy150489  * fields enclosed by brackets "[]" replaced with your own identifying
195779Sxy150489  * information: Portions Copyright [yyyy] [name of copyright owner]
205779Sxy150489  *
215779Sxy150489  * CDDL HEADER END
225779Sxy150489  */
235779Sxy150489 
245779Sxy150489 /*
25*8571SChenlu.Chen@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
265779Sxy150489  * Use is subject to license terms of the CDDL.
275779Sxy150489  */
285779Sxy150489 
295779Sxy150489 #include "igb_sw.h"
305779Sxy150489 #include "igb_debug.h"
315779Sxy150489 
325779Sxy150489 #ifdef IGB_DEBUG
335779Sxy150489 extern ddi_device_acc_attr_t igb_regs_acc_attr;
345779Sxy150489 
355779Sxy150489 void
pci_dump(void * arg)365779Sxy150489 pci_dump(void *arg)
375779Sxy150489 {
385779Sxy150489 	igb_t *igb = (igb_t *)arg;
395779Sxy150489 	ddi_acc_handle_t handle;
405779Sxy150489 	uint8_t cap_ptr;
415779Sxy150489 	uint8_t next_ptr;
425779Sxy150489 	uint32_t msix_bar;
435779Sxy150489 	uint32_t msix_ctrl;
445779Sxy150489 	uint32_t msix_tbl_sz;
455779Sxy150489 	uint32_t tbl_offset;
465779Sxy150489 	uint32_t tbl_bir;
475779Sxy150489 	uint32_t pba_offset;
485779Sxy150489 	uint32_t pba_bir;
495779Sxy150489 	off_t offset;
505779Sxy150489 	off_t mem_size;
515779Sxy150489 	uintptr_t base;
525779Sxy150489 	ddi_acc_handle_t acc_hdl;
535779Sxy150489 	int i;
545779Sxy150489 
555779Sxy150489 	handle = igb->osdep.cfg_handle;
565779Sxy150489 
575779Sxy150489 	igb_log(igb, "Begin dump PCI config space");
585779Sxy150489 
595779Sxy150489 	igb_log(igb,
605779Sxy150489 	    "PCI_CONF_VENID:\t0x%x\n",
615779Sxy150489 	    pci_config_get16(handle, PCI_CONF_VENID));
625779Sxy150489 	igb_log(igb,
635779Sxy150489 	    "PCI_CONF_DEVID:\t0x%x\n",
645779Sxy150489 	    pci_config_get16(handle, PCI_CONF_DEVID));
655779Sxy150489 	igb_log(igb,
665779Sxy150489 	    "PCI_CONF_COMMAND:\t0x%x\n",
675779Sxy150489 	    pci_config_get16(handle, PCI_CONF_COMM));
685779Sxy150489 	igb_log(igb,
695779Sxy150489 	    "PCI_CONF_STATUS:\t0x%x\n",
705779Sxy150489 	    pci_config_get16(handle, PCI_CONF_STAT));
715779Sxy150489 	igb_log(igb,
725779Sxy150489 	    "PCI_CONF_REVID:\t0x%x\n",
735779Sxy150489 	    pci_config_get8(handle, PCI_CONF_REVID));
745779Sxy150489 	igb_log(igb,
755779Sxy150489 	    "PCI_CONF_PROG_CLASS:\t0x%x\n",
765779Sxy150489 	    pci_config_get8(handle, PCI_CONF_PROGCLASS));
775779Sxy150489 	igb_log(igb,
785779Sxy150489 	    "PCI_CONF_SUB_CLASS:\t0x%x\n",
795779Sxy150489 	    pci_config_get8(handle, PCI_CONF_SUBCLASS));
805779Sxy150489 	igb_log(igb,
815779Sxy150489 	    "PCI_CONF_BAS_CLASS:\t0x%x\n",
825779Sxy150489 	    pci_config_get8(handle, PCI_CONF_BASCLASS));
835779Sxy150489 	igb_log(igb,
845779Sxy150489 	    "PCI_CONF_CACHE_LINESZ:\t0x%x\n",
855779Sxy150489 	    pci_config_get8(handle, PCI_CONF_CACHE_LINESZ));
865779Sxy150489 	igb_log(igb,
875779Sxy150489 	    "PCI_CONF_LATENCY_TIMER:\t0x%x\n",
885779Sxy150489 	    pci_config_get8(handle, PCI_CONF_LATENCY_TIMER));
895779Sxy150489 	igb_log(igb,
905779Sxy150489 	    "PCI_CONF_HEADER_TYPE:\t0x%x\n",
915779Sxy150489 	    pci_config_get8(handle, PCI_CONF_HEADER));
925779Sxy150489 	igb_log(igb,
935779Sxy150489 	    "PCI_CONF_BIST:\t0x%x\n",
945779Sxy150489 	    pci_config_get8(handle, PCI_CONF_BIST));
955779Sxy150489 	igb_log(igb,
965779Sxy150489 	    "PCI_CONF_BASE0:\t0x%x\n",
975779Sxy150489 	    pci_config_get32(handle, PCI_CONF_BASE0));
985779Sxy150489 	igb_log(igb,
995779Sxy150489 	    "PCI_CONF_BASE1:\t0x%x\n",
1005779Sxy150489 	    pci_config_get32(handle, PCI_CONF_BASE1));
1015779Sxy150489 	igb_log(igb,
1025779Sxy150489 	    "PCI_CONF_BASE2:\t0x%x\n",
1035779Sxy150489 	    pci_config_get32(handle, PCI_CONF_BASE2));
1045779Sxy150489 
1055779Sxy150489 	/* MSI-X BAR */
1065779Sxy150489 	msix_bar = pci_config_get32(handle, PCI_CONF_BASE3);
1075779Sxy150489 	igb_log(igb,
1085779Sxy150489 	    "PCI_CONF_BASE3:\t0x%x\n", msix_bar);
1095779Sxy150489 
1105779Sxy150489 	igb_log(igb,
1115779Sxy150489 	    "PCI_CONF_BASE4:\t0x%x\n",
1125779Sxy150489 	    pci_config_get32(handle, PCI_CONF_BASE4));
1135779Sxy150489 	igb_log(igb,
1145779Sxy150489 	    "PCI_CONF_BASE5:\t0x%x\n",
1155779Sxy150489 	    pci_config_get32(handle, PCI_CONF_BASE5));
1165779Sxy150489 	igb_log(igb,
1175779Sxy150489 	    "PCI_CONF_CIS:\t0x%x\n",
1185779Sxy150489 	    pci_config_get32(handle, PCI_CONF_CIS));
1195779Sxy150489 	igb_log(igb,
1205779Sxy150489 	    "PCI_CONF_SUBVENID:\t0x%x\n",
1215779Sxy150489 	    pci_config_get16(handle, PCI_CONF_SUBVENID));
1225779Sxy150489 	igb_log(igb,
1235779Sxy150489 	    "PCI_CONF_SUBSYSID:\t0x%x\n",
1245779Sxy150489 	    pci_config_get16(handle, PCI_CONF_SUBSYSID));
1255779Sxy150489 	igb_log(igb,
1265779Sxy150489 	    "PCI_CONF_ROM:\t0x%x\n",
1275779Sxy150489 	    pci_config_get32(handle, PCI_CONF_ROM));
1285779Sxy150489 
1295779Sxy150489 	cap_ptr = pci_config_get8(handle, PCI_CONF_CAP_PTR);
1305779Sxy150489 
1315779Sxy150489 	igb_log(igb,
1325779Sxy150489 	    "PCI_CONF_CAP_PTR:\t0x%x\n", cap_ptr);
1335779Sxy150489 	igb_log(igb,
1345779Sxy150489 	    "PCI_CONF_ILINE:\t0x%x\n",
1355779Sxy150489 	    pci_config_get8(handle, PCI_CONF_ILINE));
1365779Sxy150489 	igb_log(igb,
1375779Sxy150489 	    "PCI_CONF_IPIN:\t0x%x\n",
1385779Sxy150489 	    pci_config_get8(handle, PCI_CONF_IPIN));
1395779Sxy150489 	igb_log(igb,
1405779Sxy150489 	    "PCI_CONF_MIN_G:\t0x%x\n",
1415779Sxy150489 	    pci_config_get8(handle, PCI_CONF_MIN_G));
1425779Sxy150489 	igb_log(igb,
1435779Sxy150489 	    "PCI_CONF_MAX_L:\t0x%x\n",
1445779Sxy150489 	    pci_config_get8(handle, PCI_CONF_MAX_L));
1455779Sxy150489 
1465779Sxy150489 	/* Power Management */
1475779Sxy150489 	offset = cap_ptr;
1485779Sxy150489 
1495779Sxy150489 	igb_log(igb,
1505779Sxy150489 	    "PCI_PM_CAP_ID:\t0x%x\n",
1515779Sxy150489 	    pci_config_get8(handle, offset));
1525779Sxy150489 
1535779Sxy150489 	next_ptr = pci_config_get8(handle, offset + 1);
1545779Sxy150489 
1555779Sxy150489 	igb_log(igb,
1565779Sxy150489 	    "PCI_PM_NEXT_PTR:\t0x%x\n", next_ptr);
1575779Sxy150489 	igb_log(igb,
1585779Sxy150489 	    "PCI_PM_CAP:\t0x%x\n",
1595779Sxy150489 	    pci_config_get16(handle, offset + PCI_PMCAP));
1605779Sxy150489 	igb_log(igb,
1615779Sxy150489 	    "PCI_PM_CSR:\t0x%x\n",
1625779Sxy150489 	    pci_config_get16(handle, offset + PCI_PMCSR));
1635779Sxy150489 	igb_log(igb,
1645779Sxy150489 	    "PCI_PM_CSR_BSE:\t0x%x\n",
1655779Sxy150489 	    pci_config_get8(handle, offset + PCI_PMCSR_BSE));
1665779Sxy150489 	igb_log(igb,
1675779Sxy150489 	    "PCI_PM_DATA:\t0x%x\n",
1685779Sxy150489 	    pci_config_get8(handle, offset + PCI_PMDATA));
1695779Sxy150489 
1705779Sxy150489 	/* MSI Configuration */
1715779Sxy150489 	offset = next_ptr;
1725779Sxy150489 
1735779Sxy150489 	igb_log(igb,
1745779Sxy150489 	    "PCI_MSI_CAP_ID:\t0x%x\n",
1755779Sxy150489 	    pci_config_get8(handle, offset));
1765779Sxy150489 
1775779Sxy150489 	next_ptr = pci_config_get8(handle, offset + 1);
1785779Sxy150489 
1795779Sxy150489 	igb_log(igb,
1805779Sxy150489 	    "PCI_MSI_NEXT_PTR:\t0x%x\n", next_ptr);
1815779Sxy150489 	igb_log(igb,
1825779Sxy150489 	    "PCI_MSI_CTRL:\t0x%x\n",
1835779Sxy150489 	    pci_config_get16(handle, offset + PCI_MSI_CTRL));
1845779Sxy150489 	igb_log(igb,
1855779Sxy150489 	    "PCI_MSI_ADDR:\t0x%x\n",
1865779Sxy150489 	    pci_config_get32(handle, offset + PCI_MSI_ADDR_OFFSET));
1875779Sxy150489 	igb_log(igb,
1885779Sxy150489 	    "PCI_MSI_ADDR_HI:\t0x%x\n",
1895779Sxy150489 	    pci_config_get32(handle, offset + 0x8));
1905779Sxy150489 	igb_log(igb,
1915779Sxy150489 	    "PCI_MSI_DATA:\t0x%x\n",
1925779Sxy150489 	    pci_config_get16(handle, offset + 0xC));
1935779Sxy150489 
1945779Sxy150489 	/* MSI-X Configuration */
1955779Sxy150489 	offset = next_ptr;
1965779Sxy150489 
1975779Sxy150489 	igb_log(igb,
1985779Sxy150489 	    "PCI_MSIX_CAP_ID:\t0x%x\n",
1995779Sxy150489 	    pci_config_get8(handle, offset));
2005779Sxy150489 
2015779Sxy150489 	next_ptr = pci_config_get8(handle, offset + 1);
2025779Sxy150489 	igb_log(igb,
2035779Sxy150489 	    "PCI_MSIX_NEXT_PTR:\t0x%x\n", next_ptr);
2045779Sxy150489 
2055779Sxy150489 	msix_ctrl = pci_config_get16(handle, offset + PCI_MSIX_CTRL);
2065779Sxy150489 	msix_tbl_sz = msix_ctrl & 0x7ff;
2075779Sxy150489 	igb_log(igb,
2085779Sxy150489 	    "PCI_MSIX_CTRL:\t0x%x\n", msix_ctrl);
2095779Sxy150489 
2105779Sxy150489 	tbl_offset = pci_config_get32(handle, offset + PCI_MSIX_TBL_OFFSET);
2115779Sxy150489 	tbl_bir = tbl_offset & PCI_MSIX_TBL_BIR_MASK;
2125779Sxy150489 	tbl_offset = tbl_offset & ~PCI_MSIX_TBL_BIR_MASK;
2135779Sxy150489 	igb_log(igb,
2145779Sxy150489 	    "PCI_MSIX_TBL_OFFSET:\t0x%x\n", tbl_offset);
2155779Sxy150489 	igb_log(igb,
2165779Sxy150489 	    "PCI_MSIX_TBL_BIR:\t0x%x\n", tbl_bir);
2175779Sxy150489 
2185779Sxy150489 	pba_offset = pci_config_get32(handle, offset + PCI_MSIX_PBA_OFFSET);
2195779Sxy150489 	pba_bir = pba_offset & PCI_MSIX_PBA_BIR_MASK;
2205779Sxy150489 	pba_offset = pba_offset & ~PCI_MSIX_PBA_BIR_MASK;
2215779Sxy150489 	igb_log(igb,
2225779Sxy150489 	    "PCI_MSIX_PBA_OFFSET:\t0x%x\n", pba_offset);
2235779Sxy150489 	igb_log(igb,
2245779Sxy150489 	    "PCI_MSIX_PBA_BIR:\t0x%x\n", pba_bir);
2255779Sxy150489 
2265779Sxy150489 	/* PCI Express Configuration */
2275779Sxy150489 	offset = next_ptr;
2285779Sxy150489 
2295779Sxy150489 	igb_log(igb,
2305779Sxy150489 	    "PCIE_CAP_ID:\t0x%x\n",
2315779Sxy150489 	    pci_config_get8(handle, offset + PCIE_CAP_ID));
2325779Sxy150489 
2335779Sxy150489 	next_ptr = pci_config_get8(handle, offset + PCIE_CAP_NEXT_PTR);
2345779Sxy150489 
2355779Sxy150489 	igb_log(igb,
2365779Sxy150489 	    "PCIE_CAP_NEXT_PTR:\t0x%x\n", next_ptr);
2375779Sxy150489 	igb_log(igb,
2385779Sxy150489 	    "PCIE_PCIECAP:\t0x%x\n",
2395779Sxy150489 	    pci_config_get16(handle, offset + PCIE_PCIECAP));
2405779Sxy150489 	igb_log(igb,
2415779Sxy150489 	    "PCIE_DEVCAP:\t0x%x\n",
2425779Sxy150489 	    pci_config_get32(handle, offset + PCIE_DEVCAP));
2435779Sxy150489 	igb_log(igb,
2445779Sxy150489 	    "PCIE_DEVCTL:\t0x%x\n",
2455779Sxy150489 	    pci_config_get16(handle, offset + PCIE_DEVCTL));
2465779Sxy150489 	igb_log(igb,
2475779Sxy150489 	    "PCIE_DEVSTS:\t0x%x\n",
2485779Sxy150489 	    pci_config_get16(handle, offset + PCIE_DEVSTS));
2495779Sxy150489 	igb_log(igb,
2505779Sxy150489 	    "PCIE_LINKCAP:\t0x%x\n",
2515779Sxy150489 	    pci_config_get32(handle, offset + PCIE_LINKCAP));
2525779Sxy150489 	igb_log(igb,
2535779Sxy150489 	    "PCIE_LINKCTL:\t0x%x\n",
2545779Sxy150489 	    pci_config_get16(handle, offset + PCIE_LINKCTL));
2555779Sxy150489 	igb_log(igb,
2565779Sxy150489 	    "PCIE_LINKSTS:\t0x%x\n",
2575779Sxy150489 	    pci_config_get16(handle, offset + PCIE_LINKSTS));
2585779Sxy150489 
2595779Sxy150489 	/* MSI-X Memory Space */
260*8571SChenlu.Chen@Sun.COM 	if (ddi_dev_regsize(igb->dip, IGB_ADAPTER_MSIXTAB, &mem_size) !=
261*8571SChenlu.Chen@Sun.COM 	    DDI_SUCCESS) {
2625779Sxy150489 		igb_log(igb, "ddi_dev_regsize() failed");
2635779Sxy150489 		return;
2645779Sxy150489 	}
2655779Sxy150489 
266*8571SChenlu.Chen@Sun.COM 	if ((ddi_regs_map_setup(igb->dip, IGB_ADAPTER_MSIXTAB, (caddr_t *)&base,
267*8571SChenlu.Chen@Sun.COM 	    0, mem_size, &igb_regs_acc_attr, &acc_hdl)) != DDI_SUCCESS) {
2685779Sxy150489 		igb_log(igb, "ddi_regs_map_setup() failed");
2695779Sxy150489 		return;
2705779Sxy150489 	}
2715779Sxy150489 
2725779Sxy150489 	igb_log(igb, "MSI-X Memory Space: (mem_size = %d, base = %x)",
2735779Sxy150489 	    mem_size, base);
2745779Sxy150489 
2755779Sxy150489 	for (i = 0; i <= msix_tbl_sz; i++) {
2765779Sxy150489 		igb_log(igb, "MSI-X Table Entry(%d):", i);
2775779Sxy150489 		igb_log(igb, "lo_addr:\t%x",
2785779Sxy150489 		    ddi_get32(acc_hdl,
2795779Sxy150489 		    (uint32_t *)(base + tbl_offset + (i * 16))));
2805779Sxy150489 		igb_log(igb, "up_addr:\t%x",
2815779Sxy150489 		    ddi_get32(acc_hdl,
2825779Sxy150489 		    (uint32_t *)(base + tbl_offset + (i * 16) + 4)));
2835779Sxy150489 		igb_log(igb, "msg_data:\t%x",
2845779Sxy150489 		    ddi_get32(acc_hdl,
2855779Sxy150489 		    (uint32_t *)(base + tbl_offset + (i * 16) + 8)));
2865779Sxy150489 		igb_log(igb, "vct_ctrl:\t%x",
2875779Sxy150489 		    ddi_get32(acc_hdl,
2885779Sxy150489 		    (uint32_t *)(base + tbl_offset + (i * 16) + 12)));
2895779Sxy150489 	}
2905779Sxy150489 
2915779Sxy150489 	igb_log(igb, "MSI-X Pending Bits:\t%x",
2925779Sxy150489 	    ddi_get32(acc_hdl, (uint32_t *)(base + pba_offset)));
2935779Sxy150489 
2945779Sxy150489 	ddi_regs_map_free(&acc_hdl);
2955779Sxy150489 }
2965779Sxy150489 #endif
297