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.\" 26*e5cbf0e8SJohn Baldwin.Dd March 27, 2025 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 , 3382d69277SJohn 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 , 38*e5cbf0e8SJohn Baldwin.Nm pci_enable_pme , 39aac0aafaSHiten Pandya.Nm pci_find_bsf , 40855ed4c5SJohn Baldwin.Nm pci_find_cap , 4155aaf894SMarius Strobl.Nm pci_find_dbsf , 420a9c80e5SJohn Baldwin.Nm pci_find_device , 4368bf9717SJohn Baldwin.Nm pci_find_extcap , 4468bf9717SJohn Baldwin.Nm pci_find_htcap , 457a16dacdSBryan Venteicher.Nm pci_find_next_cap , 467a16dacdSBryan Venteicher.Nm pci_find_next_extcap , 477a16dacdSBryan Venteicher.Nm pci_find_next_htcap , 4887dd2f95SJohn Baldwin.Nm pci_find_pcie_root_port , 49d7be980dSAndrew Turner.Nm pci_get_id , 502ab0398dSJohn Baldwin.Nm pci_get_max_payload , 51855ed4c5SJohn Baldwin.Nm pci_get_max_read_req , 520a9c80e5SJohn Baldwin.Nm pci_get_powerstate , 53855ed4c5SJohn Baldwin.Nm pci_get_vpd_ident , 54855ed4c5SJohn Baldwin.Nm pci_get_vpd_readonly , 55*e5cbf0e8SJohn Baldwin.Nm pci_has_pm , 567d971e36SRyan Stone.Nm pci_iov_attach , 570aee83ccSJohn Baldwin.Nm pci_iov_attach_name , 587d971e36SRyan Stone.Nm pci_iov_detach , 59855ed4c5SJohn Baldwin.Nm pci_msi_count , 60855ed4c5SJohn Baldwin.Nm pci_msix_count , 61ce204e1bSJohn Baldwin.Nm pci_msix_pba_bar , 62ce204e1bSJohn Baldwin.Nm pci_msix_table_bar , 63855ed4c5SJohn Baldwin.Nm pci_pending_msix , 640a9c80e5SJohn Baldwin.Nm pci_read_config , 65855ed4c5SJohn Baldwin.Nm pci_release_msi , 66855ed4c5SJohn Baldwin.Nm pci_remap_msix , 670a9c80e5SJohn Baldwin.Nm pci_restore_state , 680a9c80e5SJohn Baldwin.Nm pci_save_state , 69855ed4c5SJohn Baldwin.Nm pci_set_max_read_req , 700a9c80e5SJohn Baldwin.Nm pci_set_powerstate , 71ec603c72SJohn Baldwin.Nm pci_write_config , 72ec603c72SJohn Baldwin.Nm pcie_adjust_config , 73da0fc925SJohn Baldwin.Nm pcie_flr , 74da0fc925SJohn Baldwin.Nm pcie_get_max_completion_timeout , 75ec603c72SJohn Baldwin.Nm pcie_read_config , 76da0fc925SJohn Baldwin.Nm pcie_wait_for_pending_transactions , 77ec603c72SJohn Baldwin.Nm pcie_write_config 78aac0aafaSHiten Pandya.Nd PCI bus interface 79aac0aafaSHiten Pandya.Sh SYNOPSIS 80aac0aafaSHiten Pandya.In sys/bus.h 81aac0aafaSHiten Pandya.In dev/pci/pcireg.h 82855ed4c5SJohn Baldwin.In dev/pci/pcivar.h 83855ed4c5SJohn Baldwin.Ft int 84855ed4c5SJohn Baldwin.Fn pci_alloc_msi "device_t dev" "int *count" 85855ed4c5SJohn Baldwin.Ft int 86855ed4c5SJohn Baldwin.Fn pci_alloc_msix "device_t dev" "int *count" 8782d69277SJohn Baldwin.Ft void 8882d69277SJohn Baldwin.Fn pci_clear_pme "device_t dev" 89aac0aafaSHiten Pandya.Ft int 90aac0aafaSHiten Pandya.Fn pci_disable_busmaster "device_t dev" 91aac0aafaSHiten Pandya.Ft int 92aac0aafaSHiten Pandya.Fn pci_disable_io "device_t dev" "int space" 93aac0aafaSHiten Pandya.Ft int 940a9c80e5SJohn Baldwin.Fn pci_enable_busmaster "device_t dev" 95aac0aafaSHiten Pandya.Ft int 960a9c80e5SJohn Baldwin.Fn pci_enable_io "device_t dev" "int space" 97*e5cbf0e8SJohn Baldwin.Ft void 98*e5cbf0e8SJohn Baldwin.Fn pci_enable_pme "device_t dev" 99aac0aafaSHiten Pandya.Ft device_t 10065bb31b8SRuslan Ermilov.Fn pci_find_bsf "uint8_t bus" "uint8_t slot" "uint8_t func" 101855ed4c5SJohn Baldwin.Ft int 102855ed4c5SJohn Baldwin.Fn pci_find_cap "device_t dev" "int capability" "int *capreg" 103aac0aafaSHiten Pandya.Ft device_t 10455aaf894SMarius Strobl.Fn pci_find_dbsf "uint32_t domain" "uint8_t bus" "uint8_t slot" "uint8_t func" 10555aaf894SMarius Strobl.Ft device_t 10665bb31b8SRuslan Ermilov.Fn pci_find_device "uint16_t vendor" "uint16_t device" 1070a9c80e5SJohn Baldwin.Ft int 10868bf9717SJohn Baldwin.Fn pci_find_extcap "device_t dev" "int capability" "int *capreg" 10968bf9717SJohn Baldwin.Ft int 11068bf9717SJohn Baldwin.Fn pci_find_htcap "device_t dev" "int capability" "int *capreg" 1117a16dacdSBryan Venteicher.Ft int 1127a16dacdSBryan Venteicher.Fn pci_find_next_cap "device_t dev" "int capability" "int start" "int *capreg" 1137a16dacdSBryan Venteicher.Ft int 1147a16dacdSBryan Venteicher.Fn pci_find_next_extcap "device_t dev" "int capability" "int start" "int *capreg" 1157a16dacdSBryan Venteicher.Ft int 1167a16dacdSBryan Venteicher.Fn pci_find_next_htcap "device_t dev" "int capability" "int start" "int *capreg" 11787dd2f95SJohn Baldwin.Ft device_t 11887dd2f95SJohn Baldwin.Fn pci_find_pcie_root_port "device_t dev" 11968bf9717SJohn Baldwin.Ft int 120d7be980dSAndrew Turner.Fn pci_get_id "device_t dev" "enum pci_id_type type" "uintptr_t *id" 121d7be980dSAndrew Turner.Ft int 1222ab0398dSJohn Baldwin.Fn pci_get_max_payload "device_t dev" 1232ab0398dSJohn Baldwin.Ft int 124855ed4c5SJohn Baldwin.Fn pci_get_max_read_req "device_t dev" 125855ed4c5SJohn Baldwin.Ft int 1260a9c80e5SJohn Baldwin.Fn pci_get_powerstate "device_t dev" 127855ed4c5SJohn Baldwin.Ft int 128855ed4c5SJohn Baldwin.Fn pci_get_vpd_ident "device_t dev" "const char **identptr" 129855ed4c5SJohn Baldwin.Ft int 130855ed4c5SJohn Baldwin.Fn pci_get_vpd_readonly "device_t dev" "const char *kw" "const char **vptr" 131*e5cbf0e8SJohn Baldwin.Ft bool 132*e5cbf0e8SJohn Baldwin.Fn pci_has_pm "device_t dev" 133855ed4c5SJohn Baldwin.Ft int 134855ed4c5SJohn Baldwin.Fn pci_msi_count "device_t dev" 135855ed4c5SJohn Baldwin.Ft int 136855ed4c5SJohn Baldwin.Fn pci_msix_count "device_t dev" 137855ed4c5SJohn Baldwin.Ft int 138ce204e1bSJohn Baldwin.Fn pci_msix_pba_bar "device_t dev" 139ce204e1bSJohn Baldwin.Ft int 140ce204e1bSJohn Baldwin.Fn pci_msix_table_bar "device_t dev" 141ce204e1bSJohn Baldwin.Ft int 142855ed4c5SJohn Baldwin.Fn pci_pending_msix "device_t dev" "u_int index" 1430a9c80e5SJohn Baldwin.Ft uint32_t 1440a9c80e5SJohn Baldwin.Fn pci_read_config "device_t dev" "int reg" "int width" 145855ed4c5SJohn Baldwin.Ft int 146855ed4c5SJohn Baldwin.Fn pci_release_msi "device_t dev" 147855ed4c5SJohn Baldwin.Ft int 148855ed4c5SJohn Baldwin.Fn pci_remap_msix "device_t dev" "int count" "const u_int *vectors" 1490a9c80e5SJohn Baldwin.Ft void 1500a9c80e5SJohn Baldwin.Fn pci_restore_state "device_t dev" 1510a9c80e5SJohn Baldwin.Ft void 1520a9c80e5SJohn Baldwin.Fn pci_save_state "device_t dev" 1530a9c80e5SJohn Baldwin.Ft int 154855ed4c5SJohn Baldwin.Fn pci_set_max_read_req "device_t dev" "int size" 155855ed4c5SJohn Baldwin.Ft int 1560a9c80e5SJohn Baldwin.Fn pci_set_powerstate "device_t dev" "int state" 1570a9c80e5SJohn Baldwin.Ft void 1580a9c80e5SJohn Baldwin.Fn pci_write_config "device_t dev" "int reg" "uint32_t val" "int width" 159ec603c72SJohn Baldwin.Ft uint32_t 160ec603c72SJohn Baldwin.Fo pcie_adjust_config 161ec603c72SJohn Baldwin.Fa "device_t dev" 162ec603c72SJohn Baldwin.Fa "int reg" 163ec603c72SJohn Baldwin.Fa "uint32_t mask" 164ec603c72SJohn Baldwin.Fa "uint32_t val" 165ec603c72SJohn Baldwin.Fa "int width" 166ec603c72SJohn Baldwin.Fc 167da0fc925SJohn Baldwin.Ft bool 168da0fc925SJohn Baldwin.Fn pcie_flr "device_t dev" "u_int max_delay" "bool force" 169da0fc925SJohn Baldwin.Ft int 170da0fc925SJohn Baldwin.Fn pcie_get_max_completion_timeout "device_t dev" 171ec603c72SJohn Baldwin.Ft uint32_t 172ec603c72SJohn Baldwin.Fn pcie_read_config "device_t dev" "int reg" "int width" 173da0fc925SJohn Baldwin.Ft bool 174da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions "device_t dev" "u_int max_delay" 175ec603c72SJohn Baldwin.Ft void 176ec603c72SJohn Baldwin.Fn pcie_write_config "device_t dev" "int reg" "uint32_t val" "int width" 17764414cc0SJohn Baldwin.Ft void 17864414cc0SJohn Baldwin.Fn pci_event_fn "void *arg" "device_t dev" 17964414cc0SJohn Baldwin.Fn EVENTHANDLER_REGISTER "pci_add_device" "pci_event_fn" 18064414cc0SJohn Baldwin.Fn EVENTHANDLER_DEREGISTER "pci_delete_resource" "pci_event_fn" 181f3bb9251SJohn Baldwin.In dev/pci/pci_iov.h 182f3bb9251SJohn Baldwin.Ft int 183f3bb9251SJohn Baldwin.Fn pci_iov_attach "device_t dev" "nvlist_t *pf_schema" "nvlist_t *vf_schema" 184f3bb9251SJohn Baldwin.Ft int 1850aee83ccSJohn Baldwin.Fo pci_iov_attach_name 1860aee83ccSJohn Baldwin.Fa "device_t dev" 1870aee83ccSJohn Baldwin.Fa "nvlist_t *pf_schema" 1880aee83ccSJohn Baldwin.Fa "nvlist_t *vf_schema" 1890aee83ccSJohn Baldwin.Fa "const char *fmt" 1900aee83ccSJohn Baldwin.Fa "..." 1910aee83ccSJohn Baldwin.Fc 1920aee83ccSJohn Baldwin.Ft int 193f3bb9251SJohn Baldwin.Fn pci_iov_detach "device_t dev" 194aac0aafaSHiten Pandya.Sh DESCRIPTION 195aac0aafaSHiten PandyaThe 196aac0aafaSHiten Pandya.Nm 197aac0aafaSHiten Pandyaset of functions are used for managing PCI devices. 198855ed4c5SJohn BaldwinThe functions are split into several groups: 199855ed4c5SJohn Baldwinraw configuration access, 200855ed4c5SJohn Baldwinlocating devices, 201855ed4c5SJohn Baldwindevice information, 202855ed4c5SJohn Baldwindevice configuration, 203855ed4c5SJohn Baldwinand 204855ed4c5SJohn Baldwinmessage signaled interrupts. 205855ed4c5SJohn Baldwin.Ss Raw Configuration Access 206aac0aafaSHiten PandyaThe 207aac0aafaSHiten Pandya.Fn pci_read_config 208aac0aafaSHiten Pandyafunction is used to read data from the PCI configuration 209aac0aafaSHiten Pandyaspace of the device 210aac0aafaSHiten Pandya.Fa dev , 211aac0aafaSHiten Pandyaat offset 212aac0aafaSHiten Pandya.Fa reg , 213aac0aafaSHiten Pandyawith 214aac0aafaSHiten Pandya.Fa width 215aac0aafaSHiten Pandyaspecifying the size of the access. 216aac0aafaSHiten Pandya.Pp 217aac0aafaSHiten PandyaThe 218aac0aafaSHiten Pandya.Fn pci_write_config 219aac0aafaSHiten Pandyafunction is used to write the value 220aac0aafaSHiten Pandya.Fa val 221aac0aafaSHiten Pandyato the PCI configuration 222aac0aafaSHiten Pandyaspace of the device 223aac0aafaSHiten Pandya.Fa dev , 224aac0aafaSHiten Pandyaat offset 225aac0aafaSHiten Pandya.Fa reg , 226aac0aafaSHiten Pandyawith 227aac0aafaSHiten Pandya.Fa width 228aac0aafaSHiten Pandyaspecifying the size of the access. 229aac0aafaSHiten Pandya.Pp 230ec603c72SJohn BaldwinThe 231ec603c72SJohn Baldwin.Fn pcie_adjust_config 232ec603c72SJohn Baldwinfunction is used to modify the value of a register in the PCI-express 233ec603c72SJohn Baldwincapability register set of device 234ec603c72SJohn Baldwin.Fa dev . 235ec603c72SJohn BaldwinThe offset 236ec603c72SJohn Baldwin.Fa reg 237ec603c72SJohn Baldwinspecifies a relative offset in the register set with 238ec603c72SJohn Baldwin.Fa width 239ec603c72SJohn Baldwinspecifying the size of the access. 240ec603c72SJohn BaldwinThe new value of the register is computed by modifying bits set in 241ec603c72SJohn Baldwin.Fa mask 242ec603c72SJohn Baldwinto the value in 243ec603c72SJohn Baldwin.Fa val . 244ec603c72SJohn BaldwinAny bits not specified in 245ec603c72SJohn Baldwin.Fa mask 246ec603c72SJohn Baldwinare preserved. 247ec603c72SJohn BaldwinThe previous value of the register is returned. 248ec603c72SJohn Baldwin.Pp 249ec603c72SJohn BaldwinThe 250ec603c72SJohn Baldwin.Fn pcie_read_config 251ec603c72SJohn Baldwinfunction is used to read the value of a register in the PCI-express 252ec603c72SJohn Baldwincapability register set of device 253ec603c72SJohn Baldwin.Fa dev . 254ec603c72SJohn BaldwinThe offset 255ec603c72SJohn Baldwin.Fa reg 256ec603c72SJohn Baldwinspecifies a relative offset in the register set with 257ec603c72SJohn Baldwin.Fa width 258ec603c72SJohn Baldwinspecifying the size of the access. 259ec603c72SJohn Baldwin.Pp 260ec603c72SJohn BaldwinThe 261ec603c72SJohn Baldwin.Fn pcie_write_config 262ec603c72SJohn Baldwinfunction is used to write the value 263ec603c72SJohn Baldwin.Fa val 264ec603c72SJohn Baldwinto a register in the PCI-express capability register set of device 265ec603c72SJohn Baldwin.Fa dev . 266ec603c72SJohn BaldwinThe offset 267ec603c72SJohn Baldwin.Fa reg 268ec603c72SJohn Baldwinspecifies a relative offset in the register set with 269ec603c72SJohn Baldwin.Fa width 270ec603c72SJohn Baldwinspecifying the size of the access. 271ec603c72SJohn Baldwin.Pp 272855ed4c5SJohn Baldwin.Em NOTE : 273855ed4c5SJohn BaldwinDevice drivers should only use these functions for functionality that 274855ed4c5SJohn Baldwinis not available via another 275855ed4c5SJohn Baldwin.Fn pci 276855ed4c5SJohn Baldwinfunction. 277855ed4c5SJohn Baldwin.Ss Locating Devices 278855ed4c5SJohn BaldwinThe 279855ed4c5SJohn Baldwin.Fn pci_find_bsf 280855ed4c5SJohn Baldwinfunction looks up the 281855ed4c5SJohn Baldwin.Vt device_t 282855ed4c5SJohn Baldwinof a PCI device, given its 283855ed4c5SJohn Baldwin.Fa bus , 284855ed4c5SJohn Baldwin.Fa slot , 285855ed4c5SJohn Baldwinand 286855ed4c5SJohn Baldwin.Fa func . 287855ed4c5SJohn BaldwinThe 288855ed4c5SJohn Baldwin.Fa slot 289855ed4c5SJohn Baldwinnumber actually refers to the number of the device on the bus, 290855ed4c5SJohn Baldwinwhich does not necessarily indicate its geographic location 291855ed4c5SJohn Baldwinin terms of a physical slot. 292855ed4c5SJohn BaldwinNote that in case the system has multiple PCI domains, 293855ed4c5SJohn Baldwinthe 294855ed4c5SJohn Baldwin.Fn pci_find_bsf 295855ed4c5SJohn Baldwinfunction only searches the first one. 296855ed4c5SJohn BaldwinActually, it is equivalent to: 297855ed4c5SJohn Baldwin.Bd -literal -offset indent 298855ed4c5SJohn Baldwinpci_find_dbsf(0, bus, slot, func); 299855ed4c5SJohn Baldwin.Ed 300855ed4c5SJohn Baldwin.Pp 301855ed4c5SJohn BaldwinThe 302855ed4c5SJohn Baldwin.Fn pci_find_dbsf 303855ed4c5SJohn Baldwinfunction looks up the 304855ed4c5SJohn Baldwin.Vt device_t 305855ed4c5SJohn Baldwinof a PCI device, given its 306855ed4c5SJohn Baldwin.Fa domain , 307855ed4c5SJohn Baldwin.Fa bus , 308855ed4c5SJohn Baldwin.Fa slot , 309855ed4c5SJohn Baldwinand 310855ed4c5SJohn Baldwin.Fa func . 311855ed4c5SJohn BaldwinThe 312855ed4c5SJohn Baldwin.Fa slot 313855ed4c5SJohn Baldwinnumber actually refers to the number of the device on the bus, 314855ed4c5SJohn Baldwinwhich does not necessarily indicate its geographic location 315855ed4c5SJohn Baldwinin terms of a physical slot. 316855ed4c5SJohn Baldwin.Pp 317855ed4c5SJohn BaldwinThe 318855ed4c5SJohn Baldwin.Fn pci_find_device 319855ed4c5SJohn Baldwinfunction looks up the 320855ed4c5SJohn Baldwin.Vt device_t 321855ed4c5SJohn Baldwinof a PCI device, given its 322855ed4c5SJohn Baldwin.Fa vendor 323855ed4c5SJohn Baldwinand 324855ed4c5SJohn Baldwin.Fa device 325855ed4c5SJohn BaldwinIDs. 326855ed4c5SJohn BaldwinNote that there can be multiple matches for this search; this function 327855ed4c5SJohn Baldwinonly returns the first matching device. 328855ed4c5SJohn Baldwin.Ss Device Information 329855ed4c5SJohn BaldwinThe 330855ed4c5SJohn Baldwin.Fn pci_find_cap 331855ed4c5SJohn Baldwinfunction is used to locate the first instance of a PCI capability 332855ed4c5SJohn Baldwinregister set for the device 333855ed4c5SJohn Baldwin.Fa dev . 334855ed4c5SJohn BaldwinThe capability to locate is specified by ID via 335855ed4c5SJohn Baldwin.Fa capability . 336855ed4c5SJohn BaldwinConstant macros of the form 337855ed4c5SJohn Baldwin.Dv PCIY_xxx 338855ed4c5SJohn Baldwinfor standard capability IDs are defined in 339855ed4c5SJohn Baldwin.In dev/pci/pcireg.h . 340855ed4c5SJohn BaldwinIf the capability is found, then 341855ed4c5SJohn Baldwin.Fa *capreg 342281a359eSJohn Baldwinis set to the offset in configuration space of the capability register set, 343855ed4c5SJohn Baldwinand 344855ed4c5SJohn Baldwin.Fn pci_find_cap 345855ed4c5SJohn Baldwinreturns zero. 346855ed4c5SJohn BaldwinIf the capability is not found or the device does not support capabilities, 347855ed4c5SJohn Baldwin.Fn pci_find_cap 348855ed4c5SJohn Baldwinreturns an error. 3497a16dacdSBryan VenteicherThe 3507a16dacdSBryan Venteicher.Fn pci_find_next_cap 3517a16dacdSBryan Venteicherfunction is used to locate the next instance of a PCI capability 3527a16dacdSBryan Venteicherregister set for the device 3537a16dacdSBryan Venteicher.Fa dev . 3547a16dacdSBryan VenteicherThe 3557a16dacdSBryan Venteicher.Fa start 3567a16dacdSBryan Venteichershould be the 3577a16dacdSBryan Venteicher.Fa *capreg 3587a16dacdSBryan Venteicherreturned by a prior 3597a16dacdSBryan Venteicher.Fn pci_find_cap 3607a16dacdSBryan Venteicheror 3617a16dacdSBryan Venteicher.Fn pci_find_next_cap . 3627a16dacdSBryan VenteicherWhen no more instances are located 3637a16dacdSBryan Venteicher.Fn pci_find_next_cap 3647a16dacdSBryan Venteicherreturns an error. 365855ed4c5SJohn Baldwin.Pp 366855ed4c5SJohn BaldwinThe 367*e5cbf0e8SJohn Baldwin.Fn pci_has_pm 368*e5cbf0e8SJohn Baldwinfunction returns true if 369*e5cbf0e8SJohn Baldwin.Fa dev 370*e5cbf0e8SJohn Baldwinsupports power management. 371*e5cbf0e8SJohn Baldwin.Pp 372*e5cbf0e8SJohn BaldwinThe 37368bf9717SJohn Baldwin.Fn pci_find_extcap 37468bf9717SJohn Baldwinfunction is used to locate the first instance of a PCI-express 37568bf9717SJohn Baldwinextended capability register set for the device 37668bf9717SJohn Baldwin.Fa dev . 37768bf9717SJohn BaldwinThe extended capability to locate is specified by ID via 37868bf9717SJohn Baldwin.Fa capability . 37968bf9717SJohn BaldwinConstant macros of the form 38068bf9717SJohn Baldwin.Dv PCIZ_xxx 38168bf9717SJohn Baldwinfor standard extended capability IDs are defined in 38268bf9717SJohn Baldwin.In dev/pci/pcireg.h . 38368bf9717SJohn BaldwinIf the extended capability is found, then 38468bf9717SJohn Baldwin.Fa *capreg 385281a359eSJohn Baldwinis set to the offset in configuration space of the extended capability 38668bf9717SJohn Baldwinregister set, and 38768bf9717SJohn Baldwin.Fn pci_find_extcap 38868bf9717SJohn Baldwinreturns zero. 38968bf9717SJohn BaldwinIf the extended capability is not found or the device is not a 39068bf9717SJohn BaldwinPCI-express device, 39168bf9717SJohn Baldwin.Fn pci_find_extcap 39268bf9717SJohn Baldwinreturns an error. 3937a16dacdSBryan VenteicherThe 3947a16dacdSBryan Venteicher.Fn pci_find_next_extcap 3957a16dacdSBryan Venteicherfunction is used to locate the next instance of a PCI-express 3967a16dacdSBryan Venteicherextended capability register set for the device 3977a16dacdSBryan Venteicher.Fa dev . 3987a16dacdSBryan VenteicherThe 3997a16dacdSBryan Venteicher.Fa start 4007a16dacdSBryan Venteichershould be the 4017a16dacdSBryan Venteicher.Fa *capreg 4027a16dacdSBryan Venteicherreturned by a prior 4037a16dacdSBryan Venteicher.Fn pci_find_extcap 4047a16dacdSBryan Venteicheror 4057a16dacdSBryan Venteicher.Fn pci_find_next_extcap . 4067a16dacdSBryan VenteicherWhen no more instances are located 4077a16dacdSBryan Venteicher.Fn pci_find_next_extcap 4087a16dacdSBryan Venteicherreturns an error. 40968bf9717SJohn Baldwin.Pp 41068bf9717SJohn BaldwinThe 41168bf9717SJohn Baldwin.Fn pci_find_htcap 41268bf9717SJohn Baldwinfunction is used to locate the first instance of a HyperTransport capability 41368bf9717SJohn Baldwinregister set for the device 41468bf9717SJohn Baldwin.Fa dev . 41568bf9717SJohn BaldwinThe capability to locate is specified by type via 41668bf9717SJohn Baldwin.Fa capability . 41768bf9717SJohn BaldwinConstant macros of the form 41868bf9717SJohn Baldwin.Dv PCIM_HTCAP_xxx 41968bf9717SJohn Baldwinfor standard HyperTransport capability types are defined in 42068bf9717SJohn Baldwin.In dev/pci/pcireg.h . 42168bf9717SJohn BaldwinIf the capability is found, then 42268bf9717SJohn Baldwin.Fa *capreg 423281a359eSJohn Baldwinis set to the offset in configuration space of the capability register set, 42468bf9717SJohn Baldwinand 42568bf9717SJohn Baldwin.Fn pci_find_htcap 42668bf9717SJohn Baldwinreturns zero. 42768bf9717SJohn BaldwinIf the capability is not found or the device is not a HyperTransport device, 42868bf9717SJohn Baldwin.Fn pci_find_htcap 42968bf9717SJohn Baldwinreturns an error. 4307a16dacdSBryan VenteicherThe 4317a16dacdSBryan Venteicher.Fn pci_find_next_htcap 4327a16dacdSBryan Venteicherfunction is used to locate the next instance of a HyperTransport capability 4337a16dacdSBryan Venteicherregister set for the device 4347a16dacdSBryan Venteicher.Fa dev . 4357a16dacdSBryan VenteicherThe 4367a16dacdSBryan Venteicher.Fa start 4377a16dacdSBryan Venteichershould be the 4387a16dacdSBryan Venteicher.Fa *capreg 4397a16dacdSBryan Venteicherreturned by a prior 4407a16dacdSBryan Venteicher.Fn pci_find_htcap 4417a16dacdSBryan Venteicheror 4427a16dacdSBryan Venteicher.Fn pci_find_next_htcap . 4437a16dacdSBryan VenteicherWhen no more instances are located 4447a16dacdSBryan Venteicher.Fn pci_find_next_htcap 4457a16dacdSBryan Venteicherreturns an error. 44668bf9717SJohn Baldwin.Pp 44768bf9717SJohn BaldwinThe 44887dd2f95SJohn Baldwin.Fn pci_find_pcie_root_port 44987dd2f95SJohn Baldwinfunction walks up the PCI device hierarchy to locate the PCI-express root 45087dd2f95SJohn Baldwinport upstream of 45187dd2f95SJohn Baldwin.Fa dev . 45287dd2f95SJohn BaldwinIf a root port is not found, 45387dd2f95SJohn Baldwin.Fn pci_find_pcie_root_port 45487dd2f95SJohn Baldwinreturns 45587dd2f95SJohn Baldwin.Dv NULL . 45687dd2f95SJohn Baldwin.Pp 45787dd2f95SJohn BaldwinThe 458d7be980dSAndrew Turner.Fn pci_get_id 459d7be980dSAndrew Turnerfunction is used to read an identifier from a device. 460d7be980dSAndrew TurnerThe 461d7be980dSAndrew Turner.Fa type 462d7be980dSAndrew Turnerflag is used to specify which identifier to read. 463d7be980dSAndrew TurnerThe following flags are supported: 464d7be980dSAndrew Turner.Bl -hang -width ".Dv PCI_ID_RID" 465d7be980dSAndrew Turner.It Dv PCI_ID_RID 466d7be980dSAndrew TurnerRead the routing identifier for the device. 4671e43b18cSAndrew Turner.It Dv PCI_ID_MSI 4681e43b18cSAndrew TurnerRead the MSI routing ID. 4691e43b18cSAndrew TurnerThis is needed by some interrupt controllers to route MSI and MSI-X interrupts. 470d7be980dSAndrew Turner.El 471d7be980dSAndrew Turner.Pp 472d7be980dSAndrew TurnerThe 473855ed4c5SJohn Baldwin.Fn pci_get_vpd_ident 474855ed4c5SJohn Baldwinfunction is used to fetch a device's Vital Product Data 475855ed4c5SJohn Baldwin.Pq VPD 476855ed4c5SJohn Baldwinidentifier string. 477855ed4c5SJohn BaldwinIf the device 478855ed4c5SJohn Baldwin.Fa dev 479855ed4c5SJohn Baldwinsupports VPD and provides an identifier string, 480855ed4c5SJohn Baldwinthen 481855ed4c5SJohn Baldwin.Fa *identptr 482855ed4c5SJohn Baldwinis set to point at a read-only, null-terminated copy of the identifier 483855ed4c5SJohn Baldwinstring, 484855ed4c5SJohn Baldwinand 485855ed4c5SJohn Baldwin.Fn pci_get_vpd_ident 486855ed4c5SJohn Baldwinreturns zero. 487855ed4c5SJohn BaldwinIf the device does not support VPD or does not provide an identifier 488855ed4c5SJohn Baldwinstring, 489855ed4c5SJohn Baldwinthen 490855ed4c5SJohn Baldwin.Fn pci_get_vpd_ident 491855ed4c5SJohn Baldwinreturns an error. 492855ed4c5SJohn Baldwin.Pp 493855ed4c5SJohn BaldwinThe 494855ed4c5SJohn Baldwin.Fn pci_get_vpd_readonly 495855ed4c5SJohn Baldwinfunction is used to fetch the value of a single VPD read-only keyword 496855ed4c5SJohn Baldwinfor the device 497855ed4c5SJohn Baldwin.Fa dev . 498855ed4c5SJohn BaldwinThe keyword to fetch is identified by the two character string 499855ed4c5SJohn Baldwin.Fa kw . 500855ed4c5SJohn BaldwinIf the device supports VPD and provides a read-only value for the 501855ed4c5SJohn Baldwinrequested keyword, 502855ed4c5SJohn Baldwinthen 503855ed4c5SJohn Baldwin.Fa *vptr 504855ed4c5SJohn Baldwinis set to point at a read-only, null-terminated copy of the value, 505855ed4c5SJohn Baldwinand 506855ed4c5SJohn Baldwin.Fn pci_get_vpd_readonly 507855ed4c5SJohn Baldwinreturns zero. 508855ed4c5SJohn BaldwinIf the device does not support VPD or does not provide the requested 509855ed4c5SJohn Baldwinkeyword, 510855ed4c5SJohn Baldwinthen 511855ed4c5SJohn Baldwin.Fn pci_get_vpd_readonly 512855ed4c5SJohn Baldwinreturns an error. 513da0fc925SJohn Baldwin.Pp 514da0fc925SJohn BaldwinThe 515da0fc925SJohn Baldwin.Fn pcie_get_max_completion_timeout 516da0fc925SJohn Baldwinfunction returns the maximum completion timeout configured for the device 517da0fc925SJohn Baldwin.Fa dev 518da0fc925SJohn Baldwinin microseconds. 519da0fc925SJohn BaldwinIf the 520da0fc925SJohn Baldwin.Fa dev 521da0fc925SJohn Baldwindevice is not a PCI-express device, 522da0fc925SJohn Baldwin.Fn pcie_get_max_completion_timeout 523da0fc925SJohn Baldwinreturns zero. 524da0fc925SJohn BaldwinWhen completion timeouts are disabled for 525da0fc925SJohn Baldwin.Fa dev , 526da0fc925SJohn Baldwinthis function returns the maxmimum timeout that would be used if timeouts 527da0fc925SJohn Baldwinwere enabled. 528da0fc925SJohn Baldwin.Pp 529da0fc925SJohn BaldwinThe 530da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions 531da0fc925SJohn Baldwinfunction waits for any pending transactions initiated by the 532da0fc925SJohn Baldwin.Fa dev 533da0fc925SJohn Baldwindevice to complete. 534da0fc925SJohn BaldwinThe function checks for pending transactions by polling the transactions 535da0fc925SJohn Baldwinpending flag in the PCI-express device status register. 536da0fc925SJohn BaldwinIt returns 537da0fc925SJohn Baldwin.Dv true 538da0fc925SJohn Baldwinonce the transaction pending flag is clear. 539da0fc925SJohn BaldwinIf transactions are still pending after 540da0fc925SJohn Baldwin.Fa max_delay 541da0fc925SJohn Baldwinmilliseconds, 542da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions 543da0fc925SJohn Baldwinreturns 544da0fc925SJohn Baldwin.Dv false . 545da0fc925SJohn BaldwinIf 546da0fc925SJohn Baldwin.Fa max_delay 547da0fc925SJohn Baldwinis set to zero, 548da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions 549da0fc925SJohn Baldwinperforms a single check; 550da0fc925SJohn Baldwinotherwise, 551da0fc925SJohn Baldwinthis function may sleep while polling the transactions pending flag. 552da0fc925SJohn Baldwin.Nm pcie_wait_for_pending_transactions 553da0fc925SJohn Baldwinreturns 554da0fc925SJohn Baldwin.Dv true 555da0fc925SJohn Baldwinif 556da0fc925SJohn Baldwin.Fa dev 557da0fc925SJohn Baldwinis not a PCI-express device. 558855ed4c5SJohn Baldwin.Ss Device Configuration 559aac0aafaSHiten PandyaThe 560aac0aafaSHiten Pandya.Fn pci_enable_busmaster 561aac0aafaSHiten Pandyafunction enables PCI bus mastering for the device 562aac0aafaSHiten Pandya.Fa dev , 563aac0aafaSHiten Pandyaby setting the 564aac0aafaSHiten Pandya.Dv PCIM_CMD_BUSMASTEREN 565aac0aafaSHiten Pandyabit in the 566aac0aafaSHiten Pandya.Dv PCIR_COMMAND 567aac0aafaSHiten Pandyaregister. 568aac0aafaSHiten PandyaThe 569aac0aafaSHiten Pandya.Fn pci_disable_busmaster 570aac0aafaSHiten Pandyafunction clears this bit. 571aac0aafaSHiten Pandya.Pp 572aac0aafaSHiten PandyaThe 573aac0aafaSHiten Pandya.Fn pci_enable_io 574aac0aafaSHiten Pandyafunction enables memory or I/O port address decoding for the device 575aac0aafaSHiten Pandya.Fa dev , 576aac0aafaSHiten Pandyaby setting the 577aac0aafaSHiten Pandya.Dv PCIM_CMD_MEMEN 578aac0aafaSHiten Pandyaor 579aac0aafaSHiten Pandya.Dv PCIM_CMD_PORTEN 580aac0aafaSHiten Pandyabit in the 581aac0aafaSHiten Pandya.Dv PCIR_COMMAND 5825203edcdSRuslan Ermilovregister appropriately. 5835203edcdSRuslan ErmilovThe 584aac0aafaSHiten Pandya.Fn pci_disable_io 585aac0aafaSHiten Pandyafunction clears the appropriate bit. 586aac0aafaSHiten PandyaThe 58765bb31b8SRuslan Ermilov.Fa space 588aac0aafaSHiten Pandyaargument specifies which resource is affected; this can be either 589aac0aafaSHiten Pandya.Dv SYS_RES_MEMORY 590aac0aafaSHiten Pandyaor 591aac0aafaSHiten Pandya.Dv SYS_RES_IOPORT 592aac0aafaSHiten Pandyaas appropriate. 593855ed4c5SJohn BaldwinDevice drivers should generally not use these routines directly. 594855ed4c5SJohn BaldwinThe PCI bus will enable decoding automatically when a 595855ed4c5SJohn Baldwin.Dv SYS_RES_MEMORY 596855ed4c5SJohn Baldwinor 597855ed4c5SJohn Baldwin.Dv SYS_RES_IOPORT 598855ed4c5SJohn Baldwinresource is activated via 599855ed4c5SJohn Baldwin.Xr bus_alloc_resource 9 600855ed4c5SJohn Baldwinor 601855ed4c5SJohn Baldwin.Xr bus_activate_resource 9 . 602aac0aafaSHiten Pandya.Pp 603855ed4c5SJohn BaldwinThe 6042ab0398dSJohn Baldwin.Fn pci_get_max_payload 6052ab0398dSJohn Baldwinfunction returns the current maximum TLP payload size in bytes for a 6062ab0398dSJohn BaldwinPCI-express device. 6072ab0398dSJohn BaldwinIf the 6082ab0398dSJohn Baldwin.Fa dev 6092ab0398dSJohn Baldwindevice is not a PCI-express device, 6102ab0398dSJohn Baldwin.Fn pci_get_max_payload 6112ab0398dSJohn Baldwinreturns zero. 6122ab0398dSJohn Baldwin.Pp 6132ab0398dSJohn BaldwinThe 614855ed4c5SJohn Baldwin.Fn pci_get_max_read_req 615855ed4c5SJohn Baldwinfunction returns the current maximum read request size in bytes for a 616855ed4c5SJohn BaldwinPCI-express device. 617855ed4c5SJohn BaldwinIf the 618855ed4c5SJohn Baldwin.Fa dev 619855ed4c5SJohn Baldwindevice is not a PCI-express device, 620855ed4c5SJohn Baldwin.Fn pci_get_max_read_req 621855ed4c5SJohn Baldwinreturns zero. 622855ed4c5SJohn Baldwin.Pp 623855ed4c5SJohn BaldwinThe 624855ed4c5SJohn Baldwin.Fn pci_set_max_read_req 625855ed4c5SJohn Baldwinsets the PCI-express maximum read request size for 626855ed4c5SJohn Baldwin.Fa dev . 627855ed4c5SJohn BaldwinThe requested 628855ed4c5SJohn Baldwin.Fa size 629855ed4c5SJohn Baldwinmay be adjusted, 630855ed4c5SJohn Baldwinand 631855ed4c5SJohn Baldwin.Fn pci_set_max_read_req 632855ed4c5SJohn Baldwinreturns the actual size set in bytes. 633855ed4c5SJohn BaldwinIf the 634855ed4c5SJohn Baldwin.Fa dev 635855ed4c5SJohn Baldwindevice is not a PCI-express device, 636855ed4c5SJohn Baldwin.Fn pci_set_max_read_req 637855ed4c5SJohn Baldwinreturns zero. 638aac0aafaSHiten Pandya.Pp 639aac0aafaSHiten PandyaThe 640aac0aafaSHiten Pandya.Fn pci_get_powerstate 641adb63907SJohn Baldwinfunction returns the current power state of the device 642aac0aafaSHiten Pandya.Fa dev . 643aac0aafaSHiten PandyaIf the device does not support power management capabilities, then the default 644aac0aafaSHiten Pandyastate of 645aac0aafaSHiten Pandya.Dv PCI_POWERSTATE_D0 646aac0aafaSHiten Pandyais returned. 647adb63907SJohn BaldwinThe following power states are defined by PCI: 64865bb31b8SRuslan Ermilov.Bl -hang -width ".Dv PCI_POWERSTATE_UNKNOWN" 649aac0aafaSHiten Pandya.It Dv PCI_POWERSTATE_D0 650aac0aafaSHiten PandyaState in which device is on and running. 651aac0aafaSHiten PandyaIt is receiving full power from the system and delivering 652aac0aafaSHiten Pandyafull functionality to the user. 653aac0aafaSHiten Pandya.It Dv PCI_POWERSTATE_D1 654aac0aafaSHiten PandyaClass-specific low-power state in which device context may or 6555a2e3b61SDaniel Gerzomay not be lost. 656db4fcadfSConrad MeyerBuses in this state cannot do anything to the bus, to 6579817b894SBruce M Simpsonforce devices to lose context. 658aac0aafaSHiten Pandya.It Dv PCI_POWERSTATE_D2 659aac0aafaSHiten PandyaClass-specific low-power state in which device context may or 660aac0aafaSHiten Pandyamay not be lost. 661aac0aafaSHiten PandyaAttains greater power savings than 662aac0aafaSHiten Pandya.Dv PCI_POWERSTATE_D1 . 663db4fcadfSConrad MeyerBuses in this state can cause devices to lose some context. 664aac0aafaSHiten PandyaDevices 665aac0aafaSHiten Pandya.Em must 666aac0aafaSHiten Pandyabe prepared for the bus to be in this state or higher. 667aac0aafaSHiten Pandya.It Dv PCI_POWERSTATE_D3 668aac0aafaSHiten PandyaState in which the device is off and not running. 669aac0aafaSHiten PandyaDevice context is lost, and power from the device can 670aac0aafaSHiten Pandyabe removed. 671aac0aafaSHiten Pandya.It Dv PCI_POWERSTATE_UNKNOWN 672aac0aafaSHiten PandyaState of the device is unknown. 673aac0aafaSHiten Pandya.El 674aac0aafaSHiten Pandya.Pp 675aac0aafaSHiten PandyaThe 676aac0aafaSHiten Pandya.Fn pci_set_powerstate 677aac0aafaSHiten Pandyafunction is used to transition the device 678aac0aafaSHiten Pandya.Fa dev 679adb63907SJohn Baldwinto the PCI power state 680aac0aafaSHiten Pandya.Fa state . 681adb63907SJohn BaldwinIf the device does not support power management capabilities or 682adb63907SJohn Baldwinit does not support the specific power state 683adb63907SJohn Baldwin.Fa state , 684adb63907SJohn Baldwinthen the function will fail with 685adb63907SJohn Baldwin.Er EOPNOTSUPP . 686aac0aafaSHiten Pandya.Pp 687aac0aafaSHiten PandyaThe 68882d69277SJohn Baldwin.Fn pci_clear_pme 68982d69277SJohn Baldwinfunction is used to clear any pending PME# signal and disable generation 69082d69277SJohn Baldwinof power management events. 69182d69277SJohn Baldwin.Pp 69282d69277SJohn BaldwinThe 693*e5cbf0e8SJohn Baldwin.Fn pci_enable_pme 694*e5cbf0e8SJohn Baldwinfunction is used to enable generation of power management events before 695*e5cbf0e8SJohn Baldwinsuspending a device. 696*e5cbf0e8SJohn Baldwin.Pp 697*e5cbf0e8SJohn BaldwinThe 6987d971e36SRyan Stone.Fn pci_iov_attach 6997d971e36SRyan Stonefunction is used to advertise that the given device 7007d971e36SRyan Stone.Pq and associated device driver 7017d971e36SRyan Stonesupports PCI Single-Root I/O Virtualization 702fe3ff217SPatrick Kelsey.Pq SR-IOV . 7037d971e36SRyan StoneA driver that supports SR-IOV must implement the 704f3bb9251SJohn Baldwin.Xr PCI_IOV_INIT 9 , 705f3bb9251SJohn Baldwin.Xr PCI_IOV_ADD_VF 9 7067d971e36SRyan Stoneand 707f3bb9251SJohn Baldwin.Xr PCI_IOV_UNINIT 9 7087d971e36SRyan Stonemethods. 7097d971e36SRyan StoneThis function should be called during the 7107d971e36SRyan Stone.Xr DEVICE_ATTACH 9 7117d971e36SRyan Stonemethod. 7127d971e36SRyan StoneIf this function returns an error, it is recommended that the device driver 7137d971e36SRyan Stonestill successfully attaches, but runs with SR-IOV disabled. 7147d971e36SRyan StoneThe 7157d971e36SRyan Stone.Fa pf_schema 7167d971e36SRyan Stoneand 7177d971e36SRyan Stone.Fa vf_schema 7187d971e36SRyan Stoneparameters are used to define what device-specific configuration parameters the 7197d971e36SRyan Stonedevice driver accepts when SR-IOV is enabled for the Physical Function 7207d971e36SRyan Stone.Pq PF 7217d971e36SRyan Stoneand for individual Virtual Functions 7227d971e36SRyan Stone.Pq VFs 7237d971e36SRyan Stonerespectively. 7247d971e36SRyan StoneSee 7257d971e36SRyan Stone.Xr pci_iov_schema 9 7267d971e36SRyan Stonefor details on how to construct the schema. 7277d971e36SRyan StoneIf either the 7287d971e36SRyan Stone.Pa pf_schema 7297d971e36SRyan Stoneor 7307d971e36SRyan Stone.Pa vf_schema 7317d971e36SRyan Stoneis invalid or specifies parameter names that conflict with parameter names that 7327d971e36SRyan Stoneare already in use, 7337d971e36SRyan Stone.Fn pci_iov_attach 7347d971e36SRyan Stonewill return an error and SR-IOV will not be available on the PF device. 7357d971e36SRyan StoneIf a driver does not accept configuration parameters for either the PF device 7367d971e36SRyan Stoneor the VF devices, the driver must pass an empty schema for that device. 7377d971e36SRyan StoneThe SR-IOV infrastructure takes ownership of the 7387d971e36SRyan Stone.Fa pf_schema 7397d971e36SRyan Stoneand 7407d971e36SRyan Stone.Fa vf_schema 7417d971e36SRyan Stoneand is responsible for freeing them. 7427d971e36SRyan StoneThe driver must never free the schemas itself. 7437d971e36SRyan Stone.Pp 7447d971e36SRyan StoneThe 7450aee83ccSJohn Baldwin.Fn pci_iov_attach_name 7460aee83ccSJohn Baldwinfunction is a variant of 7470aee83ccSJohn Baldwin.Fn pci_iov_attach 7480aee83ccSJohn Baldwinthat allows the name of the associated character device in 7490aee83ccSJohn Baldwin.Pa /dev/iov 7500aee83ccSJohn Baldwinto be specified by 7510aee83ccSJohn Baldwin.Fa fmt . 7520aee83ccSJohn BaldwinThe 7530aee83ccSJohn Baldwin.Fn pci_iov_attach 7540aee83ccSJohn Baldwinfunction uses the name of 7550aee83ccSJohn Baldwin.Fa dev 7560aee83ccSJohn Baldwinas the device name. 7570aee83ccSJohn Baldwin.Pp 7580aee83ccSJohn BaldwinThe 7597d971e36SRyan Stone.Fn pci_iov_detach 7607d971e36SRyan Stonefunction is used to advise the SR-IOV infrastructure that the driver for the 7617d971e36SRyan Stonegiven device is attempting to detach and that all SR-IOV resources for the 7627d971e36SRyan Stonedevice must be released. 7637d971e36SRyan StoneThis function must be called during the 7647d971e36SRyan Stone.Xr DEVICE_DETACH 9 7657d971e36SRyan Stonemethod if 7667d971e36SRyan Stone.Fn pci_iov_attach 7677d971e36SRyan Stonewas successfully called on the device and 7687d971e36SRyan Stone.Fn pci_iov_detach 7697d971e36SRyan Stonehas not subsequently been called on the device and returned no error. 7707d971e36SRyan StoneIf this function returns an error, the 7717d971e36SRyan Stone.Xr DEVICE_DETACH 9 7727d971e36SRyan Stonemethod must fail and return an error, as detaching the PF driver while VF 7737d971e36SRyan Stonedevices are active would cause system instability. 7747d971e36SRyan StoneThis function is safe to call and will always succeed if 7757d971e36SRyan Stone.Fn pci_iov_attach 7767d971e36SRyan Stonepreviously failed with an error on the given device, or if 7777d971e36SRyan Stone.Fn pci_iov_attach 7787d971e36SRyan Stonewas never called on the device. 7797d971e36SRyan Stone.Pp 7807d971e36SRyan StoneThe 7819415d1e0SJohn Baldwin.Fn pci_save_state 7829415d1e0SJohn Baldwinand 7839415d1e0SJohn Baldwin.Fn pci_restore_state 7849415d1e0SJohn Baldwinfunctions can be used by a device driver to save and restore standard PCI 7859415d1e0SJohn Baldwinconfig registers. 7869415d1e0SJohn BaldwinThe 7879415d1e0SJohn Baldwin.Fn pci_save_state 7889415d1e0SJohn Baldwinfunction must be invoked while the device has valid state before 7899415d1e0SJohn Baldwin.Fn pci_restore_state 7909415d1e0SJohn Baldwincan be used. 7919415d1e0SJohn BaldwinIf the device is not in the fully-powered state 7929415d1e0SJohn Baldwin.Pq Dv PCI_POWERSTATE_D0 7939415d1e0SJohn Baldwinwhen 7949415d1e0SJohn Baldwin.Fn pci_restore_state 7959415d1e0SJohn Baldwinis invoked, 7969415d1e0SJohn Baldwinthen the device will be transitioned to 7979415d1e0SJohn Baldwin.Dv PCI_POWERSTATE_D0 7989415d1e0SJohn Baldwinbefore any config registers are restored. 799da0fc925SJohn Baldwin.Pp 800da0fc925SJohn BaldwinThe 801da0fc925SJohn Baldwin.Fn pcie_flr 802da0fc925SJohn Baldwinfunction requests a Function Level Reset 803da0fc925SJohn Baldwin.Pq FLR 804da0fc925SJohn Baldwinof 805da0fc925SJohn Baldwin.Fa dev . 806da0fc925SJohn BaldwinIf 807da0fc925SJohn Baldwin.Fa dev 808da0fc925SJohn Baldwinis not a PCI-express device or does not support Function Level Resets via 809da0fc925SJohn Baldwinthe PCI-express device control register, 810da0fc925SJohn Baldwin.Dv false 811da0fc925SJohn Baldwinis returned. 812da0fc925SJohn BaldwinPending transactions are drained by disabling busmastering and calling 813da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions 814da0fc925SJohn Baldwinbefore resetting the device. 815da0fc925SJohn BaldwinThe 816da0fc925SJohn Baldwin.Fa max_delay 817da0fc925SJohn Baldwinargument specifies the maximum timeout to wait for pending transactions as 818da0fc925SJohn Baldwindescribed for 819da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions . 820da0fc925SJohn BaldwinIf 821da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions 822da0fc925SJohn Baldwinfails with a timeout and 823da0fc925SJohn Baldwin.Fa force 824da0fc925SJohn Baldwinis 825da0fc925SJohn Baldwin.Dv false , 826da0fc925SJohn Baldwinbusmastering is re-enabled and 827da0fc925SJohn Baldwin.Dv false 828da0fc925SJohn Baldwinis returned. 829da0fc925SJohn BaldwinIf 830da0fc925SJohn Baldwin.Fn pcie_wait_for_pending_transactions 831da0fc925SJohn Baldwinfails with a timeout and 832da0fc925SJohn Baldwin.Fa force 833da0fc925SJohn Baldwinis 834da0fc925SJohn Baldwin.Dv true , 835da0fc925SJohn Baldwinthe device is reset despite the timeout. 836da0fc925SJohn BaldwinAfter the reset has been requested, 837da0fc925SJohn Baldwin.Nm pcie_flr 838da0fc925SJohn Baldwinsleeps for at least 100 milliseconds before returning 839da0fc925SJohn Baldwin.Dv true . 840da0fc925SJohn BaldwinNote that 841da0fc925SJohn Baldwin.Nm pcie_flr 842da0fc925SJohn Baldwindoes not save and restore any state around the reset. 843da0fc925SJohn BaldwinThe caller should save and restore state as needed. 844855ed4c5SJohn Baldwin.Ss Message Signaled Interrupts 845855ed4c5SJohn BaldwinMessage Signaled Interrupts 846855ed4c5SJohn Baldwin.Pq MSI 847855ed4c5SJohn Baldwinand 848855ed4c5SJohn BaldwinEnhanced Message Signaled Interrupts 849855ed4c5SJohn Baldwin.Pq MSI-X 850855ed4c5SJohn Baldwinare PCI capabilities that provide an alternate method for PCI 851855ed4c5SJohn Baldwindevices to signal interrupts. 852855ed4c5SJohn BaldwinThe legacy INTx interrupt is available to PCI devices as a 853855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ 854855ed4c5SJohn Baldwinresource with a resource ID of zero. 855855ed4c5SJohn BaldwinMSI and MSI-X interrupts are available to PCI devices as one or more 856855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ 857855ed4c5SJohn Baldwinresources with resource IDs greater than zero. 858855ed4c5SJohn BaldwinA driver must ask the PCI bus to allocate MSI or MSI-X interrupts 859855ed4c5SJohn Baldwinusing 860855ed4c5SJohn Baldwin.Fn pci_alloc_msi 861855ed4c5SJohn Baldwinor 862855ed4c5SJohn Baldwin.Fn pci_alloc_msix 863855ed4c5SJohn Baldwinbefore it can use MSI or MSI-X 864855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ 865855ed4c5SJohn Baldwinresources. 866855ed4c5SJohn BaldwinA driver is not allowed to use the legacy INTx 867855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ 868855ed4c5SJohn Baldwinresource if MSI or MSI-X interrupts have been allocated, 869855ed4c5SJohn Baldwinand attempts to allocate MSI or MSI-X interrupts will fail if the 870855ed4c5SJohn Baldwindriver is currently using the legacy INTx 871855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ 872855ed4c5SJohn Baldwinresource. 873855ed4c5SJohn BaldwinA driver is only allowed to use either MSI or MSI-X, 874855ed4c5SJohn Baldwinbut not both. 8759415d1e0SJohn Baldwin.Pp 8769415d1e0SJohn BaldwinThe 877563d4639SMark Johnston.Fn pci_msi_count 878855ed4c5SJohn Baldwinfunction returns the maximum number of MSI messages supported by the 879855ed4c5SJohn Baldwindevice 880855ed4c5SJohn Baldwin.Fa dev . 881855ed4c5SJohn BaldwinIf the device does not support MSI, 882855ed4c5SJohn Baldwinthen 883563d4639SMark Johnston.Fn pci_msi_count 884855ed4c5SJohn Baldwinreturns zero. 88555aaf894SMarius Strobl.Pp 88655aaf894SMarius StroblThe 887855ed4c5SJohn Baldwin.Fn pci_alloc_msi 888855ed4c5SJohn Baldwinfunction attempts to allocate 889855ed4c5SJohn Baldwin.Fa *count 890855ed4c5SJohn BaldwinMSI messages for the device 891855ed4c5SJohn Baldwin.Fa dev . 89255aaf894SMarius StroblThe 893855ed4c5SJohn Baldwin.Fn pci_alloc_msi 894855ed4c5SJohn Baldwinfunction may allocate fewer messages than requested for various 895855ed4c5SJohn Baldwinreasons including requests for more messages than the device 896855ed4c5SJohn Baldwin.Fa dev 897855ed4c5SJohn Baldwinsupports, 898855ed4c5SJohn Baldwinor if the system has a shortage of available MSI messages. 899855ed4c5SJohn BaldwinOn success, 900855ed4c5SJohn Baldwin.Fa *count 901855ed4c5SJohn Baldwinis set to the number of messages allocated and 902855ed4c5SJohn Baldwin.Fn pci_alloc_msi 903855ed4c5SJohn Baldwinreturns zero. 904855ed4c5SJohn BaldwinThe 905855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ 906855ed4c5SJohn Baldwinresources for the allocated messages will be available at consecutive 907855ed4c5SJohn Baldwinresource IDs beginning with one. 908855ed4c5SJohn BaldwinIf 909855ed4c5SJohn Baldwin.Fn pci_alloc_msi 910855ed4c5SJohn Baldwinis not able to allocate any messages, 911855ed4c5SJohn Baldwinit returns an error. 912855ed4c5SJohn BaldwinNote that MSI only supports message counts that are powers of two; 913855ed4c5SJohn Baldwinrequests to allocate a non-power of two count of messages will fail. 914aac0aafaSHiten Pandya.Pp 915aac0aafaSHiten PandyaThe 916855ed4c5SJohn Baldwin.Fn pci_release_msi 917855ed4c5SJohn Baldwinfunction is used to release any allocated MSI or MSI-X messages back 918855ed4c5SJohn Baldwinto the system. 919855ed4c5SJohn BaldwinIf any MSI or MSI-X 920855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ 921855ed4c5SJohn Baldwinresources are allocated by the driver or have a configured interrupt 922855ed4c5SJohn Baldwinhandler, 923855ed4c5SJohn Baldwinthis function will fail with 924855ed4c5SJohn Baldwin.Er EBUSY . 925855ed4c5SJohn BaldwinThe 926855ed4c5SJohn Baldwin.Fn pci_release_msi 927855ed4c5SJohn Baldwinfunction returns zero on success and an error on failure. 928855ed4c5SJohn Baldwin.Pp 929642c4993SSergey KandaurovThe 930563d4639SMark Johnston.Fn pci_msix_count 931855ed4c5SJohn Baldwinfunction returns the maximum number of MSI-X messages supported by the 932855ed4c5SJohn Baldwindevice 933855ed4c5SJohn Baldwin.Fa dev . 934855ed4c5SJohn BaldwinIf the device does not support MSI-X, 935855ed4c5SJohn Baldwinthen 936563d4639SMark Johnston.Fn pci_msix_count 937855ed4c5SJohn Baldwinreturns zero. 938855ed4c5SJohn Baldwin.Pp 939855ed4c5SJohn BaldwinThe 940ce204e1bSJohn Baldwin.Fn pci_msix_pba_bar 941ce204e1bSJohn Baldwinfunction returns the offset in configuration space of the Base Address Register 942ce204e1bSJohn Baldwin.Pq BAR 943ce204e1bSJohn Baldwincontaining the MSI-X Pending Bit Array (PBA) for device 944ce204e1bSJohn Baldwin.Fa dev . 945ce204e1bSJohn BaldwinThe returned value can be used as the resource ID with 946ce204e1bSJohn Baldwin.Xr bus_alloc_resource 9 947ce204e1bSJohn Baldwinand 948ce204e1bSJohn Baldwin.Xr bus_release_resource 9 949ce204e1bSJohn Baldwinto allocate the BAR. 950ce204e1bSJohn BaldwinIf the device does not support MSI-X, 951ce204e1bSJohn Baldwinthen 952ce204e1bSJohn Baldwin.Fn pci_msix_pba_bar 953ce204e1bSJohn Baldwinreturns -1. 954ce204e1bSJohn Baldwin.Pp 955ce204e1bSJohn BaldwinThe 956ce204e1bSJohn Baldwin.Fn pci_msix_table_bar 957ce204e1bSJohn Baldwinfunction returns the offset in configuration space of the BAR 958ce204e1bSJohn Baldwincontaining the MSI-X vector table for device 959ce204e1bSJohn Baldwin.Fa dev . 960ce204e1bSJohn BaldwinThe returned value can be used as the resource ID with 961ce204e1bSJohn Baldwin.Xr bus_alloc_resource 9 962ce204e1bSJohn Baldwinand 963ce204e1bSJohn Baldwin.Xr bus_release_resource 9 964ce204e1bSJohn Baldwinto allocate the BAR. 965ce204e1bSJohn BaldwinIf the device does not support MSI-X, 966ce204e1bSJohn Baldwinthen 967ce204e1bSJohn Baldwin.Fn pci_msix_table_bar 968ce204e1bSJohn Baldwinreturns -1. 969ce204e1bSJohn Baldwin.Pp 970ce204e1bSJohn BaldwinThe 971855ed4c5SJohn Baldwin.Fn pci_alloc_msix 972855ed4c5SJohn Baldwinfunction attempts to allocate 973855ed4c5SJohn Baldwin.Fa *count 974855ed4c5SJohn BaldwinMSI-X messages for the device 975855ed4c5SJohn Baldwin.Fa dev . 976855ed4c5SJohn BaldwinThe 977855ed4c5SJohn Baldwin.Fn pci_alloc_msix 978855ed4c5SJohn Baldwinfunction may allocate fewer messages than requested for various 979855ed4c5SJohn Baldwinreasons including requests for more messages than the device 980855ed4c5SJohn Baldwin.Fa dev 981855ed4c5SJohn Baldwinsupports, 982855ed4c5SJohn Baldwinor if the system has a shortage of available MSI-X messages. 983855ed4c5SJohn BaldwinOn success, 984855ed4c5SJohn Baldwin.Fa *count 985855ed4c5SJohn Baldwinis set to the number of messages allocated and 986855ed4c5SJohn Baldwin.Fn pci_alloc_msix 987855ed4c5SJohn Baldwinreturns zero. 988855ed4c5SJohn BaldwinFor MSI-X messages, 989855ed4c5SJohn Baldwinthe resource ID for each 99073bbeaa5SGlen Barber.Dv SYS_RES_IRQ 99173bbeaa5SGlen Barberresource identifies the index in the MSI-X table of the 992855ed4c5SJohn Baldwincorresponding message. 993855ed4c5SJohn BaldwinA resource ID of one maps to the first index of the MSI-X table; 994855ed4c5SJohn Baldwina resource ID two identifies the second index in the table, etc. 995855ed4c5SJohn BaldwinThe 996855ed4c5SJohn Baldwin.Fn pci_alloc_msix 997855ed4c5SJohn Baldwinfunction assigns the 998855ed4c5SJohn Baldwin.Fa *count 999855ed4c5SJohn Baldwinmessages allocated to the first 1000855ed4c5SJohn Baldwin.Fa *count 10017c64ddd5SWarren Blocktable indices. 1002855ed4c5SJohn BaldwinIf 1003855ed4c5SJohn Baldwin.Fn pci_alloc_msix 1004855ed4c5SJohn Baldwinis not able to allocate any messages, 1005855ed4c5SJohn Baldwinit returns an error. 1006855ed4c5SJohn BaldwinUnlike MSI, 1007855ed4c5SJohn BaldwinMSI-X does not require message counts that are powers of two. 1008855ed4c5SJohn Baldwin.Pp 1009ce204e1bSJohn BaldwinThe BARs containing the MSI-X vector table and PBA must be 1010ce204e1bSJohn Baldwinallocated via 1011ce204e1bSJohn Baldwin.Xr bus_alloc_resource 9 1012ce204e1bSJohn Baldwinbefore calling 1013ce204e1bSJohn Baldwin.Fn pci_alloc_msix 1014ce204e1bSJohn Baldwinand must not be released until after calling 1015ce204e1bSJohn Baldwin.Fn pci_release_msi . 1016ce204e1bSJohn BaldwinNote that the vector table and PBA may be stored in the same BAR or in 1017ce204e1bSJohn Baldwindifferent BARs. 1018ce204e1bSJohn Baldwin.Pp 1019855ed4c5SJohn BaldwinThe 1020855ed4c5SJohn Baldwin.Fn pci_pending_msix 1021855ed4c5SJohn Baldwinfunction examines the 1022855ed4c5SJohn Baldwin.Fa dev 1023ce204e1bSJohn Baldwindevice's PBA 1024855ed4c5SJohn Baldwinto determine the pending status of the MSI-X message at table index 1025855ed4c5SJohn Baldwin.Fa index . 1026855ed4c5SJohn BaldwinIf the indicated message is pending, 1027855ed4c5SJohn Baldwinthis function returns a non-zero value; 1028855ed4c5SJohn Baldwinotherwise, 1029855ed4c5SJohn Baldwinit returns zero. 1030855ed4c5SJohn BaldwinPassing an invalid 1031855ed4c5SJohn Baldwin.Fa index 1032855ed4c5SJohn Baldwinto this function will result in undefined behavior. 1033855ed4c5SJohn Baldwin.Pp 1034855ed4c5SJohn BaldwinAs mentioned in the description of 1035855ed4c5SJohn Baldwin.Fn pci_alloc_msix , 1036855ed4c5SJohn BaldwinMSI-X messages are initially assigned to the first N table entries. 1037855ed4c5SJohn BaldwinA driver may use a different distribution of available messages to 1038855ed4c5SJohn Baldwintable entries via the 1039855ed4c5SJohn Baldwin.Fn pci_remap_msix 1040855ed4c5SJohn Baldwinfunction. 104173bbeaa5SGlen BarberNote that this function must be called after a successful call to 1042855ed4c5SJohn Baldwin.Fn pci_alloc_msix 1043855ed4c5SJohn Baldwinbut before any of the 1044855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ 1045855ed4c5SJohn Baldwinresources are allocated. 1046855ed4c5SJohn BaldwinThe 1047855ed4c5SJohn Baldwin.Fn pci_remap_msix 1048855ed4c5SJohn Baldwinfunction returns zero on success, 1049855ed4c5SJohn Baldwinor an error on failure. 1050855ed4c5SJohn Baldwin.Pp 1051855ed4c5SJohn BaldwinThe 1052855ed4c5SJohn Baldwin.Fa vectors 1053855ed4c5SJohn Baldwinarray should contain 1054855ed4c5SJohn Baldwin.Fa count 1055855ed4c5SJohn Baldwinmessage vectors. 1056855ed4c5SJohn BaldwinThe array maps directly to the MSI-X table in that the first entry in 1057855ed4c5SJohn Baldwinthe array specifies the message used for the first entry in the MSI-X 1058855ed4c5SJohn Baldwintable, 1059855ed4c5SJohn Baldwinthe second entry in the array corresponds to the second entry in the 1060855ed4c5SJohn BaldwinMSI-X table, 1061855ed4c5SJohn Baldwinetc. 1062855ed4c5SJohn BaldwinThe vector value in each array index can either be zero to indicate 1063855ed4c5SJohn Baldwinthat no message should be assigned to the corresponding MSI-X table entry, 1064855ed4c5SJohn Baldwinor it can be a number from one to N 1065855ed4c5SJohn Baldwin.Po 1066855ed4c5SJohn Baldwinwhere N is the count returned from the previous call to 1067855ed4c5SJohn Baldwin.Fn pci_alloc_msix 1068855ed4c5SJohn Baldwin.Pc 1069855ed4c5SJohn Baldwinto indicate which of the allocated messages should be assigned to the 1070855ed4c5SJohn Baldwincorresponding MSI-X table entry. 1071855ed4c5SJohn Baldwin.Pp 1072855ed4c5SJohn BaldwinIf 1073855ed4c5SJohn Baldwin.Fn pci_remap_msix 1074855ed4c5SJohn Baldwinsucceeds, 1075855ed4c5SJohn Baldwineach MSI-X table entry with a non-zero vector will have an associated 1076855ed4c5SJohn Baldwin.Dv SYS_RES_IRQ 1077855ed4c5SJohn Baldwinresource whose resource ID corresponds to the table index as described 1078855ed4c5SJohn Baldwinabove for 1079855ed4c5SJohn Baldwin.Fn pci_alloc_msix . 1080855ed4c5SJohn BaldwinMSI-X table entries that with a vector of zero will not have an 1081855ed4c5SJohn Baldwinassociated 108273bbeaa5SGlen Barber.Dv SYS_RES_IRQ 108373bbeaa5SGlen Barberresource. 1084855ed4c5SJohn BaldwinAdditionally, 1085855ed4c5SJohn Baldwinif any of the original messages allocated by 1086855ed4c5SJohn Baldwin.Fn pci_alloc_msix 1087855ed4c5SJohn Baldwinare not used in the new distribution of messages in the MSI-X table, 1088855ed4c5SJohn Baldwinthey will be released automatically. 1089855ed4c5SJohn BaldwinNote that if a driver wishes to use fewer messages than were allocated by 1090855ed4c5SJohn Baldwin.Fn pci_alloc_msix , 1091855ed4c5SJohn Baldwinthe driver must use a single, contiguous range of messages beginning 1092855ed4c5SJohn Baldwinwith one in the new distribution. 1093855ed4c5SJohn BaldwinThe 1094855ed4c5SJohn Baldwin.Fn pci_remap_msix 1095855ed4c5SJohn Baldwinfunction will fail if this condition is not met. 109664414cc0SJohn Baldwin.Ss Device Events 109764414cc0SJohn BaldwinThe 109864414cc0SJohn Baldwin.Va pci_add_device 109964414cc0SJohn Baldwinevent handler is invoked every time a new PCI device is added to the system. 110064414cc0SJohn BaldwinThis includes the creation of Virtual Functions via SR-IOV. 110164414cc0SJohn Baldwin.Pp 110264414cc0SJohn BaldwinThe 110364414cc0SJohn Baldwin.Va pci_delete_device 110464414cc0SJohn Baldwinevent handler is invoked every time a PCI device is removed from the system. 110564414cc0SJohn Baldwin.Pp 110664414cc0SJohn BaldwinBoth event handlers pass the 110764414cc0SJohn Baldwin.Vt device_t 110864414cc0SJohn Baldwinobject of the relevant PCI device as 110964414cc0SJohn Baldwin.Fa dev 111064414cc0SJohn Baldwinto each callback function. 111164414cc0SJohn BaldwinBoth event handlers are invoked while 111264414cc0SJohn Baldwin.Fa dev 111364414cc0SJohn Baldwinis unattached but with valid instance variables. 1114aac0aafaSHiten Pandya.Sh SEE ALSO 11157c2c06f2SSheldon Hearn.Xr pci 4 , 11167c2c06f2SSheldon Hearn.Xr pciconf 8 , 1117aac0aafaSHiten Pandya.Xr bus_alloc_resource 9 , 1118aac0aafaSHiten Pandya.Xr bus_dma 9 , 1119aac0aafaSHiten Pandya.Xr bus_release_resource 9 , 1120aac0aafaSHiten Pandya.Xr bus_setup_intr 9 , 1121aac0aafaSHiten Pandya.Xr bus_teardown_intr 9 , 1122aac0aafaSHiten Pandya.Xr devclass 9 , 1123aac0aafaSHiten Pandya.Xr device 9 , 1124aac0aafaSHiten Pandya.Xr driver 9 , 112564414cc0SJohn Baldwin.Xr eventhandler 9 , 1126aac0aafaSHiten Pandya.Xr rman 9 1127aac0aafaSHiten Pandya.Rs 1128aac0aafaSHiten Pandya.%B FreeBSD Developers' Handbook 1129aac0aafaSHiten Pandya.%T NewBus 1130c1a14887SCeri Davies.%U https://docs.freebsd.org/en/books/developers-handbook/ 1131aac0aafaSHiten Pandya.Re 1132aac0aafaSHiten Pandya.Rs 1133aac0aafaSHiten Pandya.%A Shanley 1134aac0aafaSHiten Pandya.%A Anderson 1135aac0aafaSHiten Pandya.%B PCI System Architecture 1136aac0aafaSHiten Pandya.%N 2nd Edition 1137aac0aafaSHiten Pandya.%I Addison-Wesley 1138aac0aafaSHiten Pandya.%O ISBN 0-201-30974-2 1139aac0aafaSHiten Pandya.Re 1140aac0aafaSHiten Pandya.Sh AUTHORS 11418a7314fcSBaptiste Daroussin.An -nosplit 1142571dba6eSHiten PandyaThis manual page was written by 11438a7314fcSBaptiste Daroussin.An Bruce M Simpson Aq Mt bms@FreeBSD.org 1144855ed4c5SJohn Baldwinand 11458a7314fcSBaptiste Daroussin.An John Baldwin Aq Mt jhb@FreeBSD.org . 1146aac0aafaSHiten Pandya.Sh BUGS 11474d80f750SBruce M SimpsonThe kernel PCI code has a number of references to 11484d80f750SBruce M Simpson.Dq "slot numbers" . 1149bf1639eeSBruce M SimpsonThese do not refer to the geographic location of PCI devices, 1150bf1639eeSBruce M Simpsonbut to the device number assigned by the combination of the PCI IDSEL 1151bf1639eeSBruce M Simpsonmechanism and the platform firmware. 1152bf1639eeSBruce M SimpsonThis should be taken note of when working with the kernel PCI code. 1153ce204e1bSJohn Baldwin.Pp 1154ce204e1bSJohn BaldwinThe PCI bus driver should allocate the MSI-X vector table and PBA internally 1155ce204e1bSJohn Baldwinas necessary rather than requiring the caller to do so. 1156