diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index 7d1b1b3217..8dd2b83efc 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -3232,8 +3232,11 @@ nvme_ctrlr_process_init(struct spdk_nvme_ctrlr *ctrlr) case NVME_CTRLR_STATE_RESET_ADMIN_QUEUE: nvme_transport_qpair_reset(ctrlr->adminq); - nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_IDENTIFY, - ctrlr->opts.admin_timeout_ms); + if (spdk_nvme_ctrlr_is_discovery(ctrlr)) { + nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_READY, NVME_TIMEOUT_INFINITE); + } else { + nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_IDENTIFY, ctrlr->opts.admin_timeout_ms); + } break; case NVME_CTRLR_STATE_IDENTIFY: diff --git a/lib/nvme/nvme_fabric.c b/lib/nvme/nvme_fabric.c index 7bf7853592..fd4a5cc57c 100644 --- a/lib/nvme/nvme_fabric.c +++ b/lib/nvme/nvme_fabric.c @@ -265,7 +265,6 @@ nvme_fabric_ctrlr_scan(struct spdk_nvme_probe_ctx *probe_ctx, { struct spdk_nvme_ctrlr_opts discovery_opts; struct spdk_nvme_ctrlr *discovery_ctrlr; - union spdk_nvme_cc_register cc; int rc; struct nvme_completion_poll_status *status; @@ -283,19 +282,12 @@ nvme_fabric_ctrlr_scan(struct spdk_nvme_probe_ctx *probe_ctx, if (discovery_ctrlr == NULL) { return -1; } - nvme_qpair_set_state(discovery_ctrlr->adminq, NVME_QPAIR_ENABLED); - /* TODO: this should be using the normal NVMe controller initialization process +1 */ - cc.raw = 0; - cc.bits.en = 1; - cc.bits.iosqes = 6; /* SQ entry size == 64 == 2^6 */ - cc.bits.iocqes = 4; /* CQ entry size == 16 == 2^4 */ - rc = nvme_transport_ctrlr_set_reg_4(discovery_ctrlr, offsetof(struct spdk_nvme_registers, cc.raw), - cc.raw); - if (rc < 0) { - SPDK_ERRLOG("Failed to set cc\n"); - nvme_ctrlr_destruct(discovery_ctrlr); - return -1; + while (discovery_ctrlr->state != NVME_CTRLR_STATE_READY) { + if (nvme_ctrlr_process_init(discovery_ctrlr) != 0) { + nvme_ctrlr_destruct(discovery_ctrlr); + return -1; + } } status = calloc(1, sizeof(*status)); diff --git a/test/unit/lib/nvme/nvme_fabric.c/nvme_fabric_ut.c b/test/unit/lib/nvme/nvme_fabric.c/nvme_fabric_ut.c index fecb4b272d..10016acd33 100644 --- a/test/unit/lib/nvme/nvme_fabric.c/nvme_fabric_ut.c +++ b/test/unit/lib/nvme/nvme_fabric.c/nvme_fabric_ut.c @@ -87,6 +87,8 @@ DEFINE_STUB(nvme_wait_for_completion_timeout, int, DEFINE_STUB(spdk_nvme_transport_id_adrfam_str, const char *, (enum spdk_nvmf_adrfam adrfam), NULL); +DEFINE_STUB(nvme_ctrlr_process_init, int, (struct spdk_nvme_ctrlr *ctrlr), 0); + int spdk_nvme_transport_id_populate_trstring(struct spdk_nvme_transport_id *trid, const char *trstring) {