Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jul 2016 06:46:29 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r302709 - in head/sys/dev/hyperv: include vmbus
Message-ID:  <201607130646.u6D6kTPu028099@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Wed Jul 13 06:46:29 2016
New Revision: 302709
URL: https://svnweb.freebsd.org/changeset/base/302709

Log:
  hyperv/vmbus: Pack bool field into flags field
  
  MFC after:	1 week
  Sponsored by:	Microsoft OSTC
  Differential Revision:	https://reviews.freebsd.org/D7038

Modified:
  head/sys/dev/hyperv/include/hyperv.h
  head/sys/dev/hyperv/vmbus/hv_channel.c
  head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c

Modified: head/sys/dev/hyperv/include/hyperv.h
==============================================================================
--- head/sys/dev/hyperv/include/hyperv.h	Wed Jul 13 06:39:04 2016	(r302708)
+++ head/sys/dev/hyperv/include/hyperv.h	Wed Jul 13 06:46:29 2016	(r302709)
@@ -551,17 +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;
-
 	struct hypercall_sigevt_in	*ch_sigevt;
 	struct hyperv_dma		ch_sigevt_dma;
 
@@ -622,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(

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel.c	Wed Jul 13 06:39:04 2016	(r302708)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c	Wed Jul 13 06:46:29 2016	(r302709)
@@ -856,11 +856,13 @@ VmbusProcessChannelEvent(void* context, 
 	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_soft
 			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);
 		}

Modified: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c	Wed Jul 13 06:39:04 2016	(r302708)
+++ head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c	Wed Jul 13 06:46:29 2016	(r302709)
@@ -282,21 +282,19 @@ vmbus_channel_on_offer_internal(struct v
 {
 	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,7 +308,6 @@ vmbus_channel_on_offer_internal(struct v
 		return;
 	}
 	new_channel->ch_sigevt->hc_connid = VMBUS_CONNID_EVENT;
-
 	if (sc->vmbus_version != VMBUS_VERSION_WS2008)
 		new_channel->ch_sigevt->hc_connid = offer->connection_id;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607130646.u6D6kTPu028099>