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>
24 #include "VmbusPrivate.h"
28 PDEVICE_OBJECT Device,
29 UINT32 SendBufferSize,
30 UINT32 RecvRingBufferSize,
33 VMBUS_CHANNEL_CALLBACK ChannelCallback,
37 return VmbusChannelOpen( (VMBUS_CHANNEL*)Device->context,
52 VmbusChannelClose((VMBUS_CHANNEL*)Device->context);
57 IVmbusChannelSendPacket(
58 PDEVICE_OBJECT Device,
66 return VmbusChannelSendPacket((VMBUS_CHANNEL*)Device->context,
75 IVmbusChannelSendPacketPageBuffer(
76 PDEVICE_OBJECT Device,
77 PAGE_BUFFER PageBuffers[],
84 return VmbusChannelSendPacketPageBuffer((VMBUS_CHANNEL*)Device->context,
93 IVmbusChannelSendPacketMultiPageBuffer(
94 PDEVICE_OBJECT Device,
95 MULTIPAGE_BUFFER *MultiPageBuffer,
101 return VmbusChannelSendPacketMultiPageBuffer((VMBUS_CHANNEL*)Device->context,
109 IVmbusChannelRecvPacket (
110 PDEVICE_OBJECT Device,
113 UINT32* BufferActualLen,
117 return VmbusChannelRecvPacket((VMBUS_CHANNEL*)Device->context,
125 IVmbusChannelRecvPacketRaw(
126 PDEVICE_OBJECT Device,
129 UINT32* BufferActualLen,
133 return VmbusChannelRecvPacketRaw((VMBUS_CHANNEL*)Device->context,
141 IVmbusChannelEstablishGpadl(
142 PDEVICE_OBJECT Device,
148 return VmbusChannelEstablishGpadl((VMBUS_CHANNEL*)Device->context,
155 IVmbusChannelTeardownGpadl(
156 PDEVICE_OBJECT Device,
160 return VmbusChannelTeardownGpadl((VMBUS_CHANNEL*)Device->context,
167 VMBUS_CHANNEL_INTERFACE *ChannelInterface
170 ChannelInterface->Open = IVmbusChannelOpen;
171 ChannelInterface->Close = IVmbusChannelClose;
172 ChannelInterface->SendPacket = IVmbusChannelSendPacket;
173 ChannelInterface->SendPacketPageBuffer = IVmbusChannelSendPacketPageBuffer;
174 ChannelInterface->SendPacketMultiPageBuffer = IVmbusChannelSendPacketMultiPageBuffer;
175 ChannelInterface->RecvPacket = IVmbusChannelRecvPacket;
176 ChannelInterface->RecvPacketRaw = IVmbusChannelRecvPacketRaw;
177 ChannelInterface->EstablishGpadl = IVmbusChannelEstablishGpadl;
178 ChannelInterface->TeardownGpadl = IVmbusChannelTeardownGpadl;
179 ChannelInterface->GetInfo = GetChannelInfo;
185 PDEVICE_OBJECT Device,
186 DEVICE_INFO *DeviceInfo
189 VMBUS_CHANNEL_DEBUG_INFO debugInfo;
193 VmbusChannelGetDebugInfo((VMBUS_CHANNEL*)Device->context, &debugInfo);
195 DeviceInfo->ChannelId = debugInfo.RelId;
196 DeviceInfo->ChannelState = debugInfo.State;
197 memcpy(&DeviceInfo->ChannelType, &debugInfo.InterfaceType, sizeof(GUID));
198 memcpy(&DeviceInfo->ChannelInstance, &debugInfo.InterfaceInstance, sizeof(GUID));
200 DeviceInfo->MonitorId = debugInfo.MonitorId;
202 DeviceInfo->ServerMonitorPending = debugInfo.ServerMonitorPending;
203 DeviceInfo->ServerMonitorLatency = debugInfo.ServerMonitorLatency;
204 DeviceInfo->ServerMonitorConnectionId = debugInfo.ServerMonitorConnectionId;
206 DeviceInfo->ClientMonitorPending = debugInfo.ClientMonitorPending;
207 DeviceInfo->ClientMonitorLatency = debugInfo.ClientMonitorLatency;
208 DeviceInfo->ClientMonitorConnectionId = debugInfo.ClientMonitorConnectionId;
210 DeviceInfo->Inbound.InterruptMask = debugInfo.Inbound.CurrentInterruptMask;
211 DeviceInfo->Inbound.ReadIndex = debugInfo.Inbound.CurrentReadIndex;
212 DeviceInfo->Inbound.WriteIndex = debugInfo.Inbound.CurrentWriteIndex;
213 DeviceInfo->Inbound.BytesAvailToRead = debugInfo.Inbound.BytesAvailToRead;
214 DeviceInfo->Inbound.BytesAvailToWrite = debugInfo.Inbound.BytesAvailToWrite;
216 DeviceInfo->Outbound.InterruptMask = debugInfo.Outbound.CurrentInterruptMask;
217 DeviceInfo->Outbound.ReadIndex = debugInfo.Outbound.CurrentReadIndex;
218 DeviceInfo->Outbound.WriteIndex = debugInfo.Outbound.CurrentWriteIndex;
219 DeviceInfo->Outbound.BytesAvailToRead = debugInfo.Outbound.BytesAvailToRead;
220 DeviceInfo->Outbound.BytesAvailToWrite = debugInfo.Outbound.BytesAvailToWrite;