xref: /freebsd/share/man/man9/pci.9 (revision 82d692771239f1d156a875087dff4cf09f0e8b80)
1aac0aafaSHiten Pandya.\"
2bf1639eeSBruce M Simpson.\" Copyright (c) 2005 Bruce M Simpson <bms@FreeBSD.org>
3aac0aafaSHiten Pandya.\" All rights reserved.
4aac0aafaSHiten Pandya.\"
5aac0aafaSHiten Pandya.\" Redistribution and use in source and binary forms, with or without
6aac0aafaSHiten Pandya.\" modification, are permitted provided that the following conditions
7aac0aafaSHiten Pandya.\" are met:
8aac0aafaSHiten Pandya.\" 1. Redistributions of source code must retain the above copyright
9aac0aafaSHiten Pandya.\"    notice, this list of conditions and the following disclaimer.
10aac0aafaSHiten Pandya.\" 2. Redistributions in binary form must reproduce the above copyright
11aac0aafaSHiten Pandya.\"    notice, this list of conditions and the following disclaimer in the
12aac0aafaSHiten Pandya.\"    documentation and/or other materials provided with the distribution.
13aac0aafaSHiten Pandya.\"
14aac0aafaSHiten Pandya.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15aac0aafaSHiten Pandya.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16aac0aafaSHiten Pandya.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17aac0aafaSHiten Pandya.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18aac0aafaSHiten Pandya.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19aac0aafaSHiten Pandya.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20aac0aafaSHiten Pandya.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21aac0aafaSHiten Pandya.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22aac0aafaSHiten Pandya.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23aac0aafaSHiten Pandya.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24aac0aafaSHiten Pandya.\" SUCH DAMAGE.
25aac0aafaSHiten Pandya.\"
26c1a14887SCeri Davies.Dd May 20, 2021
27aac0aafaSHiten Pandya.Dt PCI 9
28aac0aafaSHiten Pandya.Os
29aac0aafaSHiten Pandya.Sh NAME
30aac0aafaSHiten Pandya.Nm pci ,
31855ed4c5SJohn Baldwin.Nm pci_alloc_msi ,
32855ed4c5SJohn Baldwin.Nm pci_alloc_msix ,
33*82d69277SJohn Baldwin.Nm pci_clear_pme ,
34aac0aafaSHiten Pandya.Nm pci_disable_busmaster ,
35aac0aafaSHiten Pandya.Nm pci_disable_io ,
360a9c80e5SJohn Baldwin.Nm pci_enable_busmaster ,
370a9c80e5SJohn Baldwin.Nm pci_enable_io ,
38aac0aafaSHiten Pandya.Nm pci_find_bsf ,
39855ed4c5SJohn Baldwin.Nm pci_find_cap ,
4055aaf894SMarius Strobl.Nm pci_find_dbsf ,
410a9c80e5SJohn Baldwin.Nm pci_find_device ,
4268bf9717SJohn Baldwin.Nm pci_find_extcap ,
4368bf9717SJohn Baldwin.Nm pci_find_htcap ,
447a16dacdSBryan Venteicher.Nm pci_find_next_cap ,
457a16dacdSBryan Venteicher.Nm pci_find_next_extcap ,
467a16dacdSBryan Venteicher.Nm pci_find_next_htcap ,
4787dd2f95SJohn Baldwin.Nm pci_find_pcie_root_port ,
48d7be980dSAndrew Turner.Nm pci_get_id ,
492ab0398dSJohn Baldwin.Nm pci_get_max_payload ,
50855ed4c5SJohn Baldwin.Nm pci_get_max_read_req ,
510a9c80e5SJohn Baldwin.Nm pci_get_powerstate ,
52855ed4c5SJohn Baldwin.Nm pci_get_vpd_ident ,
53855ed4c5SJohn Baldwin.Nm pci_get_vpd_readonly ,
547d971e36SRyan Stone.Nm pci_iov_attach ,
550aee83ccSJohn Baldwin.Nm pci_iov_attach_name ,
567d971e36SRyan Stone.Nm pci_iov_detach ,
57855ed4c5SJohn Baldwin.Nm pci_msi_count ,
58855ed4c5SJohn Baldwin.Nm pci_msix_count ,
59ce204e1bSJohn Baldwin.Nm pci_msix_pba_bar ,
60ce204e1bSJohn Baldwin.Nm pci_msix_table_bar ,
61855ed4c5SJohn Baldwin.Nm pci_pending_msix ,
620a9c80e5SJohn Baldwin.Nm pci_read_config ,
63855ed4c5SJohn Baldwin.Nm pci_release_msi ,
64855ed4c5SJohn Baldwin.Nm pci_remap_msix ,
650a9c80e5SJohn Baldwin.Nm pci_restore_state ,
660a9c80e5SJohn Baldwin.Nm pci_save_state ,
67855ed4c5SJohn Baldwin.Nm pci_set_max_read_req ,
680a9c80e5SJohn Baldwin.Nm pci_set_powerstate ,
69ec603c72SJohn Baldwin.Nm pci_write_config ,
70ec603c72SJohn Baldwin.Nm pcie_adjust_config ,
71da0fc925SJohn Baldwin.Nm pcie_flr ,
72da0fc925SJohn Baldwin.Nm pcie_get_max_completion_timeout ,
73ec603c72SJohn Baldwin.Nm pcie_read_config ,
74da0fc925SJohn Baldwin.Nm pcie_wait_for_pending_transactions ,
75ec603c72SJohn Baldwin.Nm pcie_write_config
76aac0aafaSHiten Pandya.Nd PCI bus interface
77aac0aafaSHiten Pandya.Sh SYNOPSIS
78aac0aafaSHiten Pandya.In sys/bus.h
79aac0aafaSHiten Pandya.In dev/pci/pcireg.h
80855ed4c5SJohn Baldwin.In dev/pci/pcivar.h
81855ed4c5SJohn Baldwin.Ft int
82855ed4c5SJohn Baldwin.Fn pci_alloc_msi "device_t dev" "int *count"
83855ed4c5SJohn Baldwin.Ft int
84855ed4c5SJohn Baldwin.Fn pci_alloc_msix "device_t dev" "int *count"
85*82d69277SJohn Baldwin.Ft void
86*82d69277SJohn Baldwin.Fn pci_clear_pme "device_t dev"
87aac0aafaSHiten Pandya.Ft int
88aac0aafaSHiten Pandya.Fn pci_disable_busmaster "device_t dev"
89aac0aafaSHiten Pandya.Ft int
90aac0aafaSHiten Pandya.Fn pci_disable_io "device_t dev" "int space"
91aac0aafaSHiten Pandya.Ft int
920a9c80e5SJohn Baldwin.Fn pci_enable_busmaster "device_t dev"
93aac0aafaSHiten Pandya.Ft int
940a9c80e5SJohn Baldwin.Fn pci_enable_io "device_t dev" "int space"
95aac0aafaSHiten Pandya.Ft device_t
9665bb31b8SRuslan Ermilov.Fn pci_find_bsf "uint8_t bus" "uint8_t slot" "uint8_t func"
97855ed4c5SJohn Baldwin.Ft int
98855ed4c5SJohn Baldwin.Fn pci_find_cap "device_t dev" "int capability" "int *capreg"
99aac0aafaSHiten Pandya.Ft device_t
10055aaf894SMarius Strobl.Fn pci_find_dbsf "uint32_t domain" "uint8_t bus" "uint8_t slot" "uint8_t func"
10155aaf894SMarius Strobl.Ft device_t
10265bb31b8SRuslan Ermilov.Fn pci_find_device "uint16_t vendor" "uint16_t device"
1030a9c80e5SJohn Baldwin.Ft int
10468bf9717SJohn Baldwin.Fn pci_find_extcap "device_t dev" "int capability" "int *capreg"
10568bf9717SJohn Baldwin.Ft int
10668bf9717SJohn Baldwin.Fn pci_find_htcap "device_t dev" "int capability" "int *capreg"
1077a16dacdSBryan Venteicher.Ft int
1087a16dacdSBryan Venteicher.Fn pci_find_next_cap "device_t dev" "int capability" "int start" "int *capreg"
1097a16dacdSBryan Venteicher.Ft int
1107a16dacdSBryan Venteicher.Fn pci_find_next_extcap "device_t dev" "int capability" "int start" "int *capreg"
1117a16dacdSBryan Venteicher.Ft int
1127a16dacdSBryan Venteicher.Fn pci_find_next_htcap "device_t dev" "int capability" "int start" "int *capreg"
11387dd2f95SJohn Baldwin.Ft device_t
11487dd2f95SJohn Baldwin.Fn pci_find_pcie_root_port "device_t dev"
11568bf9717SJohn Baldwin.Ft int
116d7be980dSAndrew Turner.Fn pci_get_id "device_t dev" "enum pci_id_type type" "uintptr_t *id"
117d7be980dSAndrew Turner.Ft int
1182ab0398dSJohn Baldwin.Fn pci_get_max_payload "device_t dev"
1192ab0398dSJohn Baldwin.Ft int
120855ed4c5SJohn Baldwin.Fn pci_get_max_read_req "device_t dev"
121855ed4c5SJohn Baldwin.Ft int
1220a9c80e5SJohn Baldwin.Fn pci_get_powerstate "device_t dev"
123855ed4c5SJohn Baldwin.Ft int
124855ed4c5SJohn Baldwin.Fn pci_get_vpd_ident "device_t dev" "const char **identptr"
125855ed4c5SJohn Baldwin.Ft int
126855ed4c5SJohn Baldwin.Fn pci_get_vpd_readonly "device_t dev" "const char *kw" "const char **vptr"
127855ed4c5SJohn Baldwin.Ft int
128855ed4c5SJohn Baldwin.Fn pci_msi_count "device_t dev"
129855ed4c5SJohn Baldwin.Ft int
130855ed4c5SJohn Baldwin.Fn pci_msix_count "device_t dev"
131855ed4c5SJohn Baldwin.Ft int
132ce204e1bSJohn Baldwin.Fn pci_msix_pba_bar "device_t dev"
133ce204e1bSJohn Baldwin.Ft int
134ce204e1bSJohn Baldwin.Fn pci_msix_table_bar "device_t dev"
135ce204e1bSJohn Baldwin.Ft int
136855ed4c5SJohn Baldwin.Fn pci_pending_msix "device_t dev" "u_int index"
1370a9c80e5SJohn Baldwin.Ft uint32_t
1380a9c80e5SJohn Baldwin.Fn pci_read_config "device_t dev" "int reg" "int width"
139855ed4c5SJohn Baldwin.Ft int
140855ed4c5SJohn Baldwin.Fn pci_release_msi "device_t dev"
141855ed4c5SJohn Baldwin.Ft int
142855ed4c5SJohn Baldwin.Fn pci_remap_msix "device_t dev" "int count" "const u_int *vectors"
1430a9c80e5SJohn Baldwin.Ft void
1440a9c80e5SJohn Baldwin.Fn pci_restore_state "device_t dev"
1450a9c80e5SJohn Baldwin.Ft void
1460a9c80e5SJohn Baldwin.Fn pci_save_state "device_t dev"
1470a9c80e5SJohn Baldwin.Ft int
148855ed4c5SJohn Baldwin.Fn pci_set_max_read_req "device_t dev" "int size"
149855ed4c5SJohn Baldwin.Ft int
1500a9c80e5SJohn Baldwin.Fn pci_set_powerstate "device_t dev" "int state"
1510a9c80e5SJohn Baldwin.Ft void
1520a9c80e5SJohn Baldwin.Fn pci_write_config "device_t dev" "int reg" "uint32_t val" "int width"
153ec603c72SJohn Baldwin.Ft uint32_t
154ec603c72SJohn Baldwin.Fo pcie_adjust_config
155ec603c72SJohn Baldwin.Fa "device_t dev"
156ec603c72SJohn Baldwin.Fa "int reg"
157ec603c72SJohn Baldwin.Fa "uint32_t mask"
158ec603c72SJohn Baldwin.Fa "uint32_t val"
159ec603c72SJohn Baldwin.Fa "int width"
160ec603c72SJohn Baldwin.Fc
161da0fc925SJohn Baldwin.Ft bool
162da0fc925SJohn Baldwin.Fn pcie_flr "device_t dev" "u_int max_delay" "bool force"
163da0fc925SJohn Baldwin.Ft int
164da0fc925SJohn Baldwin.Fn pcie_get_max_completion_timeout "device_t dev"
165ec603c72SJohn Baldwin.Ft uint32_t
166ec603c72SJohn Baldwin.Fn pcie_read_config "device_t dev" "int reg" "int width"
167da0fc925SJohn Baldwin.Ft bool
168da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions "device_t dev" "u_int max_delay"
169ec603c72SJohn Baldwin.Ft void
170ec603c72SJohn Baldwin.Fn pcie_write_config "device_t dev" "int reg" "uint32_t val" "int width"
17164414cc0SJohn Baldwin.Ft void
17264414cc0SJohn Baldwin.Fn pci_event_fn "void *arg" "device_t dev"
17364414cc0SJohn Baldwin.Fn EVENTHANDLER_REGISTER "pci_add_device" "pci_event_fn"
17464414cc0SJohn Baldwin.Fn EVENTHANDLER_DEREGISTER "pci_delete_resource" "pci_event_fn"
175f3bb9251SJohn Baldwin.In dev/pci/pci_iov.h
176f3bb9251SJohn Baldwin.Ft int
177f3bb9251SJohn Baldwin.Fn pci_iov_attach "device_t dev" "nvlist_t *pf_schema" "nvlist_t *vf_schema"
178f3bb9251SJohn Baldwin.Ft int
1790aee83ccSJohn Baldwin.Fo pci_iov_attach_name
1800aee83ccSJohn Baldwin.Fa "device_t dev"
1810aee83ccSJohn Baldwin.Fa "nvlist_t *pf_schema"
1820aee83ccSJohn Baldwin.Fa "nvlist_t *vf_schema"
1830aee83ccSJohn Baldwin.Fa "const char *fmt"
1840aee83ccSJohn Baldwin.Fa "..."
1850aee83ccSJohn Baldwin.Fc
1860aee83ccSJohn Baldwin.Ft int
187f3bb9251SJohn Baldwin.Fn pci_iov_detach "device_t dev"
188aac0aafaSHiten Pandya.Sh DESCRIPTION
189aac0aafaSHiten PandyaThe
190aac0aafaSHiten Pandya.Nm
191aac0aafaSHiten Pandyaset of functions are used for managing PCI devices.
192855ed4c5SJohn BaldwinThe functions are split into several groups:
193855ed4c5SJohn Baldwinraw configuration access,
194855ed4c5SJohn Baldwinlocating devices,
195855ed4c5SJohn Baldwindevice information,
196855ed4c5SJohn Baldwindevice configuration,
197855ed4c5SJohn Baldwinand
198855ed4c5SJohn Baldwinmessage signaled interrupts.
199855ed4c5SJohn Baldwin.Ss Raw Configuration Access
200aac0aafaSHiten PandyaThe
201aac0aafaSHiten Pandya.Fn pci_read_config
202aac0aafaSHiten Pandyafunction is used to read data from the PCI configuration
203aac0aafaSHiten Pandyaspace of the device
204aac0aafaSHiten Pandya.Fa dev ,
205aac0aafaSHiten Pandyaat offset
206aac0aafaSHiten Pandya.Fa reg ,
207aac0aafaSHiten Pandyawith
208aac0aafaSHiten Pandya.Fa width
209aac0aafaSHiten Pandyaspecifying the size of the access.
210aac0aafaSHiten Pandya.Pp
211aac0aafaSHiten PandyaThe
212aac0aafaSHiten Pandya.Fn pci_write_config
213aac0aafaSHiten Pandyafunction is used to write the value
214aac0aafaSHiten Pandya.Fa val
215aac0aafaSHiten Pandyato the PCI configuration
216aac0aafaSHiten Pandyaspace of the device
217aac0aafaSHiten Pandya.Fa dev ,
218aac0aafaSHiten Pandyaat offset
219aac0aafaSHiten Pandya.Fa reg ,
220aac0aafaSHiten Pandyawith
221aac0aafaSHiten Pandya.Fa width
222aac0aafaSHiten Pandyaspecifying the size of the access.
223aac0aafaSHiten Pandya.Pp
224ec603c72SJohn BaldwinThe
225ec603c72SJohn Baldwin.Fn pcie_adjust_config
226ec603c72SJohn Baldwinfunction is used to modify the value of a register in the PCI-express
227ec603c72SJohn Baldwincapability register set of device
228ec603c72SJohn Baldwin.Fa dev .
229ec603c72SJohn BaldwinThe offset
230ec603c72SJohn Baldwin.Fa reg
231ec603c72SJohn Baldwinspecifies a relative offset in the register set with
232ec603c72SJohn Baldwin.Fa width
233ec603c72SJohn Baldwinspecifying the size of the access.
234ec603c72SJohn BaldwinThe new value of the register is computed by modifying bits set in
235ec603c72SJohn Baldwin.Fa mask
236ec603c72SJohn Baldwinto the value in
237ec603c72SJohn Baldwin.Fa val .
238ec603c72SJohn BaldwinAny bits not specified in
239ec603c72SJohn Baldwin.Fa mask
240ec603c72SJohn Baldwinare preserved.
241ec603c72SJohn BaldwinThe previous value of the register is returned.
242ec603c72SJohn Baldwin.Pp
243ec603c72SJohn BaldwinThe
244ec603c72SJohn Baldwin.Fn pcie_read_config
245ec603c72SJohn Baldwinfunction is used to read the value of a register in the PCI-express
246ec603c72SJohn Baldwincapability register set of device
247ec603c72SJohn Baldwin.Fa dev .
248ec603c72SJohn BaldwinThe offset
249ec603c72SJohn Baldwin.Fa reg
250ec603c72SJohn Baldwinspecifies a relative offset in the register set with
251ec603c72SJohn Baldwin.Fa width
252ec603c72SJohn Baldwinspecifying the size of the access.
253ec603c72SJohn Baldwin.Pp
254ec603c72SJohn BaldwinThe
255ec603c72SJohn Baldwin.Fn pcie_write_config
256ec603c72SJohn Baldwinfunction is used to write the value
257ec603c72SJohn Baldwin.Fa val
258ec603c72SJohn Baldwinto a register in the PCI-express capability register set of device
259ec603c72SJohn Baldwin.Fa dev .
260ec603c72SJohn BaldwinThe offset
261ec603c72SJohn Baldwin.Fa reg
262ec603c72SJohn Baldwinspecifies a relative offset in the register set with
263ec603c72SJohn Baldwin.Fa width
264ec603c72SJohn Baldwinspecifying the size of the access.
265ec603c72SJohn Baldwin.Pp
266855ed4c5SJohn Baldwin.Em NOTE :
267855ed4c5SJohn BaldwinDevice drivers should only use these functions for functionality that
268855ed4c5SJohn Baldwinis not available via another
269855ed4c5SJohn Baldwin.Fn pci
270855ed4c5SJohn Baldwinfunction.
271855ed4c5SJohn Baldwin.Ss Locating Devices
272855ed4c5SJohn BaldwinThe
273855ed4c5SJohn Baldwin.Fn pci_find_bsf
274855ed4c5SJohn Baldwinfunction looks up the
275855ed4c5SJohn Baldwin.Vt device_t
276855ed4c5SJohn Baldwinof a PCI device, given its
277855ed4c5SJohn Baldwin.Fa bus ,
278855ed4c5SJohn Baldwin.Fa slot ,
279855ed4c5SJohn Baldwinand
280855ed4c5SJohn Baldwin.Fa func .
281855ed4c5SJohn BaldwinThe
282855ed4c5SJohn Baldwin.Fa slot
283855ed4c5SJohn Baldwinnumber actually refers to the number of the device on the bus,
284855ed4c5SJohn Baldwinwhich does not necessarily indicate its geographic location
285855ed4c5SJohn Baldwinin terms of a physical slot.
286855ed4c5SJohn BaldwinNote that in case the system has multiple PCI domains,
287855ed4c5SJohn Baldwinthe
288855ed4c5SJohn Baldwin.Fn pci_find_bsf
289855ed4c5SJohn Baldwinfunction only searches the first one.
290855ed4c5SJohn BaldwinActually, it is equivalent to:
291855ed4c5SJohn Baldwin.Bd -literal -offset indent
292855ed4c5SJohn Baldwinpci_find_dbsf(0, bus, slot, func);
293855ed4c5SJohn Baldwin.Ed
294855ed4c5SJohn Baldwin.Pp
295855ed4c5SJohn BaldwinThe
296855ed4c5SJohn Baldwin.Fn pci_find_dbsf
297855ed4c5SJohn Baldwinfunction looks up the
298855ed4c5SJohn Baldwin.Vt device_t
299855ed4c5SJohn Baldwinof a PCI device, given its
300855ed4c5SJohn Baldwin.Fa domain ,
301855ed4c5SJohn Baldwin.Fa bus ,
302855ed4c5SJohn Baldwin.Fa slot ,
303855ed4c5SJohn Baldwinand
304855ed4c5SJohn Baldwin.Fa func .
305855ed4c5SJohn BaldwinThe
306855ed4c5SJohn Baldwin.Fa slot
307855ed4c5SJohn Baldwinnumber actually refers to the number of the device on the bus,
308855ed4c5SJohn Baldwinwhich does not necessarily indicate its geographic location
309855ed4c5SJohn Baldwinin terms of a physical slot.
310855ed4c5SJohn Baldwin.Pp
311855ed4c5SJohn BaldwinThe
312855ed4c5SJohn Baldwin.Fn pci_find_device
313855ed4c5SJohn Baldwinfunction looks up the
314855ed4c5SJohn Baldwin.Vt device_t
315855ed4c5SJohn Baldwinof a PCI device, given its
316855ed4c5SJohn Baldwin.Fa vendor
317855ed4c5SJohn Baldwinand
318855ed4c5SJohn Baldwin.Fa device
319855ed4c5SJohn BaldwinIDs.
320855ed4c5SJohn BaldwinNote that there can be multiple matches for this search; this function
321855ed4c5SJohn Baldwinonly returns the first matching device.
322855ed4c5SJohn Baldwin.Ss Device Information
323855ed4c5SJohn BaldwinThe
324855ed4c5SJohn Baldwin.Fn pci_find_cap
325855ed4c5SJohn Baldwinfunction is used to locate the first instance of a PCI capability
326855ed4c5SJohn Baldwinregister set for the device
327855ed4c5SJohn Baldwin.Fa dev .
328855ed4c5SJohn BaldwinThe capability to locate is specified by ID via
329855ed4c5SJohn Baldwin.Fa capability .
330855ed4c5SJohn BaldwinConstant macros of the form
331855ed4c5SJohn Baldwin.Dv PCIY_xxx
332855ed4c5SJohn Baldwinfor standard capability IDs are defined in
333855ed4c5SJohn Baldwin.In dev/pci/pcireg.h .
334855ed4c5SJohn BaldwinIf the capability is found, then
335855ed4c5SJohn Baldwin.Fa *capreg
336281a359eSJohn Baldwinis set to the offset in configuration space of the capability register set,
337855ed4c5SJohn Baldwinand
338855ed4c5SJohn Baldwin.Fn pci_find_cap
339855ed4c5SJohn Baldwinreturns zero.
340855ed4c5SJohn BaldwinIf the capability is not found or the device does not support capabilities,
341855ed4c5SJohn Baldwin.Fn pci_find_cap
342855ed4c5SJohn Baldwinreturns an error.
3437a16dacdSBryan VenteicherThe
3447a16dacdSBryan Venteicher.Fn pci_find_next_cap
3457a16dacdSBryan Venteicherfunction is used to locate the next instance of a PCI capability
3467a16dacdSBryan Venteicherregister set for the device
3477a16dacdSBryan Venteicher.Fa dev .
3487a16dacdSBryan VenteicherThe
3497a16dacdSBryan Venteicher.Fa start
3507a16dacdSBryan Venteichershould be the
3517a16dacdSBryan Venteicher.Fa *capreg
3527a16dacdSBryan Venteicherreturned by a prior
3537a16dacdSBryan Venteicher.Fn pci_find_cap
3547a16dacdSBryan Venteicheror
3557a16dacdSBryan Venteicher.Fn pci_find_next_cap .
3567a16dacdSBryan VenteicherWhen no more instances are located
3577a16dacdSBryan Venteicher.Fn pci_find_next_cap
3587a16dacdSBryan Venteicherreturns an error.
359855ed4c5SJohn Baldwin.Pp
360855ed4c5SJohn BaldwinThe
36168bf9717SJohn Baldwin.Fn pci_find_extcap
36268bf9717SJohn Baldwinfunction is used to locate the first instance of a PCI-express
36368bf9717SJohn Baldwinextended capability register set for the device
36468bf9717SJohn Baldwin.Fa dev .
36568bf9717SJohn BaldwinThe extended capability to locate is specified by ID via
36668bf9717SJohn Baldwin.Fa capability .
36768bf9717SJohn BaldwinConstant macros of the form
36868bf9717SJohn Baldwin.Dv PCIZ_xxx
36968bf9717SJohn Baldwinfor standard extended capability IDs are defined in
37068bf9717SJohn Baldwin.In dev/pci/pcireg.h .
37168bf9717SJohn BaldwinIf the extended capability is found, then
37268bf9717SJohn Baldwin.Fa *capreg
373281a359eSJohn Baldwinis set to the offset in configuration space of the extended capability
37468bf9717SJohn Baldwinregister set, and
37568bf9717SJohn Baldwin.Fn pci_find_extcap
37668bf9717SJohn Baldwinreturns zero.
37768bf9717SJohn BaldwinIf the extended capability is not found or the device is not a
37868bf9717SJohn BaldwinPCI-express device,
37968bf9717SJohn Baldwin.Fn pci_find_extcap
38068bf9717SJohn Baldwinreturns an error.
3817a16dacdSBryan VenteicherThe
3827a16dacdSBryan Venteicher.Fn pci_find_next_extcap
3837a16dacdSBryan Venteicherfunction is used to locate the next instance of a PCI-express
3847a16dacdSBryan Venteicherextended capability register set for the device
3857a16dacdSBryan Venteicher.Fa dev .
3867a16dacdSBryan VenteicherThe
3877a16dacdSBryan Venteicher.Fa start
3887a16dacdSBryan Venteichershould be the
3897a16dacdSBryan Venteicher.Fa *capreg
3907a16dacdSBryan Venteicherreturned by a prior
3917a16dacdSBryan Venteicher.Fn pci_find_extcap
3927a16dacdSBryan Venteicheror
3937a16dacdSBryan Venteicher.Fn pci_find_next_extcap .
3947a16dacdSBryan VenteicherWhen no more instances are located
3957a16dacdSBryan Venteicher.Fn pci_find_next_extcap
3967a16dacdSBryan Venteicherreturns an error.
39768bf9717SJohn Baldwin.Pp
39868bf9717SJohn BaldwinThe
39968bf9717SJohn Baldwin.Fn pci_find_htcap
40068bf9717SJohn Baldwinfunction is used to locate the first instance of a HyperTransport capability
40168bf9717SJohn Baldwinregister set for the device
40268bf9717SJohn Baldwin.Fa dev .
40368bf9717SJohn BaldwinThe capability to locate is specified by type via
40468bf9717SJohn Baldwin.Fa capability .
40568bf9717SJohn BaldwinConstant macros of the form
40668bf9717SJohn Baldwin.Dv PCIM_HTCAP_xxx
40768bf9717SJohn Baldwinfor standard HyperTransport capability types are defined in
40868bf9717SJohn Baldwin.In dev/pci/pcireg.h .
40968bf9717SJohn BaldwinIf the capability is found, then
41068bf9717SJohn Baldwin.Fa *capreg
411281a359eSJohn Baldwinis set to the offset in configuration space of the capability register set,
41268bf9717SJohn Baldwinand
41368bf9717SJohn Baldwin.Fn pci_find_htcap
41468bf9717SJohn Baldwinreturns zero.
41568bf9717SJohn BaldwinIf the capability is not found or the device is not a HyperTransport device,
41668bf9717SJohn Baldwin.Fn pci_find_htcap
41768bf9717SJohn Baldwinreturns an error.
4187a16dacdSBryan VenteicherThe
4197a16dacdSBryan Venteicher.Fn pci_find_next_htcap
4207a16dacdSBryan Venteicherfunction is used to locate the next instance of a HyperTransport capability
4217a16dacdSBryan Venteicherregister set for the device
4227a16dacdSBryan Venteicher.Fa dev .
4237a16dacdSBryan VenteicherThe
4247a16dacdSBryan Venteicher.Fa start
4257a16dacdSBryan Venteichershould be the
4267a16dacdSBryan Venteicher.Fa *capreg
4277a16dacdSBryan Venteicherreturned by a prior
4287a16dacdSBryan Venteicher.Fn pci_find_htcap
4297a16dacdSBryan Venteicheror
4307a16dacdSBryan Venteicher.Fn pci_find_next_htcap .
4317a16dacdSBryan VenteicherWhen no more instances are located
4327a16dacdSBryan Venteicher.Fn pci_find_next_htcap
4337a16dacdSBryan Venteicherreturns an error.
43468bf9717SJohn Baldwin.Pp
43568bf9717SJohn BaldwinThe
43687dd2f95SJohn Baldwin.Fn pci_find_pcie_root_port
43787dd2f95SJohn Baldwinfunction walks up the PCI device hierarchy to locate the PCI-express root
43887dd2f95SJohn Baldwinport upstream of
43987dd2f95SJohn Baldwin.Fa dev .
44087dd2f95SJohn BaldwinIf a root port is not found,
44187dd2f95SJohn Baldwin.Fn pci_find_pcie_root_port
44287dd2f95SJohn Baldwinreturns
44387dd2f95SJohn Baldwin.Dv NULL .
44487dd2f95SJohn Baldwin.Pp
44587dd2f95SJohn BaldwinThe
446d7be980dSAndrew Turner.Fn pci_get_id
447d7be980dSAndrew Turnerfunction is used to read an identifier from a device.
448d7be980dSAndrew TurnerThe
449d7be980dSAndrew Turner.Fa type
450d7be980dSAndrew Turnerflag is used to specify which identifier to read.
451d7be980dSAndrew TurnerThe following flags are supported:
452d7be980dSAndrew Turner.Bl -hang -width ".Dv PCI_ID_RID"
453d7be980dSAndrew Turner.It Dv PCI_ID_RID
454d7be980dSAndrew TurnerRead the routing identifier for the device.
4551e43b18cSAndrew Turner.It Dv PCI_ID_MSI
4561e43b18cSAndrew TurnerRead the MSI routing ID.
4571e43b18cSAndrew TurnerThis is needed by some interrupt controllers to route MSI and MSI-X interrupts.
458d7be980dSAndrew Turner.El
459d7be980dSAndrew Turner.Pp
460d7be980dSAndrew TurnerThe
461855ed4c5SJohn Baldwin.Fn pci_get_vpd_ident
462855ed4c5SJohn Baldwinfunction is used to fetch a device's Vital Product Data
463855ed4c5SJohn Baldwin.Pq VPD
464855ed4c5SJohn Baldwinidentifier string.
465855ed4c5SJohn BaldwinIf the device
466855ed4c5SJohn Baldwin.Fa dev
467855ed4c5SJohn Baldwinsupports VPD and provides an identifier string,
468855ed4c5SJohn Baldwinthen
469855ed4c5SJohn Baldwin.Fa *identptr
470855ed4c5SJohn Baldwinis set to point at a read-only, null-terminated copy of the identifier
471855ed4c5SJohn Baldwinstring,
472855ed4c5SJohn Baldwinand
473855ed4c5SJohn Baldwin.Fn pci_get_vpd_ident
474855ed4c5SJohn Baldwinreturns zero.
475855ed4c5SJohn BaldwinIf the device does not support VPD or does not provide an identifier
476855ed4c5SJohn Baldwinstring,
477855ed4c5SJohn Baldwinthen
478855ed4c5SJohn Baldwin.Fn pci_get_vpd_ident
479855ed4c5SJohn Baldwinreturns an error.
480855ed4c5SJohn Baldwin.Pp
481855ed4c5SJohn BaldwinThe
482855ed4c5SJohn Baldwin.Fn pci_get_vpd_readonly
483855ed4c5SJohn Baldwinfunction is used to fetch the value of a single VPD read-only keyword
484855ed4c5SJohn Baldwinfor the device
485855ed4c5SJohn Baldwin.Fa dev .
486855ed4c5SJohn BaldwinThe keyword to fetch is identified by the two character string
487855ed4c5SJohn Baldwin.Fa kw .
488855ed4c5SJohn BaldwinIf the device supports VPD and provides a read-only value for the
489855ed4c5SJohn Baldwinrequested keyword,
490855ed4c5SJohn Baldwinthen
491855ed4c5SJohn Baldwin.Fa *vptr
492855ed4c5SJohn Baldwinis set to point at a read-only, null-terminated copy of the value,
493855ed4c5SJohn Baldwinand
494855ed4c5SJohn Baldwin.Fn pci_get_vpd_readonly
495855ed4c5SJohn Baldwinreturns zero.
496855ed4c5SJohn BaldwinIf the device does not support VPD or does not provide the requested
497855ed4c5SJohn Baldwinkeyword,
498855ed4c5SJohn Baldwinthen
499855ed4c5SJohn Baldwin.Fn pci_get_vpd_readonly
500855ed4c5SJohn Baldwinreturns an error.
501da0fc925SJohn Baldwin.Pp
502da0fc925SJohn BaldwinThe
503da0fc925SJohn Baldwin.Fn pcie_get_max_completion_timeout
504da0fc925SJohn Baldwinfunction returns the maximum completion timeout configured for the device
505da0fc925SJohn Baldwin.Fa dev
506da0fc925SJohn Baldwinin microseconds.
507da0fc925SJohn BaldwinIf the
508da0fc925SJohn Baldwin.Fa dev
509da0fc925SJohn Baldwindevice is not a PCI-express device,
510da0fc925SJohn Baldwin.Fn pcie_get_max_completion_timeout
511da0fc925SJohn Baldwinreturns zero.
512da0fc925SJohn BaldwinWhen completion timeouts are disabled for
513da0fc925SJohn Baldwin.Fa dev ,
514da0fc925SJohn Baldwinthis function returns the maxmimum timeout that would be used if timeouts
515da0fc925SJohn Baldwinwere enabled.
516da0fc925SJohn Baldwin.Pp
517da0fc925SJohn BaldwinThe
518da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions
519da0fc925SJohn Baldwinfunction waits for any pending transactions initiated by the
520da0fc925SJohn Baldwin.Fa dev
521da0fc925SJohn Baldwindevice to complete.
522da0fc925SJohn BaldwinThe function checks for pending transactions by polling the transactions
523da0fc925SJohn Baldwinpending flag in the PCI-express device status register.
524da0fc925SJohn BaldwinIt returns
525da0fc925SJohn Baldwin.Dv true
526da0fc925SJohn Baldwinonce the transaction pending flag is clear.
527da0fc925SJohn BaldwinIf transactions are still pending after
528da0fc925SJohn Baldwin.Fa max_delay
529da0fc925SJohn Baldwinmilliseconds,
530da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions
531da0fc925SJohn Baldwinreturns
532da0fc925SJohn Baldwin.Dv false .
533da0fc925SJohn BaldwinIf
534da0fc925SJohn Baldwin.Fa max_delay
535da0fc925SJohn Baldwinis set to zero,
536da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions
537da0fc925SJohn Baldwinperforms a single check;
538da0fc925SJohn Baldwinotherwise,
539da0fc925SJohn Baldwinthis function may sleep while polling the transactions pending flag.
540da0fc925SJohn Baldwin.Nm pcie_wait_for_pending_transactions
541da0fc925SJohn Baldwinreturns
542da0fc925SJohn Baldwin.Dv true
543da0fc925SJohn Baldwinif
544da0fc925SJohn Baldwin.Fa dev
545da0fc925SJohn Baldwinis not a PCI-express device.
546855ed4c5SJohn Baldwin.Ss Device Configuration
547aac0aafaSHiten PandyaThe
548aac0aafaSHiten Pandya.Fn pci_enable_busmaster
549aac0aafaSHiten Pandyafunction enables PCI bus mastering for the device
550aac0aafaSHiten Pandya.Fa dev ,
551aac0aafaSHiten Pandyaby setting the
552aac0aafaSHiten Pandya.Dv PCIM_CMD_BUSMASTEREN
553aac0aafaSHiten Pandyabit in the
554aac0aafaSHiten Pandya.Dv PCIR_COMMAND
555aac0aafaSHiten Pandyaregister.
556aac0aafaSHiten PandyaThe
557aac0aafaSHiten Pandya.Fn pci_disable_busmaster
558aac0aafaSHiten Pandyafunction clears this bit.
559aac0aafaSHiten Pandya.Pp
560aac0aafaSHiten PandyaThe
561aac0aafaSHiten Pandya.Fn pci_enable_io
562aac0aafaSHiten Pandyafunction enables memory or I/O port address decoding for the device
563aac0aafaSHiten Pandya.Fa dev ,
564aac0aafaSHiten Pandyaby setting the
565aac0aafaSHiten Pandya.Dv PCIM_CMD_MEMEN
566aac0aafaSHiten Pandyaor
567aac0aafaSHiten Pandya.Dv PCIM_CMD_PORTEN
568aac0aafaSHiten Pandyabit in the
569aac0aafaSHiten Pandya.Dv PCIR_COMMAND
5705203edcdSRuslan Ermilovregister appropriately.
5715203edcdSRuslan ErmilovThe
572aac0aafaSHiten Pandya.Fn pci_disable_io
573aac0aafaSHiten Pandyafunction clears the appropriate bit.
574aac0aafaSHiten PandyaThe
57565bb31b8SRuslan Ermilov.Fa space
576aac0aafaSHiten Pandyaargument specifies which resource is affected; this can be either
577aac0aafaSHiten Pandya.Dv SYS_RES_MEMORY
578aac0aafaSHiten Pandyaor
579aac0aafaSHiten Pandya.Dv SYS_RES_IOPORT
580aac0aafaSHiten Pandyaas appropriate.
581855ed4c5SJohn BaldwinDevice drivers should generally not use these routines directly.
582855ed4c5SJohn BaldwinThe PCI bus will enable decoding automatically when a
583855ed4c5SJohn Baldwin.Dv SYS_RES_MEMORY
584855ed4c5SJohn Baldwinor
585855ed4c5SJohn Baldwin.Dv SYS_RES_IOPORT
586855ed4c5SJohn Baldwinresource is activated via
587855ed4c5SJohn Baldwin.Xr bus_alloc_resource 9
588855ed4c5SJohn Baldwinor
589855ed4c5SJohn Baldwin.Xr bus_activate_resource 9 .
590aac0aafaSHiten Pandya.Pp
591855ed4c5SJohn BaldwinThe
5922ab0398dSJohn Baldwin.Fn pci_get_max_payload
5932ab0398dSJohn Baldwinfunction returns the current maximum TLP payload size in bytes for a
5942ab0398dSJohn BaldwinPCI-express device.
5952ab0398dSJohn BaldwinIf the
5962ab0398dSJohn Baldwin.Fa dev
5972ab0398dSJohn Baldwindevice is not a PCI-express device,
5982ab0398dSJohn Baldwin.Fn pci_get_max_payload
5992ab0398dSJohn Baldwinreturns zero.
6002ab0398dSJohn Baldwin.Pp
6012ab0398dSJohn BaldwinThe
602855ed4c5SJohn Baldwin.Fn pci_get_max_read_req
603855ed4c5SJohn Baldwinfunction returns the current maximum read request size in bytes for a
604855ed4c5SJohn BaldwinPCI-express device.
605855ed4c5SJohn BaldwinIf the
606855ed4c5SJohn Baldwin.Fa dev
607855ed4c5SJohn Baldwindevice is not a PCI-express device,
608855ed4c5SJohn Baldwin.Fn pci_get_max_read_req
609855ed4c5SJohn Baldwinreturns zero.
610855ed4c5SJohn Baldwin.Pp
611855ed4c5SJohn BaldwinThe
612855ed4c5SJohn Baldwin.Fn pci_set_max_read_req
613855ed4c5SJohn Baldwinsets the PCI-express maximum read request size for
614855ed4c5SJohn Baldwin.Fa dev .
615855ed4c5SJohn BaldwinThe requested
616855ed4c5SJohn Baldwin.Fa size
617855ed4c5SJohn Baldwinmay be adjusted,
618855ed4c5SJohn Baldwinand
619855ed4c5SJohn Baldwin.Fn pci_set_max_read_req
620855ed4c5SJohn Baldwinreturns the actual size set in bytes.
621855ed4c5SJohn BaldwinIf the
622855ed4c5SJohn Baldwin.Fa dev
623855ed4c5SJohn Baldwindevice is not a PCI-express device,
624855ed4c5SJohn Baldwin.Fn pci_set_max_read_req
625855ed4c5SJohn Baldwinreturns zero.
626aac0aafaSHiten Pandya.Pp
627aac0aafaSHiten PandyaThe
628aac0aafaSHiten Pandya.Fn pci_get_powerstate
629adb63907SJohn Baldwinfunction returns the current power state of the device
630aac0aafaSHiten Pandya.Fa dev .
631aac0aafaSHiten PandyaIf the device does not support power management capabilities, then the default
632aac0aafaSHiten Pandyastate of
633aac0aafaSHiten Pandya.Dv PCI_POWERSTATE_D0
634aac0aafaSHiten Pandyais returned.
635adb63907SJohn BaldwinThe following power states are defined by PCI:
63665bb31b8SRuslan Ermilov.Bl -hang -width ".Dv PCI_POWERSTATE_UNKNOWN"
637aac0aafaSHiten Pandya.It Dv PCI_POWERSTATE_D0
638aac0aafaSHiten PandyaState in which device is on and running.
639aac0aafaSHiten PandyaIt is receiving full power from the system and delivering
640aac0aafaSHiten Pandyafull functionality to the user.
641aac0aafaSHiten Pandya.It Dv PCI_POWERSTATE_D1
642aac0aafaSHiten PandyaClass-specific low-power state in which device context may or
6435a2e3b61SDaniel Gerzomay not be lost.
644db4fcadfSConrad MeyerBuses in this state cannot do anything to the bus, to
6459817b894SBruce M Simpsonforce devices to lose context.
646aac0aafaSHiten Pandya.It Dv PCI_POWERSTATE_D2
647aac0aafaSHiten PandyaClass-specific low-power state in which device context may or
648aac0aafaSHiten Pandyamay not be lost.
649aac0aafaSHiten PandyaAttains greater power savings than
650aac0aafaSHiten Pandya.Dv PCI_POWERSTATE_D1 .
651db4fcadfSConrad MeyerBuses in this state can cause devices to lose some context.
652aac0aafaSHiten PandyaDevices
653aac0aafaSHiten Pandya.Em must
654aac0aafaSHiten Pandyabe prepared for the bus to be in this state or higher.
655aac0aafaSHiten Pandya.It Dv PCI_POWERSTATE_D3
656aac0aafaSHiten PandyaState in which the device is off and not running.
657aac0aafaSHiten PandyaDevice context is lost, and power from the device can
658aac0aafaSHiten Pandyabe removed.
659aac0aafaSHiten Pandya.It Dv PCI_POWERSTATE_UNKNOWN
660aac0aafaSHiten PandyaState of the device is unknown.
661aac0aafaSHiten Pandya.El
662aac0aafaSHiten Pandya.Pp
663aac0aafaSHiten PandyaThe
664aac0aafaSHiten Pandya.Fn pci_set_powerstate
665aac0aafaSHiten Pandyafunction is used to transition the device
666aac0aafaSHiten Pandya.Fa dev
667adb63907SJohn Baldwinto the PCI power state
668aac0aafaSHiten Pandya.Fa state .
669adb63907SJohn BaldwinIf the device does not support power management capabilities or
670adb63907SJohn Baldwinit does not support the specific power state
671adb63907SJohn Baldwin.Fa state ,
672adb63907SJohn Baldwinthen the function will fail with
673adb63907SJohn Baldwin.Er EOPNOTSUPP .
674aac0aafaSHiten Pandya.Pp
675aac0aafaSHiten PandyaThe
676*82d69277SJohn Baldwin.Fn pci_clear_pme
677*82d69277SJohn Baldwinfunction is used to clear any pending PME# signal and disable generation
678*82d69277SJohn Baldwinof power management events.
679*82d69277SJohn Baldwin.Pp
680*82d69277SJohn BaldwinThe
6817d971e36SRyan Stone.Fn pci_iov_attach
6827d971e36SRyan Stonefunction is used to advertise that the given device
6837d971e36SRyan Stone.Pq and associated device driver
6847d971e36SRyan Stonesupports PCI Single-Root I/O Virtualization
685fe3ff217SPatrick Kelsey.Pq SR-IOV .
6867d971e36SRyan StoneA driver that supports SR-IOV must implement the
687f3bb9251SJohn Baldwin.Xr PCI_IOV_INIT 9 ,
688f3bb9251SJohn Baldwin.Xr PCI_IOV_ADD_VF 9
6897d971e36SRyan Stoneand
690f3bb9251SJohn Baldwin.Xr PCI_IOV_UNINIT 9
6917d971e36SRyan Stonemethods.
6927d971e36SRyan StoneThis function should be called during the
6937d971e36SRyan Stone.Xr DEVICE_ATTACH 9
6947d971e36SRyan Stonemethod.
6957d971e36SRyan StoneIf this function returns an error, it is recommended that the device driver
6967d971e36SRyan Stonestill successfully attaches, but runs with SR-IOV disabled.
6977d971e36SRyan StoneThe
6987d971e36SRyan Stone.Fa pf_schema
6997d971e36SRyan Stoneand
7007d971e36SRyan Stone.Fa vf_schema
7017d971e36SRyan Stoneparameters are used to define what device-specific configuration parameters the
7027d971e36SRyan Stonedevice driver accepts when SR-IOV is enabled for the Physical Function
7037d971e36SRyan Stone.Pq PF
7047d971e36SRyan Stoneand for individual Virtual Functions
7057d971e36SRyan Stone.Pq VFs
7067d971e36SRyan Stonerespectively.
7077d971e36SRyan StoneSee
7087d971e36SRyan Stone.Xr pci_iov_schema 9
7097d971e36SRyan Stonefor details on how to construct the schema.
7107d971e36SRyan StoneIf either the
7117d971e36SRyan Stone.Pa pf_schema
7127d971e36SRyan Stoneor
7137d971e36SRyan Stone.Pa vf_schema
7147d971e36SRyan Stoneis invalid or specifies parameter names that conflict with parameter names that
7157d971e36SRyan Stoneare already in use,
7167d971e36SRyan Stone.Fn pci_iov_attach
7177d971e36SRyan Stonewill return an error and SR-IOV will not be available on the PF device.
7187d971e36SRyan StoneIf a driver does not accept configuration parameters for either the PF device
7197d971e36SRyan Stoneor the VF devices, the driver must pass an empty schema for that device.
7207d971e36SRyan StoneThe SR-IOV infrastructure takes ownership of the
7217d971e36SRyan Stone.Fa pf_schema
7227d971e36SRyan Stoneand
7237d971e36SRyan Stone.Fa vf_schema
7247d971e36SRyan Stoneand is responsible for freeing them.
7257d971e36SRyan StoneThe driver must never free the schemas itself.
7267d971e36SRyan Stone.Pp
7277d971e36SRyan StoneThe
7280aee83ccSJohn Baldwin.Fn pci_iov_attach_name
7290aee83ccSJohn Baldwinfunction is a variant of
7300aee83ccSJohn Baldwin.Fn pci_iov_attach
7310aee83ccSJohn Baldwinthat allows the name of the associated character device in
7320aee83ccSJohn Baldwin.Pa /dev/iov
7330aee83ccSJohn Baldwinto be specified by
7340aee83ccSJohn Baldwin.Fa fmt .
7350aee83ccSJohn BaldwinThe
7360aee83ccSJohn Baldwin.Fn pci_iov_attach
7370aee83ccSJohn Baldwinfunction uses the name of
7380aee83ccSJohn Baldwin.Fa dev
7390aee83ccSJohn Baldwinas the device name.
7400aee83ccSJohn Baldwin.Pp
7410aee83ccSJohn BaldwinThe
7427d971e36SRyan Stone.Fn pci_iov_detach
7437d971e36SRyan Stonefunction is used to advise the SR-IOV infrastructure that the driver for the
7447d971e36SRyan Stonegiven device is attempting to detach and that all SR-IOV resources for the
7457d971e36SRyan Stonedevice must be released.
7467d971e36SRyan StoneThis function must be called during the
7477d971e36SRyan Stone.Xr DEVICE_DETACH 9
7487d971e36SRyan Stonemethod if
7497d971e36SRyan Stone.Fn pci_iov_attach
7507d971e36SRyan Stonewas successfully called on the device and
7517d971e36SRyan Stone.Fn pci_iov_detach
7527d971e36SRyan Stonehas not subsequently been called on the device and returned no error.
7537d971e36SRyan StoneIf this function returns an error, the
7547d971e36SRyan Stone.Xr DEVICE_DETACH 9
7557d971e36SRyan Stonemethod must fail and return an error, as detaching the PF driver while VF
7567d971e36SRyan Stonedevices are active would cause system instability.
7577d971e36SRyan StoneThis function is safe to call and will always succeed if
7587d971e36SRyan Stone.Fn pci_iov_attach
7597d971e36SRyan Stonepreviously failed with an error on the given device, or if
7607d971e36SRyan Stone.Fn pci_iov_attach
7617d971e36SRyan Stonewas never called on the device.
7627d971e36SRyan Stone.Pp
7637d971e36SRyan StoneThe
7649415d1e0SJohn Baldwin.Fn pci_save_state
7659415d1e0SJohn Baldwinand
7669415d1e0SJohn Baldwin.Fn pci_restore_state
7679415d1e0SJohn Baldwinfunctions can be used by a device driver to save and restore standard PCI
7689415d1e0SJohn Baldwinconfig registers.
7699415d1e0SJohn BaldwinThe
7709415d1e0SJohn Baldwin.Fn pci_save_state
7719415d1e0SJohn Baldwinfunction must be invoked while the device has valid state before
7729415d1e0SJohn Baldwin.Fn pci_restore_state
7739415d1e0SJohn Baldwincan be used.
7749415d1e0SJohn BaldwinIf the device is not in the fully-powered state
7759415d1e0SJohn Baldwin.Pq Dv PCI_POWERSTATE_D0
7769415d1e0SJohn Baldwinwhen
7779415d1e0SJohn Baldwin.Fn pci_restore_state
7789415d1e0SJohn Baldwinis invoked,
7799415d1e0SJohn Baldwinthen the device will be transitioned to
7809415d1e0SJohn Baldwin.Dv PCI_POWERSTATE_D0
7819415d1e0SJohn Baldwinbefore any config registers are restored.
782da0fc925SJohn Baldwin.Pp
783da0fc925SJohn BaldwinThe
784da0fc925SJohn Baldwin.Fn pcie_flr
785da0fc925SJohn Baldwinfunction requests a Function Level Reset
786da0fc925SJohn Baldwin.Pq FLR
787da0fc925SJohn Baldwinof
788da0fc925SJohn Baldwin.Fa dev .
789da0fc925SJohn BaldwinIf
790da0fc925SJohn Baldwin.Fa dev
791da0fc925SJohn Baldwinis not a PCI-express device or does not support Function Level Resets via
792da0fc925SJohn Baldwinthe PCI-express device control register,
793da0fc925SJohn Baldwin.Dv false
794da0fc925SJohn Baldwinis returned.
795da0fc925SJohn BaldwinPending transactions are drained by disabling busmastering and calling
796da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions
797da0fc925SJohn Baldwinbefore resetting the device.
798da0fc925SJohn BaldwinThe
799da0fc925SJohn Baldwin.Fa max_delay
800da0fc925SJohn Baldwinargument specifies the maximum timeout to wait for pending transactions as
801da0fc925SJohn Baldwindescribed for
802da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions .
803da0fc925SJohn BaldwinIf
804da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions
805da0fc925SJohn Baldwinfails with a timeout and
806da0fc925SJohn Baldwin.Fa force
807da0fc925SJohn Baldwinis
808da0fc925SJohn Baldwin.Dv false ,
809da0fc925SJohn Baldwinbusmastering is re-enabled and
810da0fc925SJohn Baldwin.Dv false
811da0fc925SJohn Baldwinis returned.
812da0fc925SJohn BaldwinIf
813da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions
814da0fc925SJohn Baldwinfails with a timeout and
815da0fc925SJohn Baldwin.Fa force
816da0fc925SJohn Baldwinis
817da0fc925SJohn Baldwin.Dv true ,
818da0fc925SJohn Baldwinthe device is reset despite the timeout.
819da0fc925SJohn BaldwinAfter the reset has been requested,
820da0fc925SJohn Baldwin.Nm pcie_flr
821da0fc925SJohn Baldwinsleeps for at least 100 milliseconds before returning
822da0fc925SJohn Baldwin.Dv true .
823da0fc925SJohn BaldwinNote that
824da0fc925SJohn Baldwin.Nm pcie_flr
825da0fc925SJohn Baldwindoes not save and restore any state around the reset.
826da0fc925SJohn BaldwinThe caller should save and restore state as needed.
827855ed4c5SJohn Baldwin.Ss Message Signaled Interrupts
828855ed4c5SJohn BaldwinMessage Signaled Interrupts
829855ed4c5SJohn Baldwin.Pq MSI
830855ed4c5SJohn Baldwinand
831855ed4c5SJohn BaldwinEnhanced Message Signaled Interrupts
832855ed4c5SJohn Baldwin.Pq MSI-X
833855ed4c5SJohn Baldwinare PCI capabilities that provide an alternate method for PCI
834855ed4c5SJohn Baldwindevices to signal interrupts.
835855ed4c5SJohn BaldwinThe legacy INTx interrupt is available to PCI devices as a
836855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ
837855ed4c5SJohn Baldwinresource with a resource ID of zero.
838855ed4c5SJohn BaldwinMSI and MSI-X interrupts are available to PCI devices as one or more
839855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ
840855ed4c5SJohn Baldwinresources with resource IDs greater than zero.
841855ed4c5SJohn BaldwinA driver must ask the PCI bus to allocate MSI or MSI-X interrupts
842855ed4c5SJohn Baldwinusing
843855ed4c5SJohn Baldwin.Fn pci_alloc_msi
844855ed4c5SJohn Baldwinor
845855ed4c5SJohn Baldwin.Fn pci_alloc_msix
846855ed4c5SJohn Baldwinbefore it can use MSI or MSI-X
847855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ
848855ed4c5SJohn Baldwinresources.
849855ed4c5SJohn BaldwinA driver is not allowed to use the legacy INTx
850855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ
851855ed4c5SJohn Baldwinresource if MSI or MSI-X interrupts have been allocated,
852855ed4c5SJohn Baldwinand attempts to allocate MSI or MSI-X interrupts will fail if the
853855ed4c5SJohn Baldwindriver is currently using the legacy INTx
854855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ
855855ed4c5SJohn Baldwinresource.
856855ed4c5SJohn BaldwinA driver is only allowed to use either MSI or MSI-X,
857855ed4c5SJohn Baldwinbut not both.
8589415d1e0SJohn Baldwin.Pp
8599415d1e0SJohn BaldwinThe
860563d4639SMark Johnston.Fn pci_msi_count
861855ed4c5SJohn Baldwinfunction returns the maximum number of MSI messages supported by the
862855ed4c5SJohn Baldwindevice
863855ed4c5SJohn Baldwin.Fa dev .
864855ed4c5SJohn BaldwinIf the device does not support MSI,
865855ed4c5SJohn Baldwinthen
866563d4639SMark Johnston.Fn pci_msi_count
867855ed4c5SJohn Baldwinreturns zero.
86855aaf894SMarius Strobl.Pp
86955aaf894SMarius StroblThe
870855ed4c5SJohn Baldwin.Fn pci_alloc_msi
871855ed4c5SJohn Baldwinfunction attempts to allocate
872855ed4c5SJohn Baldwin.Fa *count
873855ed4c5SJohn BaldwinMSI messages for the device
874855ed4c5SJohn Baldwin.Fa dev .
87555aaf894SMarius StroblThe
876855ed4c5SJohn Baldwin.Fn pci_alloc_msi
877855ed4c5SJohn Baldwinfunction may allocate fewer messages than requested for various
878855ed4c5SJohn Baldwinreasons including requests for more messages than the device
879855ed4c5SJohn Baldwin.Fa dev
880855ed4c5SJohn Baldwinsupports,
881855ed4c5SJohn Baldwinor if the system has a shortage of available MSI messages.
882855ed4c5SJohn BaldwinOn success,
883855ed4c5SJohn Baldwin.Fa *count
884855ed4c5SJohn Baldwinis set to the number of messages allocated and
885855ed4c5SJohn Baldwin.Fn pci_alloc_msi
886855ed4c5SJohn Baldwinreturns zero.
887855ed4c5SJohn BaldwinThe
888855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ
889855ed4c5SJohn Baldwinresources for the allocated messages will be available at consecutive
890855ed4c5SJohn Baldwinresource IDs beginning with one.
891855ed4c5SJohn BaldwinIf
892855ed4c5SJohn Baldwin.Fn pci_alloc_msi
893855ed4c5SJohn Baldwinis not able to allocate any messages,
894855ed4c5SJohn Baldwinit returns an error.
895855ed4c5SJohn BaldwinNote that MSI only supports message counts that are powers of two;
896855ed4c5SJohn Baldwinrequests to allocate a non-power of two count of messages will fail.
897aac0aafaSHiten Pandya.Pp
898aac0aafaSHiten PandyaThe
899855ed4c5SJohn Baldwin.Fn pci_release_msi
900855ed4c5SJohn Baldwinfunction is used to release any allocated MSI or MSI-X messages back
901855ed4c5SJohn Baldwinto the system.
902855ed4c5SJohn BaldwinIf any MSI or MSI-X
903855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ
904855ed4c5SJohn Baldwinresources are allocated by the driver or have a configured interrupt
905855ed4c5SJohn Baldwinhandler,
906855ed4c5SJohn Baldwinthis function will fail with
907855ed4c5SJohn Baldwin.Er EBUSY .
908855ed4c5SJohn BaldwinThe
909855ed4c5SJohn Baldwin.Fn pci_release_msi
910855ed4c5SJohn Baldwinfunction returns zero on success and an error on failure.
911855ed4c5SJohn Baldwin.Pp
912642c4993SSergey KandaurovThe
913563d4639SMark Johnston.Fn pci_msix_count
914855ed4c5SJohn Baldwinfunction returns the maximum number of MSI-X messages supported by the
915855ed4c5SJohn Baldwindevice
916855ed4c5SJohn Baldwin.Fa dev .
917855ed4c5SJohn BaldwinIf the device does not support MSI-X,
918855ed4c5SJohn Baldwinthen
919563d4639SMark Johnston.Fn pci_msix_count
920855ed4c5SJohn Baldwinreturns zero.
921855ed4c5SJohn Baldwin.Pp
922855ed4c5SJohn BaldwinThe
923ce204e1bSJohn Baldwin.Fn pci_msix_pba_bar
924ce204e1bSJohn Baldwinfunction returns the offset in configuration space of the Base Address Register
925ce204e1bSJohn Baldwin.Pq BAR
926ce204e1bSJohn Baldwincontaining the MSI-X Pending Bit Array (PBA) for device
927ce204e1bSJohn Baldwin.Fa dev .
928ce204e1bSJohn BaldwinThe returned value can be used as the resource ID with
929ce204e1bSJohn Baldwin.Xr bus_alloc_resource 9
930ce204e1bSJohn Baldwinand
931ce204e1bSJohn Baldwin.Xr bus_release_resource 9
932ce204e1bSJohn Baldwinto allocate the BAR.
933ce204e1bSJohn BaldwinIf the device does not support MSI-X,
934ce204e1bSJohn Baldwinthen
935ce204e1bSJohn Baldwin.Fn pci_msix_pba_bar
936ce204e1bSJohn Baldwinreturns -1.
937ce204e1bSJohn Baldwin.Pp
938ce204e1bSJohn BaldwinThe
939ce204e1bSJohn Baldwin.Fn pci_msix_table_bar
940ce204e1bSJohn Baldwinfunction returns the offset in configuration space of the BAR
941ce204e1bSJohn Baldwincontaining the MSI-X vector table for device
942ce204e1bSJohn Baldwin.Fa dev .
943ce204e1bSJohn BaldwinThe returned value can be used as the resource ID with
944ce204e1bSJohn Baldwin.Xr bus_alloc_resource 9
945ce204e1bSJohn Baldwinand
946ce204e1bSJohn Baldwin.Xr bus_release_resource 9
947ce204e1bSJohn Baldwinto allocate the BAR.
948ce204e1bSJohn BaldwinIf the device does not support MSI-X,
949ce204e1bSJohn Baldwinthen
950ce204e1bSJohn Baldwin.Fn pci_msix_table_bar
951ce204e1bSJohn Baldwinreturns -1.
952ce204e1bSJohn Baldwin.Pp
953ce204e1bSJohn BaldwinThe
954855ed4c5SJohn Baldwin.Fn pci_alloc_msix
955855ed4c5SJohn Baldwinfunction attempts to allocate
956855ed4c5SJohn Baldwin.Fa *count
957855ed4c5SJohn BaldwinMSI-X messages for the device
958855ed4c5SJohn Baldwin.Fa dev .
959855ed4c5SJohn BaldwinThe
960855ed4c5SJohn Baldwin.Fn pci_alloc_msix
961855ed4c5SJohn Baldwinfunction may allocate fewer messages than requested for various
962855ed4c5SJohn Baldwinreasons including requests for more messages than the device
963855ed4c5SJohn Baldwin.Fa dev
964855ed4c5SJohn Baldwinsupports,
965855ed4c5SJohn Baldwinor if the system has a shortage of available MSI-X messages.
966855ed4c5SJohn BaldwinOn success,
967855ed4c5SJohn Baldwin.Fa *count
968855ed4c5SJohn Baldwinis set to the number of messages allocated and
969855ed4c5SJohn Baldwin.Fn pci_alloc_msix
970855ed4c5SJohn Baldwinreturns zero.
971855ed4c5SJohn BaldwinFor MSI-X messages,
972855ed4c5SJohn Baldwinthe resource ID for each
97373bbeaa5SGlen Barber.Dv SYS_RES_IRQ
97473bbeaa5SGlen Barberresource identifies the index in the MSI-X table of the
975855ed4c5SJohn Baldwincorresponding message.
976855ed4c5SJohn BaldwinA resource ID of one maps to the first index of the MSI-X table;
977855ed4c5SJohn Baldwina resource ID two identifies the second index in the table, etc.
978855ed4c5SJohn BaldwinThe
979855ed4c5SJohn Baldwin.Fn pci_alloc_msix
980855ed4c5SJohn Baldwinfunction assigns the
981855ed4c5SJohn Baldwin.Fa *count
982855ed4c5SJohn Baldwinmessages allocated to the first
983855ed4c5SJohn Baldwin.Fa *count
9847c64ddd5SWarren Blocktable indices.
985855ed4c5SJohn BaldwinIf
986855ed4c5SJohn Baldwin.Fn pci_alloc_msix
987855ed4c5SJohn Baldwinis not able to allocate any messages,
988855ed4c5SJohn Baldwinit returns an error.
989855ed4c5SJohn BaldwinUnlike MSI,
990855ed4c5SJohn BaldwinMSI-X does not require message counts that are powers of two.
991855ed4c5SJohn Baldwin.Pp
992ce204e1bSJohn BaldwinThe BARs containing the MSI-X vector table and PBA must be
993ce204e1bSJohn Baldwinallocated via
994ce204e1bSJohn Baldwin.Xr bus_alloc_resource 9
995ce204e1bSJohn Baldwinbefore calling
996ce204e1bSJohn Baldwin.Fn pci_alloc_msix
997ce204e1bSJohn Baldwinand must not be released until after calling
998ce204e1bSJohn Baldwin.Fn pci_release_msi .
999ce204e1bSJohn BaldwinNote that the vector table and PBA may be stored in the same BAR or in
1000ce204e1bSJohn Baldwindifferent BARs.
1001ce204e1bSJohn Baldwin.Pp
1002855ed4c5SJohn BaldwinThe
1003855ed4c5SJohn Baldwin.Fn pci_pending_msix
1004855ed4c5SJohn Baldwinfunction examines the
1005855ed4c5SJohn Baldwin.Fa dev
1006ce204e1bSJohn Baldwindevice's PBA
1007855ed4c5SJohn Baldwinto determine the pending status of the MSI-X message at table index
1008855ed4c5SJohn Baldwin.Fa index .
1009855ed4c5SJohn BaldwinIf the indicated message is pending,
1010855ed4c5SJohn Baldwinthis function returns a non-zero value;
1011855ed4c5SJohn Baldwinotherwise,
1012855ed4c5SJohn Baldwinit returns zero.
1013855ed4c5SJohn BaldwinPassing an invalid
1014855ed4c5SJohn Baldwin.Fa index
1015855ed4c5SJohn Baldwinto this function will result in undefined behavior.
1016855ed4c5SJohn Baldwin.Pp
1017855ed4c5SJohn BaldwinAs mentioned in the description of
1018855ed4c5SJohn Baldwin.Fn pci_alloc_msix ,
1019855ed4c5SJohn BaldwinMSI-X messages are initially assigned to the first N table entries.
1020855ed4c5SJohn BaldwinA driver may use a different distribution of available messages to
1021855ed4c5SJohn Baldwintable entries via the
1022855ed4c5SJohn Baldwin.Fn pci_remap_msix
1023855ed4c5SJohn Baldwinfunction.
102473bbeaa5SGlen BarberNote that this function must be called after a successful call to
1025855ed4c5SJohn Baldwin.Fn pci_alloc_msix
1026855ed4c5SJohn Baldwinbut before any of the
1027855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ
1028855ed4c5SJohn Baldwinresources are allocated.
1029855ed4c5SJohn BaldwinThe
1030855ed4c5SJohn Baldwin.Fn pci_remap_msix
1031855ed4c5SJohn Baldwinfunction returns zero on success,
1032855ed4c5SJohn Baldwinor an error on failure.
1033855ed4c5SJohn Baldwin.Pp
1034855ed4c5SJohn BaldwinThe
1035855ed4c5SJohn Baldwin.Fa vectors
1036855ed4c5SJohn Baldwinarray should contain
1037855ed4c5SJohn Baldwin.Fa count
1038855ed4c5SJohn Baldwinmessage vectors.
1039855ed4c5SJohn BaldwinThe array maps directly to the MSI-X table in that the first entry in
1040855ed4c5SJohn Baldwinthe array specifies the message used for the first entry in the MSI-X
1041855ed4c5SJohn Baldwintable,
1042855ed4c5SJohn Baldwinthe second entry in the array corresponds to the second entry in the
1043855ed4c5SJohn BaldwinMSI-X table,
1044855ed4c5SJohn Baldwinetc.
1045855ed4c5SJohn BaldwinThe vector value in each array index can either be zero to indicate
1046855ed4c5SJohn Baldwinthat no message should be assigned to the corresponding MSI-X table entry,
1047855ed4c5SJohn Baldwinor it can be a number from one to N
1048855ed4c5SJohn Baldwin.Po
1049855ed4c5SJohn Baldwinwhere N is the count returned from the previous call to
1050855ed4c5SJohn Baldwin.Fn pci_alloc_msix
1051855ed4c5SJohn Baldwin.Pc
1052855ed4c5SJohn Baldwinto indicate which of the allocated messages should be assigned to the
1053855ed4c5SJohn Baldwincorresponding MSI-X table entry.
1054855ed4c5SJohn Baldwin.Pp
1055855ed4c5SJohn BaldwinIf
1056855ed4c5SJohn Baldwin.Fn pci_remap_msix
1057855ed4c5SJohn Baldwinsucceeds,
1058855ed4c5SJohn Baldwineach MSI-X table entry with a non-zero vector will have an associated
1059855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ
1060855ed4c5SJohn Baldwinresource whose resource ID corresponds to the table index as described
1061855ed4c5SJohn Baldwinabove for
1062855ed4c5SJohn Baldwin.Fn pci_alloc_msix .
1063855ed4c5SJohn BaldwinMSI-X table entries that with a vector of zero will not have an
1064855ed4c5SJohn Baldwinassociated
106573bbeaa5SGlen Barber.Dv SYS_RES_IRQ
106673bbeaa5SGlen Barberresource.
1067855ed4c5SJohn BaldwinAdditionally,
1068855ed4c5SJohn Baldwinif any of the original messages allocated by
1069855ed4c5SJohn Baldwin.Fn pci_alloc_msix
1070855ed4c5SJohn Baldwinare not used in the new distribution of messages in the MSI-X table,
1071855ed4c5SJohn Baldwinthey will be released automatically.
1072855ed4c5SJohn BaldwinNote that if a driver wishes to use fewer messages than were allocated by
1073855ed4c5SJohn Baldwin.Fn pci_alloc_msix ,
1074855ed4c5SJohn Baldwinthe driver must use a single, contiguous range of messages beginning
1075855ed4c5SJohn Baldwinwith one in the new distribution.
1076855ed4c5SJohn BaldwinThe
1077855ed4c5SJohn Baldwin.Fn pci_remap_msix
1078855ed4c5SJohn Baldwinfunction will fail if this condition is not met.
107964414cc0SJohn Baldwin.Ss Device Events
108064414cc0SJohn BaldwinThe
108164414cc0SJohn Baldwin.Va pci_add_device
108264414cc0SJohn Baldwinevent handler is invoked every time a new PCI device is added to the system.
108364414cc0SJohn BaldwinThis includes the creation of Virtual Functions via SR-IOV.
108464414cc0SJohn Baldwin.Pp
108564414cc0SJohn BaldwinThe
108664414cc0SJohn Baldwin.Va pci_delete_device
108764414cc0SJohn Baldwinevent handler is invoked every time a PCI device is removed from the system.
108864414cc0SJohn Baldwin.Pp
108964414cc0SJohn BaldwinBoth event handlers pass the
109064414cc0SJohn Baldwin.Vt device_t
109164414cc0SJohn Baldwinobject of the relevant PCI device as
109264414cc0SJohn Baldwin.Fa dev
109364414cc0SJohn Baldwinto each callback function.
109464414cc0SJohn BaldwinBoth event handlers are invoked while
109564414cc0SJohn Baldwin.Fa dev
109664414cc0SJohn Baldwinis unattached but with valid instance variables.
1097aac0aafaSHiten Pandya.Sh SEE ALSO
10987c2c06f2SSheldon Hearn.Xr pci 4 ,
10997c2c06f2SSheldon Hearn.Xr pciconf 8 ,
1100aac0aafaSHiten Pandya.Xr bus_alloc_resource 9 ,
1101aac0aafaSHiten Pandya.Xr bus_dma 9 ,
1102aac0aafaSHiten Pandya.Xr bus_release_resource 9 ,
1103aac0aafaSHiten Pandya.Xr bus_setup_intr 9 ,
1104aac0aafaSHiten Pandya.Xr bus_teardown_intr 9 ,
1105aac0aafaSHiten Pandya.Xr devclass 9 ,
1106aac0aafaSHiten Pandya.Xr device 9 ,
1107aac0aafaSHiten Pandya.Xr driver 9 ,
110864414cc0SJohn Baldwin.Xr eventhandler 9 ,
1109aac0aafaSHiten Pandya.Xr rman 9
1110aac0aafaSHiten Pandya.Rs
1111aac0aafaSHiten Pandya.%B FreeBSD Developers' Handbook
1112aac0aafaSHiten Pandya.%T NewBus
1113c1a14887SCeri Davies.%U https://docs.freebsd.org/en/books/developers-handbook/
1114aac0aafaSHiten Pandya.Re
1115aac0aafaSHiten Pandya.Rs
1116aac0aafaSHiten Pandya.%A Shanley
1117aac0aafaSHiten Pandya.%A Anderson
1118aac0aafaSHiten Pandya.%B PCI System Architecture
1119aac0aafaSHiten Pandya.%N 2nd Edition
1120aac0aafaSHiten Pandya.%I Addison-Wesley
1121aac0aafaSHiten Pandya.%O ISBN 0-201-30974-2
1122aac0aafaSHiten Pandya.Re
1123aac0aafaSHiten Pandya.Sh AUTHORS
11248a7314fcSBaptiste Daroussin.An -nosplit
1125571dba6eSHiten PandyaThis manual page was written by
11268a7314fcSBaptiste Daroussin.An Bruce M Simpson Aq Mt bms@FreeBSD.org
1127855ed4c5SJohn Baldwinand
11288a7314fcSBaptiste Daroussin.An John Baldwin Aq Mt jhb@FreeBSD.org .
1129aac0aafaSHiten Pandya.Sh BUGS
11304d80f750SBruce M SimpsonThe kernel PCI code has a number of references to
11314d80f750SBruce M Simpson.Dq "slot numbers" .
1132bf1639eeSBruce M SimpsonThese do not refer to the geographic location of PCI devices,
1133bf1639eeSBruce M Simpsonbut to the device number assigned by the combination of the PCI IDSEL
1134bf1639eeSBruce M Simpsonmechanism and the platform firmware.
1135bf1639eeSBruce M SimpsonThis should be taken note of when working with the kernel PCI code.
1136ce204e1bSJohn Baldwin.Pp
1137ce204e1bSJohn BaldwinThe PCI bus driver should allocate the MSI-X vector table and PBA internally
1138ce204e1bSJohn Baldwinas necessary rather than requiring the caller to do so.
1139