Utilities and Helpers
-
int pci_bind(const char *bdf, const char *driver)
Bind a pci device to a driver
Parameters
const char *bdf
pci device identifier (“bus:device:function”)
const char *driver
driver name
Description
Bind the device identified by bdf to the driver identified by driver.
Return
On success, returns 0
. On error, returns -1
and sets
errno
.
-
int pci_unbind(const char *bdf)
Unbind a device from its current driver
Parameters
const char *bdf
pci device identifier (“bus:device:function”)
Description
Unbind the device identified by bdf from its current driver.
Return
On success, returns 0
. On error, returns -1
and sets
errno
.
-
int pci_driver_new_id(const char *driver, uint16_t vid, uint16_t did)
Add a new vendor/device id to the given driver
Parameters
const char *driver
kernel driver
uint16_t vid
vendor id
uint16_t did
device id
Description
Add a new vendor/device id pair to the given driver.
Return
On success, returns 0
. On error, returns -1
and sets
errno
.
-
int pci_driver_remove_id(const char *driver, uint16_t vid, uint16_t did)
Remove a vendor/device id from the given driver
Parameters
const char *driver
kernel driver
uint16_t vid
vendor id
uint16_t did
device id
Description
Remove a vendor/device id pair from the given driver.
Return
On success, returns 0
. On error, returns -1
and sets
errno
.
-
int pci_device_info_get_ull(const char *bdf, const char *prop, unsigned long long *v)
Get sysfs property
Parameters
const char *bdf
pci device identifier (“bus:device:function”)
const char *prop
sysfs property
unsigned long long *v
output parameter
Description
Read an interger value from a sysfs property.
Return
On success, returns 0
. On error, returns -1
and sets
errno
.
-
char *pci_get_driver(const char *bdf)
Get the name of the driver that the device is currently bound to
Parameters
const char *bdf
pci device identifier (“bus:device:function”)
Description
Get the name of the driver the device identified by bdf is currently bound to.
Return
The name of driver device bound to bdf.
-
char *pci_get_iommu_group(const char *bdf)
Get iommu group path
Parameters
const char *bdf
pci device identifier (“bus:device:function”)
Description
Get the iommu group path (/dev/vfio/N) of the device identified by bdf.
Return
The path to the iommu group
-
char *pci_get_device_vfio_id(const char *bdf)
Get vfio device id
Parameters
const char *bdf
pci device identifier (“bus:device:function”)
Description
Get the vfio device id (/sys/bus/pci/devices/s
/vfio-dev/vfio``d``) of the
device identified by bdf.
Return
The vfio device id name