Commit 6caed6ba authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Jim Harris
Browse files

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: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470648


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarWojciech Malikowski <wojciech.malikowski@intel.com>
parent f5547359
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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) ");
	}

+10 −0
Original line number Diff line number Diff line
@@ -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.
 */
+7 −0
Original line number Diff line number Diff line
@@ -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;
}
+1 −0
Original line number Diff line number Diff line
@@ -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;