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
This commit is contained in:
parent
4594925d80
commit
12ea25ae4f
@ -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_response(hv_vmbus_channel_msg_header* hdr);
|
||||
/**
|
||||
* 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_channel **subchan, int subchan_cnt __unused)
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -81,32 +81,14 @@ vmbus_msg_task(void *xsc, int pending __unused)
|
||||
|
||||
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;
|
||||
} else if (msg->msg_type == VMBUS_MSGTYPE_CHANNEL) {
|
||||
/* Channel message */
|
||||
vmbus_chan_msgproc(sc, msg);
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -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_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user