]> Pileus Git - ~andy/linux/blob - drivers/staging/hv/VmbusPrivate.h
Staging: hv: remove UINT32 and INT32 typedefs
[~andy/linux] / drivers / staging / hv / VmbusPrivate.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 _VMBUS_PRIVATE_H_
26 #define _VMBUS_PRIVATE_H_
27
28 #include "Hv.h"
29 #include "include/VmbusApi.h"
30 #include "Channel.h"
31 #include "ChannelMgmt.h"
32 #include "ChannelInterface.h"
33 //#include "ChannelMessages.h"
34 #include "RingBuffer.h"
35 //#include "Packet.h"
36 #include "include/List.h"
37
38 //
39 // Defines
40 //
41
42 // Maximum channels is determined by the size of the interrupt page which is PAGE_SIZE. 1/2 of PAGE_SIZE is for
43 // send endpoint interrupt and the other is receive endpoint interrupt
44 #define MAX_NUM_CHANNELS                                (PAGE_SIZE >> 1) << 3  // 16348 channels
45
46 // The value here must be in multiple of 32
47 // TODO: Need to make this configurable
48 #define MAX_NUM_CHANNELS_SUPPORTED              256
49
50 //
51 // Data types
52 //
53
54 typedef enum {
55         Disconnected,
56         Connecting,
57         Connected,
58         Disconnecting
59 } VMBUS_CONNECT_STATE;
60
61 #define MAX_SIZE_CHANNEL_MESSAGE                        HV_MESSAGE_PAYLOAD_BYTE_COUNT
62
63 typedef struct _VMBUS_CONNECTION {
64
65         VMBUS_CONNECT_STATE                                     ConnectState;
66
67         u32                                                             NextGpadlHandle;
68
69         // Represents channel interrupts. Each bit position
70         // represents a channel.
71         // When a channel sends an interrupt via VMBUS, it
72         // finds its bit in the sendInterruptPage, set it and
73         // calls Hv to generate a port event. The other end
74         // receives the port event and parse the recvInterruptPage
75         // to see which bit is set
76         void *                                                          InterruptPage;
77         void *                                                          SendInterruptPage;
78         void *                                                          RecvInterruptPage;
79
80         // 2 pages - 1st page for parent->child notification and 2nd is child->parent notification
81         void *                                                          MonitorPages;
82         LIST_ENTRY                                                      ChannelMsgList;
83         HANDLE                                                          ChannelMsgLock;
84
85         // List of channels
86         LIST_ENTRY                                                      ChannelList;
87         HANDLE                                                          ChannelLock;
88
89         HANDLE                                                          WorkQueue;
90 } VMBUS_CONNECTION;
91
92
93 typedef struct _VMBUS_MSGINFO {
94         // Bookkeeping stuff
95         LIST_ENTRY                      MsgListEntry;
96
97         // Synchronize the request/response if needed
98         HANDLE                          WaitEvent;
99
100         // The message itself
101         unsigned char           Msg[0];
102 } VMBUS_MSGINFO;
103
104
105 //
106 // Externs
107 //
108 extern VMBUS_CONNECTION gVmbusConnection;
109
110 //
111 // General vmbus interface
112 //
113 static DEVICE_OBJECT*
114 VmbusChildDeviceCreate(
115         GUID deviceType,
116         GUID deviceInstance,
117         void *context);
118
119 static int
120 VmbusChildDeviceAdd(
121         DEVICE_OBJECT* Device);
122
123 static void
124 VmbusChildDeviceRemove(
125    DEVICE_OBJECT* Device);
126
127 //static void
128 //VmbusChildDeviceDestroy(
129 //      DEVICE_OBJECT*);
130
131 static VMBUS_CHANNEL*
132 GetChannelFromRelId(
133         u32 relId
134         );
135
136 //
137 // Connection interface
138 //
139 static int
140 VmbusConnect(
141         void
142         );
143
144 static int
145 VmbusDisconnect(
146         void
147         );
148
149 static int
150 VmbusPostMessage(
151         void *                  buffer,
152         SIZE_T                  bufSize
153         );
154
155 static int
156 VmbusSetEvent(
157         u32 childRelId
158         );
159
160 static void
161 VmbusOnEvents(
162   void
163         );
164
165
166 #endif // _VMBUS_PRIVATE_H_