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