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/osd.h"
29 #include "include/List.h"
30 #include "RingBuffer.h"
32 #include "include/VmbusChannelInterface.h"
33 #include "include/ChannelMessages.h"
37 typedef void (*PFN_CHANNEL_CALLBACK)(void * context);
41 CHANNEL_OPENING_STATE,
43 } VMBUS_CHANNEL_STATE;
45 typedef struct _VMBUS_CHANNEL {
48 struct hv_device *DeviceObject;
50 struct osd_timer *PollTimer; /* SA-111 workaround */
52 VMBUS_CHANNEL_STATE State;
54 VMBUS_CHANNEL_OFFER_CHANNEL OfferMsg;
55 /* These are based on the OfferMsg.MonitorId. Save it here for easy access. */
59 u32 RingBufferGpadlHandle;
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 spinlock_t inbound_lock;
67 struct workqueue_struct *ControlWQ;
69 /* Channel callback are invoked in this workqueue context */
70 /* HANDLE dataWorkQueue; */
72 PFN_CHANNEL_CALLBACK OnChannelCallback;
73 void * ChannelCallbackContext;
78 typedef struct _VMBUS_CHANNEL_DEBUG_INFO {
80 VMBUS_CHANNEL_STATE State;
82 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;
93 } VMBUS_CHANNEL_DEBUG_INFO;
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;
106 * Represents each channel msg on the vmbus connection This is a
107 * variable-size data structure depending on the msg type itself
110 typedef struct _VMBUS_CHANNEL_MSGINFO {
111 /* Bookkeeping stuff */
112 LIST_ENTRY MsgListEntry;
114 /* So far, this is only used to handle gpadl body message */
115 LIST_ENTRY SubMsgList;
117 /* Synchronize the request/response if needed */
118 struct osd_waitevent *WaitEvent;
120 VMBUS_CHANNEL_MESSAGE_RESPONSE Response;
123 /* The channel message that goes out on the "wire". */
124 /* It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header */
125 unsigned char Msg[0];
126 } VMBUS_CHANNEL_MSGINFO;
131 static VMBUS_CHANNEL*
138 VMBUS_CHANNEL *Channel
142 VmbusOnChannelMessage(
147 VmbusChannelRequestOffers(
152 VmbusChannelReleaseUnattachedChannels(
156 #endif /* _CHANNEL_MGMT_H_ */