nvme: init discovery ctrlr using nvme_ctrlr_process_init

This ensures the discovery ctrlr initialization is
done the same as normal ctrlrs.  This will be
critical as we make the driver fully asynchronous.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I33c4fd7c82d241c30e7adb89abe79b8088c8776a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8090
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Jim Harris 2021-05-27 19:22:07 +00:00 committed by Tomasz Zawadzki
parent f5ba8a5ef5
commit a31e319fbb
3 changed files with 12 additions and 15 deletions

View File

@ -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:

View File

@ -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,20 +282,13 @@ 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");
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));
if (!status) {

View File

@ -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)
{