3 * Copyright (c) 2009, Microsoft Corporation.
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.
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
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.
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
25 #ifndef _CHANNEL_MGMT_H_
26 #define _CHANNEL_MGMT_H_
28 #include "include/List.h"
29 #include "RingBuffer.h"
31 #include "include/VmbusChannelInterface.h"
32 #include "include/ChannelMessages.h"
36 typedef void (*PFN_CHANNEL_CALLBACK)(void *context);
38 enum vmbus_channel_state {
40 CHANNEL_OPENING_STATE,
44 struct vmbus_channel {
47 struct hv_device *DeviceObject;
49 struct timer_list poll_timer; /* SA-111 workaround */
51 enum vmbus_channel_state State;
53 VMBUS_CHANNEL_OFFER_CHANNEL OfferMsg;
55 * These are based on the OfferMsg.MonitorId.
56 * Save it here for easy access.
61 u32 RingBufferGpadlHandle;
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;
71 /* Channel callback are invoked in this workqueue context */
72 /* HANDLE dataWorkQueue; */
74 PFN_CHANNEL_CALLBACK OnChannelCallback;
75 void *ChannelCallbackContext;
78 struct vmbus_channel_debug_info {
80 enum vmbus_channel_state State;
81 struct hv_guid InterfaceType;
82 struct hv_guid InterfaceInstance;
84 u32 ServerMonitorPending;
85 u32 ServerMonitorLatency;
86 u32 ServerMonitorConnectionId;
87 u32 ClientMonitorPending;
88 u32 ClientMonitorLatency;
89 u32 ClientMonitorConnectionId;
91 RING_BUFFER_DEBUG_INFO Inbound;
92 RING_BUFFER_DEBUG_INFO Outbound;
96 * Represents each channel msg on the vmbus connection This is a
97 * variable-size data structure depending on the msg type itself
99 struct vmbus_channel_msginfo {
100 /* Bookkeeping stuff */
101 LIST_ENTRY MsgListEntry;
103 /* So far, this is only used to handle gpadl body message */
104 LIST_ENTRY SubMsgList;
106 /* Synchronize the request/response if needed */
107 struct osd_waitevent *WaitEvent;
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;
119 * The channel message that goes out on the "wire".
120 * It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header
122 unsigned char Msg[0];
126 struct vmbus_channel *AllocVmbusChannel(void);
128 void FreeVmbusChannel(struct vmbus_channel *Channel);
130 void VmbusOnChannelMessage(void *Context);
132 int VmbusChannelRequestOffers(void);
134 void VmbusChannelReleaseUnattachedChannels(void);
136 #endif /* _CHANNEL_MGMT_H_ */