diff --git a/app/spdk_lspci/spdk_lspci.c b/app/spdk_lspci/spdk_lspci.c index b14d71b96..c005857e2 100644 --- a/app/spdk_lspci/spdk_lspci.c +++ b/app/spdk_lspci/spdk_lspci.c @@ -60,7 +60,7 @@ print_pci_dev(struct spdk_pci_device *dev) spdk_pci_device_get_vendor_id(dev), spdk_pci_device_get_device_id(dev)); - if (dev->parent && dev->parent->internal.driver == spdk_pci_vmd_get_driver()) { + if (strcmp(spdk_pci_device_get_type(dev), "vmd") == 0) { printf(" (NVMe disk behind VMD) "); } diff --git a/include/spdk/env.h b/include/spdk/env.h index 7214fe532..48e4c80c0 100644 --- a/include/spdk/env.h +++ b/include/spdk/env.h @@ -655,6 +655,7 @@ struct spdk_pci_device { struct spdk_pci_addr addr; struct spdk_pci_id id; int socket_id; + const char *type; int (*map_bar)(struct spdk_pci_device *dev, uint32_t bar, void **mapped_addr, uint64_t *phys_addr, uint64_t *size); @@ -1101,6 +1102,15 @@ void spdk_pci_hook_device(struct spdk_pci_driver *drv, struct spdk_pci_device *d */ void spdk_pci_unhook_device(struct spdk_pci_device *dev); +/** + * Return the type of the PCI device. + * + * \param dev PCI device + * + * \return string representing the type of the device + */ +const char *spdk_pci_device_get_type(const struct spdk_pci_device *dev); + /** * Remove any CPU affinity from the current thread. */ diff --git a/lib/env_dpdk/pci.c b/lib/env_dpdk/pci.c index fad7ea8bb..2e9d4070c 100644 --- a/lib/env_dpdk/pci.c +++ b/lib/env_dpdk/pci.c @@ -334,6 +334,7 @@ spdk_pci_device_init(struct rte_pci_driver *_drv, dev->id.subvendor_id = _dev->id.subsystem_vendor_id; dev->id.subdevice_id = _dev->id.subsystem_device_id; dev->socket_id = _dev->device.numa_node; + dev->type = "pci"; dev->map_bar = spdk_map_bar_rte; dev->unmap_bar = spdk_unmap_bar_rte; @@ -887,3 +888,9 @@ spdk_pci_unhook_device(struct spdk_pci_device *dev) assert(!dev->internal.attached); TAILQ_REMOVE(&g_pci_devices, dev, internal.tailq); } + +const char * +spdk_pci_device_get_type(const struct spdk_pci_device *dev) +{ + return dev->type; +} diff --git a/lib/vmd/vmd.c b/lib/vmd/vmd.c index f2d9dbf1a..d61f60d65 100644 --- a/lib/vmd/vmd.c +++ b/lib/vmd/vmd.c @@ -681,6 +681,7 @@ vmd_dev_init(struct vmd_pci_device *dev) dev->pci.addr.func = 0; dev->pci.id.vendor_id = dev->header->common.vendor_id; dev->pci.id.device_id = dev->header->common.device_id; + dev->pci.type = "vmd"; dev->pci.map_bar = vmd_dev_map_bar; dev->pci.unmap_bar = vmd_dev_unmap_bar; dev->pci.cfg_read = vmd_dev_cfg_read;