Author: sephe
Date: Fri Oct 14 08:55:49 2016
New Revision: 307308
URL: https://svnweb.freebsd.org/changeset/base/307308

Log:
  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

Modified:
  stable/11/sys/dev/hyperv/include/hyperv.h
  stable/11/sys/dev/hyperv/vmbus/hv_channel.c
  stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
  stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/hyperv/include/hyperv.h
==============================================================================
--- stable/11/sys/dev/hyperv/include/hyperv.h   Fri Oct 14 08:45:53 2016        
(r307307)
+++ stable/11/sys/dev/hyperv/include/hyperv.h   Fri Oct 14 08:55:49 2016        
(r307308)
@@ -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(

Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c
==============================================================================
--- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 08:45:53 2016        
(r307307)
+++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 08:55:49 2016        
(r307308)
@@ -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: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
==============================================================================
--- stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c    Fri Oct 14 08:45:53 
2016        (r307307)
+++ stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c    Fri Oct 14 08:55:49 
2016        (r307308)
@@ -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,12 +308,8 @@ 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->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;

Modified: stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c
==============================================================================
--- stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c     Fri Oct 14 08:45:53 
2016        (r307307)
+++ stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c     Fri Oct 14 08:55:49 
2016        (r307308)
@@ -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);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to