Author: sephe Date: Mon Jun 6 07:27:57 2016 New Revision: 301487 URL: https://svnweb.freebsd.org/changeset/base/301487
Log: hyperv/vmbus: Factor out channel message processing This paves the way for further cleanup. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6707 Modified: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h head/sys/dev/hyperv/vmbus/vmbus.c head/sys/dev/hyperv/vmbus/vmbus_var.h Modified: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Mon Jun 6 07:10:38 2016 (r301486) +++ head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Mon Jun 6 07:27:57 2016 (r301487) @@ -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 @@ static void vmbus_channel_on_version_res /** * 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 @@ vmbus_rel_subchan(struct hv_vmbus_channe 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); +} Modified: head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Jun 6 07:10:38 2016 (r301486) +++ head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Jun 6 07:27:57 2016 (r301487) @@ -364,16 +364,6 @@ typedef enum { 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 */ Modified: head/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus.c Mon Jun 6 07:10:38 2016 (r301486) +++ head/sys/dev/hyperv/vmbus/vmbus.c Mon Jun 6 07:27:57 2016 (r301487) @@ -81,32 +81,14 @@ vmbus_msg_task(void *xsc, int pending __ 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 Modified: head/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus_var.h Mon Jun 6 07:10:38 2016 (r301486) +++ head/sys/dev/hyperv/vmbus/vmbus_var.h Mon Jun 6 07:27:57 2016 (r301487) @@ -93,6 +93,7 @@ vmbus_get_device(void) 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_handle_intr(struct trapframe void vmbus_et_intr(struct trapframe *); +void vmbus_chan_msgproc(struct vmbus_softc *, + volatile struct vmbus_message *); + #endif /* !_VMBUS_VAR_H_ */ _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"