Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hyperv/include/hyperv.h
Show First 20 Lines • Show All 393 Lines • ▼ Show 20 Lines | |||||
typedef struct { | typedef struct { | ||||
hv_vmbus_channel_msg_header header; | hv_vmbus_channel_msg_header header; | ||||
uint32_t child_rel_id; | uint32_t child_rel_id; | ||||
} __packed hv_vmbus_channel_relid_released; | } __packed hv_vmbus_channel_relid_released; | ||||
#define HW_MACADDR_LEN 6 | #define HW_MACADDR_LEN 6 | ||||
enum { | |||||
HV_VMBUS_IVAR_TYPE, | |||||
HV_VMBUS_IVAR_INSTANCE, | |||||
HV_VMBUS_IVAR_NODE, | |||||
HV_VMBUS_IVAR_DEVCTX, | |||||
HV_VMBUS_IVAR_CHAN, | |||||
}; | |||||
#define HV_VMBUS_ACCESSOR(var, ivar, type) \ | |||||
__BUS_ACCESSOR(vmbus, var, HV_VMBUS, ivar, type) | |||||
struct hv_vmbus_channel; | |||||
HV_VMBUS_ACCESSOR(type, TYPE, const char *) | |||||
HV_VMBUS_ACCESSOR(devctx, DEVCTX, struct hv_device *) | |||||
HV_VMBUS_ACCESSOR(channel, CHAN, struct hv_vmbus_channel *) | |||||
/* | /* | ||||
* Common defines for Hyper-V ICs | * Common defines for Hyper-V ICs | ||||
*/ | */ | ||||
#define HV_ICMSGTYPE_NEGOTIATE 0 | #define HV_ICMSGTYPE_NEGOTIATE 0 | ||||
#define HV_ICMSGTYPE_HEARTBEAT 1 | #define HV_ICMSGTYPE_HEARTBEAT 1 | ||||
#define HV_ICMSGTYPE_KVPEXCHANGE 2 | #define HV_ICMSGTYPE_KVPEXCHANGE 2 | ||||
#define HV_ICMSGTYPE_SHUTDOWN 3 | #define HV_ICMSGTYPE_SHUTDOWN 3 | ||||
#define HV_ICMSGTYPE_TIMESYNC 4 | #define HV_ICMSGTYPE_TIMESYNC 4 | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | typedef union { | ||||
struct { | struct { | ||||
uint32_t id:24; | uint32_t id:24; | ||||
uint32_t reserved:8; | uint32_t reserved:8; | ||||
} u; | } u; | ||||
} __packed hv_vmbus_connection_id; | } __packed hv_vmbus_connection_id; | ||||
typedef struct hv_vmbus_channel { | typedef struct hv_vmbus_channel { | ||||
struct hv_device* device; | |||||
device_t ch_dev; | device_t ch_dev; | ||||
struct vmbus_softc *vmbus_sc; | struct vmbus_softc *vmbus_sc; | ||||
hv_vmbus_channel_state state; | hv_vmbus_channel_state state; | ||||
uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */ | uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */ | ||||
uint32_t ch_id; /* channel id */ | uint32_t ch_id; /* channel id */ | ||||
/* | /* | ||||
* These are based on the offer_msg.monitor_id. | * These are based on the offer_msg.monitor_id. | ||||
* Save it here for easy access. | * Save it here for easy access. | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | |||||
#define VMBUS_CHAN_FLAG_HASMNF 0x0001 | #define VMBUS_CHAN_FLAG_HASMNF 0x0001 | ||||
static inline void | static inline void | ||||
hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t state) | hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t state) | ||||
{ | { | ||||
channel->batched_reading = state; | channel->batched_reading = state; | ||||
} | } | ||||
typedef struct hv_device { | |||||
hv_guid class_id; | |||||
hv_guid device_id; | |||||
device_t device; | |||||
hv_vmbus_channel* channel; | |||||
} hv_device; | |||||
int hv_vmbus_channel_recv_packet( | int hv_vmbus_channel_recv_packet( | ||||
hv_vmbus_channel* channel, | hv_vmbus_channel* channel, | ||||
void* buffer, | void* buffer, | ||||
uint32_t buffer_len, | uint32_t buffer_len, | ||||
uint32_t* buffer_actual_len, | uint32_t* buffer_actual_len, | ||||
uint64_t* request_id); | uint64_t* request_id); | ||||
int hv_vmbus_channel_recv_packet_raw( | int hv_vmbus_channel_recv_packet_raw( | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
* @brief Get physical address from virtual | * @brief Get physical address from virtual | ||||
*/ | */ | ||||
static inline unsigned long | static inline unsigned long | ||||
hv_get_phys_addr(void *virt) | hv_get_phys_addr(void *virt) | ||||
{ | { | ||||
unsigned long ret; | unsigned long ret; | ||||
ret = (vtophys(virt) | ((vm_offset_t) virt & PAGE_MASK)); | ret = (vtophys(virt) | ((vm_offset_t) virt & PAGE_MASK)); | ||||
return (ret); | return (ret); | ||||
} | |||||
static __inline struct hv_vmbus_channel * | |||||
vmbus_get_channel(device_t dev) | |||||
{ | |||||
return device_get_ivars(dev); | |||||
} | } | ||||
#endif /* __HYPERV_H__ */ | #endif /* __HYPERV_H__ */ |