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>
33 #define MAX_PAGE_BUFFER_COUNT 16
34 #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
41 /* Single-page buffer */
42 typedef struct _PAGE_BUFFER
{
48 /* Multiple-page buffer */
49 typedef struct _MULTIPAGE_BUFFER
{
50 /* Length and Offset determines the # of pfns in the array */
53 u64 PfnArray
[MAX_MULTIPAGE_BUFFER_COUNT
];
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))
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
,
90 u32 RecvRingBufferSize
,
93 VMBUS_CHANNEL_CALLBACK ChannelCallback
,
97 typedef void (*VMBUS_CHANNEL_CLOSE
)(
98 struct hv_device
*Device
101 typedef int (*VMBUS_CHANNEL_SEND_PACKET
)(
102 struct hv_device
*Device
,
110 typedef int (*VMBUS_CHANNEL_SEND_PACKET_PAGEBUFFER
)(
111 struct hv_device
*Device
,
112 PAGE_BUFFER PageBuffers
[],
119 typedef int (*VMBUS_CHANNEL_SEND_PACKET_MULTIPAGEBUFFER
)(
120 struct hv_device
*Device
,
121 MULTIPAGE_BUFFER
*MultiPageBuffer
,
127 typedef int (*VMBUS_CHANNEL_RECV_PACKET
)(
128 struct hv_device
*Device
,
131 u32
* BufferActualLen
,
135 typedef int (*VMBUS_CHANNEL_RECV_PACKET_PAW
)(
136 struct hv_device
*Device
,
139 u32
* BufferActualLen
,
143 typedef int (*VMBUS_CHANNEL_ESTABLISH_GPADL
)(
144 struct hv_device
*Device
,
145 void * Buffer
, /* from kmalloc() */
146 u32 BufferLen
, /* page-size multiple */
150 typedef int (*VMBUS_CHANNEL_TEARDOWN_GPADL
)(
151 struct hv_device
*Device
,
156 typedef struct _PORT_INFO
{
160 u32 BytesAvailToRead
;
161 u32 BytesAvailToWrite
;
165 typedef struct _DEVICE_INFO
{
168 struct hv_guid ChannelType
;
169 struct hv_guid ChannelInstance
;
172 u32 ServerMonitorPending
;
173 u32 ServerMonitorLatency
;
174 u32 ServerMonitorConnectionId
;
175 u32 ClientMonitorPending
;
176 u32 ClientMonitorLatency
;
177 u32 ClientMonitorConnectionId
;
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 */
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 */
216 struct hv_driver
*Driver
; /* the driver for this device */
218 struct hv_guid deviceType
; /* the device type id of this device */
219 struct hv_guid deviceInstance
; /* the device instance id of this device */
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; */
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
;
253 struct hv_driver
*drv
256 #endif /* _VMBUS_API_H_ */