env: Add spdk_pci_get_device
This function will return a device handle from a pci address. Change-Id: I323d92c71014ef571f3df9f19c2ec887844707e8 Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
5bc79e9c3d
commit
9511b2a20b
@ -186,6 +186,8 @@ typedef int (*spdk_pci_enum_cb)(void *enum_ctx, struct spdk_pci_device *pci_dev)
|
||||
int spdk_pci_nvme_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx);
|
||||
int spdk_pci_ioat_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx);
|
||||
|
||||
struct spdk_pci_device *spdk_pci_get_device(struct spdk_pci_addr *pci_addr);
|
||||
|
||||
int spdk_pci_device_map_bar(struct spdk_pci_device *dev, uint32_t bar,
|
||||
void **mapped_addr, uint64_t *phys_addr, uint64_t *size);
|
||||
int spdk_pci_device_unmap_bar(struct spdk_pci_device *dev, uint32_t bar, void *addr);
|
||||
|
@ -141,6 +141,34 @@ spdk_pci_enumerate(struct spdk_pci_enum_ctx *ctx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct spdk_pci_device *
|
||||
spdk_pci_get_device(struct spdk_pci_addr *pci_addr)
|
||||
{
|
||||
struct rte_pci_device *dev;
|
||||
struct rte_pci_addr addr;
|
||||
int rc;
|
||||
|
||||
addr.domain = pci_addr->domain;
|
||||
addr.bus = pci_addr->bus;
|
||||
addr.devid = pci_addr->dev;
|
||||
addr.function = pci_addr->func;
|
||||
|
||||
TAILQ_FOREACH(dev, &pci_device_list, next) {
|
||||
rc = rte_eal_compare_pci_addr(&dev->addr, &addr);
|
||||
if (rc < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rc == 0) {
|
||||
return (struct spdk_pci_device *)dev;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_pci_device_map_bar(struct spdk_pci_device *device, uint32_t bar,
|
||||
void **mapped_addr, uint64_t *phys_addr, uint64_t *size)
|
||||
|
Loading…
Reference in New Issue
Block a user