diff options
author | Hank Janssen <hjanssen@microsoft.com> | 2009-07-13 16:02:34 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-15 12:01:43 -0700 |
commit | 3e7ee4902fe6996048f03433dd111426db3cfa92 (patch) | |
tree | c42d158ecca25ddb0b99a400fa2682eeaa0aa82e /drivers/staging/hv/VmbusPrivate.h | |
parent | Staging: hv: add the Hyper-V driver header files (diff) | |
download | linux-dev-3e7ee4902fe6996048f03433dd111426db3cfa92.tar.xz linux-dev-3e7ee4902fe6996048f03433dd111426db3cfa92.zip |
Staging: hv: add the Hyper-V virtual bus
This is the virtual bus that all of the Linux Hyper-V drivers use.
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/hv/VmbusPrivate.h')
-rw-r--r-- | drivers/staging/hv/VmbusPrivate.h | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/drivers/staging/hv/VmbusPrivate.h b/drivers/staging/hv/VmbusPrivate.h new file mode 100644 index 000000000000..5e86165dea28 --- /dev/null +++ b/drivers/staging/hv/VmbusPrivate.h @@ -0,0 +1,170 @@ +/* + * + * Copyright (c) 2009, Microsoft Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place - Suite 330, Boston, MA 02111-1307 USA. + * + * Authors: + * Haiyang Zhang <haiyangz@microsoft.com> + * Hank Janssen <hjanssen@microsoft.com> + * + */ + + +#ifndef _VMBUS_PRIVATE_H_ +#define _VMBUS_PRIVATE_H_ + +#ifndef INTERNAL +#define INTERNAL static +#endif + +#include "Hv.h" +#include "VmbusApi.h" +#include "Channel.h" +#include "ChannelMgmt.h" +#include "ChannelInterface.h" +//#include "ChannelMessages.h" +#include "RingBuffer.h" +//#include "Packet.h" +#include "List.h" + +// +// Defines +// + +// Maximum channels is determined by the size of the interrupt page which is PAGE_SIZE. 1/2 of PAGE_SIZE is for +// send endpoint interrupt and the other is receive endpoint interrupt +#define MAX_NUM_CHANNELS (PAGE_SIZE >> 1) << 3 // 16348 channels + +// The value here must be in multiple of 32 +// TODO: Need to make this configurable +#define MAX_NUM_CHANNELS_SUPPORTED 256 + +// +// Data types +// + +typedef enum { + Disconnected, + Connecting, + Connected, + Disconnecting +} VMBUS_CONNECT_STATE; + +#define MAX_SIZE_CHANNEL_MESSAGE HV_MESSAGE_PAYLOAD_BYTE_COUNT + +typedef struct _VMBUS_CONNECTION { + + VMBUS_CONNECT_STATE ConnectState; + + UINT32 NextGpadlHandle; + + // Represents channel interrupts. Each bit position + // represents a channel. + // When a channel sends an interrupt via VMBUS, it + // finds its bit in the sendInterruptPage, set it and + // calls Hv to generate a port event. The other end + // receives the port event and parse the recvInterruptPage + // to see which bit is set + VOID* InterruptPage; + VOID* SendInterruptPage; + VOID* RecvInterruptPage; + + // 2 pages - 1st page for parent->child notification and 2nd is child->parent notification + VOID* MonitorPages; + LIST_ENTRY ChannelMsgList; + HANDLE ChannelMsgLock; + + // List of channels + LIST_ENTRY ChannelList; + HANDLE ChannelLock; + + HANDLE WorkQueue; +} VMBUS_CONNECTION; + + +typedef struct _VMBUS_MSGINFO { + // Bookkeeping stuff + LIST_ENTRY MsgListEntry; + + // Synchronize the request/response if needed + HANDLE WaitEvent; + + // The message itself + unsigned char Msg[0]; +} VMBUS_MSGINFO; + + +// +// Externs +// +extern VMBUS_CONNECTION gVmbusConnection; + +// +// General vmbus interface +// +INTERNAL DEVICE_OBJECT* +VmbusChildDeviceCreate( + GUID deviceType, + GUID deviceInstance, + void *context); + +INTERNAL int +VmbusChildDeviceAdd( + DEVICE_OBJECT* Device); + +INTERNAL void +VmbusChildDeviceRemove( + DEVICE_OBJECT* Device); + +//INTERNAL void +//VmbusChildDeviceDestroy( +// DEVICE_OBJECT*); + +INTERNAL VMBUS_CHANNEL* +GetChannelFromRelId( + UINT32 relId + ); + +// +// Connection interface +// +INTERNAL int +VmbusConnect( + VOID + ); + +INTERNAL int +VmbusDisconnect( + VOID + ); + +INTERNAL int +VmbusPostMessage( + PVOID buffer, + SIZE_T bufSize + ); + +INTERNAL int +VmbusSetEvent( + UINT32 childRelId + ); + +INTERNAL VOID +VmbusOnEvents( + VOID + ); + + +#endif // _VMBUS_PRIVATE_H_ |