1/******************************************************************************
2 * sysctl.h
3 *
4 * System management operations. For use by node control stack.
5 *
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:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
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.
23 *
24 * Copyright (c) 2002-2006, K Fraser
25 */
26
27#ifndef __XEN_PUBLIC_SYSCTL_H__
28#define __XEN_PUBLIC_SYSCTL_H__
29
30#if !defined(__XEN__) && !defined(__XEN_TOOLS__)
31#error "sysctl operations are intended for use by node control tools only"
32#endif
33
34#include "xen.h"
35#include "domctl.h"
36
37#define XEN_SYSCTL_INTERFACE_VERSION 0x00000009
38
39/*
40 * Read console content from Xen buffer ring.
41 */
42/* XEN_SYSCTL_readconsole */
43struct xen_sysctl_readconsole {
44    /* IN: Non-zero -> clear after reading. */
45    uint8_t clear;
46    /* IN: Non-zero -> start index specified by @index field. */
47    uint8_t incremental;
48    uint8_t pad0, pad1;
49    /*
50     * IN:  Start index for consuming from ring buffer (if @incremental);
51     * OUT: End index after consuming from ring buffer.
52     */
53    uint32_t index;
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. */
57    uint32_t count;
58};
59typedef struct xen_sysctl_readconsole xen_sysctl_readconsole_t;
60DEFINE_XEN_GUEST_HANDLE(xen_sysctl_readconsole_t);
61
62/* Get trace buffers machine base address */
63/* XEN_SYSCTL_tbuf_op */
64struct xen_sysctl_tbuf_op {
65    /* IN variables */
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
72    uint32_t cmd;
73    /* IN/OUT variables */
74    struct xenctl_cpumap cpu_mask;
75    uint32_t             evt_mask;
76    /* OUT variables */
77    uint64_aligned_t buffer_mfn;
78    uint32_t size;  /* Also an IN variable! */
79};
80typedef struct xen_sysctl_tbuf_op xen_sysctl_tbuf_op_t;
81DEFINE_XEN_GUEST_HANDLE(xen_sysctl_tbuf_op_t);
82
83/*
84 * Get physical information about the host machine
85 */
86/* XEN_SYSCTL_physinfo */
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)
93struct xen_sysctl_physinfo {
94    uint32_t threads_per_core;
95    uint32_t cores_per_socket;
96    uint32_t nr_cpus;     /* # CPUs currently online */
97    uint32_t max_cpu_id;  /* Largest possible CPU ID on this host */
98    uint32_t nr_nodes;    /* # nodes currently online */
99    uint32_t max_node_id; /* Largest possible node ID on this host */
100    uint32_t cpu_khz;
101    uint64_aligned_t total_pages;
102    uint64_aligned_t free_pages;
103    uint64_aligned_t scrub_pages;
104    uint32_t hw_cap[8];
105
106    /* XEN_SYSCTL_PHYSCAP_??? */
107    uint32_t capabilities;
108};
109typedef struct xen_sysctl_physinfo xen_sysctl_physinfo_t;
110DEFINE_XEN_GUEST_HANDLE(xen_sysctl_physinfo_t);
111
112/*
113 * Get the ID of the current scheduler.
114 */
115/* XEN_SYSCTL_sched_id */
116struct xen_sysctl_sched_id {
117    /* OUT variable */
118    uint32_t sched_id;
119};
120typedef struct xen_sysctl_sched_id xen_sysctl_sched_id_t;
121DEFINE_XEN_GUEST_HANDLE(xen_sysctl_sched_id_t);
122
123/* Interface for controlling Xen software performance counters. */
124/* XEN_SYSCTL_perfc_op */
125/* Sub-operations: */
126#define XEN_SYSCTL_PERFCOP_reset 1   /* Reset all counters to zero. */
127#define XEN_SYSCTL_PERFCOP_query 2   /* Get perfctr information. */
128struct xen_sysctl_perfc_desc {
129    char         name[80];             /* name of perf counter */
130    uint32_t     nr_vals;              /* number of values for this counter */
131};
132typedef struct xen_sysctl_perfc_desc xen_sysctl_perfc_desc_t;
133DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t);
134typedef uint32_t xen_sysctl_perfc_val_t;
135DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_val_t);
136
137struct xen_sysctl_perfc_op {
138    /* IN variables. */
139    uint32_t       cmd;                /*  XEN_SYSCTL_PERFCOP_??? */
140    /* OUT variables. */
141    uint32_t       nr_counters;       /*  number of counters description  */
142    uint32_t       nr_vals;           /*  number of values  */
143    /* counter information (or NULL) */
144    XEN_GUEST_HANDLE_64(xen_sysctl_perfc_desc_t) desc;
145    /* counter values (or NULL) */
146    XEN_GUEST_HANDLE_64(xen_sysctl_perfc_val_t) val;
147};
148typedef struct xen_sysctl_perfc_op xen_sysctl_perfc_op_t;
149DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_op_t);
150
151/* XEN_SYSCTL_getdomaininfolist */
152struct xen_sysctl_getdomaininfolist {
153    /* IN variables. */
154    domid_t               first_domain;
155    uint32_t              max_domains;
156    XEN_GUEST_HANDLE_64(xen_domctl_getdomaininfo_t) buffer;
157    /* OUT variables. */
158    uint32_t              num_domains;
159};
160typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
161DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
162
163/* Inject debug keys into Xen. */
164/* XEN_SYSCTL_debug_keys */
165struct xen_sysctl_debug_keys {
166    /* IN variables. */
167    XEN_GUEST_HANDLE_64(char) keys;
168    uint32_t nr_keys;
169};
170typedef struct xen_sysctl_debug_keys xen_sysctl_debug_keys_t;
171DEFINE_XEN_GUEST_HANDLE(xen_sysctl_debug_keys_t);
172
173/* Get physical CPU information. */
174/* XEN_SYSCTL_getcpuinfo */
175struct xen_sysctl_cpuinfo {
176    uint64_aligned_t idletime;
177};
178typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;
179DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t);
180struct xen_sysctl_getcpuinfo {
181    /* IN variables. */
182    uint32_t max_cpus;
183    XEN_GUEST_HANDLE_64(xen_sysctl_cpuinfo_t) info;
184    /* OUT variables. */
185    uint32_t nr_cpus;
186};
187typedef struct xen_sysctl_getcpuinfo xen_sysctl_getcpuinfo_t;
188DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getcpuinfo_t);
189
190/* XEN_SYSCTL_availheap */
191struct xen_sysctl_availheap {
192    /* IN variables. */
193    uint32_t min_bitwidth;  /* Smallest address width (zero if don't care). */
194    uint32_t max_bitwidth;  /* Largest address width (zero if don't care). */
195    int32_t  node;          /* NUMA node of interest (-1 for all nodes). */
196    /* OUT variables. */
197    uint64_aligned_t avail_bytes;/* Bytes available in the specified region. */
198};
199typedef struct xen_sysctl_availheap xen_sysctl_availheap_t;
200DEFINE_XEN_GUEST_HANDLE(xen_sysctl_availheap_t);
201
202/* XEN_SYSCTL_get_pmstat */
203struct pm_px_val {
204    uint64_aligned_t freq;        /* Px core frequency */
205    uint64_aligned_t residency;   /* Px residency time */
206    uint64_aligned_t count;       /* Px transition count */
207};
208typedef struct pm_px_val pm_px_val_t;
209DEFINE_XEN_GUEST_HANDLE(pm_px_val_t);
210
211struct pm_px_stat {
212    uint8_t total;        /* total Px states */
213    uint8_t usable;       /* usable Px states */
214    uint8_t last;         /* last Px state */
215    uint8_t cur;          /* current Px state */
216    XEN_GUEST_HANDLE_64(uint64) trans_pt;   /* Px transition table */
217    XEN_GUEST_HANDLE_64(pm_px_val_t) pt;
218};
219typedef struct pm_px_stat pm_px_stat_t;
220DEFINE_XEN_GUEST_HANDLE(pm_px_stat_t);
221
222struct pm_cx_stat {
223    uint32_t nr;    /* entry nr in triggers & residencies, including C0 */
224    uint32_t last;  /* last Cx state */
225    uint64_aligned_t idle_time;                 /* idle time from boot */
226    XEN_GUEST_HANDLE_64(uint64) triggers;    /* Cx trigger counts */
227    XEN_GUEST_HANDLE_64(uint64) residencies; /* Cx residencies */
228    uint64_aligned_t pc2;
229    uint64_aligned_t pc3;
230    uint64_aligned_t pc6;
231    uint64_aligned_t pc7;
232    uint64_aligned_t cc3;
233    uint64_aligned_t cc6;
234    uint64_aligned_t cc7;
235};
236
237struct xen_sysctl_get_pmstat {
238#define PMSTAT_CATEGORY_MASK 0xf0
239#define PMSTAT_PX            0x10
240#define PMSTAT_CX            0x20
241#define PMSTAT_get_max_px    (PMSTAT_PX | 0x1)
242#define PMSTAT_get_pxstat    (PMSTAT_PX | 0x2)
243#define PMSTAT_reset_pxstat  (PMSTAT_PX | 0x3)
244#define PMSTAT_get_max_cx    (PMSTAT_CX | 0x1)
245#define PMSTAT_get_cxstat    (PMSTAT_CX | 0x2)
246#define PMSTAT_reset_cxstat  (PMSTAT_CX | 0x3)
247    uint32_t type;
248    uint32_t cpuid;
249    union {
250        struct pm_px_stat getpx;
251        struct pm_cx_stat getcx;
252        /* other struct for tx, etc */
253    } u;
254};
255typedef struct xen_sysctl_get_pmstat xen_sysctl_get_pmstat_t;
256DEFINE_XEN_GUEST_HANDLE(xen_sysctl_get_pmstat_t);
257
258/* XEN_SYSCTL_cpu_hotplug */
259struct xen_sysctl_cpu_hotplug {
260    /* IN variables */
261    uint32_t cpu;   /* Physical cpu. */
262#define XEN_SYSCTL_CPU_HOTPLUG_ONLINE  0
263#define XEN_SYSCTL_CPU_HOTPLUG_OFFLINE 1
264    uint32_t op;    /* hotplug opcode */
265};
266typedef struct xen_sysctl_cpu_hotplug xen_sysctl_cpu_hotplug_t;
267DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpu_hotplug_t);
268
269/*
270 * Get/set xen power management, include
271 * 1. cpufreq governors and related parameters
272 */
273/* XEN_SYSCTL_pm_op */
274struct xen_userspace {
275    uint32_t scaling_setspeed;
276};
277typedef struct xen_userspace xen_userspace_t;
278
279struct xen_ondemand {
280    uint32_t sampling_rate_max;
281    uint32_t sampling_rate_min;
282
283    uint32_t sampling_rate;
284    uint32_t up_threshold;
285};
286typedef struct xen_ondemand xen_ondemand_t;
287
288/*
289 * cpufreq para name of this structure named
290 * same as sysfs file name of native linux
291 */
292#define CPUFREQ_NAME_LEN 16
293struct xen_get_cpufreq_para {
294    /* IN/OUT variable */
295    uint32_t cpu_num;
296    uint32_t freq_num;
297    uint32_t gov_num;
298
299    /* for all governors */
300    /* OUT variable */
301    XEN_GUEST_HANDLE_64(uint32) affected_cpus;
302    XEN_GUEST_HANDLE_64(uint32) scaling_available_frequencies;
303    XEN_GUEST_HANDLE_64(char)   scaling_available_governors;
304    char scaling_driver[CPUFREQ_NAME_LEN];
305
306    uint32_t cpuinfo_cur_freq;
307    uint32_t cpuinfo_max_freq;
308    uint32_t cpuinfo_min_freq;
309    uint32_t scaling_cur_freq;
310
311    char scaling_governor[CPUFREQ_NAME_LEN];
312    uint32_t scaling_max_freq;
313    uint32_t scaling_min_freq;
314
315    /* for specific governor */
316    union {
317        struct  xen_userspace userspace;
318        struct  xen_ondemand ondemand;
319    } u;
320
321    int32_t turbo_enabled;
322};
323
324struct xen_set_cpufreq_gov {
325    char scaling_governor[CPUFREQ_NAME_LEN];
326};
327
328struct xen_set_cpufreq_para {
329    #define SCALING_MAX_FREQ           1
330    #define SCALING_MIN_FREQ           2
331    #define SCALING_SETSPEED           3
332    #define SAMPLING_RATE              4
333    #define UP_THRESHOLD               5
334
335    uint32_t ctrl_type;
336    uint32_t ctrl_value;
337};
338
339struct xen_sysctl_pm_op {
340    #define PM_PARA_CATEGORY_MASK      0xf0
341    #define CPUFREQ_PARA               0x10
342
343    /* cpufreq command type */
344    #define GET_CPUFREQ_PARA           (CPUFREQ_PARA | 0x01)
345    #define SET_CPUFREQ_GOV            (CPUFREQ_PARA | 0x02)
346    #define SET_CPUFREQ_PARA           (CPUFREQ_PARA | 0x03)
347    #define GET_CPUFREQ_AVGFREQ        (CPUFREQ_PARA | 0x04)
348
349    /* set/reset scheduler power saving option */
350    #define XEN_SYSCTL_pm_op_set_sched_opt_smt    0x21
351
352    /* cpuidle max_cstate access command */
353    #define XEN_SYSCTL_pm_op_get_max_cstate       0x22
354    #define XEN_SYSCTL_pm_op_set_max_cstate       0x23
355
356    /* set scheduler migration cost value */
357    #define XEN_SYSCTL_pm_op_set_vcpu_migration_delay   0x24
358    #define XEN_SYSCTL_pm_op_get_vcpu_migration_delay   0x25
359
360    /* enable/disable turbo mode when in dbs governor */
361    #define XEN_SYSCTL_pm_op_enable_turbo               0x26
362    #define XEN_SYSCTL_pm_op_disable_turbo              0x27
363
364    uint32_t cmd;
365    uint32_t cpuid;
366    union {
367        struct xen_get_cpufreq_para get_para;
368        struct xen_set_cpufreq_gov  set_gov;
369        struct xen_set_cpufreq_para set_para;
370        uint64_aligned_t get_avgfreq;
371        uint32_t                    set_sched_opt_smt;
372        uint32_t                    get_max_cstate;
373        uint32_t                    set_max_cstate;
374        uint32_t                    get_vcpu_migration_delay;
375        uint32_t                    set_vcpu_migration_delay;
376    } u;
377};
378
379/* XEN_SYSCTL_page_offline_op */
380struct xen_sysctl_page_offline_op {
381    /* IN: range of page to be offlined */
382#define sysctl_page_offline     1
383#define sysctl_page_online      2
384#define sysctl_query_page_offline  3
385    uint32_t cmd;
386    uint32_t start;
387    uint32_t end;
388    /* OUT: result of page offline request */
389    /*
390     * bit 0~15: result flags
391     * bit 16~31: owner
392     */
393    XEN_GUEST_HANDLE(uint32) status;
394};
395
396#define PG_OFFLINE_STATUS_MASK    (0xFFUL)
397
398/* The result is invalid, i.e. HV does not handle it */
399#define PG_OFFLINE_INVALID   (0x1UL << 0)
400
401#define PG_OFFLINE_OFFLINED  (0x1UL << 1)
402#define PG_OFFLINE_PENDING   (0x1UL << 2)
403#define PG_OFFLINE_FAILED    (0x1UL << 3)
404#define PG_OFFLINE_AGAIN     (0x1UL << 4)
405
406#define PG_ONLINE_FAILED     PG_OFFLINE_FAILED
407#define PG_ONLINE_ONLINED    PG_OFFLINE_OFFLINED
408
409#define PG_OFFLINE_STATUS_OFFLINED              (0x1UL << 1)
410#define PG_OFFLINE_STATUS_ONLINE                (0x1UL << 2)
411#define PG_OFFLINE_STATUS_OFFLINE_PENDING       (0x1UL << 3)
412#define PG_OFFLINE_STATUS_BROKEN                (0x1UL << 4)
413
414#define PG_OFFLINE_MISC_MASK    (0xFFUL << 4)
415
416/* valid when PG_OFFLINE_FAILED or PG_OFFLINE_PENDING */
417#define PG_OFFLINE_XENPAGE   (0x1UL << 8)
418#define PG_OFFLINE_DOM0PAGE  (0x1UL << 9)
419#define PG_OFFLINE_ANONYMOUS (0x1UL << 10)
420#define PG_OFFLINE_NOT_CONV_RAM   (0x1UL << 11)
421#define PG_OFFLINE_OWNED     (0x1UL << 12)
422
423#define PG_OFFLINE_BROKEN    (0x1UL << 13)
424#define PG_ONLINE_BROKEN     PG_OFFLINE_BROKEN
425
426#define PG_OFFLINE_OWNER_SHIFT 16
427
428/* XEN_SYSCTL_lockprof_op */
429/* Sub-operations: */
430#define XEN_SYSCTL_LOCKPROF_reset 1   /* Reset all profile data to zero. */
431#define XEN_SYSCTL_LOCKPROF_query 2   /* Get lock profile information. */
432/* Record-type: */
433#define LOCKPROF_TYPE_GLOBAL      0   /* global lock, idx meaningless */
434#define LOCKPROF_TYPE_PERDOM      1   /* per-domain lock, idx is domid */
435#define LOCKPROF_TYPE_N           2   /* number of types */
436struct xen_sysctl_lockprof_data {
437    char     name[40];     /* lock name (may include up to 2 %d specifiers) */
438    int32_t  type;         /* LOCKPROF_TYPE_??? */
439    int32_t  idx;          /* index (e.g. domain id) */
440    uint64_aligned_t lock_cnt;     /* # of locking succeeded */
441    uint64_aligned_t block_cnt;    /* # of wait for lock */
442    uint64_aligned_t lock_time;    /* nsecs lock held */
443    uint64_aligned_t block_time;   /* nsecs waited for lock */
444};
445typedef struct xen_sysctl_lockprof_data xen_sysctl_lockprof_data_t;
446DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockprof_data_t);
447struct xen_sysctl_lockprof_op {
448    /* IN variables. */
449    uint32_t       cmd;               /* XEN_SYSCTL_LOCKPROF_??? */
450    uint32_t       max_elem;          /* size of output buffer */
451    /* OUT variables (query only). */
452    uint32_t       nr_elem;           /* number of elements available */
453    uint64_aligned_t time;            /* nsecs of profile measurement */
454    /* profile information (or NULL) */
455    XEN_GUEST_HANDLE_64(xen_sysctl_lockprof_data_t) data;
456};
457typedef struct xen_sysctl_lockprof_op xen_sysctl_lockprof_op_t;
458DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockprof_op_t);
459
460/* XEN_SYSCTL_topologyinfo */
461#define INVALID_TOPOLOGY_ID  (~0U)
462struct xen_sysctl_topologyinfo {
463    /*
464     * IN: maximum addressable entry in the caller-provided arrays.
465     * OUT: largest cpu identifier in the system.
466     * If OUT is greater than IN then the arrays are truncated!
467     * If OUT is leass than IN then the array tails are not written by sysctl.
468     */
469    uint32_t max_cpu_index;
470
471    /*
472     * If not NULL, these arrays are filled with core/socket/node identifier
473     * for each cpu.
474     * If a cpu has no core/socket/node information (e.g., cpu not present)
475     * then the sentinel value ~0u is written to each array.
476     * The number of array elements written by the sysctl is:
477     *   min(@max_cpu_index_IN,@max_cpu_index_OUT)+1
478     */
479    XEN_GUEST_HANDLE_64(uint32) cpu_to_core;
480    XEN_GUEST_HANDLE_64(uint32) cpu_to_socket;
481    XEN_GUEST_HANDLE_64(uint32) cpu_to_node;
482};
483typedef struct xen_sysctl_topologyinfo xen_sysctl_topologyinfo_t;
484DEFINE_XEN_GUEST_HANDLE(xen_sysctl_topologyinfo_t);
485
486/* XEN_SYSCTL_numainfo */
487#define INVALID_NUMAINFO_ID (~0U)
488struct xen_sysctl_numainfo {
489    /*
490     * IN: maximum addressable entry in the caller-provided arrays.
491     * OUT: largest node identifier in the system.
492     * If OUT is greater than IN then the arrays are truncated!
493     */
494    uint32_t max_node_index;
495
496    /* NB. Entries are 0 if node is not present. */
497    XEN_GUEST_HANDLE_64(uint64) node_to_memsize;
498    XEN_GUEST_HANDLE_64(uint64) node_to_memfree;
499
500    /*
501     * Array, of size (max_node_index+1)^2, listing memory access distances
502     * between nodes. If an entry has no node distance information (e.g., node
503     * not present) then the value ~0u is written.
504     *
505     * Note that the array rows must be indexed by multiplying by the minimum
506     * of the caller-provided max_node_index and the returned value of
507     * max_node_index. That is, if the largest node index in the system is
508     * smaller than the caller can handle, a smaller 2-d array is constructed
509     * within the space provided by the caller. When this occurs, trailing
510     * space provided by the caller is not modified. If the largest node index
511     * in the system is larger than the caller can handle, then a 2-d array of
512     * the maximum size handleable by the caller is constructed.
513     */
514    XEN_GUEST_HANDLE_64(uint32) node_to_node_distance;
515};
516typedef struct xen_sysctl_numainfo xen_sysctl_numainfo_t;
517DEFINE_XEN_GUEST_HANDLE(xen_sysctl_numainfo_t);
518
519/* XEN_SYSCTL_cpupool_op */
520#define XEN_SYSCTL_CPUPOOL_OP_CREATE                1  /* C */
521#define XEN_SYSCTL_CPUPOOL_OP_DESTROY               2  /* D */
522#define XEN_SYSCTL_CPUPOOL_OP_INFO                  3  /* I */
523#define XEN_SYSCTL_CPUPOOL_OP_ADDCPU                4  /* A */
524#define XEN_SYSCTL_CPUPOOL_OP_RMCPU                 5  /* R */
525#define XEN_SYSCTL_CPUPOOL_OP_MOVEDOMAIN            6  /* M */
526#define XEN_SYSCTL_CPUPOOL_OP_FREEINFO              7  /* F */
527#define XEN_SYSCTL_CPUPOOL_PAR_ANY     0xFFFFFFFF
528struct xen_sysctl_cpupool_op {
529    uint32_t op;          /* IN */
530    uint32_t cpupool_id;  /* IN: CDIARM OUT: CI */
531    uint32_t sched_id;    /* IN: C      OUT: I  */
532    uint32_t domid;       /* IN: M              */
533    uint32_t cpu;         /* IN: AR             */
534    uint32_t n_dom;       /*            OUT: I  */
535    struct xenctl_cpumap cpumap; /*     OUT: IF */
536};
537typedef struct xen_sysctl_cpupool_op xen_sysctl_cpupool_op_t;
538DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpupool_op_t);
539
540#define ARINC653_MAX_DOMAINS_PER_SCHEDULE   64
541/*
542 * This structure is used to pass a new ARINC653 schedule from a
543 * privileged domain (ie dom0) to Xen.
544 */
545struct xen_sysctl_arinc653_schedule {
546    /* major_frame holds the time for the new schedule's major frame
547     * in nanoseconds. */
548    uint64_aligned_t     major_frame;
549    /* num_sched_entries holds how many of the entries in the
550     * sched_entries[] array are valid. */
551    uint8_t     num_sched_entries;
552    /* The sched_entries array holds the actual schedule entries. */
553    struct {
554        /* dom_handle must match a domain's UUID */
555        xen_domain_handle_t dom_handle;
556        /* If a domain has multiple VCPUs, vcpu_id specifies which one
557         * this schedule entry applies to. It should be set to 0 if
558         * there is only one VCPU for the domain. */
559        unsigned int vcpu_id;
560        /* runtime specifies the amount of time that should be allocated
561         * to this VCPU per major frame. It is specified in nanoseconds */
562        uint64_aligned_t runtime;
563    } sched_entries[ARINC653_MAX_DOMAINS_PER_SCHEDULE];
564};
565typedef struct xen_sysctl_arinc653_schedule xen_sysctl_arinc653_schedule_t;
566DEFINE_XEN_GUEST_HANDLE(xen_sysctl_arinc653_schedule_t);
567
568struct xen_sysctl_credit_schedule {
569    /* Length of timeslice in milliseconds */
570#define XEN_SYSCTL_CSCHED_TSLICE_MAX 1000
571#define XEN_SYSCTL_CSCHED_TSLICE_MIN 1
572    unsigned tslice_ms;
573    /* Rate limit (minimum timeslice) in microseconds */
574#define XEN_SYSCTL_SCHED_RATELIMIT_MAX 500000
575#define XEN_SYSCTL_SCHED_RATELIMIT_MIN 100
576    unsigned ratelimit_us;
577};
578typedef struct xen_sysctl_credit_schedule xen_sysctl_credit_schedule_t;
579DEFINE_XEN_GUEST_HANDLE(xen_sysctl_credit_schedule_t);
580
581/* XEN_SYSCTL_scheduler_op */
582/* Set or get info? */
583#define XEN_SYSCTL_SCHEDOP_putinfo 0
584#define XEN_SYSCTL_SCHEDOP_getinfo 1
585struct xen_sysctl_scheduler_op {
586    uint32_t cpupool_id; /* Cpupool whose scheduler is to be targetted. */
587    uint32_t sched_id;   /* XEN_SCHEDULER_* (domctl.h) */
588    uint32_t cmd;        /* XEN_SYSCTL_SCHEDOP_* */
589    union {
590        struct xen_sysctl_sched_arinc653 {
591            XEN_GUEST_HANDLE_64(xen_sysctl_arinc653_schedule_t) schedule;
592        } sched_arinc653;
593        struct xen_sysctl_credit_schedule sched_credit;
594    } u;
595};
596typedef struct xen_sysctl_scheduler_op xen_sysctl_scheduler_op_t;
597DEFINE_XEN_GUEST_HANDLE(xen_sysctl_scheduler_op_t);
598
599struct xen_sysctl {
600    uint32_t cmd;
601#define XEN_SYSCTL_readconsole                    1
602#define XEN_SYSCTL_tbuf_op                        2
603#define XEN_SYSCTL_physinfo                       3
604#define XEN_SYSCTL_sched_id                       4
605#define XEN_SYSCTL_perfc_op                       5
606#define XEN_SYSCTL_getdomaininfolist              6
607#define XEN_SYSCTL_debug_keys                     7
608#define XEN_SYSCTL_getcpuinfo                     8
609#define XEN_SYSCTL_availheap                      9
610#define XEN_SYSCTL_get_pmstat                    10
611#define XEN_SYSCTL_cpu_hotplug                   11
612#define XEN_SYSCTL_pm_op                         12
613#define XEN_SYSCTL_page_offline_op               14
614#define XEN_SYSCTL_lockprof_op                   15
615#define XEN_SYSCTL_topologyinfo                  16
616#define XEN_SYSCTL_numainfo                      17
617#define XEN_SYSCTL_cpupool_op                    18
618#define XEN_SYSCTL_scheduler_op                  19
619    uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
620    union {
621        struct xen_sysctl_readconsole       readconsole;
622        struct xen_sysctl_tbuf_op           tbuf_op;
623        struct xen_sysctl_physinfo          physinfo;
624        struct xen_sysctl_topologyinfo      topologyinfo;
625        struct xen_sysctl_numainfo          numainfo;
626        struct xen_sysctl_sched_id          sched_id;
627        struct xen_sysctl_perfc_op          perfc_op;
628        struct xen_sysctl_getdomaininfolist getdomaininfolist;
629        struct xen_sysctl_debug_keys        debug_keys;
630        struct xen_sysctl_getcpuinfo        getcpuinfo;
631        struct xen_sysctl_availheap         availheap;
632        struct xen_sysctl_get_pmstat        get_pmstat;
633        struct xen_sysctl_cpu_hotplug       cpu_hotplug;
634        struct xen_sysctl_pm_op             pm_op;
635        struct xen_sysctl_page_offline_op   page_offline;
636        struct xen_sysctl_lockprof_op       lockprof_op;
637        struct xen_sysctl_cpupool_op        cpupool_op;
638        struct xen_sysctl_scheduler_op      scheduler_op;
639        uint8_t                             pad[128];
640    } u;
641};
642typedef struct xen_sysctl xen_sysctl_t;
643DEFINE_XEN_GUEST_HANDLE(xen_sysctl_t);
644
645#endif /* __XEN_PUBLIC_SYSCTL_H__ */
646
647/*
648 * Local variables:
649 * mode: C
650 * c-set-style: "BSD"
651 * c-basic-offset: 4
652 * tab-width: 4
653 * indent-tabs-mode: nil
654 * End:
655 */
656