1e3c41896SSepherosa Ziehau /*- 2e3c41896SSepherosa Ziehau * Copyright (c) 2016 Microsoft Corp. 3e3c41896SSepherosa Ziehau * All rights reserved. 4e3c41896SSepherosa Ziehau * 5e3c41896SSepherosa Ziehau * Redistribution and use in source and binary forms, with or without 6e3c41896SSepherosa Ziehau * modification, are permitted provided that the following conditions 7e3c41896SSepherosa Ziehau * are met: 8e3c41896SSepherosa Ziehau * 1. Redistributions of source code must retain the above copyright 9e3c41896SSepherosa Ziehau * notice unmodified, this list of conditions, and the following 10e3c41896SSepherosa Ziehau * disclaimer. 11e3c41896SSepherosa Ziehau * 2. Redistributions in binary form must reproduce the above copyright 12e3c41896SSepherosa Ziehau * notice, this list of conditions and the following disclaimer in the 13e3c41896SSepherosa Ziehau * documentation and/or other materials provided with the distribution. 14e3c41896SSepherosa Ziehau * 15e3c41896SSepherosa Ziehau * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16e3c41896SSepherosa Ziehau * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17e3c41896SSepherosa Ziehau * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18e3c41896SSepherosa Ziehau * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19e3c41896SSepherosa Ziehau * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20e3c41896SSepherosa Ziehau * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21e3c41896SSepherosa Ziehau * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22e3c41896SSepherosa Ziehau * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23e3c41896SSepherosa Ziehau * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24e3c41896SSepherosa Ziehau * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25e3c41896SSepherosa Ziehau * 26e3c41896SSepherosa Ziehau * $FreeBSD$ 27e3c41896SSepherosa Ziehau */ 28e3c41896SSepherosa Ziehau 29e3c41896SSepherosa Ziehau #ifndef _VMBUS_VAR_H_ 30e3c41896SSepherosa Ziehau #define _VMBUS_VAR_H_ 31e3c41896SSepherosa Ziehau 32e3c41896SSepherosa Ziehau #include <sys/param.h> 33e3c41896SSepherosa Ziehau 34e3c41896SSepherosa Ziehau struct vmbus_pcpu_data { 35e3c41896SSepherosa Ziehau struct vmbus_message *message; /* shared messages */ 36e3c41896SSepherosa Ziehau int event_flags_cnt;/* # of event flags */ 37e3c41896SSepherosa Ziehau struct vmbus_evtflags *event_flags; /* event flags from host */ 38e3c41896SSepherosa Ziehau 39e3c41896SSepherosa Ziehau struct vmbus_softc *sc; 40e3c41896SSepherosa Ziehau int cpuid; 41e3c41896SSepherosa Ziehau int vcpuid; 42e3c41896SSepherosa Ziehau 43e3c41896SSepherosa Ziehau uint64_t timer_last; 44e3c41896SSepherosa Ziehau 45e3c41896SSepherosa Ziehau /* 46e3c41896SSepherosa Ziehau * Rarely used fields 47e3c41896SSepherosa Ziehau */ 48e3c41896SSepherosa Ziehau 49e3c41896SSepherosa Ziehau struct hyperv_dma message_dma; /* busdma glue */ 50e3c41896SSepherosa Ziehau struct hyperv_dma event_flags_dma;/* busdma glue */ 51e3c41896SSepherosa Ziehau 52e3c41896SSepherosa Ziehau /* Interrupt stuffs */ 53e3c41896SSepherosa Ziehau void *intr_hand; 54e3c41896SSepherosa Ziehau struct resource *intr_res; 55e3c41896SSepherosa Ziehau int intr_rid; 56*ae7ab5b6SSepherosa Ziehau int intr_irq; 57e3c41896SSepherosa Ziehau int intr_vec; 58*ae7ab5b6SSepherosa Ziehau char intr_desc[20]; 59e3c41896SSepherosa Ziehau } __cachealign; 60e3c41896SSepherosa Ziehau 61e3c41896SSepherosa Ziehau struct vmbus_softc { 62e3c41896SSepherosa Ziehau u_long *vmbus_tx_evtflags; 63e3c41896SSepherosa Ziehau /* event flags to host */ 64e3c41896SSepherosa Ziehau void *vmbus_mnf2; /* monitored by host */ 65e3c41896SSepherosa Ziehau 66e3c41896SSepherosa Ziehau u_long *vmbus_rx_evtflags; 67e3c41896SSepherosa Ziehau /* compat evtflgs from host */ 68e3c41896SSepherosa Ziehau struct vmbus_pcpu_data vmbus_pcpu[MAXCPU]; 69e3c41896SSepherosa Ziehau 70e3c41896SSepherosa Ziehau /* 71e3c41896SSepherosa Ziehau * Rarely used fields 72e3c41896SSepherosa Ziehau */ 73e3c41896SSepherosa Ziehau 74e3c41896SSepherosa Ziehau device_t vmbus_dev; 75e3c41896SSepherosa Ziehau struct vmbus_msghc_ctx *vmbus_msg_hc; 76e3c41896SSepherosa Ziehau uint32_t vmbus_flags; /* see VMBUS_FLAG_ */ 77e3c41896SSepherosa Ziehau uint32_t vmbus_version; /* VMBUS_VERSION_ */ 78e3c41896SSepherosa Ziehau 79e3c41896SSepherosa Ziehau /* Shared memory for vmbus_{rx,tx}_evtflags */ 80e3c41896SSepherosa Ziehau void *vmbus_evtflags; 81e3c41896SSepherosa Ziehau struct hyperv_dma vmbus_evtflags_dma; 82e3c41896SSepherosa Ziehau 83e3c41896SSepherosa Ziehau void *vmbus_mnf1; /* monitored by VM, unused */ 84e3c41896SSepherosa Ziehau struct hyperv_dma vmbus_mnf1_dma; 85e3c41896SSepherosa Ziehau struct hyperv_dma vmbus_mnf2_dma; 86e3c41896SSepherosa Ziehau }; 87e3c41896SSepherosa Ziehau 88e3c41896SSepherosa Ziehau #define VMBUS_FLAG_SYNIC 0x0002 /* SynIC was setup */ 89e3c41896SSepherosa Ziehau 90e3c41896SSepherosa Ziehau #define VMBUS_PCPU(sc, cpu) &(sc)->vmbus_pcpu[(cpu)] 91e3c41896SSepherosa Ziehau 92e3c41896SSepherosa Ziehau struct vmbus_message; 93e3c41896SSepherosa Ziehau struct vmbus_msghc; 94e3c41896SSepherosa Ziehau 95e3c41896SSepherosa Ziehau struct vmbus_msghc *vmbus_msghc_get(struct vmbus_softc *, size_t); 96e3c41896SSepherosa Ziehau void vmbus_msghc_put(struct vmbus_softc *, struct vmbus_msghc *); 97e3c41896SSepherosa Ziehau void *vmbus_msghc_dataptr(struct vmbus_msghc *); 98e3c41896SSepherosa Ziehau int vmbus_msghc_exec_noresult(struct vmbus_msghc *); 99e3c41896SSepherosa Ziehau int vmbus_msghc_exec(struct vmbus_softc *, struct vmbus_msghc *); 100e3c41896SSepherosa Ziehau const struct vmbus_message *vmbus_msghc_wait_result(struct vmbus_softc *, 101e3c41896SSepherosa Ziehau struct vmbus_msghc *); 102e3c41896SSepherosa Ziehau void vmbus_msghc_wakeup(struct vmbus_softc *, const struct vmbus_message *); 103e3c41896SSepherosa Ziehau 104e3c41896SSepherosa Ziehau #endif /* !_VMBUS_VAR_H_ */ 105