lib/env_dpdk: Allow iterating over all detected PCI devices
Added spdk_pci_get_first_device() and spdk_pci_get_next_device() to iterate over all devices on g_pci_devices list. Change-Id: I65079fb3e274195707dee64bc1fb8b4b72d07352 Signed-off-by: Wojciech Malikowski <wojciech.malikowski@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450924 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
b9e8dc71f7
commit
f056bc6524
@ -728,6 +728,25 @@ struct spdk_pci_driver *spdk_pci_virtio_get_driver(void);
|
||||
*/
|
||||
int spdk_pci_enumerate(struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb, void *enum_ctx);
|
||||
|
||||
/**
|
||||
* Begin iterating over enumerated PCI device by calling this function to get
|
||||
* the first PCI device. If there no PCI devices enumerated, return NULL
|
||||
*
|
||||
* \return a pointer to a PCI device on success, NULL otherwise.
|
||||
*/
|
||||
struct spdk_pci_device *spdk_pci_get_first_device(void);
|
||||
|
||||
/**
|
||||
* Continue iterating over enumerated PCI devices.
|
||||
* If no additional PCI devices, return NULL
|
||||
*
|
||||
* \param prev Previous PCI device returned from \ref spdk_pci_get_first_device
|
||||
* or \ref spdk_pci_get_next_device
|
||||
*
|
||||
* \return a pointer to the next PCI device on success, NULL otherwise.
|
||||
*/
|
||||
struct spdk_pci_device *spdk_pci_get_next_device(struct spdk_pci_device *prev);
|
||||
|
||||
/**
|
||||
* Map a PCI BAR in the current process.
|
||||
*
|
||||
|
@ -464,6 +464,18 @@ spdk_pci_enumerate(struct spdk_pci_driver *driver,
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct spdk_pci_device *
|
||||
spdk_pci_get_first_device(void)
|
||||
{
|
||||
return TAILQ_FIRST(&g_pci_devices);
|
||||
}
|
||||
|
||||
struct spdk_pci_device *
|
||||
spdk_pci_get_next_device(struct spdk_pci_device *prev)
|
||||
{
|
||||
return TAILQ_NEXT(prev, internal.tailq);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_pci_device_map_bar(struct spdk_pci_device *dev, uint32_t bar,
|
||||
void **mapped_addr, uint64_t *phys_addr, uint64_t *size)
|
||||
|
Loading…
x
Reference in New Issue
Block a user