Decoding pcie config space capabilites manually - looking for example

11.6k views Asked by At

I don't have an o/s running so I can't decode pcie using something like lspci (I wish lspci would take input from a file!).

I have a hex dump below (this is a Xilinx Ultrascale FPGA but the question is generic), I'm trying to understand where the capabilities start and how to decode the Next Cap Pointers to walk the config space. According to Xilinx PG156 page 2-24 the capabilities start at 0x80 from the beginning of the config space, but the values at 0x80 (0x80030001) don't seem to make sense, the next pointer is zero but there are clearly more capabilities.

I can't find a clear answer online or in the standard as to where the capabilities start.

000 0x813410ee
004 0x00100000
008 0x06800000
00c 0x00010000
010 0x0000000c
014 0x00000000
018 0x00000000
01c 0x00000000
020 0x00000000
024 0x00000000
028 0x00000000
02c 0x00000000
030 0x00000000
034 0x000000c0
038 0x00000000
03c 0x00000100
040 0x00000000
044 0x00000000
048 0x00000000
04c 0x00000000
050 0x00000000
054 0x00000000
058 0x00000000
05c 0x00000000
060 0x00000000
064 0x00000000
068 0x00000000
06c 0x00000000
070 0x00000000
074 0x00000000
078 0x00000000
07c 0x00000000
080 0x80030001
084 0x00000008
088 0x00000000
08c 0x00000000
090 0x00800005
094 0x00000000
098 0x00000000
09c 0x00000000
0a0 0x00000000
0a4 0x00000000
0a8 0x00000000
0ac 0x00000000
0b0 0x00000011
0b4 0x00000000
0b8 0x00000000
0bc 0x00000000
0c0 0x00420010
0c4 0x00008023
0c8 0x00012910
0cc 0x0073f043
0d0 0x20410000
0d4 0x00000000
0d8 0x00400000
0dc 0x00000000
0e0 0x00000000
0e4 0x00000012
0e8 0x00000000
0ec 0x0000000e
0f0 0x00030003
0f4 0x00000000
0f8 0x00000000
0fc 0x00000000
100 0x30020001
104 0x00000000
108 0x00400000
10c 0x00462030
110 0x00000001
114 0x0000e000
118 0x00000000
11c 0x00000000
120 0x00000000
124 0x00000000
128 0x00000000
12c 0x00000000
130 0x00000000
134 0x00000000
138 0x00000000
13c 0x00000000
140 0x0001000e
144 0x00000000
148 0x00000000
14c 0x00000000
150 0x30010003
154 0x00000000
158 0x00000000
15c 0x00000000
160 0x00010004
164 0x00000000
168 0x00000000
16c 0x00000000
170 0x00000000
174 0x00000000
178 0x00000000
17c 0x00000000
180 0x00000000
184 0x00000000
188 0x00000000
18c 0x00000000
190 0x00000000
194 0x00000000
198 0x00000000
19c 0x00000000
1a0 0x00000000
1a4 0x00000000
1a8 0x00000000
1ac 0x00000000
1b0 0x00000000
1b4 0x00000000
1b8 0x00010018
1bc 0x00000000
1c0 0x00010016
1c4 0x00000007
1c8 0x00000000
1cc 0x00000100
1d0 0x00000000
1d4 0x00000000
1d8 0x00000000
1dc 0x00000000
1e0 0x00000000
1e4 0x00000000
1e8 0x00000000
1ec 0x00000000
1f0 0x00000000
1f4 0x00000000
1f8 0x00000000
1fc 0x00000000
200 0x00000010
204 0x00000000
208 0x00000000
20c 0x00000000
210 0x00000000
214 0x00010000
218 0x00000000
21c 0x00000553
220 0x00000001
224 0x00000000
228 0x00000000
22c 0x00000000
230 0x00000000
234 0x00000000
238 0x00000000
23c 0x00000000
240 0x00000000
244 0x00000000
248 0x00000000
24c 0x00000000
250 0x00000000
254 0x00000000
258 0x00000000
25c 0x00000000
260 0x00000000
264 0x00000000
268 0x00000000
26c 0x00000000
270 0x00000000
274 0x30010017
278 0x00000005
27c 0x00000000
280 0x00000000
284 0x00000000
288 0x00000000
28c 0x00000000
290 0x00000000
294 0x00000000
298 0x00000000
29c 0x00000000
2a0 0x00000000
2a4 0x00000000
2a8 0x00000000
2ac 0x00000000
2b0 0x00000000
2b4 0x00000000
2b8 0x00000000
2bc 0x00000000
2c0 0x00000000
2c4 0x00000000
2c8 0x00000000
2cc 0x00000000
2d0 0x00000000
2d4 0x00000000
2d8 0x00000000
2dc 0x00000000
2e0 0x00000000
2e4 0x00000000
2e8 0x00000000
2ec 0x00000000
2f0 0x00000000
2f4 0x00000000
2f8 0x00000000
2fc 0x00000000
300 0x30010019
304 0x00000000
308 0x00000000
30c 0x3f003f00
310 0x3f003f00
314 0x3f003f00
318 0x3f003f00
31c 0x00000000
320 0x00000000
324 0x00000000
328 0x00000000
32c 0x00000000
330 0x00000000
334 0x00000000
338 0x00000000
33c 0x00000000
340 0x00000000
344 0x00000000
348 0x00000000
34c 0x00000000
350 0x00000000
354 0x00000000
358 0x00000000
35c 0x00000000
360 0x00000000
364 0x00000000
368 0x00000000
36c 0x00000000
370 0x00000000
374 0x00000000
378 0x00000000
37c 0x00000000
380 0x00000000
384 0x00000000
388 0x00000000
38c 0x00000000
390 0x00000000
394 0x00000000
398 0x00000000
39c 0x00000000
3a0 0x00000000
3a4 0x00000000
3a8 0x00000000
3ac 0x00000000
3b0 0x00000000
3b4 0x00000000
3b8 0x00000000
3bc 0x00000000
3c0 0x00010002
3c4 0x00000000
3c8 0x00000000
3cc 0x00000000
3d0 0x00000000
3d4 0x800000ff
3d8 0x00000000
3dc 0x00000000
3e0 0x00000000
3e4 0x00000000
3e8 0x00000000
3ec 0x00000000
3f0 0x00000000
3f4 0x00000000
3f8 0x00000000
3fc 0x00000000
4

There are 4 answers

1
Jeff Simpson On BEST ANSWER

I don't have an o/s running so I can't decode pcie using something like lspci (I wish lspci would take input from a file!).

lspci can take input from a file!

Use lcpci -xx on one machine to generate the hex output. Save it in a text file. Use lspci -F [filename] to read it in.

Now all you need to do is generate a text file in the same format as that original file (it's just a hex dump of the configuration space).

4
TomKeddie On

Ok, I've found out how this works. There are two kinds of capabilites, standard and extended. The pointer to the first standard capability is in the lower 8 bits of the configuration register at offset 0x34.

So

034 0x000000c0

Points to 0xc0

0c0 0x00420010

Where we find the PCIe capability register (0x10), a next pointer (0x00, end of chain) and some metadata (0x0042 ref 7.8.2 of spec to decode).

Separately we have extended capabilities at starting at offset 0x0100 (ref 7.9 of spec).

100 0x30020001

Here we find the Advanced Error Reporting Capability id (0x0001), its version (2) and a next pointer (0x300).

300 0x30010019

Here we find the Secondary PCI Express Extended Capability (0x0019), its version (1) and a next pointer (0x300 - that doesn't make sense as its pointing to itself).

1
Megadavve On

The capabilities pointer are located at address 0x34. The value you see there is the address to go to. In you case 0xc0. At address 0xC0 you have the value 0x10. This indicates a PCI Express Capability Structure. The next value is 0x00. This indicates the end of a the linked list, otherwise you would have seen an address here and jumped there to continued. 0x10 is a PCI Express Capability Structure 0x05 is a MSI Capability Structure 0x01 is a

0
zmau On

As for the PCIe Extended capabilities header structure : I think that there is a mistake.

Bit 15:0 - ID This is the ID value that can be used to identify the PCIe Extended capability. This value can be modified by setting the property on the PCIe hardblock instance. Read Only.

Bit 19:16 - Rev This is the Revision ID value that can be used to identify the PCIe Extended capability. This value can be modified by setting the property on the PCIe hardblock instance. Read Only

31:20 - Length This field indicates the number of bytes in the entire structure, including the PCI Express Extended Capability header, the Vendor-Specific header, and the rest of the data. Read Only

However the information does not make sense with the actual numbers (as you say yourself)....