Commit 13cc64fd authored by Jin Yu's avatar Jin Yu Committed by Tomasz Zawadzki
Browse files

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: default avatarJin 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: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 9396422b
Loading
Loading
Loading
Loading
+20 −20
Original line number Diff line number Diff line
@@ -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