From 13f7510f1a02274502b45a4f98417c9fa599d5b5 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Thu, 28 Oct 2021 18:02:32 +0800 Subject: [PATCH] nvmf/ctrlr: save AER commands ID When doing live migration we need to restore the AER commands in the destination VM, so here to provide an API to save these CIDs and the transport layer can save the value. After migration in destination VM, we should allocate new AER requests based on CIDs in vfio-user. Change-Id: I5881f833bbfacb0f030a2b135b4dd47726240378 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10040 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Dong Yi --- lib/nvmf/ctrlr.c | 19 +++++++++++++++++++ lib/nvmf/nvmf_internal.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/lib/nvmf/ctrlr.c b/lib/nvmf/ctrlr.c index 19f232cd4..2dd6d1b98 100644 --- a/lib/nvmf/ctrlr.c +++ b/lib/nvmf/ctrlr.c @@ -1903,6 +1903,25 @@ nvmf_ctrlr_set_features_number_of_queues(struct spdk_nvmf_request *req) return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; } +int +nvmf_ctrlr_save_aers(struct spdk_nvmf_ctrlr *ctrlr, uint16_t *aer_cids, + uint16_t max_aers) +{ + struct spdk_nvmf_request *req; + uint16_t i; + + if (!aer_cids || max_aers < ctrlr->nr_aer_reqs) { + return -EINVAL; + } + + for (i = 0; i < ctrlr->nr_aer_reqs; i++) { + req = ctrlr->aer_req[i]; + aer_cids[i] = req->cmd->nvme_cmd.cid; + } + + return ctrlr->nr_aer_reqs; +} + static int nvmf_ctrlr_set_features_async_event_configuration(struct spdk_nvmf_request *req) { diff --git a/lib/nvmf/nvmf_internal.h b/lib/nvmf/nvmf_internal.h index 5b3976ec4..ed2c3805c 100644 --- a/lib/nvmf/nvmf_internal.h +++ b/lib/nvmf/nvmf_internal.h @@ -449,6 +449,8 @@ void nvmf_ctrlr_reservation_notice_log(struct spdk_nvmf_ctrlr *ctrlr, * the host to send a subsequent AER. */ void nvmf_ctrlr_abort_aer(struct spdk_nvmf_ctrlr *ctrlr); +int nvmf_ctrlr_save_aers(struct spdk_nvmf_ctrlr *ctrlr, uint16_t *aer_cids, + uint16_t max_aers); /* * Abort zero-copy requests that already got the buffer (received zcopy_start cb), but haven't