env: add spdk_pci_device_get_type

The function allows the user to get string representation of the type of
a PCI device.

Change-Id: I02abcd9fc98ba912ca4d7936be22e9d5b4950ea2
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470648
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Wojciech Malikowski <wojciech.malikowski@intel.com>
This commit is contained in:
Konrad Sztyber 2019-10-03 09:34:42 +02:00 committed by Jim Harris
parent f554735911
commit 6caed6bac8
4 changed files with 19 additions and 1 deletions

View File

@ -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) ");
}

View File

@ -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.
*/

View File

@ -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;
}

View File

@ -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;