diff options
| author | Arnd Bergmann <arnd@arndb.de> | 2012-02-13 06:30:04 +0000 |
|---|---|---|
| committer | Arnd Bergmann <arnd@arndb.de> | 2012-02-13 06:30:04 +0000 |
| commit | eaa5699e3bff8e8335757cf401451ffbd4a88109 (patch) | |
| tree | a5a23148d26f9d083080d94991e8ceed12c0857b /include/linux/hyperv.h | |
| parent | d65b4e98d7ea3038b767b70fe8be959b2913f16d (diff) | |
| parent | da5a70f3519fd6f73ece3eea261a861c9a4d6bbd (diff) | |
Merge branch 'depends/driver-core' into next/soc2
* depends/driver-core: (55 commits)
Documentation: add information for new sysfs soc bus functionality
drivers/base: add bus for System-on-Chip devices
DWC3: use module_pci_driver
PCI: Add helper macro for pci_register_driver boilerplate
w1: Use linux/gpio.h rather than asm/gpio.h
drivers: hv: Increase the number of VCPUs supported in the guest
drivers: hv: kvp: Cleanup the kernel/user protocol
tools: hv: Use hyperv.h to get the KVP definitions
drivers: hv: Cleanup the kvp related state in hyperv.h
ACPI: remove duplicated lines of merging problems with acpi_processor_start
cpufreq/gx: Fix the compile error
drivers: hv: kvp: Move the contents of hv_kvp.h to hyperv.h
drivers: hv: kvp: Add/cleanup connector defines
sysfs: Update the name hash when renaming sysfs entries
PCI/XEN: Fix bug introduced by a recent change
USB/PCI/PCMCIA: Clean up new_id and remove_id sysfs attribute routines
CPU: Introduce ARCH_HAS_CPU_AUTOPROBE and X86 parts
x86: autoload microcode driver on Intel and AMD systems v2
cpufreq: Add support for x86 cpuinfo auto loading v4
X86: Introduce HW-Pstate scattered cpuid feature
...
Diffstat (limited to 'include/linux/hyperv.h')
| -rw-r--r-- | include/linux/hyperv.h | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 62b908e0e591..75aee6720c1b 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -25,6 +25,147 @@ #ifndef _HYPERV_H #define _HYPERV_H +#include <linux/types.h> + +/* + * An implementation of HyperV key value pair (KVP) functionality for Linux. + * + * + * Copyright (C) 2010, Novell, Inc. + * Author : K. Y. Srinivasan <ksrinivasan@novell.com> + * + */ + +/* + * Maximum value size - used for both key names and value data, and includes + * any applicable NULL terminators. + * + * Note: This limit is somewhat arbitrary, but falls easily within what is + * supported for all native guests (back to Win 2000) and what is reasonable + * for the IC KVP exchange functionality. Note that Windows Me/98/95 are + * limited to 255 character key names. + * + * MSDN recommends not storing data values larger than 2048 bytes in the + * registry. + * + * Note: This value is used in defining the KVP exchange message - this value + * cannot be modified without affecting the message size and compatibility. + */ + +/* + * bytes, including any null terminators + */ +#define HV_KVP_EXCHANGE_MAX_VALUE_SIZE (2048) + + +/* + * Maximum key size - the registry limit for the length of an entry name + * is 256 characters, including the null terminator + */ + +#define HV_KVP_EXCHANGE_MAX_KEY_SIZE (512) + +/* + * In Linux, we implement the KVP functionality in two components: + * 1) The kernel component which is packaged as part of the hv_utils driver + * is responsible for communicating with the host and responsible for + * implementing the host/guest protocol. 2) A user level daemon that is + * responsible for data gathering. + * + * Host/Guest Protocol: The host iterates over an index and expects the guest + * to assign a key name to the index and also return the value corresponding to + * the key. The host will have atmost one KVP transaction outstanding at any + * given point in time. The host side iteration stops when the guest returns + * an error. Microsoft has specified the following mapping of key names to + * host specified index: + * + * Index Key Name + * 0 FullyQualifiedDomainName + * 1 IntegrationServicesVersion + * 2 NetworkAddressIPv4 + * 3 NetworkAddressIPv6 + * 4 OSBuildNumber + * 5 OSName + * 6 OSMajorVersion + * 7 OSMinorVersion + * 8 OSVersion + * 9 ProcessorArchitecture + * + * The Windows host expects the Key Name and Key Value to be encoded in utf16. + * + * Guest Kernel/KVP Daemon Protocol: As noted earlier, we implement all of the + * data gathering functionality in a user mode daemon. The user level daemon + * is also responsible for binding the key name to the index as well. The + * kernel and user-level daemon communicate using a connector channel. + * + * The user mode component first registers with the + * the kernel component. Subsequently, the kernel component requests, data + * for the specified keys. In response to this message the user mode component + * fills in the value corresponding to the specified key. We overload the + * sequence field in the cn_msg header to define our KVP message types. + * + * + * The kernel component simply acts as a conduit for communication between the + * Windows host and the user-level daemon. The kernel component passes up the + * index received from the Host to the user-level daemon. If the index is + * valid (supported), the corresponding key as well as its + * value (both are strings) is returned. If the index is invalid + * (not supported), a NULL key string is returned. + */ + + +/* + * Registry value types. + */ + +#define REG_SZ 1 + +enum hv_kvp_exchg_op { + KVP_OP_GET = 0, + KVP_OP_SET, + KVP_OP_DELETE, + KVP_OP_ENUMERATE, + KVP_OP_REGISTER, + KVP_OP_COUNT /* Number of operations, must be last. */ +}; + +enum hv_kvp_exchg_pool { + KVP_POOL_EXTERNAL = 0, + KVP_POOL_GUEST, + KVP_POOL_AUTO, + KVP_POOL_AUTO_EXTERNAL, + KVP_POOL_AUTO_INTERNAL, + KVP_POOL_COUNT /* Number of pools, must be last. */ +}; + +struct hv_kvp_hdr { + __u8 operation; + __u8 pool; + __u16 pad; +} __attribute__((packed)); + +struct hv_kvp_exchg_msg_value { + __u32 value_type; + __u32 key_size; + __u32 value_size; + __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; + __u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; +} __attribute__((packed)); + +struct hv_kvp_msg_enumerate { + __u32 index; + struct hv_kvp_exchg_msg_value data; +} __attribute__((packed)); + +struct hv_kvp_msg { + struct hv_kvp_hdr kvp_hdr; + union { + struct hv_kvp_msg_enumerate kvp_enum_data; + char kvp_version[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; + } body; +} __attribute__((packed)); + +#ifdef __KERNEL__ #include <linux/scatterlist.h> #include <linux/list.h> #include <linux/uuid.h> @@ -870,4 +1011,9 @@ struct hyperv_service_callback { extern void vmbus_prep_negotiate_resp(struct icmsg_hdr *, struct icmsg_negotiate *, u8 *); +int hv_kvp_init(struct hv_util_service *); +void hv_kvp_deinit(void); +void hv_kvp_onchannelcallback(void *); + +#endif /* __KERNEL__ */ #endif /* _HYPERV_H */ |
