FreeBSD/sys/dev/hyperv/vmbus/hv_channel.c
/**
 * @brief Teardown the specified GPADL handle
 */
@brief Teardown the specified GPADL handle
@brief Teardown the specified GPADL handle
int
hv_vmbus_channel_teardown_gpdal(
	hv_vmbus_channel*	channel,
	uint32_t		gpadl_handle)
{
	int					ret = 0;
	hv_vmbus_channel_gpadl_teardown*	msg;
	hv_vmbus_channel_msg_info*		info;
	info = (hv_vmbus_channel_msg_info *)
		malloc(	sizeof(hv_vmbus_channel_msg_info) +
			sizeof(hv_vmbus_channel_gpadl_teardown),
				M_DEVBUF, M_NOWAIT);
	KASSERT(info != NULL,
	    ("Error VMBUS: malloc failed to allocate Gpadl Teardown Msg!"));
	if (info == NULL) {
	    ret = ENOMEM;
	    goto cleanup;
	}
	sema_init(&info->wait_sema, 0, "Open Info Sema");
	msg = (hv_vmbus_channel_gpadl_teardown*) info->msg;
	msg->header.message_type = HV_CHANNEL_MESSAGE_GPADL_TEARDOWN;
	msg->child_rel_id = channel->offer_msg.child_rel_id;
	msg->gpadl = gpadl_handle;
	mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
	TAILQ_INSERT_TAIL(&hv_vmbus_g_connection.channel_msg_anchor,
			info, msg_list_entry);
	mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
	ret = hv_vmbus_post_message(msg,
			sizeof(hv_vmbus_channel_gpadl_teardown));
	if (ret != 0) 
	    goto cleanup;
	ret = sema_timedwait(&info->wait_sema, 5 * hz); 
cleanup:
	mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
	TAILQ_REMOVE(&hv_vmbus_g_connection.channel_msg_anchor,
			info, msg_list_entry);
	mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
	sema_destroy(&info->wait_sema);
	free(info, M_DEVBUF);
	return (ret);
}
int hv_vmbus_channel_teardown_gpdal ( hv_vmbus_channel * channel , uint32_t gpadl_handle ) { int ret = 0 ; hv_vmbus_channel_gpadl_teardown * msg ; hv_vmbus_channel_msg_info * info ; info = ( hv_vmbus_channel_msg_info * ) malloc ( sizeof ( hv_vmbus_channel_msg_info ) + sizeof ( hv_vmbus_channel_gpadl_teardown ) , M_DEVBUF , M_NOWAIT ) ; KASSERT ( info != NULL , ( " " ) ) ; if ( info == NULL ) { ret = ENOMEM ; goto cleanup ; } sema_init ( & info -> wait_sema , 0 , " " ) ; msg = ( hv_vmbus_channel_gpadl_teardown * ) info -> msg ; msg -> header . message_type = HV_CHANNEL_MESSAGE_GPADL_TEARDOWN ; msg -> child_rel_id = channel -> offer_msg . child_rel_id ; msg -> gpadl = gpadl_handle ; mtx_lock ( & hv_vmbus_g_connection . channel_msg_lock ) ; TAILQ_INSERT_TAIL ( & hv_vmbus_g_connection . channel_msg_anchor , info , msg_list_entry ) ; mtx_unlock ( & hv_vmbus_g_connection . channel_msg_lock ) ; ret = hv_vmbus_post_message ( msg , sizeof ( hv_vmbus_channel_gpadl_teardown ) ) ; if ( ret != 0 ) goto cleanup ; ret = sema_timedwait ( & info -> wait_sema , 5 * hz ) ; cleanup : mtx_lock ( & hv_vmbus_g_connection . channel_msg_lock ) ; TAILQ_REMOVE ( & hv_vmbus_g_connection . channel_msg_anchor , info , msg_list_entry ) ; mtx_unlock ( & hv_vmbus_g_connection . channel_msg_lock ) ; sema_destroy ( & info -> wait_sema ) ; free ( info , M_DEVBUF ) ; return ( ret ) ; }
@brief Teardown the specified GPADL handle
@brief Teardown the specified GPADL handle
/* KYS 5 seconds */ /*
	 * Received a torndown response
	 */