Staging: hv: osd.h: fix GUID reference problem
[linux-2.6/mini2440.git] / drivers / staging / hv / include / VmbusApi.h
blobd038ad8d8b196958ca552b15397904ccd7b0c53b
1 /*
3 * Copyright (c) 2009, Microsoft Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
18 * Authors:
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
25 #ifndef _VMBUS_API_H_
26 #define _VMBUS_API_H_
30 /* Defines */
33 #define MAX_PAGE_BUFFER_COUNT 16
34 #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
36 /* Data types */
39 #pragma pack(push,1)
41 /* Single-page buffer */
42 typedef struct _PAGE_BUFFER {
43 u32 Length;
44 u32 Offset;
45 u64 Pfn;
46 } PAGE_BUFFER;
48 /* Multiple-page buffer */
49 typedef struct _MULTIPAGE_BUFFER {
50 /* Length and Offset determines the # of pfns in the array */
51 u32 Length;
52 u32 Offset;
53 u64 PfnArray[MAX_MULTIPAGE_BUFFER_COUNT];
54 }MULTIPAGE_BUFFER;
56 /* 0x18 includes the proprietary packet header */
57 #define MAX_PAGE_BUFFER_PACKET (0x18 + (sizeof(PAGE_BUFFER) * MAX_PAGE_BUFFER_COUNT))
58 #define MAX_MULTIPAGE_BUFFER_PACKET (0x18 + sizeof(MULTIPAGE_BUFFER))
61 #pragma pack(pop)
63 struct hv_driver;
64 struct hv_device;
66 /* All drivers */
67 typedef int (*PFN_ON_DEVICEADD)(struct hv_device *Device, void* AdditionalInfo);
68 typedef int (*PFN_ON_DEVICEREMOVE)(struct hv_device *Device);
69 typedef char** (*PFN_ON_GETDEVICEIDS)(void);
70 typedef void (*PFN_ON_CLEANUP)(struct hv_driver *Driver);
72 /* Vmbus extensions */
73 /* typedef int (*PFN_ON_MATCH)(struct hv_device *dev, struct hv_driver *drv); */
74 /* typedef int (*PFN_ON_PROBE)(struct hv_device *dev); */
75 typedef int (*PFN_ON_ISR)(struct hv_driver *drv);
76 typedef void (*PFN_ON_DPC)(struct hv_driver *drv);
77 typedef void (*PFN_GET_CHANNEL_OFFERS)(void);
79 typedef struct hv_device *(*PFN_ON_CHILDDEVICE_CREATE)(struct hv_guid *DeviceType, struct hv_guid *DeviceInstance, void *Context);
80 typedef void (*PFN_ON_CHILDDEVICE_DESTROY)(struct hv_device *Device);
81 typedef int (*PFN_ON_CHILDDEVICE_ADD)(struct hv_device *RootDevice, struct hv_device *ChildDevice);
82 typedef void (*PFN_ON_CHILDDEVICE_REMOVE)(struct hv_device *Device);
84 /* Vmbus channel interface */
85 typedef void (*VMBUS_CHANNEL_CALLBACK)(void * context);
87 typedef int (*VMBUS_CHANNEL_OPEN)(
88 struct hv_device *Device,
89 u32 SendBufferSize,
90 u32 RecvRingBufferSize,
91 void * UserData,
92 u32 UserDataLen,
93 VMBUS_CHANNEL_CALLBACK ChannelCallback,
94 void * Context
97 typedef void (*VMBUS_CHANNEL_CLOSE)(
98 struct hv_device *Device
101 typedef int (*VMBUS_CHANNEL_SEND_PACKET)(
102 struct hv_device *Device,
103 const void * Buffer,
104 u32 BufferLen,
105 u64 RequestId,
106 u32 Type,
107 u32 Flags
110 typedef int (*VMBUS_CHANNEL_SEND_PACKET_PAGEBUFFER)(
111 struct hv_device *Device,
112 PAGE_BUFFER PageBuffers[],
113 u32 PageCount,
114 void * Buffer,
115 u32 BufferLen,
116 u64 RequestId
119 typedef int (*VMBUS_CHANNEL_SEND_PACKET_MULTIPAGEBUFFER)(
120 struct hv_device *Device,
121 MULTIPAGE_BUFFER *MultiPageBuffer,
122 void * Buffer,
123 u32 BufferLen,
124 u64 RequestId
127 typedef int (*VMBUS_CHANNEL_RECV_PACKET)(
128 struct hv_device *Device,
129 void * Buffer,
130 u32 BufferLen,
131 u32* BufferActualLen,
132 u64* RequestId
135 typedef int (*VMBUS_CHANNEL_RECV_PACKET_PAW)(
136 struct hv_device *Device,
137 void * Buffer,
138 u32 BufferLen,
139 u32* BufferActualLen,
140 u64* RequestId
143 typedef int (*VMBUS_CHANNEL_ESTABLISH_GPADL)(
144 struct hv_device *Device,
145 void * Buffer, /* from kmalloc() */
146 u32 BufferLen, /* page-size multiple */
147 u32* GpadlHandle
150 typedef int (*VMBUS_CHANNEL_TEARDOWN_GPADL)(
151 struct hv_device *Device,
152 u32 GpadlHandle
156 typedef struct _PORT_INFO {
157 u32 InterruptMask;
158 u32 ReadIndex;
159 u32 WriteIndex;
160 u32 BytesAvailToRead;
161 u32 BytesAvailToWrite;
162 } PORT_INFO;
165 typedef struct _DEVICE_INFO {
166 u32 ChannelId;
167 u32 ChannelState;
168 struct hv_guid ChannelType;
169 struct hv_guid ChannelInstance;
171 u32 MonitorId;
172 u32 ServerMonitorPending;
173 u32 ServerMonitorLatency;
174 u32 ServerMonitorConnectionId;
175 u32 ClientMonitorPending;
176 u32 ClientMonitorLatency;
177 u32 ClientMonitorConnectionId;
179 PORT_INFO Inbound;
180 PORT_INFO Outbound;
181 } DEVICE_INFO;
183 typedef void (*VMBUS_GET_CHANNEL_INFO)(struct hv_device *Device, DEVICE_INFO* DeviceInfo);
185 typedef struct _VMBUS_CHANNEL_INTERFACE {
186 VMBUS_CHANNEL_OPEN Open;
187 VMBUS_CHANNEL_CLOSE Close;
188 VMBUS_CHANNEL_SEND_PACKET SendPacket;
189 VMBUS_CHANNEL_SEND_PACKET_PAGEBUFFER SendPacketPageBuffer;
190 VMBUS_CHANNEL_SEND_PACKET_MULTIPAGEBUFFER SendPacketMultiPageBuffer;
191 VMBUS_CHANNEL_RECV_PACKET RecvPacket;
192 VMBUS_CHANNEL_RECV_PACKET_PAW RecvPacketRaw;
193 VMBUS_CHANNEL_ESTABLISH_GPADL EstablishGpadl;
194 VMBUS_CHANNEL_TEARDOWN_GPADL TeardownGpadl;
195 VMBUS_GET_CHANNEL_INFO GetInfo;
196 } VMBUS_CHANNEL_INTERFACE;
198 typedef void (*VMBUS_GET_CHANNEL_INTERFACE)(VMBUS_CHANNEL_INTERFACE *Interface);
200 /* Base driver object */
201 struct hv_driver {
202 const char* name;
203 struct hv_guid deviceType; /* the device type supported by this driver */
205 PFN_ON_DEVICEADD OnDeviceAdd;
206 PFN_ON_DEVICEREMOVE OnDeviceRemove;
207 PFN_ON_GETDEVICEIDS OnGetDeviceIds; /* device ids supported by this driver */
208 PFN_ON_CLEANUP OnCleanup;
210 VMBUS_CHANNEL_INTERFACE VmbusChannelInterface;
214 /* Base device object */
215 struct hv_device {
216 struct hv_driver *Driver; /* the driver for this device */
217 char name[64];
218 struct hv_guid deviceType; /* the device type id of this device */
219 struct hv_guid deviceInstance; /* the device instance id of this device */
220 void* context;
221 void* Extension; /* Device extension; */
225 /* Vmbus driver object */
226 typedef struct _VMBUS_DRIVER_OBJECT {
227 struct hv_driver Base; /* !! Must be the 1st field !! */
229 /* Set by the caller */
230 PFN_ON_CHILDDEVICE_CREATE OnChildDeviceCreate;
231 PFN_ON_CHILDDEVICE_DESTROY OnChildDeviceDestroy;
232 PFN_ON_CHILDDEVICE_ADD OnChildDeviceAdd;
233 PFN_ON_CHILDDEVICE_REMOVE OnChildDeviceRemove;
235 /* Set by the callee */
236 /* PFN_ON_MATCH OnMatch; */
237 /* PFN_ON_PROBE OnProbe; */
238 PFN_ON_ISR OnIsr;
239 PFN_ON_DPC OnMsgDpc;
240 PFN_ON_DPC OnEventDpc;
241 PFN_GET_CHANNEL_OFFERS GetChannelOffers;
243 VMBUS_GET_CHANNEL_INTERFACE GetChannelInterface;
244 VMBUS_GET_CHANNEL_INFO GetChannelInfo;
245 } VMBUS_DRIVER_OBJECT;
249 /* Interface */
252 VmbusInitialize(
253 struct hv_driver *drv
256 #endif /* _VMBUS_API_H_ */