nvmf: decrease the aer notification code

Using an inline function to decrease the aer notification code.
It also can benefit from adding new async events later.

Change-Id: Id0f7c57fd66ade303c625d1d1af10d41dead8994
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2547
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Jin Yu 2020-05-20 23:33:53 +08:00 committed by Tomasz Zawadzki
parent 9396422b36
commit 13cc64fd53

View File

@ -2386,11 +2386,27 @@ nvmf_ctrlr_process_fabrics_cmd(struct spdk_nvmf_request *req)
}
}
int
nvmf_ctrlr_async_event_ns_notice(struct spdk_nvmf_ctrlr *ctrlr)
static inline int
nvmf_ctrlr_async_event_nofitification(struct spdk_nvmf_ctrlr *ctrlr,
union spdk_nvme_async_event_completion *event)
{
struct spdk_nvmf_request *req;
struct spdk_nvme_cpl *rsp;
req = ctrlr->aer_req;
rsp = &req->rsp->nvme_cpl;
rsp->cdw0 = event->raw;
spdk_nvmf_request_complete(req);
ctrlr->aer_req = NULL;
return 0;
}
int
nvmf_ctrlr_async_event_ns_notice(struct spdk_nvmf_ctrlr *ctrlr)
{
union spdk_nvme_async_event_completion event = {0};
/* Users may disable the event notification */
@ -2416,22 +2432,12 @@ nvmf_ctrlr_async_event_ns_notice(struct spdk_nvmf_ctrlr *ctrlr)
return 0;
}
req = ctrlr->aer_req;
rsp = &req->rsp->nvme_cpl;
rsp->cdw0 = event.raw;
spdk_nvmf_request_complete(req);
ctrlr->aer_req = NULL;
return 0;
return nvmf_ctrlr_async_event_nofitification(ctrlr, &event);
}
void
nvmf_ctrlr_async_event_reservation_notification(struct spdk_nvmf_ctrlr *ctrlr)
{
struct spdk_nvmf_request *req;
struct spdk_nvme_cpl *rsp;
union spdk_nvme_async_event_completion event = {0};
if (!ctrlr->num_avail_log_pages) {
@ -2455,13 +2461,7 @@ nvmf_ctrlr_async_event_reservation_notification(struct spdk_nvmf_ctrlr *ctrlr)
return;
}
req = ctrlr->aer_req;
rsp = &req->rsp->nvme_cpl;
rsp->cdw0 = event.raw;
spdk_nvmf_request_complete(req);
ctrlr->aer_req = NULL;
nvmf_ctrlr_async_event_nofitification(ctrlr, &event);
}
void