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