]> Pileus Git - ~andy/linux/blob - drivers/staging/hv/ChannelMgmt.h
Staging: hv: remove include/HvHalApi.h
[~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/List.h"
29 #include "RingBuffer.h"
30
31 #include "include/VmbusChannelInterface.h"
32 #include "include/ChannelMessages.h"
33
34
35
36 typedef void (*PFN_CHANNEL_CALLBACK)(void *context);
37
38 enum vmbus_channel_state {
39         CHANNEL_OFFER_STATE,
40         CHANNEL_OPENING_STATE,
41         CHANNEL_OPEN_STATE,
42 };
43
44 struct vmbus_channel {
45         LIST_ENTRY ListEntry;
46
47         struct hv_device *DeviceObject;
48
49         struct timer_list poll_timer; /* SA-111 workaround */
50
51         enum vmbus_channel_state State;
52
53         VMBUS_CHANNEL_OFFER_CHANNEL OfferMsg;
54         /*
55          * These are based on the OfferMsg.MonitorId.
56          * Save it here for easy access.
57          */
58         u8 MonitorGroup;
59         u8 MonitorBit;
60
61         u32 RingBufferGpadlHandle;
62
63         /* Allocated memory for ring buffer */
64         void *RingBufferPages;
65         u32 RingBufferPageCount;
66         RING_BUFFER_INFO Outbound;      /* send to parent */
67         RING_BUFFER_INFO Inbound;       /* receive from parent */
68         spinlock_t inbound_lock;
69         struct workqueue_struct *ControlWQ;
70
71         /* Channel callback are invoked in this workqueue context */
72         /* HANDLE dataWorkQueue; */
73
74         PFN_CHANNEL_CALLBACK OnChannelCallback;
75         void *ChannelCallbackContext;
76 };
77
78 struct vmbus_channel_debug_info {
79         u32 RelId;
80         enum vmbus_channel_state State;
81         struct hv_guid InterfaceType;
82         struct hv_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 };
94
95 /*
96  * Represents each channel msg on the vmbus connection This is a
97  * variable-size data structure depending on the msg type itself
98  */
99 struct vmbus_channel_msginfo {
100         /* Bookkeeping stuff */
101         LIST_ENTRY MsgListEntry;
102
103         /* So far, this is only used to handle gpadl body message */
104         LIST_ENTRY SubMsgList;
105
106         /* Synchronize the request/response if needed */
107         struct osd_waitevent *WaitEvent;
108
109         union {
110                 VMBUS_CHANNEL_VERSION_SUPPORTED VersionSupported;
111                 VMBUS_CHANNEL_OPEN_RESULT OpenResult;
112                 VMBUS_CHANNEL_GPADL_TORNDOWN GpadlTorndown;
113                 VMBUS_CHANNEL_GPADL_CREATED GpadlCreated;
114                 VMBUS_CHANNEL_VERSION_RESPONSE VersionResponse;
115         } Response;
116
117         u32 MessageSize;
118         /*
119          * The channel message that goes out on the "wire".
120          * It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header
121          */
122         unsigned char Msg[0];
123 };
124
125
126 struct vmbus_channel *AllocVmbusChannel(void);
127
128 void FreeVmbusChannel(struct vmbus_channel *Channel);
129
130 void VmbusOnChannelMessage(void *Context);
131
132 int VmbusChannelRequestOffers(void);
133
134 void VmbusChannelReleaseUnattachedChannels(void);
135
136 #endif /* _CHANNEL_MGMT_H_ */