mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-29 11:54:38 +01:00
nvme: Use newbus to ask if a device is storage
As NVMe is in more places, it has a variety of attachments. On non PCI busses, we assume we're a storage device. For PCI, we look at the interface ID. Add newbus glue to make this happen. Sponsored by: Netflix Discussed with: jhb Reviewed by: adrian Differential Revision: https://reviews.freebsd.org/D56994
This commit is contained in:
1 parent
52c0d52b91
commit
949804c819
3 files changed
+33
No files matched your search
@@ -12,6 +12,14 @@ HEADER {
|
||||
#include "dev/nvme/nvme_private.h"
|
||||
};
|
||||
|
||||
CODE {
|
||||
static bool
|
||||
default_is_storage_device(device_t dev)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# A new namespace is now available
|
||||
#
|
||||
@@ -53,3 +61,10 @@ METHOD int handle_aen {
|
||||
void *page; /* Contents of the page */
|
||||
uint32_t page_len; /* Length of the page */
|
||||
};
|
||||
|
||||
#
|
||||
# is this device a storage device or not.
|
||||
#
|
||||
METHOD bool is_storage_device {
|
||||
device_t dev;
|
||||
} default default_is_storage_device;
|
||||
@@ -38,11 +38,15 @@
|
||||
|
||||
#include "nvme_private.h"
|
||||
|
||||
#include "nvme_if.h"
|
||||
|
||||
static int nvme_pci_probe(device_t);
|
||||
static int nvme_pci_attach(device_t);
|
||||
static int nvme_pci_detach(device_t);
|
||||
static int nvme_pci_suspend(device_t);
|
||||
static int nvme_pci_resume(device_t);
|
||||
static bool nvme_pci_is_storage_device(device_t);
|
||||
|
||||
|
||||
static int nvme_ctrlr_setup_interrupts(struct nvme_controller *ctrlr);
|
||||
|
||||
@@ -54,6 +58,7 @@ static device_method_t nvme_pci_methods[] = {
|
||||
DEVMETHOD(device_suspend, nvme_pci_suspend),
|
||||
DEVMETHOD(device_resume, nvme_pci_resume),
|
||||
DEVMETHOD(device_shutdown, nvme_shutdown),
|
||||
DEVMETHOD(nvme_is_storage_device, nvme_pci_is_storage_device),
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
@@ -421,3 +426,13 @@ nvme_pci_resume(device_t dev)
|
||||
ctrlr = DEVICE2SOFTC(dev);
|
||||
return (nvme_ctrlr_resume(ctrlr));
|
||||
}
|
||||
|
||||
static bool
|
||||
nvme_pci_is_storage_device(device_t dev)
|
||||
{
|
||||
/*
|
||||
* NVMHCI 1.0 interfaces are the only devices that
|
||||
* have namespaces with LBA ranges.
|
||||
*/
|
||||
return (pci_get_progif(dev) == PCIP_STORAGE_NVM_ENTERPRISE_NVMHCI_1_0);
|
||||
}
|
||||
@@ -324,6 +324,9 @@ nvme_sim_probe(device_t dev)
|
||||
if (nvme_use_nvd)
|
||||
return (ENXIO);
|
||||
|
||||
if (!NVME_IS_STORAGE_DEVICE(device_get_parent(dev)))
|
||||
return (ENXIO);
|
||||
|
||||
device_set_desc(dev, "nvme cam");
|
||||
return (BUS_PROBE_DEFAULT);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user