Index: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c =================================================================== --- head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c +++ head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c @@ -40,6 +40,14 @@ * Internal functions */ +typedef void (*vmbus_msg_handler)(hv_vmbus_channel_msg_header *msg); + +typedef struct hv_vmbus_channel_msg_table_entry { + hv_vmbus_channel_msg_type messageType; + + vmbus_msg_handler messageHandler; +} hv_vmbus_channel_msg_table_entry; + static void vmbus_channel_on_offer(hv_vmbus_channel_msg_header* hdr); static void vmbus_channel_on_offer_internal(void* context); static void vmbus_channel_on_open_result(hv_vmbus_channel_msg_header* hdr); @@ -53,7 +61,7 @@ /** * Channel message dispatch table */ -hv_vmbus_channel_msg_table_entry +static const hv_vmbus_channel_msg_table_entry g_channel_message_table[HV_CHANNEL_MESSAGE_COUNT] = { { HV_CHANNEL_MESSAGE_INVALID, NULL }, @@ -831,3 +839,25 @@ free(subchan, M_TEMP); } + +void +vmbus_chan_msgproc(struct vmbus_softc *sc, volatile struct vmbus_message *msg) +{ + const hv_vmbus_channel_msg_table_entry *entry; + hv_vmbus_channel_msg_header *hdr; + hv_vmbus_channel_msg_type msg_type; + + /* XXX: update messageHandler interface */ + hdr = __DEVOLATILE(hv_vmbus_channel_msg_header *, msg->msg_data); + msg_type = hdr->message_type; + + if (msg_type >= HV_CHANNEL_MESSAGE_COUNT) { + device_printf(sc->vmbus_dev, "unknown message type 0x%x\n", + msg_type); + return; + } + + entry = &g_channel_message_table[msg_type]; + if (entry->messageHandler) + entry->messageHandler(hdr); +} Index: head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h =================================================================== --- head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h +++ head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h @@ -364,16 +364,6 @@ extern hv_vmbus_connection hv_vmbus_g_connection; -typedef void (*vmbus_msg_handler)(hv_vmbus_channel_msg_header *msg); - -typedef struct hv_vmbus_channel_msg_table_entry { - hv_vmbus_channel_msg_type messageType; - - vmbus_msg_handler messageHandler; -} hv_vmbus_channel_msg_table_entry; - -extern hv_vmbus_channel_msg_table_entry g_channel_message_table[]; - /* * Private, VM Bus functions */ Index: head/sys/dev/hyperv/vmbus/vmbus.c =================================================================== --- head/sys/dev/hyperv/vmbus/vmbus.c +++ head/sys/dev/hyperv/vmbus/vmbus.c @@ -81,32 +81,14 @@ msg = VMBUS_PCPU_GET(sc, message, curcpu) + VMBUS_SINT_MESSAGE; for (;;) { - const hv_vmbus_channel_msg_table_entry *entry; - hv_vmbus_channel_msg_header *hdr; - hv_vmbus_channel_msg_type msg_type; - if (msg->msg_type == VMBUS_MSGTYPE_NONE) { /* No message */ break; - } else if (msg->msg_type != VMBUS_MSGTYPE_CHANNEL) { - /* Not a channel message */ - goto handled; - } - - /* XXX: update messageHandler interface */ - hdr = __DEVOLATILE(hv_vmbus_channel_msg_header *, - msg->msg_data); - msg_type = hdr->message_type; - - if (msg_type >= HV_CHANNEL_MESSAGE_COUNT) { - printf("VMBUS: unknown message type = %d\n", msg_type); - goto handled; + } else if (msg->msg_type == VMBUS_MSGTYPE_CHANNEL) { + /* Channel message */ + vmbus_chan_msgproc(sc, msg); } - entry = &g_channel_message_table[msg_type]; - if (entry->messageHandler) - entry->messageHandler(hdr); -handled: msg->msg_type = VMBUS_MSGTYPE_NONE; /* * Make sure the write to msg_type (i.e. set to Index: head/sys/dev/hyperv/vmbus/vmbus_var.h =================================================================== --- head/sys/dev/hyperv/vmbus/vmbus_var.h +++ head/sys/dev/hyperv/vmbus/vmbus_var.h @@ -93,6 +93,7 @@ struct hv_vmbus_channel; struct trapframe; +struct vmbus_message; void vmbus_on_channel_open(const struct hv_vmbus_channel *); void vmbus_event_proc(struct vmbus_softc *, int); @@ -101,4 +102,7 @@ void vmbus_et_intr(struct trapframe *); +void vmbus_chan_msgproc(struct vmbus_softc *, + volatile struct vmbus_message *); + #endif /* !_VMBUS_VAR_H_ */