aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/hyperv.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/hyperv.h')
-rw-r--r--include/linux/hyperv.h146
1 files changed, 146 insertions, 0 deletions
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 0ae065a5fcb2..e57a6c6ee0e8 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -25,6 +25,147 @@
25#ifndef _HYPERV_H 25#ifndef _HYPERV_H
26#define _HYPERV_H 26#define _HYPERV_H
27 27
28#include <linux/types.h>
29
30/*
31 * An implementation of HyperV key value pair (KVP) functionality for Linux.
32 *
33 *
34 * Copyright (C) 2010, Novell, Inc.
35 * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
36 *
37 */
38
39/*
40 * Maximum value size - used for both key names and value data, and includes
41 * any applicable NULL terminators.
42 *
43 * Note: This limit is somewhat arbitrary, but falls easily within what is
44 * supported for all native guests (back to Win 2000) and what is reasonable
45 * for the IC KVP exchange functionality. Note that Windows Me/98/95 are
46 * limited to 255 character key names.
47 *
48 * MSDN recommends not storing data values larger than 2048 bytes in the
49 * registry.
50 *
51 * Note: This value is used in defining the KVP exchange message - this value
52 * cannot be modified without affecting the message size and compatibility.
53 */
54
55/*
56 * bytes, including any null terminators
57 */
58#define HV_KVP_EXCHANGE_MAX_VALUE_SIZE (2048)
59
60
61/*
62 * Maximum key size - the registry limit for the length of an entry name
63 * is 256 characters, including the null terminator
64 */
65
66#define HV_KVP_EXCHANGE_MAX_KEY_SIZE (512)
67
68/*
69 * In Linux, we implement the KVP functionality in two components:
70 * 1) The kernel component which is packaged as part of the hv_utils driver
71 * is responsible for communicating with the host and responsible for
72 * implementing the host/guest protocol. 2) A user level daemon that is
73 * responsible for data gathering.
74 *
75 * Host/Guest Protocol: The host iterates over an index and expects the guest
76 * to assign a key name to the index and also return the value corresponding to
77 * the key. The host will have atmost one KVP transaction outstanding at any
78 * given point in time. The host side iteration stops when the guest returns
79 * an error. Microsoft has specified the following mapping of key names to
80 * host specified index:
81 *
82 * Index Key Name
83 * 0 FullyQualifiedDomainName
84 * 1 IntegrationServicesVersion
85 * 2 NetworkAddressIPv4
86 * 3 NetworkAddressIPv6
87 * 4 OSBuildNumber
88 * 5 OSName
89 * 6 OSMajorVersion
90 * 7 OSMinorVersion
91 * 8 OSVersion
92 * 9 ProcessorArchitecture
93 *
94 * The Windows host expects the Key Name and Key Value to be encoded in utf16.
95 *
96 * Guest Kernel/KVP Daemon Protocol: As noted earlier, we implement all of the
97 * data gathering functionality in a user mode daemon. The user level daemon
98 * is also responsible for binding the key name to the index as well. The
99 * kernel and user-level daemon communicate using a connector channel.
100 *
101 * The user mode component first registers with the
102 * the kernel component. Subsequently, the kernel component requests, data
103 * for the specified keys. In response to this message the user mode component
104 * fills in the value corresponding to the specified key. We overload the
105 * sequence field in the cn_msg header to define our KVP message types.
106 *
107 *
108 * The kernel component simply acts as a conduit for communication between the
109 * Windows host and the user-level daemon. The kernel component passes up the
110 * index received from the Host to the user-level daemon. If the index is
111 * valid (supported), the corresponding key as well as its
112 * value (both are strings) is returned. If the index is invalid
113 * (not supported), a NULL key string is returned.
114 */
115
116
117/*
118 * Registry value types.
119 */
120
121#define REG_SZ 1
122
123enum hv_kvp_exchg_op {
124 KVP_OP_GET = 0,
125 KVP_OP_SET,
126 KVP_OP_DELETE,
127 KVP_OP_ENUMERATE,
128 KVP_OP_REGISTER,
129 KVP_OP_COUNT /* Number of operations, must be last. */
130};
131
132enum hv_kvp_exchg_pool {
133 KVP_POOL_EXTERNAL = 0,
134 KVP_POOL_GUEST,
135 KVP_POOL_AUTO,
136 KVP_POOL_AUTO_EXTERNAL,
137 KVP_POOL_AUTO_INTERNAL,
138 KVP_POOL_COUNT /* Number of pools, must be last. */
139};
140
141struct hv_kvp_hdr {
142 __u8 operation;
143 __u8 pool;
144 __u16 pad;
145} __attribute__((packed));
146
147struct hv_kvp_exchg_msg_value {
148 __u32 value_type;
149 __u32 key_size;
150 __u32 value_size;
151 __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
152 __u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
153} __attribute__((packed));
154
155struct hv_kvp_msg_enumerate {
156 __u32 index;
157 struct hv_kvp_exchg_msg_value data;
158} __attribute__((packed));
159
160struct hv_kvp_msg {
161 struct hv_kvp_hdr kvp_hdr;
162 union {
163 struct hv_kvp_msg_enumerate kvp_enum_data;
164 char kvp_version[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
165 } body;
166} __attribute__((packed));
167
168#ifdef __KERNEL__
28#include <linux/scatterlist.h> 169#include <linux/scatterlist.h>
29#include <linux/list.h> 170#include <linux/list.h>
30#include <linux/uuid.h> 171#include <linux/uuid.h>
@@ -870,4 +1011,9 @@ struct hyperv_service_callback {
870extern void vmbus_prep_negotiate_resp(struct icmsg_hdr *, 1011extern void vmbus_prep_negotiate_resp(struct icmsg_hdr *,
871 struct icmsg_negotiate *, u8 *); 1012 struct icmsg_negotiate *, u8 *);
872 1013
1014int hv_kvp_init(struct hv_util_service *);
1015void hv_kvp_deinit(void);
1016void hv_kvp_onchannelcallback(void *);
1017
1018#endif /* __KERNEL__ */
873#endif /* _HYPERV_H */ 1019#endif /* _HYPERV_H */