Author: sephe
Date: Tue Jul 12 08:47:04 2016
New Revision: 302636
URL: https://svnweb.freebsd.org/changeset/base/302636

Log:
  hyperv/vmbus: Move channel map to vmbus_softc
  
  MFC after:    1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:        https://reviews.freebsd.org/D6982

Modified:
  head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
  head/sys/dev/hyperv/vmbus/hv_connection.c
  head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
  head/sys/dev/hyperv/vmbus/vmbus.c
  head/sys/dev/hyperv/vmbus/vmbus_var.h

Modified: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Jul 12 08:43:09 2016        
(r302635)
+++ head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Jul 12 08:47:04 2016        
(r302636)
@@ -123,7 +123,7 @@ vmbus_channel_process_offer(hv_vmbus_cha
                 */
                printf("VMBUS: got channel0 offer\n");
        } else {
-               hv_vmbus_g_connection.channels[relid] = new_channel;
+               sc->vmbus_chmap[relid] = new_channel;
        }
 
        TAILQ_FOREACH(channel, &sc->vmbus_chlist, ch_link) {
@@ -351,10 +351,10 @@ vmbus_channel_on_offer_rescind(struct vm
                    rescind->child_rel_id);
        }
 
-       channel = hv_vmbus_g_connection.channels[rescind->child_rel_id];
+       channel = sc->vmbus_chmap[rescind->child_rel_id];
        if (channel == NULL)
            return;
-       hv_vmbus_g_connection.channels[rescind->child_rel_id] = NULL;
+       sc->vmbus_chmap[rescind->child_rel_id] = NULL;
 
        taskqueue_enqueue(taskqueue_thread, &channel->ch_detach_task);
 }
@@ -451,8 +451,8 @@ hv_vmbus_release_unattached_channels(str
            }
            hv_vmbus_free_vmbus_channel(channel);
        }
-       bzero(hv_vmbus_g_connection.channels,
-           sizeof(hv_vmbus_channel*) * VMBUS_CHAN_MAX);
+       bzero(sc->vmbus_chmap,
+           sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX);
 
        mtx_unlock(&sc->vmbus_chlist_lock);
 }

Modified: head/sys/dev/hyperv/vmbus/hv_connection.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_connection.c   Tue Jul 12 08:43:09 2016        
(r302635)
+++ head/sys/dev/hyperv/vmbus/hv_connection.c   Tue Jul 12 08:47:04 2016        
(r302636)
@@ -67,9 +67,6 @@ hv_vmbus_connect(struct vmbus_softc *sc)
         */
        hv_vmbus_g_connection.connect_state = HV_CONNECTING;
 
-       hv_vmbus_g_connection.channels = malloc(sizeof(hv_vmbus_channel*) *
-           VMBUS_CHAN_MAX, M_DEVBUF, M_WAITOK | M_ZERO);
-
        hv_vmbus_g_connection.connect_state = HV_CONNECTED;
 
        return (0);
@@ -82,14 +79,14 @@ int
 hv_vmbus_disconnect(void)
 {
 
-       free(hv_vmbus_g_connection.channels, M_DEVBUF);
        hv_vmbus_g_connection.connect_state = HV_DISCONNECTED;
 
        return (0);
 }
 
 static __inline void
-vmbus_event_flags_proc(volatile u_long *event_flags, int flag_cnt)
+vmbus_event_flags_proc(struct vmbus_softc *sc, volatile u_long *event_flags,
+    int flag_cnt)
 {
        int f;
 
@@ -112,7 +109,7 @@ vmbus_event_flags_proc(volatile u_long *
                        flags &= ~(1UL << bit);
 
                        rel_id = rel_id_base + bit;
-                       channel = hv_vmbus_g_connection.channels[rel_id];
+                       channel = sc->vmbus_chmap[rel_id];
 
                        /* if channel is closed or closing */
                        if (channel == NULL || channel->rxq == NULL)
@@ -135,7 +132,7 @@ vmbus_event_proc(struct vmbus_softc *sc,
         * to get the id of the channel that has the pending interrupt.
         */
        eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE;
-       vmbus_event_flags_proc(eventf->evt_flags,
+       vmbus_event_flags_proc(sc, eventf->evt_flags,
            VMBUS_PCPU_GET(sc, event_flags_cnt, cpu));
 }
 
@@ -146,7 +143,7 @@ vmbus_event_proc_compat(struct vmbus_sof
 
        eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE;
        if (atomic_testandclear_long(&eventf->evt_flags[0], 0)) {
-               vmbus_event_flags_proc(sc->vmbus_rx_evtflags,
+               vmbus_event_flags_proc(sc, sc->vmbus_rx_evtflags,
                    VMBUS_CHAN_MAX_COMPAT >> VMBUS_EVTFLAG_SHIFT);
        }
 }

Modified: head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h   Tue Jul 12 08:43:09 2016        
(r302635)
+++ head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h   Tue Jul 12 08:47:04 2016        
(r302636)
@@ -109,11 +109,6 @@ typedef enum {
 
 typedef struct {
        hv_vmbus_connect_state                  connect_state;
-
-       /**
-        * channel table for fast lookup through id.
-       */
-       hv_vmbus_channel                        **channels;
 } hv_vmbus_connection;
 
 typedef union {

Modified: head/sys/dev/hyperv/vmbus/vmbus.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus.c   Tue Jul 12 08:43:09 2016        
(r302635)
+++ head/sys/dev/hyperv/vmbus/vmbus.c   Tue Jul 12 08:47:04 2016        
(r302636)
@@ -1132,6 +1132,9 @@ vmbus_doattach(struct vmbus_softc *sc)
        sc->vmbus_gpadl = VMBUS_GPADL_START;
        mtx_init(&sc->vmbus_chlist_lock, "vmbus chlist", NULL, MTX_DEF);
        TAILQ_INIT(&sc->vmbus_chlist);
+       sc->vmbus_chmap = malloc(
+           sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX, M_DEVBUF,
+           M_WAITOK | M_ZERO);
 
        /*
         * Create context for "post message" Hypercalls
@@ -1201,6 +1204,7 @@ cleanup:
                vmbus_msghc_ctx_destroy(sc->vmbus_msg_hc);
                sc->vmbus_msg_hc = NULL;
        }
+       free(sc->vmbus_chmap, M_DEVBUF);
        mtx_destroy(&sc->vmbus_scan_lock);
 
        return (ret);
@@ -1282,6 +1286,7 @@ vmbus_detach(device_t dev)
                sc->vmbus_msg_hc = NULL;
        }
 
+       free(sc->vmbus_chmap, M_DEVBUF);
        mtx_destroy(&sc->vmbus_scan_lock);
        return (0);
 }

Modified: head/sys/dev/hyperv/vmbus/vmbus_var.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_var.h       Tue Jul 12 08:43:09 2016        
(r302635)
+++ head/sys/dev/hyperv/vmbus/vmbus_var.h       Tue Jul 12 08:47:04 2016        
(r302636)
@@ -75,6 +75,7 @@ struct vmbus_softc {
 
        u_long                  *vmbus_rx_evtflags;
                                                /* compat evtflgs from host */
+       struct hv_vmbus_channel **vmbus_chmap;
        struct vmbus_msghc_ctx  *vmbus_msg_hc;
        struct vmbus_pcpu_data  vmbus_pcpu[MAXCPU];
 
_______________________________________________
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