#ifndef _HYPERV_H
#define _HYPERV_H
#include <uapi/linux/hyperv.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <linux/scatterlist.h>
#include <linux/list.h>
#include <linux/timer.h>
#include <linux/completion.h>
#include <linux/device.h>
#include <linux/mod_devicetable.h>
#include <linux/interrupt.h>
#include <linux/reciprocal_div.h>
#include <asm/hyperv-tlfs.h>
#define MAX_PAGE_BUFFER_COUNT …
#define MAX_MULTIPAGE_BUFFER_COUNT …
#pragma pack(push, 1)
enum hv_gpadl_type { … };
struct hv_page_buffer { … };
struct hv_multipage_buffer { … };
struct hv_mpb_array { … };
#define MAX_PAGE_BUFFER_PACKET …
#define MAX_MULTIPAGE_BUFFER_PACKET …
#pragma pack(pop)
struct hv_ring_buffer { … } __packed;
#define VMBUS_HEADER_ADJ(payload_sz) …
#define VMBUS_RING_SIZE(payload_sz) …
struct hv_ring_buffer_info { … };
static inline u32 hv_get_bytes_to_read(const struct hv_ring_buffer_info *rbi)
{ … }
static inline u32 hv_get_bytes_to_write(const struct hv_ring_buffer_info *rbi)
{ … }
static inline u32 hv_get_avail_to_write_percent(
const struct hv_ring_buffer_info *rbi)
{ … }
#define VERSION_WS2008 …
#define VERSION_WIN7 …
#define VERSION_WIN8 …
#define VERSION_WIN8_1 …
#define VERSION_WIN10 …
#define VERSION_WIN10_V4_1 …
#define VERSION_WIN10_V5 …
#define VERSION_WIN10_V5_1 …
#define VERSION_WIN10_V5_2 …
#define VERSION_WIN10_V5_3 …
#define MAX_PIPE_DATA_PAYLOAD …
#define VMBUS_PIPE_TYPE_BYTE …
#define VMBUS_PIPE_TYPE_MESSAGE …
#define MAX_USER_DEFINED_BYTES …
#define MAX_PIPE_USER_DEFINED_BYTES …
struct vmbus_channel_offer { … } __packed;
#define VMBUS_CHANNEL_ENUMERATE_DEVICE_INTERFACE …
#define VMBUS_CHANNEL_SERVER_SUPPORTS_TRANSFER_PAGES …
#define VMBUS_CHANNEL_SERVER_SUPPORTS_GPADLS …
#define VMBUS_CHANNEL_NAMED_PIPE_MODE …
#define VMBUS_CHANNEL_LOOPBACK_OFFER …
#define VMBUS_CHANNEL_PARENT_OFFER …
#define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION …
#define VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER …
struct vmpacket_descriptor { … } __packed;
struct vmpacket_header { … } __packed;
struct vmtransfer_page_range { … } __packed;
struct vmtransfer_page_packet_header { … } __packed;
struct vmgpadl_packet_header { … } __packed;
struct vmadd_remove_transfer_page_set { … } __packed;
struct gpa_range { … };
struct vmestablish_gpadl { … } __packed;
struct vmteardown_gpadl { … } __packed;
struct vmdata_gpa_direct { … } __packed;
struct vmadditional_data { … } __packed;
vmpacket_largest_possible_header;
#define VMPACKET_DATA_START_ADDRESS(__packet) …
#define VMPACKET_DATA_LENGTH(__packet) …
#define VMPACKET_TRANSFER_MODE(__packet) …
enum vmbus_packet_type { … };
#define VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED …
enum vmbus_channel_message_type { … };
#define INVALID_RELID …
struct vmbus_channel_message_header { … } __packed;
struct vmbus_channel_query_vmbus_version { … } __packed;
struct vmbus_channel_version_supported { … } __packed;
struct vmbus_channel_offer_channel { … } __packed;
struct vmbus_channel_rescind_offer { … } __packed;
struct vmbus_channel_open_channel { … } __packed;
struct vmbus_channel_open_result { … } __packed;
struct vmbus_channel_modifychannel_response { … } __packed;
struct vmbus_channel_close_channel { … } __packed;
#define GPADL_TYPE_RING_BUFFER …
#define GPADL_TYPE_SERVER_SAVE_AREA …
#define GPADL_TYPE_TRANSACTION …
struct vmbus_channel_gpadl_header { … } __packed;
struct vmbus_channel_gpadl_body { … } __packed;
struct vmbus_channel_gpadl_created { … } __packed;
struct vmbus_channel_gpadl_teardown { … } __packed;
struct vmbus_channel_gpadl_torndown { … } __packed;
struct vmbus_channel_relid_released { … } __packed;
struct vmbus_channel_initiate_contact { … } __packed;
struct vmbus_channel_tl_connect_request { … } __packed;
struct vmbus_channel_modifychannel { … } __packed;
struct vmbus_channel_version_response { … } __packed;
enum vmbus_channel_state { … };
struct vmbus_channel_msginfo { … };
struct vmbus_close_msg { … };
hv_connection_id;
enum vmbus_device_type { … };
struct vmbus_requestor { … };
#define VMBUS_NO_RQSTOR …
#define VMBUS_RQST_ERROR …
#define VMBUS_RQST_ADDR_ANY …
#define VMBUS_RQST_ID_NO_RESPONSE …
#define VMBUS_RQST_INIT …
#define VMBUS_RQST_RESET …
struct vmbus_device { … };
#define VMBUS_DEFAULT_MAX_PKT_SIZE …
struct vmbus_gpadl { … };
struct vmbus_channel { … };
#define lock_requestor(channel, flags) …
static __always_inline void unlock_requestor(struct vmbus_channel *channel,
unsigned long flags)
{ … }
u64 vmbus_next_request_id(struct vmbus_channel *channel, u64 rqst_addr);
u64 __vmbus_request_addr_match(struct vmbus_channel *channel, u64 trans_id,
u64 rqst_addr);
u64 vmbus_request_addr_match(struct vmbus_channel *channel, u64 trans_id,
u64 rqst_addr);
u64 vmbus_request_addr(struct vmbus_channel *channel, u64 trans_id);
static inline bool is_hvsock_offer(const struct vmbus_channel_offer_channel *o)
{ … }
static inline bool is_hvsock_channel(const struct vmbus_channel *c)
{ … }
static inline bool is_sub_channel(const struct vmbus_channel *c)
{ … }
static inline void set_channel_read_mode(struct vmbus_channel *c,
enum hv_callback_mode mode)
{ … }
static inline void set_per_channel_state(struct vmbus_channel *c, void *s)
{ … }
static inline void *get_per_channel_state(struct vmbus_channel *c)
{ … }
static inline void set_channel_pending_send_size(struct vmbus_channel *c,
u32 size)
{ … }
void vmbus_onmessage(struct vmbus_channel_message_header *hdr);
int vmbus_request_offers(void);
void vmbus_set_sc_create_callback(struct vmbus_channel *primary_channel,
void (*sc_cr_cb)(struct vmbus_channel *new_sc));
void vmbus_set_chn_rescind_callback(struct vmbus_channel *channel,
void (*chn_rescind_cb)(struct vmbus_channel *));
struct vmbus_channel_packet_page_buffer { … } __packed;
struct vmbus_channel_packet_multipage_buffer { … } __packed;
struct vmbus_packet_mpb_array { … } __packed;
int vmbus_alloc_ring(struct vmbus_channel *channel,
u32 send_size, u32 recv_size);
void vmbus_free_ring(struct vmbus_channel *channel);
int vmbus_connect_ring(struct vmbus_channel *channel,
void (*onchannel_callback)(void *context),
void *context);
int vmbus_disconnect_ring(struct vmbus_channel *channel);
extern int vmbus_open(struct vmbus_channel *channel,
u32 send_ringbuffersize,
u32 recv_ringbuffersize,
void *userdata,
u32 userdatalen,
void (*onchannel_callback)(void *context),
void *context);
extern void vmbus_close(struct vmbus_channel *channel);
extern int vmbus_sendpacket_getid(struct vmbus_channel *channel,
void *buffer,
u32 bufferLen,
u64 requestid,
u64 *trans_id,
enum vmbus_packet_type type,
u32 flags);
extern int vmbus_sendpacket(struct vmbus_channel *channel,
void *buffer,
u32 bufferLen,
u64 requestid,
enum vmbus_packet_type type,
u32 flags);
extern int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
struct hv_page_buffer pagebuffers[],
u32 pagecount,
void *buffer,
u32 bufferlen,
u64 requestid);
extern int vmbus_sendpacket_mpb_desc(struct vmbus_channel *channel,
struct vmbus_packet_mpb_array *mpb,
u32 desc_size,
void *buffer,
u32 bufferlen,
u64 requestid);
extern int vmbus_establish_gpadl(struct vmbus_channel *channel,
void *kbuffer,
u32 size,
struct vmbus_gpadl *gpadl);
extern int vmbus_teardown_gpadl(struct vmbus_channel *channel,
struct vmbus_gpadl *gpadl);
void vmbus_reset_channel_cb(struct vmbus_channel *channel);
extern int vmbus_recvpacket(struct vmbus_channel *channel,
void *buffer,
u32 bufferlen,
u32 *buffer_actual_len,
u64 *requestid);
extern int vmbus_recvpacket_raw(struct vmbus_channel *channel,
void *buffer,
u32 bufferlen,
u32 *buffer_actual_len,
u64 *requestid);
struct hv_driver { … };
struct hv_device { … };
#define device_to_hv_device(d) …
#define drv_to_hv_drv(d) …
static inline void hv_set_drvdata(struct hv_device *dev, void *data)
{ … }
static inline void *hv_get_drvdata(struct hv_device *dev)
{ … }
struct hv_ring_buffer_debug_info { … };
int hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
struct hv_ring_buffer_debug_info *debug_info);
bool hv_ringbuffer_spinlock_busy(struct vmbus_channel *channel);
#define vmbus_driver_register(driver) …
int __must_check __vmbus_driver_register(struct hv_driver *hv_driver,
struct module *owner,
const char *mod_name);
void vmbus_driver_unregister(struct hv_driver *hv_driver);
void vmbus_hvsock_device_unregister(struct vmbus_channel *channel);
int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj,
resource_size_t min, resource_size_t max,
resource_size_t size, resource_size_t align,
bool fb_overlap_ok);
void vmbus_free_mmio(resource_size_t start, resource_size_t size);
#define HV_NIC_GUID …
#define HV_IDE_GUID …
#define HV_SCSI_GUID …
#define HV_SHUTDOWN_GUID …
#define HV_TS_GUID …
#define HV_HEART_BEAT_GUID …
#define HV_KVP_GUID …
#define HV_DM_GUID …
#define HV_MOUSE_GUID …
#define HV_KBD_GUID …
#define HV_VSS_GUID …
#define HV_SYNTHVID_GUID …
#define HV_SYNTHFC_GUID …
#define HV_FCOPY_GUID …
#define HV_ND_GUID …
#define HV_PCIE_GUID …
#define HV_AVMA1_GUID …
#define HV_AVMA2_GUID …
#define HV_RDV_GUID …
#define HV_IMC_GUID …
#define ICMSGTYPE_NEGOTIATE …
#define ICMSGTYPE_HEARTBEAT …
#define ICMSGTYPE_KVPEXCHANGE …
#define ICMSGTYPE_SHUTDOWN …
#define ICMSGTYPE_TIMESYNC …
#define ICMSGTYPE_VSS …
#define ICMSGTYPE_FCOPY …
#define ICMSGHDRFLAG_TRANSACTION …
#define ICMSGHDRFLAG_REQUEST …
#define ICMSGHDRFLAG_RESPONSE …
struct hv_util_service { … };
struct vmbuspipe_hdr { … } __packed;
struct ic_version { … } __packed;
struct icmsg_hdr { … } __packed;
#define IC_VERSION_NEGOTIATION_MAX_VER_COUNT …
#define ICMSG_HDR …
#define ICMSG_NEGOTIATE_PKT_SIZE(icframe_vercnt, icmsg_vercnt) …
struct icmsg_negotiate { … } __packed;
struct shutdown_msg_data { … } __packed;
struct heartbeat_msg_data { … } __packed;
#define ICTIMESYNCFLAG_PROBE …
#define ICTIMESYNCFLAG_SYNC …
#define ICTIMESYNCFLAG_SAMPLE …
#ifdef __x86_64__
#define WLTIMEDELTA …
#else
#define WLTIMEDELTA …
#endif
struct ictimesync_data { … } __packed;
struct ictimesync_ref_data { … } __packed;
struct hyperv_service_callback { … };
struct hv_dma_range { … };
#define MAX_SRV_VER …
extern bool vmbus_prep_negotiate_resp(struct icmsg_hdr *icmsghdrp, u8 *buf, u32 buflen,
const int *fw_version, int fw_vercnt,
const int *srv_version, int srv_vercnt,
int *nego_fw_version, int *nego_srv_version);
void hv_process_channel_removal(struct vmbus_channel *channel);
void vmbus_setevent(struct vmbus_channel *channel);
extern __u32 vmbus_proto_version;
int vmbus_send_tl_connect_request(const guid_t *shv_guest_servie_id,
const guid_t *shv_host_servie_id);
int vmbus_send_modifychannel(struct vmbus_channel *channel, u32 target_vp);
void vmbus_set_event(struct vmbus_channel *channel);
static inline void *
hv_get_ring_buffer(const struct hv_ring_buffer_info *ring_info)
{ … }
static inline void hv_begin_read(struct hv_ring_buffer_info *rbi)
{ … }
static inline u32 hv_end_read(struct hv_ring_buffer_info *rbi)
{ … }
static inline void *hv_pkt_data(const struct vmpacket_descriptor *desc)
{ … }
static inline u32 hv_pkt_datalen(const struct vmpacket_descriptor *desc)
{ … }
static inline u32 hv_pkt_len(const struct vmpacket_descriptor *desc)
{ … }
struct vmpacket_descriptor *
hv_pkt_iter_first(struct vmbus_channel *channel);
struct vmpacket_descriptor *
__hv_pkt_iter_next(struct vmbus_channel *channel,
const struct vmpacket_descriptor *pkt);
void hv_pkt_iter_close(struct vmbus_channel *channel);
static inline struct vmpacket_descriptor *
hv_pkt_iter_next(struct vmbus_channel *channel,
const struct vmpacket_descriptor *pkt)
{ … }
#define foreach_vmbus_pkt(pkt, channel) …
#define HV_CONFIG_BLOCK_SIZE_MAX …
int hyperv_read_cfg_blk(struct pci_dev *dev, void *buf, unsigned int buf_len,
unsigned int block_id, unsigned int *bytes_returned);
int hyperv_write_cfg_blk(struct pci_dev *dev, void *buf, unsigned int len,
unsigned int block_id);
int hyperv_reg_block_invalidate(struct pci_dev *dev, void *context,
void (*block_invalidate)(void *context,
u64 block_mask));
struct hyperv_pci_block_ops { … };
extern struct hyperv_pci_block_ops hvpci_block_ops;
static inline unsigned long virt_to_hvpfn(void *addr)
{ … }
#define NR_HV_HYP_PAGES_IN_PAGE …
#define offset_in_hvpage(ptr) …
#define HVPFN_UP(x) …
#define HVPFN_DOWN(x) …
#define page_to_hvpfn(page) …
#endif