xref: /illumos-gate/usr/src/uts/common/sys/pcie.h (revision d7574e9a)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 /*
26  * Copyright 2019 Joyent, Inc.
27  * Copyright 2023 Oxide Computer Company
28  */
29 
30 #ifndef	_SYS_PCIE_H
31 #define	_SYS_PCIE_H
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #include <sys/pci.h>
38 
39 /*
40  * PCI Express capability registers in PCI configuration space relative to
41  * the PCI Express Capability structure.
42  */
43 #define	PCIE_CAP_ID			PCI_CAP_ID
44 #define	PCIE_CAP_NEXT_PTR		PCI_CAP_NEXT_PTR
45 #define	PCIE_PCIECAP			0x02	/* PCI-e Capability Reg */
46 #define	PCIE_DEVCAP			0x04	/* Device Capability */
47 #define	PCIE_DEVCTL			0x08	/* Device Control */
48 #define	PCIE_DEVSTS			0x0A	/* Device Status */
49 #define	PCIE_LINKCAP			0x0C	/* Link Capability */
50 #define	PCIE_LINKCTL			0x10	/* Link Control */
51 #define	PCIE_LINKSTS			0x12	/* Link Status */
52 #define	PCIE_SLOTCAP			0x14	/* Slot Capability */
53 #define	PCIE_SLOTCTL			0x18	/* Slot Control */
54 #define	PCIE_SLOTSTS			0x1A	/* Slot Status */
55 #define	PCIE_ROOTCTL			0x1C	/* Root Control */
56 #define	PCIE_ROOTCAP			0x1E	/* Root Capabilities */
57 #define	PCIE_ROOTSTS			0x20	/* Root Status */
58 #define	PCIE_DEVCAP2			0x24	/* Device Capability 2 */
59 #define	PCIE_DEVCTL2			0x28	/* Device Control 2 */
60 #define	PCIE_DEVSTS2			0x2A	/* Device Status 2 */
61 #define	PCIE_LINKCAP2			0x2C	/* Link Capability 2 */
62 #define	PCIE_LINKCTL2			0x30	/* Link Control 2 */
63 #define	PCIE_LINKSTS2			0x32	/* Link Status 2 */
64 #define	PCIE_SLOTCAP2			0x34	/* Slot Capability 2 */
65 #define	PCIE_SLOTCTL2			0x38	/* Slot Control 2 */
66 #define	PCIE_SLOTSTS2			0x3A	/* Slot Status 2 */
67 
68 /*
69  * PCI-Express Config Space size
70  */
71 #define	PCIE_CONF_HDR_SIZE	4096	/* PCIe configuration header size */
72 
73 /*
74  * PCI-Express Capabilities Register (2 bytes)
75  */
76 #define	PCIE_PCIECAP_VER_1_0		0x1	/* PCI-E spec 1.0 */
77 #define	PCIE_PCIECAP_VER_2_0		0x2	/* PCI-E spec 2.0 */
78 #define	PCIE_PCIECAP_VER_MASK		0xF	/* Version Mask */
79 #define	PCIE_PCIECAP_DEV_TYPE_PCIE_DEV	0x00	/* PCI-E Endpont Device */
80 #define	PCIE_PCIECAP_DEV_TYPE_PCI_DEV	0x10	/* "Leg PCI" Endpont Device */
81 #define	PCIE_PCIECAP_DEV_TYPE_ROOT	0x40	/* Root Port of Root Complex */
82 #define	PCIE_PCIECAP_DEV_TYPE_UP	0x50	/* Upstream Port of Switch */
83 #define	PCIE_PCIECAP_DEV_TYPE_DOWN	0x60	/* Downstream Port of Switch */
84 #define	PCIE_PCIECAP_DEV_TYPE_PCIE2PCI	0x70	/* PCI-E to PCI Bridge */
85 #define	PCIE_PCIECAP_DEV_TYPE_PCI2PCIE	0x80	/* PCI to PCI-E Bridge */
86 #define	PCIE_PCIECAP_DEV_TYPE_RC_IEP	0x90	/* RootComplex Integrated Dev */
87 #define	PCIE_PCIECAP_DEV_TYPE_RC_EC	0xA0	/* RootComplex Evt Collector */
88 #define	PCIE_PCIECAP_DEV_TYPE_MASK	0xF0	/* Device/Port Type Mask */
89 #define	PCIE_PCIECAP_SLOT_IMPL		0x100	/* Slot Impl vs Integrated */
90 #define	PCIE_PCIECAP_INT_MSG_NUM	0x3E00	/* Interrupt Message Number */
91 
92 /*
93  * Device Capabilities Register (4 bytes)
94  */
95 #define	PCIE_DEVCAP_MAX_PAYLOAD_128	0x0
96 #define	PCIE_DEVCAP_MAX_PAYLOAD_256	0x1
97 #define	PCIE_DEVCAP_MAX_PAYLOAD_512	0x2
98 #define	PCIE_DEVCAP_MAX_PAYLOAD_1024	0x3
99 #define	PCIE_DEVCAP_MAX_PAYLOAD_2048	0x4
100 #define	PCIE_DEVCAP_MAX_PAYLOAD_4096	0x5
101 #define	PCIE_DEVCAP_MAX_PAYLOAD_MASK	0x7	/* Max Payload Size Supported */
102 
103 #define	PCIE_DEVCAP_PHTM_FUNC_NONE	0x00	/* No Function # bits used */
104 #define	PCIE_DEVCAP_PHTM_FUNC_ONE	0x08	/* First most sig. bit used */
105 #define	PCIE_DEVCAP_PHTM_FUNC_TWO	0x10	/* First 2 most sig bit used */
106 #define	PCIE_DEVCAP_PHTM_FUNC_THREE	0x18	/* All 3 bits used */
107 #define	PCIE_DEVCAP_PHTM_FUNC_MASK	0x18	/* Phantom Func Supported */
108 
109 #define	PCIE_DEVCAP_EXT_TAG_5BIT	0x00	/* 5-Bit Tag Field Supported */
110 #define	PCIE_DEVCAP_EXT_TAG_8BIT	0x20	/* 8-Bit Tag Field Supported */
111 #define	PCIE_DEVCAP_EXT_TAG_MASK	0x20	/* Ext. Tag Field Supported */
112 
113 #define	PCIE_DEVCAP_EP_L0S_LAT_MIN	0x000	/* < 64 ns */
114 #define	PCIE_DEVCAP_EP_L0S_LAT_64ns	0x040	/* 64 ns - 128 ns */
115 #define	PCIE_DEVCAP_EP_L0S_LAT_128ns	0x080	/* 128 ns - 256 ns */
116 #define	PCIE_DEVCAP_EP_L0S_LAT_256ns	0x0C0	/* 256 ns - 512 ns */
117 #define	PCIE_DEVCAP_EP_L0S_LAT_512ns	0x100	/* 512 ns - 1 us */
118 #define	PCIE_DEVCAP_EP_L0S_LAT_1us	0x140	/* 1 us - 2 us */
119 #define	PCIE_DEVCAP_EP_L0S_LAT_2us	0x180	/* 2 us - 4 us */
120 #define	PCIE_DEVCAP_EP_L0S_LAT_MAX	0x1C0	/* > 4 us */
121 #define	PCIE_DEVCAP_EP_L0S_LAT_MASK	0x1C0	/* EP L0s Accetable Latency */
122 
123 #define	PCIE_DEVCAP_EP_L1_LAT_MIN	0x000	/* < 1 us */
124 #define	PCIE_DEVCAP_EP_L1_LAT_1us	0x140	/* 1 us - 2 us */
125 #define	PCIE_DEVCAP_EP_L1_LAT_2us	0x180	/* 2 us - 4 us */
126 #define	PCIE_DEVCAP_EP_L1_LAT_4us	0x140	/* 4 us - 8 us */
127 #define	PCIE_DEVCAP_EP_L1_LAT_8us	0x180	/* 8 us - 16 us */
128 #define	PCIE_DEVCAP_EP_L1_LAT_16us	0x140	/* 16 us - 32 us */
129 #define	PCIE_DEVCAP_EP_L1_LAT_32us	0x180	/* 32 us - 64 us */
130 #define	PCIE_DEVCAP_EP_L1_LAT_MAX	0x1C0	/* > 64 us */
131 #define	PCIE_DEVCAP_EP_L1_LAT_MASK	0x700	/* EP L1 Accetable Latency */
132 
133 /*
134  * As of PCIe 2.x these three bits are now undefined.
135  */
136 #define	PCIE_DEVCAP_ATTN_BUTTON		0x1000	/* Attention Button Present */
137 #define	PCIE_DEVCAP_ATTN_INDICATOR	0x2000	/* Attn Indicator Present */
138 #define	PCIE_DEVCAP_PWR_INDICATOR	0x4000	/* Power Indicator Present */
139 
140 #define	PCIE_DEVCAP_ROLE_BASED_ERR_REP	0x8000	/* Role Based Error Reporting */
141 
142 #define	PCIE_DEVCAP_PLMT_VAL_SHIFT	18	/* Power Limit Value Shift */
143 #define	PCIE_DEVCAP_PLMT_VAL_MASK	0xFF	/* Power Limit Value Mask */
144 
145 #define	PCIE_DEVCAP_PLMT_SCL_1_BY_1	0x0000000	/* 1x Scale */
146 #define	PCIE_DEVCAP_PLMT_SCL_1_BY_10	0x4000000	/* 0.1x Scale */
147 #define	PCIE_DEVCAP_PLMT_SCL_1_BY_100	0x8000000	/* 0.01x Scale */
148 #define	PCIE_DEVCAP_PLMT_SCL_1_BY_1000	0xC000000	/* 0.001x Scale */
149 #define	PCIE_DEVCAP_PLMT_SCL_MASK	0xC000000	/* Power Limit Scale */
150 
151 #define	PCIE_DEVCAP_FLR			0x10000000 /* Function Level Reset */
152 
153 /*
154  * Device Control Register (2 bytes)
155  */
156 #define	PCIE_DEVCTL_CE_REPORTING_EN	0x1	/* Correctable Error Enable */
157 #define	PCIE_DEVCTL_NFE_REPORTING_EN	0x2	/* Non-Fatal Error Enable */
158 #define	PCIE_DEVCTL_FE_REPORTING_EN	0x4	/* Fatal Error Enable */
159 #define	PCIE_DEVCTL_UR_REPORTING_EN	0x8	/* Unsupported Request Enable */
160 #define	PCIE_DEVCTL_ERR_MASK		0xF	/* All of the above bits */
161 
162 #define	PCIE_DEVCTL_RO_EN		0x10	/* Enable Relaxed Ordering */
163 
164 #define	PCIE_DEVCTL_MAX_PAYLOAD_128	0x00
165 #define	PCIE_DEVCTL_MAX_PAYLOAD_256	0x20
166 #define	PCIE_DEVCTL_MAX_PAYLOAD_512	0x40
167 #define	PCIE_DEVCTL_MAX_PAYLOAD_1024	0x60
168 #define	PCIE_DEVCTL_MAX_PAYLOAD_2048	0x80
169 #define	PCIE_DEVCTL_MAX_PAYLOAD_4096	0xA0
170 #define	PCIE_DEVCTL_MAX_PAYLOAD_MASK	0xE0	/* Max_Payload_Size */
171 #define	PCIE_DEVCTL_MAX_PAYLOAD_SHIFT	0x5
172 
173 #define	PCIE_DEVCTL_EXT_TAG_FIELD_EN	0x100	/* Extended Tag Field Enable */
174 #define	PCIE_DEVCTL_PHTM_FUNC_EN	0x200	/* Phantom Functions Enable */
175 #define	PCIE_DEVCTL_AUX_POWER_PM_EN	0x400	/* Auxiliary Power PM Enable */
176 #define	PCIE_DEVCTL_ENABLE_NO_SNOOP	0x800	/* Enable No Snoop */
177 
178 #define	PCIE_DEVCTL_MAX_READ_REQ_128	0x0000
179 #define	PCIE_DEVCTL_MAX_READ_REQ_256	0x1000
180 #define	PCIE_DEVCTL_MAX_READ_REQ_512	0x2000
181 #define	PCIE_DEVCTL_MAX_READ_REQ_1024	0x3000
182 #define	PCIE_DEVCTL_MAX_READ_REQ_2048	0x4000
183 #define	PCIE_DEVCTL_MAX_READ_REQ_4096	0x5000
184 #define	PCIE_DEVCTL_MAX_READ_REQ_MASK	0x7000	/* Max_Read_Request_Size */
185 #define	PCIE_DEVCTL_MAX_READ_REQ_SHIFT	0xC
186 
187 #define	PCIE_DEVCTL_BRIDGE_RETRY	0x8000	/* Bridge can return CRS */
188 #define	PCIE_DEVCTL_INITIATE_FLR	0x8000	/* Start Function Level Reset */
189 
190 /*
191  * Device Status Register (2 bytes)
192  */
193 #define	PCIE_DEVSTS_CE_DETECTED		0x1	/* Correctable Error Detected */
194 #define	PCIE_DEVSTS_NFE_DETECTED	0x2	/* Non Fatal Error Detected */
195 #define	PCIE_DEVSTS_FE_DETECTED		0x4	/* Fatal Error Detected */
196 #define	PCIE_DEVSTS_UR_DETECTED		0x8	/* Unsupported Req Detected */
197 #define	PCIE_DEVSTS_AUX_POWER		0x10	/* AUX Power Detected */
198 #define	PCIE_DEVSTS_TRANS_PENDING	0x20	/* Transactions Pending */
199 #define	PCIE_DEVSTS_EPR_DETECTED	0x40	/* Emergency Power Reduction */
200 
201 /*
202  * Link Capability Register (4 bytes)
203  */
204 #define	PCIE_LINKCAP_MAX_SPEED_2_5	0x1	/* 2.5 GT/s Speed */
205 /*
206  * In version 2 of PCI express, this indicated that both 5.0 GT/s and 2.5 GT/s
207  * speeds were supported. The use of this as the maximum link speed was added
208  * with PCIe v3.
209  */
210 #define	PCIE_LINKCAP_MAX_SPEED_5	0x2	/* 5.0 GT/s Speed */
211 #define	PCIE_LINKCAP_MAX_SPEED_8	0x3	/* 8.0 GT/s Speed */
212 #define	PCIE_LINKCAP_MAX_SPEED_16	0x4	/* 16.0 GT/s Speed */
213 #define	PCIE_LINKCAP_MAX_SPEED_32	0x5	/* 32.0 GT/s Speed */
214 #define	PCIE_LINKCAP_MAX_SPEED_64	0x6	/* 64.0 GT/s Speed */
215 #define	PCIE_LINKCAP_MAX_SPEED_MASK	0xF	/* Maximum Link Speed */
216 #define	PCIE_LINKCAP_MAX_WIDTH_X1	0x010
217 #define	PCIE_LINKCAP_MAX_WIDTH_X2	0x020
218 #define	PCIE_LINKCAP_MAX_WIDTH_X4	0x040
219 #define	PCIE_LINKCAP_MAX_WIDTH_X8	0x080
220 #define	PCIE_LINKCAP_MAX_WIDTH_X12	0x0C0
221 #define	PCIE_LINKCAP_MAX_WIDTH_X16	0x100
222 #define	PCIE_LINKCAP_MAX_WIDTH_X32	0x200
223 #define	PCIE_LINKCAP_MAX_WIDTH_MASK	0x3f0	/* Maximum Link Width */
224 
225 #define	PCIE_LINKCAP_ASPM_SUP_L0S	0x400	/* L0s Entry Supported */
226 #define	PCIE_LINKCAP_ASPM_SUP_L1	0x800	/* L1 Entry Supported */
227 #define	PCIE_LINKCAP_ASPM_SUP_L0S_L1	0xC00	/* L0s abd L1 Supported */
228 #define	PCIE_LINKCAP_ASPM_SUP_MASK	0xC00	/* ASPM Support */
229 
230 #define	PCIE_LINKCAP_L0S_EXIT_LAT_MIN	0x0000	/* < 64 ns */
231 #define	PCIE_LINKCAP_L0S_EXIT_LAT_64ns	0x1000	/* 64 ns - 128 ns */
232 #define	PCIE_LINKCAP_L0S_EXIT_LAT_128ns	0x2000	/* 128 ns - 256 ns */
233 #define	PCIE_LINKCAP_L0S_EXIT_LAT_256ns	0x3000	/* 256 ns - 512 ns */
234 #define	PCIE_LINKCAP_L0S_EXIT_LAT_512ns	0x4000	/* 512 ns - 1 us */
235 #define	PCIE_LINKCAP_L0S_EXIT_LAT_1us	0x5000	/* 1 us - 2 us */
236 #define	PCIE_LINKCAP_L0S_EXIT_LAT_2us	0x6000	/* 2 us - 4 us */
237 #define	PCIE_LINKCAP_L0S_EXIT_LAT_MAX	0x7000	/* > 4 us */
238 #define	PCIE_LINKCAP_L0S_EXIT_LAT_MASK	0x7000	/* L0s Exit Latency */
239 
240 #define	PCIE_LINKCAP_L1_EXIT_LAT_MIN	0x00000	/* < 1 us */
241 #define	PCIE_LINKCAP_L1_EXIT_LAT_1us	0x08000	/* 1 us - 2 us */
242 #define	PCIE_LINKCAP_L1_EXIT_LAT_2us	0x10000	/* 2 us - 4 us */
243 #define	PCIE_LINKCAP_L1_EXIT_LAT_4us	0x18000	/* 4 us - 8 us */
244 #define	PCIE_LINKCAP_L1_EXIT_LAT_8us	0x20000	/* 8 us - 16 us */
245 #define	PCIE_LINKCAP_L1_EXIT_LAT_16us	0x28000	/* 16 us - 32 us */
246 #define	PCIE_LINKCAP_L1_EXIT_LAT_32us	0x30000	/* 32 us - 64 us */
247 #define	PCIE_LINKCAP_L1_EXIT_LAT_MAX	0x38000	/* > 64 us */
248 #define	PCIE_LINKCAP_L1_EXIT_LAT_MASK	0x38000	/* L1 Exit Latency */
249 
250 #define	PCIE_LINKCAP_CLOCK_POWER_MGMT	0x40000	/* Clock Power Management */
251 #define	PCIE_LINKCAP_SDER_CAP		0x80000 /* Surprise Down Err report */
252 #define	PCIE_LINKCAP_DLL_ACTIVE_REP_CAPABLE	0x100000    /* DLL Active */
253 							    /* Capable bit */
254 #define	PCIE_LINKCAP_LINK_BW_NOTIFY_CAP	0x200000 /* Link Bandwidth Notify Cap */
255 #define	PCIE_LINKCAP_ASPM_OPTIONAL	0x400000 /* ASPM Opt. Comp. */
256 
257 #define	PCIE_LINKCAP_PORT_NUMBER	0xFF000000	/* Port Number */
258 #define	PCIE_LINKCAP_PORT_NUMBER_SHIFT	24	/* Port Number Shift */
259 #define	PCIE_LINKCAP_PORT_NUMBER_MASK	0xFF	/* Port Number Mask */
260 
261 /*
262  * Link Control Register (2 bytes)
263  */
264 #define	PCIE_LINKCTL_ASPM_CTL_DIS	0x0	/* ASPM Disable */
265 #define	PCIE_LINKCTL_ASPM_CTL_L0S	0x1	/* ASPM L0s only */
266 #define	PCIE_LINKCTL_ASPM_CTL_L1	0x2	/* ASPM L1 only */
267 #define	PCIE_LINKCTL_ASPM_CTL_L0S_L1	0x3	/* ASPM L0s and L1 only */
268 #define	PCIE_LINKCTL_ASPM_CTL_MASK	0x3	/* ASPM Control */
269 
270 #define	PCIE_LINKCTL_RCB_64_BYTE	0x0	/* 64 Byte */
271 #define	PCIE_LINKCTL_RCB_128_BYTE	0x8	/* 128 Byte */
272 #define	PCIE_LINKCTL_RCB_MASK		0x8	/* Read Completion Boundary */
273 
274 #define	PCIE_LINKCTL_LINK_DISABLE	0x10	/* Link Disable */
275 #define	PCIE_LINKCTL_RETRAIN_LINK	0x20	/* Retrain Link */
276 #define	PCIE_LINKCTL_COMMON_CLK_CFG	0x40	/* Common Clock Configuration */
277 #define	PCIE_LINKCTL_EXT_SYNCH		0x80	/* Extended Synch */
278 #define	PCIE_LINKCTL_CLOCK_POWER_MGMT	0x100	/* Enable Clock Power Mgmt. */
279 #define	PCIE_LINKCTL_HW_WIDTH_DISABLE	0x200	/* hw auto width disable */
280 #define	PCIE_LINKCTL_LINK_BW_INTR_EN	0x400	/* Link bw mgmt intr */
281 #define	PCIE_LINKCTL_LINK_AUTO_BW_INTR_EN	0x800	/* Auto bw intr */
282 
283 #define	PCI_LINKCTRL_DRS_SIG_CTRL_NO_REP	0x00
284 #define	PCI_LINKCTRL_DRS_SIG_CTRL_IE		0x4000
285 #define	PCI_LINKCTRL_DRS_SIG_CTRL_DRS_FRS	0x8000
286 #define	PCIE_LINKCTL_DRS_SIG_CTRL_MASK	0xC000	/* DRS Signaling Control */
287 
288 /*
289  * Link Status Register (2 bytes)
290  */
291 #define	PCIE_LINKSTS_SPEED_2_5		0x1	/* 2.5 GT/s Link Speed */
292 #define	PCIE_LINKSTS_SPEED_5		0x2	/* 5.0 GT/s Link Speed */
293 #define	PCIE_LINKSTS_SPEED_8		0x3	/* 8.0 GT/s Link Speed */
294 #define	PCIE_LINKSTS_SPEED_16		0x4	/* 16.0 GT/s Link Speed */
295 #define	PCIE_LINKSTS_SPEED_32		0x5	/* 32.0 GT/s Link Speed */
296 #define	PCIE_LINKSTS_SPEED_64		0x6	/* 64.0 GT/s Link Speed */
297 #define	PCIE_LINKSTS_SPEED_MASK		0xF	/* Link Speed */
298 
299 #define	PCIE_LINKSTS_NEG_WIDTH_X1	0x010
300 #define	PCIE_LINKSTS_NEG_WIDTH_X2	0x020
301 #define	PCIE_LINKSTS_NEG_WIDTH_X4	0x040
302 #define	PCIE_LINKSTS_NEG_WIDTH_X8	0x080
303 #define	PCIE_LINKSTS_NEG_WIDTH_X12	0x0C0
304 #define	PCIE_LINKSTS_NEG_WIDTH_X16	0x100
305 #define	PCIE_LINKSTS_NEG_WIDTH_X32	0x200
306 #define	PCIE_LINKSTS_NEG_WIDTH_MASK	0x3F0	/* Negotiated Link Width */
307 
308 /* This bit is undefined as of PCIe 2.x */
309 #define	PCIE_LINKSTS_TRAINING_ERROR	0x400	/* Training Error */
310 #define	PCIE_LINKSTS_LINK_TRAINING	0x800	/* Link Training */
311 #define	PCIE_LINKSTS_SLOT_CLK_CFG	0x1000	/* Slot Clock Configuration */
312 #define	PCIE_LINKSTS_DLL_LINK_ACTIVE	0x2000	/* DLL Link Active */
313 #define	PCIE_LINKSTS_LINK_BW_MGMT	0x4000	/* Link bw mgmt status */
314 #define	PCIE_LINKSTS_AUTO_BW		0x8000	/* Link auto BW status */
315 
316 /*
317  * Slot Capability Register (4 bytes)
318  */
319 #define	PCIE_SLOTCAP_ATTN_BUTTON	0x1	/* Attention Button Present */
320 #define	PCIE_SLOTCAP_POWER_CONTROLLER	0x2	/* Power Controller Present */
321 #define	PCIE_SLOTCAP_MRL_SENSOR		0x4	/* MRL Sensor Present */
322 #define	PCIE_SLOTCAP_ATTN_INDICATOR	0x8	/* Attn Indicator Present */
323 #define	PCIE_SLOTCAP_PWR_INDICATOR	0x10	/* Power Indicator Present */
324 #define	PCIE_SLOTCAP_HP_SURPRISE	0x20	/* Hot-Plug Surprise */
325 #define	PCIE_SLOTCAP_HP_CAPABLE		0x40	/* Hot-Plug Capable */
326 
327 #define	PCIE_SLOTCAP_PLMT_VAL_SHIFT	7	/* Slot Pwr Limit Value Shift */
328 #define	PCIE_SLOTCAP_PLMT_VAL_MASK	0xFF	/* Slot Pwr Limit Value */
329 
330 #define	PCIE_SLOTCAP_PLMT_SCL_1_BY_1	0x00000	/* 1x Scale */
331 #define	PCIE_SLOTCAP_PLMT_SCL_1_BY_10	0x08000	/* 0.1x Scale */
332 #define	PCIE_SLOTCAP_PLMT_SCL_1_BY_100	0x10000	/* 0.01x Scale */
333 #define	PCIE_SLOTCAP_PLMT_SCL_1_BY_1000	0x18000	/* 0.001x Scale */
334 #define	PCIE_SLOTCAP_PLMT_SCL_MASK	0x18000	/* Slot Power Limit Scale */
335 #define	PCIE_SLOTCAP_EMI_LOCK_PRESENT	0x20000 /* EMI Lock Present */
336 #define	PCIE_SLOTCAP_NO_CMD_COMP_SUPP	0x40000 /* No Command Comp. Supported */
337 
338 #define	PCIE_SLOTCAP_PHY_SLOT_NUM_SHIFT	19	/* Physical Slot Num Shift */
339 #define	PCIE_SLOTCAP_PHY_SLOT_NUM_MASK	0x1FFF	/* Physical Slot Num Mask */
340 
341 #define	PCIE_SLOTCAP_PHY_SLOT_NUM(reg) \
342 	    (((reg) >> PCIE_SLOTCAP_PHY_SLOT_NUM_SHIFT) & \
343 	    PCIE_SLOTCAP_PHY_SLOT_NUM_MASK)
344 
345 /*
346  * Slot Control Register (2 bytes)
347  */
348 #define	PCIE_SLOTCTL_ATTN_BTN_EN	0x1	/* Attn Button Pressed Enable */
349 #define	PCIE_SLOTCTL_PWR_FAULT_EN	0x2	/* Pwr Fault Detected Enable */
350 #define	PCIE_SLOTCTL_MRL_SENSOR_EN	0x4	/* MRL Sensor Changed Enable */
351 #define	PCIE_SLOTCTL_PRESENCE_CHANGE_EN	0x8	/* Presence Detect Changed En */
352 #define	PCIE_SLOTCTL_CMD_INTR_EN	0x10	/* CMD Completed Interrupt En */
353 #define	PCIE_SLOTCTL_HP_INTR_EN		0x20	/* Hot-Plug Interrupt Enable */
354 #define	PCIE_SLOTCTL_PWR_CONTROL	0x0400	/* Power controller Control */
355 #define	PCIE_SLOTCTL_EMI_LOCK_CONTROL	0x0800	/* EMI Lock control */
356 #define	PCIE_SLOTCTL_DLL_STATE_EN	0x1000	/* DLL State Changed En */
357 #define	PCIE_SLOTCTL_AUTO_SLOT_PL_DIS	0x2000	/* Auto Slot Power Limit Dis */
358 #define	PCIE_SLOTCTL_ATTN_INDICATOR_MASK 0x00C0	/* Attn Indicator mask */
359 #define	PCIE_SLOTCTL_PWR_INDICATOR_MASK	0x0300	/* Power Indicator mask */
360 #define	PCIE_SLOTCTL_INTR_MASK		0x103f	/* Supported intr mask */
361 
362 /* State values for the Power and Attention Indicators */
363 #define	PCIE_SLOTCTL_INDICATOR_STATE_ON		0x1	/* indicator ON */
364 #define	PCIE_SLOTCTL_INDICATOR_STATE_BLINK	0x2	/* indicator BLINK */
365 #define	PCIE_SLOTCTL_INDICATOR_STATE_OFF	0x3	/* indicator OFF */
366 
367 /*
368  * Macros to set/get the state of Power and Attention Indicators
369  * in the PCI Express Slot Control Register.
370  */
371 #define	pcie_slotctl_pwr_indicator_get(reg)	\
372 	(((reg) & PCIE_SLOTCTL_PWR_INDICATOR_MASK) >> 8)
373 #define	pcie_slotctl_attn_indicator_get(ctrl)	\
374 	(((ctrl) & PCIE_SLOTCTL_ATTN_INDICATOR_MASK) >> 6)
375 #define	pcie_slotctl_attn_indicator_set(ctrl, v)\
376 	(((ctrl) & ~PCIE_SLOTCTL_ATTN_INDICATOR_MASK) | ((v) << 6))
377 #define	pcie_slotctl_pwr_indicator_set(ctrl, v)\
378 	(((ctrl) & ~PCIE_SLOTCTL_PWR_INDICATOR_MASK) | ((v) << 8))
379 
380 /*
381  * Slot Status register (2 bytes)
382  */
383 #define	PCIE_SLOTSTS_ATTN_BTN_PRESSED	0x1	/* Attention Button Pressed */
384 #define	PCIE_SLOTSTS_PWR_FAULT_DETECTED	0x2	/* Power Fault Detected */
385 #define	PCIE_SLOTSTS_MRL_SENSOR_CHANGED	0x4	/* MRL Sensor Changed */
386 #define	PCIE_SLOTSTS_PRESENCE_CHANGED	0x8	/* Presence Detect Changed */
387 #define	PCIE_SLOTSTS_COMMAND_COMPLETED	0x10	/* Command Completed */
388 #define	PCIE_SLOTSTS_MRL_SENSOR_OPEN	0x20	/* MRL Sensor Open */
389 #define	PCIE_SLOTSTS_PRESENCE_DETECTED	0x40	/* Card Present in slot */
390 #define	PCIE_SLOTSTS_EMI_LOCK_SET	0x0080	/* EMI Lock set */
391 #define	PCIE_SLOTSTS_DLL_STATE_CHANGED	0x0100	/* DLL State Changed */
392 #define	PCIE_SLOTSTS_STATUS_EVENTS	0x11f	/* Supported events */
393 
394 /*
395  * Root Control Register (2 bytes)
396  */
397 #define	PCIE_ROOTCTL_SYS_ERR_ON_CE_EN	0x1	/* Sys Err on Cor Err Enable */
398 #define	PCIE_ROOTCTL_SYS_ERR_ON_NFE_EN	0x2	/* Sys Err on NF Err Enable */
399 #define	PCIE_ROOTCTL_SYS_ERR_ON_FE_EN	0x4	/* Sys Err on Fatal Err En */
400 #define	PCIE_ROOTCTL_PME_INTERRUPT_EN	0x8	/* PME Interrupt Enable */
401 #define	PCIE_ROOTCTL_CRS_SW_VIS_EN	0x10	/* CRS SW Visibility EN */
402 
403 /*
404  * Root Capabilities register (2 bytes)
405  */
406 #define	PCIE_ROOTCAP_CRS_SW_VIS		0x01	/* CRS SW Visible */
407 
408 /*
409  * Root Status Register (4 bytes)
410  */
411 #define	PCIE_ROOTSTS_PME_REQ_ID_SHIFT	0	/* PME Requestor ID */
412 #define	PCIE_ROOTSTS_PME_REQ_ID_MASK	0xFFFF	/* PME Requestor ID */
413 
414 #define	PCIE_ROOTSTS_PME_STATUS		0x10000	/* PME Status */
415 #define	PCIE_ROOTSTS_PME_PENDING	0x20000	/* PME Pending */
416 
417 /*
418  * Device Capabilities 2 Register (4 bytes)
419  */
420 #define	PCIE_DEVCAP2_COM_TO_RANGE_MASK	0xF
421 #define	PCIE_DEVCAP2_COM_TO_DISABLE	0x10
422 #define	PCIE_DEVCAP2_ARI_FORWARD	0x20
423 #define	PCIE_DEVCAP2_ATOMICOP_ROUTING	0x40
424 #define	PCIE_DEVCAP2_32_ATOMICOP_COMPL  0x80
425 #define	PCIE_DEVCAP2_64_ATOMICOP_COMPL  0x100
426 #define	PCIE_DEVCAP2_128_CAS_COMPL	0x200
427 #define	PCIE_DEVCAP2_NO_RO_PR_PR_PASS	0x400
428 #define	PCIE_DEVCAP2_LTR_MECH		0x800
429 #define	PCIE_DEVCAP2_TPH_COMP_SHIFT	12
430 #define	PCIE_DEVCAP2_TPH_COMP_MASK	0x3
431 #define	PCIE_DEVCAP2_LNSYS_CLS_SHIFT	14
432 #define	PCIE_DEVCAP2_LNSYS_CLS_MASK	0x3
433 #define	PCIE_DEVCAP2_10B_TAG_COMP_SUP	0x10000
434 #define	PCIE_DEVCAP2_10B_TAG_REQ_SUP	0x20000
435 #define	PCIE_DEVCAP2_OBFF_SHIFT		18
436 #define	PCIE_DEVCAP2_OBFF_MASK		0x3
437 #define	PCIE_DEVCAP2_EXT_FMT_FIELD	0x100000
438 #define	PCIE_DEVCAP2_END_END_TLP_PREFIX	0x200000
439 #define	PCIE_DEVCAP2_MAX_END_END_SHIFT	22
440 #define	PCIE_DEVCAP2_MAX_END_END_MASK	0x3
441 #define	PCIE_DEVCAP2_EPR_SUP_SHIFT	24
442 #define	PCIE_DEVCAP2_EPR_SUP_MASK	0x3
443 #define	PCIE_DEVCAP2_EPR_INIT_REQ	0x4000000
444 #define	PCIE_DEVCAP2_FRS_SUP		0x80000000
445 
446 /*
447  * Device Control 2 Register (2 bytes)
448  */
449 #define	PCIE_DEVCTL2_COM_TO_RANGE_MASK	0xf
450 #define	PCIE_DEVCTL2_COM_TO_RANGE_0	0x0
451 #define	PCIE_DEVCTL2_COM_TO_RANGE_1	0x1
452 #define	PCIE_DEVCTL2_COM_TO_RANGE_2	0x2
453 #define	PCIE_DEVCTL2_COM_TO_RANGE_3	0x5
454 #define	PCIE_DEVCTL2_COM_TO_RANGE_4	0x6
455 #define	PCIE_DEVCTL2_COM_TO_RANGE_5	0x9
456 #define	PCIE_DEVCTL2_COM_TO_RANGE_6	0xa
457 #define	PCIE_DEVCTL2_COM_TO_RANGE_7	0xd
458 #define	PCIE_DEVCTL2_COM_TO_RANGE_8	0xe
459 #define	PCIE_DEVCTL2_COM_TO_DISABLE	0x10
460 #define	PCIE_DEVCTL2_ARI_FORWARD_EN	0x20
461 #define	PCIE_DEVCTL2_ATOMICOP_REQ_EN	0x40
462 #define	PCIE_DEVCTL2_ATOMICOP_EGRS_BLK	0x80
463 #define	PCIE_DEVCTL2_IDO_REQ_EN		0x100
464 #define	PCIE_DEVCTL2_IDO_COMPL_EN	0x200
465 #define	PCIE_DEVCTL2_LTR_MECH_EN	0x400
466 #define	PCIE_DEVCTL2_EPR_REQ		0x800
467 #define	PCIE_DEVCTL2_10B_TAG_REQ_EN	0x1000
468 #define	PCIE_DEVCTL2_OBFF_MASK		0x6000
469 #define	PCIE_DEVCTL2_OBFF_DISABLE	0x0000
470 #define	PCIE_DEVCTL2_OBFF_EN_VARA	0x2000
471 #define	PCIE_DEVCTL2_OBFF_EN_VARB	0x4000
472 #define	PCIE_DEVCTL2_OBFF_EN_WAKE	0x6000
473 #define	PCIE_DEVCTL2_END_END_TLP_PREFIX	0x8000
474 
475 
476 /*
477  * Link Capabilities 2 Register (4 bytes)
478  */
479 #define	PCIE_LINKCAP2_SPEED_2_5		0x02
480 #define	PCIE_LINKCAP2_SPEED_5		0x04
481 #define	PCIE_LINKCAP2_SPEED_8		0x08
482 #define	PCIE_LINKCAP2_SPEED_16		0x10
483 #define	PCIE_LINKCAP2_SPEED_32		0x20
484 #define	PCIE_LINKCAP2_SPEED_64		0x40
485 #define	PCIE_LINKCAP2_SPEED_MASK	0xfe
486 #define	PCIE_LINKCAP2_CROSSLINK		0x100
487 #define	PCIE_LINKCAP2_LSKP_OSGSS_MASK	0xfe00
488 #define	PCIE_LINKCAP2_LKSP_OSGSS_2_5	0x0200
489 #define	PCIE_LINKCAP2_LKSP_OSGSS_5	0x0400
490 #define	PCIE_LINKCAP2_LKSP_OSGSS_8	0x0800
491 #define	PCIE_LINKCAP2_LKSP_OSGSS_16	0x1000
492 #define	PCIE_LINKCAP2_LKSP_OSGSS_32	0x2000
493 #define	PCIE_LINKCAP2_LKSP_OSGSS_64	0x4000
494 #define	PCIE_LINKCAP2_LKSP_OSRSS_MASK	0x7f0000
495 #define	PCIE_LINKCAP2_LKSP_OSRSS_2_5	0x010000
496 #define	PCIE_LINKCAP2_LKSP_OSRSS_5	0x020000
497 #define	PCIE_LINKCAP2_LKSP_OSRSS_8	0x040000
498 #define	PCIE_LINKCAP2_LKSP_OSRSS_16	0x080000
499 #define	PCIE_LINKCAP2_LKSP_OSRSS_32	0x100000
500 #define	PCIE_LINKCAP2_LKSP_OSRSS_64	0x200000
501 #define	PCIE_LINKCAP2_RTPD_SUP		0x800000
502 #define	PCIE_LINKCAP2_TRTPD_SUP		0x01000000
503 #define	PCIE_LINKCAP2_DRS		0x80000000
504 
505 /*
506  * Link Control 2 Register (2 bytes)
507  */
508 
509 #define	PCIE_LINKCTL2_TARGET_SPEED_2_5	0x1	/* 2.5 GT/s Speed */
510 #define	PCIE_LINKCTL2_TARGET_SPEED_5	0x2	/* 5.0 GT/s Speed */
511 #define	PCIE_LINKCTL2_TARGET_SPEED_8	0x3	/* 8.0 GT/s Speed */
512 #define	PCIE_LINKCTL2_TARGET_SPEED_16	0x4	/* 16.0 GT/s Speed */
513 #define	PCIE_LINKCTL2_TARGET_SPEED_32	0x5	/* 32.0 GT/s Speed */
514 #define	PCIE_LINKCTL2_TARGET_SPEED_64	0x6	/* 64.0 GT/s Speed */
515 #define	PCIE_LINKCTL2_TARGET_SPEED_MASK	0x000f
516 #define	PICE_LINKCTL2_ENTER_COMPLIANCE	0x0010
517 #define	PCIE_LINKCTL2_HW_AUTO_SPEED_DIS	0x0020
518 #define	PCIE_LINKCTL2_SELECT_DEEMPH	0x0040
519 #define	PCIE_LINKCTL2_TX_MARGIN_MASK	0x0380
520 #define	PCIE_LINKCTL2_ENTER_MOD_COMP	0x0400
521 #define	PCIE_LINKCTL2_COMP_SOS		0x0800
522 #define	PCIE_LINKCTL2_COMP_DEEMPM_MASK	0xf000
523 
524 /*
525  * Link Status 2 Register (2 bytes)
526  */
527 #define	PCIE_LINKSTS2_CUR_DEEMPH	0x0001
528 #define	PCIE_LINKSTS2_EQ8GT_COMP	0x0002
529 #define	PCIE_LINKSTS2_EQ8GT_P1_SUC	0x0004
530 #define	PCIE_LINKSTS2_EQ8GT_P2_SUC	0x0008
531 #define	PCIE_LINKSTS2_EQ8GT_P3_SUC	0x0010
532 #define	PCIE_LINKSTS2_LINK_EQ_REQ	0x0020
533 #define	PCIE_LINKSTS2_RETIMER_PRES_DET	0x0040
534 #define	PCIE_LINKSTS2_2RETIMER_PRES_DET	0x0080
535 #define	PCIE_LINKSTS2_XLINK_RES		0x0300
536 #define	PCIE_LINKSTS2_DS_COMP_PRES_MASK	0x7000
537 #define	PCIE_LINKSTS2_DRS_MSG_RX	0x8000
538 
539 /*
540  * PCI-Express Enhanced Capabilities Link Entry Bit Offsets
541  */
542 #define	PCIE_EXT_CAP			0x100	/* Base Address of Ext Cap */
543 
544 #define	PCIE_EXT_CAP_ID_SHIFT		0	/* PCI-e Ext Cap ID */
545 #define	PCIE_EXT_CAP_ID_MASK		0xFFFF
546 #define	PCIE_EXT_CAP_VER_SHIFT		16	/* PCI-e Ext Cap Ver */
547 #define	PCIE_EXT_CAP_VER_MASK		0xF
548 #define	PCIE_EXT_CAP_NEXT_PTR_SHIFT	20	/* PCI-e Ext Cap Next Ptr */
549 #define	PCIE_EXT_CAP_NEXT_PTR_MASK	0xFFF
550 
551 #define	PCIE_EXT_CAP_NEXT_PTR_NULL	0x0
552 #define	PCIE_EXT_CAP_MAX_PTR		0x3c0	/* max. number of caps */
553 
554 /*
555  * PCI-Express Enhanced Capability Identifier Values
556  */
557 #define	PCIE_EXT_CAP_ID_AER		0x1	/* Advanced Error Handling */
558 #define	PCIE_EXT_CAP_ID_VC		0x2	/* Virtual Channel, no MFVC */
559 #define	PCIE_EXT_CAP_ID_SER		0x3	/* Serial Number */
560 #define	PCIE_EXT_CAP_ID_PWR_BUDGET	0x4	/* Power Budgeting */
561 #define	PCIE_EXT_CAP_ID_RC_LINK_DECL	0x5	/* RC Link Declaration */
562 #define	PCIE_EXT_CAP_ID_RC_INT_LINKCTRL	0x6	/* RC Internal Link Control */
563 #define	PCIE_EXT_CAP_ID_RC_EVNT_CEA	0x7	/* RC Event Collector */
564 						/* Endpoint Association */
565 #define	PCIE_EXT_CAP_ID_MFVC		0x8	/* Multi-func Virtual Channel */
566 #define	PCIE_EXT_CAP_ID_VC_WITH_MFVC	0x9	/* Virtual Channel w/ MFVC */
567 #define	PCIE_EXT_CAP_ID_RCRB		0xA	/* Root Complex Register Blck */
568 #define	PCIE_EXT_CAP_ID_VS		0xB	/* Vendor Spec Extended Cap */
569 #define	PCIE_EXT_CAP_ID_CAC		0xC	/* Config Access Correlation */
570 #define	PCIE_EXT_CAP_ID_ACS		0xD	/* Access Control Services */
571 #define	PCIE_EXT_CAP_ID_ARI		0xE	/* Alternative Routing ID */
572 #define	PCIE_EXT_CAP_ID_ATS		0xF	/* Address Translation Svcs */
573 #define	PCIE_EXT_CAP_ID_SRIOV		0x10	/* Single Root I/O Virt. */
574 #define	PCIE_EXT_CAP_ID_MRIOV		0x11	/* Multi Root I/O Virt. */
575 #define	PCIE_EXT_CAP_ID_MULTICAST	0x12	/* Multicast Services */
576 #define	PCIE_EXT_CAP_ID_PGREQ		0x13	/* Page Request */
577 #define	PCIE_EXT_CAP_ID_EA		0x14	/* Enhanced Allocation */
578 #define	PCIE_EXT_CAP_ID_RESIZE_BAR	0x15	/* Resizable BAR */
579 #define	PCIE_EXT_CAP_ID_DPA		0x16	/* Dynamic Power Allocation */
580 #define	PCIE_EXT_CAP_ID_TPH_REQ		0x17	/* TPH Requester */
581 #define	PCIE_EXT_CAP_ID_LTR		0x18	/* Latency Tolerance Report */
582 #define	PCIE_EXT_CAP_ID_PCIE2		0x19	/* PCI Express Capability 2 */
583 #define	PCIE_EXT_CAP_ID_PASID		0x1B	/* PASID */
584 #define	PCIE_EXT_CAP_ID_LNR		0x1C	/* LNR */
585 #define	PCIE_EXT_CAP_ID_DPC		0x1D	/* DPC */
586 #define	PCIE_EXT_CAP_ID_L1PM		0x1E	/* L1 PM Substrates */
587 #define	PCIE_EXT_CAP_ID_PTM		0x1F	/* Precision Time Management */
588 #define	PCIE_EXT_CAP_ID_FRS		0x21	/* Function Ready Stat. Queue */
589 #define	PCIE_EXT_CAP_ID_RTR		0x22	/* Readiness Time Reporting */
590 #define	PCIE_EXT_CAP_ID_DVS		0x23	/* Designated Vendor-Specific */
591 #define	PCIE_EXT_CAP_ID_VFRBAR		0x24	/* VF Resizable BAR */
592 #define	PCIE_EXT_CAP_ID_DLF		0x25	/* Data Link Feature */
593 #define	PCIE_EXT_CAP_ID_PL16GT		0x26	/* Physical Layer 16.0 GT/s */
594 #define	PCIE_EXT_CAP_ID_LANE_MARGIN	0x27	/* Lane Margining */
595 #define	PCIE_EXT_CAP_ID_HIEARCHY_ID	0x28	/* Hierarchy ID */
596 #define	PCIE_EXT_CAP_ID_NPEM		0x29	/* Native PCIe Enclosure Mgmt */
597 #define	PCIE_EXT_CAP_ID_PL32GT		0x2A	/* Physical Layer 32.0 GT/s */
598 #define	PCIE_EXT_CAP_ID_AP		0x2B	/* Alternate Protocol */
599 #define	PCIE_EXT_CAP_ID_SFI		0x2C	/* Sys. Firmware Intermediary */
600 #define	PCIE_EXT_CAP_ID_SHDW_FUNC	0x2D	/* Shadow Functions */
601 #define	PCIE_EXT_CAP_ID_DOE		0x2E	/* Data Object Exchange */
602 #define	PCIE_EXT_CAP_ID_DEV3		0x2F	/* Device 3 */
603 #define	PCIE_EXT_CAP_ID_IDE		0x30	/* Integrity and Data Encr. */
604 #define	PCIE_EXT_CAP_ID_PL64GT		0x31	/* Physical Layer 64.0 GT/s */
605 #define	PCIE_EXT_CAP_ID_FLIT_LOG	0x32	/* Flit Logging */
606 #define	PCIE_EXT_CAP_ID_FLIT_PERF	0x33	/* Flit Perf. Measurement */
607 #define	PCIE_EXT_CAP_ID_FLIT_ERR	0x34	/* Flit Error Injection */
608 #define	PCIE_EXT_CAP_ID_SVC		0x35	/* Streamlined Virtual Chan. */
609 #define	PCIE_EXT_CAP_ID_MMIO_RBL	0x36	/* MMIO Register Block Loc. */
610 
611 /*
612  * PCI-Express Advanced Error Reporting Extended Capability Offsets
613  */
614 #define	PCIE_AER_CAP			0x0	/* Enhanced Capability Header */
615 #define	PCIE_AER_UCE_STS		0x4	/* Uncorrectable Error Status */
616 #define	PCIE_AER_UCE_MASK		0x8	/* Uncorrectable Error Mask */
617 #define	PCIE_AER_UCE_SERV		0xc	/* Uncor Error Severity */
618 #define	PCIE_AER_CE_STS			0x10	/* Correctable Error Status */
619 #define	PCIE_AER_CE_MASK		0x14	/* Correctable Error Mask */
620 #define	PCIE_AER_CTL			0x18	/* AER Capability & Control */
621 #define	PCIE_AER_HDR_LOG		0x1c	/* Header Log */
622 
623 /* Root Ports Only */
624 #define	PCIE_AER_RE_CMD			0x2c	/* Root Error Command */
625 #define	PCIE_AER_RE_STS			0x30	/* Root Error Status */
626 #define	PCIE_AER_CE_SRC_ID		0x34	/* Error Source ID */
627 #define	PCIE_AER_ERR_SRC_ID		0x36	/* Error Source ID */
628 #define	PCIE_AER_TLP_PRE_LOG		0x38	/* TLP Prefix Log */
629 
630 /* Bridges Only */
631 #define	PCIE_AER_SUCE_STS		0x2c	/* Secondary UCE Status */
632 #define	PCIE_AER_SUCE_MASK		0x30	/* Secondary UCE Mask */
633 #define	PCIE_AER_SUCE_SERV		0x34	/* Secondary UCE Severity */
634 #define	PCIE_AER_SCTL			0x38	/* Secondary Cap & Ctl */
635 #define	PCIE_AER_SHDR_LOG		0x3c	/* Secondary Header Log */
636 
637 /*
638  * AER Uncorrectable Error Status/Mask/Severity Register
639  */
640 #define	PCIE_AER_UCE_TRAINING		0x1	/* Training Error Status */
641 #define	PCIE_AER_UCE_DLP		0x10	/* Data Link Protocol Error */
642 #define	PCIE_AER_UCE_SD			0x20	/* Link Surprise down */
643 #define	PCIE_AER_UCE_PTLP		0x1000	/* Poisoned TLP Status */
644 #define	PCIE_AER_UCE_FCP		0x2000	/* Flow Control Protocol Sts */
645 #define	PCIE_AER_UCE_TO			0x4000	/* Completion Timeout Status */
646 #define	PCIE_AER_UCE_CA			0x8000	/* Completer Abort Status */
647 #define	PCIE_AER_UCE_UC			0x10000	/* Unexpected Completion Sts */
648 #define	PCIE_AER_UCE_RO			0x20000	/* Receiver Overflow Status */
649 #define	PCIE_AER_UCE_MTLP		0x40000	/* Malformed TLP Status */
650 #define	PCIE_AER_UCE_ECRC		0x80000	/* ECRC Error Status */
651 #define	PCIE_AER_UCE_UR			0x100000 /* Unsupported Req */
652 #define	PCIE_AER_UCE_BITS		(PCIE_AER_UCE_TRAINING | \
653     PCIE_AER_UCE_DLP | PCIE_AER_UCE_SD | PCIE_AER_UCE_PTLP | \
654     PCIE_AER_UCE_FCP | PCIE_AER_UCE_TO | PCIE_AER_UCE_CA | \
655     PCIE_AER_UCE_UC | PCIE_AER_UCE_RO | PCIE_AER_UCE_MTLP | \
656     PCIE_AER_UCE_ECRC | PCIE_AER_UCE_UR)
657 #define	PCIE_AER_UCE_LOG_BITS		(PCIE_AER_UCE_PTLP | PCIE_AER_UCE_CA | \
658     PCIE_AER_UCE_UC | PCIE_AER_UCE_MTLP | PCIE_AER_UCE_ECRC | PCIE_AER_UCE_UR)
659 
660 /*
661  * AER Correctable Error Status/Mask Register
662  */
663 #define	PCIE_AER_CE_RECEIVER_ERR	0x1	/* Receiver Error Status */
664 #define	PCIE_AER_CE_BAD_TLP		0x40	/* Bad TLP Status */
665 #define	PCIE_AER_CE_BAD_DLLP		0x80	/* Bad DLLP Status */
666 #define	PCIE_AER_CE_REPLAY_ROLLOVER	0x100	/* REPLAY_NUM Rollover Status */
667 #define	PCIE_AER_CE_REPLAY_TO		0x1000	/* Replay Timer Timeout Sts */
668 #define	PCIE_AER_CE_AD_NFE		0x2000	/* Advisory Non-Fatal Status */
669 #define	PCIE_AER_CE_BITS		(PCIE_AER_CE_RECEIVER_ERR | \
670     PCIE_AER_CE_BAD_TLP | PCIE_AER_CE_BAD_DLLP | PCIE_AER_CE_REPLAY_ROLLOVER | \
671     PCIE_AER_CE_REPLAY_TO)
672 
673 /*
674  * AER Capability & Control
675  */
676 #define	PCIE_AER_CTL_FST_ERR_PTR_MASK	0x1F	/* First Error Pointer */
677 #define	PCIE_AER_CTL_ECRC_GEN_CAP	0x20	/* ECRC Generation Capable */
678 #define	PCIE_AER_CTL_ECRC_GEN_ENA	0x40	/* ECRC Generation Enable */
679 #define	PCIE_AER_CTL_ECRC_CHECK_CAP	0x80	/* ECRC Check Capable */
680 #define	PCIE_AER_CTL_ECRC_CHECK_ENA	0x100	/* ECRC Check Enable */
681 
682 /*
683  * AER Root Command Register
684  */
685 #define	PCIE_AER_RE_CMD_CE_REP_EN	0x1	/* Correctable Error Enable */
686 #define	PCIE_AER_RE_CMD_NFE_REP_EN	0x2	/* Non-Fatal Error Enable */
687 #define	PCIE_AER_RE_CMD_FE_REP_EN	0x4	/* Fatal Error Enable */
688 
689 /*
690  * AER Root Error Status Register
691  */
692 #define	PCIE_AER_RE_STS_CE_RCVD		0x1	/* ERR_COR Received */
693 #define	PCIE_AER_RE_STS_MUL_CE_RCVD	0x2	/* Multiple ERR_COR Received */
694 #define	PCIE_AER_RE_STS_FE_NFE_RCVD	0x4	/* FATAL/NON-FATAL Received */
695 #define	PCIE_AER_RE_STS_MUL_FE_NFE_RCVD	0x8	/* Multiple ERR_F/NF Received */
696 #define	PCIE_AER_RE_STS_FIRST_UC_FATAL	0x10	/* First Uncorrectable Fatal */
697 #define	PCIE_AER_RE_STS_NFE_MSGS_RCVD	0x20	/* Non-Fatal Error Msgs Rcvd */
698 #define	PCIE_AER_RE_STS_FE_MSGS_RCVD	0x40	/* Fatal Error Messages Rcvd */
699 
700 #define	PCIE_AER_RE_STS_MSG_NUM_SHIFT	27	/* Offset of Intr Msg Number */
701 #define	PCIE_AER_RE_STS_MSG_NUM_MASK	0x1F	/* Intr Msg Number Mask */
702 
703 /*
704  * AER Error Source Identification Register
705  */
706 #define	PCIE_AER_ERR_SRC_ID_CE_SHIFT	0	/* ERR_COR Source ID */
707 #define	PCIE_AER_ERR_SRC_ID_CE_MASK	0xFFFF
708 #define	PCIE_AER_ERR_SRC_ID_UE_SHIFT	16	/* ERR_FATAL/NONFATAL Src ID */
709 #define	PCIE_AER_ERR_SRC_ID_UE_MASK	0xFFFF
710 
711 /*
712  * AER Secondary Uncorrectable Error Register
713  */
714 #define	PCIE_AER_SUCE_TA_ON_SC		0x1	/* Target Abort on Split Comp */
715 #define	PCIE_AER_SUCE_MA_ON_SC		0x2	/* Master Abort on Split Comp */
716 #define	PCIE_AER_SUCE_RCVD_TA		0x4	/* Received Target Abort */
717 #define	PCIE_AER_SUCE_RCVD_MA		0x8	/* Received Master Abort */
718 #define	PCIE_AER_SUCE_USC_ERR		0x20	/* Unexpected Split Comp Err */
719 #define	PCIE_AER_SUCE_USC_MSG_DATA_ERR	0x40	/* USC Message Data Error */
720 #define	PCIE_AER_SUCE_UC_DATA_ERR	0x80	/* Uncorrectable Data Error */
721 #define	PCIE_AER_SUCE_UC_ATTR_ERR	0x100	/* UC Attribute Err */
722 #define	PCIE_AER_SUCE_UC_ADDR_ERR	0x200	/* Uncorrectable Address Err */
723 #define	PCIE_AER_SUCE_TIMER_EXPIRED	0x400	/* Delayed xtion discard */
724 #define	PCIE_AER_SUCE_PERR_ASSERT	0x800	/* PERR Assertion Detected */
725 #define	PCIE_AER_SUCE_SERR_ASSERT	0x1000	/* SERR Assertion Detected */
726 #define	PCIE_AER_SUCE_INTERNAL_ERR	0x2000	/* Internal Bridge Err Detect */
727 
728 #define	PCIE_AER_SUCE_HDR_CMD_LWR_MASK	0xF	/* Lower Command Mask */
729 #define	PCIE_AER_SUCE_HDR_CMD_LWR_SHIFT	4	/* Lower Command Shift */
730 #define	PCIE_AER_SUCE_HDR_CMD_UP_MASK	0xF	/* Upper Command Mask */
731 #define	PCIE_AER_SUCE_HDR_CMD_UP_SHIFT	8	/* Upper Command Shift */
732 #define	PCIE_AER_SUCE_HDR_ADDR_SHIFT	32	/* Upper Command Shift */
733 
734 #define	PCIE_AER_SUCE_BITS		(PCIE_AER_SUCE_TA_ON_SC | \
735     PCIE_AER_SUCE_MA_ON_SC | PCIE_AER_SUCE_RCVD_TA | PCIE_AER_SUCE_RCVD_MA | \
736     PCIE_AER_SUCE_USC_ERR | PCIE_AER_SUCE_USC_MSG_DATA_ERR | \
737     PCIE_AER_SUCE_UC_DATA_ERR | PCIE_AER_SUCE_UC_ATTR_ERR | \
738     PCIE_AER_SUCE_UC_ADDR_ERR |	PCIE_AER_SUCE_TIMER_EXPIRED | \
739     PCIE_AER_SUCE_PERR_ASSERT |	PCIE_AER_SUCE_SERR_ASSERT | \
740     PCIE_AER_SUCE_INTERNAL_ERR)
741 #define	PCIE_AER_SUCE_LOG_BITS		(PCIE_AER_SUCE_TA_ON_SC | \
742     PCIE_AER_SUCE_MA_ON_SC | PCIE_AER_SUCE_RCVD_TA | PCIE_AER_SUCE_RCVD_MA | \
743     PCIE_AER_SUCE_USC_ERR | PCIE_AER_SUCE_USC_MSG_DATA_ERR | \
744     PCIE_AER_SUCE_UC_DATA_ERR | PCIE_AER_SUCE_UC_ATTR_ERR | \
745     PCIE_AER_SUCE_UC_ADDR_ERR |	PCIE_AER_SUCE_PERR_ASSERT)
746 
747 /*
748  * AER Secondary Capability & Control
749  */
750 #define	PCIE_AER_SCTL_FST_ERR_PTR_MASK	0x1F	/* First Error Pointer */
751 
752 /*
753  * AER Secondary Headers
754  * The Secondary Header Logs is 4 DW long.
755  * The first 2 DW are split into 3 sections
756  * o Transaction Attribute
757  * o Transaction Command Lower
758  * o Transaction Command Higher
759  * The last 2 DW is the Transaction Address
760  */
761 #define	PCIE_AER_SHDR_LOG_ATTR_MASK	0xFFFFFFFFF
762 #define	PCIE_AER_SHDR_LOG_CMD_LOW_MASK	0xF000000000
763 #define	PCIE_AER_SHDR_LOG_CMD_HIGH_MASK	0xF0000000000
764 #define	PCIE_AER_SHDR_LOG_ADDR_MASK	0xFFFFFFFFFFFFFFFF
765 
766 /*
767  * PCI-Express Device Serial Number Capability Offsets.
768  */
769 #define	PCIE_SER_CAP		0x0	/* Enhanced Capability Header */
770 #define	PCIE_SER_SID_LOWER_DW	0x4	/* Lower 32-bit Serial Number */
771 #define	PCIE_SER_SID_UPPER_DW	0x8	/* Upper 32-bit Serial Number */
772 
773 /*
774  * ARI Capability Offsets
775  */
776 #define	PCIE_ARI_HDR	0x0		/* Enhanced Capability Header */
777 #define	PCIE_ARI_CAP	0x4		/* ARI Capability Register */
778 #define	PCIE_ARI_CTL	0x6		/* ARI Control Register */
779 
780 #define	PCIE_ARI_CAP_MFVC_FUNC_GRP	0x01
781 #define	PCIE_ARI_CAP_ASC_FUNC_GRP	0x02
782 
783 #define	PCIE_ARI_CAP_NEXT_FUNC_SHIFT	8
784 #define	PCIE_ARI_CAP_NEXT_FUNC_MASK	0xffff
785 
786 #define	PCIE_ARI_CTRL_MFVC_FUNC_GRP	0x01
787 #define	PCIE_ARI_CTRL_ASC_FUNC_GRP	0x02
788 
789 #define	PCIE_ARI_CTRL_FUNC_GRP_SHIFT	4
790 #define	PCIE_ARI_CTRL_FUNC_GRP_MASK	0x7
791 
792 /*
793  * PCIe Device 3 Extended Capability Header (PCIE_EXT_CAP_ID_DEV3)
794  */
795 #define	PCIE_DEVCAP3		0x04
796 #define	PCIE_DEVCAP3_DMWR_REQ_ROUTE	0x01
797 #define	PCIE_DEVCAP3_14B_TAG_COMP_SUP	0x02
798 #define	PCIE_DEVCAP3_14B_TAG_REQ_SUP	0x04
799 #define	PCIE_DEVCAP3_PORT_L0P_SUP	0x08
800 #define	PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_MASK	0x070
801 #define	PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_MIN	0x0	/* < 1us */
802 #define	PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_1us	0x1	/* [ 1us, 2us ) */
803 #define	PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_2us	0x2	/* [ 2us, 4us ) */
804 #define	PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_4us	0x3	/* [ 4us, 8us ) */
805 #define	PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_8us	0x4	/* [ 8us, 16us ) */
806 #define	PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_16us	0x5	/* [ 16us, 32us ) */
807 #define	PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_32us	0x6	/* [ 32us, 64us ] */
808 #define	PCIE_DEVCAP3_PORT_L0P_EXIT_LAT_MAX	0x7	/* > 64us */
809 #define	PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_MASK	0x380
810 #define	PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_MIN	0x0	/* < 1us */
811 #define	PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_1us	0x1	/* [ 1us, 2us ) */
812 #define	PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_2us	0x2	/* [ 2us, 4us ) */
813 #define	PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_4us	0x3	/* [ 4us, 8us ) */
814 #define	PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_8us	0x4	/* [ 8us, 16us ) */
815 #define	PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_16us	0x5	/* [ 16us, 32us ) */
816 #define	PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_32us	0x6	/* [ 32us, 64us ] */
817 #define	PCIE_DEVCAP3_RTMR_L0P_EXIT_LAT_MAX	0x7	/* > 64us */
818 
819 #define	PCIE_DEVCTL3		0x08
820 #define	PCIE_DEVCTL3_DMWR_REQ_EN	0x01
821 #define	PCIE_DEVCTL3_DMWR_EG_BLOCK	0x02
822 #define	PCIE_DEVCTL3_14B_TAG_REQ_EN	0x04
823 #define	PCIE_DEVCTL3_L0P_EN		0x08
824 #define	PCIE_DEVCTL3_TARGET_WIDTH_MASK	0x70
825 #define	PCIE_DEVCTL3_TARGET_WIDTH_X1	0x00
826 #define	PCIE_DEVCTL3_TARGET_WIDTH_X2	0x10
827 #define	PCIE_DEVCTL3_TARGET_WIDTH_X4	0x20
828 #define	PCIE_DEVCTL3_TARGET_WIDTH_X8	0x30
829 #define	PCIE_DEVCTL3_TARGET_WIDTH_X16	0x40
830 #define	PCIE_DEVCTL3_TARGET_WIDTH_DYN	0x70
831 
832 #define	PCIE_DEVSTS3		0x0c
833 #define	PCIE_DEVSTS3_INIT_WIDTH_MASK	0x07
834 #define	PCIE_DEVSTS3_INIT_WIDTH_X1	0x00
835 #define	PCIE_DEVSTS3_INIT_WIDTH_X2	0x01
836 #define	PCIE_DEVSTS3_INIT_WIDTH_X4	0x02
837 #define	PCIE_DEVSTS3_INIT_WIDTH_X8	0x03
838 #define	PCIE_DEVSTS3_INIT_WIDTH_X16	0x04
839 #define	PCIE_DEVSTS3_SEG_CAP		0x08
840 #define	PCIE_DEVSTS3_REM_L0P_SUP	0x10
841 
842 /*
843  * PCI-E Common TLP Header Fields
844  */
845 #define	PCIE_TLP_FMT_3DW	0x00
846 #define	PCIE_TLP_FMT_4DW	0x20
847 #define	PCIE_TLP_FMT_3DW_DATA	0x40
848 #define	PCIE_TLP_FMT_4DW_DATA	0x60
849 
850 #define	PCIE_TLP_TYPE_MEM	0x0
851 #define	PCIE_TLP_TYPE_MEMLK	0x1
852 #define	PCIE_TLP_TYPE_IO	0x2
853 #define	PCIE_TLP_TYPE_CFG0	0x4
854 #define	PCIE_TLP_TYPE_CFG1	0x5
855 #define	PCIE_TLP_TYPE_MSG	0x10
856 #define	PCIE_TLP_TYPE_CPL	0xA
857 #define	PCIE_TLP_TYPE_CPLLK	0xB
858 #define	PCIE_TLP_TYPE_MSI	0x18
859 
860 #define	PCIE_TLP_MRD3		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_MEM)
861 #define	PCIE_TLP_MRD4		(PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MEM)
862 #define	PCIE_TLP_MRDLK3		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_MEMLK)
863 #define	PCIE_TLP_MRDLK4		(PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MEMLK)
864 #define	PCIE_TLP_MRDWR3		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_MEM)
865 #define	PCIE_TLP_MRDWR4		(PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MEM)
866 #define	PCIE_TLP_IORD		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_IO)
867 #define	PCIE_TLP_IOWR		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_IO)
868 #define	PCIE_TLP_CFGRD0		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CFG0)
869 #define	PCIE_TLP_CFGWR0		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CFG0)
870 #define	PCIE_TLP_CFGRD1		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CFG1)
871 #define	PCIE_TLP_CFGWR1		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CFG1)
872 #define	PCIE_TLP_MSG		(PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MSG)
873 #define	PCIE_TLP_MSGD		(PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MSG)
874 #define	PCIE_TLP_CPL		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CPL)
875 #define	PCIE_TLP_CPLD		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CPL)
876 #define	PCIE_TLP_CPLLK		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CPLLK)
877 #define	PCIE_TLP_CPLDLK		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CPLLK)
878 #define	PCIE_TLP_MSI32		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_MSI)
879 #define	PCIE_TLP_MSI64		(PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MSI)
880 
881 typedef uint16_t pcie_req_id_t;
882 
883 #define	PCIE_REQ_ID_BUS_SHIFT	8
884 #define	PCIE_REQ_ID_BUS_MASK	0xFF00
885 #define	PCIE_REQ_ID_DEV_SHIFT	3
886 #define	PCIE_REQ_ID_DEV_MASK	0x00F8
887 #define	PCIE_REQ_ID_FUNC_SHIFT	0
888 #define	PCIE_REQ_ID_FUNC_MASK	0x0007
889 #define	PCIE_REQ_ID_ARI_FUNC_MASK	0x00FF
890 
891 #define	PCIE_CPL_STS_SUCCESS	0
892 #define	PCIE_CPL_STS_UR		1
893 #define	PCIE_CPL_STS_CRS	2
894 #define	PCIE_CPL_STS_CA		4
895 
896 #if defined(_BIT_FIELDS_LTOH)
897 /*
898  * PCI Express little-endian common TLP header format
899  */
900 typedef struct pcie_tlp_hdr {
901 	uint32_t	len	:10,
902 			rsvd3   :2,
903 			attr    :2,
904 			ep	:1,
905 			td	:1,
906 			rsvd2   :4,
907 			tc	:3,
908 			rsvd1   :1,
909 			type    :5,
910 			fmt	:2,
911 			rsvd0   :1;
912 } pcie_tlp_hdr_t;
913 
914 typedef struct pcie_mem64 {
915 	uint32_t	fbe	:4,
916 			lbe	:4,
917 			tag	:8,
918 			rid	:16;
919 	uint32_t	addr1;
920 	uint32_t	rsvd0   :2,
921 			addr0   :30;
922 } pcie_mem64_t;
923 
924 typedef struct pcie_memio32 {
925 	uint32_t	fbe	:4,
926 			lbe	:4,
927 			tag	:8,
928 			rid	:16;
929 	uint32_t	rsvd0   :2,
930 			addr0   :30;
931 } pcie_memio32_t;
932 
933 typedef struct pcie_cfg {
934 	uint32_t	fbe	:4,
935 			lbe	:4,
936 			tag	:8,
937 			rid	:16;
938 	uint32_t	rsvd1   :2,
939 			reg	:6,
940 			extreg  :4,
941 			rsvd0   :4,
942 			func    :3,
943 			dev	:5,
944 			bus	:8;
945 } pcie_cfg_t;
946 
947 typedef struct pcie_cpl {
948 	uint32_t	bc	:12,
949 			bcm	:1,
950 			status  :3,
951 			cid	:16;
952 	uint32_t	laddr   :7,
953 			rsvd0   :1,
954 			tag	:8,
955 			rid	:16;
956 } pcie_cpl_t;
957 
958 /*
959  * PCI-Express Message Request Header
960  */
961 typedef struct pcie_msg {
962 	uint32_t	msg_code:8,	/* DW1 */
963 			tag	:8,
964 			rid	:16;
965 	uint32_t	unused[2];	/* DW 2 & 3 */
966 } pcie_msg_t;
967 
968 #elif defined(_BIT_FIELDS_HTOL)
969 /*
970  * PCI Express big-endian common TLP header format
971  */
972 typedef struct pcie_tlp_hdr {
973 	uint32_t	rsvd0	:1,
974 			fmt	:2,
975 			type	:5,
976 			rsvd1	:1,
977 			tc	:3,
978 			rsvd2	:4,
979 			td	:1,
980 			ep	:1,
981 			attr	:2,
982 			rsvd3	:2,
983 			len	:10;
984 } pcie_tlp_hdr_t;
985 
986 typedef struct pcie_mem64 {
987 	uint32_t	rid	:16,
988 			tag	:8,
989 			lbe	:4,
990 			fbe	:4;
991 	uint32_t	addr1;
992 	uint32_t	addr0	:30,
993 			rsvd0	:2;
994 } pcie_mem64_t;
995 
996 typedef struct pcie_memio32 {
997 	uint32_t	rid	:16,
998 			tag	:8,
999 			lbe	:4,
1000 			fbe	:4;
1001 	uint32_t	addr0	:30,
1002 			rsvd0	:2;
1003 } pcie_memio32_t;
1004 
1005 typedef struct pcie_cfg {
1006 	uint32_t	rid	:16,
1007 			tag	:8,
1008 			lbe	:4,
1009 			fbe	:4;
1010 	uint32_t	bus	:8,
1011 			dev	:5,
1012 			func	:3,
1013 			rsvd0	:4,
1014 			extreg	:4,
1015 			reg	:6,
1016 			rsvd1	:2;
1017 } pcie_cfg_t;
1018 
1019 typedef struct pcie_cpl {
1020 	uint32_t	cid	:16,
1021 			status	:3,
1022 			bcm	:1,
1023 			bc	:12;
1024 	uint32_t	rid	:16,
1025 			tag	:8,
1026 			rsvd0	:1,
1027 			laddr	:7;
1028 } pcie_cpl_t;
1029 
1030 /*
1031  * PCI-Express Message Request Header
1032  */
1033 typedef struct pcie_msg {
1034 	uint32_t	rid	:16,	/* DW1 */
1035 			tag	:8,
1036 			msg_code:8;
1037 	uint32_t	unused[2];	/* DW 2 & 3 */
1038 } pcie_msg_t;
1039 #else
1040 #error "bit field not defined"
1041 #endif
1042 
1043 #define	PCIE_MSG_CODE_ERR_COR		0x30
1044 #define	PCIE_MSG_CODE_ERR_NONFATAL	0x31
1045 #define	PCIE_MSG_CODE_ERR_FATAL		0x33
1046 
1047 #ifdef	__cplusplus
1048 }
1049 #endif
1050 
1051 #endif	/* _SYS_PCIE_H */
1052