]>
Commit | Line | Data |
---|---|---|
5c473400 S |
1 | /* |
2 | * | |
3 | * Copyright (c) 2011, 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 | * K. Y. Srinivasan <kys@microsoft.com> | |
22 | * | |
23 | */ | |
3f335ea2 S |
24 | |
25 | #ifndef _HYPERV_H | |
26 | #define _HYPERV_H | |
27 | ||
28 | struct hv_guid { | |
29 | unsigned char data[16]; | |
30 | }; | |
31 | ||
a363bf7b S |
32 | #define MAX_PAGE_BUFFER_COUNT 16 |
33 | #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */ | |
34 | ||
35 | #pragma pack(push, 1) | |
36 | ||
37 | /* Single-page buffer */ | |
38 | struct hv_page_buffer { | |
39 | u32 len; | |
40 | u32 offset; | |
41 | u64 pfn; | |
42 | }; | |
43 | ||
44 | /* Multiple-page buffer */ | |
45 | struct hv_multipage_buffer { | |
46 | /* Length and Offset determines the # of pfns in the array */ | |
47 | u32 len; | |
48 | u32 offset; | |
49 | u64 pfn_array[MAX_MULTIPAGE_BUFFER_COUNT]; | |
50 | }; | |
51 | ||
52 | /* 0x18 includes the proprietary packet header */ | |
53 | #define MAX_PAGE_BUFFER_PACKET (0x18 + \ | |
54 | (sizeof(struct hv_page_buffer) * \ | |
55 | MAX_PAGE_BUFFER_COUNT)) | |
56 | #define MAX_MULTIPAGE_BUFFER_PACKET (0x18 + \ | |
57 | sizeof(struct hv_multipage_buffer)) | |
58 | ||
59 | ||
60 | #pragma pack(pop) | |
61 | ||
7effffb7 S |
62 | struct hv_ring_buffer { |
63 | /* Offset in bytes from the start of ring data below */ | |
64 | u32 write_index; | |
65 | ||
66 | /* Offset in bytes from the start of ring data below */ | |
67 | u32 read_index; | |
68 | ||
69 | u32 interrupt_mask; | |
70 | ||
71 | /* Pad it to PAGE_SIZE so that data starts on page boundary */ | |
72 | u8 reserved[4084]; | |
73 | ||
74 | /* NOTE: | |
75 | * The interrupt_mask field is used only for channels but since our | |
76 | * vmbus connection also uses this data structure and its data starts | |
77 | * here, we commented out this field. | |
78 | */ | |
79 | ||
80 | /* | |
81 | * Ring data starts here + RingDataStartOffset | |
82 | * !!! DO NOT place any fields below this !!! | |
83 | */ | |
84 | u8 buffer[0]; | |
85 | } __packed; | |
86 | ||
87 | struct hv_ring_buffer_info { | |
88 | struct hv_ring_buffer *ring_buffer; | |
89 | u32 ring_size; /* Include the shared header */ | |
90 | spinlock_t ring_lock; | |
91 | ||
92 | u32 ring_datasize; /* < ring_size */ | |
93 | u32 ring_data_startoffset; | |
94 | }; | |
95 | ||
96 | struct hv_ring_buffer_debug_info { | |
97 | u32 current_interrupt_mask; | |
98 | u32 current_read_index; | |
99 | u32 current_write_index; | |
100 | u32 bytes_avail_toread; | |
101 | u32 bytes_avail_towrite; | |
102 | }; | |
3f335ea2 | 103 | |
f7c6dfda S |
104 | /* |
105 | * We use the same version numbering for all Hyper-V modules. | |
106 | * | |
107 | * Definition of versioning is as follows; | |
108 | * | |
109 | * Major Number Changes for these scenarios; | |
110 | * 1. When a new version of Windows Hyper-V | |
111 | * is released. | |
112 | * 2. A Major change has occurred in the | |
113 | * Linux IC's. | |
114 | * (For example the merge for the first time | |
115 | * into the kernel) Every time the Major Number | |
116 | * changes, the Revision number is reset to 0. | |
117 | * Minor Number Changes when new functionality is added | |
118 | * to the Linux IC's that is not a bug fix. | |
119 | * | |
120 | * 3.1 - Added completed hv_utils driver. Shutdown/Heartbeat/Timesync | |
121 | */ | |
122 | #define HV_DRV_VERSION "3.1" | |
123 | ||
124 | ||
517d8dc6 S |
125 | /* |
126 | * A revision number of vmbus that is used for ensuring both ends on a | |
127 | * partition are using compatible versions. | |
128 | */ | |
129 | #define VMBUS_REVISION_NUMBER 13 | |
130 | ||
131 | /* Make maximum size of pipe payload of 16K */ | |
132 | #define MAX_PIPE_DATA_PAYLOAD (sizeof(u8) * 16384) | |
133 | ||
134 | /* Define PipeMode values. */ | |
135 | #define VMBUS_PIPE_TYPE_BYTE 0x00000000 | |
136 | #define VMBUS_PIPE_TYPE_MESSAGE 0x00000004 | |
137 | ||
138 | /* The size of the user defined data buffer for non-pipe offers. */ | |
139 | #define MAX_USER_DEFINED_BYTES 120 | |
140 | ||
141 | /* The size of the user defined data buffer for pipe offers. */ | |
142 | #define MAX_PIPE_USER_DEFINED_BYTES 116 | |
143 | ||
144 | /* | |
145 | * At the center of the Channel Management library is the Channel Offer. This | |
146 | * struct contains the fundamental information about an offer. | |
147 | */ | |
148 | struct vmbus_channel_offer { | |
149 | struct hv_guid if_type; | |
150 | struct hv_guid if_instance; | |
151 | u64 int_latency; /* in 100ns units */ | |
152 | u32 if_revision; | |
153 | u32 server_ctx_size; /* in bytes */ | |
154 | u16 chn_flags; | |
155 | u16 mmio_megabytes; /* in bytes * 1024 * 1024 */ | |
156 | ||
157 | union { | |
158 | /* Non-pipes: The user has MAX_USER_DEFINED_BYTES bytes. */ | |
159 | struct { | |
160 | unsigned char user_def[MAX_USER_DEFINED_BYTES]; | |
161 | } std; | |
162 | ||
163 | /* | |
164 | * Pipes: | |
165 | * The following sructure is an integrated pipe protocol, which | |
166 | * is implemented on top of standard user-defined data. Pipe | |
167 | * clients have MAX_PIPE_USER_DEFINED_BYTES left for their own | |
168 | * use. | |
169 | */ | |
170 | struct { | |
171 | u32 pipe_mode; | |
172 | unsigned char user_def[MAX_PIPE_USER_DEFINED_BYTES]; | |
173 | } pipe; | |
174 | } u; | |
175 | u32 padding; | |
176 | } __packed; | |
177 | ||
178 | /* Server Flags */ | |
179 | #define VMBUS_CHANNEL_ENUMERATE_DEVICE_INTERFACE 1 | |
180 | #define VMBUS_CHANNEL_SERVER_SUPPORTS_TRANSFER_PAGES 2 | |
181 | #define VMBUS_CHANNEL_SERVER_SUPPORTS_GPADLS 4 | |
182 | #define VMBUS_CHANNEL_NAMED_PIPE_MODE 0x10 | |
183 | #define VMBUS_CHANNEL_LOOPBACK_OFFER 0x100 | |
184 | #define VMBUS_CHANNEL_PARENT_OFFER 0x200 | |
185 | #define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION 0x400 | |
186 | ||
50ed40e0 S |
187 | struct vmpacket_descriptor { |
188 | u16 type; | |
189 | u16 offset8; | |
190 | u16 len8; | |
191 | u16 flags; | |
192 | u64 trans_id; | |
193 | } __packed; | |
194 | ||
195 | struct vmpacket_header { | |
196 | u32 prev_pkt_start_offset; | |
197 | struct vmpacket_descriptor descriptor; | |
198 | } __packed; | |
199 | ||
200 | struct vmtransfer_page_range { | |
201 | u32 byte_count; | |
202 | u32 byte_offset; | |
203 | } __packed; | |
204 | ||
205 | struct vmtransfer_page_packet_header { | |
206 | struct vmpacket_descriptor d; | |
207 | u16 xfer_pageset_id; | |
208 | bool sender_owns_set; | |
209 | u8 reserved; | |
210 | u32 range_cnt; | |
211 | struct vmtransfer_page_range ranges[1]; | |
212 | } __packed; | |
213 | ||
214 | struct vmgpadl_packet_header { | |
215 | struct vmpacket_descriptor d; | |
216 | u32 gpadl; | |
217 | u32 reserved; | |
218 | } __packed; | |
219 | ||
220 | struct vmadd_remove_transfer_page_set { | |
221 | struct vmpacket_descriptor d; | |
222 | u32 gpadl; | |
223 | u16 xfer_pageset_id; | |
224 | u16 reserved; | |
225 | } __packed; | |
226 | ||
227 | /* | |
228 | * This structure defines a range in guest physical space that can be made to | |
229 | * look virtually contiguous. | |
230 | */ | |
231 | struct gpa_range { | |
232 | u32 byte_count; | |
233 | u32 byte_offset; | |
234 | u64 pfn_array[0]; | |
235 | }; | |
236 | ||
237 | /* | |
238 | * This is the format for an Establish Gpadl packet, which contains a handle by | |
239 | * which this GPADL will be known and a set of GPA ranges associated with it. | |
240 | * This can be converted to a MDL by the guest OS. If there are multiple GPA | |
241 | * ranges, then the resulting MDL will be "chained," representing multiple VA | |
242 | * ranges. | |
243 | */ | |
244 | struct vmestablish_gpadl { | |
245 | struct vmpacket_descriptor d; | |
246 | u32 gpadl; | |
247 | u32 range_cnt; | |
248 | struct gpa_range range[1]; | |
249 | } __packed; | |
250 | ||
251 | /* | |
252 | * This is the format for a Teardown Gpadl packet, which indicates that the | |
253 | * GPADL handle in the Establish Gpadl packet will never be referenced again. | |
254 | */ | |
255 | struct vmteardown_gpadl { | |
256 | struct vmpacket_descriptor d; | |
257 | u32 gpadl; | |
258 | u32 reserved; /* for alignment to a 8-byte boundary */ | |
259 | } __packed; | |
260 | ||
261 | /* | |
262 | * This is the format for a GPA-Direct packet, which contains a set of GPA | |
263 | * ranges, in addition to commands and/or data. | |
264 | */ | |
265 | struct vmdata_gpa_direct { | |
266 | struct vmpacket_descriptor d; | |
267 | u32 reserved; | |
268 | u32 range_cnt; | |
269 | struct gpa_range range[1]; | |
270 | } __packed; | |
271 | ||
272 | /* This is the format for a Additional Data Packet. */ | |
273 | struct vmadditional_data { | |
274 | struct vmpacket_descriptor d; | |
275 | u64 total_bytes; | |
276 | u32 offset; | |
277 | u32 byte_cnt; | |
278 | unsigned char data[1]; | |
279 | } __packed; | |
280 | ||
281 | union vmpacket_largest_possible_header { | |
282 | struct vmpacket_descriptor simple_hdr; | |
283 | struct vmtransfer_page_packet_header xfer_page_hdr; | |
284 | struct vmgpadl_packet_header gpadl_hdr; | |
285 | struct vmadd_remove_transfer_page_set add_rm_xfer_page_hdr; | |
286 | struct vmestablish_gpadl establish_gpadl_hdr; | |
287 | struct vmteardown_gpadl teardown_gpadl_hdr; | |
288 | struct vmdata_gpa_direct data_gpa_direct_hdr; | |
289 | }; | |
290 | ||
291 | #define VMPACKET_DATA_START_ADDRESS(__packet) \ | |
292 | (void *)(((unsigned char *)__packet) + \ | |
293 | ((struct vmpacket_descriptor)__packet)->offset8 * 8) | |
294 | ||
295 | #define VMPACKET_DATA_LENGTH(__packet) \ | |
296 | ((((struct vmpacket_descriptor)__packet)->len8 - \ | |
297 | ((struct vmpacket_descriptor)__packet)->offset8) * 8) | |
298 | ||
299 | #define VMPACKET_TRANSFER_MODE(__packet) \ | |
300 | (((struct IMPACT)__packet)->type) | |
301 | ||
302 | enum vmbus_packet_type { | |
303 | VM_PKT_INVALID = 0x0, | |
304 | VM_PKT_SYNCH = 0x1, | |
305 | VM_PKT_ADD_XFER_PAGESET = 0x2, | |
306 | VM_PKT_RM_XFER_PAGESET = 0x3, | |
307 | VM_PKT_ESTABLISH_GPADL = 0x4, | |
308 | VM_PKT_TEARDOWN_GPADL = 0x5, | |
309 | VM_PKT_DATA_INBAND = 0x6, | |
310 | VM_PKT_DATA_USING_XFER_PAGES = 0x7, | |
311 | VM_PKT_DATA_USING_GPADL = 0x8, | |
312 | VM_PKT_DATA_USING_GPA_DIRECT = 0x9, | |
313 | VM_PKT_CANCEL_REQUEST = 0xa, | |
314 | VM_PKT_COMP = 0xb, | |
315 | VM_PKT_DATA_USING_ADDITIONAL_PKT = 0xc, | |
316 | VM_PKT_ADDITIONAL_DATA = 0xd | |
317 | }; | |
318 | ||
319 | #define VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED 1 | |
517d8dc6 | 320 | |
3f335ea2 | 321 | #endif /* _HYPERV_H */ |