diff --git a/app/nvmf_tgt/conf.c b/app/nvmf_tgt/conf.c index 0f7ec4fac..82c9c7706 100644 --- a/app/nvmf_tgt/conf.c +++ b/app/nvmf_tgt/conf.c @@ -557,7 +557,7 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp) ctx.any = false; } - if (spdk_nvme_probe(&ctx, probe_cb, attach_cb, NULL)) { + if (spdk_nvme_probe(NULL, &ctx, probe_cb, attach_cb, NULL)) { SPDK_ERRLOG("One or more controllers failed in spdk_nvme_probe()\n"); } @@ -748,7 +748,7 @@ spdk_nvmf_parse_subsystem_for_rpc(const char *name, ctx.any = false; } - if (spdk_nvme_probe(&ctx, probe_cb, attach_cb, NULL)) { + if (spdk_nvme_probe(NULL, &ctx, probe_cb, attach_cb, NULL)) { SPDK_ERRLOG("One or more controllers failed in spdk_nvme_probe()\n"); } diff --git a/examples/nvme/arbitration/arbitration.c b/examples/nvme/arbitration/arbitration.c index 6b53fd908..9aa71c047 100644 --- a/examples/nvme/arbitration/arbitration.c +++ b/examples/nvme/arbitration/arbitration.c @@ -882,7 +882,7 @@ register_controllers(void) { printf("Initializing NVMe Controllers\n"); - if (spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL) != 0) { + if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); return 1; } diff --git a/examples/nvme/fio_plugin/fio_plugin.c b/examples/nvme/fio_plugin/fio_plugin.c index e767d7041..56e671d69 100644 --- a/examples/nvme/fio_plugin/fio_plugin.c +++ b/examples/nvme/fio_plugin/fio_plugin.c @@ -205,7 +205,7 @@ static int spdk_fio_setup(struct thread_data *td) } /* Enumerate all of the controllers */ - if (spdk_nvme_probe(td, probe_cb, attach_cb, NULL) != 0) { + if (spdk_nvme_probe(NULL, td, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); return 1; } diff --git a/examples/nvme/hello_world/hello_world.c b/examples/nvme/hello_world/hello_world.c index 440bf24ce..db9111b22 100644 --- a/examples/nvme/hello_world/hello_world.c +++ b/examples/nvme/hello_world/hello_world.c @@ -340,7 +340,7 @@ int main(int argc, char **argv) * called for each controller after the SPDK NVMe driver has completed * initializing the controller we chose to attach. */ - rc = spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL); + rc = spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL); if (rc != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); cleanup(); diff --git a/examples/nvme/hotplug/hotplug.c b/examples/nvme/hotplug/hotplug.c index a307449f5..1cf11bdf7 100644 --- a/examples/nvme/hotplug/hotplug.c +++ b/examples/nvme/hotplug/hotplug.c @@ -337,7 +337,7 @@ io_loop(void) /* * Check for hotplug events. */ - if (spdk_nvme_probe(NULL, probe_cb, attach_cb, remove_cb) != 0) { + if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, remove_cb) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); break; } @@ -421,7 +421,7 @@ register_controllers(void) { fprintf(stderr, "Initializing NVMe Controllers\n"); - if (spdk_nvme_probe(NULL, probe_cb, attach_cb, remove_cb) != 0) { + if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, remove_cb) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); return 1; } diff --git a/examples/nvme/identify/identify.c b/examples/nvme/identify/identify.c index 98dda4040..2fc4c6d0d 100644 --- a/examples/nvme/identify/identify.c +++ b/examples/nvme/identify/identify.c @@ -990,12 +990,12 @@ int main(int argc, char **argv) rc = 0; if (trid.trtype == SPDK_NVME_TRANSPORT_RDMA) { - if (spdk_nvme_discover(&trid, NULL, probe_cb, attach_cb, NULL) != 0) { + if (spdk_nvme_probe(&trid, NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); } } - if (spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL) != 0) { + if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); rc = 1; } diff --git a/examples/nvme/nvme_manage/nvme_manage.c b/examples/nvme/nvme_manage/nvme_manage.c index 0cda20873..1bdfebd0e 100644 --- a/examples/nvme/nvme_manage/nvme_manage.c +++ b/examples/nvme/nvme_manage/nvme_manage.c @@ -853,7 +853,7 @@ int main(int argc, char **argv) exit(1); } - if (spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL) != 0) { + if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); return 1; } diff --git a/examples/nvme/perf/perf.c b/examples/nvme/perf/perf.c index 9eba8ee74..b19a1efb4 100644 --- a/examples/nvme/perf/perf.c +++ b/examples/nvme/perf/perf.c @@ -1045,7 +1045,7 @@ register_controllers(void) printf("Initializing NVMe Controllers\n"); - if (spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL) != 0) { + if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); } @@ -1091,8 +1091,8 @@ register_controllers(void) p = (char *)p1 + 1; snprintf(trid.trsvcid, sizeof(trid.trsvcid), "%s", p); - if (spdk_nvme_discover(&trid, NULL, probe_cb, attach_cb, NULL) != 0) { - fprintf(stderr, "spdk_nvme_discover() failed\n"); + if (spdk_nvme_probe(&trid, NULL, probe_cb, attach_cb, NULL) != 0) { + fprintf(stderr, "spdk_nvme_probe() failed\n"); } } diff --git a/examples/nvme/reserve/reserve.c b/examples/nvme/reserve/reserve.c index 9a77fb1b0..90a329c9f 100644 --- a/examples/nvme/reserve/reserve.c +++ b/examples/nvme/reserve/reserve.c @@ -400,7 +400,7 @@ int main(int argc, char **argv) exit(1); } - if (spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL) != 0) { + if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); return 1; } diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index 5c19374b2..843a50289 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -215,28 +215,12 @@ typedef void (*spdk_nvme_attach_cb)(void *cb_ctx, const struct spdk_nvme_transpo typedef void (*spdk_nvme_remove_cb)(void *cb_ctx, struct spdk_nvme_ctrlr *ctrlr); /** - * \brief Perform a device discovery using the discovery service specified by trid. - * - * \param trid The address of the discovery service on which to perform the discovery. - * \param cb_ctx Opaque value which will be passed back in cb_ctx parameter of the callbacks. - * \param probe_cb will be called once per NVMe device found in the system. - * \param attach_cb will be called for devices for which probe_cb returned true once that NVMe - * controller has been attached to the userspace driver. - * \param remove_cb will be called for devices that were attached in a previous spdk_nvme_probe() - * call but are no longer attached to the system. Optional; specify NULL if removal notices are not - * desired. - * - */ -int spdk_nvme_discover(const struct spdk_nvme_transport_id *trid, - void *cb_ctx, - spdk_nvme_probe_cb probe_cb, - spdk_nvme_attach_cb attach_cb, - spdk_nvme_remove_cb remove_cb); - -/** - * \brief Enumerate the NVMe devices attached to the system and attach the userspace NVMe driver - * to them if desired. + * \brief Enumerate the bus indicated by the transport ID and attach the userspace NVMe driver + * to each device found if desired. * + * \param trid The transport ID indicating which bus to enumerate. If the trtype is PCIe or trid is NULL, + * this will scan the local PCIe bus. If the trtype is RDMA, the traddr and trsvcid must point at the + * location of an NVMe-oF discovery service. * \param cb_ctx Opaque value which will be passed back in cb_ctx parameter of the callbacks. * \param probe_cb will be called once per NVMe device found in the system. * \param attach_cb will be called for devices for which probe_cb returned true once that NVMe @@ -257,7 +241,8 @@ int spdk_nvme_discover(const struct spdk_nvme_transport_id *trid, * To stop using the the controller and release its associated resources, * call \ref spdk_nvme_detach with the spdk_nvme_ctrlr instance returned by this function. */ -int spdk_nvme_probe(void *cb_ctx, +int spdk_nvme_probe(const struct spdk_nvme_transport_id *trid, + void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb attach_cb, spdk_nvme_remove_cb remove_cb); diff --git a/lib/bdev/nvme/blockdev_nvme.c b/lib/bdev/nvme/blockdev_nvme.c index 8fd6b7a81..86157ebf6 100644 --- a/lib/bdev/nvme/blockdev_nvme.c +++ b/lib/bdev/nvme/blockdev_nvme.c @@ -551,7 +551,7 @@ spdk_bdev_nvme_create(struct nvme_probe_ctx *ctx) prev_index_max = blockdev_index_max; - if (spdk_nvme_probe(ctx, probe_cb, attach_cb, NULL)) { + if (spdk_nvme_probe(NULL, ctx, probe_cb, attach_cb, NULL)) { return -1; } diff --git a/lib/nvme/nvme.c b/lib/nvme/nvme.c index f982ba5f4..1b39142ce 100644 --- a/lib/nvme/nvme.c +++ b/lib/nvme/nvme.c @@ -434,10 +434,10 @@ nvme_hotplug_monitor(void *cb_ctx, spdk_nvme_probe_cb probe_cb, return 0; } -static int -_spdk_nvme_probe(const struct spdk_nvme_transport_id *trid, void *cb_ctx, - spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb attach_cb, - spdk_nvme_remove_cb remove_cb) +int +spdk_nvme_probe(const struct spdk_nvme_transport_id *trid, void *cb_ctx, + spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb attach_cb, + spdk_nvme_remove_cb remove_cb) { int rc; struct spdk_nvme_ctrlr *ctrlr; @@ -501,19 +501,4 @@ _spdk_nvme_probe(const struct spdk_nvme_transport_id *trid, void *cb_ctx, return rc; } -int spdk_nvme_discover(const struct spdk_nvme_transport_id *trid, - void *cb_ctx, - spdk_nvme_probe_cb probe_cb, - spdk_nvme_attach_cb attach_cb, - spdk_nvme_remove_cb remove_cb) -{ - return _spdk_nvme_probe(trid, cb_ctx, probe_cb, attach_cb, remove_cb); -} - -int -spdk_nvme_probe(void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb attach_cb, - spdk_nvme_remove_cb remove_cb) -{ - return _spdk_nvme_probe(NULL, cb_ctx, probe_cb, attach_cb, remove_cb); -} SPDK_LOG_REGISTER_TRACE_FLAG("nvme", SPDK_TRACE_NVME) diff --git a/test/lib/nvme/aer/aer.c b/test/lib/nvme/aer/aer.c index 052c021f5..2b02aa4b3 100644 --- a/test/lib/nvme/aer/aer.c +++ b/test/lib/nvme/aer/aer.c @@ -237,7 +237,7 @@ int main(int argc, char **argv) exit(1); } - if (spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL) != 0) { + if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); return 1; } diff --git a/test/lib/nvme/e2edp/nvme_dp.c b/test/lib/nvme/e2edp/nvme_dp.c index 07148fcb6..3dca90781 100644 --- a/test/lib/nvme/e2edp/nvme_dp.c +++ b/test/lib/nvme/e2edp/nvme_dp.c @@ -653,7 +653,7 @@ int main(int argc, char **argv) exit(1); } - if (spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL) != 0) { + if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "nvme_probe() failed\n"); exit(1); } diff --git a/test/lib/nvme/overhead/overhead.c b/test/lib/nvme/overhead/overhead.c index 6300c4290..4c78221e9 100644 --- a/test/lib/nvme/overhead/overhead.c +++ b/test/lib/nvme/overhead/overhead.c @@ -562,7 +562,7 @@ register_controllers(void) { printf("Initializing NVMe Controllers\n"); - if (spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL) != 0) { + if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); return 1; } diff --git a/test/lib/nvme/reset/reset.c b/test/lib/nvme/reset/reset.c index 51ebfcbc8..cc148d420 100644 --- a/test/lib/nvme/reset/reset.c +++ b/test/lib/nvme/reset/reset.c @@ -526,7 +526,7 @@ register_controllers(void) { printf("Initializing NVMe Controllers\n"); - if (spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL) != 0) { + if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); return 1; } diff --git a/test/lib/nvme/sgl/sgl.c b/test/lib/nvme/sgl/sgl.c index 1518c03af..63068c000 100644 --- a/test/lib/nvme/sgl/sgl.c +++ b/test/lib/nvme/sgl/sgl.c @@ -427,7 +427,7 @@ int main(int argc, char **argv) exit(1); } - if (spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL) != 0) { + if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "nvme_probe() failed\n"); exit(1); }