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