From dab804fe7e3a6db8bd868e275571b663d3fd8a6b Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Sun, 26 Sep 2021 22:32:21 +0800 Subject: [PATCH] nvmf: consolidate AER notification into one function Change-Id: If43e92fad60eff3e3f12cac1a8b413f5c16232fb Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9633 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Aleksey Marchuk Reviewed-by: Jim Harris --- lib/nvmf/ctrlr.c | 92 ++++++++++++++---------------------------------- 1 file changed, 27 insertions(+), 65 deletions(-) diff --git a/lib/nvmf/ctrlr.c b/lib/nvmf/ctrlr.c index 7f2186d99..600c930f2 100644 --- a/lib/nvmf/ctrlr.c +++ b/lib/nvmf/ctrlr.c @@ -3172,26 +3172,6 @@ nvmf_ctrlr_process_fabrics_cmd(struct spdk_nvmf_request *req) } } -static inline int -nvmf_ctrlr_async_event_notification(struct spdk_nvmf_ctrlr *ctrlr, - union spdk_nvme_async_event_completion *event) -{ - struct spdk_nvmf_request *req; - struct spdk_nvme_cpl *rsp; - - assert(ctrlr->nr_aer_reqs > 0); - - req = ctrlr->aer_req[--ctrlr->nr_aer_reqs]; - rsp = &req->rsp->nvme_cpl; - - rsp->cdw0 = event->raw; - - _nvmf_request_complete(req); - ctrlr->aer_req[ctrlr->nr_aer_reqs] = NULL; - - return 0; -} - static inline void nvmf_ctrlr_queue_pending_async_event(struct spdk_nvmf_ctrlr *ctrlr, union spdk_nvme_async_event_completion *event) @@ -3207,6 +3187,33 @@ nvmf_ctrlr_queue_pending_async_event(struct spdk_nvmf_ctrlr *ctrlr, STAILQ_INSERT_TAIL(&ctrlr->async_events, nvmf_event, link); } +static inline int +nvmf_ctrlr_async_event_notification(struct spdk_nvmf_ctrlr *ctrlr, + union spdk_nvme_async_event_completion *event) +{ + struct spdk_nvmf_request *req; + struct spdk_nvme_cpl *rsp; + + /* 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; + } + + req = ctrlr->aer_req[--ctrlr->nr_aer_reqs]; + rsp = &req->rsp->nvme_cpl; + + rsp->cdw0 = event->raw; + + _nvmf_request_complete(req); + ctrlr->aer_req[ctrlr->nr_aer_reqs] = NULL; + + return 0; +} + int nvmf_ctrlr_async_event_ns_notice(struct spdk_nvmf_ctrlr *ctrlr) { @@ -3225,15 +3232,6 @@ nvmf_ctrlr_async_event_ns_notice(struct spdk_nvmf_ctrlr *ctrlr) event.bits.async_event_info = SPDK_NVME_ASYNC_EVENT_NS_ATTR_CHANGED; event.bits.log_page_identifier = SPDK_NVME_LOG_CHANGED_NS_LIST; - /* 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); } @@ -3255,15 +3253,6 @@ nvmf_ctrlr_async_event_ana_change_notice(struct spdk_nvmf_ctrlr *ctrlr) event.bits.async_event_info = SPDK_NVME_ASYNC_EVENT_ANA_CHANGE; event.bits.log_page_identifier = SPDK_NVME_LOG_ASYMMETRIC_NAMESPACE_ACCESS; - /* 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); } @@ -3284,15 +3273,6 @@ nvmf_ctrlr_async_event_reservation_notification(struct spdk_nvmf_ctrlr *ctrlr) event.bits.async_event_info = SPDK_NVME_ASYNC_EVENT_RESERVATION_LOG_AVAIL; event.bits.log_page_identifier = SPDK_NVME_LOG_RESERVATION_NOTIFICATION; - /* 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; - } - nvmf_ctrlr_async_event_notification(ctrlr, &event); } @@ -3317,15 +3297,6 @@ nvmf_ctrlr_async_event_discovery_log_change_notice(struct spdk_nvmf_ctrlr *ctrlr event.bits.async_event_info = SPDK_NVME_ASYNC_EVENT_DISCOVERY_LOG_CHANGE; event.bits.log_page_identifier = SPDK_NVME_LOG_DISCOVERY; - /* 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); } @@ -3342,15 +3313,6 @@ nvmf_ctrlr_async_event_error_event(struct spdk_nvmf_ctrlr *ctrlr, 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); }