nvmf: factor out common AER Get/Set Features code

The direct and virtual mode code is identical; move it to session.c like
the other virtualized get/set features.

Change-Id: I0a0e2dd795197c142ad5d9d0e4ddedb2aa5c8c2a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2017-02-14 16:56:29 -07:00
parent 39d5920645
commit 2be0162140
6 changed files with 53 additions and 16 deletions

View File

@ -155,9 +155,7 @@ nvmf_direct_ctrlr_process_admin_cmd(struct spdk_nvmf_request *req)
case SPDK_NVME_FEAT_KEEP_ALIVE_TIMER: case SPDK_NVME_FEAT_KEEP_ALIVE_TIMER:
return spdk_nvmf_session_get_features_keep_alive_timer(req); return spdk_nvmf_session_get_features_keep_alive_timer(req);
case SPDK_NVME_FEAT_ASYNC_EVENT_CONFIGURATION: case SPDK_NVME_FEAT_ASYNC_EVENT_CONFIGURATION:
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Get Features - Async Event Configuration\n"); return spdk_nvmf_session_get_features_async_event_configuration(req);
response->cdw0 = session->async_event_config.raw;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
default: default:
goto passthrough; goto passthrough;
} }
@ -172,10 +170,7 @@ nvmf_direct_ctrlr_process_admin_cmd(struct spdk_nvmf_request *req)
case SPDK_NVME_FEAT_KEEP_ALIVE_TIMER: case SPDK_NVME_FEAT_KEEP_ALIVE_TIMER:
return spdk_nvmf_session_set_features_keep_alive_timer(req); return spdk_nvmf_session_set_features_keep_alive_timer(req);
case SPDK_NVME_FEAT_ASYNC_EVENT_CONFIGURATION: case SPDK_NVME_FEAT_ASYNC_EVENT_CONFIGURATION:
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Set Features - Async Event Configuration, cdw11 0x%08x\n", return spdk_nvmf_session_set_features_async_event_configuration(req);
cmd->cdw11);
session->async_event_config.raw = cmd->cdw11;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
default: default:
goto passthrough; goto passthrough;
} }

View File

@ -740,3 +740,26 @@ spdk_nvmf_session_get_features_number_of_queues(struct spdk_nvmf_request *req)
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
} }
int
spdk_nvmf_session_set_features_async_event_configuration(struct spdk_nvmf_request *req)
{
struct spdk_nvmf_session *session = req->conn->sess;
struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd;
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Set Features - Async Event Configuration, cdw11 0x%08x\n",
cmd->cdw11);
session->async_event_config.raw = cmd->cdw11;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
int
spdk_nvmf_session_get_features_async_event_configuration(struct spdk_nvmf_request *req)
{
struct spdk_nvmf_session *session = req->conn->sess;
struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl;
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Get Features - Async Event Configuration\n");
rsp->cdw0 = session->async_event_config.raw;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}

View File

@ -125,4 +125,7 @@ int spdk_nvmf_session_get_features_keep_alive_timer(struct spdk_nvmf_request *re
int spdk_nvmf_session_set_features_number_of_queues(struct spdk_nvmf_request *req); int spdk_nvmf_session_set_features_number_of_queues(struct spdk_nvmf_request *req);
int spdk_nvmf_session_get_features_number_of_queues(struct spdk_nvmf_request *req); int spdk_nvmf_session_get_features_number_of_queues(struct spdk_nvmf_request *req);
int spdk_nvmf_session_set_features_async_event_configuration(struct spdk_nvmf_request *req);
int spdk_nvmf_session_get_features_async_event_configuration(struct spdk_nvmf_request *req);
#endif #endif

View File

@ -273,7 +273,6 @@ static int
nvmf_virtual_ctrlr_get_features(struct spdk_nvmf_request *req) nvmf_virtual_ctrlr_get_features(struct spdk_nvmf_request *req)
{ {
uint8_t feature; uint8_t feature;
struct spdk_nvmf_session *session = req->conn->sess;
struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd; struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd;
struct spdk_nvme_cpl *response = &req->rsp->nvme_cpl; struct spdk_nvme_cpl *response = &req->rsp->nvme_cpl;
@ -287,9 +286,7 @@ nvmf_virtual_ctrlr_get_features(struct spdk_nvmf_request *req)
case SPDK_NVME_FEAT_KEEP_ALIVE_TIMER: case SPDK_NVME_FEAT_KEEP_ALIVE_TIMER:
return spdk_nvmf_session_get_features_keep_alive_timer(req); return spdk_nvmf_session_get_features_keep_alive_timer(req);
case SPDK_NVME_FEAT_ASYNC_EVENT_CONFIGURATION: case SPDK_NVME_FEAT_ASYNC_EVENT_CONFIGURATION:
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Get Features - Async Event Configuration\n"); return spdk_nvmf_session_get_features_async_event_configuration(req);
response->cdw0 = session->async_event_config.raw;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
case SPDK_NVME_FEAT_HOST_IDENTIFIER: case SPDK_NVME_FEAT_HOST_IDENTIFIER:
return spdk_nvmf_session_get_features_host_identifier(req); return spdk_nvmf_session_get_features_host_identifier(req);
default: default:
@ -303,7 +300,6 @@ static int
nvmf_virtual_ctrlr_set_features(struct spdk_nvmf_request *req) nvmf_virtual_ctrlr_set_features(struct spdk_nvmf_request *req)
{ {
uint8_t feature; uint8_t feature;
struct spdk_nvmf_session *session = req->conn->sess;
struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd; struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd;
struct spdk_nvme_cpl *response = &req->rsp->nvme_cpl; struct spdk_nvme_cpl *response = &req->rsp->nvme_cpl;
@ -314,10 +310,7 @@ nvmf_virtual_ctrlr_set_features(struct spdk_nvmf_request *req)
case SPDK_NVME_FEAT_KEEP_ALIVE_TIMER: case SPDK_NVME_FEAT_KEEP_ALIVE_TIMER:
return spdk_nvmf_session_set_features_keep_alive_timer(req); return spdk_nvmf_session_set_features_keep_alive_timer(req);
case SPDK_NVME_FEAT_ASYNC_EVENT_CONFIGURATION: case SPDK_NVME_FEAT_ASYNC_EVENT_CONFIGURATION:
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Set Features - Async Event Configuration, cdw11 0x%08x\n", return spdk_nvmf_session_set_features_async_event_configuration(req);
cmd->cdw11);
session->async_event_config.raw = cmd->cdw11;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
case SPDK_NVME_FEAT_HOST_IDENTIFIER: case SPDK_NVME_FEAT_HOST_IDENTIFIER:
return spdk_nvmf_session_set_features_host_identifier(req); return spdk_nvmf_session_set_features_host_identifier(req);
default: default:

View File

@ -155,6 +155,17 @@ spdk_nvmf_session_get_features_keep_alive_timer(struct spdk_nvmf_request *req)
return -1; return -1;
} }
int
spdk_nvmf_session_set_features_async_event_configuration(struct spdk_nvmf_request *req)
{
return -1;
}
int
spdk_nvmf_session_get_features_async_event_configuration(struct spdk_nvmf_request *req)
{
return -1;
}
/* test suite function */ /* test suite function */
static void static void

View File

@ -76,6 +76,18 @@ spdk_nvmf_session_get_features_keep_alive_timer(struct spdk_nvmf_request *req)
return -1; return -1;
} }
int
spdk_nvmf_session_set_features_async_event_configuration(struct spdk_nvmf_request *req)
{
return -1;
}
int
spdk_nvmf_session_get_features_async_event_configuration(struct spdk_nvmf_request *req)
{
return -1;
}
int int
spdk_nvmf_request_complete(struct spdk_nvmf_request *req) spdk_nvmf_request_complete(struct spdk_nvmf_request *req)
{ {