debuggers.hg

view xen/include/public/io/domain_controller.h @ 3685:bbe8541361dd

bitkeeper revision 1.1159.1.542 (42038a42_52IAalMZRKdTn0UbVN5fw)

Merge tempest.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xeno.bk
into tempest.cl.cam.ac.uk:/local/scratch/smh22/xen-unstable.bk
author smh22@tempest.cl.cam.ac.uk
date Fri Feb 04 14:44:18 2005 +0000 (2005-02-04)
parents bb56e77896e7 ef59b38283a5
children 0a4b76b6b5a0
line source
1 /******************************************************************************
2 * domain_controller.h
3 *
4 * Interface to server controller (e.g., 'xend'). This header file defines the
5 * interface that is shared with guest OSes.
6 *
7 * Copyright (c) 2004, K A Fraser
8 */
10 #ifndef __XEN_PUBLIC_IO_DOMAIN_CONTROLLER_H__
11 #define __XEN_PUBLIC_IO_DOMAIN_CONTROLLER_H__
13 #include "ring.h"
15 /*
16 * Reason codes for SCHEDOP_shutdown. These are opaque to Xen but may be
17 * interpreted by control software to determine the appropriate action. These
18 * are only really advisories: the controller can actually do as it likes.
19 */
20 #define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */
21 #define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */
22 #define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */
25 /*
26 * CONTROLLER MESSAGING INTERFACE.
27 */
29 typedef struct {
30 u8 type; /* 0: echoed in response */
31 u8 subtype; /* 1: echoed in response */
32 u8 id; /* 2: echoed in response */
33 u8 length; /* 3: number of bytes in 'msg' */
34 u8 msg[60]; /* 4: type-specific message data */
35 } PACKED control_msg_t; /* 64 bytes */
37 /* These are used by the control message deferred ring. */
38 #define CONTROL_RING_SIZE 8
39 typedef u32 CONTROL_RING_IDX;
40 #define MASK_CONTROL_IDX(_i) ((_i)&(CONTROL_RING_SIZE-1))
42 /*
43 * Generate control ring structures and types.
44 *
45 * CONTROL_RING_MEM is currently an 8-slot ring of ctrl_msg_t structs and
46 * two 32-bit counters: (64 * 8) + (2 * 4) = 520
47 */
48 #define CONTROL_RING_MEM 520
49 #define CTRL_RING RING_PARAMS(control_msg_t, control_msg_t, CONTROL_RING_MEM)
50 DEFINE_RING_TYPES(ctrl, CTRL_RING);
52 typedef struct {
53 ctrl_sring_t tx_ring; /* 0: guest -> controller */
54 ctrl_sring_t rx_ring; /* 520: controller -> guest */
55 } PACKED control_if_t; /* 1040 bytes */
57 /*
58 * Top-level command types.
59 */
60 #define CMSG_CONSOLE 0 /* Console */
61 #define CMSG_BLKIF_BE 1 /* Block-device backend */
62 #define CMSG_BLKIF_FE 2 /* Block-device frontend */
63 #define CMSG_NETIF_BE 3 /* Network-device backend */
64 #define CMSG_NETIF_FE 4 /* Network-device frontend */
65 #define CMSG_SHUTDOWN 6 /* Shutdown messages */
66 #define CMSG_MEM_REQUEST 7 /* Memory reservation reqs */
67 #define CMSG_USBIF_BE 8 /* USB controller backend */
68 #define CMSG_USBIF_FE 9 /* USB controller frontend */
70 /******************************************************************************
71 * CONSOLE DEFINITIONS
72 */
74 /*
75 * Subtypes for console messages.
76 */
77 #define CMSG_CONSOLE_DATA 0
80 /******************************************************************************
81 * BLOCK-INTERFACE FRONTEND DEFINITIONS
82 */
84 /* Messages from domain controller to guest. */
85 #define CMSG_BLKIF_FE_INTERFACE_STATUS 0
87 /* Messages from guest to domain controller. */
88 #define CMSG_BLKIF_FE_DRIVER_STATUS 32
89 #define CMSG_BLKIF_FE_INTERFACE_CONNECT 33
90 #define CMSG_BLKIF_FE_INTERFACE_DISCONNECT 34
91 #define CMSG_BLKIF_FE_INTERFACE_QUERY 35
93 /* These are used by both front-end and back-end drivers. */
94 #define blkif_vdev_t u16
95 #define blkif_pdev_t u16
96 #define blkif_sector_t u64
98 /*
99 * CMSG_BLKIF_FE_INTERFACE_STATUS:
100 * Notify a guest about a status change on one of its block interfaces.
101 * If the interface is DESTROYED or DOWN then the interface is disconnected:
102 * 1. The shared-memory frame is available for reuse.
103 * 2. Any unacknowledged messages pending on the interface were dropped.
104 */
105 #define BLKIF_INTERFACE_STATUS_CLOSED 0 /* Interface doesn't exist. */
106 #define BLKIF_INTERFACE_STATUS_DISCONNECTED 1 /* Exists but is disconnected. */
107 #define BLKIF_INTERFACE_STATUS_CONNECTED 2 /* Exists and is connected. */
108 #define BLKIF_INTERFACE_STATUS_CHANGED 3 /* A device has been added or removed. */
109 typedef struct {
110 u32 handle; /* 0 */
111 u32 status; /* 4 */
112 u16 evtchn; /* 8: (only if status == BLKIF_INTERFACE_STATUS_CONNECTED). */
113 domid_t domid; /* 10: status != BLKIF_INTERFACE_STATUS_DESTROYED */
114 } PACKED blkif_fe_interface_status_t; /* 12 bytes */
116 /*
117 * CMSG_BLKIF_FE_DRIVER_STATUS:
118 * Notify the domain controller that the front-end driver is DOWN or UP.
119 * When the driver goes DOWN then the controller will send no more
120 * status-change notifications.
121 * If the driver goes DOWN while interfaces are still UP, the domain
122 * will automatically take the interfaces DOWN.
123 *
124 * NB. The controller should not send an INTERFACE_STATUS_CHANGED message
125 * for interfaces that are active when it receives an UP notification. We
126 * expect that the frontend driver will query those interfaces itself.
127 */
128 #define BLKIF_DRIVER_STATUS_DOWN 0
129 #define BLKIF_DRIVER_STATUS_UP 1
130 typedef struct {
131 /* IN */
132 u32 status; /* 0: BLKIF_DRIVER_STATUS_??? */
133 /* OUT */
134 /* Driver should query interfaces [0..max_handle]. */
135 u32 max_handle; /* 4 */
136 } PACKED blkif_fe_driver_status_t; /* 8 bytes */
138 /*
139 * CMSG_BLKIF_FE_INTERFACE_CONNECT:
140 * If successful, the domain controller will acknowledge with a
141 * STATUS_CONNECTED message.
142 */
143 typedef struct {
144 u32 handle; /* 0 */
145 u32 __pad;
146 memory_t shmem_frame; /* 8 */
147 MEMORY_PADDING;
148 } PACKED blkif_fe_interface_connect_t; /* 16 bytes */
150 /*
151 * CMSG_BLKIF_FE_INTERFACE_DISCONNECT:
152 * If successful, the domain controller will acknowledge with a
153 * STATUS_DISCONNECTED message.
154 */
155 typedef struct {
156 u32 handle; /* 0 */
157 } PACKED blkif_fe_interface_disconnect_t; /* 4 bytes */
159 /*
160 * CMSG_BLKIF_FE_INTERFACE_QUERY:
161 */
162 typedef struct {
163 /* IN */
164 u32 handle; /* 0 */
165 /* OUT */
166 u32 status; /* 4 */
167 u16 evtchn; /* 8: (only if status == BLKIF_INTERFACE_STATUS_CONNECTED). */
168 domid_t domid; /* 10: status != BLKIF_INTERFACE_STATUS_DESTROYED */
169 } PACKED blkif_fe_interface_query_t; /* 12 bytes */
172 /******************************************************************************
173 * BLOCK-INTERFACE BACKEND DEFINITIONS
174 */
176 /* Messages from domain controller. */
177 #define CMSG_BLKIF_BE_CREATE 0 /* Create a new block-device interface. */
178 #define CMSG_BLKIF_BE_DESTROY 1 /* Destroy a block-device interface. */
179 #define CMSG_BLKIF_BE_CONNECT 2 /* Connect i/f to remote driver. */
180 #define CMSG_BLKIF_BE_DISCONNECT 3 /* Disconnect i/f from remote driver. */
181 #define CMSG_BLKIF_BE_VBD_CREATE 4 /* Create a new VBD for an interface. */
182 #define CMSG_BLKIF_BE_VBD_DESTROY 5 /* Delete a VBD from an interface. */
183 #define CMSG_BLKIF_BE_VBD_GROW 6 /* Append an extent to a given VBD. */
184 #define CMSG_BLKIF_BE_VBD_SHRINK 7 /* Remove last extent from a given VBD. */
186 /* Messages to domain controller. */
187 #define CMSG_BLKIF_BE_DRIVER_STATUS 32
189 /*
190 * Message request/response definitions for block-device messages.
191 */
193 typedef struct {
194 blkif_sector_t sector_start; /* 0 */
195 blkif_sector_t sector_length; /* 8 */
196 blkif_pdev_t device; /* 16 */
197 u16 __pad; /* 18 */
198 } PACKED blkif_extent_t; /* 20 bytes */
200 /* Non-specific 'okay' return. */
201 #define BLKIF_BE_STATUS_OKAY 0
202 /* Non-specific 'error' return. */
203 #define BLKIF_BE_STATUS_ERROR 1
204 /* The following are specific error returns. */
205 #define BLKIF_BE_STATUS_INTERFACE_EXISTS 2
206 #define BLKIF_BE_STATUS_INTERFACE_NOT_FOUND 3
207 #define BLKIF_BE_STATUS_INTERFACE_CONNECTED 4
208 #define BLKIF_BE_STATUS_VBD_EXISTS 5
209 #define BLKIF_BE_STATUS_VBD_NOT_FOUND 6
210 #define BLKIF_BE_STATUS_OUT_OF_MEMORY 7
211 #define BLKIF_BE_STATUS_EXTENT_NOT_FOUND 8
212 #define BLKIF_BE_STATUS_MAPPING_ERROR 9
214 /* This macro can be used to create an array of descriptive error strings. */
215 #define BLKIF_BE_STATUS_ERRORS { \
216 "Okay", \
217 "Non-specific error", \
218 "Interface already exists", \
219 "Interface not found", \
220 "Interface is still connected", \
221 "VBD already exists", \
222 "VBD not found", \
223 "Out of memory", \
224 "Extent not found for VBD", \
225 "Could not map domain memory" }
227 /*
228 * CMSG_BLKIF_BE_CREATE:
229 * When the driver sends a successful response then the interface is fully
230 * created. The controller will send a DOWN notification to the front-end
231 * driver.
232 */
233 typedef struct {
234 /* IN */
235 domid_t domid; /* 0: Domain attached to new interface. */
236 u16 __pad;
237 u32 blkif_handle; /* 4: Domain-specific interface handle. */
238 /* OUT */
239 u32 status; /* 8 */
240 } PACKED blkif_be_create_t; /* 12 bytes */
242 /*
243 * CMSG_BLKIF_BE_DESTROY:
244 * When the driver sends a successful response then the interface is fully
245 * torn down. The controller will send a DESTROYED notification to the
246 * front-end driver.
247 */
248 typedef struct {
249 /* IN */
250 domid_t domid; /* 0: Identify interface to be destroyed. */
251 u16 __pad;
252 u32 blkif_handle; /* 4: ...ditto... */
253 /* OUT */
254 u32 status; /* 8 */
255 } PACKED blkif_be_destroy_t; /* 12 bytes */
257 /*
258 * CMSG_BLKIF_BE_CONNECT:
259 * When the driver sends a successful response then the interface is fully
260 * connected. The controller will send a CONNECTED notification to the
261 * front-end driver.
262 */
263 typedef struct {
264 /* IN */
265 domid_t domid; /* 0: Domain attached to new interface. */
266 u16 __pad;
267 u32 blkif_handle; /* 4: Domain-specific interface handle. */
268 memory_t shmem_frame; /* 8: Page cont. shared comms window. */
269 MEMORY_PADDING;
270 u32 evtchn; /* 16: Event channel for notifications. */
271 /* OUT */
272 u32 status; /* 20 */
273 } PACKED blkif_be_connect_t; /* 24 bytes */
275 /*
276 * CMSG_BLKIF_BE_DISCONNECT:
277 * When the driver sends a successful response then the interface is fully
278 * disconnected. The controller will send a DOWN notification to the front-end
279 * driver.
280 */
281 typedef struct {
282 /* IN */
283 domid_t domid; /* 0: Domain attached to new interface. */
284 u16 __pad;
285 u32 blkif_handle; /* 4: Domain-specific interface handle. */
286 /* OUT */
287 u32 status; /* 8 */
288 } PACKED blkif_be_disconnect_t; /* 12 bytes */
290 /* CMSG_BLKIF_BE_VBD_CREATE */
291 typedef struct {
292 /* IN */
293 domid_t domid; /* 0: Identify blkdev interface. */
294 u16 __pad;
295 u32 blkif_handle; /* 4: ...ditto... */
296 blkif_vdev_t vdevice; /* 8: Interface-specific id for this VBD. */
297 u16 readonly; /* 10: Non-zero -> VBD isn't writable. */
298 /* OUT */
299 u32 status; /* 12 */
300 } PACKED blkif_be_vbd_create_t; /* 16 bytes */
302 /* CMSG_BLKIF_BE_VBD_DESTROY */
303 typedef struct {
304 /* IN */
305 domid_t domid; /* 0: Identify blkdev interface. */
306 u16 __pad0; /* 2 */
307 u32 blkif_handle; /* 4: ...ditto... */
308 blkif_vdev_t vdevice; /* 8: Interface-specific id of the VBD. */
309 u16 __pad1; /* 10 */
310 /* OUT */
311 u32 status; /* 12 */
312 } PACKED blkif_be_vbd_destroy_t; /* 16 bytes */
314 /* CMSG_BLKIF_BE_VBD_GROW */
315 typedef struct {
316 /* IN */
317 domid_t domid; /* 0: Identify blkdev interface. */
318 u16 __pad0; /* 2 */
319 u32 blkif_handle; /* 4: ...ditto... */
320 blkif_extent_t extent; /* 8: Physical extent to append to VBD. */
321 blkif_vdev_t vdevice; /* 28: Interface-specific id of the VBD. */
322 u16 __pad1; /* 30 */
323 /* OUT */
324 u32 status; /* 32 */
325 } PACKED blkif_be_vbd_grow_t; /* 36 bytes */
327 /* CMSG_BLKIF_BE_VBD_SHRINK */
328 typedef struct {
329 /* IN */
330 domid_t domid; /* 0: Identify blkdev interface. */
331 u16 __pad0; /* 2 */
332 u32 blkif_handle; /* 4: ...ditto... */
333 blkif_vdev_t vdevice; /* 8: Interface-specific id of the VBD. */
334 u16 __pad1; /* 10 */
335 /* OUT */
336 u32 status; /* 12 */
337 } PACKED blkif_be_vbd_shrink_t; /* 16 bytes */
339 /*
340 * CMSG_BLKIF_BE_DRIVER_STATUS:
341 * Notify the domain controller that the back-end driver is DOWN or UP.
342 * If the driver goes DOWN while interfaces are still UP, the controller
343 * will automatically send DOWN notifications.
344 */
345 typedef struct {
346 u32 status; /* 0: BLKIF_DRIVER_STATUS_??? */
347 } PACKED blkif_be_driver_status_t; /* 4 bytes */
350 /******************************************************************************
351 * NETWORK-INTERFACE FRONTEND DEFINITIONS
352 */
354 /* Messages from domain controller to guest. */
355 #define CMSG_NETIF_FE_INTERFACE_STATUS 0
357 /* Messages from guest to domain controller. */
358 #define CMSG_NETIF_FE_DRIVER_STATUS 32
359 #define CMSG_NETIF_FE_INTERFACE_CONNECT 33
360 #define CMSG_NETIF_FE_INTERFACE_DISCONNECT 34
361 #define CMSG_NETIF_FE_INTERFACE_QUERY 35
363 /*
364 * CMSG_NETIF_FE_INTERFACE_STATUS:
365 * Notify a guest about a status change on one of its network interfaces.
366 * If the interface is CLOSED or DOWN then the interface is disconnected:
367 * 1. The shared-memory frame is available for reuse.
368 * 2. Any unacknowledged messgaes pending on the interface were dropped.
369 */
370 #define NETIF_INTERFACE_STATUS_CLOSED 0 /* Interface doesn't exist. */
371 #define NETIF_INTERFACE_STATUS_DISCONNECTED 1 /* Exists but is disconnected. */
372 #define NETIF_INTERFACE_STATUS_CONNECTED 2 /* Exists and is connected. */
373 #define NETIF_INTERFACE_STATUS_CHANGED 3 /* A device has been added or removed. */
374 typedef struct {
375 u32 handle; /* 0 */
376 u32 status; /* 4 */
377 u16 evtchn; /* 8: status == NETIF_INTERFACE_STATUS_CONNECTED */
378 u8 mac[6]; /* 10: status == NETIF_INTERFACE_STATUS_CONNECTED */
379 domid_t domid; /* 16: status != NETIF_INTERFACE_STATUS_DESTROYED */
380 } PACKED netif_fe_interface_status_t; /* 18 bytes */
382 /*
383 * CMSG_NETIF_FE_DRIVER_STATUS:
384 * Notify the domain controller that the front-end driver is DOWN or UP.
385 * When the driver goes DOWN then the controller will send no more
386 * status-change notifications.
387 * If the driver goes DOWN while interfaces are still UP, the domain
388 * will automatically take the interfaces DOWN.
389 *
390 * NB. The controller should not send an INTERFACE_STATUS message
391 * for interfaces that are active when it receives an UP notification. We
392 * expect that the frontend driver will query those interfaces itself.
393 */
394 #define NETIF_DRIVER_STATUS_DOWN 0
395 #define NETIF_DRIVER_STATUS_UP 1
396 typedef struct {
397 /* IN */
398 u32 status; /* 0: NETIF_DRIVER_STATUS_??? */
399 /* OUT */
400 /* Driver should query interfaces [0..max_handle]. */
401 u32 max_handle; /* 4 */
402 } PACKED netif_fe_driver_status_t; /* 8 bytes */
404 /*
405 * CMSG_NETIF_FE_INTERFACE_CONNECT:
406 * If successful, the domain controller will acknowledge with a
407 * STATUS_CONNECTED message.
408 */
409 typedef struct {
410 u32 handle; /* 0 */
411 u32 __pad; /* 4 */
412 memory_t tx_shmem_frame; /* 8 */
413 MEMORY_PADDING;
414 memory_t rx_shmem_frame; /* 16 */
415 MEMORY_PADDING;
416 } PACKED netif_fe_interface_connect_t; /* 24 bytes */
418 /*
419 * CMSG_NETIF_FE_INTERFACE_DISCONNECT:
420 * If successful, the domain controller will acknowledge with a
421 * STATUS_DISCONNECTED message.
422 */
423 typedef struct {
424 u32 handle; /* 0 */
425 } PACKED netif_fe_interface_disconnect_t; /* 4 bytes */
427 /*
428 * CMSG_NETIF_FE_INTERFACE_QUERY:
429 */
430 typedef struct {
431 /* IN */
432 u32 handle; /* 0 */
433 /* OUT */
434 u32 status; /* 4 */
435 u16 evtchn; /* 8: status == NETIF_INTERFACE_STATUS_CONNECTED */
436 u8 mac[6]; /* 10: status == NETIF_INTERFACE_STATUS_CONNECTED */
437 domid_t domid; /* 16: status != NETIF_INTERFACE_STATUS_DESTROYED */
438 } PACKED netif_fe_interface_query_t; /* 18 bytes */
441 /******************************************************************************
442 * NETWORK-INTERFACE BACKEND DEFINITIONS
443 */
445 /* Messages from domain controller. */
446 #define CMSG_NETIF_BE_CREATE 0 /* Create a new net-device interface. */
447 #define CMSG_NETIF_BE_DESTROY 1 /* Destroy a net-device interface. */
448 #define CMSG_NETIF_BE_CONNECT 2 /* Connect i/f to remote driver. */
449 #define CMSG_NETIF_BE_DISCONNECT 3 /* Disconnect i/f from remote driver. */
451 /* Messages to domain controller. */
452 #define CMSG_NETIF_BE_DRIVER_STATUS 32
454 /*
455 * Message request/response definitions for net-device messages.
456 */
458 /* Non-specific 'okay' return. */
459 #define NETIF_BE_STATUS_OKAY 0
460 /* Non-specific 'error' return. */
461 #define NETIF_BE_STATUS_ERROR 1
462 /* The following are specific error returns. */
463 #define NETIF_BE_STATUS_INTERFACE_EXISTS 2
464 #define NETIF_BE_STATUS_INTERFACE_NOT_FOUND 3
465 #define NETIF_BE_STATUS_INTERFACE_CONNECTED 4
466 #define NETIF_BE_STATUS_OUT_OF_MEMORY 5
467 #define NETIF_BE_STATUS_MAPPING_ERROR 6
469 /* This macro can be used to create an array of descriptive error strings. */
470 #define NETIF_BE_STATUS_ERRORS { \
471 "Okay", \
472 "Non-specific error", \
473 "Interface already exists", \
474 "Interface not found", \
475 "Interface is still connected", \
476 "Out of memory", \
477 "Could not map domain memory" }
479 /*
480 * CMSG_NETIF_BE_CREATE:
481 * When the driver sends a successful response then the interface is fully
482 * created. The controller will send a DOWN notification to the front-end
483 * driver.
484 */
485 typedef struct {
486 /* IN */
487 domid_t domid; /* 0: Domain attached to new interface. */
488 u16 __pad0; /* 2 */
489 u32 netif_handle; /* 4: Domain-specific interface handle. */
490 u8 mac[6]; /* 8 */
491 u16 __pad1; /* 14 */
492 u8 be_mac[6]; /* 16 */
493 u16 __pad2; /* 22 */
494 /* OUT */
495 u32 status; /* 24 */
496 } PACKED netif_be_create_t; /* 28 bytes */
498 /*
499 * CMSG_NETIF_BE_DESTROY:
500 * When the driver sends a successful response then the interface is fully
501 * torn down. The controller will send a DESTROYED notification to the
502 * front-end driver.
503 */
504 typedef struct {
505 /* IN */
506 domid_t domid; /* 0: Identify interface to be destroyed. */
507 u16 __pad;
508 u32 netif_handle; /* 4: ...ditto... */
509 /* OUT */
510 u32 status; /* 8 */
511 } PACKED netif_be_destroy_t; /* 12 bytes */
513 /*
514 * CMSG_NETIF_BE_CONNECT:
515 * When the driver sends a successful response then the interface is fully
516 * connected. The controller will send a CONNECTED notification to the
517 * front-end driver.
518 */
519 typedef struct {
520 /* IN */
521 domid_t domid; /* 0: Domain attached to new interface. */
522 u16 __pad0; /* 2 */
523 u32 netif_handle; /* 4: Domain-specific interface handle. */
524 memory_t tx_shmem_frame; /* 8: Page cont. tx shared comms window. */
525 MEMORY_PADDING;
526 memory_t rx_shmem_frame; /* 16: Page cont. rx shared comms window. */
527 MEMORY_PADDING;
528 u16 evtchn; /* 24: Event channel for notifications. */
529 u16 __pad1; /* 26 */
530 /* OUT */
531 u32 status; /* 28 */
532 } PACKED netif_be_connect_t; /* 32 bytes */
534 /*
535 * CMSG_NETIF_BE_DISCONNECT:
536 * When the driver sends a successful response then the interface is fully
537 * disconnected. The controller will send a DOWN notification to the front-end
538 * driver.
539 */
540 typedef struct {
541 /* IN */
542 domid_t domid; /* 0: Domain attached to new interface. */
543 u16 __pad;
544 u32 netif_handle; /* 4: Domain-specific interface handle. */
545 /* OUT */
546 u32 status; /* 8 */
547 } PACKED netif_be_disconnect_t; /* 12 bytes */
549 /*
550 * CMSG_NETIF_BE_DRIVER_STATUS:
551 * Notify the domain controller that the back-end driver is DOWN or UP.
552 * If the driver goes DOWN while interfaces are still UP, the domain
553 * will automatically send DOWN notifications.
554 */
555 typedef struct {
556 u32 status; /* 0: NETIF_DRIVER_STATUS_??? */
557 } PACKED netif_be_driver_status_t; /* 4 bytes */
561 /******************************************************************************
562 * USB-INTERFACE FRONTEND DEFINITIONS
563 */
565 /* Messages from domain controller to guest. */
566 #define CMSG_USBIF_FE_INTERFACE_STATUS_CHANGED 0
568 /* Messages from guest to domain controller. */
569 #define CMSG_USBIF_FE_DRIVER_STATUS_CHANGED 32
570 #define CMSG_USBIF_FE_INTERFACE_CONNECT 33
571 #define CMSG_USBIF_FE_INTERFACE_DISCONNECT 34
572 /*
573 * CMSG_USBIF_FE_INTERFACE_STATUS_CHANGED:
574 * Notify a guest about a status change on one of its block interfaces.
575 * If the interface is DESTROYED or DOWN then the interface is disconnected:
576 * 1. The shared-memory frame is available for reuse.
577 * 2. Any unacknowledged messages pending on the interface were dropped.
578 */
579 #define USBIF_INTERFACE_STATUS_DESTROYED 0 /* Interface doesn't exist. */
580 #define USBIF_INTERFACE_STATUS_DISCONNECTED 1 /* Exists but is disconnected. */
581 #define USBIF_INTERFACE_STATUS_CONNECTED 2 /* Exists and is connected. */
582 typedef struct {
583 u32 status; /* 0 */
584 u16 evtchn; /* 4: (only if status == BLKIF_INTERFACE_STATUS_CONNECTED). */
585 domid_t domid; /* 6: status != BLKIF_INTERFACE_STATUS_DESTROYED */
586 u32 bandwidth; /* 8 */
587 u32 num_ports; /* 12 */
588 } PACKED usbif_fe_interface_status_changed_t; /* 12 bytes */
590 /*
591 * CMSG_USBIF_FE_DRIVER_STATUS_CHANGED:
592 * Notify the domain controller that the front-end driver is DOWN or UP.
593 * When the driver goes DOWN then the controller will send no more
594 * status-change notifications.
595 * If the driver goes DOWN while interfaces are still UP, the domain
596 * will automatically take the interfaces DOWN.
597 *
598 * NB. The controller should not send an INTERFACE_STATUS_CHANGED message
599 * for interfaces that are active when it receives an UP notification. We
600 * expect that the frontend driver will query those interfaces itself.
601 */
602 #define USBIF_DRIVER_STATUS_DOWN 0
603 #define USBIF_DRIVER_STATUS_UP 1
604 typedef struct {
605 /* IN */
606 u32 status; /* 0: USBIF_DRIVER_STATUS_??? */
607 } PACKED usbif_fe_driver_status_changed_t; /* 4 bytes */
609 /*
610 * CMSG_USBIF_FE_INTERFACE_CONNECT:
611 * If successful, the domain controller will acknowledge with a
612 * STATUS_CONNECTED message.
613 */
614 typedef struct {
615 u32 __pad;
616 memory_t shmem_frame; /* 8 */
617 MEMORY_PADDING;
618 } PACKED usbif_fe_interface_connect_t; /* 16 bytes */
620 /*
621 * CMSG_BLKIF_FE_INTERFACE_DISCONNECT:
622 * If successful, the domain controller will acknowledge with a
623 * STATUS_DISCONNECTED message.
624 */
625 typedef struct {} PACKED usbif_fe_interface_disconnect_t; /* 4 bytes */
628 /******************************************************************************
629 * USB-INTERFACE BACKEND DEFINITIONS
630 */
632 /* Messages from domain controller. */
633 #define CMSG_USBIF_BE_CREATE 0 /* Create a new block-device interface. */
634 #define CMSG_USBIF_BE_DESTROY 1 /* Destroy a block-device interface. */
635 #define CMSG_USBIF_BE_CONNECT 2 /* Connect i/f to remote driver. */
636 #define CMSG_USBIF_BE_DISCONNECT 3 /* Disconnect i/f from remote driver. */
637 #define CMSG_USBIF_BE_CLAIM_PORT 4 /* Claim host port for a domain. */
638 #define CMSG_USBIF_BE_RELEASE_PORT 5 /* Release host port. */
639 /* Messages to domain controller. */
640 #define CMSG_USBIF_BE_DRIVER_STATUS_CHANGED 32
642 /* Non-specific 'okay' return. */
643 #define USBIF_BE_STATUS_OKAY 0
644 /* Non-specific 'error' return. */
645 #define USBIF_BE_STATUS_ERROR 1
646 /* The following are specific error returns. */
647 #define USBIF_BE_STATUS_INTERFACE_EXISTS 2
648 #define USBIF_BE_STATUS_INTERFACE_NOT_FOUND 3
649 #define USBIF_BE_STATUS_INTERFACE_CONNECTED 4
650 #define USBIF_BE_STATUS_OUT_OF_MEMORY 7
651 #define USBIF_BE_STATUS_MAPPING_ERROR 9
653 /* This macro can be used to create an array of descriptive error strings. */
654 #define USBIF_BE_STATUS_ERRORS { \
655 "Okay", \
656 "Non-specific error", \
657 "Interface already exists", \
658 "Interface not found", \
659 "Interface is still connected", \
660 "Out of memory", \
661 "Could not map domain memory" }
663 /*
664 * CMSG_USBIF_BE_CREATE:
665 * When the driver sends a successful response then the interface is fully
666 * created. The controller will send a DOWN notification to the front-end
667 * driver.
668 */
669 typedef struct {
670 /* IN */
671 domid_t domid; /* 0: Domain attached to new interface. */
672 u16 __pad;
673 /* OUT */
674 u32 status; /* 8 */
675 } PACKED usbif_be_create_t; /* 12 bytes */
677 /*
678 * CMSG_USBIF_BE_DESTROY:
679 * When the driver sends a successful response then the interface is fully
680 * torn down. The controller will send a DESTROYED notification to the
681 * front-end driver.
682 */
683 typedef struct {
684 /* IN */
685 domid_t domid; /* 0: Identify interface to be destroyed. */
686 u16 __pad;
687 /* OUT */
688 u32 status; /* 8 */
689 } PACKED usbif_be_destroy_t; /* 12 bytes */
691 /*
692 * CMSG_USBIF_BE_CONNECT:
693 * When the driver sends a successful response then the interface is fully
694 * connected. The controller will send a CONNECTED notification to the
695 * front-end driver.
696 */
697 typedef struct {
698 /* IN */
699 domid_t domid; /* 0: Domain attached to new interface. */
700 u16 __pad;
701 memory_t shmem_frame; /* 8: Page cont. shared comms window. */
702 MEMORY_PADDING;
703 u32 evtchn; /* 16: Event channel for notifications. */
704 u32 bandwidth; /* 20: Bandwidth allocated for isoch / int - us
705 * per 1ms frame (ie between 0 and 900 or 800
706 * depending on USB version). */
707 /* OUT */
708 u32 status; /* 24 */
709 } PACKED usbif_be_connect_t; /* 28 bytes */
711 /*
712 * CMSG_USBIF_BE_DISCONNECT:
713 * When the driver sends a successful response then the interface is fully
714 * disconnected. The controller will send a DOWN notification to the front-end
715 * driver.
716 */
717 typedef struct {
718 /* IN */
719 domid_t domid; /* 0: Domain attached to new interface. */
720 u16 __pad;
721 /* OUT */
722 u32 status; /* 8 */
723 } PACKED usbif_be_disconnect_t; /* 12 bytes */
725 /*
726 * CMSG_USBIF_BE_DRIVER_STATUS_CHANGED:
727 * Notify the domain controller that the back-end driver is DOWN or UP.
728 * If the driver goes DOWN while interfaces are still UP, the controller
729 * will automatically send DOWN notifications.
730 */
731 typedef struct {
732 u32 status; /* 0: USBIF_DRIVER_STATUS_??? */
733 } PACKED usbif_be_driver_status_changed_t; /* 4 bytes */
735 #define USB_PATH_LEN 16
737 /*
738 * CMSG_USBIF_BE_CLAIM_PORT:
739 * Instruct the backend driver to claim any device plugged into the specified
740 * host port and to allow the specified domain to control that port.
741 */
742 typedef struct
743 {
744 /* IN */
745 domid_t domid; /* 0: which domain */
746 u32 usbif_port; /* 6: port on the virtual root hub */
747 u32 status; /* 10: status of operation */
748 char path[USB_PATH_LEN]; /* Currently specified in the Linux style - may need to be
749 * converted to some OS-independent format at some stage. */
750 } PACKED usbif_be_claim_port_t;
752 /*
753 * CMSG_USBIF_BE_RELEASE_PORT:
754 * Instruct the backend driver to release any device plugged into the specified
755 * host port.
756 */
757 typedef struct
758 {
759 char path[USB_PATH_LEN];
760 } PACKED usbif_be_release_port_t;
762 /******************************************************************************
763 * SHUTDOWN DEFINITIONS
764 */
766 /*
767 * Subtypes for shutdown messages.
768 */
769 #define CMSG_SHUTDOWN_POWEROFF 0 /* Clean shutdown (SHUTDOWN_poweroff). */
770 #define CMSG_SHUTDOWN_REBOOT 1 /* Clean shutdown (SHUTDOWN_reboot). */
771 #define CMSG_SHUTDOWN_SUSPEND 2 /* Create suspend info, then */
772 /* SHUTDOWN_suspend. */
773 #define CMSG_SHUTDOWN_SYSRQ 3
776 /******************************************************************************
777 * MEMORY CONTROLS
778 */
780 #define CMSG_MEM_REQUEST_SET 0 /* Request a domain to set its mem footprint. */
782 /*
783 * CMSG_MEM_REQUEST:
784 * Request that the domain change its memory reservation.
785 */
786 typedef struct {
787 /* OUT */
788 u32 target; /* 0: Target memory reservation in pages. */
789 /* IN */
790 u32 status; /* 4: Return code indicates success or failure. */
791 } PACKED mem_request_t; /* 8 bytes */
794 #endif /* __XEN_PUBLIC_IO_DOMAIN_CONTROLLER_H__ */