1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
|
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
* Copyright 2022 Oxide Computer Company
*/
/*
* This file contains logic to walk and print a large chunk of configuration
* space and many of the capabilities. There are multiple sub-commands that
* vector into the same logic (e.g. 'save-cfgspace' and 'show-cfgspace'). In
* general, there are a few major goals with this bit of code:
*
* o Every field should strive to be parsable and therefore selectable for
* output. This drove the idea that every field has both a short name and a
* human name. The short name is a dot-delineated name. When in parsable
* mode, the name will always refer to a single field. However, for
* convenience for humans, when not trying to be parsable, we show the
* parents in the tree. That is if you specify something like
* 'pcie.linkcap.maxspeed', in parsable mode you'll only get that; however,
* in non-parsable mode, you'll get an indication of the capability and
* register that field was in.
*
* o Related to the above, parsable mode always outputs a raw, uninterpreted
* value. This was done on purpose. Some fields require interpreting multiple
* registers to have meaning and long strings aren't always the most useful.
*
* o Every field isn't always pretty printed. This was generally just a
* decision based upon the field itself and how much work it'd be to fit it
* into the framework we have. In general, the ones we're mostly guilty of
* doing this with are related to cases where there's a scaling value in a
* subsequent register. If you find yourself wanting this, feel free to add
* it.
*
* o Currently designated vendor-specific capabilities aren't included here (or
* any specific vendor-specific capabilities for that matter). If they are
* added, they should follow the same angle of using a name to represent a
* sub-capability as we did with HyperTransport.
*/
#include <err.h>
#include <strings.h>
#include <sys/sysmacros.h>
#include <sys/pci.h>
#include <sys/pcie.h>
#include <sys/debug.h>
#include <ofmt.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/bitext.h>
#include "pcieadm.h"
typedef enum pcieadm_cfgspace_op {
PCIEADM_CFGSPACE_OP_PRINT,
PCIEADM_CFGSPACE_OP_WRITE
} pcieadm_cfgspace_op_t;
typedef enum piceadm_cfgspace_flag {
PCIEADM_CFGSPACE_F_PARSE = 1 << 0,
PCIEADM_CFGSPACE_F_SHORT = 1 << 1,
} pcieadm_cfgspace_flags_t;
typedef enum pcieadm_cfgspace_otype {
PCIEADM_CFGSPACE_OT_SHORT,
PCIEADM_CFGSPACE_OT_HUMAN,
PCIEADM_CFGSPACE_OT_VALUE
} pcieadm_cfgsapce_otype_t;
typedef struct pcieadm_cfgspace_ofmt {
const char *pco_base;
const char *pco_short;
const char *pco_human;
uint64_t pco_value;
const char *pco_strval;
} pcieadm_cfgspace_ofmt_t;
typedef enum pcieadm_regdef_val {
PRDV_STRVAL,
PRDV_BITFIELD,
PRDV_HEX
} pcieadm_regdef_val_t;
typedef struct pcieadm_regdef_addend {
uint8_t pra_shift;
int64_t pra_addend;
} pcieadm_regdef_addend_t;
typedef struct pcieadm_regdef {
uint8_t prd_lowbit;
uint8_t prd_hibit;
const char *prd_short;
const char *prd_human;
pcieadm_regdef_val_t prd_valtype;
union {
/*
* Enough space for up to an 8-bit fields worth of values
* (though we expect most to be sparse).
*/
const char *prdv_strval[128];
pcieadm_regdef_addend_t prdv_hex;
} prd_val;
} pcieadm_regdef_t;
typedef struct pcieadm_unitdef {
const char *pcd_unit;
uint32_t pcd_mult;
} pcieadm_unitdef_t;
typedef struct pcieadm_strmap {
const char *psr_str;
uint64_t psr_val;
} pcieadm_strmap_t;
typedef struct pcieadm_cfgspace_filter {
const char *pcf_string;
size_t pcf_len;
boolean_t pcf_used;
} pcieadm_cfgspace_filter_t;
typedef struct pcieadm_strfilt {
struct pcieadm_strfilt *pstr_next;
const char *pstr_str;
char pstr_curgen[256];
} pcieadm_strfilt_t;
/*
* Data is sized to be large enough that we can hold all of PCIe extended
* configuration space.
*/
typedef union pcieadm_cfgspace_data {
uint8_t pcb_u8[PCIE_CONF_HDR_SIZE];
uint32_t pcb_u32[PCIE_CONF_HDR_SIZE / 4];
} pcieadm_cfgspace_data_t;
typedef struct pcieadm_cfgspace_walk {
pcieadm_t *pcw_pcieadm;
pcieadm_cfgspace_op_t pcw_op;
uint32_t pcw_valid;
pcieadm_cfgspace_data_t *pcw_data;
uint16_t pcw_capoff;
uint32_t pcw_caplen;
int pcw_outfd;
uint_t pcw_dtype;
uint_t pcw_nlanes;
uint_t pcw_pcietype;
uint_t pcw_nfilters;
pcieadm_cfgspace_filter_t *pcw_filters;
pcieadm_cfgspace_flags_t pcw_flags;
ofmt_handle_t pcw_ofmt;
pcieadm_strfilt_t *pcw_filt;
} pcieadm_cfgspace_walk_t;
void
pcieadm_strfilt_pop(pcieadm_cfgspace_walk_t *walkp)
{
pcieadm_strfilt_t *filt;
VERIFY3P(walkp->pcw_filt, !=, NULL);
filt = walkp->pcw_filt;
walkp->pcw_filt = filt->pstr_next;
free(filt);
}
void
pcieadm_strfilt_push(pcieadm_cfgspace_walk_t *walkp, const char *str)
{
pcieadm_strfilt_t *filt;
size_t len;
filt = calloc(1, sizeof (*filt));
if (filt == NULL) {
errx(EXIT_FAILURE, "failed to allocate memory for string "
"filter");
}
filt->pstr_str = str;
if (walkp->pcw_filt == NULL) {
len = strlcat(filt->pstr_curgen, str,
sizeof (filt->pstr_curgen));
} else {
len = snprintf(filt->pstr_curgen, sizeof (filt->pstr_curgen),
"%s.%s", walkp->pcw_filt->pstr_curgen, str);
filt->pstr_next = walkp->pcw_filt;
}
if (len >= sizeof (filt->pstr_curgen)) {
errx(EXIT_FAILURE, "overflowed internal string buffer "
"appending %s", str);
}
walkp->pcw_filt = filt;
}
static boolean_t
pcieadm_cfgspace_filter(pcieadm_cfgspace_walk_t *walkp, const char *str)
{
char buf[1024];
size_t len;
if (walkp->pcw_nfilters == 0) {
return (B_TRUE);
}
if (str == NULL) {
return (B_FALSE);
}
if (walkp->pcw_filt != NULL) {
len = snprintf(buf, sizeof (buf), "%s.%s",
walkp->pcw_filt->pstr_curgen, str);
} else {
len = snprintf(buf, sizeof (buf), "%s", str);
}
if (len >= sizeof (buf)) {
abort();
}
for (uint_t i = 0; i < walkp->pcw_nfilters; i++) {
if (strcmp(buf, walkp->pcw_filters[i].pcf_string) == 0) {
walkp->pcw_filters[i].pcf_used = B_TRUE;
return (B_TRUE);
}
/*
* If we're in non-parsable mode, we want to do a little bit
* more in a few cases. We want to make sure that we print the
* parents of more-specific entries. That is, if someone
* specified 'header.command.serr', then we want to print
* 'header', and 'header.command'. Similarly, if someone
* specifies an individual field, we want to print all of its
* subfields, that is asking for 'header.command', really gets
* that and all of 'header.command.*'.
*/
if ((walkp->pcw_flags & PCIEADM_CFGSPACE_F_PARSE) != 0) {
continue;
}
if (len >= walkp->pcw_filters[i].pcf_len) {
if (strncmp(buf, walkp->pcw_filters[i].pcf_string,
walkp->pcw_filters[i].pcf_len) == 0 &&
buf[walkp->pcw_filters[i].pcf_len] == '.') {
return (B_TRUE);
}
} else {
if (strncmp(buf, walkp->pcw_filters[i].pcf_string,
len) == 0 &&
walkp->pcw_filters[i].pcf_string[len] == '.') {
return (B_TRUE);
}
}
}
return (B_FALSE);
}
static boolean_t
pcieadm_cfgspace_ofmt_cb(ofmt_arg_t *ofarg, char *buf, uint_t buflen)
{
pcieadm_cfgspace_ofmt_t *pco = ofarg->ofmt_cbarg;
switch (ofarg->ofmt_id) {
case PCIEADM_CFGSPACE_OT_SHORT:
if (snprintf(buf, buflen, "%s.%s", pco->pco_base,
pco->pco_short) >= buflen) {
return (B_FALSE);
}
break;
case PCIEADM_CFGSPACE_OT_HUMAN:
if (strlcpy(buf, pco->pco_human, buflen) >= buflen) {
return (B_FALSE);
}
break;
case PCIEADM_CFGSPACE_OT_VALUE:
if (pco->pco_strval != NULL) {
if (strlcpy(buf, pco->pco_strval, buflen) >= buflen) {
return (B_FALSE);
}
} else {
if (snprintf(buf, buflen, "0x%" PRIx64,
pco->pco_value) >= buflen) {
return (B_FALSE);
}
}
break;
default:
abort();
}
return (B_TRUE);
}
static const ofmt_field_t pcieadm_cfgspace_ofmt[] = {
{ "SHORT", 30, PCIEADM_CFGSPACE_OT_SHORT, pcieadm_cfgspace_ofmt_cb },
{ "HUMAN", 30, PCIEADM_CFGSPACE_OT_HUMAN, pcieadm_cfgspace_ofmt_cb },
{ "VALUE", 20, PCIEADM_CFGSPACE_OT_VALUE, pcieadm_cfgspace_ofmt_cb },
{ NULL, 0, 0, NULL }
};
static void
pcieadm_cfgspace_print_parse(pcieadm_cfgspace_walk_t *walkp,
const char *sname, const char *human, uint64_t value)
{
pcieadm_cfgspace_ofmt_t pco;
VERIFY3P(walkp->pcw_filt, !=, NULL);
pco.pco_base = walkp->pcw_filt->pstr_curgen;
pco.pco_short = sname;
pco.pco_human = human;
pco.pco_value = value;
pco.pco_strval = NULL;
ofmt_print(walkp->pcw_ofmt, &pco);
}
typedef struct pcieadm_cfgspace_print pcieadm_cfgspace_print_t;
typedef void (*pcieadm_cfgspace_print_f)(pcieadm_cfgspace_walk_t *,
const pcieadm_cfgspace_print_t *, const void *);
struct pcieadm_cfgspace_print {
uint8_t pcp_off;
uint8_t pcp_len;
const char *pcp_short;
const char *pcp_human;
pcieadm_cfgspace_print_f pcp_print;
const void *pcp_arg;
};
static void
pcieadm_field_printf(pcieadm_cfgspace_walk_t *walkp, const char *shortf,
const char *humanf, uint64_t val, const char *fmt, ...)
{
va_list ap;
if (!pcieadm_cfgspace_filter(walkp, shortf))
return;
if (walkp->pcw_ofmt != NULL) {
pcieadm_cfgspace_print_parse(walkp, shortf, humanf, val);
return;
}
if (walkp->pcw_pcieadm->pia_indent > 0) {
(void) printf("%*s", walkp->pcw_pcieadm->pia_indent, "");
}
if ((walkp->pcw_flags & PCIEADM_CFGSPACE_F_SHORT) != 0) {
(void) printf("|--> %s (%s.%s): ", humanf,
walkp->pcw_filt->pstr_curgen, shortf);
} else {
(void) printf("|--> %s: ", humanf);
}
va_start(ap, fmt);
(void) vprintf(fmt, ap);
va_end(ap);
}
static void
pcieadm_cfgspace_printf(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, uint64_t val, const char *fmt, ...)
{
va_list ap;
if (!pcieadm_cfgspace_filter(walkp, print->pcp_short))
return;
if (walkp->pcw_ofmt != NULL) {
pcieadm_cfgspace_print_parse(walkp, print->pcp_short,
print->pcp_human, val);
return;
}
if (walkp->pcw_pcieadm->pia_indent > 0) {
(void) printf("%*s", walkp->pcw_pcieadm->pia_indent, "");
}
if ((walkp->pcw_flags & PCIEADM_CFGSPACE_F_SHORT) != 0) {
(void) printf("%s (%s.%s): ", print->pcp_human,
walkp->pcw_filt->pstr_curgen, print->pcp_short);
} else {
(void) printf("%s: ", print->pcp_human);
}
va_start(ap, fmt);
(void) vprintf(fmt, ap);
va_end(ap);
}
static void
pcieadm_cfgspace_puts(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const char *str)
{
if (!pcieadm_cfgspace_filter(walkp, print->pcp_short))
return;
if (walkp->pcw_ofmt != NULL) {
pcieadm_cfgspace_ofmt_t pco;
VERIFY3P(walkp->pcw_filt, !=, NULL);
pco.pco_base = walkp->pcw_filt->pstr_curgen;
pco.pco_short = print->pcp_short;
pco.pco_human = print->pcp_human;
pco.pco_strval = str;
ofmt_print(walkp->pcw_ofmt, &pco);
return;
}
if (walkp->pcw_pcieadm->pia_indent > 0) {
(void) printf("%*s", walkp->pcw_pcieadm->pia_indent, "");
}
if ((walkp->pcw_flags & PCIEADM_CFGSPACE_F_SHORT) != 0) {
(void) printf("%s (%s.%s): %s\n", print->pcp_human,
walkp->pcw_filt->pstr_curgen, print->pcp_short, str);
} else {
(void) printf("%s: %s\n", print->pcp_human, str);
}
}
static uint64_t
pcieadm_cfgspace_extract(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print)
{
uint32_t val = 0;
VERIFY3U(print->pcp_len, <=, 8);
VERIFY3U(print->pcp_off + print->pcp_len + walkp->pcw_capoff, <=,
walkp->pcw_valid);
for (uint8_t i = print->pcp_len; i > 0; i--) {
val <<= 8;
val |= walkp->pcw_data->pcb_u8[walkp->pcw_capoff +
print->pcp_off + i - 1];
}
return (val);
}
static uint16_t
pcieadm_cfgspace_extract_u16(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print)
{
VERIFY(print->pcp_len == 2);
return ((uint16_t)pcieadm_cfgspace_extract(walkp, print));
}
static void
pcieadm_cfgspace_print_unit(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
const pcieadm_unitdef_t *unit = arg;
uint64_t rawval = pcieadm_cfgspace_extract(walkp, print);
uint64_t val = rawval;
if (unit->pcd_mult > 1) {
val *= unit->pcd_mult;
}
pcieadm_cfgspace_printf(walkp, print, rawval, "0x%" PRIx64 " %s%s\n",
val, unit->pcd_unit, val != 1 ? "s" : "");
}
static void
pcieadm_cfgspace_print_regdef(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
const pcieadm_regdef_t *regdef = arg;
uint64_t val = pcieadm_cfgspace_extract(walkp, print);
pcieadm_cfgspace_printf(walkp, print, val, "0x%" PRIx64 "\n", val);
pcieadm_indent();
pcieadm_strfilt_push(walkp, print->pcp_short);
for (regdef = arg; regdef->prd_short != NULL; regdef++) {
uint32_t nbits = regdef->prd_hibit - regdef->prd_lowbit + 1UL;
uint32_t bitmask = (1UL << nbits) - 1UL;
uint64_t regval = (val >> regdef->prd_lowbit) & bitmask;
const char *strval;
uint64_t actval;
if (!pcieadm_cfgspace_filter(walkp, regdef->prd_short)) {
continue;
}
switch (regdef->prd_valtype) {
case PRDV_STRVAL:
strval = regdef->prd_val.prdv_strval[regval];
if (strval == NULL) {
strval = "reserved";
}
pcieadm_field_printf(walkp, regdef->prd_short,
regdef->prd_human, regval, "%s (0x%" PRIx64 ")\n",
strval, regval << regdef->prd_lowbit);
break;
case PRDV_HEX:
actval = regval;
if (regdef->prd_val.prdv_hex.pra_shift > 0) {
actval <<= regdef->prd_val.prdv_hex.pra_shift;
}
actval += regdef->prd_val.prdv_hex.pra_addend;
pcieadm_field_printf(walkp, regdef->prd_short,
regdef->prd_human, regval, "0x% " PRIx64 "\n",
actval);
break;
case PRDV_BITFIELD:
pcieadm_field_printf(walkp, regdef->prd_short,
regdef->prd_human, regval, "0x%" PRIx64 "\n",
regval << regdef->prd_lowbit);
if (walkp->pcw_ofmt == NULL) {
pcieadm_indent();
for (uint32_t i = 0; i < nbits; i++) {
if (((1 << i) & regval) == 0)
continue;
pcieadm_print("|--> %s (0x%x)\n",
regdef->prd_val.prdv_strval[i],
1UL << (i + regdef->prd_lowbit));
}
pcieadm_deindent();
}
break;
}
}
pcieadm_strfilt_pop(walkp);
pcieadm_deindent();
}
static void
pcieadm_cfgspace_print_strmap(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
const pcieadm_strmap_t *strmap = arg;
uint64_t val = pcieadm_cfgspace_extract(walkp, print);
const char *str = "reserved";
for (uint_t i = 0; strmap[i].psr_str != NULL; i++) {
if (strmap[i].psr_val == val) {
str = strmap[i].psr_str;
break;
}
}
pcieadm_cfgspace_printf(walkp, print, val, "0x%x -- %s\n", val, str);
}
static void
pcieadm_cfgspace_print_hex(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
uint64_t val = pcieadm_cfgspace_extract(walkp, print);
pcieadm_cfgspace_printf(walkp, print, val, "0x%" PRIx64 "\n", val);
}
static void
pcieadm_cfgspace_print_vendor(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
pcidb_vendor_t *vend;
uint16_t vid = pcieadm_cfgspace_extract_u16(walkp, print);
vend = pcidb_lookup_vendor(walkp->pcw_pcieadm->pia_pcidb, vid);
if (vend != NULL) {
pcieadm_cfgspace_printf(walkp, print, vid, "0x%x -- %s\n", vid,
pcidb_vendor_name(vend));
} else {
pcieadm_cfgspace_printf(walkp, print, vid, "0x%x\n", vid);
}
}
static void
pcieadm_cfgspace_print_device(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
pcidb_device_t *dev;
uint16_t did = pcieadm_cfgspace_extract_u16(walkp, print);
uint16_t vid = walkp->pcw_data->pcb_u8[PCI_CONF_VENID] +
(walkp->pcw_data->pcb_u8[PCI_CONF_VENID + 1] << 8);
dev = pcidb_lookup_device(walkp->pcw_pcieadm->pia_pcidb, vid, did);
if (dev != NULL) {
pcieadm_cfgspace_printf(walkp, print, did, "0x%x -- %s\n", did,
pcidb_device_name(dev));
} else {
pcieadm_cfgspace_printf(walkp, print, did, "0x%x\n", did);
}
}
/*
* To print out detailed information about a subsystem vendor or device, we need
* all of the information about the vendor and device due to the organization of
* the PCI IDs db.
*/
static void
pcieadm_cfgspace_print_subid(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
uint16_t vid = walkp->pcw_data->pcb_u8[PCI_CONF_VENID] +
(walkp->pcw_data->pcb_u8[PCI_CONF_VENID + 1] << 8);
uint16_t did = walkp->pcw_data->pcb_u8[PCI_CONF_DEVID] +
(walkp->pcw_data->pcb_u8[PCI_CONF_DEVID + 1] << 8);
uint16_t svid = walkp->pcw_data->pcb_u8[PCI_CONF_SUBVENID] +
(walkp->pcw_data->pcb_u8[PCI_CONF_SUBVENID + 1] << 8);
uint16_t sdid = walkp->pcw_data->pcb_u8[PCI_CONF_SUBSYSID] +
(walkp->pcw_data->pcb_u8[PCI_CONF_SUBSYSID + 1] << 8);
uint16_t val = pcieadm_cfgspace_extract_u16(walkp, print);
boolean_t isvendor = print->pcp_off == PCI_CONF_SUBVENID;
if (isvendor) {
pcidb_vendor_t *vend;
vend = pcidb_lookup_vendor(walkp->pcw_pcieadm->pia_pcidb,
svid);
if (vend != NULL) {
pcieadm_cfgspace_printf(walkp, print, val,
"0x%x -- %s\n", val, pcidb_vendor_name(vend));
} else {
pcieadm_cfgspace_printf(walkp, print, val,
"0x%x\n", val);
}
} else {
pcidb_subvd_t *subvd;
subvd = pcidb_lookup_subvd(walkp->pcw_pcieadm->pia_pcidb, vid,
did, svid, sdid);
if (subvd != NULL) {
pcieadm_cfgspace_printf(walkp, print, val,
"0x%x -- %s\n", val, pcidb_subvd_name(subvd));
} else {
pcieadm_cfgspace_printf(walkp, print, val, "0x%x\n",
val);
}
}
}
/*
* The variable natures of BARs is a pain. This makes printing this out and the
* fields all a bit gross.
*/
static void
pcieadm_cfgspace_print_bars(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
uint32_t *barp = &walkp->pcw_data->pcb_u32[(walkp->pcw_capoff +
print->pcp_off) / 4];
char barname[32];
const char *typestrs[2] = { "Memory Space", "I/O Space" };
for (uint_t i = 0; i < print->pcp_len / 4; i++) {
uint_t type;
(void) snprintf(barname, sizeof (barname), "%s%u",
print->pcp_short, i);
type = barp[i] & PCI_BASE_SPACE_M;
if (pcieadm_cfgspace_filter(walkp, barname) &&
walkp->pcw_ofmt == NULL) {
if ((walkp->pcw_flags & PCIEADM_CFGSPACE_F_SHORT) !=
0) {
pcieadm_print("%s %u (%s.%s)\n",
print->pcp_human, i,
walkp->pcw_filt->pstr_curgen, barname);
} else {
pcieadm_print("%s %u\n", print->pcp_human, i);
}
}
pcieadm_strfilt_push(walkp, barname);
pcieadm_indent();
pcieadm_field_printf(walkp, "space", "Space", type,
"%s (0x%x)\n", typestrs[type], type);
if (type == PCI_BASE_SPACE_IO) {
uint32_t addr = barp[i] & PCI_BASE_IO_ADDR_M;
pcieadm_field_printf(walkp, "addr", "Address", addr,
"0x%" PRIx32 "\n", addr);
} else {
uint8_t type, pre;
uint64_t addr;
const char *locstr;
type = barp[i] & PCI_BASE_TYPE_M;
pre = barp[i] & PCI_BASE_PREF_M;
addr = barp[i] & PCI_BASE_M_ADDR_M;
if (type == PCI_BASE_TYPE_ALL) {
addr += (uint64_t)barp[i+1] << 32;
i++;
}
pcieadm_field_printf(walkp, "addr", "Address", addr,
"0x%" PRIx64 "\n", addr);
switch (type) {
case PCI_BASE_TYPE_MEM:
locstr = "32-bit";
break;
case PCI_BASE_TYPE_LOW:
locstr = "Sub-1 MiB";
break;
case PCI_BASE_TYPE_ALL:
locstr = "64-bit";
break;
case PCI_BASE_TYPE_RES:
default:
locstr = "Reserved";
break;
}
pcieadm_field_printf(walkp, "type", "Memory Type", addr,
"%s (0x%x)\n", locstr, type >> 1);
pcieadm_field_printf(walkp, "prefetch", "Prefetchable",
pre != 0, "%s (0x%x)\n", pre != 0 ? "yes" : "no",
pre != 0);
}
pcieadm_deindent();
pcieadm_strfilt_pop(walkp);
}
}
static void
pcieadm_cfgspace_print_ecv(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
uint16_t bitlen, nwords;
if (bitx8(walkp->pcw_data->pcb_u8[walkp->pcw_capoff + 4], 5, 5) == 0) {
return;
}
bitlen = walkp->pcw_data->pcb_u8[walkp->pcw_capoff + 5];
if (bitlen == 0) {
bitlen = 256;
}
nwords = bitlen / 32;
if ((bitlen % 8) != 0) {
nwords++;
}
for (uint16_t i = 0; i < nwords; i++) {
char tshort[32], thuman[128];
pcieadm_cfgspace_print_t p;
(void) snprintf(tshort, sizeof (tshort), "ecv%u", i);
(void) snprintf(thuman, sizeof (thuman), "Egress Control "
"Vector %u", i);
p.pcp_off = print->pcp_off + i * 4;
p.pcp_len = 4;
p.pcp_short = tshort;
p.pcp_human = thuman;
p.pcp_print = pcieadm_cfgspace_print_hex;
p.pcp_arg = NULL;
p.pcp_print(walkp, &p, p.pcp_arg);
}
}
static void
pcieadm_cfgspace_print_dpa_paa(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
uint8_t nents;
nents = bitx8(walkp->pcw_data->pcb_u8[walkp->pcw_capoff + 4], 4, 0) + 1;
if (nents == 0) {
return;
}
for (uint8_t i = 0; i < nents; i++) {
char tshort[32], thuman[128];
pcieadm_cfgspace_print_t p;
(void) snprintf(tshort, sizeof (tshort), "%s%u",
print->pcp_short, i);
(void) snprintf(thuman, sizeof (thuman), "%s %u",
print->pcp_human, i);
p.pcp_off = print->pcp_off + i;
p.pcp_len = 1;
p.pcp_short = tshort;
p.pcp_human = thuman;
p.pcp_print = pcieadm_cfgspace_print_hex;
p.pcp_arg = NULL;
p.pcp_print(walkp, &p, p.pcp_arg);
}
}
/*
* Config Space Header Table Definitions
*/
static const pcieadm_regdef_t pcieadm_regdef_command[] = {
{ 0, 0, "io", "I/O Space", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "mem", "Memory Space", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 2, 2, "bus", "Bus Master", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 3, 3, "spec", "Special Cycle", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 4, 4, "mwi", "Memory Write and Invalidate", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 5, 5, "vga", "VGA Palette Snoop", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 6, 6, "per", "Parity Error Response", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 7, 7, "idsel", "IDSEL Stepping/Wait Cycle Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 8, "serr", "SERR# Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } }, },
{ 9, 9, "fbtx", "Fast Back-to-Back Transactions", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } }, },
{ 10, 10, "intx", "Interrupt X", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "enabled", "disabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_status[] = {
{ 0, 0, "imm", "Immediate Readiness", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } }, },
{ 3, 3, "istat", "Interrupt Status", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not pending", "pending" } }, },
{ 4, 4, "capsup", "Capabilities List", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } }, },
{ 5, 5, "66mhz", "66 MHz Capable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } }, },
{ 7, 7, "fbtxcap", "Fast Back-to-Back Capable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } }, },
{ 8, 8, "mdperr", "Master Data Parity Error", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no error", "error detected" } }, },
{ 9, 10, "devsel", "DEVSEL# Timing", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "fast", "medium", "slow",
"reserved" } } },
{ 11, 11, "sta", "Signaled Target Abort", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 12, 12, "rta", "Received Target Abort", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 13, 13, "rma", "Received Master Abort", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 14, 14, "sse", "Signaled System Error", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 15, 15, "dpe", "Detected Parity Error", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ -1, -1, NULL }
};
/*
* It might be interesting to translate these into numbers at a future point.
*/
static const pcieadm_regdef_t pcieadm_regdef_class[] = {
{ 16, 23, "class", "Class Code", PRDV_HEX },
{ 7, 15, "sclass", "Sub-Class Code", PRDV_HEX },
{ 0, 7, "pi", "Programming Interface", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_bridge_iobase[] = {
{ 0, 3, "cap", "Addressing Capability", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "16-bit", "32-bit" } } },
{ 4, 7, "base", "Base", PRDV_HEX,
.prd_val = { .prdv_hex = { 12 } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_bridge_iolim[] = {
{ 0, 3, "cap", "Addressing Capability", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "16-bit", "32-bit" } } },
{ 4, 7, "limit", "Limit", PRDV_HEX,
.prd_val = { .prdv_hex = { 12, 0xfff } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_bridgests[] = {
{ 5, 5, "66mhz", "66 MHz", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 7, 7, "fastb2b", "Fast Back-to-Back Transactions", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 8, "mdperr", "Master Data Parity Error", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no error", "error detected" } } },
{ 9, 10, "devsel", "DEVSEL# Timing", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "fast", "medium", "slow" } } },
{ 11, 11, "sta", "Signaled Target Abort", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no abort", "aborted" } } },
{ 12, 12, "rta", "Received Target Abort", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no abort", "aborted" } } },
{ 13, 13, "rma", "Received Master Abort", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no abort", "aborted" } } },
{ 14, 14, "rsyserr", "Received System Error", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no error", "error received" } } },
{ 15, 15, "dperr", "Detected Parity Error", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no error", "error detected" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_bridge_membase[] = {
{ 4, 16, "base", "Base", PRDV_HEX,
.prd_val = { .prdv_hex = { 20 } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_bridge_memlim[] = {
{ 4, 16, "limit", "Limit", PRDV_HEX,
.prd_val = { .prdv_hex = { 20, 0xfffff } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_bridge_pfbase[] = {
{ 0, 3, "cap", "Addressing Capability", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "32-bit", "64-bit" } } },
{ 4, 16, "base", "Base", PRDV_HEX,
.prd_val = { .prdv_hex = { 20 } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_bridge_pflim[] = {
{ 0, 3, "cap", "Addressing Capability", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "32-bit", "64-bit" } } },
{ 4, 16, "limit", "Limit", PRDV_HEX,
.prd_val = { .prdv_hex = { 20, 0xfffff } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_bridge_ctl[] = {
{ 0, 0, "perrresp", "Parity Error Response", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "serr", "SERR#", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 2, 2, "isa", "ISA", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 3, 3, "vga", "VGA", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 4, 4, "vgadec", "VGA 16-bit Decode", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "10-bit", "16-bit" } } },
{ 5, 5, "mabort", "Master Abort", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 6, 6, "secrst", "Secondary Bus Reset", PRDV_HEX },
{ 7, 7, "fastb2b", "Fast Back-to-Back Transactions", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 8, 8, "pridisc", "Primary Discard Timer", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "2^15 cycles", "2^10 cycles" } } },
{ 9, 9, "secdisc", "Secondary Discard Timer", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "2^15 cycles", "2^10 cycles" } } },
{ 10, 10, "disctimer", "Discard Timer Error", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 11, 11, "discserr", "Discard Timer SERR#", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static pcieadm_unitdef_t pcieadm_unitdef_cache = {
"byte", 4
};
static pcieadm_unitdef_t pcieadm_unitdef_latreg = { "cycle" };
static const pcieadm_regdef_t pcieadm_regdef_header[] = {
{ 0, 6, "layout", "Header Layout", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "Device", "Bridge", "PC Card" } } },
{ 7, 7, "mfd", "Multi-Function Device", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_bist[] = {
{ 0, 3, "code", "Completion Code", PRDV_HEX },
{ 6, 6, "start", "Start BIST", PRDV_HEX },
{ 7, 7, "cap", "BIST Capable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_exprom[] = {
{ 0, 0, "enable", "Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 3, "valsts", "Validation Status", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not supported", "in progress",
"valid contents, no trust test performed",
"valid and trusted contents",
"invalid contents",
"valid but untrusted contents",
"valid contents with warning, no trust test performed",
"valid and trusted contents with warning" } } },
{ 4, 7, "valdet", "Validation Details", PRDV_HEX },
{ 11, 31, "addr", "Base Address", PRDV_HEX,
.prd_val = { .prdv_hex = { 11 } } },
{ -1, -1, NULL }
};
static pcieadm_strmap_t pcieadm_strmap_ipin[] = {
{ "none", 0 },
{ "INTA", PCI_INTA },
{ "INTB", PCI_INTB },
{ "INTC", PCI_INTC },
{ "INTD", PCI_INTD },
{ NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cfgspace_type0[] = {
{ 0x0, 2, "vendor", "Vendor ID", pcieadm_cfgspace_print_vendor },
{ 0x2, 2, "device", "Device ID", pcieadm_cfgspace_print_device },
{ 0x4, 2, "command", "Command", pcieadm_cfgspace_print_regdef,
pcieadm_regdef_command },
{ 0x6, 2, "status", "Status", pcieadm_cfgspace_print_regdef,
pcieadm_regdef_status },
{ 0x8, 1, "revision", "Revision ID", pcieadm_cfgspace_print_hex },
{ 0x9, 3, "class", "Class Code", pcieadm_cfgspace_print_regdef,
pcieadm_regdef_class },
{ 0xc, 1, "cache", "Cache Line Size", pcieadm_cfgspace_print_unit,
&pcieadm_unitdef_cache },
{ 0xd, 1, "latency", "Latency Timer", pcieadm_cfgspace_print_unit,
&pcieadm_unitdef_latreg },
{ 0xe, 1, "type", "Header Type", pcieadm_cfgspace_print_regdef,
pcieadm_regdef_header },
{ 0xf, 1, "bist", "BIST", pcieadm_cfgspace_print_regdef,
pcieadm_regdef_bist },
{ 0x10, 24, "bar", "Base Address Register",
pcieadm_cfgspace_print_bars },
{ 0x28, 4, "cis", "Cardbus CIS Pointer", pcieadm_cfgspace_print_hex },
{ 0x2c, 2, "subvid", "Subsystem Vendor ID",
pcieadm_cfgspace_print_subid },
{ 0x2e, 2, "subdev", "Subsystem Device ID",
pcieadm_cfgspace_print_subid },
{ 0x30, 4, "rom", "Expansion ROM", pcieadm_cfgspace_print_regdef,
pcieadm_regdef_exprom },
{ 0x34, 1, "cap", "Capabilities Pointer", pcieadm_cfgspace_print_hex },
{ 0x3c, 1, "iline", "Interrupt Line", pcieadm_cfgspace_print_hex },
{ 0x3d, 1, "ipin", "Interrupt Pin", pcieadm_cfgspace_print_strmap,
pcieadm_strmap_ipin },
{ 0x3e, 1, "gnt", "Min_Gnt", pcieadm_cfgspace_print_hex },
{ 0x3f, 1, "lat", "Min_Lat", pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cfgspace_type1[] = {
{ 0x0, 2, "vendor", "Vendor ID", pcieadm_cfgspace_print_vendor },
{ 0x2, 2, "device", "Device ID", pcieadm_cfgspace_print_device },
{ 0x4, 2, "command", "Command", pcieadm_cfgspace_print_regdef,
pcieadm_regdef_command },
{ 0x6, 2, "status", "Status", pcieadm_cfgspace_print_regdef,
pcieadm_regdef_status },
{ 0x8, 1, "revision", "Revision ID", pcieadm_cfgspace_print_hex },
{ 0x9, 3, "class", "Class Code", pcieadm_cfgspace_print_regdef,
pcieadm_regdef_class },
{ 0xc, 1, "cache", "Cache Line Size", pcieadm_cfgspace_print_unit,
&pcieadm_unitdef_cache },
{ 0xd, 1, "latency", "Latency Timer", pcieadm_cfgspace_print_unit,
&pcieadm_unitdef_latreg },
{ 0xe, 1, "type", "Header Type", pcieadm_cfgspace_print_regdef,
pcieadm_regdef_header },
{ 0xf, 1, "bist", "BIST", pcieadm_cfgspace_print_regdef,
pcieadm_regdef_bist },
{ 0x10, 8, "bar", "Base Address Register",
pcieadm_cfgspace_print_bars },
{ PCI_BCNF_PRIBUS, 1, "pribus", "Primary Bus Number",
pcieadm_cfgspace_print_hex },
{ PCI_BCNF_SECBUS, 1, "secbus", "Secondary Bus Number",
pcieadm_cfgspace_print_hex },
{ PCI_BCNF_SUBBUS, 1, "subbus", "Subordinate Bus Number",
pcieadm_cfgspace_print_hex },
{ PCI_BCNF_LATENCY_TIMER, 1, "latency2", "Secondary Latency timer",
pcieadm_cfgspace_print_unit, &pcieadm_unitdef_latreg },
{ PCI_BCNF_IO_BASE_LOW, 1, "iobase", "I/O Base Low",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_bridge_iobase },
{ PCI_BCNF_IO_LIMIT_LOW, 1, "iolimit", "I/O Limit Low",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_bridge_iolim },
{ PCI_BCNF_SEC_STATUS, 2, "status2", "Secondary Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_bridgests },
{ PCI_BCNF_MEM_BASE, 2, "membase", "Memory Base",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_bridge_membase },
{ PCI_BCNF_MEM_LIMIT, 2, "memlimit", "Memory Limit",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_bridge_memlim },
{ PCI_BCNF_PF_BASE_LOW, 2, "pfbase", "Prefetchable Memory Base",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_bridge_pfbase },
{ PCI_BCNF_PF_LIMIT_LOW, 2, "pflimit", "Prefetchable Memory Limit",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_bridge_pflim },
{ PCI_BCNF_PF_BASE_HIGH, 4, "pfbasehi",
"Prefetchable Base Upper 32 bits",
pcieadm_cfgspace_print_hex },
{ PCI_BCNF_PF_LIMIT_HIGH, 4, "pflimihi",
"Prefetchable Limit Upper 32 bits",
pcieadm_cfgspace_print_hex },
{ PCI_BCNF_IO_BASE_HI, 2, "iobasehi", "I/O Base Upper 16 bits",
pcieadm_cfgspace_print_hex },
{ PCI_BCNF_IO_LIMIT_HI, 2, "iolimithi", "I/O Limit Upper 16 bits",
pcieadm_cfgspace_print_hex },
{ PCI_BCNF_CAP_PTR, 1, "cap", "Capabilities Pointer",
pcieadm_cfgspace_print_hex },
{ PCI_BCNF_ROM, 4, "rom", "Expansion ROM",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_exprom },
{ PCI_BCNF_ILINE, 1, "iline", "Interrupt Line",
pcieadm_cfgspace_print_hex },
{ PCI_BCNF_IPIN, 1, "ipin", "Interrupt Pin",
pcieadm_cfgspace_print_strmap, pcieadm_strmap_ipin },
{ PCI_BCNF_BCNTRL, 2, "bctl", "Bridge Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_bridge_ctl },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cfgspace_unknown[] = {
{ 0x0, 2, "vendor", "Vendor ID", pcieadm_cfgspace_print_vendor },
{ 0x2, 2, "device", "Device ID", pcieadm_cfgspace_print_device },
{ 0x8, 1, "revision", "Revision ID", pcieadm_cfgspace_print_hex },
{ 0xe, 1, "type", "Header Type", pcieadm_cfgspace_print_regdef,
pcieadm_regdef_header },
{ -1, -1, NULL }
};
/*
* Power Management Capability Version 3. Note versions two and three seem to be
* the same, but are used to indicate compliance to different revisions of the
* PCI power management specification.
*/
static const pcieadm_regdef_t pcieadm_regdef_pmcap[] = {
{ 0, 2, "vers", "Version", PRDV_HEX },
{ 3, 3, "clock", "PME Clock", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not required", "required" } } },
{ 4, 4, "irrd0", "Immediate Readiness on Return to D0", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 5, 5, "dsi", "Device Specific Initialization", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 6, 8, "auxcur", "Auxiliary Current", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "0", "55 mA", "100 mA", "160 mA",
"220 mA", "270 mA", "320 mA", "375 mA" } } },
{ 9, 9, "d1", "D1", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 10, 10, "d2", "D2", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 11, 15, "pme", "PME Support", PRDV_BITFIELD,
.prd_val = { .prdv_strval = { "D0", "D1", "D2", "D3hot",
"D3cold" } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_pcipm_v3[] = {
{ PCI_PMCAP, 2, "pmcap", "Power Management Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pmcap },
{ -1, -1, NULL }
};
/*
* PCI Bridge Subsystem Capability
*/
static const pcieadm_cfgspace_print_t pcieadm_cap_bridge_subsys[] = {
{ 0x4, 2, "subvid", "Subsystem Vendor ID", pcieadm_cfgspace_print_hex },
{ 0x6, 2, "subdev", "Subsystem Device ID", pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
/*
* MSI Capability
*/
static const pcieadm_regdef_t pcieadm_regdef_msictrl[] = {
{ 0, 0, "enable", "MSI Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 3, "mmsgcap", "Multiple Message Capable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "1 vector", "2 vectors",
"4 vectors", "8 vectors", "16 vectors", "32 vectors" } } },
{ 4, 6, "mmsgen", "Multiple Message Enabled", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "1 vector", "2 vectors",
"4 vectors", "8 vectors", "16 vectors", "32 vectors" } } },
{ 7, 7, "addr64", "64-bit Address Capable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 8, "pvm", "Per-Vector Masking Capable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 9, 9, "extmdcap", "Extended Message Data Capable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 10, 10, "extmden", "extended Message Data Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_msi_32[] = {
{ PCI_MSI_CTRL, 2, "ctrl", "Message Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_msictrl },
{ PCI_MSI_ADDR_OFFSET, 4, "addr", "Message Address",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_32BIT_DATA, 2, "data", "Message Data",
pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_msi_32ext[] = {
{ PCI_MSI_CTRL, 2, "ctrl", "Message Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_msictrl },
{ PCI_MSI_ADDR_OFFSET, 4, "addr", "Message Address",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_32BIT_DATA, 2, "data", "Message Data",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_32BIT_EXTDATA, 2, "extdata", "Extended Message Data",
pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_msi_32pvm[] = {
{ PCI_MSI_CTRL, 2, "ctrl", "Message Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_msictrl },
{ PCI_MSI_ADDR_OFFSET, 4, "addr", "Message Address",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_32BIT_DATA, 2, "data", "Message Data",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_32BIT_EXTDATA, 2, "extdata", "Extended Message Data",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_32BIT_MASK, 4, "mask", "Mask Bits",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_32BIT_PENDING, 4, "pend", "Pending Bits",
pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_msi_64[] = {
{ PCI_MSI_CTRL, 2, "ctrl", "Message Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_msictrl },
{ PCI_MSI_ADDR_OFFSET, 4, "addr", "Message Address",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_64BIT_ADDR, 4, "upadd", "Upper Message Address",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_64BIT_DATA, 2, "data", "Message Data",
pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_msi_64ext[] = {
{ PCI_MSI_CTRL, 2, "ctrl", "Message Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_msictrl },
{ PCI_MSI_ADDR_OFFSET, 4, "addr", "Message Address",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_64BIT_ADDR, 4, "upadd", "Upper Message Address",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_64BIT_DATA, 2, "data", "Message Data",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_64BIT_EXTDATA, 2, "extdata", "Extended Message Data",
pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_msi_64pvm[] = {
{ PCI_MSI_CTRL, 2, "ctrl", "Message Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_msictrl },
{ PCI_MSI_ADDR_OFFSET, 4, "addr", "Message Address",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_64BIT_ADDR, 4, "upadd", "Upper Message Address",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_64BIT_DATA, 2, "data", "Message Data",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_64BIT_EXTDATA, 2, "extdata", "Extended Message Data",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_64BIT_MASKBITS, 4, "mask", "Mask Bits",
pcieadm_cfgspace_print_hex },
{ PCI_MSI_64BIT_PENDING, 4, "pend", "Pending Bits",
pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
/*
* MSI-X Capability
*/
static const pcieadm_regdef_t pcieadm_regdef_msixctrl[] = {
{ 0, 10, "size", "Table Size", PRDV_HEX,
.prd_val = { .prdv_hex = { 0, 1 } } },
{ 14, 14, "mask", "Function Mask", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unmasked", "masked" } } },
{ 15, 15, "enable", "MSI-X Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_msixtable[] = {
{ 0, 2, "bir", "Table BIR", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "BAR 0", "BAR 1", "BAR 2", "BAR 3",
"BAR 4", "BAR 5" } } },
{ 3, 31, "offset", "Table Offset", PRDV_HEX,
.prd_val = { .prdv_hex = { 3 } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_msixpba[] = {
{ 0, 2, "bir", "PBA BIR", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "BAR 0", "BAR 1", "BAR 2", "BAR 3",
"BAR 4", "BAR 5" } } },
{ 3, 31, "offset", "PBA Offset", PRDV_HEX,
.prd_val = { .prdv_hex = { 3 } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_msix[] = {
{ PCI_MSIX_CTRL, 2, "ctrl", "Control Register",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_msixctrl },
{ PCI_MSIX_TBL_OFFSET, 4, "table", "Table Offset",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_msixtable },
{ PCI_MSIX_PBA_OFFSET, 4, "pba", "PBA Offset",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_msixpba },
{ -1, -1, NULL }
};
/*
* PCI Express Capability
*/
static const pcieadm_regdef_t pcieadm_regdef_pcie_cap[] = {
{ 0, 3, "vers", "Version", PRDV_HEX },
{ 4, 7, "type", "Device/Port Type", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "PCIe Endpoint",
"Legacy PCIe Endpoint", NULL, NULL,
"Root Port of PCIe Root Complex",
"Upstream Port of PCIe Switch",
"Downstream Port of PCIe Switch",
"PCIe to PCI/PCI-X Bridge",
"PCI/PCI-x to PCIe Bridge",
"RCiEP",
"Root Complex Event Collector" } } },
{ 8, 8, "slot", "Slot Implemented", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "No", "Yes" } } },
{ 9, 13, "intno", "Interrupt Message Number", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_devcap[] = {
{ 0, 2, "mps", "Max Payload Size Supported", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "128 bytes", "256 bytes",
"512 bytes", "1024 bytes", "2048 bytes", "4096 bytes" } } },
{ 3, 4, "pfunc", "Phantom Functions Supported", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "No", "1-bit", "2-bits",
"3-bits" } } },
{ 5, 5, "exttag", "Extended Tag Field", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "5-bit", "8-bit" } } },
{ 6, 8, "l0slat", "L0s Acceptable Latency", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "64 ns", "128 ns", "256 ns",
"512 ns", "1 us", "2 us", "4 us", "No limit" } } },
{ 9, 11, "l1lat", "L1 Acceptable Latency", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "1 us", "2 us", "4 us", "8 us",
"16 us", "32 us", "64 us", "No limit" } } },
{ 15, 15, "rber", "Role Based Error Reporting", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 16, 16, "errcor", "ERR_COR Subclass", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 18, 25, "csplv", "Captured Slot Power Limit", PRDV_HEX },
{ 26, 27, "cspls", "Captured Slot Power Limit Scale", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "1.0x", "0.1x", "0.01x",
"0.001x" } } },
{ 28, 28, "flr", "Function Level Reset", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_devctl[] = {
{ 0, 0, "corerr", "Correctable Error Reporting", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "nferr", "Non-Fatal Error Reporting", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 2, 2, "ferr", "Fatal Error Reporting", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 3, 3, "unsupreq", "Unsupported Request Reporting", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 4, 4, "relord", "Relaxed Ordering", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 5, 7, "mps", "Max Payload Size", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "128 bytes", "256 bytes",
"512 bytes", "1024 bytes", "2048 bytes", "4096 bytes" } } },
{ 8, 8, "exttag", "Extended Tag Field", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 9, 9, "pfunc", "Phantom Functions", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 9, 9, "auxpm", "Aux Power PM", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 11, 11, "nosnoop", "No Snoop", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 12, 14, "mrrs", "Max Read Request Size", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "128 bytes", "256 bytes",
"512 bytes", "1024 bytes", "2048 bytes", "4096 bytes" } } },
{ 15, 15, "bcrflr", "Bridge Configuration Retry / Function Level Reset",
PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_devsts[] = {
{ 0, 0, "corerr", "Correctable Error Detected", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 1, 1, "nferr", "Non-Fatal Error Detected", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 2, 2, "ferr", "Fatal Error Detected", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 3, 3, "unsupreq", "Unsupported Request Detected", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 4, 4, "auxpm", "AUX Power Detected", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 5, 5, "txpend", "Transactions Pending", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 6, 6, "eprd", "Emergency Power Reduction Detected", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_linkcap[] = {
{ 0, 3, "maxspeed", "Maximum Link Speed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { NULL, "2.5 GT/s", "5.0 GT/s",
"8.0 GT/s", "16.0 GT/s", "32.0 GT/s", "64.0 GT/s" } } },
{ 4, 9, "maxwidth", "Maximum Link Width", PRDV_HEX },
{ 10, 11, "aspm", "ASPM Support", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "None", "L0s", "L1", "L0s/L1" } } },
{ 12, 14, "l0slat", "L0s Exit Latency", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "<64ns", "64-128ns", "128-256ns",
"256-512ns", "512ns-1us", "1-2us", "2-4us", ">4us" } } },
{ 15, 17, "l1lat", "L1 Exit Latency", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "<1us", "1-2us", "2-4us", "4-8us",
"8-16us", "16-32us" "32-64us", ">64us" } } },
{ 18, 18, "clockpm", "Clock Power Management", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 19, 19, "supdown", "Surprise Down Error Reporting", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 20, 20, "dlact", "Data Link Layer Active Reporting", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 21, 21, "linkbw", "Link Bandwidth Notification Capability",
PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 22, 22, "aspmcomp", "ASPM Optionality Compliance", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not compliant", "compliant" } } },
{ 24, 31, "portno", "Port Number", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_linkctl[] = {
{ 0, 1, "aspmctl", "ASPM Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "None", "L0s", "L1", "L0s/L1" } } },
{ 3, 3, "rcb", "Read Completion Boundary", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "64 byte", "128 byte" } } },
{ 4, 4, "disable", "Link Disable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not force disabled",
"force disabled" } } },
{ 5, 5, "retrain", "Retrain Link", PRDV_HEX },
{ 6, 6, "ccc", "Common Clock Configuration", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "asynchronous", "common" } } },
{ 7, 7, "extsync", "Extended Sync", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 8, 8, "clkpm", "Clock Power Management", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 9, 9, "hwawd", "Hardware Autonomous Width", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "enabled", "disabled" } } },
{ 10, 10, "linkbwint", "Link Bandwidth Management Interrupt",
PRDV_STRVAL, .prd_val = { .prdv_strval = { "disabled",
"enabled" } } },
{ 11, 11, "linkabwint", "Link Autonomous Bandwidth Interrupt",
PRDV_STRVAL, .prd_val = { .prdv_strval = { "disabled",
"enabled" } } },
{ 14, 15, "drs", "DRS Signaling Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not reported", "Interrupt enabled",
"DRS->FRS enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_linksts[] = {
{ 0, 3, "speed", "Link Speed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { NULL, "2.5 GT/s", "5.0 GT/s",
"8.0 GT/s", "16.0 GT/s", "32.0 GT/s", "64.0 GT/s" } } },
{ 4, 9, "width", "Link Width", PRDV_HEX },
{ 11, 11, "training", "Link Training", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 12, 12, "slotclk", "Slot Clock Configuration", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "asynchronous", "common" } } },
{ 13, 13, "dllact", "Data Link Layer Link Active", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 14, 14, "linkbw", "Link Bandwidth Management Status", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no change", "change occurred" } } },
{ 15, 15, "linkabw", "Link Autonomous Bandwidth Status", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no change", "change occurred" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_slotcap[] = {
{ 0, 0, "attnbtn", "Attention Button Present", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 1, 1, "pwrctrl", "Power Controller Present", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 2, 2, "mrlsen", "MRL Sensor Present", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 3, 3, "attnind", "Attention Indicator Present", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 4, 4, "pwrind", "Power Indicator Present", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 5, 5, "hpsup", "Hot-Plug Surprise", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 6, 6, "hpcap", "Hot-Plug Capable ", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 7, 14, "slotplv", "Slot Power Limit Value", PRDV_HEX },
{ 15, 16, "slotpls", "Slot Power Limit Scale", PRDV_HEX },
{ 17, 17, "emi", "Electromechanical Interlock Present", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 18, 18, "ncc", "No Command Completed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 19, 31, "slotno", "Physical Slot Number", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_slotctl[] = {
{ 0, 0, "attnbtn", "Attention Button Pressed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "pwrflt", "Power Fault Detected", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 2, 2, "mrlchg", "MRL Sensor Changed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 3, 3, "preschg", "Presence Detect Changed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 4, 4, "ccmpltint", "Command Complete Interrupt", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "Enabled" } } },
{ 5, 5, "hpi", "Hot Plug Interrupt Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 6, 7, "attnind", "Attention Indicator Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { NULL, "on", "blink", "off" } } },
{ 8, 9, "pwrin", "Power Indicator Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { NULL, "on", "blink", "off" } } },
{ 10, 10, "pwrctrl", "Power Controller Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "power on", "power off" } } },
{ 11, 11, "emi", "Electromechanical Interlock Control", PRDV_HEX },
{ 12, 12, "dll", "Data Link Layer State Changed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 13, 13, "autopowdis", "Auto Slot Power Limit", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "enabled", "disabled" } } },
{ 14, 14, "ibpddis", "In-Band PD", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "enabled", "disabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_slotsts[] = {
{ 0, 0, "attnbtn", "Attention Button Pressed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 1, 1, "pwrflt", "Power Fault Detected", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 2, 2, "mrlchg", "MRL Sensor Changed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 3, 3, "preschg", "Presence Detect Changed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 4, 4, "ccmplt", "Command Complete", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 5, 5, "mrlsen", "MRL Sensor State", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "closed", "open" } } },
{ 6, 6, "presdet", "Presence Detect State", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not present", "present" } } },
{ 7, 7, "emi", "Electromechanical Interlock", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disengaged", "engaged" } } },
{ 8, 8, "dll", "Data Link Layer State Changed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_rootcap[] = {
{ 0, 0, "syscorerr", "System Error on Correctable Error", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "sysnonftl", "System Error on Non-Fatal Error", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 2, 2, "sysfatal", "System Error on Fatal Error", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 3, 3, "pmeie", "PME Interrupt", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 4, 4, "crssw", "CRS Software Visibility", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_rootctl[] = {
{ 0, 0, "crssw", "CRS Software Visibility", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_rootsts[] = {
{ 0, 15, "pmereqid", "PME Requester ID", PRDV_HEX },
{ 16, 16, "pmests", "PME Status", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "deasserted", "asserted" } } },
{ 17, 17, "pmepend", "PME Pending", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_devcap2[] = {
{ 0, 3, "cmpto", "Completion Timeout Ranges Supported", PRDV_BITFIELD,
.prd_val = { .prdv_strval = { "50us-10ms", "10ms-250ms",
"250ms-4s", "4s-64s" } } },
{ 4, 4, "cmptodis", "Completion Timeout Disable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 5, 5, "ari", "ARI Forwarding", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 6, 6, "atomroute", "AtomicOp Routing", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 7, 7, "atom32", "32-bit AtomicOp Completer", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 8, "atom64", "64-bit AtomicOp Completer", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 9, 9, "cas128", "128-bit CAS Completer", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 10, 10, "norelord", "No Ro-enabld PR-PR Passing", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 11, 11, "ltr", "LTR Mechanism", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 12, 13, "tph", "TPH Completer", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "TPH supported",
NULL, "TPH and Extended TPH supported" } } },
{ 14, 15, "lncls", "LN System CLS", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported",
"LN with 64-byte cachelines", "LN with 128-byte cachelines" } } },
{ 16, 16, "tag10comp", "10-bit Tag Completer", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 17, 17, "tag10req", "10-bit Tag Requester", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 18, 19, "obff", "OBFF", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "Message Signaling",
"WAKE# Signaling", "WAKE# and Message Signaling" } } },
{ 20, 20, "extfmt", "Extended Fmt Field Supported", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 21, 21, "eetlp", "End-End TLP Prefix Supported", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 22, 23, "maxeetlp", "Max End-End TLP Prefixes", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "4", "1", "2", "3" } } },
{ 24, 25, "empr", "Emergency Power Reduction", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported",
"supported, device-specific",
"supported, from factor or device-specific" } } },
{ 21, 21, "emprinit",
"Emergency Power Reduction Initialization Required", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 31, 31, "frs", "Function Readiness Status", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_devctl2[] = {
{ 0, 3, "cmpto", "Completion Timeout", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "50us-50ms", "50us-100us",
"1ms-10ms", NULL, NULL, "16ms-55ms", "65ms-210ms", NULL, NULL,
"260ms-900ms", "1s-3.5s", NULL, NULL, "4s-13s", "17s-64s" } } },
{ 4, 4, "cmptodis", "Completion Timeout Disabled", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not disabled", "disabled" } } },
{ 5, 5, "ari", "ARI Forwarding", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 6, 6, "atomreq", "AtomicOp Requester", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 7, 7, "atomblock", "AtomicOp Egress Blocking", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unblocked", "blocked" } } },
{ 8, 8, "idoreq", "ID-Based Ordering Request", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 9, 9, "idocomp", "ID-Based Ordering Completion", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 10, 10, "ltr", "LTR Mechanism", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 11, 11, "empowred", "Emergency Power Reduction", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not requested", "requested" } } },
{ 12, 12, "tag10req", "10-bit Tag Requester", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 13, 14, "obff", "OBFF", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "message signaling - A",
"message signaling - B", "WAKE# signaling" } } },
{ 15, 15, "eetlpblk", "End-End TLP Prefix Blocking", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unblocked", "blocked" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_devsts2[] = {
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_linkcap2[] = {
{ 1, 7, "supspeeds", "Supported Link Speeds", PRDV_BITFIELD,
.prd_val = { .prdv_strval = { "2.5 GT/s", "5.0 GT/s", "8.0 GT/s",
"16.0 GT/s", "32.0 GT/s", "64.0 GT/s" } } },
{ 8, 8, "crosslink", "Crosslink", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 9, 15, "skposgen", "Lower SKP OS Generation Supported Speeds Vector",
PRDV_BITFIELD,
.prd_val = { .prdv_strval = { "2.5 GT/s", "5.0 GT/s", "8.0 GT/s",
"16.0 GT/s", "32.0 GT/s", "64.0 GT/s" } } },
{ 16, 22, "skposrecv", "Lower SKP OS Reception Supported Speeds Vector",
PRDV_BITFIELD,
.prd_val = { .prdv_strval = { "2.5 GT/s", "5.0 GT/s", "8.0 GT/s",
"16.0 GT/s", "32.0 GT/s", "64.0 GT/s" } } },
{ 23, 23, "retimedet", "Retimer Presence Detect Supported", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 24, 24, "retime2det", "Two Retimers Presence Detect Supported",
PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 31, 31, "drs", "Device Readiness Status", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_linkctl2[] = {
{ 0, 3, "targspeed", "Target Link Speed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { NULL, "2.5 GT/s", "5.0 GT/s",
"8.0 GT/s", "16.0 GT/s", "32.0 GT/s", "64.0 GT/s" } } },
{ 4, 4, "comp", "Enter Compliance", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 5, 5, "hwautosp", "Hardware Autonomous Speed Disable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not disabled", "disabled" } } },
{ 6, 6, "seldeemph", "Selectable De-emphasis", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "-6 dB", "-3.5 dB" } } },
{ 7, 9, "txmarg", "TX Margin", PRDV_HEX },
{ 10, 10, "modcomp", "Enter Modified Compliance", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 11, 11, "compsos", "Compliance SOS",
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 12, 15, "compemph", "Compliance Preset/De-emphasis", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_linksts2[] = {
{ 0, 0, "curdeemph", "Current De-emphasis Level", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "-6 dB", "-3.5 dB" } } },
{ 1, 1, "eq8comp", "Equalization 8.0 GT/s Complete", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 2, 2, "eq8p1comp", "Equalization 8.0 GT/s Phase 1", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsuccessful", "successful" } } },
{ 3, 3, "eq8p2comp", "Equalization 8.0 GT/s Phase 2", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsuccessful", "successful" } } },
{ 4, 4, "eq8p3comp", "Equalization 8.0 GT/s Phase 3", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsuccessful", "successful" } } },
{ 5, 5, "linkeq8req", "Link Equalization Request 8.0 GT/s", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not requested", "requested" } } },
{ 6, 6, "retimedet", "Retimer Presence Detected", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 7, 7, "retime2det", "Two Retimers Presence Detected", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 8, 9, "crosslink", "Crosslink Resolution", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "upstream port",
"downstream port", "incomplete" } } },
{ 12, 14, "dscomppres", "Downstream Component Presence", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "link down - undetermined",
"link down - not present", "link down - present", NULL,
"link up - present", "link up - present and DRS" } } },
{ 15, 15, "drsrx", "DRS Message Received", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_slotcap2[] = {
{ 0, 0, "ibpddis", "In-Band PD Disable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_slotctl2[] = {
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie_slotsts2[] = {
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_pcie_v1_dev[] = {
{ PCIE_PCIECAP, 2, "cap", "Capability Register",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_cap },
{ PCIE_DEVCAP, 4, "devcap", "Device Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_devcap },
{ PCIE_DEVSTS, 2, "devsts", "Device Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_devsts },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_pcie_v1_link[] = {
{ PCIE_PCIECAP, 2, "cap", "Capability Register",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_cap },
{ PCIE_DEVCAP, 4, "devcap", "Device Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_devcap },
{ PCIE_DEVSTS, 2, "devsts", "Device Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_devsts },
{ PCIE_LINKCAP, 4, "linkcap", "Link Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linkcap },
{ PCIE_LINKCTL, 2, "linkctl", "Link Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linkctl },
{ PCIE_LINKSTS, 2, "linksts", "Link Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linksts },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_pcie_v1_slot[] = {
{ PCIE_PCIECAP, 2, "cap", "Capability Register",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_cap },
{ PCIE_DEVCAP, 4, "devcap", "Device Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_devcap },
{ PCIE_DEVSTS, 2, "devsts", "Device Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_devsts },
{ PCIE_LINKCAP, 4, "linkcap", "Link Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linkcap },
{ PCIE_LINKCTL, 2, "linkctl", "Link Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linkctl },
{ PCIE_LINKSTS, 2, "linksts", "Link Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linksts },
{ PCIE_SLOTCAP, 4, "slotcap", "Slot Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_slotcap },
{ PCIE_SLOTCTL, 2, "slotctl", "Slot Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_slotctl },
{ PCIE_SLOTSTS, 2, "slotsts", "Slot Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_slotsts },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_pcie_v1_all[] = {
{ PCIE_PCIECAP, 2, "cap", "Capability Register",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_cap },
{ PCIE_DEVCAP, 4, "devcap", "Device Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_devcap },
{ PCIE_DEVSTS, 2, "devsts", "Device Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_devsts },
{ PCIE_LINKCAP, 4, "linkcap", "Link Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linkcap },
{ PCIE_LINKCTL, 2, "linkctl", "Link Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linkctl },
{ PCIE_LINKSTS, 2, "linksts", "Link Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linksts },
{ PCIE_SLOTCAP, 4, "slotcap", "Slot Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_slotcap },
{ PCIE_SLOTCTL, 2, "slotctl", "Slot Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_slotctl },
{ PCIE_SLOTSTS, 2, "slotsts", "Slot Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_slotsts },
{ PCIE_ROOTCTL, 2, "rootctl", "Root control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_rootctl },
{ PCIE_ROOTCAP, 2, "rootcap", "Root Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_rootcap },
{ PCIE_ROOTSTS, 4, "rootsts", "Root Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_rootsts },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_pcie_v2[] = {
{ PCIE_PCIECAP, 2, "cap", "Capability Register",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_cap },
{ PCIE_DEVCAP, 4, "devcap", "Device Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_devcap },
{ PCIE_DEVCTL, 2, "devctl", "Device Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_devctl },
{ PCIE_DEVSTS, 2, "devsts", "Device Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_devsts },
{ PCIE_LINKCAP, 4, "linkcap", "Link Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linkcap },
{ PCIE_LINKCTL, 2, "linkctl", "Link Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linkctl },
{ PCIE_LINKSTS, 2, "linksts", "Link Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linksts },
{ PCIE_SLOTCAP, 4, "slotcap", "Slot Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_slotcap },
{ PCIE_SLOTCTL, 2, "slotctl", "Slot Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_slotctl },
{ PCIE_SLOTSTS, 2, "slotsts", "Slot Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_slotsts },
{ PCIE_ROOTCTL, 2, "rootctl", "Root Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_rootctl },
{ PCIE_ROOTCAP, 2, "rootcap", "Root Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_rootcap },
{ PCIE_ROOTSTS, 4, "rootsts", "Root Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_rootsts },
{ PCIE_DEVCAP2, 4, "devcap2", "Device Capabilities 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_devcap2 },
{ PCIE_DEVCTL2, 2, "devctl2", "Device Control 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_devctl2 },
{ PCIE_DEVSTS2, 2, "devsts2", "Device Status 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_devsts2 },
{ PCIE_LINKCAP2, 4, "linkcap2", "Link Capabilities 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linkcap2 },
{ PCIE_LINKCTL2, 2, "linkctl2", "Link Control 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linkctl2 },
{ PCIE_LINKSTS2, 2, "linksts2", "Link Status 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_linksts2 },
{ PCIE_SLOTCAP2, 4, "slotcap2", "Slot Capabilities 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_slotcap2 },
{ PCIE_SLOTCTL2, 2, "slotctl2", "Slot Control 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_slotctl2 },
{ PCIE_SLOTSTS2, 2, "slotsts2", "Slot Status 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_slotsts2 },
{ -1, -1, NULL }
};
/*
* PCIe Extended Capability Header
*/
static const pcieadm_regdef_t pcieadm_regdef_pcie_caphdr[] = {
{ 0, 15, "capid", "Capability ID", PRDV_HEX },
{ 16, 19, "version", "Capability Version", PRDV_HEX },
{ 20, 32, "offset", "Next Capability Offset", PRDV_HEX },
{ -1, -1, NULL }
};
/*
* VPD Capability
*/
static const pcieadm_regdef_t pcieadm_regdef_vpd_addr[] = {
{ 0, 14, "addr", "VPD Address", PRDV_HEX },
{ 15, 15, "flag", "Flag", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_vpd[] = {
{ 0x2, 2, "addr", "VPD Address Register",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_vpd_addr },
{ 0x4, 4, "data", "VPD Data", pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
/*
* SATA Capability per AHCI 1.3.1
*/
static const pcieadm_regdef_t pcieadm_regdef_sata_cr0[] = {
{ 0, 3, "minrev", "Minor Revision", PRDV_HEX },
{ 4, 7, "majrev", "Major Revision", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_sata_cr1[] = {
{ 0, 3, "bar", "BAR Location", PRDV_HEX,
.prd_val = { .prdv_hex = { 2 } } },
{ 4, 23, "offset", "BAR Offset", PRDV_HEX,
.prd_val = { .prdv_hex = { 2 } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_sata[] = {
{ 0x2, 2, "satacr0", "SATA Capability Register 0",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_sata_cr0 },
{ 0x4, 4, "satacr1", "SATA Capability Register 1",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_sata_cr1 },
{ -1, -1, NULL }
};
/*
* Debug Capability per EHCI
*/
static const pcieadm_regdef_t pcieadm_regdef_debug[] = {
{ 0, 12, "offset", "BAR Offset", PRDV_HEX },
{ 13, 15, "bar", "BAR Location ", PRDV_STRVAL,
.prd_val = { .prdv_strval = { NULL, "BAR 0", "BAR 1", "BAR 2",
"BAR 3", "BAR 4", "BAR 5" } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_debug[] = {
{ 0x2, 2, "port", "Debug Port",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_debug },
{ -1, -1, NULL }
};
/*
* AER Capability
*/
static const pcieadm_regdef_t pcieadm_regdef_aer_ue[] = {
{ 4, 4, "dlp", "Data Link Protocol Error", PRDV_HEX },
{ 5, 5, "sde", "Surprise Down Error", PRDV_HEX },
{ 12, 12, "ptlp", "Poisoned TLP Received", PRDV_HEX },
{ 13, 13, "fcp", "Flow Control Protocol Error", PRDV_HEX },
{ 14, 14, "cto", "Completion Timeout", PRDV_HEX },
{ 15, 15, "cab", "Completion Abort", PRDV_HEX },
{ 16, 16, "unco", "Unexpected Completion", PRDV_HEX },
{ 17, 17, "rxov", "Receiver Overflow", PRDV_HEX },
{ 18, 18, "maltlp", "Malformed TLP", PRDV_HEX },
{ 19, 19, "ecrc", "ECRC Error", PRDV_HEX },
{ 20, 20, "usuprx", "Unsupported Request Error", PRDV_HEX },
{ 21, 21, "acs", "ACS Violation", PRDV_HEX },
{ 22, 22, "ueint", "Uncorrectable Internal Error", PRDV_HEX },
{ 23, 23, "mcbtlp", "MC Blocked TLP", PRDV_HEX },
{ 24, 24, "atoomeb", "AtomicOp Egress Blocked", PRDV_HEX },
{ 25, 25, "tlppb", "TLP Prefix Blocked Error", PRDV_HEX },
{ 26, 26, "ptlpeb", "Poisoned TLP Egress Blocked", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_aer_ce[] = {
{ 0, 0, "rxerr", "Receiver Error", PRDV_HEX },
{ 6, 6, "badtlp", "Bad TLP", PRDV_HEX },
{ 7, 7, "baddllp", "Bad DLLP", PRDV_HEX },
{ 8, 8, "replayro", "REPLAY_NUM Rollover", PRDV_HEX },
{ 12, 12, "rtto", "Replay timer Timeout", PRDV_HEX },
{ 13, 13, "advnfe", "Advisory Non-Fatal Error", PRDV_HEX },
{ 14, 14, "ceint", "Correctable Internal Error", PRDV_HEX },
{ 15, 15, "headlov", "Header Log Overflow", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_aer_ctrl[] = {
{ 0, 4, "feptr", "First Error Pointer", PRDV_HEX },
{ 5, 5, "ecgencap", "ECRC Generation Capable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 6, 6, "ecgenen", "ECRC Generation Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 7, 7, "ecchkcap", "ECRC Check Capable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 8, "ecchken", "ECRC Check Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_aer_rootcom[] = {
{ 0, 0, "corerr", "Correctable Error Reporting", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "nferr", "Non-Fatal Error Reporting", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 2, 2, "faterr", "Fatal Error Reporting", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_aer_rootsts[] = {
{ 0, 0, "errcor", "ERR_COR Received", PRDV_HEX },
{ 1, 1, "merrcor", "Multiple ERR_COR Received", PRDV_HEX },
{ 2, 2, "errfnf", "ERR_FATAL/NONFATAL Received", PRDV_HEX },
{ 3, 3, "merrfnf", "Multiple ERR_FATAL/NONFATAL Received", PRDV_HEX },
{ 4, 4, "fuefat", "First Uncorrectable Fatal", PRDV_HEX },
{ 5, 5, "nferrrx", "Non-Fatal Error Messages Received", PRDV_HEX },
{ 6, 6, "faterrx", "Fatal Error Messages Received", PRDV_HEX },
{ 7, 8, "errcorsc", "ERR_COR Subclass", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "ECS Legacy", "ECS SIG_SFW",
"ECS SIG_OS", "ECS Extended" } } },
{ 27, 31, "inum", "Advanced Error Interrupt Message", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_aer_esi[] = {
{ 0, 15, "errcorr", "ERR_COR Source", PRDV_HEX },
{ 16, 31, "errfnf", "ERR_FATAL/NONFATAL Source", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_aer_secue[] = {
{ 0, 0, "taosc", "Target-Abort on Split Completion", PRDV_HEX },
{ 1, 1, "maosc", "Master-Abort on Split Completion", PRDV_HEX },
{ 2, 2, "rxta", "Received Target-Abort", PRDV_HEX },
{ 3, 3, "rxma", "Received Master-Abort", PRDV_HEX },
{ 5, 5, "unsce", "Unexpected Split Completion Error", PRDV_HEX },
{ 6, 6, "uescmd", "Uncorrectable Split Completion Message Data Error",
PRDV_HEX },
{ 7, 7, "uede", "Uncorrectable Data Error", PRDV_HEX },
{ 8, 8, "ueattre", "Uncorrectable Attribute Error", PRDV_HEX },
{ 9, 9, "ueaddre", "Uncorrectable Address Error", PRDV_HEX },
{ 10, 10, "dtdte", "Delayed Transaction Discard Timer Expired",
PRDV_HEX },
{ 11, 11, "perr", "PERR# Assertion", PRDV_HEX },
{ 12, 12, "serr", "SERR# Assertion", PRDV_HEX },
{ 13, 13, "internal", "Internal Bridge Error", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_aer_secctl[] = {
{ 0, 4, "feptr", "Secondary Uncorrectable First Error Pointer",
PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_aer_v1[] = {
{ PCIE_AER_CAP, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ PCIE_AER_UCE_STS, 4, "uestatus", "Uncorrectable Error Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ue },
{ PCIE_AER_UCE_MASK, 4, "uemask", "Uncorrectable Error Mask",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ue },
{ PCIE_AER_UCE_SERV, 4, "ueserv", "Uncorrectable Error Severity",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ue },
{ PCIE_AER_CE_STS, 4, "cestatus", "Correctable Error Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ce },
{ PCIE_AER_CE_MASK, 4, "cemask", "Correctable Error Mask",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ce },
{ PCIE_AER_CTL, 4, "ctrl", "Advanced Error Capabilities and Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ctrl },
{ PCIE_AER_HDR_LOG + 4, 4, "hl0", "Header Log 0",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_HDR_LOG + 8, 4, "hl1", "Header Log 1",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_HDR_LOG + 12, 4, "hl2", "Header Log 2",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_HDR_LOG + 12, 4, "hl3", "Header Log 3",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_CTL, 4, "rootcmd", "Root Error Command",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_rootcom },
{ PCIE_AER_RE_STS, 4, "rootsts", "Root Error Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_rootsts },
{ PCIE_AER_CE_SRC_ID, 4, "esi", "Error Source Identification",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_esi },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_aer_v2[] = {
{ PCIE_AER_CAP, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ PCIE_AER_UCE_STS, 4, "uestatus", "Uncorrectable Error Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ue },
{ PCIE_AER_UCE_MASK, 4, "uemask", "Uncorrectable Error Mask",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ue },
{ PCIE_AER_UCE_SERV, 4, "ueserv", "Uncorrectable Error Severity",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ue },
{ PCIE_AER_CE_STS, 4, "cestatus", "Correctable Error Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ce },
{ PCIE_AER_CE_MASK, 4, "cemask", "Correctable Error Mask",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ce },
{ PCIE_AER_CTL, 4, "ctrl", "Advanced Error Capabilities and Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ctrl },
{ PCIE_AER_HDR_LOG + 4, 4, "hl0", "Header Log 0",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_HDR_LOG + 8, 4, "hl1", "Header Log 1",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_HDR_LOG + 12, 4, "hl2", "Header Log 2",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_HDR_LOG + 12, 4, "hl3", "Header Log 3",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_CTL, 4, "rootcmd", "Root Error Command",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_rootcom },
{ PCIE_AER_RE_STS, 4, "rootsts", "Root Error Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_rootsts },
{ PCIE_AER_TLP_PRE_LOG, 4, "tlplog0", "TLP Prefix Log 0",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_TLP_PRE_LOG + 4, 4, "tlplog1", "TLP Prefix Log 1",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_TLP_PRE_LOG + 8, 4, "tlplog2", "TLP Prefix Log 2",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_TLP_PRE_LOG + 12, 4, "tlplog3", "TLP Prefix Log 3",
pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_aer_bridge[] = {
{ PCIE_AER_CAP, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ PCIE_AER_UCE_STS, 4, "uestatus", "Uncorrectable Error Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ue },
{ PCIE_AER_UCE_MASK, 4, "uemask", "Uncorrectable Error Mask",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ue },
{ PCIE_AER_UCE_SERV, 4, "ueserv", "Uncorrectable Error Severity",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ue },
{ PCIE_AER_CE_STS, 4, "cestatus", "Correctable Error Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ce },
{ PCIE_AER_CE_MASK, 4, "cemask", "Correctable Error Mask",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ce },
{ PCIE_AER_CTL, 4, "ctrl", "Advanced Error Capabilities and Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_ctrl },
{ PCIE_AER_HDR_LOG + 4, 4, "hl0", "Header Log 0",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_HDR_LOG + 8, 4, "hl1", "Header Log 1",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_HDR_LOG + 12, 4, "hl2", "Header Log 2",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_HDR_LOG + 12, 4, "hl3", "Header Log 3",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_CTL, 4, "rootcmd", "Root Error Command",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_rootcom },
{ PCIE_AER_RE_STS, 4, "rootsts", "Root Error Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_rootsts },
{ PCIE_AER_CE_SRC_ID, 4, "esi", "Error Source Identification",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_esi },
{ PCIE_AER_SUCE_STS, 4, "secuests",
"Secondary Uncorrectable Error Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_secue },
{ PCIE_AER_SUCE_MASK, 4, "secuests",
"Secondary Uncorrectable Error Mask",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_secue },
{ PCIE_AER_SUCE_SERV, 4, "secuests",
"Secondary Uncorrectable Error Severity",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_secue },
{ PCIE_AER_SCTL, 4, "secctrl",
"Secondary Error Capabilityes and Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_aer_secctl },
{ PCIE_AER_SHDR_LOG, 4, "shl0", "Secondary Header Log 0",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_SHDR_LOG + 4, 4, "shl1", "Secondary Header Log 1",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_SHDR_LOG + 8, 4, "shl1", "Secondary Header Log 2",
pcieadm_cfgspace_print_hex },
{ PCIE_AER_SHDR_LOG + 12, 4, "shl1", "Secondary Header Log 3",
pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
/*
* Secondary PCI Express Extended Capability
*/
static const pcieadm_regdef_t pcieadm_regdef_pcie2_linkctl3[] = {
{ 0, 0, "peq", "Perform Equalization", PRDV_HEX },
{ 1, 1, "leqrie", "Link Equalization Request Interrupt Enable",
PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 9, 15, "elskpos", "Enable Lower SKP OS Generation Vector",
PRDV_BITFIELD,
.prd_val = { .prdv_strval = { "2.5 GT/s", "5.0 GT/s", "8.0 GT/s",
"16.0 GT/s", "32.0 GT/s" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcie2_linkeq[] = {
{ 0, 3, "dstxpre", "Downstream Port 8.0 GT/s Transmitter Preset",
PRDV_HEX },
{ 4, 6, "dstxhint", "Downstream Port 8.0 GT/s Receiver Hint",
PRDV_HEX },
{ 8, 11, "ustxpre", "Upstream Port 8.0 GT/s Transmitter Preset",
PRDV_HEX },
{ 12, 14, "ustxhint", "Upstream Port 8.0 GT/s Receiver Hint",
PRDV_HEX },
{ -1, -1, NULL }
};
static void
pcieadm_cfgspace_print_laneq(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
if (walkp->pcw_nlanes == 0) {
warnx("failed to capture lane count, but somehow have "
"secondary PCIe cap");
return;
}
for (uint_t i = 0; i < walkp->pcw_nlanes; i++) {
char eqshort[32], eqhuman[128];
pcieadm_cfgspace_print_t p;
(void) snprintf(eqshort, sizeof (eqshort), "lane%u", i);
(void) snprintf(eqhuman, sizeof (eqhuman), "Lane %u EQ Control",
i);
p.pcp_off = print->pcp_off + i * 2;
p.pcp_len = 2;
p.pcp_short = eqshort;
p.pcp_human = eqhuman;
p.pcp_print = pcieadm_cfgspace_print_regdef;
p.pcp_arg = pcieadm_regdef_pcie2_linkeq;
p.pcp_print(walkp, &p, p.pcp_arg);
}
}
static const pcieadm_cfgspace_print_t pcieadm_cap_pcie2[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "linkctl3", "Link Control 3",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie2_linkctl3 },
{ 0x8, 4, "laneerr", "Lane Error Status", pcieadm_cfgspace_print_hex },
{ 0xc, 2, "eqctl", "Lane Equalization Control",
pcieadm_cfgspace_print_laneq },
{ -1, -1, NULL }
};
/*
* Access Control Services
*/
static const pcieadm_regdef_t pcieadm_regdef_acs_cap[] = {
{ 0, 0, "srcvd", "ACS Source Validation", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 1, 1, "tranblk", "ACS Transaction Blocking", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 2, 2, "p2prr", "ACS P2P Request Redirect", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 3, 3, "p2pcr", "ACS P2P Completion Redirect", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 4, 4, "upfwd", "ACS Upstream Forwarding", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 5, 5, "p2pegctl", "ACS P2P Egress Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 6, 6, "dtp2p", "ACS Direct Translated P2P", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 7, 7, "enhcap", "ACS Enhanced Capability", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 15, "ecvsz", "Egress Control Vector Size", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_acs_ctl[] = {
{ 0, 0, "srcvd", "ACS Source Validation", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "tranblk", "ACS Transaction Blocking", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 2, 2, "p2prr", "ACS P2P Request Redirect", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 3, 3, "p2pcr", "ACS P2P Completion Redirect", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 4, 4, "upfwd", "ACS Upstream Forwarding", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 5, 5, "p2pegctl", "ACS P2P Egress Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 6, 6, "dtp2p", "ACS Direct Translated P2P", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 7, 7, "iorb", "ACS I/O Request Blocking", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 8, 9, "dspmta", "ACS DSP Memory Target Access Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "Direct Request access",
"Request blocking", "Request redirect" } } },
{ 10, 11, "uspmta", "ACS USP Memory Target Access Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "Direct Request access",
"Request blocking", "Request redirect" } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_acs[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 2, "cap", "ACS Capability",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_acs_cap },
{ 0x6, 2, "ctl", "ACS Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_acs_ctl },
{ 0x8, 4, "ecv", "Egress Control Vector", pcieadm_cfgspace_print_ecv },
{ -1, -1, NULL }
};
/*
* L1 PM Substates
*/
static const pcieadm_regdef_t pcieadm_regdef_l1pm_cap[] = {
{ 0, 0, "pcil1.2", "PCI-PM L1.2", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 1, 1, "pcil1.1", "PCI-PM L1.1", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 2, 2, "aspml1.2", "ASPM L1.2", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 3, 3, "aspml1.1", "ASPM L1.1", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 4, 4, "l1pmsub", "L1 PM Substates", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 5, 5, "linkact", "Link Activation", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 15, "pcmrt", "Port Common_Mode_Restore_Time", PRDV_HEX },
{ 16, 17, "poscale", "Port T_POWER_ON Scale", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "2 us", "10 us", "100 us" } } },
{ 19, 23, "portpo", "Port T_POWER_ON Value", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_l1pm_ctl1[] = {
{ 0, 0, "pcil1.2", "PCI-PM L1.2", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "pcil1.1", "PCI-PM L1.1", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 2, 2, "aspml1.2", "ASPM L1.2", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 3, 3, "aspml1.1", "ASPM L1.1", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 4, 4, "laie", "Link Activation Interrupt Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 5, 5, "lactl", "Link Activation Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 8, 15, "cmrt", "Common_Mode_Restore_Time", PRDV_HEX },
{ 16, 25, "ltrl1.2", "LTR L1.2 Threshold Value", PRDV_HEX },
{ 29, 31, "ltrl1.2s", "LTR L1.2 Threshold Scale", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "1 ns", "32 ns", "1024 ns",
"32,768 ns", "1,048,576 ns", "33,554,432 ns" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_l1pm_ctl2[] = {
{ 0, 1, "poscale", "T_POWER_ON Scale", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "2 us", "10 us", "100 us" } } },
{ 3, 7, "portpo", "T_POWER_ON Value", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_l1pm_sts[] = {
{ 0, 0, "la", "Link Activation", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_l1pm_v1[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "caps", "L1 PM Substates Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_l1pm_cap },
{ 0x8, 4, "ctl1", "L1 PM Substates Control 1",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_l1pm_ctl1 },
{ 0xc, 4, "ctl2", "L1 PM Substates Control 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_l1pm_ctl2 },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_l1pm_v2[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "caps", "L1 PM Substates Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_l1pm_cap },
{ 0x8, 4, "ctl1", "L1 PM Substates Control 1",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_l1pm_ctl1 },
{ 0xc, 4, "ctl2", "L1 PM Substates Control 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_l1pm_ctl2 },
{ 0x10, 4, "sts", "L1 PM Substates Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_l1pm_sts },
{ -1, -1, NULL }
};
/*
* Latency Tolerance Reporting (LTR)
*/
static const pcieadm_regdef_t pcieadm_regdef_ltr[] = {
{ 0, 9, "latval", "Latency Value", PRDV_HEX },
{ 10, 12, "latscale", "Latency Scale", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "1 ns", "32 ns", "1024 ns",
"32,768 ns", "1,048,576 ns", "33,554,432 ns" } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_ltr[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 2, "snoop", "Max Snoop Latency",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ltr },
{ 0x6, 2, "nosnoop", "Max No-Snoop Latency",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ltr },
{ -1, -1, NULL }
};
/*
* Alternative Routing ID
*/
static const pcieadm_regdef_t pcieadm_regdef_ari_cap[] = {
{ 0, 0, "mfvcfg", "MFVC Function Groups", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 1, 1, "acsfg", "ACS Function Groups", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 15, "nfunc", "Next Function Number", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ari_ctl[] = {
{ 0, 0, "mfvcfg", "MFVC Function Groups", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "acsfg", "ACS Function Groups", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 4, 6, "fgrp", "Function Group", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_ari[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 2, "cap", "ARI Capability",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ari_cap },
{ 0x6, 2, "ctl", "ARI Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ari_ctl },
{ -1, -1, NULL }
};
/*
* PASID
*/
static const pcieadm_regdef_t pcieadm_regdef_pasid_cap[] = {
{ 1, 1, "exec", "Execution Permission", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 2, 2, "priv", "Privileged Mode", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 12, "width", "Max PASID Width", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pasid_ctl[] = {
{ 0, 0, "pasid", "PASID", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "exec", "Execution Permission", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 2, 2, "priv", "Privileged Mode", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_pasid[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 2, "cap", "PASID Capability",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pasid_cap },
{ 0x6, 2, "ctl", "PASID Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pasid_ctl },
{ -1, -1, NULL }
};
/*
* "Advanced Features"
*/
static const pcieadm_regdef_t pcieadm_regdef_af_cap[] = {
{ 0, 0, "tp", "Transactions Pending", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 1, 1, "flr", "Function Level Reset", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_af_ctl[] = {
{ 0, 0, "flr", "Function Level Reset", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_af_sts[] = {
{ 0, 0, "tp", "Transactions Pending", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "none pending", "pending" } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_af[] = {
{ 0x2, 2, "cap", "AF Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_af_cap },
{ 0x4, 1, "ctl", "AF Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_af_ctl },
{ 0x5, 1, "sts", "AF Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_af_sts },
{ -1, -1, NULL }
};
/*
* Multicast
*/
static const pcieadm_regdef_t pcieadm_regdef_mcast_cap[] = {
{ 0, 5, "maxgrp", "Max Group", PRDV_HEX,
.prd_val = { .prdv_hex = { 0, 1 } } },
{ 8, 13, "winsize", "Window Size (raw)", PRDV_HEX },
{ 15, 15, "ecrc", "ECRC Regeneration", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_mcast_ctl[] = {
{ 0, 5, "numgrp", "Number of Groups", PRDV_HEX,
.prd_val = { .prdv_hex = { 0, 1 } } },
{ 15, 15, "enable", "Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_mcast_base[] = {
{ 0, 5, "index", "Multicast Index Position", PRDV_HEX },
{ 12, 63, "addr", "Base Address", PRDV_HEX,
.prd_val = { .prdv_hex = { 12 } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_mcast_overlay[] = {
{ 0, 5, "size", "Overlay Size (raw)", PRDV_HEX },
{ 6, 63, "addr", "Overlay Base Address", PRDV_HEX,
.prd_val = { .prdv_hex = { 6 } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_mcast[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 2, "cap", "Multicast Capability",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_mcast_cap },
{ 0x6, 2, "ctl", "Multicast Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_mcast_ctl },
{ 0x8, 8, "base", "Multicast Base Address",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_mcast_base },
{ 0x10, 8, "rx", "Multicast Receive", pcieadm_cfgspace_print_hex },
{ 0x18, 8, "block", "Multicast Block All", pcieadm_cfgspace_print_hex },
{ 0x20, 8, "blockun", "Multicast Block Untranslated",
pcieadm_cfgspace_print_hex },
{ 0x28, 8, "overlay", "Multicast Overlay BAR",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_mcast_overlay },
{ -1, -1, NULL }
};
/*
* Various vendor extensions
*/
static const pcieadm_regdef_t pcieadm_regdef_vsec[] = {
{ 0, 15, "id", "ID", PRDV_HEX },
{ 16, 19, "rev", "Revision", PRDV_HEX },
{ 20, 31, "len", "Length", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_vs[] = {
{ 0x2, 2, "length", "Length", pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_vsec[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "header", "Vendor-Specific Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_vsec },
{ -1, -1, NULL }
};
/*
* Data Link Feature
*/
static const pcieadm_regdef_t pcieadm_regdef_dlf_cap[] = {
{ 0, 0, "lsfc", "Local Scaled Flow Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 31, 31, "dlex", "Data Link Exchange", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_dlf_sts[] = {
{ 0, 0, "rsfc", "Remote Scaled Flow Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 31, 31, "valid", "Remote Data Link Feature Valid", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "invalid", "valid" } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_dlf[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "cap", "Data Link Feature Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_dlf_cap },
{ 0x8, 4, "sts", "Data Link Feature Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_dlf_sts },
{ -1, -1, NULL }
};
/*
* 16.0 GT/s cap
*/
static const pcieadm_regdef_t pcieadm_regdef_16g_cap[] = {
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_16g_ctl[] = {
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_16g_sts[] = {
{ 0, 0, "eqcomp", "Equalization 16.0 GT/s Complete", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "incomplete", "complete" } } },
{ 1, 1, "eqp1", "Equalization 16.0 GT/s Phase 1", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "incomplete", "complete" } } },
{ 2, 2, "eqp2", "Equalization 16.0 GT/s Phase 2", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "incomplete", "complete" } } },
{ 3, 3, "eqp3", "Equalization 16.0 GT/s Phase 3", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "incomplete", "complete" } } },
{ 4, 4, "req", "Link Equalization Request 16.0 GT/s", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_16g_eq[] = {
{ 0, 3, "dstxpre", "Downstream Port 16.0 GT/s Transmitter Preset",
PRDV_HEX },
{ 4, 7, "ustxpre", "Upstream Port 16.0 GT/s Transmitter Preset",
PRDV_HEX },
{ -1, -1, NULL }
};
static void
pcieadm_cfgspace_print_16geq(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
if (walkp->pcw_nlanes == 0) {
warnx("failed to capture lane count, but somehow have "
"Physical Layer 16.0 GT/s cap");
return;
}
for (uint_t i = 0; i < walkp->pcw_nlanes; i++) {
char eqshort[32], eqhuman[128];
pcieadm_cfgspace_print_t p;
(void) snprintf(eqshort, sizeof (eqshort), "lane%u", i);
(void) snprintf(eqhuman, sizeof (eqhuman), "Lane %u EQ Control",
i);
p.pcp_off = print->pcp_off + i * 1;
p.pcp_len = 1;
p.pcp_short = eqshort;
p.pcp_human = eqhuman;
p.pcp_print = pcieadm_cfgspace_print_regdef;
p.pcp_arg = pcieadm_regdef_16g_eq;
p.pcp_print(walkp, &p, p.pcp_arg);
}
}
static const pcieadm_cfgspace_print_t pcieadm_cap_16g[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "cap", "16.0 GT/s Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_16g_cap },
{ 0x8, 4, "ctl", "16.0 GT/s Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_16g_ctl },
{ 0xc, 4, "sts", "16.0 GT/s Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_16g_sts },
{ 0x10, 4, "ldpmis", "16.0 GT/s Local Data Parity Mismatch",
pcieadm_cfgspace_print_hex },
{ 0x14, 4, "frpmis", "16.0 GT/s First Retimer Data Parity Mismatch",
pcieadm_cfgspace_print_hex },
{ 0x18, 4, "srpmis", "16.0 GT/s Second Retimer Data Parity Mismatch",
pcieadm_cfgspace_print_hex },
{ 0x1c, 4, "rsvd", "16.0 GT/s Second Retimer Data Parity Mismatch",
pcieadm_cfgspace_print_hex },
{ 0x20, 1, "eqctl", "16.0 GT/s EQ Control",
pcieadm_cfgspace_print_16geq },
{ -1, -1, NULL }
};
/*
* Receiver Margining
*/
static const pcieadm_regdef_t pcieadm_regdef_margin_cap[] = {
{ 0, 0, "sw", "Margining uses Driver Software", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_margin_sts[] = {
{ 0, 0, "ready", "Margining Ready", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 1, 1, "sw", "Margining Software Ready", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_margin_lane[] = {
{ 0, 2, "rxno", "Receiver Number", PRDV_HEX },
{ 3, 5, "type", "Margin Type", PRDV_HEX },
{ 6, 6, "model", "Usage Model", PRDV_HEX },
{ 8, 15, "payload", "Margin Payload", PRDV_HEX },
{ -1, -1, NULL }
};
static void
pcieadm_cfgspace_print_margin(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
if (walkp->pcw_nlanes == 0) {
warnx("failed to capture lane count, but somehow have "
"lane margining capability");
return;
}
for (uint_t i = 0; i < walkp->pcw_nlanes; i++) {
char mshort[32], mhuman[128];
pcieadm_cfgspace_print_t p;
(void) snprintf(mshort, sizeof (mshort), "lane%uctl", i);
(void) snprintf(mhuman, sizeof (mhuman), "Lane %u Margining "
"Control", i);
p.pcp_off = print->pcp_off + i * 4;
p.pcp_len = 2;
p.pcp_short = mshort;
p.pcp_human = mhuman;
p.pcp_print = pcieadm_cfgspace_print_regdef;
p.pcp_arg = pcieadm_regdef_margin_lane;
p.pcp_print(walkp, &p, p.pcp_arg);
(void) snprintf(mshort, sizeof (mshort), "lane%usts", i);
(void) snprintf(mhuman, sizeof (mhuman), "Lane %u Margining "
"Status", i);
p.pcp_off = print->pcp_off + 2 + i * 4;
p.pcp_len = 2;
p.pcp_short = mshort;
p.pcp_human = mhuman;
p.pcp_print = pcieadm_cfgspace_print_regdef;
p.pcp_arg = pcieadm_regdef_margin_lane;
p.pcp_print(walkp, &p, p.pcp_arg);
}
}
static const pcieadm_cfgspace_print_t pcieadm_cap_margin[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 2, "cap", "Margining Port Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_margin_cap },
{ 0x6, 2, "sts", "Margining Port Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_margin_sts },
{ 0x8, 4, "lane", "Margining Lane", pcieadm_cfgspace_print_margin },
{ -1, -1, NULL }
};
/*
* Serial Number Capability
*/
static void
pcieadm_cfgspace_print_sn(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
char sn[64];
uint16_t off = walkp->pcw_capoff + print->pcp_off;
(void) snprintf(sn, sizeof (sn),
"%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x",
walkp->pcw_data->pcb_u8[off + 7], walkp->pcw_data->pcb_u8[off + 6],
walkp->pcw_data->pcb_u8[off + 5], walkp->pcw_data->pcb_u8[off + 4],
walkp->pcw_data->pcb_u8[off + 3], walkp->pcw_data->pcb_u8[off + 2],
walkp->pcw_data->pcb_u8[off + 1], walkp->pcw_data->pcb_u8[off]);
pcieadm_cfgspace_puts(walkp, print, sn);
}
static const pcieadm_cfgspace_print_t pcieadm_cap_sn[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 8, "sn", "Serial Number", pcieadm_cfgspace_print_sn },
{ -1, -1, NULL }
};
/*
* TLP Processing Hints (TPH)
*/
static const pcieadm_regdef_t pcieadm_regdef_tph_cap[] = {
{ 0, 0, "nost", "No ST Mode", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 1, 1, "ivec", "Interrupt Vector Mode", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 2, 2, "dev", "Device Specific Mode", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 8, "exttph", "Extended TPH Requester", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 9, 10, "loc", "ST Table Location", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "Not Present",
"In Capability Structure", "MSI-X" } } },
{ 16, 26, "size", "ST Table Size", PRDV_HEX, { .prdv_hex = { 0, 1 } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_tph_ctl[] = {
{ 0, 2, "mode", "ST Mode Select", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "No ST", "Interrupt Vector",
"Device Specific" } } },
{ 8, 9, "en", "TPH Requester", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "Not Permitted", "TPH", NULL,
"TPH and Extended TPH" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_tph_st[] = {
{ 0, 7, "low", "ST Lower", PRDV_HEX },
{ 8, 15, "up", "ST Upper", PRDV_HEX },
{ -1, -1, NULL }
};
/*
* The TPH ST table is only conditionally present in the capability. So we need
* to read the TPH capability register and then check if the table location and
* size are set here.
*/
static void
pcieadm_cfgspace_print_tphst(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
uint_t nents;
uint32_t tphcap = walkp->pcw_data->pcb_u32[(walkp->pcw_capoff + 4) / 4];
if (bitx32(tphcap, 10, 9) != 1) {
return;
}
nents = bitx32(tphcap, 26, 16) + 1;
for (uint_t i = 0; i < nents; i++) {
char tshort[32], thuman[128];
pcieadm_cfgspace_print_t p;
(void) snprintf(tshort, sizeof (tshort), "st%u", i);
(void) snprintf(thuman, sizeof (thuman), "ST Table %u",
i);
p.pcp_off = print->pcp_off + i * 2;
p.pcp_len = 2;
p.pcp_short = tshort;
p.pcp_human = thuman;
p.pcp_print = pcieadm_cfgspace_print_regdef;
p.pcp_arg = pcieadm_regdef_tph_st;
p.pcp_print(walkp, &p, p.pcp_arg);
}
}
static const pcieadm_cfgspace_print_t pcieadm_cap_tph[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "cap", "TPH Requester Capability",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_tph_cap },
{ 0x8, 4, "ctl", "TPH Requester Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_tph_ctl },
{ 0xc, 2, "table", "ST Table", pcieadm_cfgspace_print_tphst },
{ -1, -1, NULL }
};
/*
* SR-IOV
*/
static const pcieadm_regdef_t pcieadm_regdef_sriov_cap[] = {
{ 0, 0, "migration", "Migration", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 1, 1, "ari", "ARI Capable Hierarchy Preserved", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unpreserved", "preserved" } } },
{ 2, 2, "vf10b", "VF 10-bit Tag Requester", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unpreserved", "preserved" } } },
{ 21, 31, "inum", "VF Migration Interrupt Message Number", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_sriov_ctl[] = {
{ 0, 0, "vf", "VF", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "vfm", "VF Migration", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 2, 2, "vfmi", "VF Migration Interrupt", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 3, 3, "ari", "ARI Capable Hierarchy", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 4, 4, "vf10b", "VF 10-bit Tag Requester", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_sriov_sts[] = {
{ 0, 0, "vfm", "VF Migration", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "none", "requested" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_sriov_pgsup[] = {
{ 0, 31, "pgsz", "Supported Page Sizes", PRDV_BITFIELD,
.prd_val = { .prdv_strval = { "4 KB", "8 KB", "16 KB", "32 KB",
"64 KB", "128 KB", "256 KB", "512 KB", "1 MB", "2 MB", "4 MB",
"8 MB", "16 MB", "32 MB", "64 MB", "128 MB", "256 MB", "512 MB",
"1 GB", "2 GB", "4 GB", "8 GB", "16 GB", "32 GB", "64 GB",
"128 GB", "256 GB", "512 GB", "1 TB", "2 TB", "4 TB", "8 TB" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_sriov_pgen[] = {
{ 0, 31, "pgsz", "System Page Sizes", PRDV_BITFIELD,
.prd_val = { .prdv_strval = { "4 KB", "8 KB", "16 KB", "32 KB",
"64 KB", "128 KB", "256 KB", "512 KB", "1 MB", "2 MB", "4 MB",
"8 MB", "16 MB", "32 MB", "64 MB", "128 MB", "256 MB", "512 MB",
"1 GB", "2 GB", "4 GB", "8 GB", "16 GB", "32 GB", "64 GB",
"128 GB", "256 GB", "512 GB", "1 TB", "2 TB", "4 TB", "8 TB" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_sriov_mig[] = {
{ 0, 2, "bir", "VF Migration State BIR", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "BAR 0", "BAR 1", "BAR 2", "BAR 3",
"BAR 4", "BAR 5" } } },
{ 3, 31, "offset", "VF Migration State Offset", PRDV_HEX,
.prd_val = { .prdv_hex = { 3 } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_sriov[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "cap", "SR-IOV Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_sriov_cap },
{ 0x8, 2, "ctl", "SR-IOV Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_sriov_ctl },
{ 0xa, 2, "sts", "SR-IOV Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_sriov_sts },
{ 0xc, 2, "initvfs", "Initial VFs", pcieadm_cfgspace_print_hex },
{ 0xe, 2, "totvfs", "Total VFs", pcieadm_cfgspace_print_hex },
{ 0x10, 2, "numvfs", "Number VFs", pcieadm_cfgspace_print_hex },
{ 0x12, 1, "dep", "Function Dependency Link",
pcieadm_cfgspace_print_hex },
{ 0x14, 2, "offset", "First VF Offset", pcieadm_cfgspace_print_hex },
{ 0x16, 2, "stride", "VF Stride", pcieadm_cfgspace_print_hex },
{ 0x1a, 2, "devid", "VF Device ID", pcieadm_cfgspace_print_hex },
{ 0x1c, 4, "pgsz", "Supported Page Sizes",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_sriov_pgsup },
{ 0x20, 4, "pgsz", "System Page Sizes",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_sriov_pgen },
{ 0x24, 24, "vfbar", "Virtual Base Address Register",
pcieadm_cfgspace_print_bars },
{ 0x3c, 4, "migration", "VF Migration State Array",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_sriov_mig },
{ -1, -1, NULL }
};
/*
* PCI-X
*/
static const pcieadm_regdef_t pcieadm_regdef_pcix_dev_ctl[] = {
{ 0, 0, "dper", "Data Parity Error Recovery", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "ro", "Relaxed Ordering", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 2, 3, "maxread", "Maximum Memory Read Byte Count", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "512 bytes", "1024 bytes",
"2048 bytes", "4096 bytes" } } },
{ 4, 6, "maxsplit", "Maximum Outstanding Split Transactions",
PRDV_STRVAL, .prd_val = { .prdv_strval = { "1", "2", "3", "4", "8",
"12", "16", "32" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcix_dev_sts[] = {
{ 0, 2, "func", "Function Number", PRDV_HEX },
{ 3, 7, "dev", "Device Number", PRDV_HEX },
{ 8, 15, "bus", "Bus Number", PRDV_HEX },
{ 16, 16, "64bit", "64-bit Device", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported (32-bit)",
"supported" } } },
{ 17, 17, "133mhz", "133 MHz Capable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported (66 MHz)",
"supported" } } },
{ 18, 18, "spcodis", "Split Completion Discarded", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 19, 19, "unspco", "Unexpected Split Completion", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 20, 20, "complex", "Device Complexity", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "simple", "bridge" } } },
{ 21, 22, "maxread", "Designed Maximum Memory Read Byte Count",
PRDV_STRVAL, .prd_val = { .prdv_strval = { "512 bytes",
"1024 bytes", "2048 bytes", "4096 bytes" } } },
{ 23, 25, "maxsplit", "Designed Maximum Outstanding Split Transactions",
PRDV_STRVAL, .prd_val = { .prdv_strval = { "1", "2", "3", "4", "8",
"12", "16", "32" } } },
{ 26, 28, "maxcread", "Designed Maximum Cumulative Read Size",
PRDV_STRVAL, .prd_val = { .prdv_strval = { "8/1KB", "16/2KB",
"32/4KB", "64/8KB", "128/16KB", "256/32KB", "512/64KB",
"1024/128KB" } } },
{ 29, 29, "rxspcoer", "Received Split Completion Error Message",
PRDV_STRVAL, .prd_val = { .prdv_strval = { "no", "yes" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcix_sec_sts[] = {
{ 0, 0, "64bit", "64-bit Device", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported (32-bit)",
"supported" } } },
{ 1, 1, "133mhz", "133 MHz Capable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported (66 MHz)",
"supported" } } },
{ 2, 2, "spcodis", "Split Completion Discarded", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 3, 3, "unspco", "Unexpected Split Completion", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 4, 4, "spcoor", "Split Completion Overrun", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 5, 5, "sprde", "Split Request Delayed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 6, 8, "freq", "Secondary Clock Frequency", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "conventional", "66 MHz", "100 Mhz",
"133 MHz" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcix_bridge_sts[] = {
{ 0, 2, "func", "Function Number", PRDV_HEX },
{ 3, 7, "dev", "Device Number", PRDV_HEX },
{ 8, 15, "bus", "Bus Number", PRDV_HEX },
{ 16, 16, "64bit", "64-bit Device", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported (32-bit)",
"supported" } } },
{ 17, 17, "133mhz", "133 MHz Capable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported (66 MHz)",
"supported" } } },
{ 18, 18, "spcodis", "Split Completion Discarded", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 19, 19, "unspco", "Unexpected Split Completion", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 20, 20, "spcoor", "Split Completion Overrun", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 21, 21, "sprde", "Split Request Delayed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pcix_bridge_split[] = {
{ 0, 15, "cap", "Split Transaction Capacity", PRDV_HEX },
{ 16, 31, "limit", "Split Transaction Commitment Limit", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_pcix_dev[] = {
{ 0x2, 2, "ctl", "PCI-X Command",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcix_dev_ctl },
{ 0x4, 4, "sts", "PCI-X Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcix_dev_sts },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_pcix_bridge[] = {
{ 0x2, 2, "secsts", "PCI-X Secondary Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcix_sec_sts },
{ 0x4, 4, "sts", "PCI-X Bridge Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcix_bridge_sts },
{ 0x8, 4, "ussplit", "Upstream Split Transaction",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcix_bridge_split },
{ 0x8, 4, "dssplit", "Downstream Split Transaction",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcix_bridge_split },
{ -1, -1, NULL }
};
/*
* Dynamic Power Allocation
*/
static const pcieadm_regdef_t pcieadm_regdef_dpa_cap[] = {
{ 0, 4, "substates", "Substate Max", PRDV_HEX,
{ .prdv_hex = { 0, 1 } } },
{ 8, 9, "tlu", "Transition Latency Unit", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "1 ms", "10 ms", "100 ms" } } },
{ 12, 13, "pas", "Power Allocation Scale", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "10.0x", "1.0x", "0.1x",
"0.01x" } } },
{ 16, 23, "tlv0", "Transition Latency Value 0", PRDV_HEX },
{ 24, 31, "tlv0", "Transition Latency Value 1", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_dpa_sts[] = {
{ 0, 4, "substate", "Substate Status", PRDV_HEX },
{ 8, 8, "ctlen", "Substate Control Enabled", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_dpa_ctl[] = {
{ 0, 4, "substate", "Substate Control", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_dpa[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "cap", "DPA Capability",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_dpa_cap },
{ 0x8, 4, "lat", "DPA Latency Indicator", pcieadm_cfgspace_print_hex },
{ 0xc, 2, "sts", "DPA Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_dpa_sts },
{ 0xe, 2, "sts", "DPA Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_dpa_ctl },
{ 0x10, 1, "paa", "DPA Power Allocation Array",
pcieadm_cfgspace_print_dpa_paa },
{ -1, -1, NULL }
};
/*
* Power Budgeting
*/
static const pcieadm_regdef_t pcieadm_regdef_powbudg_data[] = {
{ 0, 7, "base", "Base Power", PRDV_HEX },
{ 8, 9, "scale", "Data Scale", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "1.0x", "0.1x", "0.01x",
"0.001x" } } },
{ 10, 12, "pmsub", "PM Substate", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "Default", "Device Specific",
"Device Specific", "Device Specific", "Device Specific",
"Device Specific", "Device Specific", "Device Specific" } } },
{ 13, 14, "pmstate", "PM State", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "D0", "D1", "D2", "D3" } } },
{ 15, 17, "type", "Type", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "PME Aux", "Axiliary", "Idle",
"Sustained", "Sustained - EPRS", "Maximum - EPRS", NULL,
"Maximum" } } },
{ 18, 20, "rail", "Power Rail", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "Power (12V)", "Power (3.3V)",
"Power (1.5V or 1.8V)", NULL, NULL, NULL, NULL, "Thermal" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_powbudg_cap[] = {
{ 0, 0, "sa", "System Allocated", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_powbudg[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 1, "sel", "Data Select", pcieadm_cfgspace_print_hex },
{ 0x8, 4, "data", "Data Regiser", pcieadm_cfgspace_print_regdef,
pcieadm_regdef_powbudg_data },
{ 0xc, 0x1, "cap", "Power Budget Capability",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_powbudg_cap },
{ -1, -1, NULL }
};
/*
* Precision Time Management
*/
static const pcieadm_regdef_t pcieadm_regdef_ptm_cap[] = {
{ 0, 0, "req", "PTM Requester", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 1, 1, "resp", "PTM Responder", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 2, 2, "root", "PTM Root", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 3, 3, "eptm", "ePTM", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 15, "gran", "Local Clock Granularity", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ptm_ctl[] = {
{ 0, 0, "en", "PTM Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "root", "Root Select", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 8, 15, "gran", "Effective Granularity", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_info_ptm[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "cap", "PTM Capability",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ptm_cap },
{ 0x8, 4, "cap", "PTM Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ptm_ctl },
{ -1, -1, NULL }
};
/*
* Address Translation Services (ATS)
*/
static const pcieadm_regdef_t pcieadm_regdef_ats_cap[] = {
{ 0, 4, "invqd", "Invalidate Queue Depth", PRDV_HEX },
{ 5, 5, "pgalign", "Page Aligned Request", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not required", "required" } } },
{ 6, 6, "glbinv", "Global Invalidate", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 7, 7, "relo", "Relaxed Ordering", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ats_ctl[] = {
{ 0, 4, "stu", "Smallest Translation Unit", PRDV_HEX },
{ 15, 15, "en", "Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_ats[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 2, "cap", "ATS Capability",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ats_cap },
{ 0x6, 2, "cap", "ATS Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ats_ctl },
{ -1, -1, NULL }
};
/*
* Page Request
*/
static const pcieadm_regdef_t pcieadm_regdef_pgreq_ctl[] = {
{ 0, 0, "en", "Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "reset", "Reset", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_pgreq_sts[] = {
{ 0, 0, "rf", "Response Failure", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 1, 1, "uprgi", "Unexpected Page Request Group Index", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 8, 8, "stopped", "Stopped", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 15, 15, "prgrpreq", "PRG Response PASID", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not required", "required" } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_pgreq[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 2, "ctl", "Page Request Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pgreq_ctl },
{ 0x6, 2, "ctl", "Page Request Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pgreq_sts },
{ 0x8, 4, "cap", "Outstanding Page Request Capacity",
pcieadm_cfgspace_print_hex },
{ 0xc, 4, "alloc", "Outstanding Page Request Allocation",
pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
/*
* NULL Capability
*/
static const pcieadm_cfgspace_print_t pcieadm_cap_null[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ -1, -1, NULL }
};
/*
* Downstream Port Containment
*/
static const pcieadm_regdef_t pcieadm_regdef_dpc_cap[] = {
{ 0, 4, "inum", "DPC Interrupt Message Number", PRDV_HEX },
{ 5, 5, "rpext", "Root Port Extensions", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 6, 6, "ptlpeb", "Poisoned TLP Egress Blocking", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 7, 7, "swtrig", "Software Triggering", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 11, "logsz", "RP PIO Log Size", PRDV_HEX },
{ 12, 12, "errcorr", "DL_Active ERR_COR Signaling", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_dpc_ctl[] = {
{ 0, 1, "trigger", "DPC Trigger", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled, fatal",
"enabled, non-fatal" } } },
{ 2, 2, "comp", "Completion Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "Completer Abort",
"Unsupported Request" } } },
{ 3, 3, "intr", "Interrupt",
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 4, 4, "errcor", "ERR_COR",
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 5, 5, "ptlpeb", "Poisoned TLP Egress Blocking", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 6, 6, "swtrig", "Software Trigger", PRDV_HEX },
{ 7, 7, "corerr", "DL_Active ERR_COR",
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 8, 8, "sigsfw", "SIG_SFW",
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_dpc_sts[] = {
{ 0, 0, "trigger", "Trigger Status", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not triggered", "triggered" } } },
{ 1, 2, "reason", "Trigger Reason", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unmasked uncorrectable",
"ERR_NONFATAL received", "ERR_FATAL received",
"see extension" } } },
{ 3, 3, "istatus", "Interrupt Status", PRDV_HEX },
{ 4, 4, "rpbusy", "RP Busy", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 5, 6, "extreason", "Trigger Reason Extension", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "RP PIO", "Software Trigger" } } },
{ 8, 12, "feptr", "RP PIO, First Error Pointer", PRDV_HEX },
{ 13, 13, "sigsfw", "SIG_SFW Status", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_dpc_rppio_bits[] = {
{ 0, 0, "cfgur", "Configuration Request UR Completion", PRDV_HEX },
{ 1, 1, "cfgca", "Configuration Request CA Completion", PRDV_HEX },
{ 2, 2, "cfgcto", "Configuration Request Completion Timeout",
PRDV_HEX },
{ 8, 8, "iour", "I/O UR Completion", PRDV_HEX },
{ 9, 9, "ioca", "I/O CA Completion", PRDV_HEX },
{ 10, 10, "iocto", "I/O Completion Timeout", PRDV_HEX },
{ 8, 8, "memur", "Memory UR Completion", PRDV_HEX },
{ 9, 9, "memca", "Memory CA Completion", PRDV_HEX },
{ 10, 10, "memcto", "Memory Completion Timeout", PRDV_HEX },
{ -1, -1, NULL }
};
static void
pcieadm_cfgspace_print_dpc_rppio(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
uint32_t cap = walkp->pcw_data->pcb_u32[(walkp->pcw_capoff + 4) / 4];
if (bitx32(cap, 5, 5) == 0) {
return;
}
pcieadm_cfgspace_print_regdef(walkp, print, arg);
}
static void
pcieadm_cfgspace_print_dpc_piohead(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
uint32_t cap = walkp->pcw_data->pcb_u32[(walkp->pcw_capoff + 4) / 4];
uint32_t nwords = bitx32(cap, 11, 8);
if (bitx32(cap, 5, 5) == 0 || nwords < 4) {
return;
}
pcieadm_cfgspace_print_hex(walkp, print, NULL);
}
static void
pcieadm_cfgspace_print_dpc_impspec(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
uint32_t cap = walkp->pcw_data->pcb_u32[(walkp->pcw_capoff + 4) / 4];
uint32_t nwords = bitx32(cap, 11, 8);
if (bitx32(cap, 5, 5) == 0 || nwords < 5) {
return;
}
pcieadm_cfgspace_print_hex(walkp, print, NULL);
}
static void
pcieadm_cfgspace_print_dpc_tlplog(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
uint32_t cap = walkp->pcw_data->pcb_u32[(walkp->pcw_capoff + 4) / 4];
int32_t nwords = (int32_t)bitx32(cap, 11, 8);
if (nwords == 0 || bitx32(cap, 5, 5) == 0) {
return;
}
if (nwords <= 9) {
nwords -= 5;
} else {
nwords -= 4;
}
for (int32_t i = 0; i < nwords; i++) {
char tlpshort[32], tlphuman[128];
pcieadm_cfgspace_print_t p;
(void) snprintf(tlpshort, sizeof (tlpshort), "%s%u",
print->pcp_short, i);
(void) snprintf(tlphuman, sizeof (tlphuman), "%s %u",
print->pcp_human, i);
p.pcp_off = print->pcp_off + i * 4;
p.pcp_len = 4;
p.pcp_short = tlpshort;
p.pcp_human = tlphuman;
p.pcp_print = pcieadm_cfgspace_print_hex;
p.pcp_arg = NULL;
p.pcp_print(walkp, &p, p.pcp_arg);
}
}
static const pcieadm_cfgspace_print_t pcieadm_cap_dpc[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 2, "cap", "DPC Capability",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_dpc_cap },
{ 0x6, 2, "ctl", "DPC Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_dpc_ctl },
{ 0x8, 2, "sts", "DPC Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_dpc_sts },
{ 0xa, 2, "srcid", "DPC Error Source ID",
pcieadm_cfgspace_print_hex },
{ 0x10, 4, "rppiosts", "RP PIO Status",
pcieadm_cfgspace_print_dpc_rppio, pcieadm_regdef_dpc_rppio_bits },
{ 0x14, 4, "rppiomask", "RP PIO Mask ID",
pcieadm_cfgspace_print_dpc_rppio, pcieadm_regdef_dpc_rppio_bits },
{ 0x14, 4, "rppiosev", "RP PIO Severity",
pcieadm_cfgspace_print_dpc_rppio, pcieadm_regdef_dpc_rppio_bits },
{ 0x18, 4, "rppiose", "RP PIO SysError",
pcieadm_cfgspace_print_dpc_rppio, pcieadm_regdef_dpc_rppio_bits },
{ 0x1c, 4, "rppioex", "RP PIO Exception",
pcieadm_cfgspace_print_dpc_rppio, pcieadm_regdef_dpc_rppio_bits },
{ 0x20, 4, "rppiohl0", "RP PIO Header Log 0",
pcieadm_cfgspace_print_dpc_piohead },
{ 0x24, 4, "rppiohl1", "RP PIO Header Log 1",
pcieadm_cfgspace_print_dpc_piohead },
{ 0x28, 4, "rppiohl2", "RP PIO Header Log 2",
pcieadm_cfgspace_print_dpc_piohead },
{ 0x2c, 4, "rppiohl3", "RP PIO Header Log 3",
pcieadm_cfgspace_print_dpc_piohead },
{ 0x30, 4, "impspec", "RP PIO ImpSpec Log",
pcieadm_cfgspace_print_dpc_impspec },
{ 0x34, 16, "tlplog", "RP PIO TLP Prefix Log",
pcieadm_cfgspace_print_dpc_tlplog },
{ -1, -1, NULL }
};
/*
* Virtual Channel Capability
*/
static const pcieadm_regdef_t pcieadm_regdef_vc_cap1[] = {
{ 0, 2, "count", "Extended VC Count", PRDV_HEX },
{ 4, 6, "lpcount", "Low Priority Extended VC Count", PRDV_HEX },
{ 8, 9, "refclk", "Reference Clock", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "100ns" } } },
{ 10, 11, "patsz", "Port Arbitration Table Size", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "1 bit", "2 bits", "4 bits",
"8 bits" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_vc_cap2[] = {
{ 0, 7, "arbcap", "VC Arbitration Capability", PRDV_BITFIELD,
.prd_val = { .prdv_strval = { "hardware fixed",
"32 phase weighted round robin", "64 phase weighted round robin",
"128 phase weighted round robin" } } },
{ 24, 31, "offset", "VC Arbitration Table Offset", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_vc_ctl[] = {
{ 0, 0, "loadtbl", "Load VC Arbitration Table", PRDV_HEX },
{ 1, 3, "arbtype", "VC Arbitration Select", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "hardware fixed",
"32 phase weighted round robin", "64 phase weighted round robin",
"128 phase weighted round robin" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_vc_sts[] = {
{ 0, 0, "table", "VC Arbitration Table Status", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_vc_rsrccap[] = {
{ 0, 7, "arbcap", "Port Arbitration Capability", PRDV_BITFIELD,
.prd_val = { .prdv_strval = { "hardware fixed",
"32 phase weighted round robin", "64 phase weighted round robin",
"128 phase weighted round robin",
"128 phase time-based weighted round robin",
"256 phase weighted round robin" } } },
{ 14, 14, "aps", "Advanced Packet Switching", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 15, 15, "rstx", "Reject Snoop Transactions", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 16, 22, "nslots", "Maximum Time Slots", PRDV_HEX,
{ .prdv_hex = { 0, 1 } } },
{ 24, 31, "offset", "VC Arbitration Table Offset", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_vc_rsrcctl[] = {
{ 0, 7, "tcmap", "TC/VC Map", PRDV_HEX },
{ 16, 16, "loadtbl", "Load VC Arbitration Table", PRDV_HEX },
{ 17, 19, "arbtype", "Port Arbitration Select", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "hardware fixed",
"32 phase weighted round robin", "64 phase weighted round robin",
"128 phase weighted round robin",
"128 phase time-based weighted round robin",
"256 phase weighted round robin" } } },
{ 24, 26, "vcid", "VC ID", PRDV_HEX },
{ 31, 31, "en", "VC Enable",
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_vc_rsrcsts[] = {
{ 0, 0, "table", "Port Arbitration Table Status", PRDV_HEX },
{ -1, -1, NULL }
};
static void
pcieadm_cfgspace_print_vc_rsrc(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
uint32_t cap = walkp->pcw_data->pcb_u32[(walkp->pcw_capoff + 4) / 4];
uint32_t nents = bitx32(cap, 2, 0) + 1;
for (uint32_t i = 0; i < nents; i++) {
char vcshort[32], vchuman[128];
pcieadm_cfgspace_print_t p;
(void) snprintf(vcshort, sizeof (vcshort), "rsrccap%u", i);
(void) snprintf(vchuman, sizeof (vchuman), "VC Resource %u "
"Capability", i);
p.pcp_off = print->pcp_off + i * 0x10;
p.pcp_len = 4;
p.pcp_short = vcshort;
p.pcp_human = vchuman;
p.pcp_print = pcieadm_cfgspace_print_regdef;
p.pcp_arg = pcieadm_regdef_vc_rsrccap;
p.pcp_print(walkp, &p, p.pcp_arg);
(void) snprintf(vcshort, sizeof (vcshort), "rsrcctl%u", i);
(void) snprintf(vchuman, sizeof (vchuman), "VC Resource %u "
"Control", i);
p.pcp_off = print->pcp_off + i * 0x10 + 4;
p.pcp_len = 4;
p.pcp_short = vcshort;
p.pcp_human = vchuman;
p.pcp_print = pcieadm_cfgspace_print_regdef;
p.pcp_arg = pcieadm_regdef_vc_rsrcctl;
p.pcp_print(walkp, &p, p.pcp_arg);
(void) snprintf(vcshort, sizeof (vcshort), "rsrcsts%u", i);
(void) snprintf(vchuman, sizeof (vchuman), "VC Resource %u "
"Status", i);
p.pcp_off = print->pcp_off + i * 0x10 + 0xa;
p.pcp_len = 2;
p.pcp_short = vcshort;
p.pcp_human = vchuman;
p.pcp_print = pcieadm_cfgspace_print_regdef;
p.pcp_arg = pcieadm_regdef_vc_rsrcsts;
p.pcp_print(walkp, &p, p.pcp_arg);
}
}
static const pcieadm_cfgspace_print_t pcieadm_cap_vc[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "cap1", "Port VC Capability 1",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_vc_cap1 },
{ 0x8, 4, "cap2", "Port VC Capability 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_vc_cap2 },
{ 0xc, 2, "ctl", "Port VC Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_vc_ctl },
{ 0xe, 2, "sts", "Port VC Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_vc_sts },
{ 0x10, 12, "vcrec", "VC Resource", pcieadm_cfgspace_print_vc_rsrc },
{ -1, -1, NULL }
};
/*
* HyperTransport
*/
static const pcieadm_cfgspace_print_t pcieadm_cap_ht_intr[] = {
{ 0x2, 1, "index", "Interrupt Discovery Index",
pcieadm_cfgspace_print_hex },
{ 0x4, 4, "dataport", "Interrupt Dataport",
pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ht_command_pri[] = {
{ 0, 4, "unitid", "Base Unit ID", PRDV_HEX },
{ 5, 9, "count", "Unit Count", PRDV_HEX },
{ 10, 10, "host", "Master Host", PRDV_HEX },
{ 11, 11, "dir", "Default Direction", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "towards host",
"away from host" } } },
{ 12, 12, "drop", "Drop on Uninitialized Link", PRDV_HEX },
{ 13, 15, "cap", "Capability ID", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ht_command_sec[] = {
{ 0, 0, "reset", "Warm Reset", PRDV_HEX },
{ 1, 1, "de", "Double Ended", PRDV_HEX },
{ 2, 6, "devno", "Device Number", PRDV_HEX },
{ 7, 7, "chain", "Chain Side", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "from host", "from chain" } } },
{ 8, 8, "hide", "Host Hide", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "visible", "hidden" } } },
{ 10, 10, "target", "Act as Target", PRDV_HEX },
{ 11, 11, "eocerr", "Host Inbound End of Chain Error", PRDV_HEX },
{ 12, 12, "drop", "Drop on Uninitialized Link", PRDV_HEX },
{ 13, 15, "cap", "Capability ID", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ht_linkctl[] = {
{ 0, 0, "srcid", "Source ID", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "cfl", "CRC Flood", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 2, 2, "cst", "CRC Start Test", PRDV_HEX },
{ 3, 3, "cfer", "CRC Force Error", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 4, 4, "linkfail", "Link Failure", PRDV_HEX },
{ 5, 5, "initcmp", "Initialization Complete", PRDV_HEX },
{ 6, 6, "eoc", "End of Chain", PRDV_HEX },
{ 7, 7, "txoff", "Transmitter Off", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "transmitter on",
"transmitter off" } } },
{ 8, 11, "crcerr", "CRC Error", PRDV_HEX },
{ 12, 12, "isoc", "Isochronous Flow Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 13, 13, "ls", "LDTSTOP# Tristate", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 14, 14, "extctl", "Extended CTL Time", PRDV_HEX },
{ 15, 15, "64b", "64-bit Addressing", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ht_linkcfg[] = {
{ 0, 2, "maxin", "Maximum Link Width In", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "8 bits", "16 bits", NULL, "32 bits",
"2 bits", "4 bits", NULL, "not connected" } } },
{ 3, 3, "dwfcinsup", "Doubleword Flow Control In", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 4, 6, "maxout", "Maximum Link Width Out", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "8 bits", "16 bits", NULL, "32 bits",
"2 bits", "4 bits", NULL, "not connected" } } },
{ 7, 7, "dwfcoutsup", "Doubleword Flow Control Out", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 10, "linkin", "Link Width In", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "8 bits", "16 bits", NULL, "32 bits",
"2 bits", "4 bits", NULL, "not connected" } } },
{ 11, 11, "dwfcin", "Doubleword Flow Control In", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 12, 14, "linkout", "Link Width Out", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "8 bits", "16 bits", NULL, "32 bits",
"2 bits", "4 bits", NULL, "not connected" } } },
{ 15, 15, "dwfcout", "Doubleword Flow Control Out", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ht_rev[] = {
{ 0, 4, "minor", "Minor Revision", PRDV_HEX },
{ 5, 7, "major", "Major Revision", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ht_linkfreq[] = {
{ 0, 4, "freq", "Link Frequency", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "200 MHz", "300 MHz", "400 MHz",
"500 MHz", "600 MHz", "800 MHz", "1000 MHz", "1200 MHz", "1400 MHz",
"1600 MHz", "1800 MHz", "2000 MHz", "2200 MHz", "2400 MHz",
"2600 MHz", "Vendor Specfic" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ht_linkerr[] = {
{ 4, 4, "prot", "Protocol Error", PRDV_HEX },
{ 5, 5, "over", "Overflow Error", PRDV_HEX },
{ 6, 6, "eoc", "End of Chain Error", PRDV_HEX },
{ 7, 7, "ctl", "CTL Timeout", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ht_linkcap[] = {
{ 0, 15, "freq", "Link Frequency", PRDV_BITFIELD,
.prd_val = { .prdv_strval = { "200 MHz", "300 MHz", "400 MHz",
"500 MHz", "600 MHz", "800 MHz", "1000 MHz", "1200 MHz", "1400 MHz",
"1600 MHz", "1800 MHz", "2000 MHz", "2200 MHz", "2400 MHz",
"2600 MHz", "Vendor Specfic" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ht_feature[] = {
{ 0, 0, "isofc", "Isochronous Flow Control", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 1, 1, "ls", "LDTSTOP#", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 2, 2, "crct", "CRC Test Mode", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 3, 3, "ectl", "Extended CTL Time", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not required", "required" } } },
{ 4, 4, "64b", "64-bit Addressing", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 5, 5, "unitid", "UnitID Reorder", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "enabled", "disabled" } } },
{ 6, 6, "srcid", "Source Identification Extension", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "not required", "required" } } },
{ 8, 8, "extreg", "Extended Register Set", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 9, 9, "uscfg", "Upstream Configuration", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ht_error[] = {
{ 0, 0, "protfl", "Protocol Error Flood", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "ovfl", "Overflow Error Flood", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 2, 2, "protf", "Protocol Error Fatal", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 3, 3, "ovf", "Overflow Error Fatal", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 4, 4, "eocf", "End of Chain Fatal Error", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 5, 5, "respf", "Response Error Fatal", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 6, 6, "crcf", "CRC Error Fatal", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 7, 7, "sysf", "System Error Fatal", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 8, 8, "chain", "Chain Fail", PRDV_HEX },
{ 9, 9, "resp", "Response Error", PRDV_HEX },
{ 10, 10, "protnf", "Protocol Error Non-Fatal", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 11, 11, "ovfnf", "Overflow Error Non-Fatal", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 12, 12, "eocnf", "End of Chain Error Non-Fatal", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 13, 13, "respnf", "Response Error Non-Fatal", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 14, 14, "crcnf", "CRC Error Non-Fatal", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 15, 15, "sysnf", "System Error Non-Fatal", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ht_memory[] = {
{ 0, 8, "base", "Memory Base Upper 8 Bits", PRDV_HEX,
.prd_val = { .prdv_hex = { 32 } } },
{ 9, 15, "limit", "Memory Limit Upper 8 Bits", PRDV_HEX,
.prd_val = { .prdv_hex = { 32 } } },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_ht_pri[] = {
{ 0x2, 2, "command", "Command",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_command_pri },
{ 0x4, 2, "linkctl0", "Link Control 0",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkctl },
{ 0x6, 2, "linkcfg0", "Link Configuration 0",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkcfg },
{ 0x8, 2, "linkctl1", "Link Control 1",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkctl },
{ 0xa, 2, "linkcfg1", "Link Configuration 1",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkcfg },
{ 0xc, 1, "rev", "Revision",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_rev },
{ 0xd, 1, "linkfreq0", "Link Frequency 0",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkfreq },
{ 0xd, 1, "linkerr0", "Link Error 0",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkerr },
{ 0xe, 2, "linkfcap0", "Link Frequency Cap 0",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkcap },
{ 0x10, 1, "feature", "Feature Capability",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_feature },
{ 0x11, 1, "linkfreq1", "Link Frequency 1",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkfreq },
{ 0x11, 1, "linkerr1", "Link Error 1",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkerr },
{ 0x12, 2, "linkfcap1", "Link Frequency Cap 1",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkcap },
{ 0x14, 2, "scratch", "Enumeration Scratchpad",
pcieadm_cfgspace_print_hex },
{ 0x16, 2, "error", "Error Handling",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_error },
{ 0x18, 2, "memory", "Memory",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_memory },
{ 0x1a, 1, "bus", "Bus Number", pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_ht_sec[] = {
{ 0x2, 2, "command", "Command",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_command_sec },
{ 0x4, 2, "linkctl", "Link Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkctl },
{ 0x6, 2, "linkcfg", "Link Configuration",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkcfg },
{ 0x8, 1, "rev", "Revision",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_rev },
{ 0x9, 1, "linkfreq", "Link Frequency 0",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkfreq },
{ 0x9, 1, "linkerr", "Link Error 0",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkerr },
{ 0xa, 2, "linkfcap", "Link Frequency Cap 0",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_linkcap },
{ 0xc, 2, "feature", "Feature Capability",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_feature },
{ 0x10, 2, "scratch", "Enumeration Scratchpad",
pcieadm_cfgspace_print_hex },
{ 0x12, 2, "error", "Error Handling",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_error },
{ 0x14, 2, "memory", "Memory",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_memory },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ht_msi[] = {
{ 0, 0, "en", "Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "fixed", "Fixed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ -1, -1, NULL }
};
static void
pcieadm_cfgspace_print_ht_msi_addr(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
uint8_t fixed = walkp->pcw_data->pcb_u8[walkp->pcw_capoff + 2];
if (bitx8(fixed, 1, 1) != 0)
return;
pcieadm_cfgspace_print_hex(walkp, print, arg);
}
static const pcieadm_cfgspace_print_t pcieadm_cap_ht_msi[] = {
{ 0x2, 2, "command", "Command",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ht_msi },
{ 0x4, 8, "address", "MSI Address",
pcieadm_cfgspace_print_ht_msi_addr },
{ -1, -1, NULL }
};
/*
* Capability related tables
*/
typedef struct pcieadm_cap_vers {
uint32_t ppr_vers;
uint32_t ppr_len;
const pcieadm_cfgspace_print_t *ppr_print;
} pcieadm_cap_vers_t;
typedef struct pcieadm_subcap {
const char *psub_short;
const char *psub_human;
} pcieadm_subcap_t;
typedef struct pcieadm_pci_cap pcieadm_pci_cap_t;
typedef void (*pcieadm_cap_info_f)(pcieadm_cfgspace_walk_t *,
const pcieadm_pci_cap_t *, uint32_t, const pcieadm_cap_vers_t **,
uint32_t *, const pcieadm_subcap_t **);
struct pcieadm_pci_cap {
uint32_t ppc_id;
const char *ppc_short;
const char *ppc_human;
pcieadm_cap_info_f ppc_info;
const pcieadm_cap_vers_t ppc_vers[4];
};
/*
* Capability version determinations.
*/
static void
pcieadm_cap_info_fixed(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_pci_cap_t *cap, uint32_t off,
const pcieadm_cap_vers_t **versp, uint32_t *lenp,
const pcieadm_subcap_t **subcap)
{
*versp = &cap->ppc_vers[0];
*lenp = cap->ppc_vers[0].ppr_len;
*subcap = NULL;
}
static void
pcieadm_cap_info_vers(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_pci_cap_t *cap, uint32_t off,
const pcieadm_cap_vers_t **versp, uint32_t *lenp,
const pcieadm_subcap_t **subcap)
{
uint8_t vers;
*subcap = NULL;
vers = walkp->pcw_data->pcb_u8[off + 2] & 0xf;
for (uint32_t i = 0; i < ARRAY_SIZE(cap->ppc_vers); i++) {
if (vers == cap->ppc_vers[i].ppr_vers &&
cap->ppc_vers[i].ppr_vers != 0) {
*versp = &cap->ppc_vers[i];
*lenp = cap->ppc_vers[i].ppr_len;
return;
}
}
*versp = NULL;
*lenp = 0;
}
/*
* The PCI Power Management capability uses a 3-bit version ID as opposed to the
* standard 4-bit version.
*/
static void
pcieadm_cap_info_pcipm(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_pci_cap_t *cap, uint32_t off,
const pcieadm_cap_vers_t **versp, uint32_t *lenp,
const pcieadm_subcap_t **subcap)
{
uint8_t vers;
*subcap = NULL;
vers = walkp->pcw_data->pcb_u8[off + 2] & 0x7;
for (uint32_t i = 0; i < ARRAY_SIZE(cap->ppc_vers); i++) {
if (vers == cap->ppc_vers[i].ppr_vers) {
*versp = &cap->ppc_vers[i];
*lenp = cap->ppc_vers[i].ppr_len;
return;
}
}
*versp = NULL;
*lenp = 0;
}
/*
* The PCIe capability underwent a few changes. In version 1 of the capability,
* devices were not required to implement the entire capability. In particular,
* endpoints did not need to implement anything more than the link status
* register. In the v2 capability, this was changed such that all devices had to
* implement the entire capbility, but otherwise hardcode registers to zero. As
* such we get to play guess the length based on the device type.
*/
static const pcieadm_cap_vers_t pcieadm_cap_vers_pcie_v1_dev = {
1, 0x0c, pcieadm_cap_pcie_v1_dev
};
static const pcieadm_cap_vers_t pcieadm_cap_vers_pcie_v1_link = {
1, 0x14, pcieadm_cap_pcie_v1_link
};
static const pcieadm_cap_vers_t pcieadm_cap_vers_pcie_v1_slot = {
1, 0x1c, pcieadm_cap_pcie_v1_slot
};
static const pcieadm_cap_vers_t pcieadm_cap_vers_pcie_v1_all = {
1, 0x24, pcieadm_cap_pcie_v1_all
};
static const pcieadm_cap_vers_t pcieadm_cap_vers_pcie_v2 = {
2, 0x4c, pcieadm_cap_pcie_v2
};
static void
pcieadm_cap_info_pcie(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_pci_cap_t *cap, uint32_t off,
const pcieadm_cap_vers_t **versp, uint32_t *lenp,
const pcieadm_subcap_t **subcap)
{
uint8_t vers = walkp->pcw_data->pcb_u8[off + 2] & 0xf;
uint16_t pcie = walkp->pcw_data->pcb_u8[off + 2] |
(walkp->pcw_data->pcb_u8[off + 3] << 8);
/*
* Version 2 is simple. There's only one thing to do, so we do it. For
* version 1 we need to look at the device type.
*/
*subcap = NULL;
if (vers == 2) {
*versp = &pcieadm_cap_vers_pcie_v2;
*lenp = (*versp)->ppr_len;
return;
} else if (vers != 1) {
*versp = NULL;
*lenp = 0;
return;
}
switch (pcie & PCIE_PCIECAP_DEV_TYPE_MASK) {
case PCIE_PCIECAP_DEV_TYPE_PCIE_DEV:
case PCIE_PCIECAP_DEV_TYPE_PCI_DEV:
*versp = &pcieadm_cap_vers_pcie_v1_link;
break;
case PCIE_PCIECAP_DEV_TYPE_RC_IEP:
*versp = &pcieadm_cap_vers_pcie_v1_dev;
break;
case PCIE_PCIECAP_DEV_TYPE_UP:
case PCIE_PCIECAP_DEV_TYPE_DOWN:
case PCIE_PCIECAP_DEV_TYPE_PCIE2PCI:
case PCIE_PCIECAP_DEV_TYPE_PCI2PCIE:
if ((pcie & PCIE_PCIECAP_SLOT_IMPL) != 0) {
*versp = &pcieadm_cap_vers_pcie_v1_slot;
} else {
*versp = &pcieadm_cap_vers_pcie_v1_link;
}
break;
case PCIE_PCIECAP_DEV_TYPE_ROOT:
case PCIE_PCIECAP_DEV_TYPE_RC_EC:
*versp = &pcieadm_cap_vers_pcie_v1_all;
break;
default:
*versp = NULL;
*lenp = 0;
return;
}
*lenp = (*versp)->ppr_len;
}
/*
* The length of the MSI capability depends on bits in its control field. As
* such we use a custom function to extract the length and treat each of these
* variants as thought it were a different version.
*/
static pcieadm_cap_vers_t pcieadm_cap_vers_msi_32 = {
0, 0xa, pcieadm_cap_msi_32
};
static pcieadm_cap_vers_t pcieadm_cap_vers_msi_32ext = {
0, 0xc, pcieadm_cap_msi_32ext
};
static pcieadm_cap_vers_t pcieadm_cap_vers_msi_64 = {
0, 0xe, pcieadm_cap_msi_64
};
static pcieadm_cap_vers_t pcieadm_cap_vers_msi_64ext = {
0, 0x10, pcieadm_cap_msi_64ext
};
static pcieadm_cap_vers_t pcieadm_cap_vers_msi_32pvm = {
0, 0x14, pcieadm_cap_msi_32pvm
};
static pcieadm_cap_vers_t pcieadm_cap_vers_msi_64pvm = {
0, 0x18, pcieadm_cap_msi_64pvm
};
static void
pcieadm_cap_info_msi(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_pci_cap_t *cap, uint32_t off,
const pcieadm_cap_vers_t **versp, uint32_t *lenp,
const pcieadm_subcap_t **subcap)
{
uint16_t ctrl;
boolean_t addr64, pvm, ext;
*subcap = NULL;
ctrl = walkp->pcw_data->pcb_u8[off + 2] |
(walkp->pcw_data->pcb_u8[off + 3] << 8);
if (ctrl == PCI_EINVAL16) {
warnx("failed to read MSI Message Control register");
*lenp = 0;
*versp = NULL;
return;
}
/*
* The MSI capability has three main things that control its size.
* 64-bit addressing adds 4 bytes. Per-Vector Masking adds 8 bytes and
* causes the Extended data addressing piece to always be present.
* Therefore we check first for pvm as it implies evt, effectively.
*/
addr64 = (ctrl & PCI_MSI_64BIT_MASK) != 0;
pvm = (ctrl & PCI_MSI_PVM_MASK) != 0;
ext = (ctrl & PCI_MSI_EMD_MASK) != 0;
if (pvm && addr64) {
*versp = &pcieadm_cap_vers_msi_64pvm;
} else if (pvm) {
*versp = &pcieadm_cap_vers_msi_32pvm;
} else if (addr64 && ext) {
*versp = &pcieadm_cap_vers_msi_64ext;
} else if (addr64) {
*versp = &pcieadm_cap_vers_msi_64;
} else if (ext) {
*versp = &pcieadm_cap_vers_msi_32ext;
} else {
*versp = &pcieadm_cap_vers_msi_32;
}
*lenp = (*versp)->ppr_len;
}
/*
* The AER Capability is technically different for PCIe-PCI bridges. If we find
* that device type here, then we need to use a different version information
* rather than the actual set defined with the device (which have changed over
* time).
*/
static const pcieadm_cap_vers_t pcieadm_cap_vers_aer_bridge = {
1, 0x4c, pcieadm_cap_aer_bridge
};
static void
pcieadm_cap_info_aer(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_pci_cap_t *cap, uint32_t off,
const pcieadm_cap_vers_t **versp, uint32_t *lenp,
const pcieadm_subcap_t **subcap)
{
if (walkp->pcw_pcietype == PCIE_PCIECAP_DEV_TYPE_PCIE2PCI) {
uint8_t vers;
*subcap = NULL;
vers = walkp->pcw_data->pcb_u8[off + 2] & 0xf;
if (vers != pcieadm_cap_vers_aer_bridge.ppr_vers) {
warnx("encountered PCIe to PCI bridge with unknown "
"AER capability version: %u", vers);
*lenp = 0;
*versp = NULL;
return;
}
*lenp = pcieadm_cap_vers_aer_bridge.ppr_len;
*versp = &pcieadm_cap_vers_aer_bridge;
}
return (pcieadm_cap_info_vers(walkp, cap, off, versp, lenp, subcap));
}
/*
* The PCI-X capability varies depending on the header type of the device.
* Therefore we simply use the device type to figure out what to do.
*/
static pcieadm_cap_vers_t pcieadm_cap_vers_pcix_dev = {
0, 0x8, pcieadm_cap_pcix_dev
};
static pcieadm_cap_vers_t pcieadm_cap_vers_pcix_bridge = {
0, 0x10, pcieadm_cap_pcix_bridge
};
static void
pcieadm_cap_info_pcix(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_pci_cap_t *cap, uint32_t off,
const pcieadm_cap_vers_t **versp, uint32_t *lenp,
const pcieadm_subcap_t **subcap)
{
*subcap = NULL;
switch (walkp->pcw_dtype) {
case PCI_HEADER_ZERO:
*versp = &pcieadm_cap_vers_pcix_dev;
break;
case PCI_HEADER_ONE:
*versp = &pcieadm_cap_vers_pcix_bridge;
break;
default:
warnx("encountered PCI-X capability with unsupported device "
"type: 0x%x\n", walkp->pcw_dtype);
*lenp = 0;
*versp = NULL;
return;
}
*lenp = (*versp)->ppr_len;
}
typedef struct pcieadm_cap_ht {
uint32_t pch_capid;
pcieadm_subcap_t pch_subcap;
pcieadm_cap_vers_t pch_vers;
} pcieadm_cap_ht_t;
static pcieadm_cap_ht_t pcieadm_ht_cap_pri = {
0x00, { "pri", "Primary" }, { 0, 0x1c, pcieadm_cap_ht_pri }
};
static pcieadm_cap_ht_t pcieadm_ht_cap_sec = {
0x01, { "sec", "Secondary" }, { 0, 0x18, pcieadm_cap_ht_sec }
};
static pcieadm_cap_ht_t pcieadm_ht_caps[] = {
{ 0x08, { "switch", "Switch" } },
{ 0x10, { "intr", "Interrupt Discovery and Configuration" },
{ 0, 8, pcieadm_cap_ht_intr } },
{ 0x11, { "rev", "Revision ID" } },
{ 0x12, { "unitid", "UnitID Clumping" } },
{ 0x13, { "extcfg", "Extended Configuration Space Access" } },
{ 0x14, { "addrmap", "Address Mapping" } },
{ 0x15, { "msi", "MSI Mapping" },
{ 0, 4, pcieadm_cap_ht_msi } },
{ 0x16, { "dir", "DirectRoute" } },
{ 0x17, { "vcset", "VCSet" } },
{ 0x18, { "retry", "Retry Mode" } },
{ 0x19, { "x86", "X86 Encoding" } },
{ 0x1a, { "gen3", "Gen3" } },
{ 0x1b, { "fle", "Function-Level Extension" } },
{ 0x1c, { "pm", "Power Management" } },
{ UINT32_MAX, NULL },
};
static void
pcieadm_cap_info_ht(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_pci_cap_t *cap, uint32_t off,
const pcieadm_cap_vers_t **versp, uint32_t *lenp,
const pcieadm_subcap_t **subcap)
{
uint32_t base = walkp->pcw_data->pcb_u32[off / 4];
uint32_t caplo = bitx32(base, 31, 29);
pcieadm_cap_ht_t *htcap = NULL;
*versp = NULL;
*lenp = 0;
*subcap = NULL;
if (caplo > 1) {
uint32_t capid = bitx32(base, 31, 27);
for (uint32_t i = 0; pcieadm_ht_caps[i].pch_capid != UINT32_MAX;
i++) {
if (capid == pcieadm_ht_caps[i].pch_capid) {
htcap = &pcieadm_ht_caps[i];
break;
}
}
} else if (caplo == 0) {
htcap = &pcieadm_ht_cap_pri;
} else if (caplo == 1) {
htcap = &pcieadm_ht_cap_sec;
}
if (htcap == NULL) {
warnx("encountered unknown HyperTransport Capability 0x%x",
bitx32(base, 31, 27));
return;
}
*subcap = &htcap->pch_subcap;
if (htcap->pch_vers.ppr_print != NULL) {
*versp = &htcap->pch_vers;
*lenp = htcap->pch_vers.ppr_len;
}
}
/*
* Root Complex Link Declaration
*/
static const pcieadm_regdef_t pcieadm_regdef_rcld_desc[] = {
{ 0, 3, "type", "Element Type", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "Configuration Space Element",
"System Egress Port or internal sink",
"Internal Root Complex Link" } } },
{ 8, 15, "num", "Number of Entries", PRDV_HEX },
{ 16, 23, "id", "Component ID", PRDV_HEX },
{ 24, 31, "port", "Port Number", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_rcld_link[] = {
{ 0, 0, "valid", "Link Valid", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 1, 1, "type", "Link Type", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "RCRB", "Configuration Space" } } },
{ 2, 2, "rcrb", "Assosciate RCRB", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 16, 23, "tid", "Target Component ID", PRDV_HEX },
{ 24, 31, "tport", "Target Port Number", PRDV_HEX },
{ -1, -1, NULL }
};
/*
* Print a variable number of Root Complex Links.
*/
static void
pcieadm_cfgspace_print_rcld(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
uint_t nlinks = walkp->pcw_data->pcb_u8[walkp->pcw_capoff + 5];
for (uint_t i = 0; i < nlinks; i++) {
char mshort[32], mhuman[128];
pcieadm_cfgspace_print_t p;
uint16_t off = print->pcp_off + i * 0x10;
uint8_t type = walkp->pcw_data->pcb_u8[walkp->pcw_capoff + off];
(void) snprintf(mshort, sizeof (mshort), "link%udesc", i);
(void) snprintf(mhuman, sizeof (mhuman), "Link %u Description");
p.pcp_off = off;
p.pcp_len = 4;
p.pcp_short = mshort;
p.pcp_human = mhuman;
p.pcp_print = pcieadm_cfgspace_print_regdef;
p.pcp_arg = pcieadm_regdef_rcld_link;
p.pcp_print(walkp, &p, p.pcp_arg);
/*
* The way that we print the link depends on the actual type of
* link which is in bit 2 of the link description.
*/
p.pcp_off += 8;
if ((type & (1 << 1)) == 0) {
(void) snprintf(mshort, sizeof (mshort),
"link%uaddr", i);
(void) snprintf(mhuman, sizeof (mhuman),
"Link %u Address");
p.pcp_len = 8;
p.pcp_print = pcieadm_cfgspace_print_hex;
p.pcp_arg = NULL;
p.pcp_print(walkp, &p, p.pcp_arg);
} else {
warnx("encountered unsupported RCLD Link Address");
}
}
}
static const pcieadm_cfgspace_print_t pcieadm_cap_rcld[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "desc", "Self Description",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_rcld_desc },
{ 0x10, 0x10, "link", "Link Entry", pcieadm_cfgspace_print_rcld },
{ -1, -1, NULL }
};
/*
* Physical Layer 32.0 GT/s Capability
*/
static const pcieadm_regdef_t pcieadm_regdef_32g_cap[] = {
{ 0, 0, "eqbyp", "Equalization Bypass to Highest Rate", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 1, 1, "noeq", "No Equalization Needed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 8, "mts0", "Modified TS Usage Mode 0 - PCI Express", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 9, 9, "mts1", "Modified TS Usage Mode 1 - Training Set", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 10, 10, "mts2", "Modified TS Usage Mode 2 - Alternate Protocol",
PRDV_STRVAL, .prd_val = { .prdv_strval = { "unsupported",
"supported" } } },
/*
* Bits 11 to 15 are defined as reserved for future use here as
* read-only bits. Add them here once they have actual definitions.
*/
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_32g_ctl[] = {
{ 0, 0, "eqbyp", "Equalization Bypass to Highest Rate", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "enabled", "disabled" } } },
{ 1, 1, "noeq", "No Equalization Needed", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "enabled", "disabled" } } },
{ 8, 10, "mts", "Modified TS Usage Mode Selected", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "PCIe", "training set messages",
"alternate protocol negotiation" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_32g_sts[] = {
{ 0, 0, "eqcomp", "Equalization 32.0 GT/s Complete", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "incomplete", "complete" } } },
{ 1, 1, "eqp1", "Equalization 32.0 GT/s Phase 1", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "incomplete", "complete" } } },
{ 2, 2, "eqp2", "Equalization 32.0 GT/s Phase 2", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "incomplete", "complete" } } },
{ 3, 3, "eqp3", "Equalization 32.0 GT/s Phase 3", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "incomplete", "complete" } } },
{ 4, 4, "req", "Link Equalization Request 32.0 GT/s", PRDV_HEX },
{ 5, 5, "mts", "Modified TS Received", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 6, 7, "rxelbc", "Received Enhanced Link Behavior Control",
PRDV_STRVAL, .prd_val = { .prdv_strval = {
"full equalization required", "equalization bypass to highest rate",
"no equalization needed", "modified TS1/TS2 ordered sets" } } },
{ 8, 8, "txpre", "Transmitter Precoding", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 9, 9, "prereq", "Transmitter Precoding Request", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 10, 10, "noeqrx", "No Equalization Needed Received", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_32g_rxts1[] = {
{ 0, 2, "mts", "Modified TS Usage Mode Selected", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "PCIe", "training set messages",
"alternate protocol negotiation" } } },
{ 3, 15, "info", "Received Modified TS Information 1", PRDV_HEX },
{ 16, 31, "vendor", "Received Modified TS Vendor ID", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_32g_rxts2[] = {
{ 0, 23, "info", "Received Modified TS Information 2", PRDV_HEX },
{ 24, 25, "apnsts", "Alternate Protocol Negotiation Status",
PRDV_STRVAL, .prd_val = { .prdv_strval = { "not supported",
"disabled", "failed", "succeeded" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_32g_txts1[] = {
{ 0, 2, "mts", "Transmitted Modified TS Usage Mode", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "PCIe", "training set messages",
"alternate protocol negotiation" } } },
{ 3, 15, "info", "Transmitted Modified TS Information 1", PRDV_HEX },
{ 16, 31, "vendor", "Transmitted Modified TS Vendor ID", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_32g_txts2[] = {
{ 0, 23, "info", "Transmitted Modified TS Information 2", PRDV_HEX },
{ 24, 25, "apnsts", "Alternate Protocol Negotiation Status",
PRDV_STRVAL, .prd_val = { .prdv_strval = { "not supported",
"disabled", "failed", "succeeded" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_32g_eq[] = {
{ 0, 3, "dstxpre", "Downstream Port 32.0 GT/s Transmitter Preset",
PRDV_HEX },
{ 4, 7, "ustxpre", "Upstream Port 32.0 GT/s Transmitter Preset",
PRDV_HEX },
{ -1, -1, NULL }
};
static void
pcieadm_cfgspace_print_32geq(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
if (walkp->pcw_nlanes == 0) {
warnx("failed to capture lane count, but somehow have "
"Physical Layer 32.0 GT/s cap");
return;
}
for (uint_t i = 0; i < walkp->pcw_nlanes; i++) {
char eqshort[32], eqhuman[128];
pcieadm_cfgspace_print_t p;
(void) snprintf(eqshort, sizeof (eqshort), "lane%u", i);
(void) snprintf(eqhuman, sizeof (eqhuman), "Lane %u EQ Control",
i);
p.pcp_off = print->pcp_off + i * 1;
p.pcp_len = 1;
p.pcp_short = eqshort;
p.pcp_human = eqhuman;
p.pcp_print = pcieadm_cfgspace_print_regdef;
p.pcp_arg = pcieadm_regdef_32g_eq;
p.pcp_print(walkp, &p, p.pcp_arg);
}
}
static const pcieadm_cfgspace_print_t pcieadm_cap_32g[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "cap", "32.0 GT/s Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_32g_cap },
{ 0x8, 4, "ctl", "32.0 GT/s Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_32g_ctl },
{ 0xc, 4, "sts", "32.0 GT/s Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_32g_sts },
{ 0x10, 4, "rxts1", "Received Modified TS Data 1",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_32g_rxts1 },
{ 0x14, 4, "rxts2", "Received Modified TS Data 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_32g_rxts2 },
{ 0x18, 4, "txts1", "Transmitted Modified TS Data 1",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_32g_txts1 },
{ 0x1c, 4, "txts2", "Transmitted Modified TS Data 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_32g_txts2 },
{ 0x20, 1, "eqctl", "32.0 GT/s EQ Control",
pcieadm_cfgspace_print_32geq },
{ -1, -1, NULL }
};
/*
* Native PCIe Enclosure Management
*/
static const pcieadm_regdef_t pcieadm_regdef_npem_cap[] = {
{ 0, 0, "npem", "NPEM", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 1, 1, "reset", "NPEM Reset", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 2, 2, "ok", "NPEM OK", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 3, 3, "loc", "NPEM Locate", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 4, 4, "fail", "NPEM Fail", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 5, 5, "rb", "NPEM Rebuild", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 6, 6, "pfa", "NPEM PFA", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 7, 7, "hs", "NPEM Hot Spare", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 8, 8, "crit", "NPEM In a Critical Array", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 9, 9, "fail", "NPEM In a Failed Array", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 10, 10, "invdt", "NPEM Invalid Device type", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 11, 11, "dis", "NPEM Disabled", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ 24, 31, "es", "Enclosure-specific Capabilities", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_npem_ctl[] = {
{ 0, 0, "npem", "NPEM", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 1, "reset", "NPEM Initiate Reset", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 2, 2, "ok", "NPEM OK", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 3, 3, "loc", "NPEM Locate", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 4, 4, "fail", "NPEM Fail", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 5, 5, "rb", "NPEM Rebuild", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 6, 6, "pfa", "NPEM PFA", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 7, 7, "hs", "NPEM Hot Spare", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 8, 8, "crit", "NPEM In a Critical Array", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 9, 9, "fail", "NPEM In a Failed Array", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 10, 10, "invdt", "NPEM Invalid Device type", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 11, 11, "dis", "NPEM Disabled", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 24, 31, "es", "Enclosure-specific Control", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_npem_sts[] = {
{ 0, 0, "ccmplt", "NPEM Command Complete", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "no", "yes" } } },
{ 24, 31, "es", "Enclosure-specific Status", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_npem[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "cap", "NPEM Capability",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_npem_cap },
{ 0x8, 4, "ctl", "NPEM Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_npem_ctl },
{ 0xc, 4, "sts", "NPEM Status",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_npem_sts },
{ -1, -1, NULL }
};
/*
* Alternate Protocol Capability
*/
static const pcieadm_regdef_t pcieadm_regdef_ap_cap[] = {
{ 0, 7, "count", "Alternate Protocol Count", PRDV_HEX },
{ 8, 8, "sen", "Alternate Protocol Select Enable", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "unsupported", "supported" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ap_ctl[] = {
{ 0, 7, "index", "Alternate Protocol Index Select", PRDV_HEX },
{ 8, 8, "apngen", "Alternate Protocol Negotiation Global Enable",
PRDV_STRVAL, .prd_val = { .prdv_strval = { "disabled",
"enabled" } } },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ap_data1[] = {
{ 0, 2, "use", "Alternate Protocol Usage Information", PRDV_HEX },
{ 5, 15, "detail", "Alternate Protocol Details", PRDV_HEX },
{ 16, 31, "vendor", "Alternate Protocol Vendor ID", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ap_data2[] = {
{ 0, 23, "mts2", "Modified TS 2 Information", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_regdef_t pcieadm_regdef_ap_sen[] = {
{ 0, 0, "pcie", "Selective Enable Mask - PCIe", PRDV_STRVAL,
.prd_val = { .prdv_strval = { "disabled", "enabled" } } },
{ 1, 31, "other", "Selective Enable Mask - Other", PRDV_HEX },
{ -1, -1, NULL }
};
/*
* The Advanced Protocol Selective Enable Mask register is only present if a bit
* in the capabilities register is present. As such, we need to check if it is
* here before we try to read and print it.
*/
static void
pcieadm_cfgspace_print_ap_sen(pcieadm_cfgspace_walk_t *walkp,
const pcieadm_cfgspace_print_t *print, const void *arg)
{
uint32_t ap_cap = walkp->pcw_data->pcb_u32[walkp->pcw_capoff + 4];
pcieadm_cfgspace_print_t p;
if (bitx32(ap_cap, 8, 8) == 0)
return;
(void) memcpy(&p, print, sizeof (*print));
p.pcp_print = pcieadm_cfgspace_print_regdef;
p.pcp_arg = pcieadm_regdef_ap_sen;
p.pcp_print(walkp, &p, p.pcp_arg);
}
static const pcieadm_cfgspace_print_t pcieadm_cap_ap[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "cap", "Alternate Protocol Capabilities",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ap_cap },
{ 0x8, 4, "ctl", "Alternate Protocol Control",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ap_ctl },
{ 0xc, 4, "data1", "Alternate Protocol Data 1",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ap_data1 },
{ 0x10, 4, "data2", "Alternate Protocol Data 2",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_ap_data2 },
{ 0x14, 4, "sen", "Alternate Protocol Select Enable Mask",
pcieadm_cfgspace_print_ap_sen },
{ -1, -1, NULL }
};
/*
* Root Complex Event Collector Endpoint Association
*/
static const pcieadm_regdef_t pcieadm_regdef_rcecea_bus[] = {
{ 8, 15, "next", "RCEC Next Bus", PRDV_HEX },
{ 16, 23, "last", "RCEC Last Bus", PRDV_HEX },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_rcecea_v1[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "bitmap", "Association Bitmap for RCiEPs",
pcieadm_cfgspace_print_hex },
{ -1, -1, NULL }
};
static const pcieadm_cfgspace_print_t pcieadm_cap_rcecea_v2[] = {
{ 0x0, 4, "caphdr", "Capability Header",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_pcie_caphdr },
{ 0x4, 4, "bitmap", "Association Bitmap for RCiEPs",
pcieadm_cfgspace_print_hex },
{ 0x8, 4, "bus", "RCEC Associated Bus Numbers",
pcieadm_cfgspace_print_regdef, pcieadm_regdef_rcecea_bus },
{ -1, -1, NULL }
};
static const pcieadm_pci_cap_t pcieadm_pci_caps[] = {
{ PCI_CAP_ID_PM, "pcipm", "PCI Power Management",
pcieadm_cap_info_pcipm, { { 2, 8, pcieadm_cap_pcipm_v3 },
{ 3, 8, pcieadm_cap_pcipm_v3 } } },
{ PCI_CAP_ID_AGP, "agp", "Accelerated Graphics Port" },
{ PCI_CAP_ID_VPD, "vpd", "Vital Product Data", pcieadm_cap_info_fixed,
{ { 0, 8, pcieadm_cap_vpd } } },
{ PCI_CAP_ID_SLOT_ID, "slot", "Slot Identification" },
{ PCI_CAP_ID_MSI, "msi", "Message Signaled Interrupts",
pcieadm_cap_info_msi },
{ PCI_CAP_ID_cPCI_HS, "cpci", "CompactPCI Hot Swap" },
{ PCI_CAP_ID_PCIX, "pcix", "PCI-X", pcieadm_cap_info_pcix },
{ PCI_CAP_ID_HT, "ht", "HyperTransport", pcieadm_cap_info_ht },
{ PCI_CAP_ID_VS, "vs", "Vendor Specific", pcieadm_cap_info_fixed,
{ { 0, 3, pcieadm_cap_vs } } },
{ PCI_CAP_ID_DEBUG_PORT, "dbg", "Debug Port", pcieadm_cap_info_fixed,
{ { 0, 4, pcieadm_cap_debug } } },
{ PCI_CAP_ID_cPCI_CRC, "cpcicrc",
"CompactPCI Central Resource Control" },
{ PCI_CAP_ID_PCI_HOTPLUG, "pcihp", "PCI Hot-Plug" },
{ PCI_CAP_ID_P2P_SUBSYS, "bdgsub", "PCI Bridge Subsystem Vendor ID",
pcieadm_cap_info_fixed, { 0, 8, pcieadm_cap_bridge_subsys } },
{ PCI_CAP_ID_AGP_8X, "agp8x", "AGP 8x" },
{ PCI_CAP_ID_SECURE_DEV, "secdev", "Secure Device" },
{ PCI_CAP_ID_PCI_E, "pcie", "PCI Express", pcieadm_cap_info_pcie },
{ PCI_CAP_ID_MSI_X, "msix", "MSI-X", pcieadm_cap_info_fixed,
{ { 0, 12, pcieadm_cap_msix } } },
{ PCI_CAP_ID_SATA, "sata", "Serial ATA Configuration",
pcieadm_cap_info_fixed, { { 0, 8, pcieadm_cap_sata } } },
/*
* Note, the AF feature doesn't have a version but encodes a length in
* the version field, so we cheat and use that.
*/
{ PCI_CAP_ID_FLR, "af", "Advanced Features", pcieadm_cap_info_vers,
{ { 6, 6, pcieadm_cap_af } } },
{ PCI_CAP_ID_EA, "ea", "Enhanced Allocation" },
{ PCI_CAP_ID_FPB, "fpb", "Flattening Portal Bridge" }
};
static const pcieadm_pci_cap_t pcieadm_pcie_caps[] = {
{ 0, "null", "NULL Capability", pcieadm_cap_info_fixed,
{ { 0, 0x4, pcieadm_cap_null } } },
{ PCIE_EXT_CAP_ID_AER, "aer", "Advanced Error Reporting",
pcieadm_cap_info_aer, { { 1, 0x38, pcieadm_cap_aer_v1 },
{ 2, 0x48, pcieadm_cap_aer_v2 } } },
{ PCIE_EXT_CAP_ID_VC, "vc", "Virtual Channel", pcieadm_cap_info_vers,
{ { 0x1, 0x1c, pcieadm_cap_vc } } },
{ PCIE_EXT_CAP_ID_SER, "sn", "Serial Number", pcieadm_cap_info_vers,
{ { 1, 0xc, pcieadm_cap_sn } } },
{ PCIE_EXT_CAP_ID_PWR_BUDGET, "pwrbudg", "Power Budgeting",
pcieadm_cap_info_vers, { { 1, 0x10, pcieadm_cap_powbudg } } },
{ PCIE_EXT_CAP_ID_RC_LINK_DECL, "rcld",
"Root Complex Link Declaration", pcieadm_cap_info_vers,
{ { 1, 0x1c, pcieadm_cap_rcld } } },
{ PCIE_EXT_CAP_ID_RC_INT_LINKCTRL, "rcilc",
"Root Complex Internal Link Control" },
{ PCIE_EXT_CAP_ID_RC_EVNT_CEA, "rcecea",
"Root Complex Event Collector Endpoint Association",
pcieadm_cap_info_vers, { { 1, 0x8, pcieadm_cap_rcecea_v1 },
{ 2, 0xc, pcieadm_cap_rcecea_v2 } } },
{ PCIE_EXT_CAP_ID_MFVC, "mfvc", "Multi-Function Virtual Channel" },
{ PCIE_EXT_CAP_ID_VC_WITH_MFVC, "vcwmfvc", "Virtual Channel with MFVC",
pcieadm_cap_info_vers, { { 0x1, 0x1c, pcieadm_cap_vc } } },
{ PCIE_EXT_CAP_ID_RCRB, "rcrb", "Root Complex Register Block" },
{ PCIE_EXT_CAP_ID_VS, "vsec", "Vendor Specific Extended Capability",
pcieadm_cap_info_vers, { { 1, 0x8, pcieadm_cap_vsec } } },
{ PCIE_EXT_CAP_ID_CAC, "cac", "Configuration Access Correlation" },
{ PCIE_EXT_CAP_ID_ACS, "acs", "Access Control Services",
pcieadm_cap_info_vers, { { 1, 0x8, pcieadm_cap_acs } } },
{ PCIE_EXT_CAP_ID_ARI, "ari", "Alternative Routing-ID Interpretation",
pcieadm_cap_info_vers, { { 1, 0x8, pcieadm_cap_ari } } },
{ PCIE_EXT_CAP_ID_ATS, "ats", "Access Translation Services",
pcieadm_cap_info_vers, { { 1, 0x8, pcieadm_cap_ats } } },
{ PCIE_EXT_CAP_ID_SRIOV, "sriov", "Single Root I/O Virtualization",
pcieadm_cap_info_vers, { { 1, 0x40, pcieadm_cap_sriov } } },
{ PCIE_EXT_CAP_ID_MRIOV, "mriov", "Multi-Root I/O Virtualization" },
{ PCIE_EXT_CAP_ID_MULTICAST, "mcast", "Multicast",
pcieadm_cap_info_vers, { { 1, 0x30, pcieadm_cap_mcast } } },
{ PCIE_EXT_CAP_ID_PGREQ, "pgreq", "Page Request",
pcieadm_cap_info_vers, { { 1, 0x10, pcieadm_cap_pgreq } } },
{ PCIE_EXT_CAP_ID_EA, "ea", "Enhanced Allocation" },
{ PCIE_EXT_CAP_ID_RESIZE_BAR, "rbar", "Resizable Bar" },
{ PCIE_EXT_CAP_ID_DPA, "dpa", "Dynamic Power Allocation",
pcieadm_cap_info_vers, { { 1, 0x10, pcieadm_cap_dpa } } },
{ PCIE_EXT_CAP_ID_TPH_REQ, "tph", "TPH Requester",
pcieadm_cap_info_vers, { { 1, 0xc, pcieadm_cap_tph } } },
{ PCIE_EXT_CAP_ID_LTR, "ltr", "Latency Tolerance Reporting",
pcieadm_cap_info_vers, { { 1, 0x8, pcieadm_cap_ltr } } },
{ PCIE_EXT_CAP_ID_PCIE2, "pcie2", "Secondary PCI Express",
pcieadm_cap_info_vers, { { 1, 0xc, pcieadm_cap_pcie2 } } },
{ PCIE_EXT_CAP_ID_PASID, "pasid", "Process Address Space ID",
pcieadm_cap_info_vers, { { 1, 0x8, pcieadm_cap_pasid } } },
{ PCIE_EXT_CAP_ID_LNR, "lnr", "LN Requester" },
{ PCIE_EXT_CAP_ID_DPC, "dpc", "Downstream Port Containment",
pcieadm_cap_info_vers, { { 1, 0x30, pcieadm_cap_dpc } } },
{ PCIE_EXT_CAP_ID_L1PM, "l1pm", "L1 PM Substates",
pcieadm_cap_info_vers, { { 1, 0x10, pcieadm_cap_l1pm_v1 },
{ 2, 0x14, pcieadm_cap_l1pm_v2 } } },
{ PCIE_EXT_CAP_ID_PTM, "ptm", "Precision Time Management",
pcieadm_cap_info_vers, { { 1, 0xc, pcieadm_cap_info_ptm } } },
{ PCIE_EXT_CAP_ID_FRS, "frs", "FRS Queueing" },
{ PCIE_EXT_CAP_ID_RTR, "trt", "Readiness Time Reporting" },
/*
* When we encounter a designated vendor specification, in particular,
* for CXL, we'll want to set ppc_subcap so we can use reasonable
* filtering.
*/
{ PCIE_EXT_CAP_ID_DVS, "dvsec",
"Designated Vendor-Specific Extended Capability" },
{ PCIE_EXT_CAP_ID_VFRBAR, "vfrbar", "Virtual Function Resizable BAR" },
{ PCIE_EXT_CAP_ID_DLF, "dlf", "Data Link Feature",
pcieadm_cap_info_vers, { { 1, 0xc, pcieadm_cap_dlf } } },
{ PCIE_EXT_CAP_ID_PL16GT, "pl16g", "Physical Layer 16.0 GT/s",
pcieadm_cap_info_vers, { { 1, 0x22, pcieadm_cap_16g } } },
{ PCIE_EXT_CAP_ID_LANE_MARGIN, "margin",
"Lane Margining at the Receiver", pcieadm_cap_info_vers,
{ { 1, 0x8, pcieadm_cap_margin } } },
{ PCIE_EXT_CAP_ID_HIEARCHY_ID, "hierid", "Hierarchy ID" },
{ PCIE_EXT_CAP_ID_NPEM, "npem", "Native PCIe Enclosure Management",
pcieadm_cap_info_vers, { { 1, 0x10, pcieadm_cap_npem } } },
/*
* The sizing of the 32.0 GT/s physical layer requires that there's at
* least one lane's worth of information and the device is required to
* pad that out to 4-byte alignment.
*/
{ PCIE_EXT_CAP_ID_PL32GT, "pl32g", "Physical Layer 32.0 GT/s",
pcieadm_cap_info_vers, { { 1, 0x24, pcieadm_cap_32g } } },
{ PCIE_EXT_CAP_ID_AP, "ap", "Alternative Protocol",
pcieadm_cap_info_vers, { { 1, 0x14, pcieadm_cap_ap } } },
{ PCIE_EXT_CAP_ID_SFI, "sfi", "System Firmware Intermediary" },
{ PCIE_EXT_CAP_ID_SHDW_FUNC, "sfunc", "Shadow Functions" },
{ PCIE_EXT_CAP_ID_DOE, "doe", "Data Object Exchange" },
{ PCIE_EXT_CAP_ID_DEV3, "dev3", "Device 3" },
{ PCIE_EXT_CAP_ID_IDE, "ide", "Integrity and Data Encryption" },
{ PCIE_EXT_CAP_ID_PL64GT, "pl64g", "Physical Layer 64.0 GT/s" },
{ PCIE_EXT_CAP_ID_FLIT_LOG, "fltlog", "Flit Logging" },
{ PCIE_EXT_CAP_ID_FLIT_PERF, "fltperf",
"Flit Performance Measurement" },
{ PCIE_EXT_CAP_ID_FLIT_ERR, "flterr", "Flit Error Injection" }
};
static const pcieadm_pci_cap_t *
pcieadm_cfgspace_match_cap(uint32_t capid, boolean_t pcie)
{
uint_t ncaps;
const pcieadm_pci_cap_t *caps;
if (pcie) {
ncaps = ARRAY_SIZE(pcieadm_pcie_caps);
caps = pcieadm_pcie_caps;
} else {
ncaps = ARRAY_SIZE(pcieadm_pci_caps);
caps = pcieadm_pci_caps;
}
for (uint_t i = 0; i < ncaps; i++) {
if (caps[i].ppc_id == capid) {
return (&caps[i]);
}
}
return (NULL);
}
static void
pcieadm_cfgspace_print_cap(pcieadm_cfgspace_walk_t *walkp, uint_t capid,
const pcieadm_pci_cap_t *cap_info, const pcieadm_cap_vers_t *vers_info,
const pcieadm_subcap_t *subcap)
{
boolean_t filter = B_FALSE;
/*
* If we don't recognize the capability, print out the ID if we're not
* filtering and not in parsable mode.
*/
if (cap_info == NULL) {
if (walkp->pcw_ofmt == NULL &&
pcieadm_cfgspace_filter(walkp, NULL)) {
warnx("encountered unknown capability ID 0x%x "
"unable to print or list", capid);
pcieadm_print("Unknown Capability (0x%x)\n", capid);
}
return;
}
/*
* Check to see if we should print this and in particular, if there's
* both a capability or subcapability, we need to try and match both.
* The reason that the calls to check the filters are conditioned on
* pcw_ofmt is that when we're in parsable mode, we cannot match a
* top-level capability since it's an arbitrary number of fields.
*/
if (walkp->pcw_ofmt == NULL) {
filter = pcieadm_cfgspace_filter(walkp, cap_info->ppc_short);
}
pcieadm_strfilt_push(walkp, cap_info->ppc_short);
if (subcap != NULL) {
if (walkp->pcw_ofmt == NULL) {
boolean_t subfilt = pcieadm_cfgspace_filter(walkp,
subcap->psub_short);
filter = subfilt || filter;
}
pcieadm_strfilt_push(walkp, subcap->psub_short);
}
if (walkp->pcw_ofmt == NULL && filter) {
if ((walkp->pcw_flags & PCIEADM_CFGSPACE_F_SHORT) != 0) {
if (subcap != NULL) {
pcieadm_print("%s Capability - %s (%s) "
"(0x%x)\n", cap_info->ppc_human,
subcap->psub_human,
walkp->pcw_filt->pstr_curgen, capid);
} else {
pcieadm_print("%s Capability (%s) (0x%x)\n",
cap_info->ppc_human,
walkp->pcw_filt->pstr_curgen, capid);
}
} else {
if (subcap != NULL) {
pcieadm_print("%s Capability - %s (0x%x)\n",
cap_info->ppc_human, subcap->psub_human,
capid);
} else {
pcieadm_print("%s Capability (0x%x)\n",
cap_info->ppc_human, capid);
}
}
}
if (vers_info != NULL) {
const pcieadm_cfgspace_print_t *print;
pcieadm_indent();
for (print = vers_info->ppr_print;
print->pcp_short != NULL; print++) {
VERIFY3P(print->pcp_print, !=, NULL);
print->pcp_print(walkp, print,
print->pcp_arg);
}
pcieadm_deindent();
} else {
if (subcap != NULL) {
warnx("Unable to print or list %s - %s (no support or "
"missing version info)", cap_info->ppc_human,
subcap->psub_human);
} else {
warnx("Unable to print or list %s (no support or "
"missing version info)", cap_info->ppc_human);
}
}
if (subcap != NULL) {
pcieadm_strfilt_pop(walkp);
}
pcieadm_strfilt_pop(walkp);
}
static void
pcieadm_cfgspace_write(int fd, const uint8_t *source, size_t len)
{
size_t off = 0;
while (len > 0) {
ssize_t ret = write(fd, source + off, len - off);
if (ret < 0) {
err(EXIT_FAILURE, "failed to write config space to "
"output file");
}
off += ret;
len -= ret;
}
}
void
pcieadm_cfgspace(pcieadm_t *pcip, pcieadm_cfgspace_op_t op,
pcieadm_cfgspace_f readf, int fd, void *readarg, uint_t nfilts,
pcieadm_cfgspace_filter_t *filters, pcieadm_cfgspace_flags_t flags,
ofmt_handle_t ofmt)
{
uint_t type;
uint16_t cap;
pcieadm_cfgspace_data_t data;
pcieadm_cfgspace_walk_t walk;
const char *headstr, *headshort;
const pcieadm_cfgspace_print_t *header;
boolean_t capsup = B_FALSE, extcfg = B_FALSE;
uint_t ncaps;
walk.pcw_pcieadm = pcip;
walk.pcw_op = op;
walk.pcw_data = &data;
walk.pcw_outfd = fd;
walk.pcw_capoff = 0;
walk.pcw_nlanes = 0;
walk.pcw_nfilters = nfilts;
walk.pcw_filters = filters;
walk.pcw_flags = flags;
walk.pcw_ofmt = ofmt;
walk.pcw_filt = NULL;
/*
* Start by reading all of the basic 40-byte config space header in one
* fell swoop.
*/
for (uint32_t i = 0; i < PCI_CAP_PTR_OFF / 4; i++) {
if (!readf(i * 4, 4, &data.pcb_u32[i], readarg)) {
errx(EXIT_FAILURE, "failed to read offset %u from "
"configuration space", i * 4);
}
}
walk.pcw_valid = PCI_CAP_PTR_OFF;
walk.pcw_caplen = PCI_CAP_PTR_OFF;
/*
* Grab the information from the header that we need to figure out what
* kind of device this is, how to print it, if there are any
* capabilities, and go from there.
*/
type = data.pcb_u8[PCI_CONF_HEADER] & PCI_HEADER_TYPE_M;
switch (type) {
case PCI_HEADER_ZERO:
headstr = "Type 0 Header";
headshort = "header0";
header = pcieadm_cfgspace_type0;
capsup = (data.pcb_u8[PCI_CONF_STAT] & PCI_STAT_CAP) != 0;
break;
case PCI_HEADER_ONE:
headstr = "Type 1 Header";
headshort = "header1";
header = pcieadm_cfgspace_type1;
capsup = (data.pcb_u8[PCI_CONF_STAT] & PCI_STAT_CAP) != 0;
break;
case PCI_HEADER_TWO:
default:
headstr = "Unknown Header";
headshort = "headerX";
header = pcieadm_cfgspace_unknown;
warnx("unsupported PCI header type: 0x%x, output limited to "
"data configuration space");
}
walk.pcw_dtype = type;
if (op == PCIEADM_CFGSPACE_OP_WRITE) {
pcieadm_cfgspace_write(fd, &data.pcb_u8[0], PCI_CAP_PTR_OFF);
} else if (op == PCIEADM_CFGSPACE_OP_PRINT) {
const pcieadm_cfgspace_print_t *print;
if (walk.pcw_ofmt == NULL &&
pcieadm_cfgspace_filter(&walk, headshort)) {
if ((flags & PCIEADM_CFGSPACE_F_SHORT) != 0) {
pcieadm_print("Device %s -- %s (%s)\n",
pcip->pia_devstr, headstr, headshort);
} else {
pcieadm_print("Device %s -- %s\n",
pcip->pia_devstr, headstr);
}
}
pcieadm_strfilt_push(&walk, headshort);
pcieadm_indent();
for (print = header; print->pcp_short != NULL; print++) {
print->pcp_print(&walk, print, print->pcp_arg);
}
pcieadm_deindent();
pcieadm_strfilt_pop(&walk);
}
if (!capsup) {
return;
}
for (uint32_t i = PCI_CAP_PTR_OFF / 4; i < PCI_CONF_HDR_SIZE / 4; i++) {
if (!readf(i * 4, 4, &data.pcb_u32[i], readarg)) {
errx(EXIT_FAILURE, "failed to read offset %u from "
"configuration space", i * 4);
}
}
walk.pcw_valid = PCIE_EXT_CAP;
VERIFY3P(walk.pcw_filt, ==, NULL);
if (op == PCIEADM_CFGSPACE_OP_WRITE) {
pcieadm_cfgspace_write(fd, &data.pcb_u8[PCI_CAP_PTR_OFF],
PCI_CONF_HDR_SIZE - PCI_CAP_PTR_OFF);
}
ncaps = 0;
cap = data.pcb_u8[PCI_CONF_CAP_PTR];
while (cap != 0 && cap != PCI_EINVAL8) {
const pcieadm_pci_cap_t *cap_info;
const pcieadm_cap_vers_t *vers_info = NULL;
const pcieadm_subcap_t *subcap = NULL;
uint8_t cap_id, nextcap;
uint32_t read_len = 0;
/*
* The PCI specification requires that the caller mask off the
* bottom two bits. Always check for an invalid value (all 1s)
* before this.
*/
cap &= PCI_CAP_PTR_MASK;
cap_id = data.pcb_u8[cap + PCI_CAP_ID];
nextcap = data.pcb_u8[cap + PCI_CAP_NEXT_PTR];
cap_info = pcieadm_cfgspace_match_cap(cap_id, B_FALSE);
if (cap_info != NULL && cap_info->ppc_info != NULL) {
cap_info->ppc_info(&walk, cap_info, cap, &vers_info,
&read_len, &subcap);
}
walk.pcw_caplen = read_len;
walk.pcw_capoff = cap;
if (cap_id == PCI_CAP_ID_PCI_E) {
extcfg = B_TRUE;
if (walk.pcw_valid != 0) {
walk.pcw_pcietype = data.pcb_u8[cap +
PCIE_PCIECAP] & PCIE_PCIECAP_DEV_TYPE_MASK;
walk.pcw_nlanes = (data.pcb_u8[cap +
PCIE_LINKCAP] & 0xf0) >> 4;
walk.pcw_nlanes |= (data.pcb_u8[cap +
PCIE_LINKCAP + 1] & 0x01) << 4;
} else {
walk.pcw_pcietype = UINT_MAX;
}
}
if (op == PCIEADM_CFGSPACE_OP_PRINT) {
pcieadm_cfgspace_print_cap(&walk, cap_id, cap_info,
vers_info, subcap);
}
cap = nextcap;
ncaps++;
if (ncaps >= PCI_CAP_MAX_PTR) {
errx(EXIT_FAILURE, "encountered more PCI capabilities "
"than fit in configuration space");
}
}
if (!extcfg) {
return;
}
for (uint_t i = PCIE_EXT_CAP / 4; i < PCIE_CONF_HDR_SIZE / 4; i++) {
if (!readf(i * 4, 4, &data.pcb_u32[i], readarg)) {
errx(EXIT_FAILURE, "failed to read offset %u from "
"configuration space", i * 4);
}
}
walk.pcw_valid = PCIE_CONF_HDR_SIZE;
if (op == PCIEADM_CFGSPACE_OP_WRITE) {
pcieadm_cfgspace_write(fd, &data.pcb_u8[PCIE_EXT_CAP],
PCIE_CONF_HDR_SIZE - PCIE_EXT_CAP);
return;
}
cap = PCIE_EXT_CAP;
ncaps = 0;
while (cap != 0 && cap != PCI_EINVAL16) {
uint16_t cap_id, nextcap;
const pcieadm_pci_cap_t *cap_info;
const pcieadm_cap_vers_t *vers_info = NULL;
const pcieadm_subcap_t *subcap = NULL;
uint32_t read_len = 0;
/*
* PCIe has the same masking as PCI. Note, sys/pcie.h currently
* has PCIE_EXT_CAP_NEXT_PTR_MASK as 0xfff, instead of the
* below. This should be switched to PCIE_EXT_CAP_NEXT_PTR_MASK
* when the kernel headers are fixed.
*/
cap &= 0xffc;
/*
* While this seems duplicative of the loop condition, a device
* without capabilities indicates it with a zero for the first
* cap.
*/
if (data.pcb_u32[cap / 4] == 0 ||
data.pcb_u32[cap / 4] == PCI_EINVAL32)
break;
cap_id = data.pcb_u32[cap / 4] & PCIE_EXT_CAP_ID_MASK;
nextcap = (data.pcb_u32[cap / 4] >>
PCIE_EXT_CAP_NEXT_PTR_SHIFT) & PCIE_EXT_CAP_NEXT_PTR_MASK;
cap_info = pcieadm_cfgspace_match_cap(cap_id, B_TRUE);
if (cap_info != NULL && cap_info->ppc_info != NULL) {
cap_info->ppc_info(&walk, cap_info, cap, &vers_info,
&read_len, &subcap);
}
walk.pcw_caplen = read_len;
walk.pcw_capoff = cap;
if (op == PCIEADM_CFGSPACE_OP_PRINT) {
pcieadm_cfgspace_print_cap(&walk, cap_id, cap_info,
vers_info, subcap);
}
cap = nextcap;
ncaps++;
if (ncaps >= PCIE_EXT_CAP_MAX_PTR) {
errx(EXIT_FAILURE, "encountered more PCI capabilities "
"than fit in configuration space");
}
}
}
void
pcieadm_show_cfgspace_usage(FILE *f)
{
(void) fprintf(f, "\tshow-cfgspace\t[-L] [-n] [-H] -d device | -f file "
"[filter...]\n");
(void) fprintf(f, "\tshow-cfgspace\t-p -o field[,...] [-H] -d device | "
"-f file [filter...]\n");
}
static void
pcieadm_show_cfgspace_help(const char *fmt, ...)
{
if (fmt != NULL) {
va_list ap;
va_start(ap, fmt);
vwarnx(fmt, ap);
va_end(ap);
(void) fprintf(stderr, "\n");
}
(void) fprintf(stderr, "Usage: %s show-cfgspace [-L] [-n] [-H] -d "
"device | -f file [filter...]\n", pcieadm_progname);
(void) fprintf(stderr, " %s show-cfgspace -p -o field[,...] "
"[-H] -d device | -f file\n\t\t\t [filter...]\n",
pcieadm_progname);
(void) fprintf(stderr, "\nPrint and decode PCI configuration space "
"data from a device or file. Each\n<filter> selects a given "
"capability, sub-capability, register, or field to print.\n\n"
"\t-d device\tread data from the specified device (driver instance,"
"\n\t\t\t/devices path, or b/d/f)\n"
"\t-f file\t\tread data from the specified file\n"
"\t-L\t\tlist printable fields\n"
"\t-n\t\tshow printable short names\n"
"\t-H\t\tomit the column header (for -L and -p)\n"
"\t-p\t\tparsable output (requires -o)\n"
"\t-o field\toutput fields to print (required for -p)\n\n"
"The following fields are supported:\n"
"\thuman\t\ta human-readable description of the specific output\n"
"\tshort\t\tthe short name of the value used for filters\n"
"\tvalue\t\tthe value of a the given capability, register, etc.\n");
}
int
pcieadm_show_cfgspace(pcieadm_t *pcip, int argc, char *argv[])
{
int c, ret;
pcieadm_cfgspace_f readf;
void *readarg;
boolean_t list = B_FALSE, parse = B_FALSE;
const char *device = NULL, *file = NULL, *fields = NULL;
uint_t nfilts = 0;
pcieadm_cfgspace_filter_t *filts = NULL;
pcieadm_cfgspace_flags_t flags = 0;
uint_t oflags = 0;
ofmt_handle_t ofmt = NULL;
while ((c = getopt(argc, argv, ":HLd:f:o:np")) != -1) {
switch (c) {
case 'd':
device = optarg;
break;
case 'L':
list = B_TRUE;
break;
case 'f':
file = optarg;
break;
case 'p':
parse = B_TRUE;
flags |= PCIEADM_CFGSPACE_F_PARSE;
oflags |= OFMT_PARSABLE;
break;
case 'n':
flags |= PCIEADM_CFGSPACE_F_SHORT;
break;
case 'H':
oflags |= OFMT_NOHEADER;
break;
case 'o':
fields = optarg;
break;
case ':':
pcieadm_show_cfgspace_help("Option -%c requires an "
"argument", optopt);
exit(EXIT_USAGE);
case '?':
default:
pcieadm_show_cfgspace_help("unknown option: -%c",
optopt);
exit(EXIT_USAGE);
}
}
argc -= optind;
argv += optind;
if (device == NULL && file == NULL) {
pcieadm_show_cfgspace_help("one of -d or -f must be specified");
exit(EXIT_USAGE);
}
if (device != NULL && file != NULL) {
pcieadm_show_cfgspace_help("only one of -d and -f must be "
"specified");
exit(EXIT_USAGE);
}
if (parse && fields == NULL) {
pcieadm_show_cfgspace_help("-p requires fields specified with "
"-o");
exit(EXIT_USAGE);
}
if (!parse && fields != NULL) {
pcieadm_show_cfgspace_help("-o can only be used with -p");
exit(EXIT_USAGE);
}
if ((oflags & OFMT_NOHEADER) && !(list || parse)) {
pcieadm_show_cfgspace_help("-H must be used with either -L or "
"-p");
exit(EXIT_USAGE);
}
if ((flags & PCIEADM_CFGSPACE_F_SHORT) && (list || parse)) {
pcieadm_show_cfgspace_help("-n cannot be used with either -L "
"or -p");
exit(EXIT_USAGE);
}
if (list && parse != 0) {
pcieadm_show_cfgspace_help("-L and -p cannot be used together");
exit(EXIT_USAGE);
}
if (list && fields != NULL) {
pcieadm_show_cfgspace_help("-L and -o cannot be used together");
exit(EXIT_USAGE);
}
if (list) {
fields = "short,human";
}
if (argc > 0) {
nfilts = argc;
filts = calloc(nfilts, sizeof (pcieadm_cfgspace_filter_t));
for (int i = 0; i < argc; i++) {
filts[i].pcf_string = argv[i];
filts[i].pcf_len = strlen(argv[i]);
}
}
if (list || parse) {
ofmt_status_t oferr;
oferr = ofmt_open(fields, pcieadm_cfgspace_ofmt, oflags, 0,
&ofmt);
ofmt_check(oferr, parse, ofmt, pcieadm_ofmt_errx, warnx);
}
/*
* Initialize privileges that we require. For reading from the kernel
* we require all privileges. For a file, we just intersect with things
* that would allow someone to read from any file.
*/
if (device != NULL) {
/*
* We need full privileges if reading from a device,
* unfortunately.
*/
priv_fillset(pcip->pia_priv_eff);
} else {
VERIFY0(priv_addset(pcip->pia_priv_eff, PRIV_FILE_DAC_READ));
VERIFY0(priv_addset(pcip->pia_priv_eff, PRIV_FILE_DAC_SEARCH));
}
pcieadm_init_privs(pcip);
if (device != NULL) {
pcieadm_find_dip(pcip, device);
pcieadm_init_cfgspace_kernel(pcip, &readf, &readarg);
} else {
pcip->pia_devstr = file;
pcieadm_init_cfgspace_file(pcip, file, &readf, &readarg);
}
pcieadm_cfgspace(pcip, PCIEADM_CFGSPACE_OP_PRINT, readf, -1, readarg,
nfilts, filts, flags, ofmt);
if (device != NULL) {
pcieadm_fini_cfgspace_kernel(readarg);
} else {
pcieadm_fini_cfgspace_file(readarg);
}
ofmt_close(ofmt);
ret = EXIT_SUCCESS;
for (uint_t i = 0; i < nfilts; i++) {
if (!filts[i].pcf_used) {
warnx("filter '%s' did not match any fields",
filts[i].pcf_string);
ret = EXIT_FAILURE;
}
}
return (ret);
}
typedef struct pcieadm_save_cfgspace {
pcieadm_t *psc_pci;
int psc_dirfd;
uint_t psc_nsaved;
int psc_ret;
} pcieadm_save_cfgspace_t;
static int
pcieadm_save_cfgspace_cb(di_node_t devi, void *arg)
{
int fd, nregs, *regs;
pcieadm_save_cfgspace_t *psc = arg;
pcieadm_cfgspace_f readf;
void *readarg;
char fname[128];
psc->psc_pci->pia_devstr = di_node_name(devi);
psc->psc_pci->pia_devi = devi;
psc->psc_pci->pia_nexus = DI_NODE_NIL;
pcieadm_find_nexus(psc->psc_pci);
if (psc->psc_pci->pia_nexus == DI_NODE_NIL) {
warnx("failed to find nexus for %s", di_node_name(devi));
psc->psc_ret = EXIT_FAILURE;
return (DI_WALK_CONTINUE);
}
nregs = di_prop_lookup_ints(DDI_DEV_T_ANY, devi, "reg", ®s);
if (nregs <= 0) {
warnx("failed to lookup regs array for %s",
psc->psc_pci->pia_devstr);
psc->psc_ret = EXIT_FAILURE;
return (DI_WALK_CONTINUE);
}
(void) snprintf(fname, sizeof (fname), "%02x-%02x-%02x.pci",
PCI_REG_BUS_G(regs[0]), PCI_REG_DEV_G(regs[0]),
PCI_REG_FUNC_G(regs[0]));
if (setppriv(PRIV_SET, PRIV_EFFECTIVE, psc->psc_pci->pia_priv_eff) !=
0) {
err(EXIT_FAILURE, "failed to raise privileges");
}
fd = openat(psc->psc_dirfd, fname, O_WRONLY | O_TRUNC | O_CREAT, 0666);
if (setppriv(PRIV_SET, PRIV_EFFECTIVE, psc->psc_pci->pia_priv_min) !=
0) {
err(EXIT_FAILURE, "failed to reduce privileges");
}
if (fd < 0) {
warn("failed to create output file %s", fname);
psc->psc_ret = EXIT_FAILURE;
return (DI_WALK_CONTINUE);
}
pcieadm_init_cfgspace_kernel(psc->psc_pci, &readf, &readarg);
pcieadm_cfgspace(psc->psc_pci, PCIEADM_CFGSPACE_OP_WRITE, readf, fd,
readarg, 0, NULL, 0, NULL);
pcieadm_fini_cfgspace_kernel(readarg);
if (close(fd) != 0) {
warn("failed to close output fd for %s", fname);
psc->psc_ret = EXIT_FAILURE;
} else {
psc->psc_nsaved++;
}
return (DI_WALK_CONTINUE);
}
void
pcieadm_save_cfgspace_usage(FILE *f)
{
(void) fprintf(f, "\tsave-cfgspace\t-d device output-file\n");
(void) fprintf(f, "\tsave-cfgspace\t-a output-directory\n");
}
static void
pcieadm_save_cfgspace_help(const char *fmt, ...)
{
if (fmt != NULL) {
va_list ap;
va_start(ap, fmt);
vwarnx(fmt, ap);
va_end(ap);
(void) fprintf(stderr, "\n");
}
(void) fprintf(stderr, "Usage: %s save-cfgspace -d device "
"output-file\n", pcieadm_progname);
(void) fprintf(stderr, " %s save-cfgspace -a "
"output-directory\n", pcieadm_progname);
(void) fprintf(stderr, "\nSave PCI configuration space data from a "
"device to a file or\nsave all devices to a specified directory."
"\n\n"
"\t-a\t\tsave data from all devices\n"
"\t-d device\tread data from the specified device (driver instance,"
"\n\t\t\t/devices path, or b/d/f)\n");
}
int
pcieadm_save_cfgspace(pcieadm_t *pcip, int argc, char *argv[])
{
int c;
pcieadm_cfgspace_f readf;
void *readarg;
const char *device = NULL;
boolean_t do_all = B_FALSE;
while ((c = getopt(argc, argv, ":ad:")) != -1) {
switch (c) {
case 'a':
do_all = B_TRUE;
break;
case 'd':
device = optarg;
break;
case ':':
pcieadm_save_cfgspace_help("Option -%c requires an "
"argument", optopt);
exit(EXIT_USAGE);
case '?':
default:
pcieadm_save_cfgspace_help("unknown option: -%c",
optopt);
exit(EXIT_USAGE);
}
}
argc -= optind;
argv += optind;
if (device == NULL && !do_all) {
pcieadm_save_cfgspace_help("missing required -d option to "
"indicate device to dump");
exit(EXIT_USAGE);
}
if (argc != 1) {
pcieadm_save_cfgspace_help("missing required output path");
exit(EXIT_USAGE);
}
/*
* For reading from devices, we need to full privileges, unfortunately.
*/
priv_fillset(pcip->pia_priv_eff);
pcieadm_init_privs(pcip);
if (!do_all) {
int fd;
pcieadm_find_dip(pcip, device);
if (setppriv(PRIV_SET, PRIV_EFFECTIVE, pcip->pia_priv_eff) !=
0) {
err(EXIT_FAILURE, "failed to raise privileges");
}
if ((fd = open(argv[0], O_WRONLY | O_CREAT | O_TRUNC, 0666)) <
0) {
err(EXIT_FAILURE, "failed to open output file %s",
argv[0]);
}
if (setppriv(PRIV_SET, PRIV_EFFECTIVE, pcip->pia_priv_min) !=
0) {
err(EXIT_FAILURE, "failed to reduce privileges");
}
pcieadm_init_cfgspace_kernel(pcip, &readf, &readarg);
pcieadm_cfgspace(pcip, PCIEADM_CFGSPACE_OP_WRITE, readf, fd,
readarg, 0, NULL, 0, NULL);
pcieadm_fini_cfgspace_kernel(readarg);
if (close(fd) != 0) {
err(EXIT_FAILURE, "failed to close output file "
"descriptor");
}
return (EXIT_SUCCESS);
} else {
pcieadm_save_cfgspace_t psc;
pcieadm_di_walk_t walk;
if (setppriv(PRIV_SET, PRIV_EFFECTIVE, pcip->pia_priv_eff) !=
0) {
err(EXIT_FAILURE, "failed to raise privileges");
}
if ((psc.psc_dirfd = open(argv[0], O_RDONLY | O_DIRECTORY)) <
0) {
err(EXIT_FAILURE, "failed to open output directory %s",
argv[0]);
}
if (setppriv(PRIV_SET, PRIV_EFFECTIVE, pcip->pia_priv_min) !=
0) {
err(EXIT_FAILURE, "failed to reduce privileges");
}
psc.psc_nsaved = 0;
psc.psc_ret = EXIT_SUCCESS;
psc.psc_pci = pcip;
walk.pdw_arg = &psc;
walk.pdw_func = pcieadm_save_cfgspace_cb;
pcieadm_di_walk(pcip, &walk);
VERIFY0(close(psc.psc_dirfd));
if (psc.psc_nsaved == 0) {
warnx("failed to save any PCI devices");
return (EXIT_FAILURE);
}
pcieadm_print("successfully saved %u devices to %s\n",
psc.psc_nsaved, argv[0]);
return (psc.psc_ret);
}
}
|