env: add spdk_pci_for_each_device
This is a safer alternative to spdk_pci_get_first/next_device, since those APIs do not hold the lock between calls. Future patches will remove those APIs, and change callers to use this new API instead. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I71c7e8c1feb9112da8be32a8056b30e105e30463 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10655 Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
01cdc4afa1
commit
84e198a925
@ -31,6 +31,10 @@ New APIs, `spdk_nvme_ctrlr_disconnect`, `spdk_nvme_ctrlr_reconnect_async`, and
|
|||||||
the existing APIs,`spdk_nvme_ctrlr_reset_async` and `spdk_nvme_ctrlr_reset_poll_async`
|
the existing APIs,`spdk_nvme_ctrlr_reset_async` and `spdk_nvme_ctrlr_reset_poll_async`
|
||||||
were deprecated.
|
were deprecated.
|
||||||
|
|
||||||
|
### env
|
||||||
|
|
||||||
|
Added spdk_pci_for_each_device.
|
||||||
|
|
||||||
## v21.10
|
## v21.10
|
||||||
|
|
||||||
Structure `spdk_nvmf_target_opts` has been extended with new member `discovery_filter` which allows to specify
|
Structure `spdk_nvmf_target_opts` has been extended with new member `discovery_filter` which allows to specify
|
||||||
|
@ -788,6 +788,14 @@ struct spdk_pci_driver *spdk_pci_nvme_get_driver(void);
|
|||||||
*/
|
*/
|
||||||
int spdk_pci_enumerate(struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb, void *enum_ctx);
|
int spdk_pci_enumerate(struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb, void *enum_ctx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call the provided function pointer for every enumerated PCI device.
|
||||||
|
*
|
||||||
|
* \param ctx Context parameter to pass to fn.
|
||||||
|
* \param fn Function to call for each PCI device
|
||||||
|
*/
|
||||||
|
void spdk_pci_for_each_device(void *ctx, void (*fn)(void *ctx, struct spdk_pci_device *dev));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begin iterating over enumerated PCI device by calling this function to get
|
* Begin iterating over enumerated PCI device by calling this function to get
|
||||||
* the first PCI device. If there no PCI devices enumerated, return NULL
|
* the first PCI device. If there no PCI devices enumerated, return NULL
|
||||||
|
@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
|
|||||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||||
|
|
||||||
SO_VER := 7
|
SO_VER := 7
|
||||||
SO_MINOR := 0
|
SO_MINOR := 1
|
||||||
|
|
||||||
CFLAGS += $(ENV_CFLAGS)
|
CFLAGS += $(ENV_CFLAGS)
|
||||||
C_SRCS = env.c memory.c pci.c init.c threads.c
|
C_SRCS = env.c memory.c pci.c init.c threads.c
|
||||||
|
@ -762,6 +762,18 @@ spdk_pci_enumerate(struct spdk_pci_driver *driver,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
spdk_pci_for_each_device(void *ctx, void (*fn)(void *ctx, struct spdk_pci_device *dev))
|
||||||
|
{
|
||||||
|
struct spdk_pci_device *dev;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&g_pci_mutex);
|
||||||
|
TAILQ_FOREACH(dev, &g_pci_devices, internal.tailq) {
|
||||||
|
fn(ctx, dev);
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&g_pci_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
struct spdk_pci_device *
|
struct spdk_pci_device *
|
||||||
spdk_pci_get_first_device(void)
|
spdk_pci_get_first_device(void)
|
||||||
{
|
{
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
spdk_pci_ioat_get_driver;
|
spdk_pci_ioat_get_driver;
|
||||||
spdk_pci_virtio_get_driver;
|
spdk_pci_virtio_get_driver;
|
||||||
spdk_pci_enumerate;
|
spdk_pci_enumerate;
|
||||||
|
spdk_pci_for_each_device;
|
||||||
spdk_pci_get_first_device;
|
spdk_pci_get_first_device;
|
||||||
spdk_pci_get_next_device;
|
spdk_pci_get_next_device;
|
||||||
spdk_pci_device_map_bar;
|
spdk_pci_device_map_bar;
|
||||||
|
Loading…
Reference in New Issue
Block a user