]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/staging/hv/channel_interface.c
4032e9c46f20c40c2d07237f12a5363715988e4e
[karo-tx-linux.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 ivmbus_open(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->channel, sendbuffer_size,
35                                 recv_ringbuffer_size, userdata, userdatalen,
36                                 channel_callback, context);
37 }
38
39 static void ivmbus_close(struct hv_device *device)
40 {
41         vmbus_close(device->channel);
42 }
43
44 static int ivmbus_sendpacket(struct hv_device *device, const void *buffer,
45                                    u32 bufferlen, u64 requestid, u32 type,
46                                    u32 flags)
47 {
48         return vmbus_sendpacket(device->channel, buffer, bufferlen,
49                                       requestid, type, flags);
50 }
51
52 static int ivmbus_sendpacket_pagebuffer(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->channel, pagebuffers,
58                                                 pagecount, buffer, bufferlen,
59                                                 requestid);
60 }
61
62 /* vmbus interface function pointer table */
63 const struct vmbus_channel_interface vmbus_ops = {
64         .Open = ivmbus_open,
65         .Close = ivmbus_close,
66         .SendPacket = ivmbus_sendpacket,
67         .SendPacketPageBuffer = ivmbus_sendpacket_pagebuffer,
68 };