Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/hyperv/vmbus/hv_vmbus_priv.h
Show First 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | enum { | ||||
HV_VMBUS_MONITOR_PORT_ID = 3, | HV_VMBUS_MONITOR_PORT_ID = 3, | ||||
HV_VMBUS_MESSAGE_SINT = 2 | HV_VMBUS_MESSAGE_SINT = 2 | ||||
}; | }; | ||||
#define HV_PRESENT_BIT 0x80000000 | #define HV_PRESENT_BIT 0x80000000 | ||||
#define HV_HYPERCALL_PARAM_ALIGN sizeof(uint64_t) | #define HV_HYPERCALL_PARAM_ALIGN sizeof(uint64_t) | ||||
/* | |||||
* Connection identifier type | |||||
*/ | |||||
typedef union { | |||||
uint32_t as_uint32_t; | |||||
struct { | |||||
uint32_t id:24; | |||||
uint32_t reserved:8; | |||||
} u; | |||||
} __packed hv_vmbus_connection_id; | |||||
/* | |||||
* Definition of the hv_vmbus_signal_event hypercall input structure | |||||
*/ | |||||
typedef struct { | typedef struct { | ||||
hv_vmbus_connection_id connection_id; | |||||
uint16_t flag_number; | |||||
uint16_t rsvd_z; | |||||
} __packed hv_vmbus_input_signal_event; | |||||
typedef struct { | |||||
uint64_t align8; | |||||
hv_vmbus_input_signal_event event; | |||||
} __packed hv_vmbus_input_signal_event_buffer; | |||||
typedef struct { | |||||
uint64_t guest_id; | uint64_t guest_id; | ||||
void* hypercall_page; | void* hypercall_page; | ||||
hv_bool_uint8_t syn_ic_initialized; | hv_bool_uint8_t syn_ic_initialized; | ||||
hv_vmbus_handle syn_ic_msg_page[MAXCPU]; | |||||
hv_vmbus_handle syn_ic_event_page[MAXCPU]; | |||||
/* | /* | ||||
* This is used as an input param to HV_CALL_SIGNAL_EVENT hypercall. | * For FreeBSD cpuid to Hyper-V vcpuid mapping. | ||||
* The input param is immutable in our usage and | |||||
* must be dynamic mem (vs stack or global). | |||||
*/ | */ | ||||
hv_vmbus_input_signal_event_buffer *signal_event_buffer; | uint32_t hv_vcpu_index[MAXCPU]; | ||||
/* | /* | ||||
* 8-bytes aligned of the buffer above | * Each cpu has its own software interrupt handler for channel | ||||
* event and msg handling. | |||||
*/ | */ | ||||
hv_vmbus_input_signal_event *signal_event_param; | struct intr_event *hv_event_intr_event[MAXCPU]; | ||||
struct intr_event *hv_msg_intr_event[MAXCPU]; | |||||
hv_vmbus_handle syn_ic_msg_page[MAXCPU]; | void *event_swintr[MAXCPU]; | ||||
hv_vmbus_handle syn_ic_event_page[MAXCPU]; | void *msg_swintr[MAXCPU]; | ||||
/* | |||||
* Host use this vector to intrrupt guest for vmbus channel | |||||
* event and msg. | |||||
*/ | |||||
unsigned int hv_cb_vector; | |||||
} hv_vmbus_context; | } hv_vmbus_context; | ||||
/* | /* | ||||
* Define hypervisor message types | * Define hypervisor message types | ||||
*/ | */ | ||||
typedef enum { | typedef enum { | ||||
HV_MESSAGE_TYPE_NONE = 0x00000000, | HV_MESSAGE_TYPE_NONE = 0x00000000, | ||||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | typedef struct { | ||||
* 2 pages - 1st page for parent->child | * 2 pages - 1st page for parent->child | ||||
* notification and 2nd is child->parent | * notification and 2nd is child->parent | ||||
* notification | * notification | ||||
*/ | */ | ||||
void *monitor_pages; | void *monitor_pages; | ||||
TAILQ_HEAD(, hv_vmbus_channel_msg_info) channel_msg_anchor; | TAILQ_HEAD(, hv_vmbus_channel_msg_info) channel_msg_anchor; | ||||
struct mtx channel_msg_lock; | struct mtx channel_msg_lock; | ||||
/** | /** | ||||
* List of channels | * List of primary channels. Sub channels will be linked | ||||
* under their primary channel. | |||||
*/ | */ | ||||
TAILQ_HEAD(, hv_vmbus_channel) channel_anchor; | TAILQ_HEAD(, hv_vmbus_channel) channel_anchor; | ||||
struct mtx channel_lock; | struct mtx channel_lock; | ||||
hv_vmbus_handle work_queue; | hv_vmbus_handle work_queue; | ||||
struct sema control_sema; | struct sema control_sema; | ||||
} hv_vmbus_connection; | } hv_vmbus_connection; | ||||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Define the synthetic interrupt controller event flags format | * Define the synthetic interrupt controller event flags format | ||||
*/ | */ | ||||
typedef union { | typedef union { | ||||
uint8_t flags8[HV_EVENT_FLAGS_BYTE_COUNT]; | uint8_t flags8[HV_EVENT_FLAGS_BYTE_COUNT]; | ||||
uint32_t flags32[HV_EVENT_FLAGS_DWORD_COUNT]; | uint32_t flags32[HV_EVENT_FLAGS_DWORD_COUNT]; | ||||
} hv_vmbus_synic_event_flags; | } hv_vmbus_synic_event_flags; | ||||
/* MSR used to provide vcpu index */ | |||||
#define HV_X64_MSR_VP_INDEX (0x40000002) | |||||
/* | /* | ||||
* Define synthetic interrupt controller model specific registers | * Define synthetic interrupt controller model specific registers | ||||
*/ | */ | ||||
#define HV_X64_MSR_SCONTROL (0x40000080) | #define HV_X64_MSR_SCONTROL (0x40000080) | ||||
#define HV_X64_MSR_SVERSION (0x40000081) | #define HV_X64_MSR_SVERSION (0x40000081) | ||||
#define HV_X64_MSR_SIEFP (0x40000082) | #define HV_X64_MSR_SIEFP (0x40000082) | ||||
#define HV_X64_MSR_SIMP (0x40000083) | #define HV_X64_MSR_SIMP (0x40000083) | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | int hv_vmbus_ring_buffer_init( | ||||
uint32_t buffer_len); | uint32_t buffer_len); | ||||
void hv_ring_buffer_cleanup( | void hv_ring_buffer_cleanup( | ||||
hv_vmbus_ring_buffer_info *ring_info); | hv_vmbus_ring_buffer_info *ring_info); | ||||
int hv_ring_buffer_write( | int hv_ring_buffer_write( | ||||
hv_vmbus_ring_buffer_info *ring_info, | hv_vmbus_ring_buffer_info *ring_info, | ||||
hv_vmbus_sg_buffer_list sg_buffers[], | hv_vmbus_sg_buffer_list sg_buffers[], | ||||
uint32_t sg_buff_count); | uint32_t sg_buff_count, | ||||
boolean_t *need_sig); | |||||
int hv_ring_buffer_peek( | int hv_ring_buffer_peek( | ||||
hv_vmbus_ring_buffer_info *ring_info, | hv_vmbus_ring_buffer_info *ring_info, | ||||
void *buffer, | void *buffer, | ||||
uint32_t buffer_len); | uint32_t buffer_len); | ||||
int hv_ring_buffer_read( | int hv_ring_buffer_read( | ||||
hv_vmbus_ring_buffer_info *ring_info, | hv_vmbus_ring_buffer_info *ring_info, | ||||
void *buffer, | void *buffer, | ||||
uint32_t buffer_len, | uint32_t buffer_len, | ||||
uint32_t offset); | uint32_t offset); | ||||
uint32_t hv_vmbus_get_ring_buffer_interrupt_mask( | uint32_t hv_vmbus_get_ring_buffer_interrupt_mask( | ||||
hv_vmbus_ring_buffer_info *ring_info); | hv_vmbus_ring_buffer_info *ring_info); | ||||
void hv_vmbus_dump_ring_info( | void hv_vmbus_dump_ring_info( | ||||
hv_vmbus_ring_buffer_info *ring_info, | hv_vmbus_ring_buffer_info *ring_info, | ||||
char *prefix); | char *prefix); | ||||
void hv_ring_buffer_read_begin( | |||||
hv_vmbus_ring_buffer_info *ring_info); | |||||
uint32_t hv_ring_buffer_read_end( | |||||
hv_vmbus_ring_buffer_info *ring_info); | |||||
hv_vmbus_channel* hv_vmbus_allocate_channel(void); | hv_vmbus_channel* hv_vmbus_allocate_channel(void); | ||||
void hv_vmbus_free_vmbus_channel(hv_vmbus_channel *channel); | void hv_vmbus_free_vmbus_channel(hv_vmbus_channel *channel); | ||||
void hv_vmbus_on_channel_message(void *context); | void hv_vmbus_on_channel_message(void *context); | ||||
int hv_vmbus_request_channel_offers(void); | int hv_vmbus_request_channel_offers(void); | ||||
void hv_vmbus_release_unattached_channels(void); | void hv_vmbus_release_unattached_channels(void); | ||||
int hv_vmbus_init(void); | int hv_vmbus_init(void); | ||||
void hv_vmbus_cleanup(void); | void hv_vmbus_cleanup(void); | ||||
uint16_t hv_vmbus_post_msg_via_msg_ipc( | uint16_t hv_vmbus_post_msg_via_msg_ipc( | ||||
hv_vmbus_connection_id connection_id, | hv_vmbus_connection_id connection_id, | ||||
hv_vmbus_msg_type message_type, | hv_vmbus_msg_type message_type, | ||||
void *payload, | void *payload, | ||||
size_t payload_size); | size_t payload_size); | ||||
uint16_t hv_vmbus_signal_event(void); | uint16_t hv_vmbus_signal_event(void *con_id); | ||||
void hv_vmbus_synic_init(void *irq_arg); | void hv_vmbus_synic_init(void *irq_arg); | ||||
void hv_vmbus_synic_cleanup(void *arg); | void hv_vmbus_synic_cleanup(void *arg); | ||||
int hv_vmbus_query_hypervisor_presence(void); | int hv_vmbus_query_hypervisor_presence(void); | ||||
struct hv_device* hv_vmbus_child_device_create( | struct hv_device* hv_vmbus_child_device_create( | ||||
hv_guid device_type, | hv_guid device_type, | ||||
hv_guid device_instance, | hv_guid device_instance, | ||||
hv_vmbus_channel *channel); | hv_vmbus_channel *channel); | ||||
int hv_vmbus_child_device_register( | int hv_vmbus_child_device_register( | ||||
struct hv_device *child_dev); | struct hv_device *child_dev); | ||||
int hv_vmbus_child_device_unregister( | int hv_vmbus_child_device_unregister( | ||||
struct hv_device *child_dev); | struct hv_device *child_dev); | ||||
hv_vmbus_channel* hv_vmbus_get_channel_from_rel_id(uint32_t rel_id); | hv_vmbus_channel* hv_vmbus_get_channel_from_rel_id(uint32_t rel_id); | ||||
/** | /** | ||||
* Connection interfaces | * Connection interfaces | ||||
*/ | */ | ||||
int hv_vmbus_connect(void); | int hv_vmbus_connect(void); | ||||
int hv_vmbus_disconnect(void); | int hv_vmbus_disconnect(void); | ||||
int hv_vmbus_post_message(void *buffer, size_t buf_size); | int hv_vmbus_post_message(void *buffer, size_t buf_size); | ||||
int hv_vmbus_set_event(uint32_t child_rel_id); | int hv_vmbus_set_event(hv_vmbus_channel *channel); | ||||
void hv_vmbus_on_events(void *); | void hv_vmbus_on_events(void *); | ||||
/* | /* | ||||
* The guest OS needs to register the guest ID with the hypervisor. | * The guest OS needs to register the guest ID with the hypervisor. | ||||
* The guest ID is a 64 bit entity and the structure of this ID is | * The guest ID is a 64 bit entity and the structure of this ID is | ||||
* specified in the Hyper-V specification: | * specified in the Hyper-V specification: | ||||
* | * | ||||
Show All 27 Lines | static inline uint64_t hv_generate_guest_id( | ||||
guest_id |= (((uint64_t)(distro_id_part1)) << 48); | guest_id |= (((uint64_t)(distro_id_part1)) << 48); | ||||
guest_id |= (((uint64_t)(__FreeBSD_version)) << 16); /* in param.h */ | guest_id |= (((uint64_t)(__FreeBSD_version)) << 16); /* in param.h */ | ||||
guest_id |= ((uint64_t)(distro_id_part2)); | guest_id |= ((uint64_t)(distro_id_part2)); | ||||
return guest_id; | return guest_id; | ||||
} | } | ||||
typedef struct { | typedef struct { | ||||
unsigned int vector; | unsigned int vector; | ||||
void *page_buffers[2]; | void *page_buffers[2 * MAXCPU]; | ||||
} hv_setup_args; | } hv_setup_args; | ||||
#endif /* __HYPERV_PRIV_H__ */ | #endif /* __HYPERV_PRIV_H__ */ |