nvme: make nvme_ctrlr_configure_aer() can be executed asynchronously
Change-Id: I1cc4c79dc5f27aef18936e00953b72ed45c859bd Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.gerrithub.io/425070 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
38a396d959
commit
cf5448a910
@ -634,6 +634,8 @@ nvme_ctrlr_state_string(enum nvme_ctrlr_state state)
|
|||||||
return "construct namespaces";
|
return "construct namespaces";
|
||||||
case NVME_CTRLR_STATE_CONFIGURE_AER:
|
case NVME_CTRLR_STATE_CONFIGURE_AER:
|
||||||
return "configure AER";
|
return "configure AER";
|
||||||
|
case NVME_CTRLR_STATE_WAIT_FOR_CONFIGURE_AER:
|
||||||
|
return "wait for configure aer";
|
||||||
case NVME_CTRLR_STATE_SET_SUPPORTED_LOG_PAGES:
|
case NVME_CTRLR_STATE_SET_SUPPORTED_LOG_PAGES:
|
||||||
return "set supported log pages";
|
return "set supported log pages";
|
||||||
case NVME_CTRLR_STATE_SET_SUPPORTED_FEATURES:
|
case NVME_CTRLR_STATE_SET_SUPPORTED_FEATURES:
|
||||||
@ -1344,11 +1346,39 @@ nvme_ctrlr_construct_and_submit_aer(struct spdk_nvme_ctrlr *ctrlr,
|
|||||||
return nvme_ctrlr_submit_admin_request(ctrlr, req);
|
return nvme_ctrlr_submit_admin_request(ctrlr, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nvme_ctrlr_configure_aer_done(void *arg, const struct spdk_nvme_cpl *cpl)
|
||||||
|
{
|
||||||
|
struct nvme_async_event_request *aer;
|
||||||
|
int rc;
|
||||||
|
uint32_t i;
|
||||||
|
struct spdk_nvme_ctrlr *ctrlr = (struct spdk_nvme_ctrlr *)arg;
|
||||||
|
|
||||||
|
if (spdk_nvme_cpl_is_error(cpl)) {
|
||||||
|
SPDK_NOTICELOG("nvme_ctrlr_configure_aer failed!\n");
|
||||||
|
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_SET_SUPPORTED_LOG_PAGES, NVME_TIMEOUT_INFINITE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* aerl is a zero-based value, so we need to add 1 here. */
|
||||||
|
ctrlr->num_aers = spdk_min(NVME_MAX_ASYNC_EVENTS, (ctrlr->cdata.aerl + 1));
|
||||||
|
|
||||||
|
for (i = 0; i < ctrlr->num_aers; i++) {
|
||||||
|
aer = &ctrlr->aer[i];
|
||||||
|
rc = nvme_ctrlr_construct_and_submit_aer(ctrlr, aer);
|
||||||
|
if (rc) {
|
||||||
|
SPDK_ERRLOG("nvme_ctrlr_construct_and_submit_aer failed!\n");
|
||||||
|
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_ERROR, NVME_TIMEOUT_INFINITE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_SET_SUPPORTED_LOG_PAGES, NVME_TIMEOUT_INFINITE);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_nvme_ctrlr_configure_aer(struct spdk_nvme_ctrlr *ctrlr)
|
nvme_ctrlr_configure_aer(struct spdk_nvme_ctrlr *ctrlr)
|
||||||
{
|
{
|
||||||
union spdk_nvme_feat_async_event_configuration config;
|
union spdk_nvme_feat_async_event_configuration config;
|
||||||
struct nvme_completion_poll_status status;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
config.raw = 0;
|
config.raw = 0;
|
||||||
@ -1370,43 +1400,16 @@ _nvme_ctrlr_configure_aer(struct spdk_nvme_ctrlr *ctrlr)
|
|||||||
config.bits.telemetry_log_notice = 1;
|
config.bits.telemetry_log_notice = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = nvme_ctrlr_cmd_set_async_event_config(ctrlr, config, nvme_completion_poll_cb, &status);
|
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_WAIT_FOR_CONFIGURE_AER, NVME_TIMEOUT_INFINITE);
|
||||||
|
|
||||||
|
rc = nvme_ctrlr_cmd_set_async_event_config(ctrlr, config,
|
||||||
|
nvme_ctrlr_configure_aer_done,
|
||||||
|
ctrlr);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
|
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_ERROR, NVME_TIMEOUT_INFINITE);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spdk_nvme_wait_for_completion(ctrlr->adminq, &status)) {
|
|
||||||
return -ENXIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
nvme_ctrlr_configure_aer(struct spdk_nvme_ctrlr *ctrlr)
|
|
||||||
{
|
|
||||||
struct nvme_async_event_request *aer;
|
|
||||||
uint32_t i;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = _nvme_ctrlr_configure_aer(ctrlr);
|
|
||||||
if (rc != 0) {
|
|
||||||
SPDK_NOTICELOG("nvme_ctrlr_configure_aer failed!\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* aerl is a zero-based value, so we need to add 1 here. */
|
|
||||||
ctrlr->num_aers = spdk_min(NVME_MAX_ASYNC_EVENTS, (ctrlr->cdata.aerl + 1));
|
|
||||||
|
|
||||||
for (i = 0; i < ctrlr->num_aers; i++) {
|
|
||||||
aer = &ctrlr->aer[i];
|
|
||||||
rc = nvme_ctrlr_construct_and_submit_aer(ctrlr, aer);
|
|
||||||
if (rc) {
|
|
||||||
SPDK_ERRLOG("nvme_ctrlr_construct_and_submit_aer failed!\n");
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1835,7 +1838,10 @@ nvme_ctrlr_process_init(struct spdk_nvme_ctrlr *ctrlr)
|
|||||||
|
|
||||||
case NVME_CTRLR_STATE_CONFIGURE_AER:
|
case NVME_CTRLR_STATE_CONFIGURE_AER:
|
||||||
rc = nvme_ctrlr_configure_aer(ctrlr);
|
rc = nvme_ctrlr_configure_aer(ctrlr);
|
||||||
nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_SET_SUPPORTED_LOG_PAGES, NVME_TIMEOUT_INFINITE);
|
break;
|
||||||
|
|
||||||
|
case NVME_CTRLR_STATE_WAIT_FOR_CONFIGURE_AER:
|
||||||
|
spdk_nvme_qpair_process_completions(ctrlr->adminq, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NVME_CTRLR_STATE_SET_SUPPORTED_LOG_PAGES:
|
case NVME_CTRLR_STATE_SET_SUPPORTED_LOG_PAGES:
|
||||||
|
@ -457,6 +457,11 @@ enum nvme_ctrlr_state {
|
|||||||
*/
|
*/
|
||||||
NVME_CTRLR_STATE_CONFIGURE_AER,
|
NVME_CTRLR_STATE_CONFIGURE_AER,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waiting for the Configure AER to be completed.
|
||||||
|
*/
|
||||||
|
NVME_CTRLR_STATE_WAIT_FOR_CONFIGURE_AER,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set supported log pages of the controller.
|
* Set supported log pages of the controller.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user