staging: hv: Convert camel cased local variables in channel_interface.c to lower...
[pandora-kernel.git] / drivers / staging / hv / channel_interface.c
1 /*
2  *
3  * Copyright (c) 2009, Microsoft Corporation.
4  *
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.
8  *
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.
13  *
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.
17  *
18  * Authors:
19  *   Haiyang Zhang <haiyangz@microsoft.com>
20  *   Hank Janssen  <hjanssen@microsoft.com>
21  *
22  */
23 #include <linux/kernel.h>
24 #include <linux/mm.h>
25 #include "osd.h"
26 #include "vmbus_private.h"
27
28 static int IVmbusChannelOpen(struct hv_device *device, u32 sendbuffer_size,
29                              u32 recv_ringbuffer_size, void *userdata,
30                              u32 userdatalen,
31                              void (*channel_callback)(void *context),
32                              void *context)
33 {
34         return vmbus_open(device->context, sendbuffer_size,
35                                 recv_ringbuffer_size, userdata, userdatalen,
36                                 channel_callback, context);
37 }
38
39 static void IVmbusChannelClose(struct hv_device *device)
40 {
41         vmbus_close(device->context);
42 }
43
44 static int IVmbusChannelSendPacket(struct hv_device *device, const void *buffer,
45                                    u32 bufferlen, u64 requestid, u32 type,
46                                    u32 flags)
47 {
48         return vmbus_sendpacket(device->context, buffer, bufferlen,
49                                       requestid, type, flags);
50 }
51
52 static int IVmbusChannelSendPacketPageBuffer(struct hv_device *device,
53                                 struct hv_page_buffer pagebuffers[],
54                                 u32 pagecount, void *buffer,
55                                 u32 bufferlen, u64 requestid)
56 {
57         return vmbus_sendpacket_pagebuffer(device->context, pagebuffers,
58                                                 pagecount, buffer, bufferlen,
59                                                 requestid);
60 }
61
62 static int IVmbusChannelSendPacketMultiPageBuffer(struct hv_device *device,
63                                 struct hv_multipage_buffer *multi_pagebuffer,
64                                 void *buffer, u32 bufferlen, u64 requestid)
65 {
66         return vmbus_sendpacket_multipagebuffer(device->context,
67                                                      multi_pagebuffer, buffer,
68                                                      bufferlen, requestid);
69 }
70
71 static int IVmbusChannelRecvPacket(struct hv_device *device, void *buffer,
72                                    u32 bufferlen, u32 *buffer_actuallen,
73                                    u64 *requestid)
74 {
75         return vmbus_recvpacket(device->context, buffer, bufferlen,
76                                       buffer_actuallen, requestid);
77 }
78
79 static int IVmbusChannelRecvPacketRaw(struct hv_device *device, void *buffer,
80                                       u32 bufferlen, u32 *buffer_actuallen,
81                                       u64 *requestid)
82 {
83         return vmbus_recvpacket_raw(device->context, buffer, bufferlen,
84                                          buffer_actuallen, requestid);
85 }
86
87 static int IVmbusChannelEstablishGpadl(struct hv_device *device, void *buffer,
88                                        u32 bufferlen, u32 *gpadl_handle)
89 {
90         return vmbus_establish_gpadl(device->context, buffer, bufferlen,
91                                           gpadl_handle);
92 }
93
94 static int IVmbusChannelTeardownGpadl(struct hv_device *device,
95                                       u32 gpadl_handle)
96 {
97         return vmbus_teardown_gpadl(device->context, gpadl_handle);
98
99 }
100
101
102 void GetChannelInfo(struct hv_device *device, struct hv_device_info *info)
103 {
104         struct vmbus_channel_debug_info debug_info;
105
106         if (!device->context)
107                 return;
108
109         vmbus_get_debug_info(device->context, &debug_info);
110
111         info->ChannelId = debug_info.RelId;
112         info->ChannelState = debug_info.State;
113         memcpy(&info->ChannelType, &debug_info.InterfaceType,
114                sizeof(struct hv_guid));
115         memcpy(&info->ChannelInstance, &debug_info.InterfaceInstance,
116                sizeof(struct hv_guid));
117
118         info->MonitorId = debug_info.MonitorId;
119
120         info->ServerMonitorPending = debug_info.ServerMonitorPending;
121         info->ServerMonitorLatency = debug_info.ServerMonitorLatency;
122         info->ServerMonitorConnectionId = debug_info.ServerMonitorConnectionId;
123
124         info->ClientMonitorPending = debug_info.ClientMonitorPending;
125         info->ClientMonitorLatency = debug_info.ClientMonitorLatency;
126         info->ClientMonitorConnectionId = debug_info.ClientMonitorConnectionId;
127
128         info->Inbound.InterruptMask = debug_info.Inbound.CurrentInterruptMask;
129         info->Inbound.ReadIndex = debug_info.Inbound.CurrentReadIndex;
130         info->Inbound.WriteIndex = debug_info.Inbound.CurrentWriteIndex;
131         info->Inbound.BytesAvailToRead = debug_info.Inbound.BytesAvailToRead;
132         info->Inbound.BytesAvailToWrite = debug_info.Inbound.BytesAvailToWrite;
133
134         info->Outbound.InterruptMask = debug_info.Outbound.CurrentInterruptMask;
135         info->Outbound.ReadIndex = debug_info.Outbound.CurrentReadIndex;
136         info->Outbound.WriteIndex = debug_info.Outbound.CurrentWriteIndex;
137         info->Outbound.BytesAvailToRead = debug_info.Outbound.BytesAvailToRead;
138         info->Outbound.BytesAvailToWrite =
139                 debug_info.Outbound.BytesAvailToWrite;
140 }
141
142
143 /* vmbus interface function pointer table */
144 const struct vmbus_channel_interface vmbus_ops = {
145         .Open = IVmbusChannelOpen,
146         .Close = IVmbusChannelClose,
147         .SendPacket = IVmbusChannelSendPacket,
148         .SendPacketPageBuffer = IVmbusChannelSendPacketPageBuffer,
149         .SendPacketMultiPageBuffer = IVmbusChannelSendPacketMultiPageBuffer,
150         .RecvPacket = IVmbusChannelRecvPacket,
151         .RecvPacketRaw  = IVmbusChannelRecvPacketRaw,
152         .EstablishGpadl = IVmbusChannelEstablishGpadl,
153         .TeardownGpadl = IVmbusChannelTeardownGpadl,
154         .GetInfo = GetChannelInfo,
155 };