hyperv/vmbus: Move channel map to vmbus_softc
MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6982
This commit is contained in:
parent
302244700f
commit
af3be0bfa5
@ -123,7 +123,7 @@ vmbus_channel_process_offer(hv_vmbus_channel *new_channel)
|
||||
*/
|
||||
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 vmbus_softc *sc,
|
||||
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(struct vmbus_softc *sc)
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
@ -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 *event_flags, int flag_cnt)
|
||||
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, int cpu)
|
||||
* 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_softc *sc, int cpu)
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user