Staging: hv: Transform PDEVICE_OBJECT and DEVICE_OBJECT typedefs into their correspon...
[deliverable/linux.git] / drivers / staging / hv / include / VmbusApi.h
1 /*
2 *
3 * Copyright (c) 2009, Microsoft Corporation.
4 *
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.
8 *
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.
13 *
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.
17 *
18 * Authors:
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
21 *
22 */
23
24
25 #ifndef _VMBUS_API_H_
26 #define _VMBUS_API_H_
27
28 #include "osd.h"
29
30
31 /* Defines */
32
33
34 #define MAX_PAGE_BUFFER_COUNT 16
35 #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
36
37
38
39 /* Fwd declarations */
40
41 typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
42
43
44 /* Data types */
45
46
47 #pragma pack(push,1)
48
49 /* Single-page buffer */
50 typedef struct _PAGE_BUFFER {
51 u32 Length;
52 u32 Offset;
53 u64 Pfn;
54 } PAGE_BUFFER;
55
56 /* Multiple-page buffer */
57 typedef struct _MULTIPAGE_BUFFER {
58 /* Length and Offset determines the # of pfns in the array */
59 u32 Length;
60 u32 Offset;
61 u64 PfnArray[MAX_MULTIPAGE_BUFFER_COUNT];
62 }MULTIPAGE_BUFFER;
63
64 /* 0x18 includes the proprietary packet header */
65 #define MAX_PAGE_BUFFER_PACKET (0x18 + (sizeof(PAGE_BUFFER) * MAX_PAGE_BUFFER_COUNT))
66 #define MAX_MULTIPAGE_BUFFER_PACKET (0x18 + sizeof(MULTIPAGE_BUFFER))
67
68
69 #pragma pack(pop)
70
71 struct hv_device;
72
73 /* All drivers */
74 typedef int (*PFN_ON_DEVICEADD)(struct hv_device *Device, void* AdditionalInfo);
75 typedef int (*PFN_ON_DEVICEREMOVE)(struct hv_device *Device);
76 typedef char** (*PFN_ON_GETDEVICEIDS)(void);
77 typedef void (*PFN_ON_CLEANUP)(PDRIVER_OBJECT Driver);
78
79 /* Vmbus extensions */
80 /* typedef int (*PFN_ON_MATCH)(struct hv_device *dev, PDRIVER_OBJECT drv); */
81 /* typedef int (*PFN_ON_PROBE)(struct hv_device *dev); */
82 typedef int (*PFN_ON_ISR)(PDRIVER_OBJECT drv);
83 typedef void (*PFN_ON_DPC)(PDRIVER_OBJECT drv);
84 typedef void (*PFN_GET_CHANNEL_OFFERS)(void);
85
86 typedef struct hv_device *(*PFN_ON_CHILDDEVICE_CREATE)(GUID DeviceType, GUID DeviceInstance, void *Context);
87 typedef void (*PFN_ON_CHILDDEVICE_DESTROY)(struct hv_device *Device);
88 typedef int (*PFN_ON_CHILDDEVICE_ADD)(struct hv_device *RootDevice, struct hv_device *ChildDevice);
89 typedef void (*PFN_ON_CHILDDEVICE_REMOVE)(struct hv_device *Device);
90
91 /* Vmbus channel interface */
92 typedef void (*VMBUS_CHANNEL_CALLBACK)(void * context);
93
94 typedef int (*VMBUS_CHANNEL_OPEN)(
95 struct hv_device *Device,
96 u32 SendBufferSize,
97 u32 RecvRingBufferSize,
98 void * UserData,
99 u32 UserDataLen,
100 VMBUS_CHANNEL_CALLBACK ChannelCallback,
101 void * Context
102 );
103
104 typedef void (*VMBUS_CHANNEL_CLOSE)(
105 struct hv_device *Device
106 );
107
108 typedef int (*VMBUS_CHANNEL_SEND_PACKET)(
109 struct hv_device *Device,
110 const void * Buffer,
111 u32 BufferLen,
112 u64 RequestId,
113 u32 Type,
114 u32 Flags
115 );
116
117 typedef int (*VMBUS_CHANNEL_SEND_PACKET_PAGEBUFFER)(
118 struct hv_device *Device,
119 PAGE_BUFFER PageBuffers[],
120 u32 PageCount,
121 void * Buffer,
122 u32 BufferLen,
123 u64 RequestId
124 );
125
126 typedef int (*VMBUS_CHANNEL_SEND_PACKET_MULTIPAGEBUFFER)(
127 struct hv_device *Device,
128 MULTIPAGE_BUFFER *MultiPageBuffer,
129 void * Buffer,
130 u32 BufferLen,
131 u64 RequestId
132 );
133
134 typedef int (*VMBUS_CHANNEL_RECV_PACKET)(
135 struct hv_device *Device,
136 void * Buffer,
137 u32 BufferLen,
138 u32* BufferActualLen,
139 u64* RequestId
140 );
141
142 typedef int (*VMBUS_CHANNEL_RECV_PACKET_PAW)(
143 struct hv_device *Device,
144 void * Buffer,
145 u32 BufferLen,
146 u32* BufferActualLen,
147 u64* RequestId
148 );
149
150 typedef int (*VMBUS_CHANNEL_ESTABLISH_GPADL)(
151 struct hv_device *Device,
152 void * Buffer, /* from kmalloc() */
153 u32 BufferLen, /* page-size multiple */
154 u32* GpadlHandle
155 );
156
157 typedef int (*VMBUS_CHANNEL_TEARDOWN_GPADL)(
158 struct hv_device *Device,
159 u32 GpadlHandle
160 );
161
162
163 typedef struct _PORT_INFO {
164 u32 InterruptMask;
165 u32 ReadIndex;
166 u32 WriteIndex;
167 u32 BytesAvailToRead;
168 u32 BytesAvailToWrite;
169 } PORT_INFO;
170
171
172 typedef struct _DEVICE_INFO {
173 u32 ChannelId;
174 u32 ChannelState;
175 GUID ChannelType;
176 GUID ChannelInstance;
177
178 u32 MonitorId;
179 u32 ServerMonitorPending;
180 u32 ServerMonitorLatency;
181 u32 ServerMonitorConnectionId;
182 u32 ClientMonitorPending;
183 u32 ClientMonitorLatency;
184 u32 ClientMonitorConnectionId;
185
186 PORT_INFO Inbound;
187 PORT_INFO Outbound;
188 } DEVICE_INFO;
189
190 typedef void (*VMBUS_GET_CHANNEL_INFO)(struct hv_device *Device, DEVICE_INFO* DeviceInfo);
191
192 typedef struct _VMBUS_CHANNEL_INTERFACE {
193 VMBUS_CHANNEL_OPEN Open;
194 VMBUS_CHANNEL_CLOSE Close;
195 VMBUS_CHANNEL_SEND_PACKET SendPacket;
196 VMBUS_CHANNEL_SEND_PACKET_PAGEBUFFER SendPacketPageBuffer;
197 VMBUS_CHANNEL_SEND_PACKET_MULTIPAGEBUFFER SendPacketMultiPageBuffer;
198 VMBUS_CHANNEL_RECV_PACKET RecvPacket;
199 VMBUS_CHANNEL_RECV_PACKET_PAW RecvPacketRaw;
200 VMBUS_CHANNEL_ESTABLISH_GPADL EstablishGpadl;
201 VMBUS_CHANNEL_TEARDOWN_GPADL TeardownGpadl;
202 VMBUS_GET_CHANNEL_INFO GetInfo;
203 } VMBUS_CHANNEL_INTERFACE;
204
205 typedef void (*VMBUS_GET_CHANNEL_INTERFACE)(VMBUS_CHANNEL_INTERFACE *Interface);
206
207 /* Base driver object */
208 typedef struct _DRIVER_OBJECT {
209 const char* name;
210 GUID deviceType; /* the device type supported by this driver */
211
212 PFN_ON_DEVICEADD OnDeviceAdd;
213 PFN_ON_DEVICEREMOVE OnDeviceRemove;
214 PFN_ON_GETDEVICEIDS OnGetDeviceIds; /* device ids supported by this driver */
215 PFN_ON_CLEANUP OnCleanup;
216
217 VMBUS_CHANNEL_INTERFACE VmbusChannelInterface;
218 } DRIVER_OBJECT;
219
220
221 /* Base device object */
222 struct hv_device {
223 DRIVER_OBJECT* Driver; /* the driver for this device */
224 char name[64];
225 GUID deviceType; /* the device type id of this device */
226 GUID deviceInstance; /* the device instance id of this device */
227 void* context;
228 void* Extension; /* Device extension; */
229 };
230
231
232 /* Vmbus driver object */
233 typedef struct _VMBUS_DRIVER_OBJECT {
234 DRIVER_OBJECT Base; /* !! Must be the 1st field !! */
235
236 /* Set by the caller */
237 PFN_ON_CHILDDEVICE_CREATE OnChildDeviceCreate;
238 PFN_ON_CHILDDEVICE_DESTROY OnChildDeviceDestroy;
239 PFN_ON_CHILDDEVICE_ADD OnChildDeviceAdd;
240 PFN_ON_CHILDDEVICE_REMOVE OnChildDeviceRemove;
241
242 /* Set by the callee */
243 /* PFN_ON_MATCH OnMatch; */
244 /* PFN_ON_PROBE OnProbe; */
245 PFN_ON_ISR OnIsr;
246 PFN_ON_DPC OnMsgDpc;
247 PFN_ON_DPC OnEventDpc;
248 PFN_GET_CHANNEL_OFFERS GetChannelOffers;
249
250 VMBUS_GET_CHANNEL_INTERFACE GetChannelInterface;
251 VMBUS_GET_CHANNEL_INFO GetChannelInfo;
252 } VMBUS_DRIVER_OBJECT;
253
254
255
256 /* Interface */
257
258 int
259 VmbusInitialize(
260 DRIVER_OBJECT* drv
261 );
262
263 #endif /* _VMBUS_API_H_ */
This page took 0.039041 seconds and 5 git commands to generate.