sysctl.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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. #ifndef __XEN_PUBLIC_SYSCTL_H__
  27. #define __XEN_PUBLIC_SYSCTL_H__
  28. #if !defined(__XEN__) && !defined(__XEN_TOOLS__)
  29. #error "sysctl operations are intended for use by node control tools only"
  30. #endif
  31. #include "xen.h"
  32. #include "domctl.h"
  33. #define XEN_SYSCTL_INTERFACE_VERSION 0x00000006
  34. /*
  35. * Read console content from Xen buffer ring.
  36. */
  37. #define XEN_SYSCTL_readconsole 1
  38. struct xen_sysctl_readconsole {
  39. /* IN: Non-zero -> clear after reading. */
  40. uint8_t clear;
  41. /* IN: Non-zero -> start index specified by @index field. */
  42. uint8_t incremental;
  43. uint8_t pad0, pad1;
  44. /*
  45. * IN: Start index for consuming from ring buffer (if @incremental);
  46. * OUT: End index after consuming from ring buffer.
  47. */
  48. uint32_t index;
  49. /* IN: Virtual address to write console data. */
  50. XEN_GUEST_HANDLE_64(char) buffer;
  51. /* IN: Size of buffer; OUT: Bytes written to buffer. */
  52. uint32_t count;
  53. };
  54. typedef struct xen_sysctl_readconsole xen_sysctl_readconsole_t;
  55. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_readconsole_t);
  56. /* Get trace buffers machine base address */
  57. #define XEN_SYSCTL_tbuf_op 2
  58. struct xen_sysctl_tbuf_op {
  59. /* IN variables */
  60. #define XEN_SYSCTL_TBUFOP_get_info 0
  61. #define XEN_SYSCTL_TBUFOP_set_cpu_mask 1
  62. #define XEN_SYSCTL_TBUFOP_set_evt_mask 2
  63. #define XEN_SYSCTL_TBUFOP_set_size 3
  64. #define XEN_SYSCTL_TBUFOP_enable 4
  65. #define XEN_SYSCTL_TBUFOP_disable 5
  66. uint32_t cmd;
  67. /* IN/OUT variables */
  68. struct xenctl_cpumap cpu_mask;
  69. uint32_t evt_mask;
  70. /* OUT variables */
  71. uint64_aligned_t buffer_mfn;
  72. uint32_t size;
  73. };
  74. typedef struct xen_sysctl_tbuf_op xen_sysctl_tbuf_op_t;
  75. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_tbuf_op_t);
  76. /*
  77. * Get physical information about the host machine
  78. */
  79. #define XEN_SYSCTL_physinfo 3
  80. /* (x86) The platform supports HVM guests. */
  81. #define _XEN_SYSCTL_PHYSCAP_hvm 0
  82. #define XEN_SYSCTL_PHYSCAP_hvm (1u<<_XEN_SYSCTL_PHYSCAP_hvm)
  83. /* (x86) The platform supports HVM-guest direct access to I/O devices. */
  84. #define _XEN_SYSCTL_PHYSCAP_hvm_directio 1
  85. #define XEN_SYSCTL_PHYSCAP_hvm_directio (1u<<_XEN_SYSCTL_PHYSCAP_hvm_directio)
  86. struct xen_sysctl_physinfo {
  87. uint32_t threads_per_core;
  88. uint32_t cores_per_socket;
  89. uint32_t nr_cpus;
  90. uint32_t nr_nodes;
  91. uint32_t cpu_khz;
  92. uint64_aligned_t total_pages;
  93. uint64_aligned_t free_pages;
  94. uint64_aligned_t scrub_pages;
  95. uint32_t hw_cap[8];
  96. /*
  97. * IN: maximum addressable entry in the caller-provided cpu_to_node array.
  98. * OUT: largest cpu identifier in the system.
  99. * If OUT is greater than IN then the cpu_to_node array is truncated!
  100. */
  101. uint32_t max_cpu_id;
  102. /*
  103. * If not NULL, this array is filled with node identifier for each cpu.
  104. * If a cpu has no node information (e.g., cpu not present) then the
  105. * sentinel value ~0u is written.
  106. * The size of this array is specified by the caller in @max_cpu_id.
  107. * If the actual @max_cpu_id is smaller than the array then the trailing
  108. * elements of the array will not be written by the sysctl.
  109. */
  110. XEN_GUEST_HANDLE_64(uint32) cpu_to_node;
  111. /* XEN_SYSCTL_PHYSCAP_??? */
  112. uint32_t capabilities;
  113. };
  114. typedef struct xen_sysctl_physinfo xen_sysctl_physinfo_t;
  115. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_physinfo_t);
  116. /*
  117. * Get the ID of the current scheduler.
  118. */
  119. #define XEN_SYSCTL_sched_id 4
  120. struct xen_sysctl_sched_id {
  121. /* OUT variable */
  122. uint32_t sched_id;
  123. };
  124. typedef struct xen_sysctl_sched_id xen_sysctl_sched_id_t;
  125. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_sched_id_t);
  126. /* Interface for controlling Xen software performance counters. */
  127. #define XEN_SYSCTL_perfc_op 5
  128. /* Sub-operations: */
  129. #define XEN_SYSCTL_PERFCOP_reset 1 /* Reset all counters to zero. */
  130. #define XEN_SYSCTL_PERFCOP_query 2 /* Get perfctr information. */
  131. struct xen_sysctl_perfc_desc {
  132. char name[80]; /* name of perf counter */
  133. uint32_t nr_vals; /* number of values for this counter */
  134. };
  135. typedef struct xen_sysctl_perfc_desc xen_sysctl_perfc_desc_t;
  136. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t);
  137. typedef uint32_t xen_sysctl_perfc_val_t;
  138. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_val_t);
  139. struct xen_sysctl_perfc_op {
  140. /* IN variables. */
  141. uint32_t cmd; /* XEN_SYSCTL_PERFCOP_??? */
  142. /* OUT variables. */
  143. uint32_t nr_counters; /* number of counters description */
  144. uint32_t nr_vals; /* number of values */
  145. /* counter information (or NULL) */
  146. XEN_GUEST_HANDLE_64(xen_sysctl_perfc_desc_t) desc;
  147. /* counter values (or NULL) */
  148. XEN_GUEST_HANDLE_64(xen_sysctl_perfc_val_t) val;
  149. };
  150. typedef struct xen_sysctl_perfc_op xen_sysctl_perfc_op_t;
  151. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_op_t);
  152. #define XEN_SYSCTL_getdomaininfolist 6
  153. struct xen_sysctl_getdomaininfolist {
  154. /* IN variables. */
  155. domid_t first_domain;
  156. uint32_t max_domains;
  157. XEN_GUEST_HANDLE_64(xen_domctl_getdomaininfo_t) buffer;
  158. /* OUT variables. */
  159. uint32_t num_domains;
  160. };
  161. typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
  162. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
  163. /* Inject debug keys into Xen. */
  164. #define XEN_SYSCTL_debug_keys 7
  165. struct xen_sysctl_debug_keys {
  166. /* IN variables. */
  167. XEN_GUEST_HANDLE_64(char) keys;
  168. uint32_t nr_keys;
  169. };
  170. typedef struct xen_sysctl_debug_keys xen_sysctl_debug_keys_t;
  171. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_debug_keys_t);
  172. /* Get physical CPU information. */
  173. #define XEN_SYSCTL_getcpuinfo 8
  174. struct xen_sysctl_cpuinfo {
  175. uint64_aligned_t idletime;
  176. };
  177. typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;
  178. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t);
  179. struct xen_sysctl_getcpuinfo {
  180. /* IN variables. */
  181. uint32_t max_cpus;
  182. XEN_GUEST_HANDLE_64(xen_sysctl_cpuinfo_t) info;
  183. /* OUT variables. */
  184. uint32_t nr_cpus;
  185. };
  186. typedef struct xen_sysctl_getcpuinfo xen_sysctl_getcpuinfo_t;
  187. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getcpuinfo_t);
  188. #define XEN_SYSCTL_availheap 9
  189. struct xen_sysctl_availheap {
  190. /* IN variables. */
  191. uint32_t min_bitwidth; /* Smallest address width (zero if don't care). */
  192. uint32_t max_bitwidth; /* Largest address width (zero if don't care). */
  193. int32_t node; /* NUMA node of interest (-1 for all nodes). */
  194. /* OUT variables. */
  195. uint64_aligned_t avail_bytes;/* Bytes available in the specified region. */
  196. };
  197. typedef struct xen_sysctl_availheap xen_sysctl_availheap_t;
  198. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_availheap_t);
  199. #define XEN_SYSCTL_get_pmstat 10
  200. struct pm_px_val {
  201. uint64_aligned_t freq; /* Px core frequency */
  202. uint64_aligned_t residency; /* Px residency time */
  203. uint64_aligned_t count; /* Px transition count */
  204. };
  205. typedef struct pm_px_val pm_px_val_t;
  206. DEFINE_XEN_GUEST_HANDLE(pm_px_val_t);
  207. struct pm_px_stat {
  208. uint8_t total; /* total Px states */
  209. uint8_t usable; /* usable Px states */
  210. uint8_t last; /* last Px state */
  211. uint8_t cur; /* current Px state */
  212. XEN_GUEST_HANDLE_64(uint64) trans_pt; /* Px transition table */
  213. XEN_GUEST_HANDLE_64(pm_px_val_t) pt;
  214. };
  215. typedef struct pm_px_stat pm_px_stat_t;
  216. DEFINE_XEN_GUEST_HANDLE(pm_px_stat_t);
  217. struct pm_cx_stat {
  218. uint32_t nr; /* entry nr in triggers & residencies, including C0 */
  219. uint32_t last; /* last Cx state */
  220. uint64_aligned_t idle_time; /* idle time from boot */
  221. XEN_GUEST_HANDLE_64(uint64) triggers; /* Cx trigger counts */
  222. XEN_GUEST_HANDLE_64(uint64) residencies; /* Cx residencies */
  223. };
  224. struct xen_sysctl_get_pmstat {
  225. #define PMSTAT_CATEGORY_MASK 0xf0
  226. #define PMSTAT_PX 0x10
  227. #define PMSTAT_CX 0x20
  228. #define PMSTAT_get_max_px (PMSTAT_PX | 0x1)
  229. #define PMSTAT_get_pxstat (PMSTAT_PX | 0x2)
  230. #define PMSTAT_reset_pxstat (PMSTAT_PX | 0x3)
  231. #define PMSTAT_get_max_cx (PMSTAT_CX | 0x1)
  232. #define PMSTAT_get_cxstat (PMSTAT_CX | 0x2)
  233. #define PMSTAT_reset_cxstat (PMSTAT_CX | 0x3)
  234. uint32_t type;
  235. uint32_t cpuid;
  236. union {
  237. struct pm_px_stat getpx;
  238. struct pm_cx_stat getcx;
  239. /* other struct for tx, etc */
  240. } u;
  241. };
  242. typedef struct xen_sysctl_get_pmstat xen_sysctl_get_pmstat_t;
  243. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_get_pmstat_t);
  244. #define XEN_SYSCTL_cpu_hotplug 11
  245. struct xen_sysctl_cpu_hotplug {
  246. /* IN variables */
  247. uint32_t cpu; /* Physical cpu. */
  248. #define XEN_SYSCTL_CPU_HOTPLUG_ONLINE 0
  249. #define XEN_SYSCTL_CPU_HOTPLUG_OFFLINE 1
  250. uint32_t op; /* hotplug opcode */
  251. };
  252. typedef struct xen_sysctl_cpu_hotplug xen_sysctl_cpu_hotplug_t;
  253. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpu_hotplug_t);
  254. struct xen_sysctl {
  255. uint32_t cmd;
  256. uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
  257. union {
  258. struct xen_sysctl_readconsole readconsole;
  259. struct xen_sysctl_tbuf_op tbuf_op;
  260. struct xen_sysctl_physinfo physinfo;
  261. struct xen_sysctl_sched_id sched_id;
  262. struct xen_sysctl_perfc_op perfc_op;
  263. struct xen_sysctl_getdomaininfolist getdomaininfolist;
  264. struct xen_sysctl_debug_keys debug_keys;
  265. struct xen_sysctl_getcpuinfo getcpuinfo;
  266. struct xen_sysctl_availheap availheap;
  267. struct xen_sysctl_get_pmstat get_pmstat;
  268. struct xen_sysctl_cpu_hotplug cpu_hotplug;
  269. uint8_t pad[128];
  270. } u;
  271. };
  272. typedef struct xen_sysctl xen_sysctl_t;
  273. DEFINE_XEN_GUEST_HANDLE(xen_sysctl_t);
  274. #endif /* __XEN_PUBLIC_SYSCTL_H__ */
  275. /*
  276. * Local variables:
  277. * mode: C
  278. * c-set-style: "BSD"
  279. * c-basic-offset: 4
  280. * tab-width: 4
  281. * indent-tabs-mode: nil
  282. * End:
  283. */