pci_device_read_capid()

Get the ID of the nth capability that a device supports

Synopsis:

#include <pci/pci.h>

pci_err_t pci_device_read_capid( pci_bdf_t bdf,
                                 pci_capid_t *capid,
                                 uint_t idx );

Arguments:

bdf
The Bus/Device/Function associated with a device.
capid
A pointer to a location where the function can store the capability ID.
idx
The index of the capability.

Library:

libpci

Use the -l pci option to qcc to link against this library.

Description:

You can use pci_device_read_capid() and pci_device_find_capid() to identify which capabilities the device identified by bdf supports. The pci_device_read_capid() function obtains the capability ID for the nth capability (specified by idx and starting at 0) that the device identified by bdf supports.

Note: This function doesn't cause a capability module to be loaded.

The purpose of this function is to obtain the capability index for a capability that the software wishes to enable for the device. You'll use this index when you call pci_device_read_cap().

You can use pci_device_read_capid() to easily loop with an incrementing idx value and obtain the pci_capid_t at that index. If *capid is for a desired capability, you can then read the capability with pci_device_read_cap() and the current idx value.

Returns:

PCI_ERR_OK
Success; *capid holds the ID of the capability at the specified idx.
PCI_ERR_ENOENT
The capability at idx doesn't exist. This usually means the end of the devices capability list, but if idx is 0, it means that the device has no capabilities.
PCI_ERR_EIO
A malformed capability “next” pointer was encountered.

If any error occurs, you should consider the contents of *capid to be invalid data.

Classification:

QNX Neutrino

Safety:  
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

See also:

pci_device_find_capid(), pci_device_read_cap()