X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=drivers%2Fstaging%2Fhv%2FChannelMgmt.h;h=a839d8fe6cecb4777f13aac053a88f8d3074bf43;hb=dcbf77b9e86e1726f5fbd01bb98820dac06d456e;hp=6208cd847e1029363a28b64590c96a45a39d6e32;hpb=3d3b5518a35fa3c31b74224d944cbc83302c5ab4;p=~andy%2Flinux diff --git a/drivers/staging/hv/ChannelMgmt.h b/drivers/staging/hv/ChannelMgmt.h index 6208cd847e1..a839d8fe6ce 100644 --- a/drivers/staging/hv/ChannelMgmt.h +++ b/drivers/staging/hv/ChannelMgmt.h @@ -25,132 +25,295 @@ #ifndef _CHANNEL_MGMT_H_ #define _CHANNEL_MGMT_H_ -#include "include/osd.h" -#include "include/List.h" +#include #include "RingBuffer.h" +#include "VmbusChannelInterface.h" +#include "VmbusPacketFormat.h" + +/* Version 1 messages */ +enum vmbus_channel_message_type { + ChannelMessageInvalid = 0, + ChannelMessageOfferChannel = 1, + ChannelMessageRescindChannelOffer = 2, + ChannelMessageRequestOffers = 3, + ChannelMessageAllOffersDelivered = 4, + ChannelMessageOpenChannel = 5, + ChannelMessageOpenChannelResult = 6, + ChannelMessageCloseChannel = 7, + ChannelMessageGpadlHeader = 8, + ChannelMessageGpadlBody = 9, + ChannelMessageGpadlCreated = 10, + ChannelMessageGpadlTeardown = 11, + ChannelMessageGpadlTorndown = 12, + ChannelMessageRelIdReleased = 13, + ChannelMessageInitiateContact = 14, + ChannelMessageVersionResponse = 15, + ChannelMessageUnload = 16, +#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD + ChannelMessageViewRangeAdd = 17, + ChannelMessageViewRangeRemove = 18, +#endif + ChannelMessageCount +} __attribute__((packed)); + +struct vmbus_channel_message_header { + enum vmbus_channel_message_type MessageType; + u32 Padding; +} __attribute__((packed)); + +/* Query VMBus Version parameters */ +struct vmbus_channel_query_vmbus_version { + struct vmbus_channel_message_header Header; + u32 Version; +} __attribute__((packed)); + +/* VMBus Version Supported parameters */ +struct vmbus_channel_version_supported { + struct vmbus_channel_message_header Header; + bool VersionSupported; +} __attribute__((packed)); + +/* Offer Channel parameters */ +struct vmbus_channel_offer_channel { + struct vmbus_channel_message_header Header; + struct vmbus_channel_offer Offer; + u32 ChildRelId; + u8 MonitorId; + bool MonitorAllocated; +} __attribute__((packed)); + +/* Rescind Offer parameters */ +struct vmbus_channel_rescind_offer { + struct vmbus_channel_message_header Header; + u32 ChildRelId; +} __attribute__((packed)); -#include "include/VmbusChannelInterface.h" -#include "include/ChannelMessages.h" +/* + * Request Offer -- no parameters, SynIC message contains the partition ID + * Set Snoop -- no parameters, SynIC message contains the partition ID + * Clear Snoop -- no parameters, SynIC message contains the partition ID + * All Offers Delivered -- no parameters, SynIC message contains the partition + * ID + * Flush Client -- no parameters, SynIC message contains the partition ID + */ + +/* Open Channel parameters */ +struct vmbus_channel_open_channel { + struct vmbus_channel_message_header Header; + + /* Identifies the specific VMBus channel that is being opened. */ + u32 ChildRelId; + + /* ID making a particular open request at a channel offer unique. */ + u32 OpenId; + + /* GPADL for the channel's ring buffer. */ + u32 RingBufferGpadlHandle; + /* GPADL for the channel's server context save area. */ + u32 ServerContextAreaGpadlHandle; + /* + * The upstream ring buffer begins at offset zero in the memory + * described by RingBufferGpadlHandle. The downstream ring buffer + * follows it at this offset (in pages). + */ + u32 DownstreamRingBufferPageOffset; -typedef void (*PFN_CHANNEL_CALLBACK)(void * context); + /* User-specific data to be passed along to the server endpoint. */ + unsigned char UserData[MAX_USER_DEFINED_BYTES]; +} __attribute__((packed)); -typedef enum { +/* Open Channel Result parameters */ +struct vmbus_channel_open_result { + struct vmbus_channel_message_header Header; + u32 ChildRelId; + u32 OpenId; + u32 Status; +} __attribute__((packed)); + +/* Close channel parameters; */ +struct vmbus_channel_close_channel { + struct vmbus_channel_message_header Header; + u32 ChildRelId; +} __attribute__((packed)); + +/* Channel Message GPADL */ +#define GPADL_TYPE_RING_BUFFER 1 +#define GPADL_TYPE_SERVER_SAVE_AREA 2 +#define GPADL_TYPE_TRANSACTION 8 + +/* + * The number of PFNs in a GPADL message is defined by the number of + * pages that would be spanned by ByteCount and ByteOffset. If the + * implied number of PFNs won't fit in this packet, there will be a + * follow-up packet that contains more. + */ +struct vmbus_channel_gpadl_header { + struct vmbus_channel_message_header Header; + u32 ChildRelId; + u32 Gpadl; + u16 RangeBufLen; + u16 RangeCount; + struct gpa_range Range[0]; +} __attribute__((packed)); + +/* This is the followup packet that contains more PFNs. */ +struct vmbus_channel_gpadl_body { + struct vmbus_channel_message_header Header; + u32 MessageNumber; + u32 Gpadl; + u64 Pfn[0]; +} __attribute__((packed)); + +struct vmbus_channel_gpadl_created { + struct vmbus_channel_message_header Header; + u32 ChildRelId; + u32 Gpadl; + u32 CreationStatus; +} __attribute__((packed)); + +struct vmbus_channel_gpadl_teardown { + struct vmbus_channel_message_header Header; + u32 ChildRelId; + u32 Gpadl; +} __attribute__((packed)); + +struct vmbus_channel_gpadl_torndown { + struct vmbus_channel_message_header Header; + u32 Gpadl; +} __attribute__((packed)); + +#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD +struct vmbus_channel_view_range_add { + struct vmbus_channel_message_header Header; + PHYSICAL_ADDRESS ViewRangeBase; + u64 ViewRangeLength; + u32 ChildRelId; +} __attribute__((packed)); + +struct vmbus_channel_view_range_remove { + struct vmbus_channel_message_header Header; + PHYSICAL_ADDRESS ViewRangeBase; + u32 ChildRelId; +} __attribute__((packed)); +#endif + +struct vmbus_channel_relid_released { + struct vmbus_channel_message_header Header; + u32 ChildRelId; +} __attribute__((packed)); + +struct vmbus_channel_initiate_contact { + struct vmbus_channel_message_header Header; + u32 VMBusVersionRequested; + u32 Padding2; + u64 InterruptPage; + u64 MonitorPage1; + u64 MonitorPage2; +} __attribute__((packed)); + +struct vmbus_channel_version_response { + struct vmbus_channel_message_header Header; + bool VersionSupported; +} __attribute__((packed)); + +enum vmbus_channel_state { CHANNEL_OFFER_STATE, CHANNEL_OPENING_STATE, CHANNEL_OPEN_STATE, -} VMBUS_CHANNEL_STATE; +}; -typedef struct _VMBUS_CHANNEL { - LIST_ENTRY ListEntry; +struct vmbus_channel { + struct list_head ListEntry; struct hv_device *DeviceObject; - HANDLE PollTimer; /* SA-111 workaround */ + struct timer_list poll_timer; /* SA-111 workaround */ - VMBUS_CHANNEL_STATE State; + enum vmbus_channel_state State; - VMBUS_CHANNEL_OFFER_CHANNEL OfferMsg; - /* These are based on the OfferMsg.MonitorId. Save it here for easy access. */ - u8 MonitorGroup; - u8 MonitorBit; + struct vmbus_channel_offer_channel OfferMsg; + /* + * These are based on the OfferMsg.MonitorId. + * Save it here for easy access. + */ + u8 MonitorGroup; + u8 MonitorBit; - u32 RingBufferGpadlHandle; + u32 RingBufferGpadlHandle; /* Allocated memory for ring buffer */ - void * RingBufferPages; - u32 RingBufferPageCount; - RING_BUFFER_INFO Outbound; /* send to parent */ - RING_BUFFER_INFO Inbound; /* receive from parent */ + void *RingBufferPages; + u32 RingBufferPageCount; + RING_BUFFER_INFO Outbound; /* send to parent */ + RING_BUFFER_INFO Inbound; /* receive from parent */ spinlock_t inbound_lock; struct workqueue_struct *ControlWQ; /* Channel callback are invoked in this workqueue context */ - /* HANDLE dataWorkQueue; */ - - PFN_CHANNEL_CALLBACK OnChannelCallback; - void * ChannelCallbackContext; - -} VMBUS_CHANNEL; - - -typedef struct _VMBUS_CHANNEL_DEBUG_INFO { - u32 RelId; - VMBUS_CHANNEL_STATE State; - GUID InterfaceType; - GUID InterfaceInstance; - u32 MonitorId; - u32 ServerMonitorPending; - u32 ServerMonitorLatency; - u32 ServerMonitorConnectionId; - u32 ClientMonitorPending; - u32 ClientMonitorLatency; - u32 ClientMonitorConnectionId; - - RING_BUFFER_DEBUG_INFO Inbound; - RING_BUFFER_DEBUG_INFO Outbound; -} VMBUS_CHANNEL_DEBUG_INFO; - - -typedef union { - VMBUS_CHANNEL_VERSION_SUPPORTED VersionSupported; - VMBUS_CHANNEL_OPEN_RESULT OpenResult; - VMBUS_CHANNEL_GPADL_TORNDOWN GpadlTorndown; - VMBUS_CHANNEL_GPADL_CREATED GpadlCreated; - VMBUS_CHANNEL_VERSION_RESPONSE VersionResponse; -} VMBUS_CHANNEL_MESSAGE_RESPONSE; - + /* HANDLE dataWorkQueue; */ + + void (*OnChannelCallback)(void *context); + void *ChannelCallbackContext; +}; + +struct vmbus_channel_debug_info { + u32 RelId; + enum vmbus_channel_state State; + struct hv_guid InterfaceType; + struct hv_guid InterfaceInstance; + u32 MonitorId; + u32 ServerMonitorPending; + u32 ServerMonitorLatency; + u32 ServerMonitorConnectionId; + u32 ClientMonitorPending; + u32 ClientMonitorLatency; + u32 ClientMonitorConnectionId; + + RING_BUFFER_DEBUG_INFO Inbound; + RING_BUFFER_DEBUG_INFO Outbound; +}; /* * Represents each channel msg on the vmbus connection This is a * variable-size data structure depending on the msg type itself */ - -typedef struct _VMBUS_CHANNEL_MSGINFO { +struct vmbus_channel_msginfo { /* Bookkeeping stuff */ - LIST_ENTRY MsgListEntry; + struct list_head MsgListEntry; /* So far, this is only used to handle gpadl body message */ - LIST_ENTRY SubMsgList; + struct list_head SubMsgList; /* Synchronize the request/response if needed */ - HANDLE WaitEvent; - - VMBUS_CHANNEL_MESSAGE_RESPONSE Response; + struct osd_waitevent *WaitEvent; - u32 MessageSize; - /* The channel message that goes out on the "wire". */ - /* It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header */ - unsigned char Msg[0]; -} VMBUS_CHANNEL_MSGINFO; + union { + struct vmbus_channel_version_supported VersionSupported; + struct vmbus_channel_open_result OpenResult; + struct vmbus_channel_gpadl_torndown GpadlTorndown; + struct vmbus_channel_gpadl_created GpadlCreated; + struct vmbus_channel_version_response VersionResponse; + } Response; + u32 MessageSize; + /* + * The channel message that goes out on the "wire". + * It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header + */ + unsigned char Msg[0]; +}; -/* Routines */ -static VMBUS_CHANNEL* -AllocVmbusChannel( - void - ); +struct vmbus_channel *AllocVmbusChannel(void); -static void -FreeVmbusChannel( - VMBUS_CHANNEL *Channel - ); +void FreeVmbusChannel(struct vmbus_channel *Channel); -static void -VmbusOnChannelMessage( - void *Context - ); +void VmbusOnChannelMessage(void *Context); -static int -VmbusChannelRequestOffers( - void - ); +int VmbusChannelRequestOffers(void); -static void -VmbusChannelReleaseUnattachedChannels( - void - ); +void VmbusChannelReleaseUnattachedChannels(void); #endif /* _CHANNEL_MGMT_H_ */