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
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.
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
34 #define MAX_PAGE_BUFFER_COUNT 16
35 #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
39 /* Fwd declarations */
41 typedef struct _DRIVER_OBJECT
*PDRIVER_OBJECT
;
49 /* Single-page buffer */
50 typedef struct _PAGE_BUFFER
{
56 /* Multiple-page buffer */
57 typedef struct _MULTIPAGE_BUFFER
{
58 /* Length and Offset determines the # of pfns in the array */
61 u64 PfnArray
[MAX_MULTIPAGE_BUFFER_COUNT
];
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))
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
);
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);
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
);
91 /* Vmbus channel interface */
92 typedef void (*VMBUS_CHANNEL_CALLBACK
)(void * context
);
94 typedef int (*VMBUS_CHANNEL_OPEN
)(
95 struct hv_device
*Device
,
97 u32 RecvRingBufferSize
,
100 VMBUS_CHANNEL_CALLBACK ChannelCallback
,
104 typedef void (*VMBUS_CHANNEL_CLOSE
)(
105 struct hv_device
*Device
108 typedef int (*VMBUS_CHANNEL_SEND_PACKET
)(
109 struct hv_device
*Device
,
117 typedef int (*VMBUS_CHANNEL_SEND_PACKET_PAGEBUFFER
)(
118 struct hv_device
*Device
,
119 PAGE_BUFFER PageBuffers
[],
126 typedef int (*VMBUS_CHANNEL_SEND_PACKET_MULTIPAGEBUFFER
)(
127 struct hv_device
*Device
,
128 MULTIPAGE_BUFFER
*MultiPageBuffer
,
134 typedef int (*VMBUS_CHANNEL_RECV_PACKET
)(
135 struct hv_device
*Device
,
138 u32
* BufferActualLen
,
142 typedef int (*VMBUS_CHANNEL_RECV_PACKET_PAW
)(
143 struct hv_device
*Device
,
146 u32
* BufferActualLen
,
150 typedef int (*VMBUS_CHANNEL_ESTABLISH_GPADL
)(
151 struct hv_device
*Device
,
152 void * Buffer
, /* from kmalloc() */
153 u32 BufferLen
, /* page-size multiple */
157 typedef int (*VMBUS_CHANNEL_TEARDOWN_GPADL
)(
158 struct hv_device
*Device
,
163 typedef struct _PORT_INFO
{
167 u32 BytesAvailToRead
;
168 u32 BytesAvailToWrite
;
172 typedef struct _DEVICE_INFO
{
176 GUID ChannelInstance
;
179 u32 ServerMonitorPending
;
180 u32 ServerMonitorLatency
;
181 u32 ServerMonitorConnectionId
;
182 u32 ClientMonitorPending
;
183 u32 ClientMonitorLatency
;
184 u32 ClientMonitorConnectionId
;
190 typedef void (*VMBUS_GET_CHANNEL_INFO
)(struct hv_device
*Device
, DEVICE_INFO
* DeviceInfo
);
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
;
205 typedef void (*VMBUS_GET_CHANNEL_INTERFACE
)(VMBUS_CHANNEL_INTERFACE
*Interface
);
207 /* Base driver object */
208 typedef struct _DRIVER_OBJECT
{
210 GUID deviceType
; /* the device type supported by this driver */
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
;
217 VMBUS_CHANNEL_INTERFACE VmbusChannelInterface
;
221 /* Base device object */
223 DRIVER_OBJECT
* Driver
; /* the driver for this device */
225 GUID deviceType
; /* the device type id of this device */
226 GUID deviceInstance
; /* the device instance id of this device */
228 void* Extension
; /* Device extension; */
232 /* Vmbus driver object */
233 typedef struct _VMBUS_DRIVER_OBJECT
{
234 DRIVER_OBJECT Base
; /* !! Must be the 1st field !! */
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
;
242 /* Set by the callee */
243 /* PFN_ON_MATCH OnMatch; */
244 /* PFN_ON_PROBE OnProbe; */
247 PFN_ON_DPC OnEventDpc
;
248 PFN_GET_CHANNEL_OFFERS GetChannelOffers
;
250 VMBUS_GET_CHANNEL_INTERFACE GetChannelInterface
;
251 VMBUS_GET_CHANNEL_INFO GetChannelInfo
;
252 } VMBUS_DRIVER_OBJECT
;
263 #endif /* _VMBUS_API_H_ */