]> Pileus Git - ~andy/linux/blob - drivers/staging/hv/Channel.h
Staging: hv: remove UINT32 and INT32 typedefs
[~andy/linux] / drivers / staging / hv / Channel.h
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
24
25 #ifndef _CHANNEL_H_
26 #define _CHANNEL_H_
27
28 #include "include/osd.h"
29 #include "ChannelMgmt.h"
30
31 #pragma pack(push,1)
32
33
34 // The format must be the same as VMDATA_GPA_DIRECT
35 typedef struct _VMBUS_CHANNEL_PACKET_PAGE_BUFFER {
36     u16                         Type;
37     u16                         DataOffset8;
38     u16                         Length8;
39     u16                         Flags;
40     UINT64                              TransactionId;
41         u32                             Reserved;
42         u32                             RangeCount;
43     PAGE_BUFFER                 Range[MAX_PAGE_BUFFER_COUNT];
44 } VMBUS_CHANNEL_PACKET_PAGE_BUFFER;
45
46
47 // The format must be the same as VMDATA_GPA_DIRECT
48 typedef struct _VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER {
49     u16                         Type;
50     u16                         DataOffset8;
51     u16                         Length8;
52     u16                         Flags;
53     UINT64                              TransactionId;
54         u32                             Reserved;
55         u32                             RangeCount;             // Always 1 in this case
56         MULTIPAGE_BUFFER        Range;
57 } VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER;
58
59 #pragma pack(pop)
60
61 //
62 // Routines
63 //
64
65 static int
66 VmbusChannelOpen(
67         VMBUS_CHANNEL                   *Channel,
68         u32                                     SendRingBufferSize,
69         u32                                     RecvRingBufferSize,
70         void *                                  UserData,
71         u32                                     UserDataLen,
72         PFN_CHANNEL_CALLBACK    pfnOnChannelCallback,
73         void *                                  Context
74         );
75
76 static void
77 VmbusChannelClose(
78         VMBUS_CHANNEL           *Channel
79         );
80
81 static int
82 VmbusChannelSendPacket(
83         VMBUS_CHANNEL           *Channel,
84         const void *                    Buffer,
85         u32                             BufferLen,
86         UINT64                          RequestId,
87         VMBUS_PACKET_TYPE       Type,
88         u32                             Flags
89 );
90
91 static int
92 VmbusChannelSendPacketPageBuffer(
93         VMBUS_CHANNEL           *Channel,
94         PAGE_BUFFER                     PageBuffers[],
95         u32                             PageCount,
96         void *                          Buffer,
97         u32                             BufferLen,
98         UINT64                          RequestId
99         );
100
101 static int
102 VmbusChannelSendPacketMultiPageBuffer(
103         VMBUS_CHANNEL           *Channel,
104         MULTIPAGE_BUFFER        *MultiPageBuffer,
105         void *                          Buffer,
106         u32                             BufferLen,
107         UINT64                          RequestId
108 );
109
110 static int
111 VmbusChannelEstablishGpadl(
112         VMBUS_CHANNEL           *Channel,
113         void *                          Kbuffer,        // from kmalloc()
114         u32                             Size,           // page-size multiple
115         u32                             *GpadlHandle
116         );
117
118 static int
119 VmbusChannelTeardownGpadl(
120         VMBUS_CHANNEL   *Channel,
121         u32                     GpadlHandle
122         );
123
124 static int
125 VmbusChannelRecvPacket(
126         VMBUS_CHANNEL           *Channel,
127         void *                          Buffer,
128         u32                             BufferLen,
129         u32*                            BufferActualLen,
130         UINT64*                         RequestId
131         );
132
133 static int
134 VmbusChannelRecvPacketRaw(
135         VMBUS_CHANNEL           *Channel,
136         void *                          Buffer,
137         u32                             BufferLen,
138         u32*                            BufferActualLen,
139         UINT64*                         RequestId
140         );
141
142 static void
143 VmbusChannelOnChannelEvent(
144         VMBUS_CHANNEL           *Channel
145         );
146
147 static void
148 VmbusChannelGetDebugInfo(
149         VMBUS_CHANNEL                           *Channel,
150         VMBUS_CHANNEL_DEBUG_INFO        *DebugInfo
151         );
152
153 static void
154 VmbusChannelOnTimer(
155         void            *Context
156         );
157 #endif //_CHANNEL_H_