]> git.ipfire.org Git - thirdparty/pciutils.git/blob - ls-ecaps.c
Display some PCIe extended capabilities only when verbose level >= 2
[thirdparty/pciutils.git] / ls-ecaps.c
1 /*
2 * The PCI Utilities -- Show Extended Capabilities
3 *
4 * Copyright (c) 1997--2008 Martin Mares <mj@ucw.cz>
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9 #include <stdio.h>
10 #include <string.h>
11
12 #include "lspci.h"
13
14 static void
15 cap_dsn(struct device *d, int where)
16 {
17 u32 t1, t2;
18 if (!config_fetch(d, where + 4, 8))
19 return;
20 t1 = get_conf_long(d, where + 4);
21 t2 = get_conf_long(d, where + 8);
22 printf("Device Serial Number %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n",
23 t1 & 0xff, (t1 >> 8) & 0xff, (t1 >> 16) & 0xff, t1 >> 24,
24 t2 & 0xff, (t2 >> 8) & 0xff, (t2 >> 16) & 0xff, t2 >> 24);
25 }
26
27 static void
28 cap_aer(struct device *d, int where)
29 {
30 u32 l;
31
32 printf("Advanced Error Reporting\n");
33 if (verbose < 2)
34 return;
35
36 if (!config_fetch(d, where + PCI_ERR_UNCOR_STATUS, 24))
37 return;
38
39 l = get_conf_long(d, where + PCI_ERR_UNCOR_STATUS);
40 printf("\t\tUESta:\tDLP%c SDES%c TLP%c FCP%c CmpltTO%c CmpltAbrt%c UnxCmplt%c RxOF%c "
41 "MalfTLP%c ECRC%c UnsupReq%c ACSViol%c\n",
42 FLAG(l, PCI_ERR_UNC_DLP), FLAG(l, PCI_ERR_UNC_SDES), FLAG(l, PCI_ERR_UNC_POISON_TLP),
43 FLAG(l, PCI_ERR_UNC_FCP), FLAG(l, PCI_ERR_UNC_COMP_TIME), FLAG(l, PCI_ERR_UNC_COMP_ABORT),
44 FLAG(l, PCI_ERR_UNC_UNX_COMP), FLAG(l, PCI_ERR_UNC_RX_OVER), FLAG(l, PCI_ERR_UNC_MALF_TLP),
45 FLAG(l, PCI_ERR_UNC_ECRC), FLAG(l, PCI_ERR_UNC_UNSUP), FLAG(l, PCI_ERR_UNC_ACS_VIOL));
46 l = get_conf_long(d, where + PCI_ERR_UNCOR_MASK);
47 printf("\t\tUEMsk:\tDLP%c SDES%c TLP%c FCP%c CmpltTO%c CmpltAbrt%c UnxCmplt%c RxOF%c "
48 "MalfTLP%c ECRC%c UnsupReq%c ACSViol%c\n",
49 FLAG(l, PCI_ERR_UNC_DLP), FLAG(l, PCI_ERR_UNC_SDES), FLAG(l, PCI_ERR_UNC_POISON_TLP),
50 FLAG(l, PCI_ERR_UNC_FCP), FLAG(l, PCI_ERR_UNC_COMP_TIME), FLAG(l, PCI_ERR_UNC_COMP_ABORT),
51 FLAG(l, PCI_ERR_UNC_UNX_COMP), FLAG(l, PCI_ERR_UNC_RX_OVER), FLAG(l, PCI_ERR_UNC_MALF_TLP),
52 FLAG(l, PCI_ERR_UNC_ECRC), FLAG(l, PCI_ERR_UNC_UNSUP), FLAG(l, PCI_ERR_UNC_ACS_VIOL));
53 l = get_conf_long(d, where + PCI_ERR_UNCOR_SEVER);
54 printf("\t\tUESvrt:\tDLP%c SDES%c TLP%c FCP%c CmpltTO%c CmpltAbrt%c UnxCmplt%c RxOF%c "
55 "MalfTLP%c ECRC%c UnsupReq%c ACSViol%c\n",
56 FLAG(l, PCI_ERR_UNC_DLP), FLAG(l, PCI_ERR_UNC_SDES), FLAG(l, PCI_ERR_UNC_POISON_TLP),
57 FLAG(l, PCI_ERR_UNC_FCP), FLAG(l, PCI_ERR_UNC_COMP_TIME), FLAG(l, PCI_ERR_UNC_COMP_ABORT),
58 FLAG(l, PCI_ERR_UNC_UNX_COMP), FLAG(l, PCI_ERR_UNC_RX_OVER), FLAG(l, PCI_ERR_UNC_MALF_TLP),
59 FLAG(l, PCI_ERR_UNC_ECRC), FLAG(l, PCI_ERR_UNC_UNSUP), FLAG(l, PCI_ERR_UNC_ACS_VIOL));
60 l = get_conf_long(d, where + PCI_ERR_COR_STATUS);
61 printf("\t\tCESta:\tRxErr%c BadTLP%c BadDLLP%c Rollover%c Timeout%c NonFatalErr%c\n",
62 FLAG(l, PCI_ERR_COR_RCVR), FLAG(l, PCI_ERR_COR_BAD_TLP), FLAG(l, PCI_ERR_COR_BAD_DLLP),
63 FLAG(l, PCI_ERR_COR_REP_ROLL), FLAG(l, PCI_ERR_COR_REP_TIMER), FLAG(l, PCI_ERR_COR_REP_ANFE));
64 l = get_conf_long(d, where + PCI_ERR_COR_MASK);
65 printf("\t\tCEMsk:\tRxErr%c BadTLP%c BadDLLP%c Rollover%c Timeout%c NonFatalErr%c\n",
66 FLAG(l, PCI_ERR_COR_RCVR), FLAG(l, PCI_ERR_COR_BAD_TLP), FLAG(l, PCI_ERR_COR_BAD_DLLP),
67 FLAG(l, PCI_ERR_COR_REP_ROLL), FLAG(l, PCI_ERR_COR_REP_TIMER), FLAG(l, PCI_ERR_COR_REP_ANFE));
68 l = get_conf_long(d, where + PCI_ERR_CAP);
69 printf("\t\tAERCap:\tFirst Error Pointer: %02x, GenCap%c CGenEn%c ChkCap%c ChkEn%c\n",
70 PCI_ERR_CAP_FEP(l), FLAG(l, PCI_ERR_CAP_ECRC_GENC), FLAG(l, PCI_ERR_CAP_ECRC_GENE),
71 FLAG(l, PCI_ERR_CAP_ECRC_CHKC), FLAG(l, PCI_ERR_CAP_ECRC_CHKE));
72
73 }
74
75 static void
76 cap_acs(struct device *d, int where)
77 {
78 u16 w;
79
80 printf("Access Control Services\n");
81 if (verbose < 2)
82 return;
83
84 if (!config_fetch(d, where + PCI_ACS_CAP, 4))
85 return;
86
87 w = get_conf_word(d, where + PCI_ACS_CAP);
88 printf("\t\tACSCap:\tSrcValid%c TransBlk%c ReqRedir%c CmpltRedir%c UpstreamFwd%c EgressCtrl%c "
89 "DirectTrans%c\n",
90 FLAG(w, PCI_ACS_CAP_VALID), FLAG(w, PCI_ACS_CAP_BLOCK), FLAG(w, PCI_ACS_CAP_REQ_RED),
91 FLAG(w, PCI_ACS_CAP_CMPLT_RED), FLAG(w, PCI_ACS_CAP_FORWARD), FLAG(w, PCI_ACS_CAP_EGRESS),
92 FLAG(w, PCI_ACS_CAP_TRANS));
93 w = get_conf_word(d, where + PCI_ACS_CTRL);
94 printf("\t\tACSCtl:\tSrcValid%c TransBlk%c ReqRedir%c CmpltRedir%c UpstreamFwd%c EgressCtrl%c "
95 "DirectTrans%c\n",
96 FLAG(w, PCI_ACS_CTRL_VALID), FLAG(w, PCI_ACS_CTRL_BLOCK), FLAG(w, PCI_ACS_CTRL_REQ_RED),
97 FLAG(w, PCI_ACS_CTRL_CMPLT_RED), FLAG(w, PCI_ACS_CTRL_FORWARD), FLAG(w, PCI_ACS_CTRL_EGRESS),
98 FLAG(w, PCI_ACS_CTRL_TRANS));
99 }
100
101 static void
102 cap_ari(struct device *d, int where)
103 {
104 u16 w;
105
106 printf("Alternative Routing-ID Interpretation (ARI)\n");
107 if (verbose < 2)
108 return;
109
110 if (!config_fetch(d, where + PCI_ARI_CAP, 4))
111 return;
112
113 w = get_conf_word(d, where + PCI_ARI_CAP);
114 printf("\t\tARICap:\tMFVC%c ACS%c, Next Function: %d\n",
115 FLAG(w, PCI_ARI_CAP_MFVC), FLAG(w, PCI_ARI_CAP_ACS),
116 PCI_ARI_CAP_NFN(w));
117 w = get_conf_word(d, where + PCI_ARI_CTRL);
118 printf("\t\tARICtl:\tMFVC%c ACS%c, Function Group: %d\n",
119 FLAG(w, PCI_ARI_CTRL_MFVC), FLAG(w, PCI_ARI_CTRL_ACS),
120 PCI_ARI_CTRL_FG(w));
121 }
122
123 static void
124 cap_ats(struct device *d, int where)
125 {
126 u16 w;
127
128 printf("Address Translation Service (ATS)\n");
129 if (verbose < 2)
130 return;
131
132 if (!config_fetch(d, where + PCI_ATS_CAP, 4))
133 return;
134
135 w = get_conf_word(d, where + PCI_ATS_CAP);
136 printf("\t\tATSCap:\tInvalidate Queue Depth: %02x\n", PCI_ATS_CAP_IQD(w));
137 w = get_conf_word(d, where + PCI_ATS_CTRL);
138 printf("\t\tATSCtl:\tEnable%c, Smallest Translation Unit: %02x\n",
139 FLAG(w, PCI_ATS_CTRL_ENABLE), PCI_ATS_CTRL_STU(w));
140 }
141
142 static void
143 cap_sriov(struct device *d, int where)
144 {
145 u16 b;
146 u16 w;
147 u32 l;
148
149 printf("Single Root I/O Virtualization (SR-IOV)\n");
150 if (verbose < 2)
151 return;
152
153 if (!config_fetch(d, where + PCI_IOV_CAP, 0x3c))
154 return;
155
156 l = get_conf_long(d, where + PCI_IOV_CAP);
157 printf("\t\tIOVCap:\tMigration%c, Interrupt Message Number: %03x\n",
158 FLAG(l, PCI_IOV_CAP_VFM), PCI_IOV_CAP_IMN(l));
159 w = get_conf_word(d, where + PCI_IOV_CTRL);
160 printf("\t\tIOVCtl:\tEnable%c Migration%c Interrupt%c MSE%c ARIHierarchy%c\n",
161 FLAG(w, PCI_IOV_CTRL_VFE), FLAG(w, PCI_IOV_CTRL_VFME),
162 FLAG(w, PCI_IOV_CTRL_VFMIE), FLAG(w, PCI_IOV_CTRL_MSE),
163 FLAG(w, PCI_IOV_CTRL_ARI));
164 w = get_conf_word(d, where + PCI_IOV_STATUS);
165 printf("\t\tIOVSta:\tMigration%c\n", FLAG(w, PCI_IOV_STATUS_MS));
166 w = get_conf_word(d, where + PCI_IOV_INITIALVF);
167 printf("\t\tInitial VFs: %d, ", w);
168 w = get_conf_word(d, where + PCI_IOV_TOTALVF);
169 printf("Total VFs: %d, ", w);
170 w = get_conf_word(d, where + PCI_IOV_NUMVF);
171 printf("Number of VFs: %d, ", w);
172 b = get_conf_byte(d, where + PCI_IOV_FDL);
173 printf("Function Dependency Link: %02x\n", b);
174 w = get_conf_word(d, where + PCI_IOV_OFFSET);
175 printf("\t\tVF offset: %d, ", w);
176 w = get_conf_word(d, where + PCI_IOV_STRIDE);
177 printf("stride: %d, ", w);
178 w = get_conf_word(d, where + PCI_IOV_DID);
179 printf("Device ID: %04x\n", w);
180 l = get_conf_long(d, where + PCI_IOV_SUPPS);
181 printf("\t\tSupported Page Size: %08x, ", l);
182 l = get_conf_long(d, where + PCI_IOV_SYSPS);
183 printf("System Page Size: %08x\n", l);
184 l = get_conf_long(d, where + PCI_IOV_MSAO);
185 printf("\t\tVF Migration: offset: %08x, BIR: %x\n", PCI_IOV_MSA_OFFSET(l),
186 PCI_IOV_MSA_BIR(l));
187 }
188
189 void
190 show_ext_caps(struct device *d)
191 {
192 int where = 0x100;
193 char been_there[0x1000];
194 memset(been_there, 0, 0x1000);
195 do
196 {
197 u32 header;
198 int id;
199
200 if (!config_fetch(d, where, 4))
201 break;
202 header = get_conf_long(d, where);
203 if (!header)
204 break;
205 id = header & 0xffff;
206 printf("\tCapabilities: [%03x] ", where);
207 if (been_there[where]++)
208 {
209 printf("<chain looped>\n");
210 break;
211 }
212 switch (id)
213 {
214 case PCI_EXT_CAP_ID_AER:
215 cap_aer(d, where);
216 break;
217 case PCI_EXT_CAP_ID_VC:
218 printf("Virtual Channel <?>\n");
219 break;
220 case PCI_EXT_CAP_ID_DSN:
221 cap_dsn(d, where);
222 break;
223 case PCI_EXT_CAP_ID_PB:
224 printf("Power Budgeting <?>\n");
225 break;
226 case PCI_EXT_CAP_ID_RCLINK:
227 printf("Root Complex Link <?>\n");
228 break;
229 case PCI_EXT_CAP_ID_RCILINK:
230 printf("Root Complex Internal Link <?>\n");
231 break;
232 case PCI_EXT_CAP_ID_RCECOLL:
233 printf("Root Complex Event Collector <?>\n");
234 break;
235 case PCI_EXT_CAP_ID_MFVC:
236 printf("Multi-Function Virtual Channel <?>\n");
237 break;
238 case PCI_EXT_CAP_ID_RBCB:
239 printf("Root Bridge Control Block <?>\n");
240 break;
241 case PCI_EXT_CAP_ID_VNDR:
242 printf("Vendor Specific Information <?>\n");
243 break;
244 case PCI_EXT_CAP_ID_ACS:
245 cap_acs(d, where);
246 break;
247 case PCI_EXT_CAP_ID_ARI:
248 cap_ari(d, where);
249 break;
250 case PCI_EXT_CAP_ID_ATS:
251 cap_ats(d, where);
252 break;
253 case PCI_EXT_CAP_ID_SRIOV:
254 cap_sriov(d, where);
255 break;
256 default:
257 printf("#%02x\n", id);
258 break;
259 }
260 where = header >> 20;
261 } while (where);
262 }