Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
Show All 30 Lines | |||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <dev/hyperv/vmbus/hv_vmbus_priv.h> | #include <dev/hyperv/vmbus/hv_vmbus_priv.h> | ||||
#include <dev/hyperv/vmbus/vmbus_reg.h> | #include <dev/hyperv/vmbus/vmbus_reg.h> | ||||
#include <dev/hyperv/vmbus/vmbus_var.h> | #include <dev/hyperv/vmbus/vmbus_var.h> | ||||
/* | typedef void (*vmbus_chanmsg_proc_t) | ||||
* Internal functions | (struct vmbus_softc *, const struct vmbus_message *); | ||||
*/ | |||||
typedef struct hv_vmbus_channel_msg_table_entry { | |||||
hv_vmbus_channel_msg_type messageType; | |||||
void (*messageHandler) | |||||
(struct vmbus_softc *sc, | |||||
const struct vmbus_message *msg); | |||||
} hv_vmbus_channel_msg_table_entry; | |||||
static void vmbus_channel_on_offer_internal(void *context); | static void vmbus_channel_on_offer_internal(void *context); | ||||
static void vmbus_channel_on_offer_rescind_internal(void *context); | static void vmbus_channel_on_offer_rescind_internal(void *context); | ||||
static void vmbus_channel_on_offer(struct vmbus_softc *, | static void vmbus_channel_on_offer(struct vmbus_softc *, | ||||
const struct vmbus_message *); | const struct vmbus_message *); | ||||
static void vmbus_channel_on_open_result(struct vmbus_softc *, | static void vmbus_channel_on_open_result(struct vmbus_softc *, | ||||
const struct vmbus_message *); | const struct vmbus_message *); | ||||
static void vmbus_channel_on_offer_rescind(struct vmbus_softc *, | static void vmbus_channel_on_offer_rescind(struct vmbus_softc *, | ||||
const struct vmbus_message *); | const struct vmbus_message *); | ||||
static void vmbus_channel_on_gpadl_created(struct vmbus_softc *, | static void vmbus_channel_on_gpadl_created(struct vmbus_softc *, | ||||
const struct vmbus_message *); | const struct vmbus_message *); | ||||
static void vmbus_channel_on_gpadl_torndown(struct vmbus_softc *, | static void vmbus_channel_on_gpadl_torndown(struct vmbus_softc *, | ||||
const struct vmbus_message *); | const struct vmbus_message *); | ||||
static void vmbus_channel_on_offers_delivered(struct vmbus_softc *, | static void vmbus_channel_on_offers_delivered(struct vmbus_softc *, | ||||
const struct vmbus_message *); | const struct vmbus_message *); | ||||
static void vmbus_channel_on_version_response(struct vmbus_softc *, | static void vmbus_channel_on_version_response(struct vmbus_softc *, | ||||
const struct vmbus_message *); | const struct vmbus_message *); | ||||
/** | /** | ||||
* Channel message dispatch table | * Channel message dispatch table | ||||
*/ | */ | ||||
static const hv_vmbus_channel_msg_table_entry | static const vmbus_chanmsg_proc_t | ||||
g_channel_message_table[HV_CHANNEL_MESSAGE_COUNT] = { | vmbus_chanmsg_process[HV_CHANNEL_MESSAGE_COUNT] = { | ||||
{ HV_CHANNEL_MESSAGE_INVALID, | [HV_CHANNEL_MESSAGE_OFFER_CHANNEL] = | ||||
NULL }, | vmbus_channel_on_offer, | ||||
{ HV_CHANNEL_MESSAGE_OFFER_CHANNEL, | [HV_CHANNEL_MESSAGE_RESCIND_CHANNEL_OFFER] = | ||||
vmbus_channel_on_offer }, | vmbus_channel_on_offer_rescind, | ||||
{ HV_CHANNEL_MESSAGE_RESCIND_CHANNEL_OFFER, | [HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED] = | ||||
vmbus_channel_on_offer_rescind }, | vmbus_channel_on_offers_delivered, | ||||
{ HV_CHANNEL_MESSAGE_REQUEST_OFFERS, | [HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT] = | ||||
NULL }, | vmbus_channel_on_open_result, | ||||
{ HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED, | [HV_CHANNEL_MESSAGE_GPADL_CREATED] = | ||||
vmbus_channel_on_offers_delivered }, | vmbus_channel_on_gpadl_created, | ||||
{ HV_CHANNEL_MESSAGE_OPEN_CHANNEL, | [HV_CHANNEL_MESSAGE_GPADL_TORNDOWN] = | ||||
NULL }, | vmbus_channel_on_gpadl_torndown, | ||||
{ HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT, | [HV_CHANNEL_MESSAGE_VERSION_RESPONSE] = | ||||
vmbus_channel_on_open_result }, | vmbus_channel_on_version_response | ||||
{ HV_CHANNEL_MESSAGE_CLOSE_CHANNEL, | |||||
NULL }, | |||||
{ HV_CHANNEL_MESSAGEL_GPADL_HEADER, | |||||
NULL }, | |||||
{ HV_CHANNEL_MESSAGE_GPADL_BODY, | |||||
NULL }, | |||||
{ HV_CHANNEL_MESSAGE_GPADL_CREATED, | |||||
vmbus_channel_on_gpadl_created }, | |||||
{ HV_CHANNEL_MESSAGE_GPADL_TEARDOWN, | |||||
NULL }, | |||||
{ HV_CHANNEL_MESSAGE_GPADL_TORNDOWN, | |||||
vmbus_channel_on_gpadl_torndown }, | |||||
{ HV_CHANNEL_MESSAGE_REL_ID_RELEASED, | |||||
NULL }, | |||||
{ HV_CHANNEL_MESSAGE_INITIATED_CONTACT, | |||||
NULL }, | |||||
{ HV_CHANNEL_MESSAGE_VERSION_RESPONSE, | |||||
vmbus_channel_on_version_response }, | |||||
{ HV_CHANNEL_MESSAGE_UNLOAD, | |||||
NULL } | |||||
}; | }; | ||||
typedef struct hv_work_item { | typedef struct hv_work_item { | ||||
struct task work; | struct task work; | ||||
void (*callback)(void *); | void (*callback)(void *); | ||||
void* context; | void* context; | ||||
} hv_work_item; | } hv_work_item; | ||||
▲ Show 20 Lines • Show All 692 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
free(subchan, M_TEMP); | free(subchan, M_TEMP); | ||||
} | } | ||||
void | void | ||||
vmbus_chan_msgproc(struct vmbus_softc *sc, const struct vmbus_message *msg) | vmbus_chan_msgproc(struct vmbus_softc *sc, const struct vmbus_message *msg) | ||||
{ | { | ||||
const hv_vmbus_channel_msg_table_entry *entry; | vmbus_chanmsg_proc_t msg_proc; | ||||
const hv_vmbus_channel_msg_header *hdr; | uint32_t msg_type; | ||||
hv_vmbus_channel_msg_type msg_type; | |||||
hdr = (const hv_vmbus_channel_msg_header *)msg->msg_data; | msg_type = ((const struct vmbus_chanmsg_hdr *)msg->msg_data)->chm_type; | ||||
msg_type = hdr->message_type; | |||||
if (msg_type >= HV_CHANNEL_MESSAGE_COUNT) { | if (msg_type >= HV_CHANNEL_MESSAGE_COUNT) { | ||||
device_printf(sc->vmbus_dev, "unknown message type 0x%x\n", | device_printf(sc->vmbus_dev, "unknown message type 0x%x\n", | ||||
msg_type); | msg_type); | ||||
return; | return; | ||||
} | } | ||||
entry = &g_channel_message_table[msg_type]; | msg_proc = vmbus_chanmsg_process[msg_type]; | ||||
if (entry->messageHandler) | if (msg_proc != NULL) | ||||
entry->messageHandler(sc, msg); | msg_proc(sc, msg); | ||||
} | } |