diff options
author | Bjarke Istrup Pedersen <gurligebis@gentoo.org> | 2014-01-22 04:16:58 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-07 18:18:31 -0500 |
commit | 5267cf02c7794953d89e9593a0d497bf43e3790d (patch) | |
tree | 177bb2d6533bee863515171fde18e437bb0a13d1 /include | |
parent | e2527ec3690bc820e5b4288577f79945f4a22d77 (diff) |
hv: Add hyperv.h to uapi headers
This patch adds the hyperv.h header to the uapi folder, and adds it to the Kbuild file.
Doing this enables compiling userspace Hyper-V tools using the installed headers.
Version 2: Split UAPI parts into new header, instead of duplicating.
Signed-off-by: Bjarke Istrup Pedersen <gurligebis@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/hyperv.h | 321 | ||||
-rw-r--r-- | include/uapi/linux/Kbuild | 1 | ||||
-rw-r--r-- | include/uapi/linux/hyperv.h | 344 |
3 files changed, 347 insertions, 319 deletions
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 15da677478dd..167ef47e3d6e 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h | |||
@@ -25,325 +25,9 @@ | |||
25 | #ifndef _HYPERV_H | 25 | #ifndef _HYPERV_H |
26 | #define _HYPERV_H | 26 | #define _HYPERV_H |
27 | 27 | ||
28 | #include <linux/types.h> | 28 | #include <uapi/linux/hyperv.h> |
29 | |||
30 | /* | ||
31 | * Framework version for util services. | ||
32 | */ | ||
33 | #define UTIL_FW_MINOR 0 | ||
34 | |||
35 | #define UTIL_WS2K8_FW_MAJOR 1 | ||
36 | #define UTIL_WS2K8_FW_VERSION (UTIL_WS2K8_FW_MAJOR << 16 | UTIL_FW_MINOR) | ||
37 | |||
38 | #define UTIL_FW_MAJOR 3 | ||
39 | #define UTIL_FW_VERSION (UTIL_FW_MAJOR << 16 | UTIL_FW_MINOR) | ||
40 | |||
41 | |||
42 | /* | ||
43 | * Implementation of host controlled snapshot of the guest. | ||
44 | */ | ||
45 | |||
46 | #define VSS_OP_REGISTER 128 | ||
47 | |||
48 | enum hv_vss_op { | ||
49 | VSS_OP_CREATE = 0, | ||
50 | VSS_OP_DELETE, | ||
51 | VSS_OP_HOT_BACKUP, | ||
52 | VSS_OP_GET_DM_INFO, | ||
53 | VSS_OP_BU_COMPLETE, | ||
54 | /* | ||
55 | * Following operations are only supported with IC version >= 5.0 | ||
56 | */ | ||
57 | VSS_OP_FREEZE, /* Freeze the file systems in the VM */ | ||
58 | VSS_OP_THAW, /* Unfreeze the file systems */ | ||
59 | VSS_OP_AUTO_RECOVER, | ||
60 | VSS_OP_COUNT /* Number of operations, must be last */ | ||
61 | }; | ||
62 | |||
63 | |||
64 | /* | ||
65 | * Header for all VSS messages. | ||
66 | */ | ||
67 | struct hv_vss_hdr { | ||
68 | __u8 operation; | ||
69 | __u8 reserved[7]; | ||
70 | } __attribute__((packed)); | ||
71 | |||
72 | |||
73 | /* | ||
74 | * Flag values for the hv_vss_check_feature. Linux supports only | ||
75 | * one value. | ||
76 | */ | ||
77 | #define VSS_HBU_NO_AUTO_RECOVERY 0x00000005 | ||
78 | |||
79 | struct hv_vss_check_feature { | ||
80 | __u32 flags; | ||
81 | } __attribute__((packed)); | ||
82 | |||
83 | struct hv_vss_check_dm_info { | ||
84 | __u32 flags; | ||
85 | } __attribute__((packed)); | ||
86 | |||
87 | struct hv_vss_msg { | ||
88 | union { | ||
89 | struct hv_vss_hdr vss_hdr; | ||
90 | int error; | ||
91 | }; | ||
92 | union { | ||
93 | struct hv_vss_check_feature vss_cf; | ||
94 | struct hv_vss_check_dm_info dm_info; | ||
95 | }; | ||
96 | } __attribute__((packed)); | ||
97 | |||
98 | /* | ||
99 | * An implementation of HyperV key value pair (KVP) functionality for Linux. | ||
100 | * | ||
101 | * | ||
102 | * Copyright (C) 2010, Novell, Inc. | ||
103 | * Author : K. Y. Srinivasan <ksrinivasan@novell.com> | ||
104 | * | ||
105 | */ | ||
106 | |||
107 | /* | ||
108 | * Maximum value size - used for both key names and value data, and includes | ||
109 | * any applicable NULL terminators. | ||
110 | * | ||
111 | * Note: This limit is somewhat arbitrary, but falls easily within what is | ||
112 | * supported for all native guests (back to Win 2000) and what is reasonable | ||
113 | * for the IC KVP exchange functionality. Note that Windows Me/98/95 are | ||
114 | * limited to 255 character key names. | ||
115 | * | ||
116 | * MSDN recommends not storing data values larger than 2048 bytes in the | ||
117 | * registry. | ||
118 | * | ||
119 | * Note: This value is used in defining the KVP exchange message - this value | ||
120 | * cannot be modified without affecting the message size and compatibility. | ||
121 | */ | ||
122 | |||
123 | /* | ||
124 | * bytes, including any null terminators | ||
125 | */ | ||
126 | #define HV_KVP_EXCHANGE_MAX_VALUE_SIZE (2048) | ||
127 | |||
128 | |||
129 | /* | ||
130 | * Maximum key size - the registry limit for the length of an entry name | ||
131 | * is 256 characters, including the null terminator | ||
132 | */ | ||
133 | |||
134 | #define HV_KVP_EXCHANGE_MAX_KEY_SIZE (512) | ||
135 | 29 | ||
136 | /* | 30 | #include <linux/types.h> |
137 | * In Linux, we implement the KVP functionality in two components: | ||
138 | * 1) The kernel component which is packaged as part of the hv_utils driver | ||
139 | * is responsible for communicating with the host and responsible for | ||
140 | * implementing the host/guest protocol. 2) A user level daemon that is | ||
141 | * responsible for data gathering. | ||
142 | * | ||
143 | * Host/Guest Protocol: The host iterates over an index and expects the guest | ||
144 | * to assign a key name to the index and also return the value corresponding to | ||
145 | * the key. The host will have atmost one KVP transaction outstanding at any | ||
146 | * given point in time. The host side iteration stops when the guest returns | ||
147 | * an error. Microsoft has specified the following mapping of key names to | ||
148 | * host specified index: | ||
149 | * | ||
150 | * Index Key Name | ||
151 | * 0 FullyQualifiedDomainName | ||
152 | * 1 IntegrationServicesVersion | ||
153 | * 2 NetworkAddressIPv4 | ||
154 | * 3 NetworkAddressIPv6 | ||
155 | * 4 OSBuildNumber | ||
156 | * 5 OSName | ||
157 | * 6 OSMajorVersion | ||
158 | * 7 OSMinorVersion | ||
159 | * 8 OSVersion | ||
160 | * 9 ProcessorArchitecture | ||
161 | * | ||
162 | * The Windows host expects the Key Name and Key Value to be encoded in utf16. | ||
163 | * | ||
164 | * Guest Kernel/KVP Daemon Protocol: As noted earlier, we implement all of the | ||
165 | * data gathering functionality in a user mode daemon. The user level daemon | ||
166 | * is also responsible for binding the key name to the index as well. The | ||
167 | * kernel and user-level daemon communicate using a connector channel. | ||
168 | * | ||
169 | * The user mode component first registers with the | ||
170 | * the kernel component. Subsequently, the kernel component requests, data | ||
171 | * for the specified keys. In response to this message the user mode component | ||
172 | * fills in the value corresponding to the specified key. We overload the | ||
173 | * sequence field in the cn_msg header to define our KVP message types. | ||
174 | * | ||
175 | * | ||
176 | * The kernel component simply acts as a conduit for communication between the | ||
177 | * Windows host and the user-level daemon. The kernel component passes up the | ||
178 | * index received from the Host to the user-level daemon. If the index is | ||
179 | * valid (supported), the corresponding key as well as its | ||
180 | * value (both are strings) is returned. If the index is invalid | ||
181 | * (not supported), a NULL key string is returned. | ||
182 | */ | ||
183 | |||
184 | |||
185 | /* | ||
186 | * Registry value types. | ||
187 | */ | ||
188 | |||
189 | #define REG_SZ 1 | ||
190 | #define REG_U32 4 | ||
191 | #define REG_U64 8 | ||
192 | |||
193 | /* | ||
194 | * As we look at expanding the KVP functionality to include | ||
195 | * IP injection functionality, we need to maintain binary | ||
196 | * compatibility with older daemons. | ||
197 | * | ||
198 | * The KVP opcodes are defined by the host and it was unfortunate | ||
199 | * that I chose to treat the registration operation as part of the | ||
200 | * KVP operations defined by the host. | ||
201 | * Here is the level of compatibility | ||
202 | * (between the user level daemon and the kernel KVP driver) that we | ||
203 | * will implement: | ||
204 | * | ||
205 | * An older daemon will always be supported on a newer driver. | ||
206 | * A given user level daemon will require a minimal version of the | ||
207 | * kernel driver. | ||
208 | * If we cannot handle the version differences, we will fail gracefully | ||
209 | * (this can happen when we have a user level daemon that is more | ||
210 | * advanced than the KVP driver. | ||
211 | * | ||
212 | * We will use values used in this handshake for determining if we have | ||
213 | * workable user level daemon and the kernel driver. We begin by taking the | ||
214 | * registration opcode out of the KVP opcode namespace. We will however, | ||
215 | * maintain compatibility with the existing user-level daemon code. | ||
216 | */ | ||
217 | |||
218 | /* | ||
219 | * Daemon code not supporting IP injection (legacy daemon). | ||
220 | */ | ||
221 | |||
222 | #define KVP_OP_REGISTER 4 | ||
223 | |||
224 | /* | ||
225 | * Daemon code supporting IP injection. | ||
226 | * The KVP opcode field is used to communicate the | ||
227 | * registration information; so define a namespace that | ||
228 | * will be distinct from the host defined KVP opcode. | ||
229 | */ | ||
230 | |||
231 | #define KVP_OP_REGISTER1 100 | ||
232 | |||
233 | enum hv_kvp_exchg_op { | ||
234 | KVP_OP_GET = 0, | ||
235 | KVP_OP_SET, | ||
236 | KVP_OP_DELETE, | ||
237 | KVP_OP_ENUMERATE, | ||
238 | KVP_OP_GET_IP_INFO, | ||
239 | KVP_OP_SET_IP_INFO, | ||
240 | KVP_OP_COUNT /* Number of operations, must be last. */ | ||
241 | }; | ||
242 | |||
243 | enum hv_kvp_exchg_pool { | ||
244 | KVP_POOL_EXTERNAL = 0, | ||
245 | KVP_POOL_GUEST, | ||
246 | KVP_POOL_AUTO, | ||
247 | KVP_POOL_AUTO_EXTERNAL, | ||
248 | KVP_POOL_AUTO_INTERNAL, | ||
249 | KVP_POOL_COUNT /* Number of pools, must be last. */ | ||
250 | }; | ||
251 | |||
252 | /* | ||
253 | * Some Hyper-V status codes. | ||
254 | */ | ||
255 | |||
256 | #define HV_S_OK 0x00000000 | ||
257 | #define HV_E_FAIL 0x80004005 | ||
258 | #define HV_S_CONT 0x80070103 | ||
259 | #define HV_ERROR_NOT_SUPPORTED 0x80070032 | ||
260 | #define HV_ERROR_MACHINE_LOCKED 0x800704F7 | ||
261 | #define HV_ERROR_DEVICE_NOT_CONNECTED 0x8007048F | ||
262 | #define HV_INVALIDARG 0x80070057 | ||
263 | #define HV_GUID_NOTFOUND 0x80041002 | ||
264 | |||
265 | #define ADDR_FAMILY_NONE 0x00 | ||
266 | #define ADDR_FAMILY_IPV4 0x01 | ||
267 | #define ADDR_FAMILY_IPV6 0x02 | ||
268 | |||
269 | #define MAX_ADAPTER_ID_SIZE 128 | ||
270 | #define MAX_IP_ADDR_SIZE 1024 | ||
271 | #define MAX_GATEWAY_SIZE 512 | ||
272 | |||
273 | |||
274 | struct hv_kvp_ipaddr_value { | ||
275 | __u16 adapter_id[MAX_ADAPTER_ID_SIZE]; | ||
276 | __u8 addr_family; | ||
277 | __u8 dhcp_enabled; | ||
278 | __u16 ip_addr[MAX_IP_ADDR_SIZE]; | ||
279 | __u16 sub_net[MAX_IP_ADDR_SIZE]; | ||
280 | __u16 gate_way[MAX_GATEWAY_SIZE]; | ||
281 | __u16 dns_addr[MAX_IP_ADDR_SIZE]; | ||
282 | } __attribute__((packed)); | ||
283 | |||
284 | |||
285 | struct hv_kvp_hdr { | ||
286 | __u8 operation; | ||
287 | __u8 pool; | ||
288 | __u16 pad; | ||
289 | } __attribute__((packed)); | ||
290 | |||
291 | struct hv_kvp_exchg_msg_value { | ||
292 | __u32 value_type; | ||
293 | __u32 key_size; | ||
294 | __u32 value_size; | ||
295 | __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; | ||
296 | union { | ||
297 | __u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; | ||
298 | __u32 value_u32; | ||
299 | __u64 value_u64; | ||
300 | }; | ||
301 | } __attribute__((packed)); | ||
302 | |||
303 | struct hv_kvp_msg_enumerate { | ||
304 | __u32 index; | ||
305 | struct hv_kvp_exchg_msg_value data; | ||
306 | } __attribute__((packed)); | ||
307 | |||
308 | struct hv_kvp_msg_get { | ||
309 | struct hv_kvp_exchg_msg_value data; | ||
310 | }; | ||
311 | |||
312 | struct hv_kvp_msg_set { | ||
313 | struct hv_kvp_exchg_msg_value data; | ||
314 | }; | ||
315 | |||
316 | struct hv_kvp_msg_delete { | ||
317 | __u32 key_size; | ||
318 | __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; | ||
319 | }; | ||
320 | |||
321 | struct hv_kvp_register { | ||
322 | __u8 version[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; | ||
323 | }; | ||
324 | |||
325 | struct hv_kvp_msg { | ||
326 | union { | ||
327 | struct hv_kvp_hdr kvp_hdr; | ||
328 | int error; | ||
329 | }; | ||
330 | union { | ||
331 | struct hv_kvp_msg_get kvp_get; | ||
332 | struct hv_kvp_msg_set kvp_set; | ||
333 | struct hv_kvp_msg_delete kvp_delete; | ||
334 | struct hv_kvp_msg_enumerate kvp_enum_data; | ||
335 | struct hv_kvp_ipaddr_value kvp_ip_val; | ||
336 | struct hv_kvp_register kvp_register; | ||
337 | } body; | ||
338 | } __attribute__((packed)); | ||
339 | |||
340 | struct hv_kvp_ip_msg { | ||
341 | __u8 operation; | ||
342 | __u8 pool; | ||
343 | struct hv_kvp_ipaddr_value kvp_ip_val; | ||
344 | } __attribute__((packed)); | ||
345 | |||
346 | #ifdef __KERNEL__ | ||
347 | #include <linux/scatterlist.h> | 31 | #include <linux/scatterlist.h> |
348 | #include <linux/list.h> | 32 | #include <linux/list.h> |
349 | #include <linux/uuid.h> | 33 | #include <linux/uuid.h> |
@@ -1465,5 +1149,4 @@ void hv_vss_onchannelcallback(void *); | |||
1465 | 1149 | ||
1466 | extern __u32 vmbus_proto_version; | 1150 | extern __u32 vmbus_proto_version; |
1467 | 1151 | ||
1468 | #endif /* __KERNEL__ */ | ||
1469 | #endif /* _HYPERV_H */ | 1152 | #endif /* _HYPERV_H */ |
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild index 3ce25b5d75a9..6929571b79b0 100644 --- a/include/uapi/linux/Kbuild +++ b/include/uapi/linux/Kbuild | |||
@@ -139,6 +139,7 @@ header-y += hid.h | |||
139 | header-y += hiddev.h | 139 | header-y += hiddev.h |
140 | header-y += hidraw.h | 140 | header-y += hidraw.h |
141 | header-y += hpet.h | 141 | header-y += hpet.h |
142 | header-y += hyperv.h | ||
142 | header-y += hysdn_if.h | 143 | header-y += hysdn_if.h |
143 | header-y += i2c-dev.h | 144 | header-y += i2c-dev.h |
144 | header-y += i2c.h | 145 | header-y += i2c.h |
diff --git a/include/uapi/linux/hyperv.h b/include/uapi/linux/hyperv.h new file mode 100644 index 000000000000..1861f8e2ce2b --- /dev/null +++ b/include/uapi/linux/hyperv.h | |||
@@ -0,0 +1,344 @@ | |||
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 | */ | ||
24 | |||
25 | #ifndef _UAPI_HYPERV_H | ||
26 | #define _UAPI_HYPERV_H | ||
27 | |||
28 | /* | ||
29 | * Framework version for util services. | ||
30 | */ | ||
31 | #define UTIL_FW_MINOR 0 | ||
32 | |||
33 | #define UTIL_WS2K8_FW_MAJOR 1 | ||
34 | #define UTIL_WS2K8_FW_VERSION (UTIL_WS2K8_FW_MAJOR << 16 | UTIL_FW_MINOR) | ||
35 | |||
36 | #define UTIL_FW_MAJOR 3 | ||
37 | #define UTIL_FW_VERSION (UTIL_FW_MAJOR << 16 | UTIL_FW_MINOR) | ||
38 | |||
39 | |||
40 | /* | ||
41 | * Implementation of host controlled snapshot of the guest. | ||
42 | */ | ||
43 | |||
44 | #define VSS_OP_REGISTER 128 | ||
45 | |||
46 | enum hv_vss_op { | ||
47 | VSS_OP_CREATE = 0, | ||
48 | VSS_OP_DELETE, | ||
49 | VSS_OP_HOT_BACKUP, | ||
50 | VSS_OP_GET_DM_INFO, | ||
51 | VSS_OP_BU_COMPLETE, | ||
52 | /* | ||
53 | * Following operations are only supported with IC version >= 5.0 | ||
54 | */ | ||
55 | VSS_OP_FREEZE, /* Freeze the file systems in the VM */ | ||
56 | VSS_OP_THAW, /* Unfreeze the file systems */ | ||
57 | VSS_OP_AUTO_RECOVER, | ||
58 | VSS_OP_COUNT /* Number of operations, must be last */ | ||
59 | }; | ||
60 | |||
61 | |||
62 | /* | ||
63 | * Header for all VSS messages. | ||
64 | */ | ||
65 | struct hv_vss_hdr { | ||
66 | __u8 operation; | ||
67 | __u8 reserved[7]; | ||
68 | } __attribute__((packed)); | ||
69 | |||
70 | |||
71 | /* | ||
72 | * Flag values for the hv_vss_check_feature. Linux supports only | ||
73 | * one value. | ||
74 | */ | ||
75 | #define VSS_HBU_NO_AUTO_RECOVERY 0x00000005 | ||
76 | |||
77 | struct hv_vss_check_feature { | ||
78 | __u32 flags; | ||
79 | } __attribute__((packed)); | ||
80 | |||
81 | struct hv_vss_check_dm_info { | ||
82 | __u32 flags; | ||
83 | } __attribute__((packed)); | ||
84 | |||
85 | struct hv_vss_msg { | ||
86 | union { | ||
87 | struct hv_vss_hdr vss_hdr; | ||
88 | int error; | ||
89 | }; | ||
90 | union { | ||
91 | struct hv_vss_check_feature vss_cf; | ||
92 | struct hv_vss_check_dm_info dm_info; | ||
93 | }; | ||
94 | } __attribute__((packed)); | ||
95 | |||
96 | /* | ||
97 | * An implementation of HyperV key value pair (KVP) functionality for Linux. | ||
98 | * | ||
99 | * | ||
100 | * Copyright (C) 2010, Novell, Inc. | ||
101 | * Author : K. Y. Srinivasan <ksrinivasan@novell.com> | ||
102 | * | ||
103 | */ | ||
104 | |||
105 | /* | ||
106 | * Maximum value size - used for both key names and value data, and includes | ||
107 | * any applicable NULL terminators. | ||
108 | * | ||
109 | * Note: This limit is somewhat arbitrary, but falls easily within what is | ||
110 | * supported for all native guests (back to Win 2000) and what is reasonable | ||
111 | * for the IC KVP exchange functionality. Note that Windows Me/98/95 are | ||
112 | * limited to 255 character key names. | ||
113 | * | ||
114 | * MSDN recommends not storing data values larger than 2048 bytes in the | ||
115 | * registry. | ||
116 | * | ||
117 | * Note: This value is used in defining the KVP exchange message - this value | ||
118 | * cannot be modified without affecting the message size and compatibility. | ||
119 | */ | ||
120 | |||
121 | /* | ||
122 | * bytes, including any null terminators | ||
123 | */ | ||
124 | #define HV_KVP_EXCHANGE_MAX_VALUE_SIZE (2048) | ||
125 | |||
126 | |||
127 | /* | ||
128 | * Maximum key size - the registry limit for the length of an entry name | ||
129 | * is 256 characters, including the null terminator | ||
130 | */ | ||
131 | |||
132 | #define HV_KVP_EXCHANGE_MAX_KEY_SIZE (512) | ||
133 | |||
134 | /* | ||
135 | * In Linux, we implement the KVP functionality in two components: | ||
136 | * 1) The kernel component which is packaged as part of the hv_utils driver | ||
137 | * is responsible for communicating with the host and responsible for | ||
138 | * implementing the host/guest protocol. 2) A user level daemon that is | ||
139 | * responsible for data gathering. | ||
140 | * | ||
141 | * Host/Guest Protocol: The host iterates over an index and expects the guest | ||
142 | * to assign a key name to the index and also return the value corresponding to | ||
143 | * the key. The host will have atmost one KVP transaction outstanding at any | ||
144 | * given point in time. The host side iteration stops when the guest returns | ||
145 | * an error. Microsoft has specified the following mapping of key names to | ||
146 | * host specified index: | ||
147 | * | ||
148 | * Index Key Name | ||
149 | * 0 FullyQualifiedDomainName | ||
150 | * 1 IntegrationServicesVersion | ||
151 | * 2 NetworkAddressIPv4 | ||
152 | * 3 NetworkAddressIPv6 | ||
153 | * 4 OSBuildNumber | ||
154 | * 5 OSName | ||
155 | * 6 OSMajorVersion | ||
156 | * 7 OSMinorVersion | ||
157 | * 8 OSVersion | ||
158 | * 9 ProcessorArchitecture | ||
159 | * | ||
160 | * The Windows host expects the Key Name and Key Value to be encoded in utf16. | ||
161 | * | ||
162 | * Guest Kernel/KVP Daemon Protocol: As noted earlier, we implement all of the | ||
163 | * data gathering functionality in a user mode daemon. The user level daemon | ||
164 | * is also responsible for binding the key name to the index as well. The | ||
165 | * kernel and user-level daemon communicate using a connector channel. | ||
166 | * | ||
167 | * The user mode component first registers with the | ||
168 | * the kernel component. Subsequently, the kernel component requests, data | ||
169 | * for the specified keys. In response to this message the user mode component | ||
170 | * fills in the value corresponding to the specified key. We overload the | ||
171 | * sequence field in the cn_msg header to define our KVP message types. | ||
172 | * | ||
173 | * | ||
174 | * The kernel component simply acts as a conduit for communication between the | ||
175 | * Windows host and the user-level daemon. The kernel component passes up the | ||
176 | * index received from the Host to the user-level daemon. If the index is | ||
177 | * valid (supported), the corresponding key as well as its | ||
178 | * value (both are strings) is returned. If the index is invalid | ||
179 | * (not supported), a NULL key string is returned. | ||
180 | */ | ||
181 | |||
182 | |||
183 | /* | ||
184 | * Registry value types. | ||
185 | */ | ||
186 | |||
187 | #define REG_SZ 1 | ||
188 | #define REG_U32 4 | ||
189 | #define REG_U64 8 | ||
190 | |||
191 | /* | ||
192 | * As we look at expanding the KVP functionality to include | ||
193 | * IP injection functionality, we need to maintain binary | ||
194 | * compatibility with older daemons. | ||
195 | * | ||
196 | * The KVP opcodes are defined by the host and it was unfortunate | ||
197 | * that I chose to treat the registration operation as part of the | ||
198 | * KVP operations defined by the host. | ||
199 | * Here is the level of compatibility | ||
200 | * (between the user level daemon and the kernel KVP driver) that we | ||
201 | * will implement: | ||
202 | * | ||
203 | * An older daemon will always be supported on a newer driver. | ||
204 | * A given user level daemon will require a minimal version of the | ||
205 | * kernel driver. | ||
206 | * If we cannot handle the version differences, we will fail gracefully | ||
207 | * (this can happen when we have a user level daemon that is more | ||
208 | * advanced than the KVP driver. | ||
209 | * | ||
210 | * We will use values used in this handshake for determining if we have | ||
211 | * workable user level daemon and the kernel driver. We begin by taking the | ||
212 | * registration opcode out of the KVP opcode namespace. We will however, | ||
213 | * maintain compatibility with the existing user-level daemon code. | ||
214 | */ | ||
215 | |||
216 | /* | ||
217 | * Daemon code not supporting IP injection (legacy daemon). | ||
218 | */ | ||
219 | |||
220 | #define KVP_OP_REGISTER 4 | ||
221 | |||
222 | /* | ||
223 | * Daemon code supporting IP injection. | ||
224 | * The KVP opcode field is used to communicate the | ||
225 | * registration information; so define a namespace that | ||
226 | * will be distinct from the host defined KVP opcode. | ||
227 | */ | ||
228 | |||
229 | #define KVP_OP_REGISTER1 100 | ||
230 | |||
231 | enum hv_kvp_exchg_op { | ||
232 | KVP_OP_GET = 0, | ||
233 | KVP_OP_SET, | ||
234 | KVP_OP_DELETE, | ||
235 | KVP_OP_ENUMERATE, | ||
236 | KVP_OP_GET_IP_INFO, | ||
237 | KVP_OP_SET_IP_INFO, | ||
238 | KVP_OP_COUNT /* Number of operations, must be last. */ | ||
239 | }; | ||
240 | |||
241 | enum hv_kvp_exchg_pool { | ||
242 | KVP_POOL_EXTERNAL = 0, | ||
243 | KVP_POOL_GUEST, | ||
244 | KVP_POOL_AUTO, | ||
245 | KVP_POOL_AUTO_EXTERNAL, | ||
246 | KVP_POOL_AUTO_INTERNAL, | ||
247 | KVP_POOL_COUNT /* Number of pools, must be last. */ | ||
248 | }; | ||
249 | |||
250 | /* | ||
251 | * Some Hyper-V status codes. | ||
252 | */ | ||
253 | |||
254 | #define HV_S_OK 0x00000000 | ||
255 | #define HV_E_FAIL 0x80004005 | ||
256 | #define HV_S_CONT 0x80070103 | ||
257 | #define HV_ERROR_NOT_SUPPORTED 0x80070032 | ||
258 | #define HV_ERROR_MACHINE_LOCKED 0x800704F7 | ||
259 | #define HV_ERROR_DEVICE_NOT_CONNECTED 0x8007048F | ||
260 | #define HV_INVALIDARG 0x80070057 | ||
261 | #define HV_GUID_NOTFOUND 0x80041002 | ||
262 | |||
263 | #define ADDR_FAMILY_NONE 0x00 | ||
264 | #define ADDR_FAMILY_IPV4 0x01 | ||
265 | #define ADDR_FAMILY_IPV6 0x02 | ||
266 | |||
267 | #define MAX_ADAPTER_ID_SIZE 128 | ||
268 | #define MAX_IP_ADDR_SIZE 1024 | ||
269 | #define MAX_GATEWAY_SIZE 512 | ||
270 | |||
271 | |||
272 | struct hv_kvp_ipaddr_value { | ||
273 | __u16 adapter_id[MAX_ADAPTER_ID_SIZE]; | ||
274 | __u8 addr_family; | ||
275 | __u8 dhcp_enabled; | ||
276 | __u16 ip_addr[MAX_IP_ADDR_SIZE]; | ||
277 | __u16 sub_net[MAX_IP_ADDR_SIZE]; | ||
278 | __u16 gate_way[MAX_GATEWAY_SIZE]; | ||
279 | __u16 dns_addr[MAX_IP_ADDR_SIZE]; | ||
280 | } __attribute__((packed)); | ||
281 | |||
282 | |||
283 | struct hv_kvp_hdr { | ||
284 | __u8 operation; | ||
285 | __u8 pool; | ||
286 | __u16 pad; | ||
287 | } __attribute__((packed)); | ||
288 | |||
289 | struct hv_kvp_exchg_msg_value { | ||
290 | __u32 value_type; | ||
291 | __u32 key_size; | ||
292 | __u32 value_size; | ||
293 | __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; | ||
294 | union { | ||
295 | __u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; | ||
296 | __u32 value_u32; | ||
297 | __u64 value_u64; | ||
298 | }; | ||
299 | } __attribute__((packed)); | ||
300 | |||
301 | struct hv_kvp_msg_enumerate { | ||
302 | __u32 index; | ||
303 | struct hv_kvp_exchg_msg_value data; | ||
304 | } __attribute__((packed)); | ||
305 | |||
306 | struct hv_kvp_msg_get { | ||
307 | struct hv_kvp_exchg_msg_value data; | ||
308 | }; | ||
309 | |||
310 | struct hv_kvp_msg_set { | ||
311 | struct hv_kvp_exchg_msg_value data; | ||
312 | }; | ||
313 | |||
314 | struct hv_kvp_msg_delete { | ||
315 | __u32 key_size; | ||
316 | __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; | ||
317 | }; | ||
318 | |||
319 | struct hv_kvp_register { | ||
320 | __u8 version[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; | ||
321 | }; | ||
322 | |||
323 | struct hv_kvp_msg { | ||
324 | union { | ||
325 | struct hv_kvp_hdr kvp_hdr; | ||
326 | int error; | ||
327 | }; | ||
328 | union { | ||
329 | struct hv_kvp_msg_get kvp_get; | ||
330 | struct hv_kvp_msg_set kvp_set; | ||
331 | struct hv_kvp_msg_delete kvp_delete; | ||
332 | struct hv_kvp_msg_enumerate kvp_enum_data; | ||
333 | struct hv_kvp_ipaddr_value kvp_ip_val; | ||
334 | struct hv_kvp_register kvp_register; | ||
335 | } body; | ||
336 | } __attribute__((packed)); | ||
337 | |||
338 | struct hv_kvp_ip_msg { | ||
339 | __u8 operation; | ||
340 | __u8 pool; | ||
341 | struct hv_kvp_ipaddr_value kvp_ip_val; | ||
342 | } __attribute__((packed)); | ||
343 | |||
344 | #endif /* _UAPI_HYPERV_H */ | ||