Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hyperv/vmbus/hv_channel.c
Show All 30 Lines | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/sysctl.h> | |||||
#include <machine/bus.h> | #include <machine/bus.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/vm_param.h> | #include <vm/vm_param.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
#include "hv_vmbus_priv.h" | #include "hv_vmbus_priv.h" | ||||
static int vmbus_channel_create_gpadl_header( | static int vmbus_channel_create_gpadl_header( | ||||
Show All 28 Lines | synch_set_bit(channel->monitor_bit, | ||||
(uint32_t *)&monitor_page-> | (uint32_t *)&monitor_page-> | ||||
trigger_group[channel->monitor_group].u.pending); | trigger_group[channel->monitor_group].u.pending); | ||||
} else { | } else { | ||||
hv_vmbus_set_event(channel); | hv_vmbus_set_event(channel); | ||||
} | } | ||||
} | } | ||||
static void | |||||
hv_vmbus_channel_stat(hv_vmbus_channel* channel) | |||||
{ | |||||
device_t dev; | |||||
struct sysctl_oid *devch_sysctl; | |||||
struct sysctl_oid *devch_id_sysctl, *devch_sub_sysctl; | |||||
struct sysctl_oid *devch_id_in_sysctl, *devch_id_out_sysctl; | |||||
struct sysctl_ctx_list *ctx; | |||||
uint32_t ch_id; | |||||
uint16_t sub_ch_id; | |||||
char name[16]; | |||||
hv_vmbus_channel* primary_ch = channel->primary_channel; | |||||
if (primary_ch == NULL) { | |||||
dev = channel->device->device; | |||||
ch_id = channel->offer_msg.child_rel_id; | |||||
} else { | |||||
dev = primary_ch->device->device; | |||||
ch_id = primary_ch->offer_msg.child_rel_id; | |||||
sub_ch_id = channel->offer_msg.offer.sub_channel_index; | |||||
} | |||||
ctx = device_get_sysctl_ctx(dev); | |||||
/* This creates dev.DEVNAME.DEVUNIT.channel tree */ | |||||
devch_sysctl = SYSCTL_ADD_NODE(ctx, | |||||
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), | |||||
OID_AUTO, "channel", CTLFLAG_RD, 0, ""); | |||||
/* This creates dev.DEVNAME.DEVUNIT.channel.CHANID tree */ | |||||
snprintf(name, sizeof(name), "%d", ch_id); | |||||
devch_id_sysctl = SYSCTL_ADD_NODE(ctx, | |||||
SYSCTL_CHILDREN(devch_sysctl), | |||||
OID_AUTO, name, CTLFLAG_RD, 0, ""); | |||||
if (primary_ch != NULL) { | |||||
devch_sub_sysctl = SYSCTL_ADD_NODE(ctx, | |||||
SYSCTL_CHILDREN(devch_id_sysctl), | |||||
OID_AUTO, "sub", CTLFLAG_RD, 0, ""); | |||||
snprintf(name, sizeof(name), "%d", sub_ch_id); | |||||
devch_id_sysctl = SYSCTL_ADD_NODE(ctx, | |||||
SYSCTL_CHILDREN(devch_sub_sysctl), | |||||
OID_AUTO, name, CTLFLAG_RD, 0, ""); | |||||
} | |||||
devch_id_in_sysctl = SYSCTL_ADD_NODE(ctx, | |||||
SYSCTL_CHILDREN(devch_id_sysctl), | |||||
OID_AUTO, | |||||
"in", | |||||
CTLFLAG_RD, 0, ""); | |||||
devch_id_out_sysctl = SYSCTL_ADD_NODE(ctx, | |||||
SYSCTL_CHILDREN(devch_id_sysctl), | |||||
OID_AUTO, | |||||
"out", | |||||
CTLFLAG_RD, 0, ""); | |||||
hv_ring_buffer_stat(ctx, | |||||
SYSCTL_CHILDREN(devch_id_in_sysctl), | |||||
&(channel->inbound), | |||||
"inbound ring buffer stats"); | |||||
hv_ring_buffer_stat(ctx, | |||||
SYSCTL_CHILDREN(devch_id_out_sysctl), | |||||
&(channel->outbound), | |||||
"outbound ring buffer stats"); | |||||
} | |||||
/** | /** | ||||
* @brief Open the specified channel | * @brief Open the specified channel | ||||
*/ | */ | ||||
int | int | ||||
hv_vmbus_channel_open( | hv_vmbus_channel_open( | ||||
hv_vmbus_channel* new_channel, | hv_vmbus_channel* new_channel, | ||||
uint32_t send_ring_buffer_size, | uint32_t send_ring_buffer_size, | ||||
uint32_t recv_ring_buffer_size, | uint32_t recv_ring_buffer_size, | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | hv_vmbus_ring_buffer_init( | ||||
&new_channel->outbound, | &new_channel->outbound, | ||||
out, | out, | ||||
send_ring_buffer_size); | send_ring_buffer_size); | ||||
hv_vmbus_ring_buffer_init( | hv_vmbus_ring_buffer_init( | ||||
&new_channel->inbound, | &new_channel->inbound, | ||||
in, | in, | ||||
recv_ring_buffer_size); | recv_ring_buffer_size); | ||||
/* setup statistic tracking for this channel */ | |||||
hv_vmbus_channel_stat(new_channel); | |||||
/** | /** | ||||
* Establish the gpadl for the ring buffer | * Establish the gpadl for the ring buffer | ||||
*/ | */ | ||||
new_channel->ring_buffer_gpadl_handle = 0; | new_channel->ring_buffer_gpadl_handle = 0; | ||||
ret = hv_vmbus_channel_establish_gpadl(new_channel, | ret = hv_vmbus_channel_establish_gpadl(new_channel, | ||||
new_channel->outbound.ring_buffer, | new_channel->outbound.ring_buffer, | ||||
▲ Show 20 Lines • Show All 791 Lines • Show Last 20 Lines |