1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
/*
*
* Copyright (c) 2009, Microsoft Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Authors:
* Haiyang Zhang <haiyangz@microsoft.com>
* Hank Janssen <hjanssen@microsoft.com>
*
*/
#ifndef _VMBUS_PRIVATE_H_
#define _VMBUS_PRIVATE_H_
#include "Hv.h"
#include "include/VmbusApi.h"
#include "Channel.h"
#include "ChannelMgmt.h"
#include "ChannelInterface.h"
/* #include "ChannelMessages.h" */
#include "RingBuffer.h"
/* #include "Packet.h" */
#include "include/List.h"
/* Defines */
/*
* Maximum channels is determined by the size of the interrupt page
* which is PAGE_SIZE. 1/2 of PAGE_SIZE is for send endpoint interrupt
* and the other is receive endpoint interrupt
*/
#define MAX_NUM_CHANNELS (PAGE_SIZE >> 1) << 3 /* 16348 channels */
/* The value here must be in multiple of 32 */
/* TODO: Need to make this configurable */
#define MAX_NUM_CHANNELS_SUPPORTED 256
/* Data types */
enum VMBUS_CONNECT_STATE {
Disconnected,
Connecting,
Connected,
Disconnecting
};
#define MAX_SIZE_CHANNEL_MESSAGE HV_MESSAGE_PAYLOAD_BYTE_COUNT
typedef struct _VMBUS_CONNECTION {
enum VMBUS_CONNECT_STATE ConnectState;
u32 NextGpadlHandle;
/*
* Represents channel interrupts. Each bit position represents
* a channel. When a channel sends an interrupt via VMBUS, it
* finds its bit in the sendInterruptPage, set it and calls Hv
* to generate a port event. The other end receives the port
* event and parse the recvInterruptPage to see which bit is
* set
*/
void * InterruptPage;
void * SendInterruptPage;
void * RecvInterruptPage;
/*
* 2 pages - 1st page for parent->child notification and 2nd
* is child->parent notification
*/
void * MonitorPages;
LIST_ENTRY ChannelMsgList;
spinlock_t channelmsg_lock;
/* List of channels */
LIST_ENTRY ChannelList;
spinlock_t channel_lock;
HANDLE WorkQueue;
} VMBUS_CONNECTION;
typedef struct _VMBUS_MSGINFO {
/* Bookkeeping stuff */
LIST_ENTRY MsgListEntry;
/* Synchronize the request/response if needed */
HANDLE WaitEvent;
/* The message itself */
unsigned char Msg[0];
} VMBUS_MSGINFO;
/* Externs */
extern VMBUS_CONNECTION gVmbusConnection;
/* General vmbus interface */
static DEVICE_OBJECT*
VmbusChildDeviceCreate(
GUID deviceType,
GUID deviceInstance,
void *context);
static int
VmbusChildDeviceAdd(
DEVICE_OBJECT* Device);
static void
VmbusChildDeviceRemove(
DEVICE_OBJECT* Device);
/* static void */
/* VmbusChildDeviceDestroy( */
/* DEVICE_OBJECT*); */
static VMBUS_CHANNEL*
GetChannelFromRelId(
u32 relId
);
/* Connection interface */
static int
VmbusConnect(
void
);
static int
VmbusDisconnect(
void
);
static int
VmbusPostMessage(
void * buffer,
size_t bufSize
);
static int
VmbusSetEvent(
u32 childRelId
);
static void
VmbusOnEvents(
void
);
#endif /* _VMBUS_PRIVATE_H_ */
|