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 DEVICE_OBJECT* DeviceObject;
50 HANDLE 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 UINT32 RingBufferGpadlHandle;
61 // Allocated memory for ring buffer
62 void * RingBufferPages;
63 UINT32 RingBufferPageCount;
64 RING_BUFFER_INFO Outbound; // send to parent
65 RING_BUFFER_INFO Inbound; // receive from parent
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 UINT32 ServerMonitorPending;
85 UINT32 ServerMonitorLatency;
86 UINT32 ServerMonitorConnectionId;
87 UINT32 ClientMonitorPending;
88 UINT32 ClientMonitorLatency;
89 UINT32 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;
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 {
110 LIST_ENTRY MsgListEntry;
112 // So far, this is only used to handle gpadl body message
113 LIST_ENTRY SubMsgList;
115 // Synchronize the request/response if needed
118 VMBUS_CHANNEL_MESSAGE_RESPONSE Response;
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;
131 static VMBUS_CHANNEL*
138 VMBUS_CHANNEL *Channel
142 VmbusOnChannelMessage(
147 VmbusChannelRequestOffers(
152 VmbusChannelReleaseUnattachedChannels(
156 #endif //_CHANNEL_MGMT_H_