linux/include/uapi/linux/hyperv.h

/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
 *
 * Copyright (c) 2011, Microsoft Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307 USA.
 *
 * Authors:
 *   Haiyang Zhang <[email protected]>
 *   Hank Janssen  <[email protected]>
 *   K. Y. Srinivasan <[email protected]>
 *
 */

#ifndef _UAPI_HYPERV_H
#define _UAPI_HYPERV_H

#include <linux/types.h>

/*
 * Framework version for util services.
 */
#define UTIL_FW_MINOR

#define UTIL_WS2K8_FW_MAJOR
#define UTIL_WS2K8_FW_VERSION

#define UTIL_FW_MAJOR
#define UTIL_FW_VERSION


/*
 * Implementation of host controlled snapshot of the guest.
 */

#define VSS_OP_REGISTER

/*
  Daemon code with full handshake support.
 */
#define VSS_OP_REGISTER1

enum hv_vss_op {};


/*
 * Header for all VSS messages.
 */
struct hv_vss_hdr {} __attribute__((packed));


/*
 * Flag values for the hv_vss_check_feature. Linux supports only
 * one value.
 */
#define VSS_HBU_NO_AUTO_RECOVERY

struct hv_vss_check_feature {} __attribute__((packed));

struct hv_vss_check_dm_info {} __attribute__((packed));

/*
 * struct hv_vss_msg encodes the fields that the Linux VSS
 * driver accesses. However, FREEZE messages from Hyper-V contain
 * additional LUN information that Linux doesn't use and are not
 * represented in struct hv_vss_msg. A received FREEZE message may
 * be as large as 6,260 bytes, so the driver must allocate at least
 * that much space, not sizeof(struct hv_vss_msg). Other messages
 * such as AUTO_RECOVER may be as large as 12,500 bytes. However,
 * because the Linux VSS driver responds that it doesn't support
 * auto-recovery, it should not receive such messages.
 */
struct hv_vss_msg {} __attribute__((packed));

/*
 * Implementation of a host to guest copy facility.
 */

#define FCOPY_VERSION_0
#define FCOPY_VERSION_1
#define FCOPY_CURRENT_VERSION
#define W_MAX_PATH

enum hv_fcopy_op {};

struct hv_fcopy_hdr {} __attribute__((packed));

#define OVER_WRITE
#define CREATE_PATH

struct hv_start_fcopy {} __attribute__((packed));

/*
 * The file is chunked into fragments.
 */
#define DATA_FRAGMENT

struct hv_do_fcopy {} __attribute__((packed));

/*
 * An implementation of HyperV key value pair (KVP) functionality for Linux.
 *
 *
 * Copyright (C) 2010, Novell, Inc.
 * Author : K. Y. Srinivasan <[email protected]>
 *
 */

/*
 * 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


/*
 * 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

/*
 * 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
 * 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
#define REG_U32
#define REG_U64

/*
 * As we look at expanding the KVP functionality to include
 * IP injection functionality, we need to maintain binary
 * compatibility with older daemons.
 *
 * The KVP opcodes are defined by the host and it was unfortunate
 * that I chose to treat the registration operation as part of the
 * KVP operations defined by the host.
 * Here is the level of compatibility
 * (between the user level daemon and the kernel KVP driver) that we
 * will implement:
 *
 * An older daemon will always be supported on a newer driver.
 * A given user level daemon will require a minimal version of the
 * kernel driver.
 * If we cannot handle the version differences, we will fail gracefully
 * (this can happen when we have a user level daemon that is more
 * advanced than the KVP driver.
 *
 * We will use values used in this handshake for determining if we have
 * workable user level daemon and the kernel driver. We begin by taking the
 * registration opcode out of the KVP opcode namespace. We will however,
 * maintain compatibility with the existing user-level daemon code.
 */

/*
 * Daemon code not supporting IP injection (legacy daemon).
 */

#define KVP_OP_REGISTER

/*
 * Daemon code supporting IP injection.
 * The KVP opcode field is used to communicate the
 * registration information; so define a namespace that
 * will be distinct from the host defined KVP opcode.
 */

#define KVP_OP_REGISTER1

enum hv_kvp_exchg_op {};

enum hv_kvp_exchg_pool {};

/*
 * Some Hyper-V status codes.
 */

#define HV_S_OK
#define HV_E_FAIL
#define HV_S_CONT
#define HV_ERROR_NOT_SUPPORTED
#define HV_ERROR_MACHINE_LOCKED
#define HV_ERROR_DEVICE_NOT_CONNECTED
#define HV_INVALIDARG
#define HV_GUID_NOTFOUND
#define HV_ERROR_ALREADY_EXISTS
#define HV_ERROR_DISK_FULL

#define ADDR_FAMILY_NONE
#define ADDR_FAMILY_IPV4
#define ADDR_FAMILY_IPV6

#define MAX_ADAPTER_ID_SIZE
#define MAX_IP_ADDR_SIZE
#define MAX_GATEWAY_SIZE


struct hv_kvp_ipaddr_value {} __attribute__((packed));


struct hv_kvp_hdr {} __attribute__((packed));

struct hv_kvp_exchg_msg_value {} __attribute__((packed));

struct hv_kvp_msg_enumerate {} __attribute__((packed));

struct hv_kvp_msg_get {};

struct hv_kvp_msg_set {};

struct hv_kvp_msg_delete {};

struct hv_kvp_register {};

struct hv_kvp_msg {} __attribute__((packed));

struct hv_kvp_ip_msg {} __attribute__((packed));

#endif /* _UAPI_HYPERV_H */