Commit 414ff9bc authored by Szulik, Maciej's avatar Szulik, Maciej Committed by Jim Harris
Browse files

nvmf: make async event and error related functions public



This patch makes functions related to Asynchronous Event and error
handling public, so that they can be used in custom nvmf transport
compiled out of SPDK tree.

Signed-off-by: default avatarSzulik, Maciej <maciej.szulik@intel.com>
Change-Id: I253bb7cfc98ea3012c179a709a3337c36b36cb0e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17237


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent a7d3e106
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -22,6 +22,11 @@ New function `spdk_env_get_main_core` was added.
New `spdk_nvmf_request_copy_to/from_buf()` APIs have been added, which support
iovecs, unlike the deprecated `spdk_nvmf_request_get_data()`.

Two functions related to Asynchronous Event and error handling have been made public:

-	`spdk_nvmf_ctrlr_async_event_error_event`,
-	`spdk_nvmf_ctrlr_abort_aer`.

### nvme

New API `spdk_nvme_ns_get_format_index` was added to calculate the exact format index, that
+20 −0
Original line number Diff line number Diff line
@@ -629,6 +629,26 @@ spdk_nvmf_req_get_xfer(struct spdk_nvmf_request *req) {
	return xfer;
}

/**
 * Complete Asynchronous Event as Error.
 *
 * \param ctrlr Controller whose AER is going to be completed.
 * \param info Asynchronous Event Error Information to be reported.
 *
 * \return int. 0 if it completed successfully, or negative errno if it failed.
 */
int spdk_nvmf_ctrlr_async_event_error_event(struct spdk_nvmf_ctrlr *ctrlr,
		enum spdk_nvme_async_event_info_error info);

/**
 * Abort outstanding Asynchronous Event Requests (AERs).
 *
 * Completes AERs with ABORTED_BY_REQUEST status code.
 *
 * \param ctrlr Controller whose AERs are going to be aborted.
 */
void spdk_nvmf_ctrlr_abort_aer(struct spdk_nvmf_ctrlr *ctrlr);

/*
 * Macro used to register new transports.
 */
+10 −5
Original line number Diff line number Diff line
@@ -3764,18 +3764,23 @@ nvmf_ctrlr_async_event_discovery_log_change_notice(void *ctx)
}

int
nvmf_ctrlr_async_event_error_event(struct spdk_nvmf_ctrlr *ctrlr,
				   union spdk_nvme_async_event_completion event)
spdk_nvmf_ctrlr_async_event_error_event(struct spdk_nvmf_ctrlr *ctrlr,
					enum spdk_nvme_async_event_info_error info)
{
	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) {
	if (info > SPDK_NVME_ASYNC_EVENT_FW_IMAGE_LOAD) {
		return 0;
	}

	event.bits.async_event_type = SPDK_NVME_ASYNC_EVENT_TYPE_ERROR;
	event.bits.log_page_identifier = SPDK_NVME_LOG_ERROR;
	event.bits.async_event_info = info;

	return nvmf_ctrlr_async_event_notification(ctrlr, &event);
}

@@ -3800,7 +3805,7 @@ nvmf_qpair_free_aer(struct spdk_nvmf_qpair *qpair)
}

void
nvmf_ctrlr_abort_aer(struct spdk_nvmf_ctrlr *ctrlr)
spdk_nvmf_ctrlr_abort_aer(struct spdk_nvmf_ctrlr *ctrlr)
{
	struct spdk_nvmf_request *req;
	int i;
+1 −8
Original line number Diff line number Diff line
@@ -411,19 +411,12 @@ 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);
void nvmf_ctrlr_async_event_discovery_log_change_notice(void *ctx);
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,
				       enum spdk_nvme_reservation_notification_log_page_type type);

/*
 * Abort aer is sent on a per controller basis and sends a completion for the aer to the host.
 * This function should be called when attempting to recover in error paths when it is OK for
 * the host to send a subsequent AER.
 */
void nvmf_ctrlr_abort_aer(struct spdk_nvmf_ctrlr *ctrlr);

/*
 * Abort zero-copy requests that already got the buffer (received zcopy_start cb), but haven't
+2 −0
Original line number Diff line number Diff line
@@ -125,6 +125,8 @@
	spdk_nvmf_ctrlr_restore_migr_data;
	spdk_nvmf_req_get_xfer;
	spdk_nvmf_poll_group_remove;
	spdk_nvmf_ctrlr_async_event_error_event;
	spdk_nvmf_ctrlr_abort_aer;

	local: *;
};
Loading