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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
/*
*
* Copyright (c) 2009, Microsoft Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Authors:
* Haiyang Zhang <haiyangz@microsoft.com>
* Hank Janssen <hjanssen@microsoft.com>
*
*/
#include "VmbusPrivate.h"
static int
IVmbusChannelOpen(
PDEVICE_OBJECT Device,
u32 SendBufferSize,
u32 RecvRingBufferSize,
void * UserData,
u32 UserDataLen,
VMBUS_CHANNEL_CALLBACK ChannelCallback,
void * Context
)
{
return VmbusChannelOpen( (VMBUS_CHANNEL*)Device->context,
SendBufferSize,
RecvRingBufferSize,
UserData,
UserDataLen,
ChannelCallback,
Context);
}
static void
IVmbusChannelClose(
PDEVICE_OBJECT Device
)
{
VmbusChannelClose((VMBUS_CHANNEL*)Device->context);
}
static int
IVmbusChannelSendPacket(
PDEVICE_OBJECT Device,
const void * Buffer,
u32 BufferLen,
u64 RequestId,
u32 Type,
u32 Flags
)
{
return VmbusChannelSendPacket((VMBUS_CHANNEL*)Device->context,
Buffer,
BufferLen,
RequestId,
Type,
Flags);
}
static int
IVmbusChannelSendPacketPageBuffer(
PDEVICE_OBJECT Device,
PAGE_BUFFER PageBuffers[],
u32 PageCount,
void * Buffer,
u32 BufferLen,
u64 RequestId
)
{
return VmbusChannelSendPacketPageBuffer((VMBUS_CHANNEL*)Device->context,
PageBuffers,
PageCount,
Buffer,
BufferLen,
RequestId);
}
static int
IVmbusChannelSendPacketMultiPageBuffer(
PDEVICE_OBJECT Device,
MULTIPAGE_BUFFER *MultiPageBuffer,
void * Buffer,
u32 BufferLen,
u64 RequestId
)
{
return VmbusChannelSendPacketMultiPageBuffer((VMBUS_CHANNEL*)Device->context,
MultiPageBuffer,
Buffer,
BufferLen,
RequestId);
}
static int
IVmbusChannelRecvPacket (
PDEVICE_OBJECT Device,
void * Buffer,
u32 BufferLen,
u32* BufferActualLen,
u64* RequestId
)
{
return VmbusChannelRecvPacket((VMBUS_CHANNEL*)Device->context,
Buffer,
BufferLen,
BufferActualLen,
RequestId);
}
static int
IVmbusChannelRecvPacketRaw(
PDEVICE_OBJECT Device,
void * Buffer,
u32 BufferLen,
u32* BufferActualLen,
u64* RequestId
)
{
return VmbusChannelRecvPacketRaw((VMBUS_CHANNEL*)Device->context,
Buffer,
BufferLen,
BufferActualLen,
RequestId);
}
static int
IVmbusChannelEstablishGpadl(
PDEVICE_OBJECT Device,
void * Buffer,
u32 BufferLen,
u32* GpadlHandle
)
{
return VmbusChannelEstablishGpadl((VMBUS_CHANNEL*)Device->context,
Buffer,
BufferLen,
GpadlHandle);
}
static int
IVmbusChannelTeardownGpadl(
PDEVICE_OBJECT Device,
u32 GpadlHandle
)
{
return VmbusChannelTeardownGpadl((VMBUS_CHANNEL*)Device->context,
GpadlHandle);
}
static void
GetChannelInterface(
VMBUS_CHANNEL_INTERFACE *ChannelInterface
)
{
ChannelInterface->Open = IVmbusChannelOpen;
ChannelInterface->Close = IVmbusChannelClose;
ChannelInterface->SendPacket = IVmbusChannelSendPacket;
ChannelInterface->SendPacketPageBuffer = IVmbusChannelSendPacketPageBuffer;
ChannelInterface->SendPacketMultiPageBuffer = IVmbusChannelSendPacketMultiPageBuffer;
ChannelInterface->RecvPacket = IVmbusChannelRecvPacket;
ChannelInterface->RecvPacketRaw = IVmbusChannelRecvPacketRaw;
ChannelInterface->EstablishGpadl = IVmbusChannelEstablishGpadl;
ChannelInterface->TeardownGpadl = IVmbusChannelTeardownGpadl;
ChannelInterface->GetInfo = GetChannelInfo;
}
static void
GetChannelInfo(
PDEVICE_OBJECT Device,
DEVICE_INFO *DeviceInfo
)
{
VMBUS_CHANNEL_DEBUG_INFO debugInfo;
if (Device->context)
{
VmbusChannelGetDebugInfo((VMBUS_CHANNEL*)Device->context, &debugInfo);
DeviceInfo->ChannelId = debugInfo.RelId;
DeviceInfo->ChannelState = debugInfo.State;
memcpy(&DeviceInfo->ChannelType, &debugInfo.InterfaceType, sizeof(GUID));
memcpy(&DeviceInfo->ChannelInstance, &debugInfo.InterfaceInstance, sizeof(GUID));
DeviceInfo->MonitorId = debugInfo.MonitorId;
DeviceInfo->ServerMonitorPending = debugInfo.ServerMonitorPending;
DeviceInfo->ServerMonitorLatency = debugInfo.ServerMonitorLatency;
DeviceInfo->ServerMonitorConnectionId = debugInfo.ServerMonitorConnectionId;
DeviceInfo->ClientMonitorPending = debugInfo.ClientMonitorPending;
DeviceInfo->ClientMonitorLatency = debugInfo.ClientMonitorLatency;
DeviceInfo->ClientMonitorConnectionId = debugInfo.ClientMonitorConnectionId;
DeviceInfo->Inbound.InterruptMask = debugInfo.Inbound.CurrentInterruptMask;
DeviceInfo->Inbound.ReadIndex = debugInfo.Inbound.CurrentReadIndex;
DeviceInfo->Inbound.WriteIndex = debugInfo.Inbound.CurrentWriteIndex;
DeviceInfo->Inbound.BytesAvailToRead = debugInfo.Inbound.BytesAvailToRead;
DeviceInfo->Inbound.BytesAvailToWrite = debugInfo.Inbound.BytesAvailToWrite;
DeviceInfo->Outbound.InterruptMask = debugInfo.Outbound.CurrentInterruptMask;
DeviceInfo->Outbound.ReadIndex = debugInfo.Outbound.CurrentReadIndex;
DeviceInfo->Outbound.WriteIndex = debugInfo.Outbound.CurrentWriteIndex;
DeviceInfo->Outbound.BytesAvailToRead = debugInfo.Outbound.BytesAvailToRead;
DeviceInfo->Outbound.BytesAvailToWrite = debugInfo.Outbound.BytesAvailToWrite;
}
}
|