nvme: asynchronous admin queue connection

Split the connection process across two states, which allows the
transport to connect the admin queue asynchronously.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ie84477331df0abf5ffdfc2a0ff5d5ada760c9e73
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9076
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Monica Kenguva <monica.kenguva@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Konrad Sztyber 2021-08-03 14:17:03 +02:00 committed by Tomasz Zawadzki
parent 7d32600e5c
commit 37c36ec154
3 changed files with 31 additions and 4 deletions

View File

@ -1195,6 +1195,8 @@ nvme_ctrlr_state_string(enum nvme_ctrlr_state state)
return "delay init";
case NVME_CTRLR_STATE_CONNECT_ADMINQ:
return "connect adminq";
case NVME_CTRLR_STATE_WAIT_FOR_CONNECT_ADMINQ:
return "wait for connect adminq";
case NVME_CTRLR_STATE_READ_VS:
return "read vs";
case NVME_CTRLR_STATE_READ_CAP:
@ -3326,7 +3328,7 @@ nvme_ctrlr_process_init(struct spdk_nvme_ctrlr *ctrlr)
}
ctrlr->sleep_timeout_tsc = 0;
if (ctrlr->state > NVME_CTRLR_STATE_CONNECT_ADMINQ &&
if (ctrlr->state > NVME_CTRLR_STATE_WAIT_FOR_CONNECT_ADMINQ &&
(nvme_ctrlr_get_cc(ctrlr, &cc) || nvme_ctrlr_get_csts(ctrlr, &csts))) {
if (!ctrlr->is_failed && ctrlr->state_timeout_tsc != NVME_TIMEOUT_INFINITE) {
/* While a device is resetting, it may be unable to service MMIO reads
@ -3362,16 +3364,35 @@ nvme_ctrlr_process_init(struct spdk_nvme_ctrlr *ctrlr)
break;
case NVME_CTRLR_STATE_CONNECT_ADMINQ: /* synonymous with NVME_CTRLR_STATE_INIT */
assert(ctrlr->adminq->async == false); /* not currently supported */
rc = nvme_transport_ctrlr_connect_qpair(ctrlr, ctrlr->adminq);
if (rc == 0) {
nvme_qpair_set_state(ctrlr->adminq, NVME_QPAIR_ENABLED);
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_READ_VS, NVME_TIMEOUT_INFINITE);
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_WAIT_FOR_CONNECT_ADMINQ,
NVME_TIMEOUT_INFINITE);
} else {
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_ERROR, NVME_TIMEOUT_INFINITE);
}
break;
case NVME_CTRLR_STATE_WAIT_FOR_CONNECT_ADMINQ:
spdk_nvme_qpair_process_completions(ctrlr->adminq, 0);
switch (nvme_qpair_get_state(ctrlr->adminq)) {
case NVME_QPAIR_CONNECTING:
break;
case NVME_QPAIR_CONNECTED:
nvme_qpair_set_state(ctrlr->adminq, NVME_QPAIR_ENABLED);
/* Fall through */
case NVME_QPAIR_ENABLED:
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_READ_VS,
NVME_TIMEOUT_INFINITE);
break;
default:
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_ERROR, NVME_TIMEOUT_INFINITE);
break;
}
break;
case NVME_CTRLR_STATE_READ_VS:
nvme_ctrlr_get_vs(ctrlr, &ctrlr->vs);
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_READ_CAP, NVME_TIMEOUT_INFINITE);

View File

@ -545,6 +545,11 @@ enum nvme_ctrlr_state {
*/
NVME_CTRLR_STATE_INIT = NVME_CTRLR_STATE_CONNECT_ADMINQ,
/**
* Waiting for admin queue to connect.
*/
NVME_CTRLR_STATE_WAIT_FOR_CONNECT_ADMINQ,
/**
* Read Version (VS) register.
*/

View File

@ -1649,6 +1649,7 @@ int g_connect_qpair_return_code = 0;
int nvme_transport_ctrlr_connect_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair)
{
g_connect_qpair_called = true;
qpair->state = NVME_QPAIR_CONNECTED;
return g_connect_qpair_return_code;
}