diff options
Diffstat (limited to 'include/linux/hyperv.h')
| -rw-r--r-- | include/linux/hyperv.h | 355 |
1 files changed, 32 insertions, 323 deletions
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 15da677478dd..ab7359fde987 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h | |||
| @@ -25,328 +25,11 @@ | |||
| 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 | |||
| 136 | /* | ||
| 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 | 29 | ||
| 256 | #define HV_S_OK 0x00000000 | 30 | #include <linux/types.h> |
| 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> | ||
| 350 | #include <linux/timer.h> | 33 | #include <linux/timer.h> |
| 351 | #include <linux/workqueue.h> | 34 | #include <linux/workqueue.h> |
| 352 | #include <linux/completion.h> | 35 | #include <linux/completion.h> |
| @@ -354,7 +37,7 @@ struct hv_kvp_ip_msg { | |||
| 354 | #include <linux/mod_devicetable.h> | 37 | #include <linux/mod_devicetable.h> |
| 355 | 38 | ||
| 356 | 39 | ||
| 357 | #define MAX_PAGE_BUFFER_COUNT 19 | 40 | #define MAX_PAGE_BUFFER_COUNT 32 |
| 358 | #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */ | 41 | #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */ |
| 359 | 42 | ||
| 360 | #pragma pack(push, 1) | 43 | #pragma pack(push, 1) |
| @@ -875,7 +558,7 @@ struct vmbus_channel_relid_released { | |||
| 875 | struct vmbus_channel_initiate_contact { | 558 | struct vmbus_channel_initiate_contact { |
| 876 | struct vmbus_channel_message_header header; | 559 | struct vmbus_channel_message_header header; |
| 877 | u32 vmbus_version_requested; | 560 | u32 vmbus_version_requested; |
| 878 | u32 padding2; | 561 | u32 target_vcpu; /* The VCPU the host should respond to */ |
| 879 | u64 interrupt_page; | 562 | u64 interrupt_page; |
| 880 | u64 monitor_page1; | 563 | u64 monitor_page1; |
| 881 | u64 monitor_page2; | 564 | u64 monitor_page2; |
| @@ -1043,6 +726,10 @@ struct vmbus_channel { | |||
| 1043 | * This will be NULL for the primary channel. | 726 | * This will be NULL for the primary channel. |
| 1044 | */ | 727 | */ |
| 1045 | struct vmbus_channel *primary_channel; | 728 | struct vmbus_channel *primary_channel; |
| 729 | /* | ||
| 730 | * Support per-channel state for use by vmbus drivers. | ||
| 731 | */ | ||
| 732 | void *per_channel_state; | ||
| 1046 | }; | 733 | }; |
| 1047 | 734 | ||
| 1048 | static inline void set_channel_read_state(struct vmbus_channel *c, bool state) | 735 | static inline void set_channel_read_state(struct vmbus_channel *c, bool state) |
| @@ -1050,6 +737,16 @@ static inline void set_channel_read_state(struct vmbus_channel *c, bool state) | |||
| 1050 | c->batched_reading = state; | 737 | c->batched_reading = state; |
| 1051 | } | 738 | } |
| 1052 | 739 | ||
| 740 | static inline void set_per_channel_state(struct vmbus_channel *c, void *s) | ||
| 741 | { | ||
| 742 | c->per_channel_state = s; | ||
| 743 | } | ||
| 744 | |||
| 745 | static inline void *get_per_channel_state(struct vmbus_channel *c) | ||
| 746 | { | ||
| 747 | return c->per_channel_state; | ||
| 748 | } | ||
| 749 | |||
| 1053 | void vmbus_onmessage(void *context); | 750 | void vmbus_onmessage(void *context); |
| 1054 | 751 | ||
| 1055 | int vmbus_request_offers(void); | 752 | int vmbus_request_offers(void); |
| @@ -1118,7 +815,7 @@ extern int vmbus_open(struct vmbus_channel *channel, | |||
| 1118 | extern void vmbus_close(struct vmbus_channel *channel); | 815 | extern void vmbus_close(struct vmbus_channel *channel); |
| 1119 | 816 | ||
| 1120 | extern int vmbus_sendpacket(struct vmbus_channel *channel, | 817 | extern int vmbus_sendpacket(struct vmbus_channel *channel, |
| 1121 | const void *buffer, | 818 | void *buffer, |
| 1122 | u32 bufferLen, | 819 | u32 bufferLen, |
| 1123 | u64 requestid, | 820 | u64 requestid, |
| 1124 | enum vmbus_packet_type type, | 821 | enum vmbus_packet_type type, |
| @@ -1352,6 +1049,17 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver); | |||
| 1352 | } | 1049 | } |
| 1353 | 1050 | ||
| 1354 | /* | 1051 | /* |
| 1052 | * Guest File Copy Service | ||
| 1053 | * {34D14BE3-DEE4-41c8-9AE7-6B174977C192} | ||
| 1054 | */ | ||
| 1055 | |||
| 1056 | #define HV_FCOPY_GUID \ | ||
| 1057 | .guid = { \ | ||
| 1058 | 0xE3, 0x4B, 0xD1, 0x34, 0xE4, 0xDE, 0xC8, 0x41, \ | ||
| 1059 | 0x9A, 0xE7, 0x6B, 0x17, 0x49, 0x77, 0xC1, 0x92 \ | ||
| 1060 | } | ||
| 1061 | |||
| 1062 | /* | ||
| 1355 | * Common header for Hyper-V ICs | 1063 | * Common header for Hyper-V ICs |
| 1356 | */ | 1064 | */ |
| 1357 | 1065 | ||
| @@ -1459,11 +1167,12 @@ int hv_vss_init(struct hv_util_service *); | |||
| 1459 | void hv_vss_deinit(void); | 1167 | void hv_vss_deinit(void); |
| 1460 | void hv_vss_onchannelcallback(void *); | 1168 | void hv_vss_onchannelcallback(void *); |
| 1461 | 1169 | ||
| 1170 | extern struct resource hyperv_mmio; | ||
| 1171 | |||
| 1462 | /* | 1172 | /* |
| 1463 | * Negotiated version with the Host. | 1173 | * Negotiated version with the Host. |
| 1464 | */ | 1174 | */ |
| 1465 | 1175 | ||
| 1466 | extern __u32 vmbus_proto_version; | 1176 | extern __u32 vmbus_proto_version; |
| 1467 | 1177 | ||
| 1468 | #endif /* __KERNEL__ */ | ||
| 1469 | #endif /* _HYPERV_H */ | 1178 | #endif /* _HYPERV_H */ |
