hyperv/vmbus: Pack bool field into flags field

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7038
This commit is contained in:
Sepherosa Ziehau 2016-07-13 06:46:29 +00:00
parent 7c2abef176
commit df1021e7bf
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=302709
3 changed files with 26 additions and 26 deletions

View File

@ -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(

View File

@ -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);
}

View File

@ -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,7 +308,6 @@ 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->ch_sigevt->hc_connid = offer->connection_id;