xref: /illumos-gate/usr/src/uts/common/xen/public/sysctl.h (revision 4764d912222e53f8386bae7bf491f5780fd102ec)
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 /*
31  * XXPV - We need sysctl (physinfo) in the solaris kernel.
32  */
33 #if 0
34 
35 #if !defined(__XEN__) && !defined(__XEN_TOOLS__)
36 #error "sysctl operations are intended for use by node control tools only"
37 #endif
38 
39 #endif /* XXPV */
40 
41 #include "xen.h"
42 #include "domctl.h"
43 
44 #define XEN_SYSCTL_INTERFACE_VERSION 0x00000003
45 
46 /*
47  * Read console content from Xen buffer ring.
48  */
49 #define XEN_SYSCTL_readconsole       1
50 struct xen_sysctl_readconsole {
51     /* IN variables. */
52     uint32_t clear;                /* Non-zero -> clear after reading. */
53     uint8_t  pad1[4];
54     XEN_GUEST_HANDLE_64(char) buffer; /* Buffer start */
55     /* IN/OUT variables. */
56     uint32_t count;            /* In: Buffer size;  Out: Used buffer size  */
57     uint8_t pad2[4];
58 };
59 typedef struct xen_sysctl_readconsole xen_sysctl_readconsole_t;
60 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_readconsole_t);
61 
62 /* Get trace buffers machine base address */
63 #define XEN_SYSCTL_tbuf_op           2
64 struct 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     uint8_t pad1[4];
74     /* IN/OUT variables */
75     struct xenctl_cpumap cpu_mask;
76     uint32_t             evt_mask;
77     uint8_t pad2[4];
78     /* OUT variables */
79     uint64_aligned_t buffer_mfn;
80     uint32_t size;
81 };
82 typedef struct xen_sysctl_tbuf_op xen_sysctl_tbuf_op_t;
83 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_tbuf_op_t);
84 
85 /*
86  * Get physical information about the host machine
87  */
88 #define XEN_SYSCTL_physinfo          3
89 struct xen_sysctl_physinfo {
90     uint32_t threads_per_core;
91     uint32_t cores_per_socket;
92     uint32_t sockets_per_node;
93     uint32_t nr_nodes;
94     uint32_t cpu_khz;
95     uint8_t  pad[4];
96     uint64_aligned_t total_pages;
97     uint64_aligned_t free_pages;
98     uint64_aligned_t scrub_pages;
99     uint32_t hw_cap[8];
100 };
101 typedef struct xen_sysctl_physinfo xen_sysctl_physinfo_t;
102 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_physinfo_t);
103 
104 /*
105  * Get the ID of the current scheduler.
106  */
107 #define XEN_SYSCTL_sched_id          4
108 struct xen_sysctl_sched_id {
109     /* OUT variable */
110     uint32_t sched_id;
111 };
112 typedef struct xen_sysctl_sched_id xen_sysctl_sched_id_t;
113 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_sched_id_t);
114 
115 /* Interface for controlling Xen software performance counters. */
116 #define XEN_SYSCTL_perfc_op          5
117 /* Sub-operations: */
118 #define XEN_SYSCTL_PERFCOP_reset 1   /* Reset all counters to zero. */
119 #define XEN_SYSCTL_PERFCOP_query 2   /* Get perfctr information. */
120 struct xen_sysctl_perfc_desc {
121     char         name[80];             /* name of perf counter */
122     uint32_t     nr_vals;              /* number of values for this counter */
123 };
124 typedef struct xen_sysctl_perfc_desc xen_sysctl_perfc_desc_t;
125 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t);
126 typedef uint32_t xen_sysctl_perfc_val_t;
127 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_val_t);
128 
129 struct xen_sysctl_perfc_op {
130     /* IN variables. */
131     uint32_t       cmd;                /*  XEN_SYSCTL_PERFCOP_??? */
132     /* OUT variables. */
133     uint32_t       nr_counters;       /*  number of counters description  */
134     uint32_t       nr_vals;           /*  number of values  */
135     uint8_t        pad[4];
136     /* counter information (or NULL) */
137     XEN_GUEST_HANDLE_64(xen_sysctl_perfc_desc_t) desc;
138     /* counter values (or NULL) */
139     XEN_GUEST_HANDLE_64(xen_sysctl_perfc_val_t) val;
140 };
141 typedef struct xen_sysctl_perfc_op xen_sysctl_perfc_op_t;
142 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_op_t);
143 
144 #define XEN_SYSCTL_getdomaininfolist 6
145 struct xen_sysctl_getdomaininfolist {
146     /* IN variables. */
147     domid_t               first_domain;
148     uint8_t               pad1[2];
149     uint32_t              max_domains;
150     XEN_GUEST_HANDLE_64(xen_domctl_getdomaininfo_t) buffer;
151     /* OUT variables. */
152     uint32_t              num_domains;
153     uint8_t               pad2[4];
154 };
155 typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
156 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
157 
158 /* Inject debug keys into Xen. */
159 #define XEN_SYSCTL_debug_keys        7
160 struct xen_sysctl_debug_keys {
161     /* IN variables. */
162     XEN_GUEST_HANDLE_64(char) keys;
163     uint32_t nr_keys;
164     uint8_t pad[4];
165 };
166 typedef struct xen_sysctl_debug_keys xen_sysctl_debug_keys_t;
167 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_debug_keys_t);
168 
169 /* Get physical CPU information. */
170 #define XEN_SYSCTL_getcpuinfo        8
171 struct xen_sysctl_cpuinfo {
172     uint64_t idletime;
173 };
174 typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;
175 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t);
176 struct xen_sysctl_getcpuinfo {
177     /* IN variables. */
178     uint32_t max_cpus;
179     uint8_t  pad1[4];
180     XEN_GUEST_HANDLE_64(xen_sysctl_cpuinfo_t) info;
181     /* OUT variables. */
182     uint32_t nr_cpus;
183     uint8_t  pad2[4];
184 };
185 typedef struct xen_sysctl_getcpuinfo xen_sysctl_getcpuinfo_t;
186 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getcpuinfo_t);
187 
188 struct xen_sysctl {
189     uint32_t cmd;
190     uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
191     union {
192         struct xen_sysctl_readconsole       readconsole;
193         struct xen_sysctl_tbuf_op           tbuf_op;
194         struct xen_sysctl_physinfo          physinfo;
195         struct xen_sysctl_sched_id          sched_id;
196         struct xen_sysctl_perfc_op          perfc_op;
197         struct xen_sysctl_getdomaininfolist getdomaininfolist;
198         struct xen_sysctl_debug_keys        debug_keys;
199         struct xen_sysctl_getcpuinfo        getcpuinfo;
200         uint8_t                             pad[128];
201     } u;
202 };
203 typedef struct xen_sysctl xen_sysctl_t;
204 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_t);
205 
206 #endif /* __XEN_PUBLIC_SYSCTL_H__ */
207 
208 /*
209  * Local variables:
210  * mode: C
211  * c-set-style: "BSD"
212  * c-basic-offset: 4
213  * tab-width: 4
214  * indent-tabs-mode: nil
215  * End:
216  */
217