1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#ifndef _VMBUS_API_H_
26#define _VMBUS_API_H_
27
28#define MAX_PAGE_BUFFER_COUNT 16
29#define MAX_MULTIPAGE_BUFFER_COUNT 32
30
31#pragma pack(push, 1)
32
33
34struct hv_page_buffer {
35 u32 Length;
36 u32 Offset;
37 u64 Pfn;
38};
39
40
41struct hv_multipage_buffer {
42
43 u32 Length;
44 u32 Offset;
45 u64 PfnArray[MAX_MULTIPAGE_BUFFER_COUNT];
46};
47
48
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))
54
55
56#pragma pack(pop)
57
58struct hv_driver;
59struct hv_device;
60
61struct hv_dev_port_info {
62 u32 InterruptMask;
63 u32 ReadIndex;
64 u32 WriteIndex;
65 u32 BytesAvailToRead;
66 u32 BytesAvailToWrite;
67};
68
69struct hv_device_info {
70 u32 ChannelId;
71 u32 ChannelState;
72 struct hv_guid ChannelType;
73 struct hv_guid ChannelInstance;
74
75 u32 MonitorId;
76 u32 ServerMonitorPending;
77 u32 ServerMonitorLatency;
78 u32 ServerMonitorConnectionId;
79 u32 ClientMonitorPending;
80 u32 ClientMonitorLatency;
81 u32 ClientMonitorConnectionId;
82
83 struct hv_dev_port_info Inbound;
84 struct hv_dev_port_info Outbound;
85};
86
87struct vmbus_channel_interface {
88 int (*Open)(struct hv_device *Device, u32 SendBufferSize,
89 u32 RecvRingBufferSize, void *UserData, u32 UserDataLen,
90 void (*ChannelCallback)(void *context),
91 void *Context);
92 void (*Close)(struct hv_device *device);
93 int (*SendPacket)(struct hv_device *Device, const void *Buffer,
94 u32 BufferLen, u64 RequestId, u32 Type, u32 Flags);
95 int (*SendPacketPageBuffer)(struct hv_device *dev,
96 struct hv_page_buffer PageBuffers[],
97 u32 PageCount, void *Buffer, u32 BufferLen,
98 u64 RequestId);
99 int (*SendPacketMultiPageBuffer)(struct hv_device *device,
100 struct hv_multipage_buffer *mpb,
101 void *Buffer,
102 u32 BufferLen,
103 u64 RequestId);
104 int (*RecvPacket)(struct hv_device *dev, void *buf, u32 buflen,
105 u32 *BufferActualLen, u64 *RequestId);
106 int (*RecvPacketRaw)(struct hv_device *dev, void *buf, u32 buflen,
107 u32 *BufferActualLen, u64 *RequestId);
108 int (*EstablishGpadl)(struct hv_device *dev, void *buf, u32 buflen,
109 u32 *GpadlHandle);
110 int (*TeardownGpadl)(struct hv_device *device, u32 GpadlHandle);
111 void (*GetInfo)(struct hv_device *dev, struct hv_device_info *devinfo);
112};
113
114
115struct hv_driver {
116 const char *name;
117
118
119 struct hv_guid deviceType;
120
121 int (*OnDeviceAdd)(struct hv_device *device, void *data);
122 int (*OnDeviceRemove)(struct hv_device *device);
123 void (*OnCleanup)(struct hv_driver *driver);
124
125 struct vmbus_channel_interface VmbusChannelInterface;
126};
127
128
129struct hv_device {
130
131 struct hv_driver *Driver;
132
133 char name[64];
134
135
136 struct hv_guid deviceType;
137
138
139 struct hv_guid deviceInstance;
140
141 void *context;
142
143
144 void *Extension;
145};
146
147
148struct vmbus_driver {
149
150
151 struct hv_driver Base;
152
153
154 struct hv_device * (*OnChildDeviceCreate)(struct hv_guid *DeviceType,
155 struct hv_guid *DeviceInstance,
156 void *Context);
157 void (*OnChildDeviceDestroy)(struct hv_device *device);
158 int (*OnChildDeviceAdd)(struct hv_device *RootDevice,
159 struct hv_device *ChildDevice);
160 void (*OnChildDeviceRemove)(struct hv_device *device);
161
162
163 int (*OnIsr)(struct hv_driver *driver);
164 void (*OnMsgDpc)(struct hv_driver *driver);
165 void (*OnEventDpc)(struct hv_driver *driver);
166 void (*GetChannelOffers)(void);
167
168 void (*GetChannelInterface)(struct vmbus_channel_interface *i);
169 void (*GetChannelInfo)(struct hv_device *dev,
170 struct hv_device_info *devinfo);
171};
172
173int VmbusInitialize(struct hv_driver *drv);
174
175#endif
176