aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/hyperv.h
diff options
context:
space:
mode:
authorK. Y. Srinivasan <kys@microsoft.com>2012-01-27 18:55:58 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-02-02 18:30:47 -0500
commit2939437ce8f2de07237eb2bcce29b6a699bfe799 (patch)
tree332fcfba624a5f9661eb456c9ae65d28829b2edd /include/linux/hyperv.h
parent4f03a2c934894f30a64d397df8c7c4de129c5b30 (diff)
drivers: hv: kvp: Move the contents of hv_kvp.h to hyperv.h
In preparation for consolidating all KVP related defines into a single header file that both the kernel and user level components can use, move the contents of hv_kvp.h into hyperv.h. Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/hyperv.h')
-rw-r--r--include/linux/hyperv.h165
1 files changed, 165 insertions, 0 deletions
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 62b908e0e591..7332b3faecc8 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -25,6 +25,166 @@
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 * The following definitions are shared with the user-mode component; do not
119 * change any of this without making the corresponding changes in
120 * the KVP user-mode component.
121 */
122
123enum hv_ku_op {
124 KVP_REGISTER = 0, /* Register the user mode component */
125 KVP_KERNEL_GET, /* Kernel is requesting the value */
126 KVP_KERNEL_SET, /* Kernel is providing the value */
127 KVP_USER_GET, /* User is requesting the value */
128 KVP_USER_SET /* User is providing the value */
129};
130
131struct hv_ku_msg {
132 __u32 kvp_index; /* Key index */
133 __u8 kvp_key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; /* Key name */
134 __u8 kvp_value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; /* Key value */
135};
136
137
138
139
140#ifdef __KERNEL__
141
142/*
143 * Registry value types.
144 */
145
146#define REG_SZ 1
147
148enum hv_kvp_exchg_op {
149 KVP_OP_GET = 0,
150 KVP_OP_SET,
151 KVP_OP_DELETE,
152 KVP_OP_ENUMERATE,
153 KVP_OP_COUNT /* Number of operations, must be last. */
154};
155
156enum hv_kvp_exchg_pool {
157 KVP_POOL_EXTERNAL = 0,
158 KVP_POOL_GUEST,
159 KVP_POOL_AUTO,
160 KVP_POOL_AUTO_EXTERNAL,
161 KVP_POOL_AUTO_INTERNAL,
162 KVP_POOL_COUNT /* Number of pools, must be last. */
163};
164
165struct hv_kvp_hdr {
166 u8 operation;
167 u8 pool;
168};
169
170struct hv_kvp_exchg_msg_value {
171 u32 value_type;
172 u32 key_size;
173 u32 value_size;
174 u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
175 u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
176};
177
178struct hv_kvp_msg_enumerate {
179 u32 index;
180 struct hv_kvp_exchg_msg_value data;
181};
182
183struct hv_kvp_msg {
184 struct hv_kvp_hdr kvp_hdr;
185 struct hv_kvp_msg_enumerate kvp_data;
186};
187
28#include <linux/scatterlist.h> 188#include <linux/scatterlist.h>
29#include <linux/list.h> 189#include <linux/list.h>
30#include <linux/uuid.h> 190#include <linux/uuid.h>
@@ -870,4 +1030,9 @@ struct hyperv_service_callback {
870extern void vmbus_prep_negotiate_resp(struct icmsg_hdr *, 1030extern void vmbus_prep_negotiate_resp(struct icmsg_hdr *,
871 struct icmsg_negotiate *, u8 *); 1031 struct icmsg_negotiate *, u8 *);
872 1032
1033int hv_kvp_init(struct hv_util_service *);
1034void hv_kvp_deinit(void);
1035void hv_kvp_onchannelcallback(void *);
1036
1037#endif /* __KERNEL__ */
873#endif /* _HYPERV_H */ 1038#endif /* _HYPERV_H */