xref: /freebsd/sys/dev/pci/pci_if.m (revision d7be980dbe6961abce6b3e12de0391cbad295f95)
1#-
2# Copyright (c) 1998 Doug Rabson
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9#    notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11#    notice, this list of conditions and the following disclaimer in the
12#    documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
26# $FreeBSD$
27#
28
29#include <sys/bus.h>
30#include <dev/pci/pcivar.h>
31
32INTERFACE pci;
33
34CODE {
35	static int
36	null_msi_count(device_t dev, device_t child)
37	{
38		return (0);
39	}
40
41	static int
42	null_msix_bar(device_t dev, device_t child)
43	{
44		return (-1);
45	}
46
47	static device_t
48	null_create_iov_child(device_t bus, device_t pf, uint16_t rid,
49	    uint16_t vid, uint16_t did)
50	{
51		device_printf(bus, "PCI_IOV not implemented on this bus.\n");
52		return (NULL);
53	}
54};
55
56HEADER {
57	struct nvlist;
58
59	enum pci_id_type {
60	    PCI_ID_RID,
61	};
62}
63
64
65METHOD u_int32_t read_config {
66	device_t	dev;
67	device_t	child;
68	int		reg;
69	int		width;
70};
71
72METHOD void write_config {
73	device_t	dev;
74	device_t	child;
75	int		reg;
76	u_int32_t	val;
77	int		width;
78};
79
80METHOD int get_powerstate {
81	device_t	dev;
82	device_t	child;
83};
84
85METHOD int set_powerstate {
86	device_t	dev;
87	device_t	child;
88	int		state;
89};
90
91METHOD int get_vpd_ident {
92	device_t	dev;
93	device_t	child;
94	const char	**identptr;
95};
96
97METHOD int get_vpd_readonly {
98	device_t	dev;
99	device_t	child;
100	const char	*kw;
101	const char	**vptr;
102};
103
104METHOD int enable_busmaster {
105	device_t	dev;
106	device_t	child;
107};
108
109METHOD int disable_busmaster {
110	device_t	dev;
111	device_t	child;
112};
113
114METHOD int enable_io {
115	device_t	dev;
116	device_t	child;
117	int		space;
118};
119
120METHOD int disable_io {
121	device_t	dev;
122	device_t	child;
123	int		space;
124};
125
126METHOD int assign_interrupt {
127	device_t	dev;
128	device_t	child;
129};
130
131METHOD int find_cap {
132	device_t	dev;
133	device_t	child;
134	int		capability;
135	int		*capreg;
136};
137
138METHOD int find_extcap {
139	device_t	dev;
140	device_t	child;
141	int		capability;
142	int		*capreg;
143};
144
145METHOD int find_htcap {
146	device_t	dev;
147	device_t	child;
148	int		capability;
149	int		*capreg;
150};
151
152METHOD int alloc_msi {
153	device_t	dev;
154	device_t	child;
155	int		*count;
156};
157
158METHOD int alloc_msix {
159	device_t	dev;
160	device_t	child;
161	int		*count;
162};
163
164METHOD void enable_msi {
165	device_t	dev;
166	device_t	child;
167	uint64_t	address;
168	uint16_t	data;
169};
170
171METHOD void enable_msix {
172	device_t	dev;
173	device_t	child;
174	u_int		index;
175	uint64_t	address;
176	uint32_t	data;
177};
178
179METHOD void disable_msi {
180	device_t	dev;
181	device_t	child;
182};
183
184METHOD int remap_msix {
185	device_t	dev;
186	device_t	child;
187	int		count;
188	const u_int	*vectors;
189};
190
191METHOD int release_msi {
192	device_t	dev;
193	device_t	child;
194};
195
196METHOD int msi_count {
197	device_t	dev;
198	device_t	child;
199} DEFAULT null_msi_count;
200
201METHOD int msix_count {
202	device_t	dev;
203	device_t	child;
204} DEFAULT null_msi_count;
205
206METHOD int msix_pba_bar {
207	device_t	dev;
208	device_t	child;
209} DEFAULT null_msix_bar;
210
211METHOD int msix_table_bar {
212	device_t	dev;
213	device_t	child;
214} DEFAULT null_msix_bar;
215
216METHOD int get_id {
217	device_t	dev;
218	device_t	child;
219	enum pci_id_type type;
220	uintptr_t	*id;
221};
222
223METHOD struct pci_devinfo * alloc_devinfo {
224	device_t	dev;
225};
226
227METHOD void child_added {
228	device_t	dev;
229	device_t	child;
230};
231
232METHOD int iov_attach {
233	device_t	dev;
234	device_t	child;
235	struct nvlist	*pf_schema;
236	struct nvlist	*vf_schema;
237};
238
239METHOD int iov_detach {
240	device_t	dev;
241	device_t	child;
242};
243
244METHOD device_t create_iov_child {
245	device_t bus;
246	device_t pf;
247	uint16_t rid;
248	uint16_t vid;
249	uint16_t did;
250} DEFAULT null_create_iov_child;
251