]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/staging/hv/include/VmbusPacketFormat.h
Staging: hv: Remove C99 comments
[mirror_ubuntu-artful-kernel.git] / drivers / staging / hv / include / VmbusPacketFormat.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 #pragma once
26
27 /* #ifndef PAGE_SIZE */
28 /* #if defined(_IA64_) */
29 /* #error This does not work for IA64 */
30 /* #else */
31 /* #define PAGE_SIZE 0x1000 */
32 /* #endif */
33 /* #endif */
34
35 /* allow nameless unions */
36 /* #pragma warning(disable : 4201) */
37
38 typedef struct
39 {
40 union
41 {
42 struct
43 {
44 volatile u32 In; /* Offset in bytes from the ring base */
45 volatile u32 Out; /* Offset in bytes from the ring base */
46 };
47 volatile long long InOut;
48 };
49
50
51 /* If the receiving endpoint sets this to some non-zero value, the sending */
52 /* endpoint should not send any interrupts. */
53
54
55 volatile u32 InterruptMask;
56
57 } VMRCB, *PVMRCB;
58
59 typedef struct
60 {
61 union
62 {
63 struct
64 {
65 VMRCB Control;
66 };
67
68 u8 Reserved[PAGE_SIZE];
69 };
70
71
72 /* Beginning of the ring data. Note: It must be guaranteed that */
73 /* this data does not share a page with the control structure. */
74
75 u8 Data[1];
76 } VMRING, *PVMRING;
77
78 #pragma pack(push, 1)
79
80 typedef struct
81 {
82 u16 Type;
83 u16 DataOffset8;
84 u16 Length8;
85 u16 Flags;
86 u64 TransactionId;
87 } VMPACKET_DESCRIPTOR, *PVMPACKET_DESCRIPTOR;
88
89 typedef u32 PREVIOUS_PACKET_OFFSET, *PPREVIOUS_PACKET_OFFSET;
90
91 typedef struct
92 {
93 PREVIOUS_PACKET_OFFSET PreviousPacketStartOffset;
94 VMPACKET_DESCRIPTOR Descriptor;
95 } VMPACKET_HEADER, *PVMPACKET_HEADER;
96
97 typedef struct
98 {
99 u32 ByteCount;
100 u32 ByteOffset;
101 } VMTRANSFER_PAGE_RANGE, *PVMTRANSFER_PAGE_RANGE;
102
103 #ifdef __cplusplus
104
105 typedef struct _VMTRANSFER_PAGE_PACKET_HEADER : VMPACKET_DESCRIPTOR {
106
107 #else
108
109 typedef struct VMTRANSFER_PAGE_PACKET_HEADER {
110
111 VMPACKET_DESCRIPTOR d;
112
113 #endif
114
115 u16 TransferPageSetId;
116 bool SenderOwnsSet;
117 u8 Reserved;
118 u32 RangeCount;
119 VMTRANSFER_PAGE_RANGE Ranges[1];
120
121 } VMTRANSFER_PAGE_PACKET_HEADER, *PVMTRANSFER_PAGE_PACKET_HEADER;
122
123
124 #ifdef __cplusplus
125
126 typedef struct _VMGPADL_PACKET_HEADER : VMPACKET_DESCRIPTOR {
127
128 #else
129
130 typedef struct _VMGPADL_PACKET_HEADER {
131
132 VMPACKET_DESCRIPTOR d;
133
134 #endif
135
136
137 u32 Gpadl;
138 u32 Reserved;
139
140 } VMGPADL_PACKET_HEADER, *PVMGPADL_PACKET_HEADER;
141
142 #ifdef __cplusplus
143
144 typedef struct _VMADD_REMOVE_TRANSFER_PAGE_SET : VMPACKET_DESCRIPTOR {
145
146 #else
147
148 typedef struct _VMADD_REMOVE_TRANSFER_PAGE_SET {
149
150 VMPACKET_DESCRIPTOR d;
151
152 #endif
153
154 u32 Gpadl;
155 u16 TransferPageSetId;
156 u16 Reserved;
157
158 } VMADD_REMOVE_TRANSFER_PAGE_SET, *PVMADD_REMOVE_TRANSFER_PAGE_SET;
159
160 #pragma pack(pop)
161
162
163 /* This structure defines a range in guest physical space that can be made */
164 /* to look virtually contiguous. */
165
166
167 typedef struct _GPA_RANGE {
168
169 u32 ByteCount;
170 u32 ByteOffset;
171 u64 PfnArray[0];
172
173 } GPA_RANGE, *PGPA_RANGE;
174
175
176
177 #pragma pack(push, 1)
178
179
180 /* This is the format for an Establish Gpadl packet, which contains a handle */
181 /* by which this GPADL will be known and a set of GPA ranges associated with */
182 /* it. This can be converted to a MDL by the guest OS. If there are multiple */
183 /* GPA ranges, then the resulting MDL will be "chained," representing multiple */
184 /* VA ranges. */
185
186
187 #ifdef __cplusplus
188
189 typedef struct _VMESTABLISH_GPADL : VMPACKET_DESCRIPTOR {
190
191 #else
192
193 typedef struct _VMESTABLISH_GPADL {
194
195 VMPACKET_DESCRIPTOR d;
196
197 #endif
198
199 u32 Gpadl;
200 u32 RangeCount;
201 GPA_RANGE Range[1];
202
203 } VMESTABLISH_GPADL, *PVMESTABLISH_GPADL;
204
205
206
207 /* This is the format for a Teardown Gpadl packet, which indicates that the */
208 /* GPADL handle in the Establish Gpadl packet will never be referenced again. */
209
210
211 #ifdef __cplusplus
212
213 typedef struct _VMTEARDOWN_GPADL : VMPACKET_DESCRIPTOR {
214
215 #else
216
217 typedef struct _VMTEARDOWN_GPADL {
218
219 VMPACKET_DESCRIPTOR d;
220
221 #endif
222
223 u32 Gpadl;
224 u32 Reserved; /* for alignment to a 8-byte boundary */
225 } VMTEARDOWN_GPADL, *PVMTEARDOWN_GPADL;
226
227
228
229 /* This is the format for a GPA-Direct packet, which contains a set of GPA */
230 /* ranges, in addition to commands and/or data. */
231
232
233 #ifdef __cplusplus
234
235 typedef struct _VMDATA_GPA_DIRECT : VMPACKET_DESCRIPTOR {
236
237 #else
238
239 typedef struct _VMDATA_GPA_DIRECT {
240
241 VMPACKET_DESCRIPTOR d;
242
243 #endif
244
245 u32 Reserved;
246 u32 RangeCount;
247 GPA_RANGE Range[1];
248
249 } VMDATA_GPA_DIRECT, *PVMDATA_GPA_DIRECT;
250
251
252
253
254 /* This is the format for a Additional Data Packet. */
255
256
257 #ifdef __cplusplus
258
259 typedef struct _VMADDITIONAL_DATA : VMPACKET_DESCRIPTOR {
260
261 #else
262
263 typedef struct _VMADDITIONAL_DATA {
264
265 VMPACKET_DESCRIPTOR d;
266
267 #endif
268
269 u64 TotalBytes;
270 u32 ByteOffset;
271 u32 ByteCount;
272 unsigned char Data[1];
273
274 } VMADDITIONAL_DATA, *PVMADDITIONAL_DATA;
275
276
277 #pragma pack(pop)
278
279 typedef union {
280 VMPACKET_DESCRIPTOR SimpleHeader;
281 VMTRANSFER_PAGE_PACKET_HEADER TransferPageHeader;
282 VMGPADL_PACKET_HEADER GpadlHeader;
283 VMADD_REMOVE_TRANSFER_PAGE_SET AddRemoveTransferPageHeader;
284 VMESTABLISH_GPADL EstablishGpadlHeader;
285 VMTEARDOWN_GPADL TeardownGpadlHeader;
286 VMDATA_GPA_DIRECT DataGpaDirectHeader;
287 } VMPACKET_LARGEST_POSSIBLE_HEADER, *PVMPACKET_LARGEST_POSSIBLE_HEADER;
288
289 #define VMPACKET_DATA_START_ADDRESS(__packet) \
290 (void *)(((unsigned char *)__packet) + ((PVMPACKET_DESCRIPTOR)__packet)->DataOffset8 * 8)
291
292 #define VMPACKET_DATA_LENGTH(__packet) \
293 ((((PVMPACKET_DESCRIPTOR)__packet)->Length8 - ((PVMPACKET_DESCRIPTOR)__packet)->DataOffset8) * 8)
294
295 #define VMPACKET_TRANSFER_MODE(__packet) ((PVMPACKET_DESCRIPTOR)__packet)->Type
296
297 typedef enum {
298 VmbusServerEndpoint = 0,
299 VmbusClientEndpoint,
300 VmbusEndpointMaximum
301 } ENDPOINT_TYPE, *PENDPOINT_TYPE;
302
303 typedef enum {
304 VmbusPacketTypeInvalid = 0x0,
305 VmbusPacketTypeSynch = 0x1,
306 VmbusPacketTypeAddTransferPageSet = 0x2,
307 VmbusPacketTypeRemoveTransferPageSet = 0x3,
308 VmbusPacketTypeEstablishGpadl = 0x4,
309 VmbusPacketTypeTearDownGpadl = 0x5,
310 VmbusPacketTypeDataInBand = 0x6,
311 VmbusPacketTypeDataUsingTransferPages = 0x7,
312 VmbusPacketTypeDataUsingGpadl = 0x8,
313 VmbusPacketTypeDataUsingGpaDirect = 0x9,
314 VmbusPacketTypeCancelRequest = 0xa,
315 VmbusPacketTypeCompletion = 0xb,
316 VmbusPacketTypeDataUsingAdditionalPackets = 0xc,
317 VmbusPacketTypeAdditionalData = 0xd
318 } VMBUS_PACKET_TYPE, *PVMBUS_PACKET_TYPE;
319
320 #define VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED 1