From 86ad145bc1642571f5ea22bbcf8fa7ea4d08717e Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Thu, 23 Sep 2021 16:21:53 +0800 Subject: [PATCH] nvmf: add AER error event API support We still don't support get log page with error information LID. Change-Id: I92db361dc956ea3ed4f6e7bdfdca763d0fea6886 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9583 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Reviewed-by: Aleksey Marchuk Reviewed-by: Ben Walker --- lib/nvmf/ctrlr.c | 41 +++++++++++++++++++++++++++++++++++++++- lib/nvmf/nvmf_internal.h | 2 ++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/lib/nvmf/ctrlr.c b/lib/nvmf/ctrlr.c index 40c93b8f13..7f2186d994 100644 --- a/lib/nvmf/ctrlr.c +++ b/lib/nvmf/ctrlr.c @@ -1925,7 +1925,8 @@ enum spdk_nvme_async_event_mask_bit { SPDK_NVME_ASYNC_EVENT_DISCOVERY_LOG_CHANGE_MASK_BIT = 2, /* Mask Reservation Log Page Available Notification */ SPDK_NVME_ASYNC_EVENT_RESERVATION_LOG_AVAIL_MASK_BIT = 3, - + /* Mask Error Event */ + SPDK_NVME_ASYNC_EVENT_ERROR_MASK_BIT = 4, /* 4 - 63 Reserved */ }; @@ -1979,6 +1980,17 @@ nvmf_ctrlr_get_ana_state_from_nsid(struct spdk_nvmf_ctrlr *ctrlr, uint32_t nsid) return nvmf_ctrlr_get_ana_state(ctrlr, ns->anagrpid); } +static void +nvmf_get_error_log_page(struct spdk_nvmf_ctrlr *ctrlr, struct iovec *iovs, int iovcnt, + uint64_t offset, uint32_t length, uint32_t rae) +{ + if (!rae) { + nvmf_ctrlr_unmask_aen(ctrlr, SPDK_NVME_ASYNC_EVENT_ERROR_MASK_BIT); + } + + /* TODO: actually fill out log page data */ +} + static void nvmf_get_ana_log_page(struct spdk_nvmf_ctrlr *ctrlr, struct iovec *iovs, int iovcnt, uint64_t offset, uint32_t length, uint32_t rae) @@ -2288,6 +2300,8 @@ nvmf_ctrlr_get_log_page(struct spdk_nvmf_request *req) } else { switch (lid) { case SPDK_NVME_LOG_ERROR: + nvmf_get_error_log_page(ctrlr, req->iov, req->iovcnt, offset, len, rae); + return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; case SPDK_NVME_LOG_HEALTH_INFORMATION: /* TODO: actually fill out log page data */ return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; @@ -3315,6 +3329,31 @@ nvmf_ctrlr_async_event_discovery_log_change_notice(struct spdk_nvmf_ctrlr *ctrlr return nvmf_ctrlr_async_event_notification(ctrlr, &event); } +int +nvmf_ctrlr_async_event_error_event(struct spdk_nvmf_ctrlr *ctrlr, + union spdk_nvme_async_event_completion event) +{ + if (!nvmf_ctrlr_mask_aen(ctrlr, SPDK_NVME_ASYNC_EVENT_ERROR_MASK_BIT)) { + return 0; + } + + if (event.bits.async_event_type != SPDK_NVME_ASYNC_EVENT_TYPE_ERROR || + event.bits.async_event_info > SPDK_NVME_ASYNC_EVENT_FW_IMAGE_LOAD) { + return 0; + } + + /* If there is no outstanding AER request, queue the event. Then + * if an AER is later submitted, this event can be sent as a + * response. + */ + if (ctrlr->nr_aer_reqs == 0) { + nvmf_ctrlr_queue_pending_async_event(ctrlr, &event); + return 0; + } + + return nvmf_ctrlr_async_event_notification(ctrlr, &event); +} + void nvmf_qpair_free_aer(struct spdk_nvmf_qpair *qpair) { diff --git a/lib/nvmf/nvmf_internal.h b/lib/nvmf/nvmf_internal.h index 939fcccb7c..2a49832986 100644 --- a/lib/nvmf/nvmf_internal.h +++ b/lib/nvmf/nvmf_internal.h @@ -425,6 +425,8 @@ int nvmf_ctrlr_async_event_ns_notice(struct spdk_nvmf_ctrlr *ctrlr); int nvmf_ctrlr_async_event_ana_change_notice(struct spdk_nvmf_ctrlr *ctrlr); int nvmf_ctrlr_async_event_discovery_log_change_notice(struct spdk_nvmf_ctrlr *ctrlr); void nvmf_ctrlr_async_event_reservation_notification(struct spdk_nvmf_ctrlr *ctrlr); +int nvmf_ctrlr_async_event_error_event(struct spdk_nvmf_ctrlr *ctrlr, + union spdk_nvme_async_event_completion event); void nvmf_ns_reservation_request(void *ctx); void nvmf_ctrlr_reservation_notice_log(struct spdk_nvmf_ctrlr *ctrlr, struct spdk_nvmf_ns *ns,