From: BitKeeper B. <ri...@su...> - 2005-03-10 19:03:18
|
ChangeSet 1.1313, 2005/03/10 18:15:14+00:00, ka...@fi... Merge firebug.cl.cam.ac.uk:/local/scratch/kaf24/xen-2.0-testing.bk into firebug.cl.cam.ac.uk:/local/scratch/kaf24/xen-unstable.bk domain_controller.h | 245 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 238 insertions(+), 7 deletions(-) diff -Nru a/xen/include/public/io/domain_controller.h b/xen/include/public/io/domain_controller.h --- a/xen/include/public/io/domain_controller.h 2005-03-10 14:03:14 -05:00 +++ b/xen/include/public/io/domain_controller.h 2005-03-10 14:03:14 -05:00 @@ -10,6 +10,7 @@ #ifndef __XEN_PUBLIC_IO_DOMAIN_CONTROLLER_H__ #define __XEN_PUBLIC_IO_DOMAIN_CONTROLLER_H__ +#include "ring.h" /* * Reason codes for SCHEDOP_shutdown. These are opaque to Xen but may be @@ -33,15 +34,23 @@ u8 msg[60]; /* 4: type-specific message data */ } PACKED control_msg_t; /* 64 bytes */ +/* These are used by the control message deferred ring. */ #define CONTROL_RING_SIZE 8 typedef u32 CONTROL_RING_IDX; #define MASK_CONTROL_IDX(_i) ((_i)&(CONTROL_RING_SIZE-1)) +/* + * Generate control ring structures and types. + * + * CONTROL_RING_MEM is currently an 8-slot ring of ctrl_msg_t structs and + * two 32-bit counters: (64 * 8) + (2 * 4) = 520 + */ +#define CONTROL_RING_MEM 520 +DEFINE_RING_TYPES(ctrl, control_msg_t, control_msg_t, CONTROL_RING_MEM); + typedef struct { - control_msg_t tx_ring[CONTROL_RING_SIZE]; /* 0: guest -> controller */ - control_msg_t rx_ring[CONTROL_RING_SIZE]; /* 512: controller -> guest */ - CONTROL_RING_IDX tx_req_prod, tx_resp_prod; /* 1024, 1028 */ - CONTROL_RING_IDX rx_req_prod, rx_resp_prod; /* 1032, 1036 */ + ctrl_sring_t tx_ring; /* 0: guest -> controller */ + ctrl_sring_t rx_ring; /* 520: controller -> guest */ } PACKED control_if_t; /* 1040 bytes */ /* @@ -54,7 +63,8 @@ #define CMSG_NETIF_FE 4 /* Network-device frontend */ #define CMSG_SHUTDOWN 6 /* Shutdown messages */ #define CMSG_MEM_REQUEST 7 /* Memory reservation reqs */ - +#define CMSG_USBIF_BE 8 /* USB controller backend */ +#define CMSG_USBIF_FE 9 /* USB controller frontend */ /****************************************************************************** * CONSOLE DEFINITIONS @@ -435,6 +445,7 @@ #define CMSG_NETIF_BE_DESTROY 1 /* Destroy a net-device interface. */ #define CMSG_NETIF_BE_CONNECT 2 /* Connect i/f to remote driver. */ #define CMSG_NETIF_BE_DISCONNECT 3 /* Disconnect i/f from remote driver. */ +#define CMSG_NETIF_BE_CREDITLIMIT 4 /* Limit i/f to a given credit limit. */ /* Messages to domain controller. */ #define CMSG_NETIF_BE_DRIVER_STATUS 32 @@ -477,9 +488,11 @@ u32 netif_handle; /* 4: Domain-specific interface handle. */ u8 mac[6]; /* 8 */ u16 __pad1; /* 14 */ + u8 be_mac[6]; /* 16 */ + u16 __pad2; /* 22 */ /* OUT */ - u32 status; /* 16 */ -} PACKED netif_be_create_t; /* 20 bytes */ + u32 status; /* 24 */ +} PACKED netif_be_create_t; /* 28 bytes */ /* * CMSG_NETIF_BE_DESTROY: @@ -497,6 +510,22 @@ } PACKED netif_be_destroy_t; /* 12 bytes */ /* + * CMSG_NETIF_BE_CREDITLIMIT: + * Limit a virtual interface to "credit_bytes" bytes per "period_usec" + * microseconds. + */ +typedef struct { + /* IN */ + domid_t domid; /* 0: Domain attached to new interface. */ + u16 __pad0; /* 2 */ + u32 netif_handle; /* 4: Domain-specific interface handle. */ + u32 credit_bytes; /* 8: Vifs credit of bytes per period. */ + u32 period_usec; /* 12: Credit replenishment period. */ + /* OUT */ + u32 status; /* 16 */ +} PACKED netif_be_creditlimit_t; /* 20 bytes */ + +/* * CMSG_NETIF_BE_CONNECT: * When the driver sends a successful response then the interface is fully * connected. The controller will send a CONNECTED notification to the @@ -542,6 +571,208 @@ u32 status; /* 0: NETIF_DRIVER_STATUS_??? */ } PACKED netif_be_driver_status_t; /* 4 bytes */ + + +/****************************************************************************** + * USB-INTERFACE FRONTEND DEFINITIONS + */ + +/* Messages from domain controller to guest. */ +#define CMSG_USBIF_FE_INTERFACE_STATUS_CHANGED 0 + +/* Messages from guest to domain controller. */ +#define CMSG_USBIF_FE_DRIVER_STATUS_CHANGED 32 +#define CMSG_USBIF_FE_INTERFACE_CONNECT 33 +#define CMSG_USBIF_FE_INTERFACE_DISCONNECT 34 +/* + * CMSG_USBIF_FE_INTERFACE_STATUS_CHANGED: + * Notify a guest about a status change on one of its block interfaces. + * If the interface is DESTROYED or DOWN then the interface is disconnected: + * 1. The shared-memory frame is available for reuse. + * 2. Any unacknowledged messages pending on the interface were dropped. + */ +#define USBIF_INTERFACE_STATUS_DESTROYED 0 /* Interface doesn't exist. */ +#define USBIF_INTERFACE_STATUS_DISCONNECTED 1 /* Exists but is disconnected. */ +#define USBIF_INTERFACE_STATUS_CONNECTED 2 /* Exists and is connected. */ +typedef struct { + u32 status; /* 0 */ + u16 evtchn; /* 4: (only if status == BLKIF_INTERFACE_STATUS_CONNECTED). */ + domid_t domid; /* 6: status != BLKIF_INTERFACE_STATUS_DESTROYED */ + u32 bandwidth; /* 8 */ + u32 num_ports; /* 12 */ +} PACKED usbif_fe_interface_status_changed_t; /* 12 bytes */ + +/* + * CMSG_USBIF_FE_DRIVER_STATUS_CHANGED: + * Notify the domain controller that the front-end driver is DOWN or UP. + * When the driver goes DOWN then the controller will send no more + * status-change notifications. + * If the driver goes DOWN while interfaces are still UP, the domain + * will automatically take the interfaces DOWN. + * + * NB. The controller should not send an INTERFACE_STATUS_CHANGED message + * for interfaces that are active when it receives an UP notification. We + * expect that the frontend driver will query those interfaces itself. + */ +#define USBIF_DRIVER_STATUS_DOWN 0 +#define USBIF_DRIVER_STATUS_UP 1 +typedef struct { + /* IN */ + u32 status; /* 0: USBIF_DRIVER_STATUS_??? */ +} PACKED usbif_fe_driver_status_changed_t; /* 4 bytes */ + +/* + * CMSG_USBIF_FE_INTERFACE_CONNECT: + * If successful, the domain controller will acknowledge with a + * STATUS_CONNECTED message. + */ +typedef struct { + u32 __pad; + memory_t shmem_frame; /* 8 */ + MEMORY_PADDING; +} PACKED usbif_fe_interface_connect_t; /* 16 bytes */ + +/* + * CMSG_BLKIF_FE_INTERFACE_DISCONNECT: + * If successful, the domain controller will acknowledge with a + * STATUS_DISCONNECTED message. + */ +typedef struct {} PACKED usbif_fe_interface_disconnect_t; /* 4 bytes */ + + +/****************************************************************************** + * USB-INTERFACE BACKEND DEFINITIONS + */ + +/* Messages from domain controller. */ +#define CMSG_USBIF_BE_CREATE 0 /* Create a new block-device interface. */ +#define CMSG_USBIF_BE_DESTROY 1 /* Destroy a block-device interface. */ +#define CMSG_USBIF_BE_CONNECT 2 /* Connect i/f to remote driver. */ +#define CMSG_USBIF_BE_DISCONNECT 3 /* Disconnect i/f from remote driver. */ +#define CMSG_USBIF_BE_CLAIM_PORT 4 /* Claim host port for a domain. */ +#define CMSG_USBIF_BE_RELEASE_PORT 5 /* Release host port. */ +/* Messages to domain controller. */ +#define CMSG_USBIF_BE_DRIVER_STATUS_CHANGED 32 + +/* Non-specific 'okay' return. */ +#define USBIF_BE_STATUS_OKAY 0 +/* Non-specific 'error' return. */ +#define USBIF_BE_STATUS_ERROR 1 +/* The following are specific error returns. */ +#define USBIF_BE_STATUS_INTERFACE_EXISTS 2 +#define USBIF_BE_STATUS_INTERFACE_NOT_FOUND 3 +#define USBIF_BE_STATUS_INTERFACE_CONNECTED 4 +#define USBIF_BE_STATUS_OUT_OF_MEMORY 7 +#define USBIF_BE_STATUS_MAPPING_ERROR 9 + +/* This macro can be used to create an array of descriptive error strings. */ +#define USBIF_BE_STATUS_ERRORS { \ + "Okay", \ + "Non-specific error", \ + "Interface already exists", \ + "Interface not found", \ + "Interface is still connected", \ + "Out of memory", \ + "Could not map domain memory" } + +/* + * CMSG_USBIF_BE_CREATE: + * When the driver sends a successful response then the interface is fully + * created. The controller will send a DOWN notification to the front-end + * driver. + */ +typedef struct { + /* IN */ + domid_t domid; /* 0: Domain attached to new interface. */ + u16 __pad; + /* OUT */ + u32 status; /* 8 */ +} PACKED usbif_be_create_t; /* 12 bytes */ + +/* + * CMSG_USBIF_BE_DESTROY: + * When the driver sends a successful response then the interface is fully + * torn down. The controller will send a DESTROYED notification to the + * front-end driver. + */ +typedef struct { + /* IN */ + domid_t domid; /* 0: Identify interface to be destroyed. */ + u16 __pad; + /* OUT */ + u32 status; /* 8 */ +} PACKED usbif_be_destroy_t; /* 12 bytes */ + +/* + * CMSG_USBIF_BE_CONNECT: + * When the driver sends a successful response then the interface is fully + * connected. The controller will send a CONNECTED notification to the + * front-end driver. + */ +typedef struct { + /* IN */ + domid_t domid; /* 0: Domain attached to new interface. */ + u16 __pad; + memory_t shmem_frame; /* 8: Page cont. shared comms window. */ + MEMORY_PADDING; + u32 evtchn; /* 16: Event channel for notifications. */ + u32 bandwidth; /* 20: Bandwidth allocated for isoch / int - us + * per 1ms frame (ie between 0 and 900 or 800 + * depending on USB version). */ + /* OUT */ + u32 status; /* 24 */ +} PACKED usbif_be_connect_t; /* 28 bytes */ + |