]>
Commit | Line | Data |
---|---|---|
fb2627ce OO |
1 | #ifndef LSCPU_H |
2 | #define LSCPU_H | |
3 | ||
71061694 KZ |
4 | #include "c.h" |
5 | #include "nls.h" | |
6 | #include "cpuset.h" | |
7 | #include "xalloc.h" | |
8 | #include "strutils.h" | |
9 | #include "bitops.h" | |
10 | #include "path.h" | |
11 | #include "pathnames.h" | |
12 | #include "all-io.h" | |
13 | ||
14 | /* virtualization types */ | |
15 | enum { | |
16 | VIRT_NONE = 0, | |
17 | VIRT_PARA, | |
18 | VIRT_FULL, | |
19 | VIRT_CONT | |
20 | }; | |
21 | ||
fb2627ce OO |
22 | /* hypervisor vendors */ |
23 | enum { | |
24 | HYPER_NONE = 0, | |
25 | HYPER_XEN, | |
26 | HYPER_KVM, | |
27 | HYPER_MSHV, | |
28 | HYPER_VMWARE, | |
29 | HYPER_IBM, /* sys-z powervm */ | |
30 | HYPER_VSERVER, | |
31 | HYPER_UML, | |
32 | HYPER_INNOTEK, /* VBOX */ | |
33 | HYPER_HITACHI, | |
96ce475f RM |
34 | HYPER_PARALLELS, /* OpenVZ/VIrtuozzo */ |
35 | HYPER_VBOX, | |
5bd31c6d RM |
36 | HYPER_OS400, |
37 | HYPER_PHYP, | |
4597b692 | 38 | HYPER_SPAR, |
7572fb2b | 39 | HYPER_WSL, |
fb2627ce OO |
40 | }; |
41 | ||
71061694 KZ |
42 | /* CPU modes */ |
43 | enum { | |
44 | MODE_32BIT = (1 << 1), | |
45 | MODE_64BIT = (1 << 2) | |
46 | }; | |
47 | ||
48 | /* cache(s) description */ | |
49 | struct cpu_cache { | |
50 | char *name; | |
0e86bc84 | 51 | char *type; |
cf3b6b71 KZ |
52 | char *allocation_policy; |
53 | char *write_policy; | |
54 | ||
0e86bc84 | 55 | int level; |
0e86bc84 | 56 | uint64_t size; |
71061694 | 57 | |
cf3b6b71 KZ |
58 | unsigned int ways_of_associativity; |
59 | unsigned int physical_line_partition; | |
60 | unsigned int number_of_sets; | |
61 | unsigned int coherency_line_size; | |
62 | ||
71061694 KZ |
63 | int nsharedmaps; |
64 | cpu_set_t **sharedmaps; | |
65 | }; | |
66 | ||
67 | /* dispatching modes */ | |
68 | enum { | |
69 | DISP_HORIZONTAL = 0, | |
70 | DISP_VERTICAL = 1 | |
71 | }; | |
72 | ||
73 | /* cpu polarization */ | |
74 | enum { | |
75 | POLAR_UNKNOWN = 0, | |
76 | POLAR_VLOW, | |
77 | POLAR_VMEDIUM, | |
78 | POLAR_VHIGH, | |
79 | POLAR_HORIZONTAL | |
80 | }; | |
81 | ||
82 | struct polarization_modes { | |
83 | char *parsable; | |
84 | char *readable; | |
85 | }; | |
86 | ||
639eeb28 KZ |
87 | struct cpu_vulnerability { |
88 | char *name; | |
89 | char *text; | |
90 | }; | |
71061694 KZ |
91 | |
92 | /* global description */ | |
93 | struct lscpu_desc { | |
6e509042 KZ |
94 | const char *prefix; /* path to /sys and /proc snapshot or NULL */ |
95 | ||
96 | struct path_cxt *syscpu; /* _PATH_SYS_CPU path handler */ | |
97 | struct path_cxt *procfs; /* /proc path handler */ | |
98 | ||
71061694 KZ |
99 | char *arch; |
100 | char *vendor; | |
101 | char *machinetype; /* s390 */ | |
102 | char *family; | |
103 | char *model; | |
104 | char *modelname; | |
105 | char *revision; /* alternative for model (ppc) */ | |
106 | char *cpu; /* alternative for modelname (ppc, sparc) */ | |
107 | char *virtflag; /* virtualization flag (vmx, svm) */ | |
108 | char *hypervisor; /* hypervisor software */ | |
109 | int hyper; /* hypervisor vendor ID */ | |
110 | int virtype; /* VIRT_PARA|FULL|NONE ? */ | |
111 | char *mhz; | |
112 | char *dynamic_mhz; /* dynamic mega hertz (s390) */ | |
113 | char *static_mhz; /* static mega hertz (s390) */ | |
114 | char **maxmhz; /* maximum mega hertz */ | |
115 | char **minmhz; /* minimum mega hertz */ | |
116 | char *stepping; | |
117 | char *bogomips; | |
118 | char *flags; | |
119 | char *mtid; /* maximum thread id (s390) */ | |
3e48ef72 | 120 | char *addrsz; /* address sizes */ |
71061694 | 121 | int dispatching; /* none, horizontal or vertical */ |
16ca0551 | 122 | int freqboost; /* -1 if not evailable */ |
71061694 KZ |
123 | int mode; /* rm, lm or/and tm */ |
124 | ||
125 | int ncpuspos; /* maximal possible CPUs */ | |
126 | int ncpus; /* number of present CPUs */ | |
127 | cpu_set_t *present; /* mask with present CPUs */ | |
128 | cpu_set_t *online; /* mask with online CPUs */ | |
129 | ||
130 | int nthreads; /* number of online threads */ | |
131 | ||
132 | int ncaches; | |
133 | struct cpu_cache *caches; | |
134 | ||
135 | int necaches; /* extra caches (s390) */ | |
136 | struct cpu_cache *ecaches; | |
137 | ||
639eeb28 KZ |
138 | struct cpu_vulnerability *vuls; /* array of CPU vulnerabilities */ |
139 | int nvuls; /* number of CPU vulnerabilities */ | |
140 | ||
71061694 KZ |
141 | /* |
142 | * All maps are sequentially indexed (0..ncpuspos), the array index | |
143 | * does not have match with cpuX number as presented by kernel. You | |
144 | * have to use real_cpu_num() to get the real cpuX number. | |
145 | * | |
146 | * For example, the possible system CPUs are: 1,3,5, it means that | |
147 | * ncpuspos=3, so all arrays are in range 0..3. | |
148 | */ | |
149 | int *idx2cpunum; /* mapping index to CPU num */ | |
150 | ||
151 | int nnodes; /* number of NUMA modes */ | |
152 | int *idx2nodenum; /* Support for discontinuous nodes */ | |
153 | cpu_set_t **nodemaps; /* array with NUMA nodes */ | |
154 | ||
155 | /* drawers -- based on drawer_siblings (internal kernel map of cpuX's | |
156 | * hardware threads within the same drawer */ | |
157 | int ndrawers; /* number of all online drawers */ | |
158 | cpu_set_t **drawermaps; /* unique drawer_siblings */ | |
159 | int *drawerids; /* physical drawer ids */ | |
160 | ||
161 | /* books -- based on book_siblings (internal kernel map of cpuX's | |
162 | * hardware threads within the same book */ | |
163 | int nbooks; /* number of all online books */ | |
164 | cpu_set_t **bookmaps; /* unique book_siblings */ | |
165 | int *bookids; /* physical book ids */ | |
166 | ||
167 | /* sockets -- based on core_siblings (internal kernel map of cpuX's | |
168 | * hardware threads within the same physical_package_id (socket)) */ | |
169 | int nsockets; /* number of all online sockets */ | |
170 | cpu_set_t **socketmaps; /* unique core_siblings */ | |
171 | int *socketids; /* physical socket ids */ | |
172 | ||
173 | /* cores -- based on thread_siblings (internal kernel map of cpuX's | |
174 | * hardware threads within the same core as cpuX) */ | |
175 | int ncores; /* number of all online cores */ | |
176 | cpu_set_t **coremaps; /* unique thread_siblings */ | |
177 | int *coreids; /* physical core ids */ | |
178 | ||
179 | int *polarization; /* cpu polarization */ | |
180 | int *addresses; /* physical cpu addresses */ | |
181 | int *configured; /* cpu configured */ | |
182 | int physsockets; /* Physical sockets (modules) */ | |
183 | int physchips; /* Physical chips */ | |
184 | int physcoresperchip; /* Physical cores per chip */ | |
185 | }; | |
186 | ||
187 | enum { | |
188 | OUTPUT_SUMMARY = 0, /* default */ | |
189 | OUTPUT_PARSABLE, /* -p */ | |
190 | OUTPUT_READABLE, /* -e */ | |
0e86bc84 | 191 | OUTPUT_CACHES /* -C */ |
71061694 KZ |
192 | }; |
193 | ||
194 | enum { | |
195 | SYSTEM_LIVE = 0, /* analyzing a live system */ | |
196 | SYSTEM_SNAPSHOT, /* analyzing a snapshot of a different system */ | |
197 | }; | |
198 | ||
199 | struct lscpu_modifier { | |
200 | int mode; /* OUTPUT_* */ | |
201 | int system; /* SYSTEM_* */ | |
202 | unsigned int hex:1, /* print CPU masks rather than CPU lists */ | |
203 | compat:1, /* use backwardly compatible format */ | |
204 | online:1, /* print online CPUs */ | |
205 | offline:1, /* print offline CPUs */ | |
206 | json:1, /* JSON output format */ | |
0e86bc84 | 207 | bytes:1, /* output sizes in bytes */ |
71061694 KZ |
208 | physical:1; /* use physical numbers */ |
209 | }; | |
210 | ||
fb2627ce | 211 | extern int read_hypervisor_dmi(void); |
8229df20 | 212 | extern void arm_cpu_decode(struct lscpu_desc *desc); |
fb2627ce OO |
213 | |
214 | #endif /* LSCPU_H */ |