xref: /titanic_51/usr/src/uts/common/xen/public/sysctl.h (revision cf5b5989488984444a152faba2a8183a71dcf485)
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 0x00000002
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     XEN_GUEST_HANDLE(char) buffer; /* Buffer start */
54     /* IN/OUT variables. */
55     uint32_t count;            /* In: Buffer size;  Out: Used buffer size  */
56 };
57 typedef struct xen_sysctl_readconsole xen_sysctl_readconsole_t;
58 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_readconsole_t);
59 
60 /* Get trace buffers machine base address */
61 #define XEN_SYSCTL_tbuf_op           2
62 struct xen_sysctl_tbuf_op {
63     /* IN variables */
64 #define XEN_SYSCTL_TBUFOP_get_info     0
65 #define XEN_SYSCTL_TBUFOP_set_cpu_mask 1
66 #define XEN_SYSCTL_TBUFOP_set_evt_mask 2
67 #define XEN_SYSCTL_TBUFOP_set_size     3
68 #define XEN_SYSCTL_TBUFOP_enable       4
69 #define XEN_SYSCTL_TBUFOP_disable      5
70     uint32_t cmd;
71     /* IN/OUT variables */
72     struct xenctl_cpumap cpu_mask;
73     uint32_t             evt_mask;
74     /* OUT variables */
75     uint64_t buffer_mfn;
76     uint32_t size;
77 };
78 typedef struct xen_sysctl_tbuf_op xen_sysctl_tbuf_op_t;
79 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_tbuf_op_t);
80 
81 /*
82  * Get physical information about the host machine
83  */
84 #define XEN_SYSCTL_physinfo          3
85 struct xen_sysctl_physinfo {
86     uint32_t threads_per_core;
87     uint32_t cores_per_socket;
88     uint32_t sockets_per_node;
89     uint32_t nr_nodes;
90     uint32_t cpu_khz;
91     uint64_t total_pages;
92     uint64_t free_pages;
93     uint64_t scrub_pages;
94     uint32_t hw_cap[8];
95 };
96 typedef struct xen_sysctl_physinfo xen_sysctl_physinfo_t;
97 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_physinfo_t);
98 
99 /*
100  * Get the ID of the current scheduler.
101  */
102 #define XEN_SYSCTL_sched_id          4
103 struct xen_sysctl_sched_id {
104     /* OUT variable */
105     uint32_t sched_id;
106 };
107 typedef struct xen_sysctl_sched_id xen_sysctl_sched_id_t;
108 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_sched_id_t);
109 
110 /* Interface for controlling Xen software performance counters. */
111 #define XEN_SYSCTL_perfc_op          5
112 /* Sub-operations: */
113 #define XEN_SYSCTL_PERFCOP_reset 1   /* Reset all counters to zero. */
114 #define XEN_SYSCTL_PERFCOP_query 2   /* Get perfctr information. */
115 struct xen_sysctl_perfc_desc {
116     char         name[80];             /* name of perf counter */
117     uint32_t     nr_vals;              /* number of values for this counter */
118 };
119 typedef struct xen_sysctl_perfc_desc xen_sysctl_perfc_desc_t;
120 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t);
121 typedef uint32_t xen_sysctl_perfc_val_t;
122 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_val_t);
123 
124 struct xen_sysctl_perfc_op {
125     /* IN variables. */
126     uint32_t       cmd;                /*  XEN_SYSCTL_PERFCOP_??? */
127     /* OUT variables. */
128     uint32_t       nr_counters;       /*  number of counters description  */
129     uint32_t       nr_vals;           /*  number of values  */
130     /* counter information (or NULL) */
131     XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t) desc;
132     /* counter values (or NULL) */
133     XEN_GUEST_HANDLE(xen_sysctl_perfc_val_t) val;
134 };
135 typedef struct xen_sysctl_perfc_op xen_sysctl_perfc_op_t;
136 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_op_t);
137 
138 #define XEN_SYSCTL_getdomaininfolist 6
139 struct xen_sysctl_getdomaininfolist {
140     /* IN variables. */
141     domid_t               first_domain;
142     uint32_t              max_domains;
143     XEN_GUEST_HANDLE(xen_domctl_getdomaininfo_t) buffer;
144     /* OUT variables. */
145     uint32_t              num_domains;
146 };
147 typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
148 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
149 
150 struct xen_sysctl {
151     uint32_t cmd;
152     uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
153     union {
154         struct xen_sysctl_readconsole       readconsole;
155         struct xen_sysctl_tbuf_op           tbuf_op;
156         struct xen_sysctl_physinfo          physinfo;
157         struct xen_sysctl_sched_id          sched_id;
158         struct xen_sysctl_perfc_op          perfc_op;
159         struct xen_sysctl_getdomaininfolist getdomaininfolist;
160         uint8_t                             pad[128];
161     } u;
162 };
163 typedef struct xen_sysctl xen_sysctl_t;
164 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_t);
165 
166 #endif /* __XEN_PUBLIC_SYSCTL_H__ */
167 
168 /*
169  * Local variables:
170  * mode: C
171  * c-set-style: "BSD"
172  * c-basic-offset: 4
173  * tab-width: 4
174  * indent-tabs-mode: nil
175  * End:
176  */
177