]>
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; | |
51 | char *size; | |
52 | ||
53 | int nsharedmaps; | |
54 | cpu_set_t **sharedmaps; | |
55 | }; | |
56 | ||
57 | /* dispatching modes */ | |
58 | enum { | |
59 | DISP_HORIZONTAL = 0, | |
60 | DISP_VERTICAL = 1 | |
61 | }; | |
62 | ||
63 | /* cpu polarization */ | |
64 | enum { | |
65 | POLAR_UNKNOWN = 0, | |
66 | POLAR_VLOW, | |
67 | POLAR_VMEDIUM, | |
68 | POLAR_VHIGH, | |
69 | POLAR_HORIZONTAL | |
70 | }; | |
71 | ||
72 | struct polarization_modes { | |
73 | char *parsable; | |
74 | char *readable; | |
75 | }; | |
76 | ||
77 | ||
78 | /* global description */ | |
79 | struct lscpu_desc { | |
6e509042 KZ |
80 | const char *prefix; /* path to /sys and /proc snapshot or NULL */ |
81 | ||
82 | struct path_cxt *syscpu; /* _PATH_SYS_CPU path handler */ | |
83 | struct path_cxt *procfs; /* /proc path handler */ | |
84 | ||
71061694 KZ |
85 | char *arch; |
86 | char *vendor; | |
87 | char *machinetype; /* s390 */ | |
88 | char *family; | |
89 | char *model; | |
90 | char *modelname; | |
91 | char *revision; /* alternative for model (ppc) */ | |
92 | char *cpu; /* alternative for modelname (ppc, sparc) */ | |
93 | char *virtflag; /* virtualization flag (vmx, svm) */ | |
94 | char *hypervisor; /* hypervisor software */ | |
95 | int hyper; /* hypervisor vendor ID */ | |
96 | int virtype; /* VIRT_PARA|FULL|NONE ? */ | |
97 | char *mhz; | |
98 | char *dynamic_mhz; /* dynamic mega hertz (s390) */ | |
99 | char *static_mhz; /* static mega hertz (s390) */ | |
100 | char **maxmhz; /* maximum mega hertz */ | |
101 | char **minmhz; /* minimum mega hertz */ | |
102 | char *stepping; | |
103 | char *bogomips; | |
104 | char *flags; | |
105 | char *mtid; /* maximum thread id (s390) */ | |
3e48ef72 | 106 | char *addrsz; /* address sizes */ |
71061694 | 107 | int dispatching; /* none, horizontal or vertical */ |
16ca0551 | 108 | int freqboost; /* -1 if not evailable */ |
71061694 KZ |
109 | int mode; /* rm, lm or/and tm */ |
110 | ||
111 | int ncpuspos; /* maximal possible CPUs */ | |
112 | int ncpus; /* number of present CPUs */ | |
113 | cpu_set_t *present; /* mask with present CPUs */ | |
114 | cpu_set_t *online; /* mask with online CPUs */ | |
115 | ||
116 | int nthreads; /* number of online threads */ | |
117 | ||
118 | int ncaches; | |
119 | struct cpu_cache *caches; | |
120 | ||
121 | int necaches; /* extra caches (s390) */ | |
122 | struct cpu_cache *ecaches; | |
123 | ||
124 | /* | |
125 | * All maps are sequentially indexed (0..ncpuspos), the array index | |
126 | * does not have match with cpuX number as presented by kernel. You | |
127 | * have to use real_cpu_num() to get the real cpuX number. | |
128 | * | |
129 | * For example, the possible system CPUs are: 1,3,5, it means that | |
130 | * ncpuspos=3, so all arrays are in range 0..3. | |
131 | */ | |
132 | int *idx2cpunum; /* mapping index to CPU num */ | |
133 | ||
134 | int nnodes; /* number of NUMA modes */ | |
135 | int *idx2nodenum; /* Support for discontinuous nodes */ | |
136 | cpu_set_t **nodemaps; /* array with NUMA nodes */ | |
137 | ||
138 | /* drawers -- based on drawer_siblings (internal kernel map of cpuX's | |
139 | * hardware threads within the same drawer */ | |
140 | int ndrawers; /* number of all online drawers */ | |
141 | cpu_set_t **drawermaps; /* unique drawer_siblings */ | |
142 | int *drawerids; /* physical drawer ids */ | |
143 | ||
144 | /* books -- based on book_siblings (internal kernel map of cpuX's | |
145 | * hardware threads within the same book */ | |
146 | int nbooks; /* number of all online books */ | |
147 | cpu_set_t **bookmaps; /* unique book_siblings */ | |
148 | int *bookids; /* physical book ids */ | |
149 | ||
150 | /* sockets -- based on core_siblings (internal kernel map of cpuX's | |
151 | * hardware threads within the same physical_package_id (socket)) */ | |
152 | int nsockets; /* number of all online sockets */ | |
153 | cpu_set_t **socketmaps; /* unique core_siblings */ | |
154 | int *socketids; /* physical socket ids */ | |
155 | ||
156 | /* cores -- based on thread_siblings (internal kernel map of cpuX's | |
157 | * hardware threads within the same core as cpuX) */ | |
158 | int ncores; /* number of all online cores */ | |
159 | cpu_set_t **coremaps; /* unique thread_siblings */ | |
160 | int *coreids; /* physical core ids */ | |
161 | ||
162 | int *polarization; /* cpu polarization */ | |
163 | int *addresses; /* physical cpu addresses */ | |
164 | int *configured; /* cpu configured */ | |
165 | int physsockets; /* Physical sockets (modules) */ | |
166 | int physchips; /* Physical chips */ | |
167 | int physcoresperchip; /* Physical cores per chip */ | |
168 | }; | |
169 | ||
170 | enum { | |
171 | OUTPUT_SUMMARY = 0, /* default */ | |
172 | OUTPUT_PARSABLE, /* -p */ | |
173 | OUTPUT_READABLE, /* -e */ | |
174 | }; | |
175 | ||
176 | enum { | |
177 | SYSTEM_LIVE = 0, /* analyzing a live system */ | |
178 | SYSTEM_SNAPSHOT, /* analyzing a snapshot of a different system */ | |
179 | }; | |
180 | ||
181 | struct lscpu_modifier { | |
182 | int mode; /* OUTPUT_* */ | |
183 | int system; /* SYSTEM_* */ | |
184 | unsigned int hex:1, /* print CPU masks rather than CPU lists */ | |
185 | compat:1, /* use backwardly compatible format */ | |
186 | online:1, /* print online CPUs */ | |
187 | offline:1, /* print offline CPUs */ | |
188 | json:1, /* JSON output format */ | |
189 | physical:1; /* use physical numbers */ | |
190 | }; | |
191 | ||
fb2627ce | 192 | extern int read_hypervisor_dmi(void); |
8229df20 | 193 | extern void arm_cpu_decode(struct lscpu_desc *desc); |
fb2627ce OO |
194 | |
195 | #endif /* LSCPU_H */ |