Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hyperv/vmbus/hv_connection.c
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | hv_vmbus_negotiate_version(hv_vmbus_channel_msg_info *msg_info, | ||||
msg->monitor_page_2 = hv_get_phys_addr( | msg->monitor_page_2 = hv_get_phys_addr( | ||||
hv_vmbus_g_connection.monitor_page_2); | hv_vmbus_g_connection.monitor_page_2); | ||||
/** | /** | ||||
* Add to list before we send the request since we may receive the | * Add to list before we send the request since we may receive the | ||||
* response before returning from this routine | * response before returning from this routine | ||||
*/ | */ | ||||
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); | mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); | ||||
TAILQ_INSERT_TAIL( | TAILQ_INSERT_TAIL( | ||||
&hv_vmbus_g_connection.channel_msg_anchor, | &hv_vmbus_g_connection.channel_msg_anchor, | ||||
msg_info, | msg_info, | ||||
msg_list_entry); | msg_list_entry); | ||||
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); | mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); | ||||
ret = hv_vmbus_post_message( | ret = hv_vmbus_post_message( | ||||
msg, | msg, | ||||
sizeof(hv_vmbus_channel_initiate_contact)); | sizeof(hv_vmbus_channel_initiate_contact)); | ||||
if (ret != 0) { | if (ret != 0) { | ||||
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); | mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); | ||||
TAILQ_REMOVE( | TAILQ_REMOVE( | ||||
&hv_vmbus_g_connection.channel_msg_anchor, | &hv_vmbus_g_connection.channel_msg_anchor, | ||||
msg_info, | msg_info, | ||||
msg_list_entry); | msg_list_entry); | ||||
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); | mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); | ||||
return (ret); | return (ret); | ||||
} | } | ||||
/** | /** | ||||
* Wait for the connection response | * Wait for the connection response | ||||
*/ | */ | ||||
ret = sema_timedwait(&msg_info->wait_sema, 5 * hz); /* KYS 5 seconds */ | ret = sema_timedwait(&msg_info->wait_sema, 5 * hz); /* KYS 5 seconds */ | ||||
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); | mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); | ||||
TAILQ_REMOVE( | TAILQ_REMOVE( | ||||
&hv_vmbus_g_connection.channel_msg_anchor, | &hv_vmbus_g_connection.channel_msg_anchor, | ||||
msg_info, | msg_info, | ||||
msg_list_entry); | msg_list_entry); | ||||
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); | mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); | ||||
/** | /** | ||||
* Check if successful | * Check if successful | ||||
*/ | */ | ||||
if (msg_info->response.version_response.version_supported) { | if (msg_info->response.version_response.version_supported) { | ||||
hv_vmbus_g_connection.connect_state = HV_CONNECTED; | hv_vmbus_g_connection.connect_state = HV_CONNECTED; | ||||
} else { | } else { | ||||
ret = ECONNREFUSED; | ret = ECONNREFUSED; | ||||
Show All 20 Lines | hv_vmbus_connect(void) { | ||||
/** | /** | ||||
* Initialize the vmbus connection | * Initialize the vmbus connection | ||||
*/ | */ | ||||
hv_vmbus_g_connection.connect_state = HV_CONNECTING; | hv_vmbus_g_connection.connect_state = HV_CONNECTING; | ||||
TAILQ_INIT(&hv_vmbus_g_connection.channel_msg_anchor); | TAILQ_INIT(&hv_vmbus_g_connection.channel_msg_anchor); | ||||
mtx_init(&hv_vmbus_g_connection.channel_msg_lock, "vmbus channel msg", | mtx_init(&hv_vmbus_g_connection.channel_msg_lock, "vmbus channel msg", | ||||
NULL, MTX_SPIN); | NULL, MTX_DEF); | ||||
TAILQ_INIT(&hv_vmbus_g_connection.channel_anchor); | TAILQ_INIT(&hv_vmbus_g_connection.channel_anchor); | ||||
mtx_init(&hv_vmbus_g_connection.channel_lock, "vmbus channel", | mtx_init(&hv_vmbus_g_connection.channel_lock, "vmbus channel", | ||||
NULL, MTX_DEF); | NULL, MTX_DEF); | ||||
/** | /** | ||||
* Setup the vmbus event connection for channel interrupt abstraction | * Setup the vmbus event connection for channel interrupt abstraction | ||||
* stuff | * stuff | ||||
▲ Show 20 Lines • Show All 237 Lines • Show Last 20 Lines |