diff --git a/lib/nvme/nvme.c b/lib/nvme/nvme.c index f96b73c88b..9f1f8a1f0c 100644 --- a/lib/nvme/nvme.c +++ b/lib/nvme/nvme.c @@ -292,7 +292,7 @@ _spdk_nvme_probe(const struct spdk_nvme_discover_info *info, void *cb_ctx, transport = (uint8_t)info->trtype; } - rc = nvme_transport_ctrlr_scan(transport, probe_cb, cb_ctx, (void *)info); + rc = nvme_transport_ctrlr_scan(transport, probe_cb, cb_ctx, (void *)info, NULL); /* * Keep going even if one or more nvme_attach() calls failed, diff --git a/lib/nvme/nvme_internal.h b/lib/nvme/nvme_internal.h index bb94f43834..cba48d95bb 100644 --- a/lib/nvme/nvme_internal.h +++ b/lib/nvme/nvme_internal.h @@ -545,7 +545,7 @@ struct spdk_nvme_ctrlr *nvme_attach(enum spdk_nvme_transport transport, struct spdk_nvme_ctrlr *nvme_ ## name ## _ctrlr_construct(enum spdk_nvme_transport transport, const struct spdk_nvme_ctrlr_opts *opts, \ const struct spdk_nvme_probe_info *probe_info, void *devhandle); \ int nvme_ ## name ## _ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr); \ - int nvme_ ## name ## _ctrlr_scan(enum spdk_nvme_transport transport, spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle); \ + int nvme_ ## name ## _ctrlr_scan(enum spdk_nvme_transport transport, spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle, void *pci_address); \ int nvme_ ## name ## _ctrlr_enable(struct spdk_nvme_ctrlr *ctrlr); \ int nvme_ ## name ## _ctrlr_get_pci_id(struct spdk_nvme_ctrlr *ctrlr, struct spdk_pci_id *pci_id); \ int nvme_ ## name ## _ctrlr_set_reg_4(struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, uint32_t value); \ diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index 7958c9de31..2636bfc6f3 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -545,14 +545,18 @@ pcie_nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev) int nvme_pcie_ctrlr_scan(enum spdk_nvme_transport transport, - spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle) + spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle, void *pci_address) { struct nvme_pcie_enum_ctx enum_ctx; enum_ctx.probe_cb = probe_cb; enum_ctx.cb_ctx = cb_ctx; - - return spdk_pci_enumerate(SPDK_PCI_DEVICE_NVME, pcie_nvme_enum_cb, &enum_ctx); + if (!pci_address) { + return spdk_pci_enumerate(SPDK_PCI_DEVICE_NVME, pcie_nvme_enum_cb, &enum_ctx); + } else { + return spdk_pci_device_attach(SPDK_PCI_DEVICE_NVME, pcie_nvme_enum_cb, &enum_ctx, + (struct spdk_pci_addr *)pci_address); + } } struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(enum spdk_nvme_transport transport, diff --git a/lib/nvme/nvme_rdma.c b/lib/nvme/nvme_rdma.c index a1b1a46612..cd7b1fc636 100644 --- a/lib/nvme/nvme_rdma.c +++ b/lib/nvme/nvme_rdma.c @@ -1046,7 +1046,7 @@ nvme_fabrics_get_log_discovery_page(struct spdk_nvme_ctrlr *ctrlr, /* This function must only be called while holding g_spdk_nvme_driver->lock */ int nvme_rdma_ctrlr_scan(enum spdk_nvme_transport transport, - spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle) + spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle, void *pci_address) { struct spdk_nvme_discover_info *discover_info = devhandle; struct spdk_nvme_probe_info probe_info; diff --git a/lib/nvme/nvme_transport.c b/lib/nvme/nvme_transport.c index 856d7b4dd8..1b3463939a 100644 --- a/lib/nvme/nvme_transport.c +++ b/lib/nvme/nvme_transport.c @@ -94,9 +94,9 @@ struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(enum spdk_nvme_transport int nvme_transport_ctrlr_scan(enum spdk_nvme_transport transport, - spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle) + spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle, void *pci_address) { - NVME_TRANSPORT_CALL(transport, ctrlr_scan, (transport, probe_cb, cb_ctx, devhandle)); + NVME_TRANSPORT_CALL(transport, ctrlr_scan, (transport, probe_cb, cb_ctx, devhandle, pci_address)); } int diff --git a/test/lib/nvme/unit/nvme_c/nvme_ut.c b/test/lib/nvme/unit/nvme_c/nvme_ut.c index 6958e1aa70..23ab2c5d01 100644 --- a/test/lib/nvme/unit/nvme_c/nvme_ut.c +++ b/test/lib/nvme/unit/nvme_c/nvme_ut.c @@ -73,7 +73,7 @@ struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(enum spdk_nvme_transport int nvme_transport_ctrlr_scan(enum spdk_nvme_transport transport, - spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle) + spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle, void *pci_address) { return 0; } diff --git a/test/lib/nvme/unit/nvme_ns_cmd_c/nvme_ns_cmd_ut.c b/test/lib/nvme/unit/nvme_ns_cmd_c/nvme_ns_cmd_ut.c index abcacd5b37..b77475fffb 100644 --- a/test/lib/nvme/unit/nvme_ns_cmd_c/nvme_ns_cmd_ut.c +++ b/test/lib/nvme/unit/nvme_ns_cmd_c/nvme_ns_cmd_ut.c @@ -164,7 +164,7 @@ nvme_ctrlr_get_ref_count(struct spdk_nvme_ctrlr *ctrlr) int nvme_transport_ctrlr_scan(enum spdk_nvme_transport transport, - spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle) + spdk_nvme_probe_cb probe_cb, void *cb_ctx, void *devhandle, void *pci_address) { return 0; }