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>
28 #define MAX_PAGE_BUFFER_COUNT 16
29 #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
33 /* Single-page buffer */
34 struct hv_page_buffer
{
40 /* Multiple-page buffer */
41 struct hv_multipage_buffer
{
42 /* Length and Offset determines the # of pfns in the array */
45 u64 PfnArray
[MAX_MULTIPAGE_BUFFER_COUNT
];
48 /* 0x18 includes the proprietary packet header */
49 #define MAX_PAGE_BUFFER_PACKET (0x18 + \
50 (sizeof(struct hv_page_buffer) * \
51 MAX_PAGE_BUFFER_COUNT))
52 #define MAX_MULTIPAGE_BUFFER_PACKET (0x18 + \
53 sizeof(struct hv_multipage_buffer))
61 struct hv_dev_port_info
{
66 u32 BytesAvailToWrite
;
69 struct hv_device_info
{
72 struct hv_guid ChannelType
;
73 struct hv_guid ChannelInstance
;
76 u32 ServerMonitorPending
;
77 u32 ServerMonitorLatency
;
78 u32 ServerMonitorConnectionId
;
79 u32 ClientMonitorPending
;
80 u32 ClientMonitorLatency
;
81 u32 ClientMonitorConnectionId
;
83 struct hv_dev_port_info Inbound
;
84 struct hv_dev_port_info Outbound
;
88 * struct vmbus_channel_interface - Contains member functions for vmbus channel
89 * @Open: Open the channel
90 * @Close: Close the channel
91 * @SendPacket: Send a packet over the channel
92 * @SendPacketPageBuffer: Send a single page buffer over the channel
94 * This structure contains function pointer to control vmbus channel
95 * behavior. None of these functions is externally callable, but they
96 * are used for normal vmbus channel internal behavior.
97 * Only used by Hyper-V drivers.
99 struct vmbus_channel_interface
{
100 int (*Open
)(struct hv_device
*Device
, u32 SendBufferSize
,
101 u32 RecvRingBufferSize
, void *UserData
, u32 UserDataLen
,
102 void (*ChannelCallback
)(void *context
),
104 void (*Close
)(struct hv_device
*device
);
105 int (*SendPacket
)(struct hv_device
*Device
, const void *Buffer
,
106 u32 BufferLen
, u64 RequestId
, u32 Type
, u32 Flags
);
107 int (*SendPacketPageBuffer
)(struct hv_device
*dev
,
108 struct hv_page_buffer PageBuffers
[],
109 u32 PageCount
, void *Buffer
, u32 BufferLen
,
113 extern const struct vmbus_channel_interface vmbus_ops
;
116 /* Base driver object */
120 /* the device type supported by this driver */
121 struct hv_guid deviceType
;
123 int (*OnDeviceAdd
)(struct hv_device
*device
, void *data
);
124 int (*OnDeviceRemove
)(struct hv_device
*device
);
125 void (*OnCleanup
)(struct hv_driver
*driver
);
127 struct vmbus_channel_interface VmbusChannelInterface
;
130 /* Base device object */
132 /* the driver for this device */
133 struct hv_driver
*Driver
;
137 /* the device type id of this device */
138 struct hv_guid deviceType
;
140 /* the device instance id of this device */
141 struct hv_guid deviceInstance
;
143 struct vmbus_channel
*channel
;
145 /* Device extension; */
149 /* Vmbus driver object */
150 struct vmbus_driver
{
151 /* !! Must be the 1st field !! */
152 /* FIXME if ^, then someone is doing somthing stupid */
153 struct hv_driver Base
;
155 /* Set by the caller */
156 struct hv_device
* (*OnChildDeviceCreate
)(struct hv_guid
*DeviceType
,
157 struct hv_guid
*DeviceInstance
,
158 struct vmbus_channel
*channel
);
159 void (*OnChildDeviceDestroy
)(struct hv_device
*device
);
160 int (*OnChildDeviceAdd
)(struct hv_device
*RootDevice
,
161 struct hv_device
*ChildDevice
);
162 void (*OnChildDeviceRemove
)(struct hv_device
*device
);
164 /* Set by the callee */
165 int (*OnIsr
)(struct hv_driver
*driver
);
166 void (*OnMsgDpc
)(struct hv_driver
*driver
);
167 void (*OnEventDpc
)(struct hv_driver
*driver
);
168 void (*GetChannelOffers
)(void);
171 int VmbusInitialize(struct hv_driver
*drv
);
173 #endif /* _VMBUS_API_H_ */