]> Pileus Git - ~andy/linux/blob - drivers/staging/hv/ChannelMgmt.h
Staging: hv: remove UINT32 and INT32 typedefs
[~andy/linux] / drivers / staging / hv / ChannelMgmt.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_MGMT_H_
26 #define _CHANNEL_MGMT_H_
27
28 #include "include/osd.h"
29 #include "include/List.h"
30 #include "RingBuffer.h"
31
32 #include "include/VmbusChannelInterface.h"
33 #include "include/ChannelMessages.h"
34
35
36
37 typedef void (*PFN_CHANNEL_CALLBACK)(void * context);
38
39 typedef enum {
40         CHANNEL_OFFER_STATE,
41         CHANNEL_OPENING_STATE,
42         CHANNEL_OPEN_STATE,
43 } VMBUS_CHANNEL_STATE;
44
45 typedef struct _VMBUS_CHANNEL {
46         LIST_ENTRY                                      ListEntry;
47
48         DEVICE_OBJECT*                          DeviceObject;
49
50         HANDLE                                          PollTimer; // SA-111 workaround
51
52         VMBUS_CHANNEL_STATE                     State;
53
54         VMBUS_CHANNEL_OFFER_CHANNEL OfferMsg;
55         // These are based on the OfferMsg.MonitorId. Save it here for easy access.
56         u8                                              MonitorGroup;
57         u8                                              MonitorBit;
58
59         u32                                             RingBufferGpadlHandle;
60
61         // Allocated memory for ring buffer
62         void *                                          RingBufferPages;
63         u32                                             RingBufferPageCount;
64         RING_BUFFER_INFO                        Outbound;       // send to parent
65         RING_BUFFER_INFO                        Inbound;        // receive from parent
66         HANDLE                                          InboundLock;
67         HANDLE                                          ControlWQ;
68
69         // Channel callback are invoked in this workqueue context
70         //HANDLE                                                dataWorkQueue;
71
72         PFN_CHANNEL_CALLBACK            OnChannelCallback;
73         void *                                          ChannelCallbackContext;
74
75 } VMBUS_CHANNEL;
76
77
78 typedef struct _VMBUS_CHANNEL_DEBUG_INFO {
79         u32                                             RelId;
80         VMBUS_CHANNEL_STATE                     State;
81         GUID                                            InterfaceType;
82     GUID                                                InterfaceInstance;
83         u32                                             MonitorId;
84         u32                                             ServerMonitorPending;
85         u32                                             ServerMonitorLatency;
86         u32                                             ServerMonitorConnectionId;
87         u32                                             ClientMonitorPending;
88         u32                                             ClientMonitorLatency;
89         u32                                             ClientMonitorConnectionId;
90
91         RING_BUFFER_DEBUG_INFO          Inbound;
92         RING_BUFFER_DEBUG_INFO          Outbound;
93 } VMBUS_CHANNEL_DEBUG_INFO;
94
95
96 typedef union {
97         VMBUS_CHANNEL_VERSION_SUPPORTED         VersionSupported;
98         VMBUS_CHANNEL_OPEN_RESULT                       OpenResult;
99         VMBUS_CHANNEL_GPADL_TORNDOWN            GpadlTorndown;
100         VMBUS_CHANNEL_GPADL_CREATED                     GpadlCreated;
101         VMBUS_CHANNEL_VERSION_RESPONSE          VersionResponse;
102 } VMBUS_CHANNEL_MESSAGE_RESPONSE;
103
104
105 // Represents each channel msg on the vmbus connection
106 // This is a variable-size data structure depending on
107 // the msg type itself
108 typedef struct _VMBUS_CHANNEL_MSGINFO {
109         // Bookkeeping stuff
110         LIST_ENTRY              MsgListEntry;
111
112         // So far, this is only used to handle gpadl body message
113         LIST_ENTRY              SubMsgList;
114
115         // Synchronize the request/response if needed
116         HANDLE                  WaitEvent;
117
118         VMBUS_CHANNEL_MESSAGE_RESPONSE Response;
119
120         u32                     MessageSize;
121         // The channel message that goes out on the "wire".
122         // It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header
123         unsigned char   Msg[0];
124 } VMBUS_CHANNEL_MSGINFO;
125
126
127 //
128 // Routines
129 //
130
131 static VMBUS_CHANNEL*
132 AllocVmbusChannel(
133         void
134         );
135
136 static void
137 FreeVmbusChannel(
138         VMBUS_CHANNEL *Channel
139         );
140
141 static void
142 VmbusOnChannelMessage(
143         void *Context
144         );
145
146 static int
147 VmbusChannelRequestOffers(
148         void
149         );
150
151 static void
152 VmbusChannelReleaseUnattachedChannels(
153         void
154         );
155
156 #endif //_CHANNEL_MGMT_H_