1 /******************************************************************************
4 * System management operations. For use by node control stack.
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
24 * Copyright (c) 2002-2006, K Fraser
27 #ifndef __XEN_PUBLIC_SYSCTL_H__
28 #define __XEN_PUBLIC_SYSCTL_H__
30 #if !defined(__XEN__) && !defined(__XEN_TOOLS__)
31 #error "sysctl operations are intended for use by node control tools only"
37 #define XEN_SYSCTL_INTERFACE_VERSION 0x00000007
40 * Read console content from Xen buffer ring.
42 #define XEN_SYSCTL_readconsole 1
43 struct xen_sysctl_readconsole {
44 /* IN: Non-zero -> clear after reading. */
46 /* IN: Non-zero -> start index specified by @index field. */
50 * IN: Start index for consuming from ring buffer (if @incremental);
51 * OUT: End index after consuming from ring buffer.
54 /* IN: Virtual address to write console data. */
55 XEN_GUEST_HANDLE_64(char) buffer;
56 /* IN: Size of buffer; OUT: Bytes written to buffer. */
59 typedef struct xen_sysctl_readconsole xen_sysctl_readconsole_t;
60 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_readconsole_t);
62 /* Get trace buffers machine base address */
63 #define XEN_SYSCTL_tbuf_op 2
64 struct xen_sysctl_tbuf_op {
66 #define XEN_SYSCTL_TBUFOP_get_info 0
67 #define XEN_SYSCTL_TBUFOP_set_cpu_mask 1
68 #define XEN_SYSCTL_TBUFOP_set_evt_mask 2
69 #define XEN_SYSCTL_TBUFOP_set_size 3
70 #define XEN_SYSCTL_TBUFOP_enable 4
71 #define XEN_SYSCTL_TBUFOP_disable 5
73 /* IN/OUT variables */
74 struct xenctl_cpumap cpu_mask;
77 uint64_aligned_t buffer_mfn;
80 typedef struct xen_sysctl_tbuf_op xen_sysctl_tbuf_op_t;
81 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_tbuf_op_t);
84 * Get physical information about the host machine
86 #define XEN_SYSCTL_physinfo 3
87 /* (x86) The platform supports HVM guests. */
88 #define _XEN_SYSCTL_PHYSCAP_hvm 0
89 #define XEN_SYSCTL_PHYSCAP_hvm (1u<<_XEN_SYSCTL_PHYSCAP_hvm)
90 /* (x86) The platform supports HVM-guest direct access to I/O devices. */
91 #define _XEN_SYSCTL_PHYSCAP_hvm_directio 1
92 #define XEN_SYSCTL_PHYSCAP_hvm_directio (1u<<_XEN_SYSCTL_PHYSCAP_hvm_directio)
93 struct xen_sysctl_physinfo {
94 uint32_t threads_per_core;
95 uint32_t cores_per_socket;
99 uint64_aligned_t total_pages;
100 uint64_aligned_t free_pages;
101 uint64_aligned_t scrub_pages;
105 * IN: maximum addressable entry in the caller-provided cpu_to_node array.
106 * OUT: largest cpu identifier in the system.
107 * If OUT is greater than IN then the cpu_to_node array is truncated!
111 * If not NULL, this array is filled with node identifier for each cpu.
112 * If a cpu has no node information (e.g., cpu not present) then the
113 * sentinel value ~0u is written.
114 * The size of this array is specified by the caller in @max_cpu_id.
115 * If the actual @max_cpu_id is smaller than the array then the trailing
116 * elements of the array will not be written by the sysctl.
118 XEN_GUEST_HANDLE_64(uint32) cpu_to_node;
120 /* XEN_SYSCTL_PHYSCAP_??? */
121 uint32_t capabilities;
123 typedef struct xen_sysctl_physinfo xen_sysctl_physinfo_t;
124 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_physinfo_t);
127 * Get the ID of the current scheduler.
129 #define XEN_SYSCTL_sched_id 4
130 struct xen_sysctl_sched_id {
134 typedef struct xen_sysctl_sched_id xen_sysctl_sched_id_t;
135 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_sched_id_t);
137 /* Interface for controlling Xen software performance counters. */
138 #define XEN_SYSCTL_perfc_op 5
139 /* Sub-operations: */
140 #define XEN_SYSCTL_PERFCOP_reset 1 /* Reset all counters to zero. */
141 #define XEN_SYSCTL_PERFCOP_query 2 /* Get perfctr information. */
142 struct xen_sysctl_perfc_desc {
143 char name[80]; /* name of perf counter */
144 uint32_t nr_vals; /* number of values for this counter */
146 typedef struct xen_sysctl_perfc_desc xen_sysctl_perfc_desc_t;
147 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t);
148 typedef uint32_t xen_sysctl_perfc_val_t;
149 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_val_t);
151 struct xen_sysctl_perfc_op {
153 uint32_t cmd; /* XEN_SYSCTL_PERFCOP_??? */
155 uint32_t nr_counters; /* number of counters description */
156 uint32_t nr_vals; /* number of values */
157 /* counter information (or NULL) */
158 XEN_GUEST_HANDLE_64(xen_sysctl_perfc_desc_t) desc;
159 /* counter values (or NULL) */
160 XEN_GUEST_HANDLE_64(xen_sysctl_perfc_val_t) val;
162 typedef struct xen_sysctl_perfc_op xen_sysctl_perfc_op_t;
163 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_op_t);
165 #define XEN_SYSCTL_getdomaininfolist 6
166 struct xen_sysctl_getdomaininfolist {
168 domid_t first_domain;
169 uint32_t max_domains;
170 XEN_GUEST_HANDLE_64(xen_domctl_getdomaininfo_t) buffer;
172 uint32_t num_domains;
174 typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
175 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
177 /* Inject debug keys into Xen. */
178 #define XEN_SYSCTL_debug_keys 7
179 struct xen_sysctl_debug_keys {
181 XEN_GUEST_HANDLE_64(char) keys;
184 typedef struct xen_sysctl_debug_keys xen_sysctl_debug_keys_t;
185 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_debug_keys_t);
187 /* Get physical CPU information. */
188 #define XEN_SYSCTL_getcpuinfo 8
189 struct xen_sysctl_cpuinfo {
190 uint64_aligned_t idletime;
192 typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;
193 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t);
194 struct xen_sysctl_getcpuinfo {
197 XEN_GUEST_HANDLE_64(xen_sysctl_cpuinfo_t) info;
201 typedef struct xen_sysctl_getcpuinfo xen_sysctl_getcpuinfo_t;
202 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getcpuinfo_t);
204 #define XEN_SYSCTL_availheap 9
205 struct xen_sysctl_availheap {
207 uint32_t min_bitwidth; /* Smallest address width (zero if don't care). */
208 uint32_t max_bitwidth; /* Largest address width (zero if don't care). */
209 int32_t node; /* NUMA node of interest (-1 for all nodes). */
211 uint64_aligned_t avail_bytes;/* Bytes available in the specified region. */
213 typedef struct xen_sysctl_availheap xen_sysctl_availheap_t;
214 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_availheap_t);
216 #define XEN_SYSCTL_get_pmstat 10
218 uint64_aligned_t freq; /* Px core frequency */
219 uint64_aligned_t residency; /* Px residency time */
220 uint64_aligned_t count; /* Px transition count */
222 typedef struct pm_px_val pm_px_val_t;
223 DEFINE_XEN_GUEST_HANDLE(pm_px_val_t);
226 uint8_t total; /* total Px states */
227 uint8_t usable; /* usable Px states */
228 uint8_t last; /* last Px state */
229 uint8_t cur; /* current Px state */
230 XEN_GUEST_HANDLE_64(uint64) trans_pt; /* Px transition table */
231 XEN_GUEST_HANDLE_64(pm_px_val_t) pt;
233 typedef struct pm_px_stat pm_px_stat_t;
234 DEFINE_XEN_GUEST_HANDLE(pm_px_stat_t);
237 uint32_t nr; /* entry nr in triggers & residencies, including C0 */
238 uint32_t last; /* last Cx state */
239 uint64_aligned_t idle_time; /* idle time from boot */
240 XEN_GUEST_HANDLE_64(uint64) triggers; /* Cx trigger counts */
241 XEN_GUEST_HANDLE_64(uint64) residencies; /* Cx residencies */
244 struct xen_sysctl_get_pmstat {
245 #define PMSTAT_CATEGORY_MASK 0xf0
246 #define PMSTAT_PX 0x10
247 #define PMSTAT_CX 0x20
248 #define PMSTAT_get_max_px (PMSTAT_PX | 0x1)
249 #define PMSTAT_get_pxstat (PMSTAT_PX | 0x2)
250 #define PMSTAT_reset_pxstat (PMSTAT_PX | 0x3)
251 #define PMSTAT_get_max_cx (PMSTAT_CX | 0x1)
252 #define PMSTAT_get_cxstat (PMSTAT_CX | 0x2)
253 #define PMSTAT_reset_cxstat (PMSTAT_CX | 0x3)
257 struct pm_px_stat getpx;
258 struct pm_cx_stat getcx;
259 /* other struct for tx, etc */
262 typedef struct xen_sysctl_get_pmstat xen_sysctl_get_pmstat_t;
263 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_get_pmstat_t);
266 * Status codes. Must be greater than 0 to avoid confusing
267 * sysctl callers that see 0 as a plain successful return.
269 #define XEN_CPU_HOTPLUG_STATUS_OFFLINE 1
270 #define XEN_CPU_HOTPLUG_STATUS_ONLINE 2
271 #define XEN_CPU_HOTPLUG_STATUS_NEW 3
273 #define XEN_SYSCTL_cpu_hotplug 11
274 struct xen_sysctl_cpu_hotplug {
276 uint32_t cpu; /* Physical cpu. */
277 #define XEN_SYSCTL_CPU_HOTPLUG_ONLINE 0
278 #define XEN_SYSCTL_CPU_HOTPLUG_OFFLINE 1
279 #define XEN_SYSCTL_CPU_HOTPLUG_STATUS 2
280 uint32_t op; /* hotplug opcode */
282 typedef struct xen_sysctl_cpu_hotplug xen_sysctl_cpu_hotplug_t;
283 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpu_hotplug_t);
286 * Get/set xen power management, include
287 * 1. cpufreq governors and related parameters
289 #define XEN_SYSCTL_pm_op 12
290 struct xen_userspace {
291 uint32_t scaling_setspeed;
293 typedef struct xen_userspace xen_userspace_t;
295 struct xen_ondemand {
296 uint32_t sampling_rate_max;
297 uint32_t sampling_rate_min;
299 uint32_t sampling_rate;
300 uint32_t up_threshold;
302 typedef struct xen_ondemand xen_ondemand_t;
305 * cpufreq para name of this structure named
306 * same as sysfs file name of native linux
308 #define CPUFREQ_NAME_LEN 16
309 struct xen_get_cpufreq_para {
310 /* IN/OUT variable */
315 /* for all governors */
317 XEN_GUEST_HANDLE_64(uint32) affected_cpus;
318 XEN_GUEST_HANDLE_64(uint32) scaling_available_frequencies;
319 XEN_GUEST_HANDLE_64(char) scaling_available_governors;
320 char scaling_driver[CPUFREQ_NAME_LEN];
322 uint32_t cpuinfo_cur_freq;
323 uint32_t cpuinfo_max_freq;
324 uint32_t cpuinfo_min_freq;
325 uint32_t scaling_cur_freq;
327 char scaling_governor[CPUFREQ_NAME_LEN];
328 uint32_t scaling_max_freq;
329 uint32_t scaling_min_freq;
331 /* for specific governor */
333 struct xen_userspace userspace;
334 struct xen_ondemand ondemand;
338 struct xen_set_cpufreq_gov {
339 char scaling_governor[CPUFREQ_NAME_LEN];
342 struct xen_set_cpufreq_para {
343 #define SCALING_MAX_FREQ 1
344 #define SCALING_MIN_FREQ 2
345 #define SCALING_SETSPEED 3
346 #define SAMPLING_RATE 4
347 #define UP_THRESHOLD 5
353 /* Get physical CPU topology information. */
354 #define INVALID_TOPOLOGY_ID (~0U)
355 struct xen_get_cputopo {
356 /* IN: maximum addressable entry in
357 * the caller-provided cpu_to_core/socket.
360 XEN_GUEST_HANDLE_64(uint32) cpu_to_core;
361 XEN_GUEST_HANDLE_64(uint32) cpu_to_socket;
363 /* OUT: number of cpus returned
364 * If OUT is greater than IN then the cpu_to_core/socket is truncated!
369 struct xen_sysctl_pm_op {
370 #define PM_PARA_CATEGORY_MASK 0xf0
371 #define CPUFREQ_PARA 0x10
373 /* cpufreq command type */
374 #define GET_CPUFREQ_PARA (CPUFREQ_PARA | 0x01)
375 #define SET_CPUFREQ_GOV (CPUFREQ_PARA | 0x02)
376 #define SET_CPUFREQ_PARA (CPUFREQ_PARA | 0x03)
377 #define GET_CPUFREQ_AVGFREQ (CPUFREQ_PARA | 0x04)
379 /* get CPU topology */
380 #define XEN_SYSCTL_pm_op_get_cputopo 0x20
382 /* set/reset scheduler power saving option */
383 #define XEN_SYSCTL_pm_op_set_sched_opt_smt 0x21
385 /* cpuidle max_cstate access command */
386 #define XEN_SYSCTL_pm_op_get_max_cstate 0x22
387 #define XEN_SYSCTL_pm_op_set_max_cstate 0x23
389 /* set scheduler migration cost value */
390 #define XEN_SYSCTL_pm_op_set_vcpu_migration_delay 0x24
391 #define XEN_SYSCTL_pm_op_get_vcpu_migration_delay 0x25
396 struct xen_get_cpufreq_para get_para;
397 struct xen_set_cpufreq_gov set_gov;
398 struct xen_set_cpufreq_para set_para;
399 uint64_aligned_t get_avgfreq;
400 struct xen_get_cputopo get_topo;
401 uint32_t set_sched_opt_smt;
402 uint32_t get_max_cstate;
403 uint32_t set_max_cstate;
404 uint32_t get_vcpu_migration_delay;
405 uint32_t set_vcpu_migration_delay;
409 #define XEN_SYSCTL_page_offline_op 14
410 struct xen_sysctl_page_offline_op {
411 /* IN: range of page to be offlined */
412 #define sysctl_page_offline 1
413 #define sysctl_page_online 2
414 #define sysctl_query_page_offline 3
418 /* OUT: result of page offline request */
420 * bit 0~15: result flags
423 XEN_GUEST_HANDLE(uint32) status;
426 #define PG_OFFLINE_STATUS_MASK (0xFFUL)
428 /* The result is invalid, i.e. HV does not handle it */
429 #define PG_OFFLINE_INVALID (0x1UL << 0)
431 #define PG_OFFLINE_OFFLINED (0x1UL << 1)
432 #define PG_OFFLINE_PENDING (0x1UL << 2)
433 #define PG_OFFLINE_FAILED (0x1UL << 3)
435 #define PG_ONLINE_FAILED PG_OFFLINE_FAILED
436 #define PG_ONLINE_ONLINED PG_OFFLINE_OFFLINED
438 #define PG_OFFLINE_STATUS_OFFLINED (0x1UL << 1)
439 #define PG_OFFLINE_STATUS_ONLINE (0x1UL << 2)
440 #define PG_OFFLINE_STATUS_OFFLINE_PENDING (0x1UL << 3)
441 #define PG_OFFLINE_STATUS_BROKEN (0x1UL << 4)
443 #define PG_OFFLINE_MISC_MASK (0xFFUL << 4)
445 /* only valid when PG_OFFLINE_FAILED */
446 #define PG_OFFLINE_XENPAGE (0x1UL << 8)
447 #define PG_OFFLINE_DOM0PAGE (0x1UL << 9)
448 #define PG_OFFLINE_ANONYMOUS (0x1UL << 10)
449 #define PG_OFFLINE_NOT_CONV_RAM (0x1UL << 11)
450 #define PG_OFFLINE_OWNED (0x1UL << 12)
452 #define PG_OFFLINE_BROKEN (0x1UL << 13)
453 #define PG_ONLINE_BROKEN PG_OFFLINE_BROKEN
455 #define PG_OFFLINE_OWNER_SHIFT 16
457 #define XEN_SYSCTL_lockprof_op 15
458 /* Sub-operations: */
459 #define XEN_SYSCTL_LOCKPROF_reset 1 /* Reset all profile data to zero. */
460 #define XEN_SYSCTL_LOCKPROF_query 2 /* Get lock profile information. */
462 #define LOCKPROF_TYPE_GLOBAL 0 /* global lock, idx meaningless */
463 #define LOCKPROF_TYPE_PERDOM 1 /* per-domain lock, idx is domid */
464 #define LOCKPROF_TYPE_N 2 /* number of types */
465 struct xen_sysctl_lockprof_data {
466 char name[40]; /* lock name (may include up to 2 %d specifiers) */
467 int32_t type; /* LOCKPROF_TYPE_??? */
468 int32_t idx; /* index (e.g. domain id) */
469 uint64_aligned_t lock_cnt; /* # of locking succeeded */
470 uint64_aligned_t block_cnt; /* # of wait for lock */
471 uint64_aligned_t lock_time; /* nsecs lock held */
472 uint64_aligned_t block_time; /* nsecs waited for lock */
474 typedef struct xen_sysctl_lockprof_data xen_sysctl_lockprof_data_t;
475 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockprof_data_t);
476 struct xen_sysctl_lockprof_op {
478 uint32_t cmd; /* XEN_SYSCTL_LOCKPROF_??? */
479 uint32_t max_elem; /* size of output buffer */
480 /* OUT variables (query only). */
481 uint32_t nr_elem; /* number of elements available */
482 uint64_aligned_t time; /* nsecs of profile measurement */
483 /* profile information (or NULL) */
484 XEN_GUEST_HANDLE_64(xen_sysctl_lockprof_data_t) data;
486 typedef struct xen_sysctl_lockprof_op xen_sysctl_lockprof_op_t;
487 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockprof_op_t);
491 uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
493 struct xen_sysctl_readconsole readconsole;
494 struct xen_sysctl_tbuf_op tbuf_op;
495 struct xen_sysctl_physinfo physinfo;
496 struct xen_sysctl_sched_id sched_id;
497 struct xen_sysctl_perfc_op perfc_op;
498 struct xen_sysctl_getdomaininfolist getdomaininfolist;
499 struct xen_sysctl_debug_keys debug_keys;
500 struct xen_sysctl_getcpuinfo getcpuinfo;
501 struct xen_sysctl_availheap availheap;
502 struct xen_sysctl_get_pmstat get_pmstat;
503 struct xen_sysctl_cpu_hotplug cpu_hotplug;
504 struct xen_sysctl_pm_op pm_op;
505 struct xen_sysctl_page_offline_op page_offline;
506 struct xen_sysctl_lockprof_op lockprof_op;
510 typedef struct xen_sysctl xen_sysctl_t;
511 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_t);
513 #endif /* __XEN_PUBLIC_SYSCTL_H__ */
521 * indent-tabs-mode: nil