Staging: hv: remove function pointer typedefs from VmbusApi.h
[wandboard.git] / drivers / staging / hv / ChannelInterface.c
blob019b064f7cb3d7130269a4445716f3389bc90373
1 /*
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
12 * more details.
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.
18 * Authors:
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
23 #include <linux/kernel.h>
24 #include <linux/mm.h>
25 #include "osd.h"
26 #include "VmbusPrivate.h"
28 static int IVmbusChannelOpen(struct hv_device *device, u32 SendBufferSize,
29 u32 RecvRingBufferSize, void *UserData,
30 u32 UserDataLen,
31 void (*ChannelCallback)(void *context),
32 void *Context)
34 return VmbusChannelOpen(device->context, SendBufferSize,
35 RecvRingBufferSize, UserData, UserDataLen,
36 ChannelCallback, Context);
39 static void IVmbusChannelClose(struct hv_device *device)
41 VmbusChannelClose(device->context);
44 static int IVmbusChannelSendPacket(struct hv_device *device, const void *Buffer,
45 u32 BufferLen, u64 RequestId, u32 Type,
46 u32 Flags)
48 return VmbusChannelSendPacket(device->context, Buffer, BufferLen,
49 RequestId, Type, Flags);
52 static int IVmbusChannelSendPacketPageBuffer(struct hv_device *device,
53 struct hv_page_buffer PageBuffers[],
54 u32 PageCount, void *Buffer,
55 u32 BufferLen, u64 RequestId)
57 return VmbusChannelSendPacketPageBuffer(device->context, PageBuffers,
58 PageCount, Buffer, BufferLen,
59 RequestId);
62 static int IVmbusChannelSendPacketMultiPageBuffer(struct hv_device *device,
63 struct hv_multipage_buffer *MultiPageBuffer,
64 void *Buffer, u32 BufferLen, u64 RequestId)
66 return VmbusChannelSendPacketMultiPageBuffer(device->context,
67 MultiPageBuffer, Buffer,
68 BufferLen, RequestId);
71 static int IVmbusChannelRecvPacket(struct hv_device *device, void *Buffer,
72 u32 BufferLen, u32 *BufferActualLen,
73 u64 *RequestId)
75 return VmbusChannelRecvPacket(device->context, Buffer, BufferLen,
76 BufferActualLen, RequestId);
79 static int IVmbusChannelRecvPacketRaw(struct hv_device *device, void *Buffer,
80 u32 BufferLen, u32 *BufferActualLen,
81 u64 *RequestId)
83 return VmbusChannelRecvPacketRaw(device->context, Buffer, BufferLen,
84 BufferActualLen, RequestId);
87 static int IVmbusChannelEstablishGpadl(struct hv_device *device, void *Buffer,
88 u32 BufferLen, u32 *GpadlHandle)
90 return VmbusChannelEstablishGpadl(device->context, Buffer, BufferLen,
91 GpadlHandle);
94 static int IVmbusChannelTeardownGpadl(struct hv_device *device, u32 GpadlHandle)
96 return VmbusChannelTeardownGpadl(device->context, GpadlHandle);
100 void GetChannelInterface(struct vmbus_channel_interface *iface)
102 iface->Open = IVmbusChannelOpen;
103 iface->Close = IVmbusChannelClose;
104 iface->SendPacket = IVmbusChannelSendPacket;
105 iface->SendPacketPageBuffer = IVmbusChannelSendPacketPageBuffer;
106 iface->SendPacketMultiPageBuffer =
107 IVmbusChannelSendPacketMultiPageBuffer;
108 iface->RecvPacket = IVmbusChannelRecvPacket;
109 iface->RecvPacketRaw = IVmbusChannelRecvPacketRaw;
110 iface->EstablishGpadl = IVmbusChannelEstablishGpadl;
111 iface->TeardownGpadl = IVmbusChannelTeardownGpadl;
112 iface->GetInfo = GetChannelInfo;
115 void GetChannelInfo(struct hv_device *device, struct hv_device_info *info)
117 struct vmbus_channel_debug_info debugInfo;
119 if (!device->context)
120 return;
122 VmbusChannelGetDebugInfo(device->context, &debugInfo);
124 info->ChannelId = debugInfo.RelId;
125 info->ChannelState = debugInfo.State;
126 memcpy(&info->ChannelType, &debugInfo.InterfaceType,
127 sizeof(struct hv_guid));
128 memcpy(&info->ChannelInstance, &debugInfo.InterfaceInstance,
129 sizeof(struct hv_guid));
131 info->MonitorId = debugInfo.MonitorId;
133 info->ServerMonitorPending = debugInfo.ServerMonitorPending;
134 info->ServerMonitorLatency = debugInfo.ServerMonitorLatency;
135 info->ServerMonitorConnectionId = debugInfo.ServerMonitorConnectionId;
137 info->ClientMonitorPending = debugInfo.ClientMonitorPending;
138 info->ClientMonitorLatency = debugInfo.ClientMonitorLatency;
139 info->ClientMonitorConnectionId = debugInfo.ClientMonitorConnectionId;
141 info->Inbound.InterruptMask = debugInfo.Inbound.CurrentInterruptMask;
142 info->Inbound.ReadIndex = debugInfo.Inbound.CurrentReadIndex;
143 info->Inbound.WriteIndex = debugInfo.Inbound.CurrentWriteIndex;
144 info->Inbound.BytesAvailToRead = debugInfo.Inbound.BytesAvailToRead;
145 info->Inbound.BytesAvailToWrite = debugInfo.Inbound.BytesAvailToWrite;
147 info->Outbound.InterruptMask = debugInfo.Outbound.CurrentInterruptMask;
148 info->Outbound.ReadIndex = debugInfo.Outbound.CurrentReadIndex;
149 info->Outbound.WriteIndex = debugInfo.Outbound.CurrentWriteIndex;
150 info->Outbound.BytesAvailToRead = debugInfo.Outbound.BytesAvailToRead;
151 info->Outbound.BytesAvailToWrite = debugInfo.Outbound.BytesAvailToWrite;