Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107369808
D4596.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D4596.diff
View Options
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
@@ -31,13 +31,6 @@
#include "hv_vmbus_priv.h"
-typedef void (*hv_pfn_channel_msg_handler)(hv_vmbus_channel_msg_header* msg);
-
-typedef struct hv_vmbus_channel_msg_table_entry {
- hv_vmbus_channel_msg_type messageType;
- hv_pfn_channel_msg_handler messageHandler;
-} hv_vmbus_channel_msg_table_entry;
-
/*
* Internal functions
*/
@@ -55,29 +48,40 @@
*/
hv_vmbus_channel_msg_table_entry
g_channel_message_table[HV_CHANNEL_MESSAGE_COUNT] = {
- { HV_CHANNEL_MESSAGE_INVALID, NULL },
- { HV_CHANNEL_MESSAGE_OFFER_CHANNEL, vmbus_channel_on_offer },
+ { HV_CHANNEL_MESSAGE_INVALID,
+ 0, NULL },
+ { HV_CHANNEL_MESSAGE_OFFER_CHANNEL,
+ 0, vmbus_channel_on_offer },
{ HV_CHANNEL_MESSAGE_RESCIND_CHANNEL_OFFER,
- vmbus_channel_on_offer_rescind },
- { HV_CHANNEL_MESSAGE_REQUEST_OFFERS, NULL },
+ 0, vmbus_channel_on_offer_rescind },
+ { HV_CHANNEL_MESSAGE_REQUEST_OFFERS,
+ 0, NULL },
{ HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED,
- vmbus_channel_on_offers_delivered },
- { HV_CHANNEL_MESSAGE_OPEN_CHANNEL, NULL },
+ 1, vmbus_channel_on_offers_delivered },
+ { HV_CHANNEL_MESSAGE_OPEN_CHANNEL,
+ 0, NULL },
{ HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT,
- vmbus_channel_on_open_result },
- { HV_CHANNEL_MESSAGE_CLOSE_CHANNEL, NULL },
- { HV_CHANNEL_MESSAGEL_GPADL_HEADER, NULL },
- { HV_CHANNEL_MESSAGE_GPADL_BODY, NULL },
+ 1, vmbus_channel_on_open_result },
+ { HV_CHANNEL_MESSAGE_CLOSE_CHANNEL,
+ 0, NULL },
+ { HV_CHANNEL_MESSAGEL_GPADL_HEADER,
+ 0, NULL },
+ { HV_CHANNEL_MESSAGE_GPADL_BODY,
+ 0, NULL },
{ HV_CHANNEL_MESSAGE_GPADL_CREATED,
- vmbus_channel_on_gpadl_created },
- { HV_CHANNEL_MESSAGE_GPADL_TEARDOWN, NULL },
+ 1, vmbus_channel_on_gpadl_created },
+ { HV_CHANNEL_MESSAGE_GPADL_TEARDOWN,
+ 0, NULL },
{ HV_CHANNEL_MESSAGE_GPADL_TORNDOWN,
- vmbus_channel_on_gpadl_torndown },
- { HV_CHANNEL_MESSAGE_REL_ID_RELEASED, NULL },
- { HV_CHANNEL_MESSAGE_INITIATED_CONTACT, NULL },
+ 1, vmbus_channel_on_gpadl_torndown },
+ { HV_CHANNEL_MESSAGE_REL_ID_RELEASED,
+ 0, NULL },
+ { HV_CHANNEL_MESSAGE_INITIATED_CONTACT,
+ 0, NULL },
{ HV_CHANNEL_MESSAGE_VERSION_RESPONSE,
- vmbus_channel_on_version_response },
- { HV_CHANNEL_MESSAGE_UNLOAD, NULL }
+ 1, vmbus_channel_on_version_response },
+ { HV_CHANNEL_MESSAGE_UNLOAD,
+ 0, NULL }
};
Index: head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
===================================================================
--- head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
+++ head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
@@ -76,8 +76,12 @@
{
int cpu;
void* page_addr;
+ hv_vmbus_channel_msg_header *hdr;
+ hv_vmbus_channel_msg_table_entry *entry;
+ hv_vmbus_channel_msg_type msg_type;
hv_vmbus_message* msg;
hv_vmbus_message* copied;
+ static bool warned = false;
cpu = (int)(long)arg;
KASSERT(cpu <= mp_maxid, ("VMBUS: vmbus_msg_swintr: "
@@ -87,9 +91,24 @@
msg = (hv_vmbus_message*) page_addr + HV_VMBUS_MESSAGE_SINT;
for (;;) {
- if (msg->header.message_type == HV_MESSAGE_TYPE_NONE) {
+ if (msg->header.message_type == HV_MESSAGE_TYPE_NONE)
break; /* no message */
- } else {
+
+ hdr = (hv_vmbus_channel_msg_header *)msg->u.payload;
+ msg_type = hdr->message_type;
+
+ if (msg_type >= HV_CHANNEL_MESSAGE_COUNT && !warned) {
+ warned = true;
+ printf("VMBUS: unknown message type = %d\n", msg_type);
+ goto handled;
+ }
+
+ entry = &g_channel_message_table[msg_type];
+
+ if (entry->handler_no_sleep)
+ entry->messageHandler(hdr);
+ else {
+
copied = malloc(sizeof(hv_vmbus_message),
M_DEVBUF, M_NOWAIT);
KASSERT(copied != NULL,
@@ -97,11 +116,13 @@
" hv_vmbus_message!"));
if (copied == NULL)
continue;
+
memcpy(copied, msg, sizeof(hv_vmbus_message));
hv_queue_work_item(hv_vmbus_g_connection.work_queue,
- hv_vmbus_on_channel_message, copied);
- }
-
+ hv_vmbus_on_channel_message,
+ copied);
+ }
+handled:
msg->header.message_type = HV_MESSAGE_TYPE_NONE;
/*
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
@@ -586,6 +586,16 @@
extern hv_vmbus_context hv_vmbus_g_context;
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;
+
+ bool handler_no_sleep; /* true: the handler doesn't sleep */
+ 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
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 14, 4:18 AM (21 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15790914
Default Alt Text
D4596.diff (4 KB)
Attached To
Mode
D4596: hyperv: vmbus: run non-blocking message handlers in vmbus_msg_swintr()
Attached
Detach File
Event Timeline
Log In to Comment