nvmf: consolidate AER notification into one function

Change-Id: If43e92fad60eff3e3f12cac1a8b413f5c16232fb
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9633
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Changpeng Liu 2021-09-26 22:32:21 +08:00 committed by Tomasz Zawadzki
parent 86ad145bc1
commit f7866a563f

View File

@ -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 static inline void
nvmf_ctrlr_queue_pending_async_event(struct spdk_nvmf_ctrlr *ctrlr, nvmf_ctrlr_queue_pending_async_event(struct spdk_nvmf_ctrlr *ctrlr,
union spdk_nvme_async_event_completion *event) 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); 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 int
nvmf_ctrlr_async_event_ns_notice(struct spdk_nvmf_ctrlr *ctrlr) 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.async_event_info = SPDK_NVME_ASYNC_EVENT_NS_ATTR_CHANGED;
event.bits.log_page_identifier = SPDK_NVME_LOG_CHANGED_NS_LIST; 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); 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.async_event_info = SPDK_NVME_ASYNC_EVENT_ANA_CHANGE;
event.bits.log_page_identifier = SPDK_NVME_LOG_ASYMMETRIC_NAMESPACE_ACCESS; 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); 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.async_event_info = SPDK_NVME_ASYNC_EVENT_RESERVATION_LOG_AVAIL;
event.bits.log_page_identifier = SPDK_NVME_LOG_RESERVATION_NOTIFICATION; 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); 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.async_event_info = SPDK_NVME_ASYNC_EVENT_DISCOVERY_LOG_CHANGE;
event.bits.log_page_identifier = SPDK_NVME_LOG_DISCOVERY; 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); 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; 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); return nvmf_ctrlr_async_event_notification(ctrlr, &event);
} }