Commit f056bc65 authored by Wojciech Malikowski's avatar Wojciech Malikowski Committed by Ben Walker
Browse files

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: default avatarWojciech Malikowski <wojciech.malikowski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450924


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent b9e8dc71
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -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.
 *
+12 −0
Original line number Diff line number Diff line
@@ -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)