xref: /freebsd/share/man/man4/pci.4 (revision 2d4a74d7a0a6295ec462a3a2e5f2588bd21eb36a)
164ae346bSKenneth D. Merry.\"
264ae346bSKenneth D. Merry.\" Copyright (c) 1999 Kenneth D. Merry.
364ae346bSKenneth D. Merry.\" All rights reserved.
464ae346bSKenneth D. Merry.\"
564ae346bSKenneth D. Merry.\" Redistribution and use in source and binary forms, with or without
664ae346bSKenneth D. Merry.\" modification, are permitted provided that the following conditions
764ae346bSKenneth D. Merry.\" are met:
864ae346bSKenneth D. Merry.\" 1. Redistributions of source code must retain the above copyright
964ae346bSKenneth D. Merry.\"    notice, this list of conditions and the following disclaimer.
1064ae346bSKenneth D. Merry.\" 2. The name of the author may not be used to endorse or promote products
1164ae346bSKenneth D. Merry.\"    derived from this software without specific prior written permission.
1264ae346bSKenneth D. Merry.\"
1364ae346bSKenneth D. Merry.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1464ae346bSKenneth D. Merry.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1564ae346bSKenneth D. Merry.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1664ae346bSKenneth D. Merry.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1764ae346bSKenneth D. Merry.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1864ae346bSKenneth D. Merry.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1964ae346bSKenneth D. Merry.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2064ae346bSKenneth D. Merry.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2164ae346bSKenneth D. Merry.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2264ae346bSKenneth D. Merry.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2364ae346bSKenneth D. Merry.\" SUCH DAMAGE.
2464ae346bSKenneth D. Merry.\"
2564ae346bSKenneth D. Merry.\" $FreeBSD$
2664ae346bSKenneth D. Merry.\"
2765d328a3SNiclas Zeising.Dd June 17, 2019
2864ae346bSKenneth D. Merry.Dt PCI 4
293d45e180SRuslan Ermilov.Os
3064ae346bSKenneth D. Merry.Sh NAME
3164ae346bSKenneth D. Merry.Nm pci
32c97a3872SJohn Baldwin.Nd generic PCI bus driver
33251c176fSRuslan Ermilov.Sh SYNOPSIS
34c97a3872SJohn BaldwinTo compile the PCI bus driver into the kernel,
35c97a3872SJohn Baldwinplace the following line in your
36c97a3872SJohn Baldwinkernel configuration file:
37c97a3872SJohn Baldwin.Bd -ragged -offset indent
386b713d58SJeroen Ruigrok van der Werven.Cd device pci
39c97a3872SJohn Baldwin.Ed
40c97a3872SJohn Baldwin.Pp
41c97a3872SJohn BaldwinTo compile in support for Single Root I/O Virtualization
42c97a3872SJohn Baldwin.Pq SR-IOV :
43c97a3872SJohn Baldwin.Bd -ragged -offset indent
44c97a3872SJohn Baldwin.Cd options PCI_IOV
45c97a3872SJohn Baldwin.Ed
46c97a3872SJohn Baldwin.Pp
47c97a3872SJohn BaldwinTo compile in support for native PCI-express HotPlug:
48c97a3872SJohn Baldwin.Bd -ragged -offset indent
49c97a3872SJohn Baldwin.Cd options PCI_HP
50c97a3872SJohn Baldwin.Ed
5164ae346bSKenneth D. Merry.Sh DESCRIPTION
5264ae346bSKenneth D. MerryThe
534b66483fSRuslan Ermilov.Nm
54c97a3872SJohn Baldwindriver provides support for
55c97a3872SJohn Baldwin.Tn PCI
56c97a3872SJohn Baldwindevices in the kernel and limited access to
57c97a3872SJohn Baldwin.Tn PCI
58c97a3872SJohn Baldwindevices for userland.
59c97a3872SJohn Baldwin.Pp
60c97a3872SJohn BaldwinThe
61c97a3872SJohn Baldwin.Nm
62c97a3872SJohn Baldwindriver provides a
63c97a3872SJohn Baldwin.Pa /dev/pci
64c97a3872SJohn Baldwincharacter device that can be used by userland programs to read and write
6564ae346bSKenneth D. Merry.Tn PCI
66b5e7e999SRuslan Ermilovconfiguration registers.
67c97a3872SJohn BaldwinPrograms can also use this device to get a list of all
6864ae346bSKenneth D. Merry.Tn PCI
6964ae346bSKenneth D. Merrydevices, or all
7064ae346bSKenneth D. Merry.Tn PCI
7164ae346bSKenneth D. Merrydevices that match various patterns.
7264ae346bSKenneth D. Merry.Pp
7364ae346bSKenneth D. MerrySince the
744b66483fSRuslan Ermilov.Nm
7564ae346bSKenneth D. Merrydriver provides a write interface for
7664ae346bSKenneth D. Merry.Tn PCI
7764ae346bSKenneth D. Merryconfiguration registers, system administrators should exercise caution when
7864ae346bSKenneth D. Merrygranting access to the
794b66483fSRuslan Ermilov.Nm
80b5e7e999SRuslan Ermilovdevice.
81b5e7e999SRuslan ErmilovIf used improperly, this driver can allow userland applications to
8264ae346bSKenneth D. Merrycrash a machine or cause data loss.
830ade47aeSWarner Losh.Pp
840ade47aeSWarner LoshThe
854b66483fSRuslan Ermilov.Nm
86c0c7deaaSChristian Bruefferdriver implements the
87c0c7deaaSChristian Brueffer.Tn PCI
88c0c7deaaSChristian Bruefferbus in the kernel.
89c0c7deaaSChristian BruefferIt enumerates any devices on the
90c0c7deaaSChristian Brueffer.Tn PCI
91c0c7deaaSChristian Bruefferbus and gives
92c0c7deaaSChristian Brueffer.Tn PCI
93c0c7deaaSChristian Bruefferclient drivers the chance to attach to them.
94c0c7deaaSChristian BruefferIt assigns resources to children, when the BIOS does not.
950ade47aeSWarner LoshIt takes care of routing interrupts when necessary.
96c0c7deaaSChristian BruefferIt reprobes the unattached
97c0c7deaaSChristian Brueffer.Tn PCI
98c0c7deaaSChristian Bruefferchildren when
99c0c7deaaSChristian Brueffer.Tn PCI
100c0c7deaaSChristian Bruefferclient drivers are dynamically
1010ade47aeSWarner Loshloaded at runtime.
1020ade47aeSWarner LoshThe
1030ade47aeSWarner Losh.Nm
104c97a3872SJohn Baldwindriver also includes support for PCI-PCI bridges,
105c97a3872SJohn Baldwinvarious platform-specific Host-PCI bridges,
106c97a3872SJohn Baldwinand basic support for
107c97a3872SJohn Baldwin.Tn PCI
108c97a3872SJohn BaldwinVGA adapters.
10964ae346bSKenneth D. Merry.Sh IOCTLS
11064ae346bSKenneth D. MerryThe following
11164ae346bSKenneth D. Merry.Xr ioctl 2
11264ae346bSKenneth D. Merrycalls are supported by the
1134b66483fSRuslan Ermilov.Nm
114b5e7e999SRuslan Ermilovdriver.
115b5e7e999SRuslan ErmilovThey are defined in the header file
116fe08efe6SRuslan Ermilov.In sys/pciio.h .
11764ae346bSKenneth D. Merry.Bl -tag -width 012345678901234
11864ae346bSKenneth D. Merry.It PCIOCGETCONF
11964ae346bSKenneth D. MerryThis
12064ae346bSKenneth D. Merry.Xr ioctl 2
12164ae346bSKenneth D. Merrytakes a
12264ae346bSKenneth D. Merry.Va pci_conf_io
123b5e7e999SRuslan Ermilovstructure.
124b5e7e999SRuslan ErmilovIt allows the user to retrieve information on all
12564ae346bSKenneth D. Merry.Tn PCI
12664ae346bSKenneth D. Merrydevices in the system, or on
12764ae346bSKenneth D. Merry.Tn PCI
1285203edcdSRuslan Ermilovdevices matching patterns supplied by the user.
1295203edcdSRuslan ErmilovThe call may set
13007e3ed79SJohn-Mark Gurney.Va errno
13107e3ed79SJohn-Mark Gurneyto any value specified in either
13207e3ed79SJohn-Mark Gurney.Xr copyin 9
13307e3ed79SJohn-Mark Gurneyor
13407e3ed79SJohn-Mark Gurney.Xr copyout 9 .
13564ae346bSKenneth D. MerryThe
13664ae346bSKenneth D. Merry.Va pci_conf_io
13764ae346bSKenneth D. Merrystructure consists of a number of fields:
13864ae346bSKenneth D. Merry.Bl -tag -width match_buf_len
13964ae346bSKenneth D. Merry.It pat_buf_len
14064ae346bSKenneth D. MerryThe length, in bytes, of the buffer filled with user-supplied patterns.
14164ae346bSKenneth D. Merry.It num_patterns
14264ae346bSKenneth D. MerryThe number of user-supplied patterns.
14364ae346bSKenneth D. Merry.It patterns
14464ae346bSKenneth D. MerryPointer to a buffer filled with user-supplied patterns.
14564ae346bSKenneth D. Merry.Va patterns
14664ae346bSKenneth D. Merryis a pointer to
14764ae346bSKenneth D. Merry.Va num_patterns
14864ae346bSKenneth D. Merry.Va pci_match_conf
1495203edcdSRuslan Ermilovstructures.
1505203edcdSRuslan ErmilovThe
15164ae346bSKenneth D. Merry.Va pci_match_conf
15264ae346bSKenneth D. Merrystructure consists of the following elements:
15364ae346bSKenneth D. Merry.Bl -tag -width pd_vendor
15464ae346bSKenneth D. Merry.It pc_sel
15564ae346bSKenneth D. Merry.Tn PCI
15655aaf894SMarius Strobldomain, bus, slot and function.
15764ae346bSKenneth D. Merry.It pd_name
15864ae346bSKenneth D. Merry.Tn PCI
15964ae346bSKenneth D. Merrydevice driver name.
16064ae346bSKenneth D. Merry.It pd_unit
16164ae346bSKenneth D. Merry.Tn PCI
16264ae346bSKenneth D. Merrydevice driver unit number.
16364ae346bSKenneth D. Merry.It pc_vendor
16464ae346bSKenneth D. Merry.Tn PCI
16564ae346bSKenneth D. Merryvendor ID.
16664ae346bSKenneth D. Merry.It pc_device
16764ae346bSKenneth D. Merry.Tn PCI
16864ae346bSKenneth D. Merrydevice ID.
16964ae346bSKenneth D. Merry.It pc_class
17064ae346bSKenneth D. Merry.Tn PCI
17164ae346bSKenneth D. Merrydevice class.
17264ae346bSKenneth D. Merry.It flags
17364ae346bSKenneth D. MerryThe flags describe which of the fields the kernel should match against.
174b5e7e999SRuslan ErmilovA device must match all specified fields in order to be returned.
175b5e7e999SRuslan ErmilovThe match flags are enumerated in the
17664ae346bSKenneth D. Merry.Va pci_getconf_flags
17764ae346bSKenneth D. Merrystructure.
1780227791bSRuslan ErmilovHopefully the flag values are obvious enough that they do not need to
17964ae346bSKenneth D. Merrydescribed in detail.
18064ae346bSKenneth D. Merry.El
18164ae346bSKenneth D. Merry.It match_buf_len
18264ae346bSKenneth D. MerryLength of the
18364ae346bSKenneth D. Merry.Va matches
18464ae346bSKenneth D. Merrybuffer allocated by the user to hold the results of the
18564ae346bSKenneth D. Merry.Dv PCIOCGETCONF
18664ae346bSKenneth D. Merryquery.
18764ae346bSKenneth D. Merry.It num_matches
18864ae346bSKenneth D. MerryNumber of matches returned by the kernel.
18964ae346bSKenneth D. Merry.It matches
190b5e7e999SRuslan ErmilovBuffer containing matching devices returned by the kernel.
191b5e7e999SRuslan ErmilovThe items in this buffer are of type
19264ae346bSKenneth D. Merry.Va pci_conf ,
19364ae346bSKenneth D. Merrywhich consists of the following items:
19464ae346bSKenneth D. Merry.Bl -tag -width pc_subvendor
19564ae346bSKenneth D. Merry.It pc_sel
19664ae346bSKenneth D. Merry.Tn PCI
19755aaf894SMarius Strobldomain, bus, slot and function.
19864ae346bSKenneth D. Merry.It pc_hdr
19964ae346bSKenneth D. Merry.Tn PCI
20064ae346bSKenneth D. Merryheader type.
20164ae346bSKenneth D. Merry.It pc_subvendor
20264ae346bSKenneth D. Merry.Tn PCI
20364ae346bSKenneth D. Merrysubvendor ID.
20464ae346bSKenneth D. Merry.It pc_subdevice
20564ae346bSKenneth D. Merry.Tn PCI
20664ae346bSKenneth D. Merrysubdevice ID.
20764ae346bSKenneth D. Merry.It pc_vendor
20864ae346bSKenneth D. Merry.Tn PCI
20964ae346bSKenneth D. Merryvendor ID.
21064ae346bSKenneth D. Merry.It pc_device
21164ae346bSKenneth D. Merry.Tn PCI
21264ae346bSKenneth D. Merrydevice ID.
21364ae346bSKenneth D. Merry.It pc_class
21464ae346bSKenneth D. Merry.Tn PCI
21564ae346bSKenneth D. Merrydevice class.
21664ae346bSKenneth D. Merry.It pc_subclass
21764ae346bSKenneth D. Merry.Tn PCI
21864ae346bSKenneth D. Merrydevice subclass.
21964ae346bSKenneth D. Merry.It pc_progif
22064ae346bSKenneth D. Merry.Tn PCI
22164ae346bSKenneth D. Merrydevice programming interface.
22264ae346bSKenneth D. Merry.It pc_revid
22364ae346bSKenneth D. Merry.Tn PCI
22464ae346bSKenneth D. Merryrevision ID.
22564ae346bSKenneth D. Merry.It pd_name
22664ae346bSKenneth D. MerryDriver name.
22764ae346bSKenneth D. Merry.It pd_unit
22864ae346bSKenneth D. MerryDriver unit number.
22964ae346bSKenneth D. Merry.El
23064ae346bSKenneth D. Merry.It offset
23164ae346bSKenneth D. MerryThe offset is passed in by the user to tell the kernel where it should
232b5e7e999SRuslan Ermilovstart traversing the device list.
233b5e7e999SRuslan ErmilovThe value passed out by the kernel
234b5e7e999SRuslan Ermilovpoints to the record immediately after the last one returned.
235b5e7e999SRuslan ErmilovThe user may
23664ae346bSKenneth D. Merrypass the value returned by the kernel in subsequent calls to the
23764ae346bSKenneth D. Merry.Dv PCIOCGETCONF
238b5e7e999SRuslan Ermilovioctl.
239b5e7e999SRuslan ErmilovIf the user does not intend to use the offset, it must be set to zero.
24064ae346bSKenneth D. Merry.It generation
24164ae346bSKenneth D. Merry.Tn PCI
242b5e7e999SRuslan Ermilovconfiguration generation.
243b5e7e999SRuslan ErmilovThis value only needs to be set if the offset is set.
244b5e7e999SRuslan ErmilovThe kernel will compare the current generation number of its internal
24564ae346bSKenneth D. Merrydevice list to the generation passed in by the user to determine whether
24664ae346bSKenneth D. Merryits device list has changed since the user last called the
24764ae346bSKenneth D. Merry.Dv PCIOCGETCONF
248b5e7e999SRuslan Ermilovioctl.
249b5e7e999SRuslan ErmilovIf the device list has changed, a status of
25064ae346bSKenneth D. Merry.Va PCI_GETCONF_LIST_CHANGED
25164ae346bSKenneth D. Merrywill be passed back.
25264ae346bSKenneth D. Merry.It status
25364ae346bSKenneth D. MerryThe status tells the user the disposition of his request for a device list.
25464ae346bSKenneth D. MerryThe possible status values are:
25564ae346bSKenneth D. Merry.Bl -ohang
25664ae346bSKenneth D. Merry.It PCI_GETCONF_LAST_DEVICE
25710012d53SJohn BaldwinThis means that there are no more devices in the PCI device list matching
25810012d53SJohn Baldwinthe specified criteria after the
25964ae346bSKenneth D. Merryones returned in the
26064ae346bSKenneth D. Merry.Va matches
26164ae346bSKenneth D. Merrybuffer.
26264ae346bSKenneth D. Merry.It PCI_GETCONF_LIST_CHANGED
26364ae346bSKenneth D. MerryThis status tells the user that the
26464ae346bSKenneth D. Merry.Tn PCI
26564ae346bSKenneth D. Merrydevice list has changed since his last call to the
26664ae346bSKenneth D. Merry.Dv PCIOCGETCONF
26764ae346bSKenneth D. Merryioctl and he must reset the
26864ae346bSKenneth D. Merry.Va offset
26964ae346bSKenneth D. Merryand
27064ae346bSKenneth D. Merry.Va generation
27164ae346bSKenneth D. Merryto zero to start over at the beginning of the list.
27264ae346bSKenneth D. Merry.It PCI_GETCONF_MORE_DEVS
27364ae346bSKenneth D. MerryThis tells the user that his buffer was not large enough to hold all of the
27410012d53SJohn Baldwinremaining devices in the device list that match his criteria.
27564ae346bSKenneth D. Merry.It PCI_GETCONF_ERROR
276b5e7e999SRuslan ErmilovThis indicates a general error while servicing the user's request.
277b5e7e999SRuslan ErmilovIf the
27807e3ed79SJohn-Mark Gurney.Va pat_buf_len
27907e3ed79SJohn-Mark Gurneyis not equal to
28007e3ed79SJohn-Mark Gurney.Va num_patterns
28107e3ed79SJohn-Mark Gurneytimes
282b5e7e999SRuslan Ermilov.Fn sizeof "struct pci_match_conf" ,
283b5e7e999SRuslan Ermilov.Va errno
284b5e7e999SRuslan Ermilovwill be set to
285b5e7e999SRuslan Ermilov.Er EINVAL .
28664ae346bSKenneth D. Merry.El
28764ae346bSKenneth D. Merry.El
28864ae346bSKenneth D. Merry.It PCIOCREAD
28964ae346bSKenneth D. MerryThis
29064ae346bSKenneth D. Merry.Xr ioctl 2
29164ae346bSKenneth D. Merryreads the
29264ae346bSKenneth D. Merry.Tn PCI
293999546e1SNiclas Zeisingconfiguration register specified by the passed-in
29464ae346bSKenneth D. Merry.Va pci_io
2955203edcdSRuslan Ermilovstructure.
2965203edcdSRuslan ErmilovThe
29764ae346bSKenneth D. Merry.Va pci_io
29864ae346bSKenneth D. Merrystructure consists of the following fields:
29964ae346bSKenneth D. Merry.Bl -tag -width pi_width
30064ae346bSKenneth D. Merry.It pi_sel
30164ae346bSKenneth D. MerryA
30264ae346bSKenneth D. Merry.Va pcisel
30355aaf894SMarius Stroblstructure which specifies the domain, bus, slot and function the user would
30455aaf894SMarius Strobllike to query.
30555aaf894SMarius StroblIf the specific bus is not found, errno will be set to ENODEV and -1 returned
30655aaf894SMarius Stroblfrom the ioctl.
30764ae346bSKenneth D. Merry.It pi_reg
30864ae346bSKenneth D. MerryThe
30964ae346bSKenneth D. Merry.Tn PCI
310*2d4a74d7SNiclas Zeisingconfiguration registers the user would like to access.
31164ae346bSKenneth D. Merry.It pi_width
312b5e7e999SRuslan ErmilovThe width, in bytes, of the data the user would like to read.
313b5e7e999SRuslan ErmilovThis value
3145203edcdSRuslan Ermilovmay be either 1, 2, or 4.
3155203edcdSRuslan Ermilov3-byte reads and reads larger than 4 bytes are
3165203edcdSRuslan Ermilovnot supported.
3175203edcdSRuslan ErmilovIf an invalid width is passed, errno will be set to EINVAL.
31864ae346bSKenneth D. Merry.It pi_data
31964ae346bSKenneth D. MerryThe data returned by the kernel.
32064ae346bSKenneth D. Merry.El
32164ae346bSKenneth D. Merry.It PCIOCWRITE
32264ae346bSKenneth D. MerryThis
32364ae346bSKenneth D. Merry.Xr ioctl 2
32464ae346bSKenneth D. Merryallows users to write to the
32564ae346bSKenneth D. Merry.Tn PCI
326*2d4a74d7SNiclas Zeisingconfiguration registers specified in the passed-in
32764ae346bSKenneth D. Merry.Va pci_io
3285203edcdSRuslan Ermilovstructure.
3295203edcdSRuslan ErmilovThe
33064ae346bSKenneth D. Merry.Va pci_io
331b5e7e999SRuslan Ermilovstructure is described above.
332b5e7e999SRuslan ErmilovThe limitations on data width described for
33364ae346bSKenneth D. Merryreading registers, above, also apply to writing
33464ae346bSKenneth D. Merry.Tn PCI
33564ae346bSKenneth D. Merryconfiguration registers.
33665d328a3SNiclas Zeising.It PCIOCATTACHED
33765d328a3SNiclas ZeisingThis
33865d328a3SNiclas Zeising.Xr ioctl 2
33965d328a3SNiclas Zeisingallows users to query if a driver is attached to the
34065d328a3SNiclas Zeising.Tn PCI
341999546e1SNiclas Zeisingdevice specified in the passed-in
34265d328a3SNiclas Zeising.Va pci_io
34365d328a3SNiclas Zeisingstructure.
34465d328a3SNiclas ZeisingThe
34565d328a3SNiclas Zeising.Va pci_io
34665d328a3SNiclas Zeisingstructure is described above, however, the
34765d328a3SNiclas Zeising.Va pi_reg
34865d328a3SNiclas Zeisingand
34965d328a3SNiclas Zeising.Va pi_width
35065d328a3SNiclas Zeisingfields are not used.
35165d328a3SNiclas ZeisingThe status of the device is stored in the
35265d328a3SNiclas Zeising.Va pi_data
35365d328a3SNiclas Zeisingfield.
35465d328a3SNiclas ZeisingA value of 0 indicates no driver is attached, while a value larger than 0
35565d328a3SNiclas Zeisingindicates that a driver is attached.
35687842989SKonstantin Belousov.It PCIOCBARMMAP
35787842989SKonstantin BelousovThis
35887842989SKonstantin Belousov.Xr ioctl 2
35987842989SKonstantin Belousovcommand allows userspace processes to
36087842989SKonstantin Belousov.Xr mmap 2
36187842989SKonstantin Belousovthe memory-mapped PCI BAR into its address space.
36287842989SKonstantin BelousovThe input parameters and results are passed in the
36387842989SKonstantin Belousov.Va pci_bar_mmap
36487842989SKonstantin Belousovstructure, which has the following fields:
36587842989SKonstantin Belousov.Bl -tag -width Vt struct pcise pbm_sel
36687842989SKonstantin Belousov.It Vt uint64_t	pbm_map_base
36787842989SKonstantin BelousovReports the established mapping base to the caller.
36887842989SKonstantin BelousovIf
36987842989SKonstantin Belousov.Va PCIIO_BAR_MMAP_FIXED
37087842989SKonstantin Belousovflag was specified, then this field must be filled before the call
37187842989SKonstantin Belousovwith the desired address for the mapping.
37287842989SKonstantin Belousov.It Vt uint64_t pbm_map_length
37387842989SKonstantin BelousovReports the mapped length of the BAR, in bytes.
37487842989SKonstantin BelousovIts .Vt uint64_t value is always multiple of machine pages.
37587842989SKonstantin Belousov.It Vt int64_t pbm_bar_length
37687842989SKonstantin BelousovReports length of the bar as exposed by the device.
37787842989SKonstantin Belousov.It Vt int pbm_bar_off
37887842989SKonstantin BelousovReports offset from the mapped base to the start of the
37987842989SKonstantin Belousovfirst register in the bar.
38087842989SKonstantin Belousov.It Vt struct pcisel pbm_sel
38187842989SKonstantin BelousovShould be filled before the call.
38287842989SKonstantin BelousovDescribes the device to operate on.
38387842989SKonstantin Belousov.It Vt int pbm_reg
38487842989SKonstantin BelousovThe BAR index to mmap.
38587842989SKonstantin Belousov.It Vt int pbm_flags
38687842989SKonstantin BelousovFlags which augments the operation.
38787842989SKonstantin BelousovSee below.
38887842989SKonstantin Belousov.It Vt int pbm_memattr
38987842989SKonstantin BelousovThe caching attribute for the mapping.
39087842989SKonstantin BelousovTypical values are
39187842989SKonstantin Belousov.Dv VM_MEMATTR_UNCACHEABLE
39287842989SKonstantin Belousovfor control registers BARs, and
39387842989SKonstantin Belousov.Dv VM_MEMATTR_WRITE_COMBINING
39487842989SKonstantin Belousovfor frame buffers.
39587842989SKonstantin BelousovRegular memory-like BAR should be mapped with
39687842989SKonstantin Belousov.Dv VM_MEMATTR_DEFAULT
39787842989SKonstantin Belousovattribute.
39887842989SKonstantin Belousov.El
39987842989SKonstantin Belousov.Pp
40087842989SKonstantin BelousovCurrently defined flags are:
40187842989SKonstantin Belousov.Bl -tag -width PCIIO_BAR_MMAP_ACTIVATE
40287842989SKonstantin Belousov.It PCIIO_BAR_MMAP_FIXED
40387842989SKonstantin BelousovThe resulted mappings should be established at the address
40487842989SKonstantin Belousovspecified by the
40587842989SKonstantin Belousov.Va pbm_map_base
40687842989SKonstantin Belousovmember, otherwise fail.
40787842989SKonstantin Belousov.It PCIIO_BAR_MMAP_EXCL
40887842989SKonstantin BelousovMust be used together with
4091adc28f5SChristian Brueffer.Dv PCIIO_BAR_MMAP_FIXED
41087842989SKonstantin BelousovIf the specified base contains already established mappings, the
41187842989SKonstantin Belousovoperation fails instead of implicitly unmapping them.
41287842989SKonstantin Belousov.It PCIIO_BAR_MMAP_RW
41387842989SKonstantin BelousovThe requested mapping allows both reading and writing.
41487842989SKonstantin BelousovWithout the flag, read-only mapping is established.
41587842989SKonstantin BelousovNote that it is common for the device registers to have side-effects
41687842989SKonstantin Belousoveven on reads.
41787842989SKonstantin Belousov.It PCIIO_BAR_MMAP_ACTIVATE
41887842989SKonstantin Belousov(Unimplemented) If the BAR is not activated, activate it in the course
41987842989SKonstantin Belousovof mapping.
42087842989SKonstantin BelousovCurrently attempt to mmap an inactive BAR results in error.
42187842989SKonstantin Belousov.El
42264ae346bSKenneth D. Merry.El
423c97a3872SJohn Baldwin.Sh LOADER TUNABLES
424c97a3872SJohn BaldwinTunables can be set at the
425c97a3872SJohn Baldwin.Xr loader 8
426c97a3872SJohn Baldwinprompt before booting the kernel, or stored in
427c97a3872SJohn Baldwin.Xr loader.conf 5 .
428c97a3872SJohn BaldwinThe current value of these tunables can be examined at runtime via
429c97a3872SJohn Baldwin.Xr sysctl 8
430c97a3872SJohn Baldwinnodes of the same name.
431c97a3872SJohn BaldwinUnless otherwise specified,
432c97a3872SJohn Baldwineach of these tunables is a boolean that can be enabled by setting the
433c97a3872SJohn Baldwintunable to a non-zero value.
434c97a3872SJohn Baldwin.Bl -tag -width indent
435c97a3872SJohn Baldwin.It Va hw.pci.clear_bars Pq Defaults to 0
436c97a3872SJohn BaldwinIgnore any firmware-assigned memory and I/O port resources.
437c97a3872SJohn BaldwinThis forces the
438c97a3872SJohn Baldwin.Tn PCI
439c97a3872SJohn Baldwinbus driver to allocate resource ranges for memory and I/O port resources
440c97a3872SJohn Baldwinfrom scratch.
441c97a3872SJohn Baldwin.It Va hw.pci.clear_buses Pq Defaults to 0
442c97a3872SJohn BaldwinIgnore any firmware-assigned bus number registers in PCI-PCI bridges.
443c97a3872SJohn BaldwinThis forces the
444c97a3872SJohn Baldwin.Tn PCI
445c97a3872SJohn Baldwinbus driver and PCI-PCI bridge driver to allocate bus numbers for secondary
446c97a3872SJohn Baldwinbuses behind PCI-PCI bridges.
447c97a3872SJohn Baldwin.It Va hw.pci.clear_pcib Pq Defaults to 0
448c97a3872SJohn BaldwinIgnore any firmware-assigned memory and I/O port resource windows in PCI-PCI
449c97a3872SJohn Baldwinbridges.
450c97a3872SJohn BaldwinThis forces the PCI-PCI bridge driver to allocate memory and I/O port resources
451c97a3872SJohn Baldwinfor resource windows from scratch.
452c97a3872SJohn Baldwin.Pp
453c97a3872SJohn BaldwinBy default the PCI-PCI bridge driver will allocate windows that
454c97a3872SJohn Baldwincontain the firmware-assigned resources devices behind the bridge.
455c97a3872SJohn BaldwinIn addition, the PCI-PCI bridge driver will suballocate from existing window
456c97a3872SJohn Baldwinregions when possible to satisfy a resource request.
457c97a3872SJohn BaldwinAs a result,
458c97a3872SJohn Baldwinboth
459c97a3872SJohn Baldwin.Va hw.pci.clear_bars
460c97a3872SJohn Baldwinand
461c97a3872SJohn Baldwin.Va hw.pci.clear_pcib
462c97a3872SJohn Baldwinmust be enabled to fully ignore firmware-supplied resource assignments.
463c97a3872SJohn Baldwin.It Va hw.pci.default_vgapci_unit Pq Defaults to -1
464c97a3872SJohn BaldwinBy default,
465c97a3872SJohn Baldwinthe first
466c97a3872SJohn Baldwin.Tn PCI
467c97a3872SJohn BaldwinVGA adapter encountered by the system is assumed to be the boot display device.
468c97a3872SJohn BaldwinThis tunable can be set to choose a specific VGA adapter by specifying the
469c97a3872SJohn Baldwinunit number of the associated
470c97a3872SJohn Baldwin.Va vgapci Ns Ar X
471c97a3872SJohn Baldwindevice.
472c97a3872SJohn Baldwin.It Va hw.pci.do_power_nodriver Pq Defaults to 0
473c97a3872SJohn BaldwinPlace devices into a low power state
474c97a3872SJohn Baldwin.Pq D3
475c97a3872SJohn Baldwinwhen a suitable device driver is not found.
476c97a3872SJohn BaldwinCan be set to one of the following values:
477c97a3872SJohn Baldwin.Bl -tag -width indent
478c97a3872SJohn Baldwin.It 3
479c97a3872SJohn BaldwinPowers down all
480c97a3872SJohn Baldwin.Tn PCI
481c97a3872SJohn Baldwindevices without a device driver.
482c97a3872SJohn Baldwin.It 2
483c97a3872SJohn BaldwinPowers down most devices without a device driver.
484c97a3872SJohn BaldwinPCI devices with the display, memory, and base peripheral device classes
485c97a3872SJohn Baldwinare not powered down.
486c97a3872SJohn Baldwin.It 1
487c97a3872SJohn BaldwinSimilar to a setting of 2 except that storage controllers are also not
488c97a3872SJohn Baldwinpowered down.
489c97a3872SJohn Baldwin.It 0
490c97a3872SJohn BaldwinAll devices are left fully powered.
491c97a3872SJohn Baldwin.El
492c97a3872SJohn Baldwin.Pp
493c97a3872SJohn BaldwinA
494c97a3872SJohn Baldwin.Tn PCI
495c97a3872SJohn Baldwindevice must support power management to be powered down.
496c97a3872SJohn BaldwinPlacing a device into a low power state may not reduce power consumption.
497c97a3872SJohn Baldwin.It Va hw.pci.do_power_resume Pq Defaults to 1
498c97a3872SJohn BaldwinPlace
499c97a3872SJohn Baldwin.Tn PCI
500c97a3872SJohn Baldwindevices into the fully powered state when resuming either the system or an
501c97a3872SJohn Baldwinindividual device.
502c97a3872SJohn BaldwinSetting this to zero is discouraged as the system will not attempt to power
503c97a3872SJohn Baldwinup non-powered PCI devices after a suspend.
504c97a3872SJohn Baldwin.It Va hw.pci.do_power_suspend Pq Defaults to 1
505c97a3872SJohn BaldwinPlace
506c97a3872SJohn Baldwin.Tn PCI
507c97a3872SJohn Baldwindevices into a low power state when suspending either the system or individual
508c97a3872SJohn Baldwindevices.
509c97a3872SJohn BaldwinNormally the D3 state is used as the low power state,
510c97a3872SJohn Baldwinbut firmware may override the desired power state during a system suspend.
511c97a3872SJohn Baldwin.It Va hw.pci.enable_ari Pq Defaults to 1
512c97a3872SJohn BaldwinEnable support for PCI-express Alternative RID Interpretation.
513c97a3872SJohn BaldwinThis is often used in conjunction with SR-IOV.
514c97a3872SJohn Baldwin.It Va hw.pci.enable_io_modes Pq Defaults to 1
515c97a3872SJohn BaldwinEnable memory or I/O port decoding in a PCI device's command register if it has
516c97a3872SJohn Baldwinfirmware-assigned memory or I/O port resources.
517c97a3872SJohn BaldwinThe firmware
518c97a3872SJohn Baldwin.Pq BIOS
519c97a3872SJohn Baldwinin some systems does not enable memory or I/O port decoding for some devices
520c97a3872SJohn Baldwineven when it has assigned resources to the device.
521c97a3872SJohn BaldwinThis enables decoding for such resources during bus probe.
522c97a3872SJohn Baldwin.It Va hw.pci.enable_msi Pq Defaults to 1
523c97a3872SJohn BaldwinEnable support for Message Signalled Interrupts
524c97a3872SJohn Baldwin.Pq MSI .
525c97a3872SJohn BaldwinMSI interrupts can be disabled by setting this tunable to 0.
526c97a3872SJohn Baldwin.It Va hw.pci.enable_msix Pq Defaults to 1
527c97a3872SJohn BaldwinEnable support for extended Message Signalled Interrupts
528c97a3872SJohn Baldwin.Pq MSI-X .
529c97a3872SJohn BaldwinMSI-X interrupts can be disabled by setting this tunable to 0.
530c97a3872SJohn Baldwin.It Va hw.pci.enable_pcie_hp Pq Defaults to 1
531c97a3872SJohn BaldwinEnable support for native PCI-express HotPlug.
532c97a3872SJohn Baldwin.It Va hw.pci.honor_msi_blacklist Pq Defaults to 1
533c97a3872SJohn BaldwinMSI and MSI-X interrupts are disabled for certain chipsets known to have
534c97a3872SJohn Baldwinbroken MSI and MSI-X implementations when this tunable is set.
535c97a3872SJohn BaldwinIt can be set to zero to permit use of MSI and MSI-X interrupts if the
536c97a3872SJohn Baldwinchipset match is a false positive.
537c97a3872SJohn Baldwin.It Va hw.pci.iov_max_config Pq Defaults to 1MB
538c97a3872SJohn BaldwinThe maximum amount of memory permitted for the configuration parameters
539c97a3872SJohn Baldwinused when creating Virtual Functions via SR-IOV.
540c97a3872SJohn BaldwinThis tunable can also be changed at runtime via
541c97a3872SJohn Baldwin.Xr sysctl 8 .
542c97a3872SJohn Baldwin.It Va hw.pci.realloc_bars Pq Defaults to 0
543c97a3872SJohn BaldwinAttempt to allocate a new resource range during the initial device scan
544c97a3872SJohn Baldwinfor any memory or I/O port resources with firmware-assigned ranges that
545c97a3872SJohn Baldwinconflict with another active resource.
546c97a3872SJohn Baldwin.It Va hw.pci.usb_early_takeover Pq Defaults to 1 on Tn amd64 and Tn i386
547c97a3872SJohn BaldwinDisable legacy device emulation of USB devices during the initial device
548c97a3872SJohn Baldwinscan.
549c97a3872SJohn BaldwinSet this tunable to zero to use USB devices via legacy emulation when
550c97a3872SJohn Baldwinusing a custom kernel without USB controller drivers.
551c97a3872SJohn Baldwin.It Va hw.pci<D>.<B>.<S>.INT<P>.irq
552c97a3872SJohn BaldwinThese tunables can be used to override the interrupt routing for legacy
553c97a3872SJohn BaldwinPCI INTx interrupts.
554c97a3872SJohn BaldwinUnlike other tunables in this list,
555c97a3872SJohn Baldwinthese do not have corresponding sysctl nodes.
556c97a3872SJohn BaldwinThe tunable name includes the address of the PCI device as well as the
557c97a3872SJohn Baldwinpin of the desired INTx IRQ to override:
558c97a3872SJohn Baldwin.Bl -tag -width indent
559c97a3872SJohn Baldwin.It <D>
560c97a3872SJohn BaldwinThe domain
561c97a3872SJohn Baldwin.Pq or segment
562c97a3872SJohn Baldwinof the PCI device in decimal.
563c97a3872SJohn Baldwin.It <B>
564c97a3872SJohn BaldwinThe bus address of the PCI device in decimal.
565c97a3872SJohn Baldwin.It <S>
566c97a3872SJohn BaldwinThe slot of the PCI device in decimal.
567c97a3872SJohn Baldwin.It <P>
568c97a3872SJohn BaldwinThe interrupt pin of the PCI slot to override.
569c97a3872SJohn BaldwinOne of
570c97a3872SJohn Baldwin.Ql A ,
571c97a3872SJohn Baldwin.Ql B ,
572c97a3872SJohn Baldwin.Ql C ,
573c97a3872SJohn Baldwinor
574c97a3872SJohn Baldwin.Ql D .
575c97a3872SJohn Baldwin.El
576c97a3872SJohn Baldwin.Pp
577c97a3872SJohn BaldwinThe value of the tunable is the raw IRQ value to use for the INTx interrupt
578c97a3872SJohn Baldwinpin identified by the tunable name.
579c97a3872SJohn BaldwinMapping of IRQ values to platform interrupt sources is machine dependent.
580c97a3872SJohn Baldwin.El
5819b94cc24SWarner Losh.Sh DEVICE WIRING
5829b94cc24SWarner LoshYou can wire the device unit at a given location with device.hints.
5839b94cc24SWarner LoshEntries of the form
5849b94cc24SWarner Losh.Va hints.<name>.<unit>.at="pci<B>:<S>:<F>"
5859b94cc24SWarner Loshor
5869b94cc24SWarner Losh.Va hints.<name>.<unit>.at="pci<D>:<B>:<S>:<F>"
5879b94cc24SWarner Loshwill force the driver
5889b94cc24SWarner Losh.Va name
5899b94cc24SWarner Loshto probe and attach at unit
5909b94cc24SWarner Losh.Va unit
5919b94cc24SWarner Loshfor any PCI device found to match the specification, where:
5929b94cc24SWarner Losh.Bl -tag -width -indent
5939b94cc24SWarner Losh.It <D>
5949b94cc24SWarner LoshThe domain
5959b94cc24SWarner Losh.Pq or segment
5969b94cc24SWarner Loshof the PCI device in decimal.
5979b94cc24SWarner LoshDefaults to 0 if unspecified
5989b94cc24SWarner Losh.It <B>
5999b94cc24SWarner LoshThe bus address of the PCI device in decimal.
6009b94cc24SWarner Losh.It <S>
6019b94cc24SWarner LoshThe slot of the PCI device in decimal.
6029b94cc24SWarner Losh.It <F>
6039b94cc24SWarner LoshThe function of the PCI device in decimal.
6049b94cc24SWarner Losh.El
6059b94cc24SWarner Losh.Pp
6069b94cc24SWarner LoshThe code to do the matching requires an exact string match.
6079b94cc24SWarner LoshDo not specify the angle brackets
6089b94cc24SWarner Losh.Pq < >
6099b94cc24SWarner Loshin the hints file.
6109b94cc24SWarner LoshWiring multiple devices to the same
6119b94cc24SWarner Losh.Va name
6129b94cc24SWarner Loshand
6139b94cc24SWarner Losh.Va unit
6149b94cc24SWarner Loshproduces undefined results.
6159b94cc24SWarner Losh.Ss Examples
6169b94cc24SWarner LoshGiven the following lines in
6179b94cc24SWarner Losh.Pa /boot/device.hints :
6189b94cc24SWarner Losh.Cd hint.nvme.3.at="pci6:0:0"
6199b94cc24SWarner Losh.Cd hint.igb.8.at="pci14:0:0"
6209b94cc24SWarner LoshIf there is a device that supports
6219b94cc24SWarner Losh.Xr igb 4
6229b94cc24SWarner Loshat PCI bus 14 slot 0 function 0,
6239b94cc24SWarner Loshthen it will be assigned igb8 for probe and attach.
6249b94cc24SWarner LoshLikewise, if there is an
6259b94cc24SWarner Losh.Xr nvme 4
6269b94cc24SWarner Loshcard at PCI bus 6 slot 0 function 0,
6279b94cc24SWarner Loshthen it will be assigned nvme3 for probe and attach.
6289b94cc24SWarner LoshIf another type of card is in either of these locations, the name and
6299b94cc24SWarner Loshunit of that card will be the default names and will be unaffected by
6309b94cc24SWarner Loshthese hints.
6319b94cc24SWarner LoshIf other igb or nvme cards are located elsewhere, they will be
6329b94cc24SWarner Loshassigned their unit numbers sequentially, skipping the unit numbers
6339b94cc24SWarner Loshthat have 'at' hints.
63464ae346bSKenneth D. Merry.Sh FILES
6353136363fSRuslan Ermilov.Bl -tag -width /dev/pci -compact
63664ae346bSKenneth D. Merry.It Pa /dev/pci
63764ae346bSKenneth D. MerryCharacter device for the
6384b66483fSRuslan Ermilov.Nm
63964ae346bSKenneth D. Merrydriver.
64064ae346bSKenneth D. Merry.El
64164ae346bSKenneth D. Merry.Sh SEE ALSO
64264ae346bSKenneth D. Merry.Xr pciconf 8
64364ae346bSKenneth D. Merry.Sh HISTORY
64464ae346bSKenneth D. MerryThe
6454b66483fSRuslan Ermilov.Nm
64664ae346bSKenneth D. Merrydriver (not the kernel's
64764ae346bSKenneth D. Merry.Tn PCI
64864ae346bSKenneth D. Merrysupport code) first appeared in
64964ae346bSKenneth D. Merry.Fx 2.2 ,
65064ae346bSKenneth D. Merryand was written by Stefan Esser and Garrett Wollman.
65164ae346bSKenneth D. MerrySupport for device listing and matching was re-implemented by
65264ae346bSKenneth D. MerryKenneth Merry, and first appeared in
65364ae346bSKenneth D. Merry.Fx 3.0 .
65464ae346bSKenneth D. Merry.Sh AUTHORS
6556c899950SBaptiste Daroussin.An Kenneth Merry Aq Mt ken@FreeBSD.org
65664ae346bSKenneth D. Merry.Sh BUGS
6570227791bSRuslan ErmilovIt is not possible for users to specify an accurate offset into the device
65864ae346bSKenneth D. Merrylist without calling the
65964ae346bSKenneth D. Merry.Dv PCIOCGETCONF
66064ae346bSKenneth D. Merryat least once, since they have no way of knowing the current generation
661b5e7e999SRuslan Ermilovnumber otherwise.
6620227791bSRuslan ErmilovThis probably is not a serious problem, though, since
66364ae346bSKenneth D. Merryusers can easily narrow their search by specifying a pattern or patterns
66464ae346bSKenneth D. Merryfor the kernel to match against.
665