xref: /illumos-gate/usr/src/uts/common/xen/public/sysctl.h (revision e7cbe64f7a72dae5cb44f100db60ca88f3313c65)
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 pad[4];
74     /* IN/OUT variables */
75     struct xenctl_cpumap cpu_mask;
76     uint32_t             evt_mask;
77     /* OUT variables */
78     uint64_aligned_t buffer_mfn;
79     uint32_t size;
80 };
81 typedef struct xen_sysctl_tbuf_op xen_sysctl_tbuf_op_t;
82 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_tbuf_op_t);
83 
84 /*
85  * Get physical information about the host machine
86  */
87 #define XEN_SYSCTL_physinfo          3
88 struct xen_sysctl_physinfo {
89     uint32_t threads_per_core;
90     uint32_t cores_per_socket;
91     uint32_t sockets_per_node;
92     uint32_t nr_nodes;
93     uint32_t cpu_khz;
94     uint8_t  pad[4];
95     uint64_aligned_t total_pages;
96     uint64_aligned_t free_pages;
97     uint64_aligned_t scrub_pages;
98     uint32_t hw_cap[8];
99 };
100 typedef struct xen_sysctl_physinfo xen_sysctl_physinfo_t;
101 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_physinfo_t);
102 
103 /*
104  * Get the ID of the current scheduler.
105  */
106 #define XEN_SYSCTL_sched_id          4
107 struct xen_sysctl_sched_id {
108     /* OUT variable */
109     uint32_t sched_id;
110 };
111 typedef struct xen_sysctl_sched_id xen_sysctl_sched_id_t;
112 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_sched_id_t);
113 
114 /* Interface for controlling Xen software performance counters. */
115 #define XEN_SYSCTL_perfc_op          5
116 /* Sub-operations: */
117 #define XEN_SYSCTL_PERFCOP_reset 1   /* Reset all counters to zero. */
118 #define XEN_SYSCTL_PERFCOP_query 2   /* Get perfctr information. */
119 struct xen_sysctl_perfc_desc {
120     char         name[80];             /* name of perf counter */
121     uint32_t     nr_vals;              /* number of values for this counter */
122 };
123 typedef struct xen_sysctl_perfc_desc xen_sysctl_perfc_desc_t;
124 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t);
125 typedef uint32_t xen_sysctl_perfc_val_t;
126 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_val_t);
127 
128 struct xen_sysctl_perfc_op {
129     /* IN variables. */
130     uint32_t       cmd;                /*  XEN_SYSCTL_PERFCOP_??? */
131     /* OUT variables. */
132     uint32_t       nr_counters;       /*  number of counters description  */
133     uint32_t       nr_vals;           /*  number of values  */
134     uint8_t        pad[4];
135     /* counter information (or NULL) */
136     XEN_GUEST_HANDLE_64(xen_sysctl_perfc_desc_t) desc;
137     /* counter values (or NULL) */
138     XEN_GUEST_HANDLE_64(xen_sysctl_perfc_val_t) val;
139 };
140 typedef struct xen_sysctl_perfc_op xen_sysctl_perfc_op_t;
141 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_op_t);
142 
143 #define XEN_SYSCTL_getdomaininfolist 6
144 struct xen_sysctl_getdomaininfolist {
145     /* IN variables. */
146     domid_t               first_domain;
147     uint8_t               pad1[2];
148     uint32_t              max_domains;
149     XEN_GUEST_HANDLE_64(xen_domctl_getdomaininfo_t) buffer;
150     /* OUT variables. */
151     uint32_t              num_domains;
152     uint8_t               pad2[4];
153 };
154 typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
155 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
156 
157 /* Inject debug keys into Xen. */
158 #define XEN_SYSCTL_debug_keys        7
159 struct xen_sysctl_debug_keys {
160     /* IN variables. */
161     XEN_GUEST_HANDLE_64(char) keys;
162     uint32_t nr_keys;
163     uint8_t pad[4];
164 };
165 typedef struct xen_sysctl_debug_keys xen_sysctl_debug_keys_t;
166 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_debug_keys_t);
167 
168 /* Get physical CPU information. */
169 #define XEN_SYSCTL_getcpuinfo        8
170 struct xen_sysctl_cpuinfo {
171     uint64_t idletime;
172 };
173 typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;
174 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t);
175 struct xen_sysctl_getcpuinfo {
176     /* IN variables. */
177     uint32_t max_cpus;
178     uint8_t  pad1[4];
179     XEN_GUEST_HANDLE_64(xen_sysctl_cpuinfo_t) info;
180     /* OUT variables. */
181     uint32_t nr_cpus;
182     uint8_t  pad2[4];
183 };
184 typedef struct xen_sysctl_getcpuinfo xen_sysctl_getcpuinfo_t;
185 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getcpuinfo_t);
186 
187 struct xen_sysctl {
188     uint32_t cmd;
189     uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
190     union {
191         struct xen_sysctl_readconsole       readconsole;
192         struct xen_sysctl_tbuf_op           tbuf_op;
193         struct xen_sysctl_physinfo          physinfo;
194         struct xen_sysctl_sched_id          sched_id;
195         struct xen_sysctl_perfc_op          perfc_op;
196         struct xen_sysctl_getdomaininfolist getdomaininfolist;
197         struct xen_sysctl_debug_keys        debug_keys;
198         struct xen_sysctl_getcpuinfo        getcpuinfo;
199         uint8_t                             pad[128];
200     } u;
201 };
202 typedef struct xen_sysctl xen_sysctl_t;
203 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_t);
204 
205 #endif /* __XEN_PUBLIC_SYSCTL_H__ */
206 
207 /*
208  * Local variables:
209  * mode: C
210  * c-set-style: "BSD"
211  * c-basic-offset: 4
212  * tab-width: 4
213  * indent-tabs-mode: nil
214  * End:
215  */
216