external_code/nvme: send identify controller during init

Now that it's possible to both submit the identify controller command
and process its completion, the initialization flow has been updated to
issue that command and update controller's identify data (which can be
retrieved via nvme_ctrlr_get_data()).

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Iee0e85f431275a5e6f1767db1d807de7fba6cdcc
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6677
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Konrad Sztyber 2021-02-24 08:15:22 +01:00 committed by Tomasz Zawadzki
parent 71c69ddfc3
commit e4d271f302

View File

@ -395,9 +395,21 @@ submit_request(struct nvme_qpair *qpair, struct nvme_request *request)
spdk_mmio_write_4(qpair->sq_tdbl, qpair->sq_tail);
}
int identify_ctrlr(struct nvme_ctrlr *ctrlr);
static void
identify_ctrlr_done(void *ctx, const struct spdk_nvme_cpl *cpl)
{
struct nvme_ctrlr *ctrlr = ctx;
int
if (spdk_nvme_cpl_is_error(cpl)) {
SPDK_ERRLOG("Identify Controller command failed\n");
ctrlr->state = NVME_CTRLR_STATE_ERROR;
return;
}
ctrlr->state = NVME_CTRLR_STATE_READY;
}
static int
identify_ctrlr(struct nvme_ctrlr *ctrlr)
{
struct nvme_request *request;
@ -416,8 +428,8 @@ identify_ctrlr(struct nvme_ctrlr *ctrlr)
return -EAGAIN;
}
request->cb_fn = NULL;
request->cb_arg = NULL;
request->cb_fn = identify_ctrlr_done;
request->cb_arg = ctrlr;
cmd = &request->cmd;
cmd->cid = request->cid;
@ -433,9 +445,7 @@ identify_ctrlr(struct nvme_ctrlr *ctrlr)
return 0;
}
int32_t process_completions(struct nvme_qpair *qpair);
int32_t
static int32_t
process_completions(struct nvme_qpair *qpair)
{
struct spdk_nvme_cpl *cpl;
@ -478,6 +488,7 @@ process_ctrlr_init(struct nvme_ctrlr *ctrlr)
union spdk_nvme_cc_register cc;
union spdk_nvme_csts_register csts;
union spdk_nvme_aqa_register aqa;
int rc = 0;
if (ctrlr->state == NVME_CTRLR_STATE_READY) {
return 0;
@ -526,15 +537,25 @@ process_ctrlr_init(struct nvme_ctrlr *ctrlr)
break;
case NVME_CTRLR_STATE_ENABLE_WAIT_FOR_READY_1:
if (csts.bits.rdy) {
ctrlr->state = NVME_CTRLR_STATE_READY;
ctrlr->state = NVME_CTRLR_STATE_IDENTIFY;
}
break;
case NVME_CTRLR_STATE_IDENTIFY:
ctrlr->state = NVME_CTRLR_STATE_WAIT_FOR_IDENTIFY;
rc = identify_ctrlr(ctrlr);
break;
case NVME_CTRLR_STATE_WAIT_FOR_IDENTIFY:
process_completions(ctrlr->admin_qpair);
break;
case NVME_CTRLR_STATE_ERROR:
rc = -1;
break;
default:
assert(0 && "should never get here");
return -1;
}
return 0;
return rc;
}
static void