nvmf: factor out generic Get Features handler

Most Get Features commands can be handled by just setting CDW0 to a
particular value and returning success.

Get Features - Host Identifier needs special handling, so it isn't
converted.

Change-Id: I8a3e2d5659a9ecbb3904589912ccf44d0d25b715
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/403901
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Daniel Verkamp 2018-03-14 17:26:54 -07:00 committed by Jim Harris
parent 0f56183728
commit 4fce1a5fa6

View File

@ -738,17 +738,6 @@ spdk_nvmf_ctrlr_set_features_keep_alive_timer(struct spdk_nvmf_request *req)
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
static int
spdk_nvmf_ctrlr_get_features_keep_alive_timer(struct spdk_nvmf_request *req)
{
struct spdk_nvmf_ctrlr *ctrlr = req->qpair->ctrlr;
struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl;
SPDK_DEBUGLOG(SPDK_LOG_NVMF, "Get Features - Keep Alive Timer\n");
rsp->cdw0 = ctrlr->feat.keep_alive_timer.bits.kato;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
static int
spdk_nvmf_ctrlr_set_features_number_of_queues(struct spdk_nvmf_request *req)
{
@ -773,28 +762,6 @@ spdk_nvmf_ctrlr_set_features_number_of_queues(struct spdk_nvmf_request *req)
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
static int
spdk_nvmf_ctrlr_get_features_number_of_queues(struct spdk_nvmf_request *req)
{
struct spdk_nvmf_ctrlr *ctrlr = req->qpair->ctrlr;
struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl;
SPDK_DEBUGLOG(SPDK_LOG_NVMF, "Get Features - Number of Queues\n");
rsp->cdw0 = ctrlr->feat.number_of_queues.raw;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
static int
spdk_nvmf_ctrlr_get_features_write_cache(struct spdk_nvmf_request *req)
{
struct spdk_nvmf_ctrlr *ctrlr = req->qpair->ctrlr;
struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl;
SPDK_DEBUGLOG(SPDK_LOG_NVMF, "Get Features - Write Cache\n");
rsp->cdw0 = ctrlr->feat.volatile_write_cache.raw;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
static int
spdk_nvmf_ctrlr_set_features_async_event_configuration(struct spdk_nvmf_request *req)
{
@ -807,17 +774,6 @@ spdk_nvmf_ctrlr_set_features_async_event_configuration(struct spdk_nvmf_request
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
static int
spdk_nvmf_ctrlr_get_features_async_event_configuration(struct spdk_nvmf_request *req)
{
struct spdk_nvmf_ctrlr *ctrlr = req->qpair->ctrlr;
struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl;
SPDK_DEBUGLOG(SPDK_LOG_NVMF, "Get Features - Async Event Configuration\n");
rsp->cdw0 = ctrlr->feat.async_event_configuration.raw;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
static int
spdk_nvmf_ctrlr_async_event_request(struct spdk_nvmf_request *req)
{
@ -1187,23 +1143,33 @@ spdk_nvmf_ctrlr_abort(struct spdk_nvmf_request *req)
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
static int
get_features_generic(struct spdk_nvmf_request *req, uint32_t cdw0)
{
struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl;
rsp->cdw0 = cdw0;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
static int
spdk_nvmf_ctrlr_get_features(struct spdk_nvmf_request *req)
{
uint8_t feature;
struct spdk_nvmf_ctrlr *ctrlr = req->qpair->ctrlr;
struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd;
struct spdk_nvme_cpl *response = &req->rsp->nvme_cpl;
feature = cmd->cdw10 & 0xff; /* mask out the FID value */
switch (feature) {
case SPDK_NVME_FEAT_NUMBER_OF_QUEUES:
return spdk_nvmf_ctrlr_get_features_number_of_queues(req);
return get_features_generic(req, ctrlr->feat.number_of_queues.raw);
case SPDK_NVME_FEAT_VOLATILE_WRITE_CACHE:
return spdk_nvmf_ctrlr_get_features_write_cache(req);
return get_features_generic(req, ctrlr->feat.volatile_write_cache.raw);
case SPDK_NVME_FEAT_KEEP_ALIVE_TIMER:
return spdk_nvmf_ctrlr_get_features_keep_alive_timer(req);
return get_features_generic(req, ctrlr->feat.keep_alive_timer.raw);
case SPDK_NVME_FEAT_ASYNC_EVENT_CONFIGURATION:
return spdk_nvmf_ctrlr_get_features_async_event_configuration(req);
return get_features_generic(req, ctrlr->feat.async_event_configuration.raw);
case SPDK_NVME_FEAT_HOST_IDENTIFIER:
return spdk_nvmf_ctrlr_get_features_host_identifier(req);
default: