summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsephe <sephe@FreeBSD.org>2016-10-14 08:55:49 +0000
committersephe <sephe@FreeBSD.org>2016-10-14 08:55:49 +0000
commit4d80b480dec0869fd07a324d14fe16a3b46a0120 (patch)
treede592b02ad4d2cf467836e03755392c106905c80
parent009dae63903789c8d06c154dd9f4e8064d7b924a (diff)
downloadFreeBSD-src-4d80b480dec0869fd07a324d14fe16a3b46a0120.zip
FreeBSD-src-4d80b480dec0869fd07a324d14fe16a3b46a0120.tar.gz
MFC 302707-302709
302707 hyperv/vmbus: Nuke unused field from hv_vmbus_channel. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7036 302708 hyperv/bufring: Remove unused fields Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7037 302709 hyperv/vmbus: Pack bool field into flags field Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7038
-rw-r--r--sys/dev/hyperv/include/hyperv.h33
-rw-r--r--sys/dev/hyperv/vmbus/hv_channel.c8
-rw-r--r--sys/dev/hyperv/vmbus/hv_channel_mgmt.c22
-rw-r--r--sys/dev/hyperv/vmbus/hv_ring_buffer.c1
4 files changed, 28 insertions, 36 deletions
diff --git a/sys/dev/hyperv/include/hyperv.h b/sys/dev/hyperv/include/hyperv.h
index 74f5ac4..ae23f30 100644
--- a/sys/dev/hyperv/include/hyperv.h
+++ b/sys/dev/hyperv/include/hyperv.h
@@ -471,7 +471,7 @@ typedef struct {
uint8_t reserved[4084];
/*
- * WARNING: Ring data starts here + ring_data_start_offset
+ * WARNING: Ring data starts here
* !!! DO NOT place any fields below this !!!
*/
uint8_t buffer[0]; /* doubles as interrupt mask */
@@ -491,10 +491,8 @@ typedef struct {
typedef struct {
hv_vmbus_ring_buffer* ring_buffer;
- uint32_t ring_size; /* Include the shared header */
struct mtx ring_lock;
uint32_t ring_data_size; /* ring_size */
- uint32_t ring_data_start_offset;
} hv_vmbus_ring_buffer_info;
typedef void (*hv_vmbus_pfn_channel_callback)(void *context);
@@ -553,19 +551,6 @@ typedef struct hv_vmbus_channel {
hv_vmbus_pfn_channel_callback on_channel_callback;
void* channel_callback_context;
- /*
- * If batched_reading is set to "true", mask the interrupt
- * and read until the channel is empty.
- * If batched_reading is set to "false", the channel is not
- * going to perform batched reading.
- *
- * Batched reading is enabled by default; specific
- * drivers that don't want this behavior can turn it off.
- */
- boolean_t batched_reading;
-
- boolean_t is_dedicated_interrupt;
-
struct hypercall_sigevt_in *ch_sigevt;
struct hyperv_dma ch_sigevt_dma;
@@ -626,11 +611,23 @@ typedef struct hv_vmbus_channel {
#define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL)
#define VMBUS_CHAN_FLAG_HASMNF 0x0001
+/*
+ * If this flag is set, this channel's interrupt will be masked in ISR,
+ * and the RX bufring will be drained before this channel's interrupt is
+ * unmasked.
+ *
+ * This flag is turned on by default. Drivers can turn it off according
+ * to their own requirement.
+ */
+#define VMBUS_CHAN_FLAG_BATCHREAD 0x0002
static inline void
-hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t state)
+hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t on)
{
- channel->batched_reading = state;
+ if (!on)
+ channel->ch_flags &= ~VMBUS_CHAN_FLAG_BATCHREAD;
+ else
+ channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD;
}
int hv_vmbus_channel_recv_packet(
diff --git a/sys/dev/hyperv/vmbus/hv_channel.c b/sys/dev/hyperv/vmbus/hv_channel.c
index a7d9de8..3d3608b 100644
--- a/sys/dev/hyperv/vmbus/hv_channel.c
+++ b/sys/dev/hyperv/vmbus/hv_channel.c
@@ -856,11 +856,13 @@ VmbusProcessChannelEvent(void* context, int pending)
void* arg;
uint32_t bytes_to_read;
hv_vmbus_channel* channel = (hv_vmbus_channel*)context;
- boolean_t is_batched_reading;
+ bool is_batched_reading = false;
+
+ if (channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD)
+ is_batched_reading = true;
if (channel->on_channel_callback != NULL) {
arg = channel->channel_callback_context;
- is_batched_reading = channel->batched_reading;
/*
* Optimize host to guest signaling by ensuring:
* 1. While reading the channel, we disable interrupts from
@@ -917,7 +919,7 @@ vmbus_event_flags_proc(struct vmbus_softc *sc, volatile u_long *event_flags,
if (channel == NULL || channel->rxq == NULL)
continue;
- if (channel->batched_reading)
+ if (channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD)
hv_ring_buffer_read_begin(&channel->inbound);
taskqueue_enqueue(channel->rxq, &channel->channel_task);
}
diff --git a/sys/dev/hyperv/vmbus/hv_channel_mgmt.c b/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
index 7b071d8..ed1f069 100644
--- a/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
+++ b/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
@@ -282,21 +282,19 @@ vmbus_channel_on_offer_internal(struct vmbus_softc *sc,
{
hv_vmbus_channel* new_channel;
- /* Allocate the channel object and save this offer */
+ /*
+ * Allocate the channel object and save this offer
+ */
new_channel = hv_vmbus_allocate_channel(sc);
new_channel->ch_id = offer->child_rel_id;
new_channel->ch_subidx = offer->offer.sub_channel_index;
- if (offer->monitor_allocated)
- new_channel->ch_flags |= VMBUS_CHAN_FLAG_HASMNF;
new_channel->ch_guid_type = offer->offer.interface_type;
new_channel->ch_guid_inst = offer->offer.interface_instance;
- /*
- * By default we setup state to enable batched
- * reading. A specific service can choose to
- * disable this prior to opening the channel.
- */
- new_channel->batched_reading = TRUE;
+ /* Batch reading is on by default */
+ new_channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD;
+ if (offer->monitor_allocated)
+ new_channel->ch_flags |= VMBUS_CHAN_FLAG_HASMNF;
new_channel->ch_sigevt = hyperv_dmamem_alloc(
bus_get_dma_tag(sc->vmbus_dev),
@@ -310,12 +308,8 @@ vmbus_channel_on_offer_internal(struct vmbus_softc *sc,
return;
}
new_channel->ch_sigevt->hc_connid = VMBUS_CONNID_EVENT;
-
- if (sc->vmbus_version != VMBUS_VERSION_WS2008) {
- new_channel->is_dedicated_interrupt =
- (offer->is_dedicated_interrupt != 0);
+ if (sc->vmbus_version != VMBUS_VERSION_WS2008)
new_channel->ch_sigevt->hc_connid = offer->connection_id;
- }
new_channel->monitor_group = (uint8_t) offer->monitor_id / 32;
new_channel->monitor_bit = (uint8_t) offer->monitor_id % 32;
diff --git a/sys/dev/hyperv/vmbus/hv_ring_buffer.c b/sys/dev/hyperv/vmbus/hv_ring_buffer.c
index bd5bda1..0a84f82 100644
--- a/sys/dev/hyperv/vmbus/hv_ring_buffer.c
+++ b/sys/dev/hyperv/vmbus/hv_ring_buffer.c
@@ -286,7 +286,6 @@ hv_vmbus_ring_buffer_init(
ring_info->ring_buffer->read_index =
ring_info->ring_buffer->write_index = 0;
- ring_info->ring_size = buffer_len;
ring_info->ring_data_size = buffer_len - sizeof(hv_vmbus_ring_buffer);
mtx_init(&ring_info->ring_lock, "vmbus ring buffer", NULL, MTX_SPIN);
OpenPOWER on IntegriCloud