Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / hypervisor / src / common / include / hvctl.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* Hypervisor Software File: hvctl.h
5*
6* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
7*
8* - Do no alter or remove copyright notices
9*
10* - Redistribution and use of this software in source and binary forms, with
11* or without modification, are permitted provided that the following
12* conditions are met:
13*
14* - Redistribution of source code must retain the above copyright notice,
15* this list of conditions and the following disclaimer.
16*
17* - Redistribution in binary form must reproduce the above copyright notice,
18* this list of conditions and the following disclaimer in the
19* documentation and/or other materials provided with the distribution.
20*
21* Neither the name of Sun Microsystems, Inc. or the names of contributors
22* may be used to endorse or promote products derived from this software
23* without specific prior written permission.
24*
25* This software is provided "AS IS," without a warranty of any kind.
26* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
27* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
28* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
29* MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
30* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
31* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
32* OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
33* FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
34* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
35* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
36* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
37*
38* You acknowledge that this software is not designed, licensed or
39* intended for use in the design, construction, operation or maintenance of
40* any nuclear facility.
41*
42* ========== Copyright Header End ============================================
43*/
44/*
45 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
46 * Use is subject to license terms.
47 */
48
49#ifndef _HVCTL_H
50#define _HVCTL_H
51
52#pragma ident "@(#)hvctl.h 1.8 07/06/06 SMI"
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58#include <hypervisor.h>
59#include <support.h>
60
61#define HVCTL_MSG_MAXLEN 64
62
63
64#define HVCTL_STATE_UNCONNECTED 0
65#define HVCTL_STATE_CHALLENGED 1
66#define HVCTL_STATE_CONNECTED 2
67
68#define HVCTL_VERSION_MAJOR_NUMBER 1
69#define HVCTL_VERSION_MINOR_NUMBER 0
70
71#define HVCTL_HV_CHALLENGE_K 0xbadbeef20 /* to go away */
72#define HVCTL_ZEUS_CHALLENGE_K 0x12cafe42a /* to go away */
73
74#define HVCTL_RES_STATUS_DATA_SIZE 40
75
76#if !defined(_ASM) /* { */
77
78/*
79 * Hypervisor control message definitions
80 */
81
82
83/*
84 * Type codes for HV control messages
85 */
86
87
88/*
89 * The operation code
90 */
91typedef enum {
92 HVctl_op_hello = 0, /* Initial request to open hvctl channel */
93 /* yields a response of the same if fails */
94 HVctl_op_challenge, /* challenge returned from HV to Zeus */
95 HVctl_op_response, /* Response from Zeus */
96 HVctl_op_get_hvconfig, /* Get the HV config pointers */
97 HVctl_op_reconfigure, /* Reconfigure request */
98 HVctl_op_guest_start, /* Start a guest */
99 HVctl_op_guest_stop, /* Stop a guest */
100 HVctl_op_guest_delayed_reconf, /* Delayed reconfigure on guest exit */
101 HVctl_op_guest_suspend, /* Suspend a guest */
102 HVctl_op_guest_resume, /* Resume a guest */
103 HVctl_op_guest_panic, /* Panic a guest */
104 HVctl_op_get_res_stat, /* Get resource status if supported */
105 HVctl_op_new_res_stat, /* Aync resource status update if supported */
106 HVctl_op_cancel_reconf, /* Cancel any pending delayed reconfigure */
107} hvctl_op_t;
108
109/*
110 * Response codes.
111 */
112typedef enum {
113 HVctl_st_ok = 0,
114 HVctl_st_bad_seqn, /* Bad sequence number (dropped packet) */
115 HVctl_st_eauth, /* Not authorised */
116 HVctl_st_enotsupp, /* OP is not supported */
117 HVctl_st_badmd, /* Broken MD */
118 HVctl_st_mdnotsupp, /* Unsupported MD format */
119 HVctl_st_rc_failed, /* Reconfig failed */
120 HVctl_st_einval, /* Invalid argument specified */
121 HVctl_st_eillegal, /* Illegal operation requested */
122 HVctl_st_stop_failed, /* Stop request failed */
123} hvctl_status_t;
124
125
126/*
127 * Resource codes ... in parse process order
128 */
129typedef enum {
130 HVctl_res_guest = 0, /* guest resource */
131 HVctl_res_vcpu, /* virtual cpu resource */
132 HVctl_res_memory, /* memory block */
133 HVctl_res_mau, /* Niagara crypto unit */
134 HVctl_res_cwq, /* Niagara II crypto unit */
135 HVctl_res_ldc, /* LDC */
136 HVctl_res_console, /* Console nodes */
137 HVctl_res_hv_ldc, /* HV LDC - to be deleted */
138 HVctl_res_pcie_bus, /* PCIE bus */
139 HVctl_res_guestmd, /* guest md */
140 HVctl_res_network_device, /* Network */
141} hvctl_res_t;
142
143
144/*
145 * Resource specific error codes.
146 *
147 * The encoding of these may be specific to each resource. In other
148 * words a given code may have two or more different meanings depending
149 * on the resource that flags it.
150 * For the moment we keep the codes unique since it makes it easier to
151 * debug with, but I reserve the right to go and double these up later,
152 * so careful how you code.
153 *
154 * NOTE: with a well formed MD you should never see these errors. They are
155 * here to help debug and in case someone ignores the HVCTL versioning.
156 */
157typedef enum {
158 /* Guest specific errors */
159 HVctl_e_guest_missing_id,
160 HVctl_e_guest_invalid_id,
161 HVctl_e_guest_missing_property,
162 HVctl_e_guest_nocpus,
163 HVctl_e_guest_active,
164 HVctl_e_guest_stopped,
165 HVctl_e_guest_base_mblock_too_small,
166 /* vcpu specific errors */
167 HVctl_e_vcpu_missing_id,
168 HVctl_e_vcpu_invalid_id,
169 HVctl_e_vcpu_missing_strandid,
170 HVctl_e_vcpu_invalid_strandid,
171 HVctl_e_vcpu_missing_vid,
172 HVctl_e_vcpu_invalid_vid,
173 HVctl_e_vcpu_missing_guest,
174 HVctl_e_vcpu_missing_parttag,
175 HVctl_e_vcpu_invalid_parttag,
176 HVctl_e_vcpu_rebind_na, /* rebind not allowed */
177 /* memory specific errors */
178 HVctl_e_mblock_missing_id,
179 HVctl_e_mblock_invalid_id,
180 HVctl_e_mblock_missing_membase,
181 HVctl_e_mblock_missing_memsize,
182 HVctl_e_mblock_invalid_parange,
183 HVctl_e_mblock_missing_realbase,
184 HVctl_e_mblock_invalid_rarange,
185 HVctl_e_mblock_missing_guest,
186 HVctl_e_mblock_rebind_na,
187 HVctl_e_mblock_guest_active,
188 /* mau specific errors */
189 HVctl_e_mau_missing_id,
190 HVctl_e_mau_invalid_id,
191 HVctl_e_mau_missing_cpu,
192 HVctl_e_mau_missing_strandid,
193 HVctl_e_mau_invalid_strandid,
194 HVctl_e_mau_missing_ino,
195 HVctl_e_mau_missing_guest,
196 HVctl_e_mau_rebind_na, /* rebind not allowed */
197 /* cwq specific errors */
198 HVctl_e_cwq_missing_id,
199 HVctl_e_cwq_invalid_id,
200 HVctl_e_cwq_missing_cpu,
201 HVctl_e_cwq_missing_strandid,
202 HVctl_e_cwq_invalid_strandid,
203 HVctl_e_cwq_missing_ino,
204 HVctl_e_cwq_missing_guest,
205 HVctl_e_cwq_rebind_na, /* rebind not allowed */
206 /* pcie_bus specific errors */
207 HVctl_e_pcie_missing_prop,
208 HVctl_e_pcie_illegal_prop,
209 HVctl_e_pcie_rebind_na,
210 HVctl_e_pcie_missing_guest,
211 /* network specific errors */
212 HVctl_e_network_missing_prop,
213 HVctl_e_network_illegal_prop,
214 HVctl_e_network_rebind_na,
215 HVctl_e_network_missing_guest,
216 /* ldc specific errors */
217 HVctl_e_ldc_missing_prop,
218 HVctl_e_ldc_illegal_prop,
219 HVctl_e_ldc_rebind_na,
220 /* hv_ldc */
221 HVctl_e_hv_ldc_missing_prop,
222 HVctl_e_hv_ldc_illegal_prop,
223 HVctl_e_hv_ldc_rebind_na,
224 /* console configuration errors */
225 HVctl_e_cons_missing_id,
226 HVctl_e_cons_missing_guest,
227 HVctl_e_cons_missing_guest_id,
228 HVctl_e_cons_invalid_guest_id,
229 HVctl_e_cons_missing_ldc_id,
230 HVctl_e_cons_invalid_ldc_id,
231 HVctl_e_cons_missing_ino,
232 HVctl_e_cons_invalid_ino,
233 HVctl_e_cons_missing_uartbase,
234 /* common */
235 HVctl_e_invalid_infoid,
236} hvctl_res_error_t;
237
238
239/*
240 * Format for initial hello.
241 * Used for both init handshake, and for a nack response.
242 */
243typedef struct hvctl_hello {
244 uint16_t major;
245 uint16_t minor;
246} hvctl_hello_t;
247
248/*
249 * Format used for an ack response to a handshake
250 * holds the challenge code required by the HV.
251 * And returned to the HV by Zeus using HVctl_op_response
252 */
253typedef struct hvctl_challenge {
254 uint64_t code;
255} hvctl_challenge_t;
256
257/*
258 * Request to return the HVs current config info
259 */
260typedef struct hvctl_hvconfig {
261 uint64_t hv_membase;
262 uint64_t hv_memsize;
263 uint64_t hvmdp;
264 uint64_t del_reconf_hvmdp;
265 uint32_t del_reconf_gid;
266} hvctl_hvconfig_t;
267
268
269/*
270 * Configuration change request.
271 *
272 * HV figures out the rest and lets us know what if anything can't be done.
273 *
274 * guestid is invalid if this is not a delayed config request
275 *
276 * The command is acked if the MD parses OK, but the actual reconfigure
277 * is pended until the guest defined by guestid requests an exit or a reboot.
278 */
279typedef struct hvctl_reconfig {
280 uint64_t hvmdp;
281 uint32_t guestid;
282} hvctl_reconfig_t;
283
284/*
285 * If the new config fails for some reason this is the response packet.
286 *
287 * The HV stops on first failure.
288 *
289 * The packet contains the node index of the resource that could not be
290 * configured. The resource type (see above) and a resource type specific
291 * failure code as to why. The remainder of the packet may (at some point)
292 * contain further resource specific information.
293 */
294typedef struct hvctl_rc_fail {
295 uint64_t hvmdp; /* the one that failed */
296 uint32_t res; /* code of the resource the failed */
297 uint32_t code; /* resource specific failure code */
298 uint32_t nodeidx; /* idx of node in given HVMD */
299 uint32_t resid; /* resource id of resource */
300} hvctl_rc_fail_t;
301
302/*
303 * Payload and response packet used for other guest operations:
304 * HVctl_op_guest_start
305 * HVctl_op_guest_stop
306 * HVctl_op_guest_suspend
307 * HVctl_op_guest_resume
308 * HVctl_op_guest_panic
309 *
310 * code is unused (set 0) in request from Zeus, but may contain a guest
311 * resource specific error code from the HV in the event that the op fails
312 * and more info than just the hvctl_status_t in the pkt header is needed.
313 */
314typedef struct hvctl_guest_op {
315 uint32_t guestid;
316 uint32_t code;
317} hvctl_guest_op_t;
318
319
320/*
321 * Resource status/statistics request and async notice packet. The payload
322 * is resource specific, and so left in a general form here.
323 *
324 * In the get request payload the data field is ignored.
325 *
326 * For example, this is used for a guest status update notification
327 * The data payload holds the guest state info.
328 * The side-effect of the get form in this case is to clear
329 * any no-notify on change state.
330 */
331typedef struct hvctl_res_status {
332 uint32_t res; /* code of the resource type */
333 uint32_t resid; /* ID of the instance of resource type */
334 uint32_t infoid; /* ID of the info within the resource */
335 uint32_t code; /* resource specific failure code */
336 uint8_t data[HVCTL_RES_STATUS_DATA_SIZE];
337} hvctl_res_status_t;
338
339/*
340 * Info identifiers for guest resource.
341 */
342typedef enum {
343 HVctl_info_guest_state,
344 HVctl_info_guest_soft_state,
345 HVctl_info_guest_tod,
346 HVctl_info_guest_utilisation,
347 HVctl_info_guest_max,
348} hvctl_guest_info_t;
349
350/*
351 * Resource state returned in data for the
352 * HVctl_info_guest_state infoid.
353 */
354typedef struct rs_guest_state {
355 uint64_t state;
356} rs_guest_state_t;
357
358/*
359 * Resource state returned in data for the
360 * HVctl_info_guest_soft_state infoid.
361 */
362typedef struct rs_guest_soft_state {
363 uint8_t soft_state;
364 char soft_state_str[SOFT_STATE_SIZE];
365} rs_guest_soft_state_t;
366
367/*
368 * Resource state returned in data for the
369 * HVctl_info_guest_tod infoid.
370 */
371typedef struct rs_guest_tod {
372 uint64_t tod;
373} rs_guest_tod_t;
374
375/*
376 * Rsource state returned in data for the
377 * HVctl_info_guest_utilisation infoid.
378 * (this structure is full)
379 */
380
381typedef struct rs_guest_util {
382 uint64_t lifespan;
383 uint64_t wallclock_delta;
384 uint64_t active_delta;
385 uint64_t stopped_cycles;
386 uint64_t yielded_cycles;
387} rs_guest_util_t;
388
389
390/*
391 * Info identifiers for vcpu resource.
392 */
393typedef enum {
394 HVctl_info_vcpu_state,
395 HVctl_info_vcpu_max,
396} hvctl_vcpu_info_t;
397
398/*
399 * Resource state returned in data for the
400 * HVctl_info_vcpu_state infoid.
401 */
402typedef struct rs_vcpu_state {
403 uint8_t state;
404 uint64_t lifespan;
405 uint64_t wallclock_delta;
406 uint64_t active_delta;
407 uint64_t yielded_cycles;
408} rs_vcpu_state_t;
409
410
411/*
412 * Standard message header
413 *
414 * Applies to both requests and responses.
415 *
416 * The op field corresponds to an operation code or a reply code.
417 * The sequence number is specific to the sender and is merely
418 * used to detect dropped message packets.
419 *
420 * The status response accompanies an op field when in response to
421 * a request to do something.
422 */
423
424/*
425 * Basic header
426 *
427 * In requests to the HV the status field is ignored, in responses to
428 * requests from Zeus, status corresponds to the relevent error code for
429 * the request (op) field.
430 *
431 * For all messages (except the initial hello messages) the sequence number
432 * is tracked to determine dropped requests.
433 *
434 * In the event of a dropped request, all future messages are dumped until
435 * Zeus re-negotiates the HV control channel connection.
436 */
437
438typedef struct hvctl_header {
439 uint16_t op;
440 uint16_t seqn;
441 uint16_t chksum;
442 uint16_t status; /* = 0 for commands, status for responses */
443} hvctl_header_t;
444
445
446typedef struct hvctl_msg {
447 hvctl_header_t hdr;
448 union {
449 hvctl_hello_t hello;
450 hvctl_challenge_t clnge;
451 hvctl_hvconfig_t hvcnf;
452 hvctl_reconfig_t reconfig;
453 hvctl_rc_fail_t rcfail;
454 hvctl_guest_op_t guestop;
455 hvctl_res_status_t resstat;
456 } msg;
457} hvctl_msg_t;
458
459
460/*
461 * HV functions
462 */
463void reloc_resource_info();
464hvctl_status_t op_reconfig(hvctl_msg_t *cmdp, hvctl_msg_t *replyp,
465 bool_t isdelayed);
466hvctl_status_t op_guest_start(hvctl_msg_t *cmdp, hvctl_msg_t *replyp);
467
468
469#endif /* } !ASM */
470
471#ifdef __cplusplus
472}
473#endif
474
475#endif /* _HVCTL_H */