xref: /onnv-gate/usr/src/uts/common/io/igb/igb_debug.c (revision 5779:e875a8701bfc)
1*5779Sxy150489 /*
2*5779Sxy150489  * CDDL HEADER START
3*5779Sxy150489  *
4*5779Sxy150489  * Copyright(c) 2007-2008 Intel Corporation. All rights reserved.
5*5779Sxy150489  * The contents of this file are subject to the terms of the
6*5779Sxy150489  * Common Development and Distribution License (the "License").
7*5779Sxy150489  * You may not use this file except in compliance with the License.
8*5779Sxy150489  *
9*5779Sxy150489  * You can obtain a copy of the license at:
10*5779Sxy150489  *	http://www.opensolaris.org/os/licensing.
11*5779Sxy150489  * See the License for the specific language governing permissions
12*5779Sxy150489  * and limitations under the License.
13*5779Sxy150489  *
14*5779Sxy150489  * When using or redistributing this file, you may do so under the
15*5779Sxy150489  * License only. No other modification of this header is permitted.
16*5779Sxy150489  *
17*5779Sxy150489  * If applicable, add the following below this CDDL HEADER, with the
18*5779Sxy150489  * fields enclosed by brackets "[]" replaced with your own identifying
19*5779Sxy150489  * information: Portions Copyright [yyyy] [name of copyright owner]
20*5779Sxy150489  *
21*5779Sxy150489  * CDDL HEADER END
22*5779Sxy150489  */
23*5779Sxy150489 
24*5779Sxy150489 /*
25*5779Sxy150489  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
26*5779Sxy150489  * Use is subject to license terms of the CDDL.
27*5779Sxy150489  */
28*5779Sxy150489 
29*5779Sxy150489 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*5779Sxy150489 
31*5779Sxy150489 #include "igb_sw.h"
32*5779Sxy150489 #include "igb_debug.h"
33*5779Sxy150489 
34*5779Sxy150489 #ifdef IGB_DEBUG
35*5779Sxy150489 extern ddi_device_acc_attr_t igb_regs_acc_attr;
36*5779Sxy150489 
37*5779Sxy150489 void
38*5779Sxy150489 pci_dump(void *arg)
39*5779Sxy150489 {
40*5779Sxy150489 	igb_t *igb = (igb_t *)arg;
41*5779Sxy150489 	ddi_acc_handle_t handle;
42*5779Sxy150489 	uint8_t cap_ptr;
43*5779Sxy150489 	uint8_t next_ptr;
44*5779Sxy150489 	uint32_t msix_bar;
45*5779Sxy150489 	uint32_t msix_ctrl;
46*5779Sxy150489 	uint32_t msix_tbl_sz;
47*5779Sxy150489 	uint32_t tbl_offset;
48*5779Sxy150489 	uint32_t tbl_bir;
49*5779Sxy150489 	uint32_t pba_offset;
50*5779Sxy150489 	uint32_t pba_bir;
51*5779Sxy150489 	off_t offset;
52*5779Sxy150489 	off_t mem_size;
53*5779Sxy150489 	uintptr_t base;
54*5779Sxy150489 	ddi_acc_handle_t acc_hdl;
55*5779Sxy150489 	int i;
56*5779Sxy150489 
57*5779Sxy150489 	handle = igb->osdep.cfg_handle;
58*5779Sxy150489 
59*5779Sxy150489 	igb_log(igb, "Begin dump PCI config space");
60*5779Sxy150489 
61*5779Sxy150489 	igb_log(igb,
62*5779Sxy150489 	    "PCI_CONF_VENID:\t0x%x\n",
63*5779Sxy150489 	    pci_config_get16(handle, PCI_CONF_VENID));
64*5779Sxy150489 	igb_log(igb,
65*5779Sxy150489 	    "PCI_CONF_DEVID:\t0x%x\n",
66*5779Sxy150489 	    pci_config_get16(handle, PCI_CONF_DEVID));
67*5779Sxy150489 	igb_log(igb,
68*5779Sxy150489 	    "PCI_CONF_COMMAND:\t0x%x\n",
69*5779Sxy150489 	    pci_config_get16(handle, PCI_CONF_COMM));
70*5779Sxy150489 	igb_log(igb,
71*5779Sxy150489 	    "PCI_CONF_STATUS:\t0x%x\n",
72*5779Sxy150489 	    pci_config_get16(handle, PCI_CONF_STAT));
73*5779Sxy150489 	igb_log(igb,
74*5779Sxy150489 	    "PCI_CONF_REVID:\t0x%x\n",
75*5779Sxy150489 	    pci_config_get8(handle, PCI_CONF_REVID));
76*5779Sxy150489 	igb_log(igb,
77*5779Sxy150489 	    "PCI_CONF_PROG_CLASS:\t0x%x\n",
78*5779Sxy150489 	    pci_config_get8(handle, PCI_CONF_PROGCLASS));
79*5779Sxy150489 	igb_log(igb,
80*5779Sxy150489 	    "PCI_CONF_SUB_CLASS:\t0x%x\n",
81*5779Sxy150489 	    pci_config_get8(handle, PCI_CONF_SUBCLASS));
82*5779Sxy150489 	igb_log(igb,
83*5779Sxy150489 	    "PCI_CONF_BAS_CLASS:\t0x%x\n",
84*5779Sxy150489 	    pci_config_get8(handle, PCI_CONF_BASCLASS));
85*5779Sxy150489 	igb_log(igb,
86*5779Sxy150489 	    "PCI_CONF_CACHE_LINESZ:\t0x%x\n",
87*5779Sxy150489 	    pci_config_get8(handle, PCI_CONF_CACHE_LINESZ));
88*5779Sxy150489 	igb_log(igb,
89*5779Sxy150489 	    "PCI_CONF_LATENCY_TIMER:\t0x%x\n",
90*5779Sxy150489 	    pci_config_get8(handle, PCI_CONF_LATENCY_TIMER));
91*5779Sxy150489 	igb_log(igb,
92*5779Sxy150489 	    "PCI_CONF_HEADER_TYPE:\t0x%x\n",
93*5779Sxy150489 	    pci_config_get8(handle, PCI_CONF_HEADER));
94*5779Sxy150489 	igb_log(igb,
95*5779Sxy150489 	    "PCI_CONF_BIST:\t0x%x\n",
96*5779Sxy150489 	    pci_config_get8(handle, PCI_CONF_BIST));
97*5779Sxy150489 	igb_log(igb,
98*5779Sxy150489 	    "PCI_CONF_BASE0:\t0x%x\n",
99*5779Sxy150489 	    pci_config_get32(handle, PCI_CONF_BASE0));
100*5779Sxy150489 	igb_log(igb,
101*5779Sxy150489 	    "PCI_CONF_BASE1:\t0x%x\n",
102*5779Sxy150489 	    pci_config_get32(handle, PCI_CONF_BASE1));
103*5779Sxy150489 	igb_log(igb,
104*5779Sxy150489 	    "PCI_CONF_BASE2:\t0x%x\n",
105*5779Sxy150489 	    pci_config_get32(handle, PCI_CONF_BASE2));
106*5779Sxy150489 
107*5779Sxy150489 	/* MSI-X BAR */
108*5779Sxy150489 	msix_bar = pci_config_get32(handle, PCI_CONF_BASE3);
109*5779Sxy150489 	igb_log(igb,
110*5779Sxy150489 	    "PCI_CONF_BASE3:\t0x%x\n", msix_bar);
111*5779Sxy150489 
112*5779Sxy150489 	igb_log(igb,
113*5779Sxy150489 	    "PCI_CONF_BASE4:\t0x%x\n",
114*5779Sxy150489 	    pci_config_get32(handle, PCI_CONF_BASE4));
115*5779Sxy150489 	igb_log(igb,
116*5779Sxy150489 	    "PCI_CONF_BASE5:\t0x%x\n",
117*5779Sxy150489 	    pci_config_get32(handle, PCI_CONF_BASE5));
118*5779Sxy150489 	igb_log(igb,
119*5779Sxy150489 	    "PCI_CONF_CIS:\t0x%x\n",
120*5779Sxy150489 	    pci_config_get32(handle, PCI_CONF_CIS));
121*5779Sxy150489 	igb_log(igb,
122*5779Sxy150489 	    "PCI_CONF_SUBVENID:\t0x%x\n",
123*5779Sxy150489 	    pci_config_get16(handle, PCI_CONF_SUBVENID));
124*5779Sxy150489 	igb_log(igb,
125*5779Sxy150489 	    "PCI_CONF_SUBSYSID:\t0x%x\n",
126*5779Sxy150489 	    pci_config_get16(handle, PCI_CONF_SUBSYSID));
127*5779Sxy150489 	igb_log(igb,
128*5779Sxy150489 	    "PCI_CONF_ROM:\t0x%x\n",
129*5779Sxy150489 	    pci_config_get32(handle, PCI_CONF_ROM));
130*5779Sxy150489 
131*5779Sxy150489 	cap_ptr = pci_config_get8(handle, PCI_CONF_CAP_PTR);
132*5779Sxy150489 
133*5779Sxy150489 	igb_log(igb,
134*5779Sxy150489 	    "PCI_CONF_CAP_PTR:\t0x%x\n", cap_ptr);
135*5779Sxy150489 	igb_log(igb,
136*5779Sxy150489 	    "PCI_CONF_ILINE:\t0x%x\n",
137*5779Sxy150489 	    pci_config_get8(handle, PCI_CONF_ILINE));
138*5779Sxy150489 	igb_log(igb,
139*5779Sxy150489 	    "PCI_CONF_IPIN:\t0x%x\n",
140*5779Sxy150489 	    pci_config_get8(handle, PCI_CONF_IPIN));
141*5779Sxy150489 	igb_log(igb,
142*5779Sxy150489 	    "PCI_CONF_MIN_G:\t0x%x\n",
143*5779Sxy150489 	    pci_config_get8(handle, PCI_CONF_MIN_G));
144*5779Sxy150489 	igb_log(igb,
145*5779Sxy150489 	    "PCI_CONF_MAX_L:\t0x%x\n",
146*5779Sxy150489 	    pci_config_get8(handle, PCI_CONF_MAX_L));
147*5779Sxy150489 
148*5779Sxy150489 	/* Power Management */
149*5779Sxy150489 	offset = cap_ptr;
150*5779Sxy150489 
151*5779Sxy150489 	igb_log(igb,
152*5779Sxy150489 	    "PCI_PM_CAP_ID:\t0x%x\n",
153*5779Sxy150489 	    pci_config_get8(handle, offset));
154*5779Sxy150489 
155*5779Sxy150489 	next_ptr = pci_config_get8(handle, offset + 1);
156*5779Sxy150489 
157*5779Sxy150489 	igb_log(igb,
158*5779Sxy150489 	    "PCI_PM_NEXT_PTR:\t0x%x\n", next_ptr);
159*5779Sxy150489 	igb_log(igb,
160*5779Sxy150489 	    "PCI_PM_CAP:\t0x%x\n",
161*5779Sxy150489 	    pci_config_get16(handle, offset + PCI_PMCAP));
162*5779Sxy150489 	igb_log(igb,
163*5779Sxy150489 	    "PCI_PM_CSR:\t0x%x\n",
164*5779Sxy150489 	    pci_config_get16(handle, offset + PCI_PMCSR));
165*5779Sxy150489 	igb_log(igb,
166*5779Sxy150489 	    "PCI_PM_CSR_BSE:\t0x%x\n",
167*5779Sxy150489 	    pci_config_get8(handle, offset + PCI_PMCSR_BSE));
168*5779Sxy150489 	igb_log(igb,
169*5779Sxy150489 	    "PCI_PM_DATA:\t0x%x\n",
170*5779Sxy150489 	    pci_config_get8(handle, offset + PCI_PMDATA));
171*5779Sxy150489 
172*5779Sxy150489 	/* MSI Configuration */
173*5779Sxy150489 	offset = next_ptr;
174*5779Sxy150489 
175*5779Sxy150489 	igb_log(igb,
176*5779Sxy150489 	    "PCI_MSI_CAP_ID:\t0x%x\n",
177*5779Sxy150489 	    pci_config_get8(handle, offset));
178*5779Sxy150489 
179*5779Sxy150489 	next_ptr = pci_config_get8(handle, offset + 1);
180*5779Sxy150489 
181*5779Sxy150489 	igb_log(igb,
182*5779Sxy150489 	    "PCI_MSI_NEXT_PTR:\t0x%x\n", next_ptr);
183*5779Sxy150489 	igb_log(igb,
184*5779Sxy150489 	    "PCI_MSI_CTRL:\t0x%x\n",
185*5779Sxy150489 	    pci_config_get16(handle, offset + PCI_MSI_CTRL));
186*5779Sxy150489 	igb_log(igb,
187*5779Sxy150489 	    "PCI_MSI_ADDR:\t0x%x\n",
188*5779Sxy150489 	    pci_config_get32(handle, offset + PCI_MSI_ADDR_OFFSET));
189*5779Sxy150489 	igb_log(igb,
190*5779Sxy150489 	    "PCI_MSI_ADDR_HI:\t0x%x\n",
191*5779Sxy150489 	    pci_config_get32(handle, offset + 0x8));
192*5779Sxy150489 	igb_log(igb,
193*5779Sxy150489 	    "PCI_MSI_DATA:\t0x%x\n",
194*5779Sxy150489 	    pci_config_get16(handle, offset + 0xC));
195*5779Sxy150489 
196*5779Sxy150489 	/* MSI-X Configuration */
197*5779Sxy150489 	offset = next_ptr;
198*5779Sxy150489 
199*5779Sxy150489 	igb_log(igb,
200*5779Sxy150489 	    "PCI_MSIX_CAP_ID:\t0x%x\n",
201*5779Sxy150489 	    pci_config_get8(handle, offset));
202*5779Sxy150489 
203*5779Sxy150489 	next_ptr = pci_config_get8(handle, offset + 1);
204*5779Sxy150489 	igb_log(igb,
205*5779Sxy150489 	    "PCI_MSIX_NEXT_PTR:\t0x%x\n", next_ptr);
206*5779Sxy150489 
207*5779Sxy150489 	msix_ctrl = pci_config_get16(handle, offset + PCI_MSIX_CTRL);
208*5779Sxy150489 	msix_tbl_sz = msix_ctrl & 0x7ff;
209*5779Sxy150489 	igb_log(igb,
210*5779Sxy150489 	    "PCI_MSIX_CTRL:\t0x%x\n", msix_ctrl);
211*5779Sxy150489 
212*5779Sxy150489 	tbl_offset = pci_config_get32(handle, offset + PCI_MSIX_TBL_OFFSET);
213*5779Sxy150489 	tbl_bir = tbl_offset & PCI_MSIX_TBL_BIR_MASK;
214*5779Sxy150489 	tbl_offset = tbl_offset & ~PCI_MSIX_TBL_BIR_MASK;
215*5779Sxy150489 	igb_log(igb,
216*5779Sxy150489 	    "PCI_MSIX_TBL_OFFSET:\t0x%x\n", tbl_offset);
217*5779Sxy150489 	igb_log(igb,
218*5779Sxy150489 	    "PCI_MSIX_TBL_BIR:\t0x%x\n", tbl_bir);
219*5779Sxy150489 
220*5779Sxy150489 	pba_offset = pci_config_get32(handle, offset + PCI_MSIX_PBA_OFFSET);
221*5779Sxy150489 	pba_bir = pba_offset & PCI_MSIX_PBA_BIR_MASK;
222*5779Sxy150489 	pba_offset = pba_offset & ~PCI_MSIX_PBA_BIR_MASK;
223*5779Sxy150489 	igb_log(igb,
224*5779Sxy150489 	    "PCI_MSIX_PBA_OFFSET:\t0x%x\n", pba_offset);
225*5779Sxy150489 	igb_log(igb,
226*5779Sxy150489 	    "PCI_MSIX_PBA_BIR:\t0x%x\n", pba_bir);
227*5779Sxy150489 
228*5779Sxy150489 	/* PCI Express Configuration */
229*5779Sxy150489 	offset = next_ptr;
230*5779Sxy150489 
231*5779Sxy150489 	igb_log(igb,
232*5779Sxy150489 	    "PCIE_CAP_ID:\t0x%x\n",
233*5779Sxy150489 	    pci_config_get8(handle, offset + PCIE_CAP_ID));
234*5779Sxy150489 
235*5779Sxy150489 	next_ptr = pci_config_get8(handle, offset + PCIE_CAP_NEXT_PTR);
236*5779Sxy150489 
237*5779Sxy150489 	igb_log(igb,
238*5779Sxy150489 	    "PCIE_CAP_NEXT_PTR:\t0x%x\n", next_ptr);
239*5779Sxy150489 	igb_log(igb,
240*5779Sxy150489 	    "PCIE_PCIECAP:\t0x%x\n",
241*5779Sxy150489 	    pci_config_get16(handle, offset + PCIE_PCIECAP));
242*5779Sxy150489 	igb_log(igb,
243*5779Sxy150489 	    "PCIE_DEVCAP:\t0x%x\n",
244*5779Sxy150489 	    pci_config_get32(handle, offset + PCIE_DEVCAP));
245*5779Sxy150489 	igb_log(igb,
246*5779Sxy150489 	    "PCIE_DEVCTL:\t0x%x\n",
247*5779Sxy150489 	    pci_config_get16(handle, offset + PCIE_DEVCTL));
248*5779Sxy150489 	igb_log(igb,
249*5779Sxy150489 	    "PCIE_DEVSTS:\t0x%x\n",
250*5779Sxy150489 	    pci_config_get16(handle, offset + PCIE_DEVSTS));
251*5779Sxy150489 	igb_log(igb,
252*5779Sxy150489 	    "PCIE_LINKCAP:\t0x%x\n",
253*5779Sxy150489 	    pci_config_get32(handle, offset + PCIE_LINKCAP));
254*5779Sxy150489 	igb_log(igb,
255*5779Sxy150489 	    "PCIE_LINKCTL:\t0x%x\n",
256*5779Sxy150489 	    pci_config_get16(handle, offset + PCIE_LINKCTL));
257*5779Sxy150489 	igb_log(igb,
258*5779Sxy150489 	    "PCIE_LINKSTS:\t0x%x\n",
259*5779Sxy150489 	    pci_config_get16(handle, offset + PCIE_LINKSTS));
260*5779Sxy150489 
261*5779Sxy150489 	/* MSI-X Memory Space */
262*5779Sxy150489 	if (ddi_dev_regsize(igb->dip, 4, &mem_size) != DDI_SUCCESS) {
263*5779Sxy150489 		igb_log(igb, "ddi_dev_regsize() failed");
264*5779Sxy150489 		return;
265*5779Sxy150489 	}
266*5779Sxy150489 
267*5779Sxy150489 	if ((ddi_regs_map_setup(igb->dip, 4, (caddr_t *)&base, 0, mem_size,
268*5779Sxy150489 	    &igb_regs_acc_attr, &acc_hdl)) != DDI_SUCCESS) {
269*5779Sxy150489 		igb_log(igb, "ddi_regs_map_setup() failed");
270*5779Sxy150489 		return;
271*5779Sxy150489 	}
272*5779Sxy150489 
273*5779Sxy150489 	igb_log(igb, "MSI-X Memory Space: (mem_size = %d, base = %x)",
274*5779Sxy150489 	    mem_size, base);
275*5779Sxy150489 
276*5779Sxy150489 	for (i = 0; i <= msix_tbl_sz; i++) {
277*5779Sxy150489 		igb_log(igb, "MSI-X Table Entry(%d):", i);
278*5779Sxy150489 		igb_log(igb, "lo_addr:\t%x",
279*5779Sxy150489 		    ddi_get32(acc_hdl,
280*5779Sxy150489 		    (uint32_t *)(base + tbl_offset + (i * 16))));
281*5779Sxy150489 		igb_log(igb, "up_addr:\t%x",
282*5779Sxy150489 		    ddi_get32(acc_hdl,
283*5779Sxy150489 		    (uint32_t *)(base + tbl_offset + (i * 16) + 4)));
284*5779Sxy150489 		igb_log(igb, "msg_data:\t%x",
285*5779Sxy150489 		    ddi_get32(acc_hdl,
286*5779Sxy150489 		    (uint32_t *)(base + tbl_offset + (i * 16) + 8)));
287*5779Sxy150489 		igb_log(igb, "vct_ctrl:\t%x",
288*5779Sxy150489 		    ddi_get32(acc_hdl,
289*5779Sxy150489 		    (uint32_t *)(base + tbl_offset + (i * 16) + 12)));
290*5779Sxy150489 	}
291*5779Sxy150489 
292*5779Sxy150489 	igb_log(igb, "MSI-X Pending Bits:\t%x",
293*5779Sxy150489 	    ddi_get32(acc_hdl, (uint32_t *)(base + pba_offset)));
294*5779Sxy150489 
295*5779Sxy150489 	ddi_regs_map_free(&acc_hdl);
296*5779Sxy150489 }
297*5779Sxy150489 #endif
298