1008024f2SSepherosa Ziehau /*- 2008024f2SSepherosa Ziehau * Copyright (c) 2016 Microsoft Corp. 3008024f2SSepherosa Ziehau * All rights reserved. 4008024f2SSepherosa Ziehau * 5008024f2SSepherosa Ziehau * Redistribution and use in source and binary forms, with or without 6008024f2SSepherosa Ziehau * modification, are permitted provided that the following conditions 7008024f2SSepherosa Ziehau * are met: 8008024f2SSepherosa Ziehau * 1. Redistributions of source code must retain the above copyright 9008024f2SSepherosa Ziehau * notice unmodified, this list of conditions, and the following 10008024f2SSepherosa Ziehau * disclaimer. 11008024f2SSepherosa Ziehau * 2. Redistributions in binary form must reproduce the above copyright 12008024f2SSepherosa Ziehau * notice, this list of conditions and the following disclaimer in the 13008024f2SSepherosa Ziehau * documentation and/or other materials provided with the distribution. 14008024f2SSepherosa Ziehau * 15008024f2SSepherosa Ziehau * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16008024f2SSepherosa Ziehau * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17008024f2SSepherosa Ziehau * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18008024f2SSepherosa Ziehau * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19008024f2SSepherosa Ziehau * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20008024f2SSepherosa Ziehau * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21008024f2SSepherosa Ziehau * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22008024f2SSepherosa Ziehau * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23008024f2SSepherosa Ziehau * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24008024f2SSepherosa Ziehau * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25008024f2SSepherosa Ziehau * 26008024f2SSepherosa Ziehau * $FreeBSD$ 27008024f2SSepherosa Ziehau */ 28008024f2SSepherosa Ziehau 29008024f2SSepherosa Ziehau #ifndef _VMBUS_VAR_H_ 30008024f2SSepherosa Ziehau #define _VMBUS_VAR_H_ 31008024f2SSepherosa Ziehau 32008024f2SSepherosa Ziehau #include <sys/param.h> 33008024f2SSepherosa Ziehau 34008024f2SSepherosa Ziehau struct vmbus_pcpu_data { 35008024f2SSepherosa Ziehau int event_flag_cnt; /* # of event flags */ 36008024f2SSepherosa Ziehau } __aligned(CACHE_LINE_SIZE); 37008024f2SSepherosa Ziehau 38008024f2SSepherosa Ziehau struct vmbus_softc { 39646995bdSSepherosa Ziehau void (*vmbus_event_proc)(struct vmbus_softc *, int); 40008024f2SSepherosa Ziehau struct vmbus_pcpu_data vmbus_pcpu[MAXCPU]; 41e2468dfeSSepherosa Ziehau device_t vmbus_dev; 42*fc4d679fSSepherosa Ziehau int vmbus_idtvec; 43008024f2SSepherosa Ziehau }; 44008024f2SSepherosa Ziehau 45008024f2SSepherosa Ziehau extern struct vmbus_softc *vmbus_sc; 46008024f2SSepherosa Ziehau 47008024f2SSepherosa Ziehau static __inline struct vmbus_softc * 48008024f2SSepherosa Ziehau vmbus_get_softc(void) 49008024f2SSepherosa Ziehau { 50008024f2SSepherosa Ziehau return vmbus_sc; 51008024f2SSepherosa Ziehau } 52008024f2SSepherosa Ziehau 53e2468dfeSSepherosa Ziehau static __inline device_t 54e2468dfeSSepherosa Ziehau vmbus_get_device(void) 55e2468dfeSSepherosa Ziehau { 56e2468dfeSSepherosa Ziehau return vmbus_sc->vmbus_dev; 57e2468dfeSSepherosa Ziehau } 58e2468dfeSSepherosa Ziehau 59646995bdSSepherosa Ziehau #define VMBUS_SC_PCPU_GET(sc, field, cpu) (sc)->vmbus_pcpu[(cpu)].field 60646995bdSSepherosa Ziehau #define VMBUS_SC_PCPU_PTR(sc, field, cpu) &(sc)->vmbus_pcpu[(cpu)].field 61008024f2SSepherosa Ziehau #define VMBUS_PCPU_GET(field, cpu) \ 62646995bdSSepherosa Ziehau VMBUS_SC_PCPU_GET(vmbus_get_softc(), field, (cpu)) 63008024f2SSepherosa Ziehau #define VMBUS_PCPU_PTR(field, cpu) \ 64646995bdSSepherosa Ziehau VMBUS_SC_PCPU_PTR(vmbus_get_softc(), field, (cpu)) 65008024f2SSepherosa Ziehau 66008024f2SSepherosa Ziehau void vmbus_on_channel_open(const struct hv_vmbus_channel *); 67646995bdSSepherosa Ziehau void vmbus_event_proc(struct vmbus_softc *, int); 68646995bdSSepherosa Ziehau void vmbus_event_proc_compat(struct vmbus_softc *, int); 69008024f2SSepherosa Ziehau 70008024f2SSepherosa Ziehau #endif /* !_VMBUS_VAR_H_ */ 71