diff options
Diffstat (limited to 'include/linux/hyperv.h')
| -rw-r--r-- | include/linux/hyperv.h | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 0ae065a5fcb2..5852545e6bba 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h | |||
| @@ -25,6 +25,173 @@ | |||
| 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 | #define REG_U32 4 | ||
| 123 | #define REG_U64 8 | ||
| 124 | |||
| 125 | enum hv_kvp_exchg_op { | ||
| 126 | KVP_OP_GET = 0, | ||
| 127 | KVP_OP_SET, | ||
| 128 | KVP_OP_DELETE, | ||
| 129 | KVP_OP_ENUMERATE, | ||
| 130 | KVP_OP_REGISTER, | ||
| 131 | KVP_OP_COUNT /* Number of operations, must be last. */ | ||
| 132 | }; | ||
| 133 | |||
| 134 | enum hv_kvp_exchg_pool { | ||
| 135 | KVP_POOL_EXTERNAL = 0, | ||
| 136 | KVP_POOL_GUEST, | ||
| 137 | KVP_POOL_AUTO, | ||
| 138 | KVP_POOL_AUTO_EXTERNAL, | ||
| 139 | KVP_POOL_AUTO_INTERNAL, | ||
| 140 | KVP_POOL_COUNT /* Number of pools, must be last. */ | ||
| 141 | }; | ||
| 142 | |||
| 143 | struct hv_kvp_hdr { | ||
| 144 | __u8 operation; | ||
| 145 | __u8 pool; | ||
| 146 | __u16 pad; | ||
| 147 | } __attribute__((packed)); | ||
| 148 | |||
| 149 | struct hv_kvp_exchg_msg_value { | ||
| 150 | __u32 value_type; | ||
| 151 | __u32 key_size; | ||
| 152 | __u32 value_size; | ||
| 153 | __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; | ||
| 154 | union { | ||
| 155 | __u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; | ||
| 156 | __u32 value_u32; | ||
| 157 | __u64 value_u64; | ||
| 158 | }; | ||
| 159 | } __attribute__((packed)); | ||
| 160 | |||
| 161 | struct hv_kvp_msg_enumerate { | ||
| 162 | __u32 index; | ||
| 163 | struct hv_kvp_exchg_msg_value data; | ||
| 164 | } __attribute__((packed)); | ||
| 165 | |||
| 166 | struct hv_kvp_msg_get { | ||
| 167 | struct hv_kvp_exchg_msg_value data; | ||
| 168 | }; | ||
| 169 | |||
| 170 | struct hv_kvp_msg_set { | ||
| 171 | struct hv_kvp_exchg_msg_value data; | ||
| 172 | }; | ||
| 173 | |||
| 174 | struct hv_kvp_msg_delete { | ||
| 175 | __u32 key_size; | ||
| 176 | __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; | ||
| 177 | }; | ||
| 178 | |||
| 179 | struct hv_kvp_register { | ||
| 180 | __u8 version[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; | ||
| 181 | }; | ||
| 182 | |||
| 183 | struct hv_kvp_msg { | ||
| 184 | struct hv_kvp_hdr kvp_hdr; | ||
| 185 | union { | ||
| 186 | struct hv_kvp_msg_get kvp_get; | ||
| 187 | struct hv_kvp_msg_set kvp_set; | ||
| 188 | struct hv_kvp_msg_delete kvp_delete; | ||
| 189 | struct hv_kvp_msg_enumerate kvp_enum_data; | ||
| 190 | struct hv_kvp_register kvp_register; | ||
| 191 | } body; | ||
| 192 | } __attribute__((packed)); | ||
| 193 | |||
| 194 | #ifdef __KERNEL__ | ||
| 28 | #include <linux/scatterlist.h> | 195 | #include <linux/scatterlist.h> |
| 29 | #include <linux/list.h> | 196 | #include <linux/list.h> |
| 30 | #include <linux/uuid.h> | 197 | #include <linux/uuid.h> |
| @@ -785,6 +952,7 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver); | |||
| 785 | 952 | ||
| 786 | #define HV_S_OK 0x00000000 | 953 | #define HV_S_OK 0x00000000 |
| 787 | #define HV_E_FAIL 0x80004005 | 954 | #define HV_E_FAIL 0x80004005 |
| 955 | #define HV_S_CONT 0x80070103 | ||
| 788 | #define HV_ERROR_NOT_SUPPORTED 0x80070032 | 956 | #define HV_ERROR_NOT_SUPPORTED 0x80070032 |
| 789 | #define HV_ERROR_MACHINE_LOCKED 0x800704F7 | 957 | #define HV_ERROR_MACHINE_LOCKED 0x800704F7 |
| 790 | 958 | ||
| @@ -870,4 +1038,9 @@ struct hyperv_service_callback { | |||
| 870 | extern void vmbus_prep_negotiate_resp(struct icmsg_hdr *, | 1038 | extern void vmbus_prep_negotiate_resp(struct icmsg_hdr *, |
| 871 | struct icmsg_negotiate *, u8 *); | 1039 | struct icmsg_negotiate *, u8 *); |
| 872 | 1040 | ||
| 1041 | int hv_kvp_init(struct hv_util_service *); | ||
| 1042 | void hv_kvp_deinit(void); | ||
| 1043 | void hv_kvp_onchannelcallback(void *); | ||
| 1044 | |||
| 1045 | #endif /* __KERNEL__ */ | ||
| 873 | #endif /* _HYPERV_H */ | 1046 | #endif /* _HYPERV_H */ |
