xref: /freebsd/sys/dev/hyperv/vmbus/vmbus_var.h (revision 008024f2b89b6a10a85bbb8cec8de931453f910f)
1*008024f2SSepherosa Ziehau /*-
2*008024f2SSepherosa Ziehau  * Copyright (c) 2016 Microsoft Corp.
3*008024f2SSepherosa Ziehau  * All rights reserved.
4*008024f2SSepherosa Ziehau  *
5*008024f2SSepherosa Ziehau  * Redistribution and use in source and binary forms, with or without
6*008024f2SSepherosa Ziehau  * modification, are permitted provided that the following conditions
7*008024f2SSepherosa Ziehau  * are met:
8*008024f2SSepherosa Ziehau  * 1. Redistributions of source code must retain the above copyright
9*008024f2SSepherosa Ziehau  *    notice unmodified, this list of conditions, and the following
10*008024f2SSepherosa Ziehau  *    disclaimer.
11*008024f2SSepherosa Ziehau  * 2. Redistributions in binary form must reproduce the above copyright
12*008024f2SSepherosa Ziehau  *    notice, this list of conditions and the following disclaimer in the
13*008024f2SSepherosa Ziehau  *    documentation and/or other materials provided with the distribution.
14*008024f2SSepherosa Ziehau  *
15*008024f2SSepherosa Ziehau  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*008024f2SSepherosa Ziehau  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*008024f2SSepherosa Ziehau  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*008024f2SSepherosa Ziehau  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19*008024f2SSepherosa Ziehau  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*008024f2SSepherosa Ziehau  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*008024f2SSepherosa Ziehau  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*008024f2SSepherosa Ziehau  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*008024f2SSepherosa Ziehau  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*008024f2SSepherosa Ziehau  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*008024f2SSepherosa Ziehau  *
26*008024f2SSepherosa Ziehau  * $FreeBSD$
27*008024f2SSepherosa Ziehau  */
28*008024f2SSepherosa Ziehau 
29*008024f2SSepherosa Ziehau #ifndef _VMBUS_VAR_H_
30*008024f2SSepherosa Ziehau #define _VMBUS_VAR_H_
31*008024f2SSepherosa Ziehau 
32*008024f2SSepherosa Ziehau #include <sys/param.h>
33*008024f2SSepherosa Ziehau 
34*008024f2SSepherosa Ziehau struct vmbus_pcpu_data {
35*008024f2SSepherosa Ziehau 	int		event_flag_cnt;	/* # of event flags */
36*008024f2SSepherosa Ziehau } __aligned(CACHE_LINE_SIZE);
37*008024f2SSepherosa Ziehau 
38*008024f2SSepherosa Ziehau struct vmbus_softc {
39*008024f2SSepherosa Ziehau 	struct vmbus_pcpu_data	vmbus_pcpu[MAXCPU];
40*008024f2SSepherosa Ziehau };
41*008024f2SSepherosa Ziehau 
42*008024f2SSepherosa Ziehau extern struct vmbus_softc	*vmbus_sc;
43*008024f2SSepherosa Ziehau 
44*008024f2SSepherosa Ziehau static __inline struct vmbus_softc *
45*008024f2SSepherosa Ziehau vmbus_get_softc(void)
46*008024f2SSepherosa Ziehau {
47*008024f2SSepherosa Ziehau 	return vmbus_sc;
48*008024f2SSepherosa Ziehau }
49*008024f2SSepherosa Ziehau 
50*008024f2SSepherosa Ziehau #define VMBUS_PCPU_GET(field, cpu)	\
51*008024f2SSepherosa Ziehau 	(vmbus_get_softc())->vmbus_pcpu[cpu].field
52*008024f2SSepherosa Ziehau #define VMBUS_PCPU_PTR(field, cpu)	\
53*008024f2SSepherosa Ziehau 	&(vmbus_get_softc())->vmbus_pcpu[cpu].field
54*008024f2SSepherosa Ziehau 
55*008024f2SSepherosa Ziehau void	vmbus_on_channel_open(const struct hv_vmbus_channel *);
56*008024f2SSepherosa Ziehau 
57*008024f2SSepherosa Ziehau #endif	/* !_VMBUS_VAR_H_ */
58