From fd36d11e17adcef3b7d577769913a9ffea61bce9 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 18 Nov 2016 15:32:02 -0700 Subject: [PATCH] nvmf_tgt: stub out Async Event Config feature Record the user-provided asynchronous event configuration set via Set Features, and return it in Get Features. This value is not actually used, since AER is not implemented yet in the virtual controller model, but it at least implements the mandatory Set/Get Features. This allows the hack in the NVMe host code that ignored the Set Features failure to be reverted. Change-Id: I2ac639eb8b069ef8e87230a21fa77225f32aedde Signed-off-by: Daniel Verkamp --- lib/nvme/nvme_ctrlr.c | 3 +-- lib/nvmf/session.c | 1 + lib/nvmf/session.h | 8 ++++++++ lib/nvmf/virtual.c | 9 +++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index 2a2678f23..a8de5f8b9 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -785,8 +785,7 @@ nvme_ctrlr_configure_aer(struct spdk_nvme_ctrlr *ctrlr) } if (spdk_nvme_cpl_is_error(&status.cpl)) { SPDK_ERRLOG("nvme_ctrlr_cmd_set_async_event_config failed!\n"); - /* change the return value since NVMf target does not suppport aer, should be fixed later*/ - return 0; + return -ENXIO; } /* aerl is a zero-based value, so we need to add 1 here. */ diff --git a/lib/nvmf/session.c b/lib/nvmf/session.c index dafb02cd9..d0adf4435 100644 --- a/lib/nvmf/session.c +++ b/lib/nvmf/session.c @@ -257,6 +257,7 @@ spdk_nvmf_session_connect(struct spdk_nvmf_conn *conn, TAILQ_INIT(&session->connections); session->id = subsystem->session_id++; session->kato = cmd->kato; + session->async_event_config.raw = 0; session->num_connections = 0; session->subsys = subsystem; session->max_connections_allowed = g_nvmf_tgt.max_queues_per_session; diff --git a/lib/nvmf/session.h b/lib/nvmf/session.h index 6a7d8ab69..cf3f60d2e 100644 --- a/lib/nvmf/session.h +++ b/lib/nvmf/session.h @@ -82,6 +82,14 @@ struct spdk_nvmf_session { int num_connections; int max_connections_allowed; uint32_t kato; + union { + uint32_t raw; + struct { + union spdk_nvme_critical_warning_state crit_warn; + uint8_t ns_attr_notice : 1; + uint8_t fw_activation_notice : 1; + } bits; + } async_event_config; const struct spdk_nvmf_transport *transport; TAILQ_ENTRY(spdk_nvmf_session) link; diff --git a/lib/nvmf/virtual.c b/lib/nvmf/virtual.c index 851c658dc..a7c5b6e42 100644 --- a/lib/nvmf/virtual.c +++ b/lib/nvmf/virtual.c @@ -286,6 +286,10 @@ nvmf_virtual_ctrlr_get_features(struct spdk_nvmf_request *req) case SPDK_NVME_FEAT_KEEP_ALIVE_TIMER: response->cdw0 = session->kato; return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; + case SPDK_NVME_FEAT_ASYNC_EVENT_CONFIGURATION: + SPDK_TRACELOG(SPDK_TRACE_NVMF, "Get Features - Async Event Configuration\n"); + response->cdw0 = session->async_event_config.raw; + return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; default: SPDK_ERRLOG("get features command with invalid code\n"); response->status.sc = SPDK_NVME_SC_INVALID_OPCODE; @@ -326,6 +330,11 @@ nvmf_virtual_ctrlr_set_features(struct spdk_nvmf_request *req) session->kato = cmd->cdw11; } return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; + case SPDK_NVME_FEAT_ASYNC_EVENT_CONFIGURATION: + SPDK_TRACELOG(SPDK_TRACE_NVMF, "Set Features - Async Event Configuration, cdw11 0x%08x\n", + cmd->cdw11); + session->async_event_config.raw = cmd->cdw11; + return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; default: SPDK_ERRLOG("set features command with invalid code\n"); response->status.sc = SPDK_NVME_SC_INVALID_OPCODE;