Commit 38462248 authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Jim Harris
Browse files

env: make the generic device attach API public



This follows the overall model introduced together
with PCI device hooks. Having an additional set of
attach/enumerate/hook functions for each device type
doesn't scale well. We can simplify this by moving
the driver-agnostic attach and enumerate functions to
the public headers. It'll be used directly by the
upcoming VMD driver.

Change-Id: Ie2039389b6ea530d74d568dc7ebe8b214f547057
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/435804


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent aade7e3b
Loading
Loading
Loading
Loading
+36 −17
Original line number Diff line number Diff line
@@ -627,13 +627,14 @@ typedef int (*spdk_pci_enum_cb)(void *enum_ctx, struct spdk_pci_device *pci_dev)
struct spdk_pci_driver *spdk_pci_nvme_get_driver(void);

/**
 * Enumerate all NVMe devices on the PCI bus and try to attach those that
 * weren't attached yet. The provided callback will be called for each such
 * device and its return code will decide whether that device is attached
 * or not. Attached devices have to be manually detached with
 * spdk_pci_device_detach() to be attach-able again.
 *
 * \param enum_cb Callback to be called for each non-attached NVMe device.
 * Enumerate all PCI devices supported by the provided driver and try to
 * attach those that weren't attached yet. The provided callback will be
 * called for each such device and its return code will decide whether that
 * device is attached or not. Attached devices have to be manually detached
 * with spdk_pci_device_detach() to be attach-able again.
 *
 * \param driver Driver for a specific device type.
 * \param enum_cb Callback to be called for each non-attached PCI device.
 * The return code can be as follows:
 *  -1 - device was not attached, the enumeration is stopped
 *   0 - device attached successfully, enumeration continues
@@ -643,13 +644,21 @@ struct spdk_pci_driver *spdk_pci_nvme_get_driver(void);
 * \return -1 if an internal error occured or the provided callback returned -1,
 *         0 otherwise
 */
int spdk_pci_enumerate(struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb, void *enum_ctx);

/**
 * Enumerate all NVMe devices on the PCI bus and try to attach those that
 * weren't attached yet.
 *
 * \see spdk_pci_enumerate
 */
int spdk_pci_nvme_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx);

/**
 * Enumerate all I/OAT devices on the PCI bus and try to attach those that
 * weren't attached yet.
 *
 * \see spdk_pci_nvme_enumerate
 * \see spdk_pci_enumerate
 */
int spdk_pci_ioat_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx);

@@ -657,7 +666,7 @@ int spdk_pci_ioat_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx);
 * Enumerate all Virtio devices on the PCI bus and try to attach those that
 * weren't attached yet.
 *
 * \see spdk_pci_nvme_enumerate
 * \see spdk_pci_enumerate
 */
int spdk_pci_virtio_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx);

@@ -824,13 +833,15 @@ int spdk_pci_device_claim(const struct spdk_pci_addr *pci_addr);
void spdk_pci_device_detach(struct spdk_pci_device *device);

/**
 * Attach a PCI NVMe device. This will bypass all blacklist rules and
 * explicitly attach a PCI device at the provided address. The return code
 * of the provided callback will decide whether that device is attached
 * or not. Attached devices have to be manually detached with
 * spdk_pci_device_detach() to be attach-able again.
 * Attach a PCI device. This will bypass all blacklist rules and explicitly
 * attach a device at the provided address. The return code of the provided
 * callback will decide whether that device is attached or not. Attached
 * devices have to be manually detached with spdk_pci_device_detach() to be
 * attach-able again.
 *
 * \param enum_cb Callback to be called for the NVMe device once it's found.
 * \param driver Driver for a specific device type. The device will only be
 * attached if it's supported by this driver.
 * \param enum_cb Callback to be called for the PCI device once it's found.
 * The return code can be as follows:
 *  -1, 1 - an error occured, fail the attach request entirely
 *   0 - device attached successfully
@@ -841,13 +852,21 @@ void spdk_pci_device_detach(struct spdk_pci_device *device);
 *         -1 if an internal error happened or the provided callback returned non-zero,
 *         0 otherwise
 */
int spdk_pci_device_attach(struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb,
			   void *enum_ctx, struct spdk_pci_addr *pci_address);

/**
 * Attach a PCI NVMe device.
 *
 * \see spdk_pci_device_attach
 */
int spdk_pci_nvme_device_attach(spdk_pci_enum_cb enum_cb, void *enum_ctx,
				struct spdk_pci_addr *pci_address);

/**
 * Attach a PCI I/OAT device.
 *
 * \see spdk_pci_nvme_device_attach
 * \see spdk_pci_device_attach
 */
int spdk_pci_ioat_device_attach(spdk_pci_enum_cb enum_cb, void *enum_ctx,
				struct spdk_pci_addr *pci_address);
@@ -855,7 +874,7 @@ int spdk_pci_ioat_device_attach(spdk_pci_enum_cb enum_cb, void *enum_ctx,
/**
 * Attach a PCI Virtio device.
 *
 * \see spdk_pci_nvme_device_attach
 * \see spdk_pci_device_attach
 */
int spdk_pci_virtio_device_attach(spdk_pci_enum_cb enum_cb, void *enum_ctx,
				  struct spdk_pci_addr *pci_address);
+0 −4
Original line number Diff line number Diff line
@@ -90,10 +90,6 @@ void spdk_pci_driver_register(struct spdk_pci_driver *driver);
int spdk_pci_device_init(struct rte_pci_driver *driver, struct rte_pci_device *device);
int spdk_pci_device_fini(struct rte_pci_device *device);

int spdk_pci_enumerate(struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb, void *enum_ctx);
int spdk_pci_device_attach(struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb, void *enum_ctx,
			   struct spdk_pci_addr *pci_address);

void spdk_pci_init(void);
int spdk_mem_map_init(void);
int spdk_vtophys_init(void);