xref: /freebsd/sys/dev/vmd/vmd.h (revision f5ef5f675d9d9eb6e35ed9142d70ecf774456ad4)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright 2019 Cisco Systems, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  *
30  */
31 
32 #ifndef __VMD_PRIVATE_H__
33 #define	__VMD_PRIVATE_H__
34 
35 struct vmd_irq_handler {
36 	TAILQ_ENTRY(vmd_irq_handler)	vmd_link;
37 	device_t			vmd_child;
38 	driver_intr_t			*vmd_intr;
39 	void				*vmd_arg;
40 	int				vmd_rid;
41 };
42 
43 struct vmd_irq {
44 	struct resource			*vmd_res;
45 	int				vmd_rid;
46 	void 				*vmd_handle;
47 	struct vmd_softc		*vmd_sc;
48 	int				vmd_instance;
49 	TAILQ_HEAD(,vmd_irq_handler)	vmd_list;
50 };
51 
52 /*
53  * VMD specific data.
54  */
55 struct vmd_softc
56 {
57 	device_t		vmd_dev;
58 	device_t		vmd_child;
59 	uint32_t		vmd_flags;	/* flags */
60 #define	PCIB_SUBTRACTIVE	0x1
61 #define	PCIB_DISABLE_MSI	0x2
62 #define	PCIB_DISABLE_MSIX	0x4
63 #define	PCIB_ENABLE_ARI		0x8
64 #define	PCIB_HOTPLUG		0x10
65 #define	PCIB_HOTPLUG_CMD_PENDING 0x20
66 #define	PCIB_DETACH_PENDING	0x40
67 #define	PCIB_DETACHING		0x80
68 	u_int			vmd_domain;	/* domain number */
69 	struct pcib_secbus	vmd_bus;	/* secondary bus numbers */
70 
71 #define VMD_MAX_BAR         3
72 	struct resource         *vmd_regs_resource[VMD_MAX_BAR];
73 	int                     vmd_regs_rid[VMD_MAX_BAR];
74 	bus_space_handle_t      vmd_bhandle;
75 	bus_space_tag_t         vmd_btag;
76 	int                     vmd_io_rid;
77 	struct resource         *vmd_io_resource;
78 	void                    *vmd_intr;
79 	struct vmd_irq          *vmd_irq;
80 	int			vmd_msix_count;
81 #ifdef TASK_QUEUE_INTR
82 	struct taskqueue	*vmd_irq_tq;
83 	struct task		vmd_irq_task;
84 #else
85 	struct mtx		vmd_irq_lock;
86 #endif
87 };
88 
89 #endif
90