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