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