nvmf: drop redundant nvmf_process_admin_cmd params
Everything necessary for processing an admin command is now stored in nvmf_request. Change-Id: I74e75a5b7bb3b406ad167c2b31cab1af7a1f270a Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
2f5ccef310
commit
8836a17f80
@ -729,7 +729,7 @@ nvmf_process_admin_command(struct spdk_nvmf_conn *conn,
|
|||||||
tx_desc, req, (void *)req->rsp, (void *)tx_desc->send_sgl.addr);
|
tx_desc, req, (void *)req->rsp, (void *)tx_desc->send_sgl.addr);
|
||||||
|
|
||||||
/* send to NVMf library for backend NVMe processing */
|
/* send to NVMf library for backend NVMe processing */
|
||||||
ret = nvmf_process_admin_cmd(req->session, cmd, req->data, req->length, req);
|
ret = nvmf_process_admin_cmd(req);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
/* library failed the request and should have
|
/* library failed the request and should have
|
||||||
Updated the response */
|
Updated the response */
|
||||||
|
@ -42,23 +42,21 @@
|
|||||||
#include "spdk/trace.h"
|
#include "spdk/trace.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
nvmf_process_admin_cmd(struct nvmf_session *session,
|
nvmf_process_admin_cmd(struct nvmf_request *req)
|
||||||
struct spdk_nvme_cmd *cmd,
|
|
||||||
void *buf, uint32_t len,
|
|
||||||
struct nvmf_request *req_state)
|
|
||||||
{
|
{
|
||||||
struct spdk_nvme_cpl *response;
|
struct nvmf_session *session = req->session;
|
||||||
|
struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd;
|
||||||
|
struct spdk_nvme_cpl *response = &req->rsp->nvme_cpl;
|
||||||
struct spdk_nvmf_subsystem *subsystem = session->subsys;
|
struct spdk_nvmf_subsystem *subsystem = session->subsys;
|
||||||
struct spdk_nvme_ctrlr *ctrlr = NULL;
|
struct spdk_nvme_ctrlr *ctrlr = NULL;
|
||||||
uint32_t nsid = 0;
|
uint32_t nsid = 0;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
uint8_t feature;
|
uint8_t feature;
|
||||||
|
|
||||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_process_admin_cmd: req_state %p\n",
|
SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_process_admin_cmd: req %p\n",
|
||||||
req_state);
|
req);
|
||||||
|
|
||||||
/* pre-set response details for this command */
|
/* pre-set response details for this command */
|
||||||
response = &req_state->rsp->nvme_cpl;
|
|
||||||
response->status.sc = SPDK_NVME_SC_SUCCESS;
|
response->status.sc = SPDK_NVME_SC_SUCCESS;
|
||||||
response->cid = cmd->cid;
|
response->cid = cmd->cid;
|
||||||
|
|
||||||
@ -94,7 +92,7 @@ nvmf_process_admin_cmd(struct nvmf_session *session,
|
|||||||
|
|
||||||
switch (cmd->opc) {
|
switch (cmd->opc) {
|
||||||
case SPDK_NVME_OPC_IDENTIFY:
|
case SPDK_NVME_OPC_IDENTIFY:
|
||||||
if (buf == NULL) {
|
if (req->data == NULL) {
|
||||||
SPDK_ERRLOG("identify command with no buffer\n");
|
SPDK_ERRLOG("identify command with no buffer\n");
|
||||||
response->status.sc = SPDK_NVME_SC_INVALID_FIELD;
|
response->status.sc = SPDK_NVME_SC_INVALID_FIELD;
|
||||||
rc = -1;
|
rc = -1;
|
||||||
@ -120,14 +118,14 @@ nvmf_process_admin_cmd(struct nvmf_session *session,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nsdata = spdk_nvme_ns_get_data(ns);
|
nsdata = spdk_nvme_ns_get_data(ns);
|
||||||
memcpy((char *)buf, (char *)nsdata, sizeof(struct spdk_nvme_ns_data));
|
memcpy(req->data, (char *)nsdata, sizeof(struct spdk_nvme_ns_data));
|
||||||
req_state->cb_fn(req_state);
|
req->cb_fn(req);
|
||||||
} else if (cmd->cdw10 == 1) {
|
} else if (cmd->cdw10 == 1) {
|
||||||
/* identify controller */
|
/* identify controller */
|
||||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Identify Controller\n");
|
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Identify Controller\n");
|
||||||
/* pull from virtual controller context */
|
/* pull from virtual controller context */
|
||||||
memcpy(buf, (char *)&session->vcdata, sizeof(struct spdk_nvme_ctrlr_data));
|
memcpy(req->data, (char *)&session->vcdata, sizeof(struct spdk_nvme_ctrlr_data));
|
||||||
req_state->cb_fn(req_state);
|
req->cb_fn(req);
|
||||||
} else {
|
} else {
|
||||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Identify Namespace List\n");
|
SPDK_TRACELOG(SPDK_TRACE_NVMF, "Identify Namespace List\n");
|
||||||
response->status.sc = SPDK_NVME_SC_INVALID_OPCODE;
|
response->status.sc = SPDK_NVME_SC_INVALID_OPCODE;
|
||||||
@ -279,7 +277,7 @@ nvmf_process_admin_cmd(struct nvmf_session *session,
|
|||||||
until NVMe library indicates some event.
|
until NVMe library indicates some event.
|
||||||
*/
|
*/
|
||||||
if (session->aer_req_state == NULL) {
|
if (session->aer_req_state == NULL) {
|
||||||
session->aer_req_state = req_state;
|
session->aer_req_state = req;
|
||||||
} else {
|
} else {
|
||||||
/* AER already recorded, send error response */
|
/* AER already recorded, send error response */
|
||||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "AER already active!\n");
|
SPDK_TRACELOG(SPDK_TRACE_NVMF, "AER already active!\n");
|
||||||
@ -307,9 +305,9 @@ passthrough:
|
|||||||
cmd->nsid = nsid;
|
cmd->nsid = nsid;
|
||||||
rc = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr,
|
rc = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr,
|
||||||
cmd,
|
cmd,
|
||||||
buf, len,
|
req->data, req->length,
|
||||||
nvmf_complete_cmd,
|
nvmf_complete_cmd,
|
||||||
(void *)req_state);
|
req);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
SPDK_ERRLOG("nvmf_process_admin_cmd: Error to submit Admin Opcode %x\n", cmd->opc);
|
SPDK_ERRLOG("nvmf_process_admin_cmd: Error to submit Admin Opcode %x\n", cmd->opc);
|
||||||
response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
|
response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
|
||||||
|
@ -120,10 +120,7 @@ void
|
|||||||
nvmf_init_session_properties(struct nvmf_session *session, int aq_depth);
|
nvmf_init_session_properties(struct nvmf_session *session, int aq_depth);
|
||||||
|
|
||||||
int
|
int
|
||||||
nvmf_process_admin_cmd(struct nvmf_session *session,
|
nvmf_process_admin_cmd(struct nvmf_request *req);
|
||||||
struct spdk_nvme_cmd *cmd,
|
|
||||||
void *buf, uint32_t len,
|
|
||||||
struct nvmf_request *req_state);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
nvmf_process_io_cmd(struct nvmf_request *req);
|
nvmf_process_io_cmd(struct nvmf_request *req);
|
||||||
|
@ -583,9 +583,10 @@ nvmf_test_process_admin_cmd(void)
|
|||||||
struct nvmf_request nvmf_req = {};
|
struct nvmf_request nvmf_req = {};
|
||||||
struct spdk_nvmf_subsystem *subsystem;
|
struct spdk_nvmf_subsystem *subsystem;
|
||||||
int buf_len = sizeof(struct spdk_nvme_ns_data);
|
int buf_len = sizeof(struct spdk_nvme_ns_data);
|
||||||
uint8_t *buf;
|
|
||||||
|
|
||||||
sess = nvmf_find_session_by_id("subsystem1", SS_SC_CNTLID);
|
sess = nvmf_find_session_by_id("subsystem1", SS_SC_CNTLID);
|
||||||
|
nvmf_req.session = sess;
|
||||||
|
nvmf_req.cmd = (union nvmf_h2c_msg *)&nvmf_cmd;
|
||||||
nvmf_req.rsp = malloc(sizeof(union nvmf_c2h_msg));
|
nvmf_req.rsp = malloc(sizeof(union nvmf_c2h_msg));
|
||||||
nvmf_req.cb_fn = admin_nvmf_cmd_complete;
|
nvmf_req.cb_fn = admin_nvmf_cmd_complete;
|
||||||
#define BUILD_CMD(cmd_opc, cmd_nsid, cmd_cid, cmd_cdw10) \
|
#define BUILD_CMD(cmd_opc, cmd_nsid, cmd_cid, cmd_cdw10) \
|
||||||
@ -598,13 +599,13 @@ nvmf_test_process_admin_cmd(void)
|
|||||||
|
|
||||||
#define RUN_AND_CHECK_PROPERT_GET_RESULT(expect_ret, cmd_cid, sts) \
|
#define RUN_AND_CHECK_PROPERT_GET_RESULT(expect_ret, cmd_cid, sts) \
|
||||||
do { \
|
do { \
|
||||||
CU_ASSERT_EQUAL(nvmf_process_admin_cmd(sess, &nvmf_cmd, buf, buf_len, &nvmf_req), expect_ret); \
|
CU_ASSERT_EQUAL(nvmf_process_admin_cmd(&nvmf_req), expect_ret); \
|
||||||
CU_ASSERT_EQUAL(nvmf_req.rsp->nvme_cpl.cid, cmd_cid); \
|
CU_ASSERT_EQUAL(nvmf_req.rsp->nvme_cpl.cid, cmd_cid); \
|
||||||
CU_ASSERT_EQUAL(nvmf_req.rsp->nvme_cpl.status.sc, sts); \
|
CU_ASSERT_EQUAL(nvmf_req.rsp->nvme_cpl.status.sc, sts); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* check subsys=NULL condition */
|
/* check subsys=NULL condition */
|
||||||
buf = malloc(buf_len);
|
nvmf_req.data = malloc(buf_len);
|
||||||
subsystem = sess->subsys;
|
subsystem = sess->subsys;
|
||||||
sess->subsys = NULL;
|
sess->subsys = NULL;
|
||||||
BUILD_CMD(SPDK_NVME_OPC_IDENTIFY, 2, 100, 0);
|
BUILD_CMD(SPDK_NVME_OPC_IDENTIFY, 2, 100, 0);
|
||||||
@ -622,16 +623,16 @@ nvmf_test_process_admin_cmd(void)
|
|||||||
/* identify namespace */
|
/* identify namespace */
|
||||||
BUILD_CMD(SPDK_NVME_OPC_IDENTIFY, 2, 8, 0);
|
BUILD_CMD(SPDK_NVME_OPC_IDENTIFY, 2, 8, 0);
|
||||||
RUN_AND_CHECK_PROPERT_GET_RESULT(0, 8, SPDK_NVME_SC_SUCCESS);
|
RUN_AND_CHECK_PROPERT_GET_RESULT(0, 8, SPDK_NVME_SC_SUCCESS);
|
||||||
free(buf);
|
free(nvmf_req.data);
|
||||||
/* identify controller */
|
/* identify controller */
|
||||||
buf_len = sizeof(struct spdk_nvme_ctrlr_data);
|
buf_len = sizeof(struct spdk_nvme_ctrlr_data);
|
||||||
buf = malloc(buf_len);
|
nvmf_req.data = malloc(buf_len);
|
||||||
BUILD_CMD(SPDK_NVME_OPC_IDENTIFY, 2, 9, 1);
|
BUILD_CMD(SPDK_NVME_OPC_IDENTIFY, 2, 9, 1);
|
||||||
RUN_AND_CHECK_PROPERT_GET_RESULT(0, 9, SPDK_NVME_SC_SUCCESS);
|
RUN_AND_CHECK_PROPERT_GET_RESULT(0, 9, SPDK_NVME_SC_SUCCESS);
|
||||||
free(buf);
|
free(nvmf_req.data);
|
||||||
/* identify controller with invalid cdw10=2 */
|
/* identify controller with invalid cdw10=2 */
|
||||||
buf_len = sizeof(struct spdk_nvme_ctrlr_data);
|
buf_len = sizeof(struct spdk_nvme_ctrlr_data);
|
||||||
buf = malloc(buf_len);
|
nvmf_req.data = malloc(buf_len);
|
||||||
BUILD_CMD(SPDK_NVME_OPC_IDENTIFY, 2, 9, 2);
|
BUILD_CMD(SPDK_NVME_OPC_IDENTIFY, 2, 9, 2);
|
||||||
RUN_AND_CHECK_PROPERT_GET_RESULT(-1, 9, SPDK_NVME_SC_INVALID_OPCODE);
|
RUN_AND_CHECK_PROPERT_GET_RESULT(-1, 9, SPDK_NVME_SC_INVALID_OPCODE);
|
||||||
/* create IO SQ whose qid > MAX_SESSION_IO_QUEUES */
|
/* create IO SQ whose qid > MAX_SESSION_IO_QUEUES */
|
||||||
@ -699,8 +700,8 @@ nvmf_test_process_admin_cmd(void)
|
|||||||
BUILD_CMD(SPDK_NVME_OPC_SET_FEATURES, 2, 19, SPDK_NVME_FEAT_NUMBER_OF_QUEUES);
|
BUILD_CMD(SPDK_NVME_OPC_SET_FEATURES, 2, 19, SPDK_NVME_FEAT_NUMBER_OF_QUEUES);
|
||||||
RUN_AND_CHECK_PROPERT_GET_RESULT(1, 19, SPDK_NVME_SC_SUCCESS);
|
RUN_AND_CHECK_PROPERT_GET_RESULT(1, 19, SPDK_NVME_SC_SUCCESS);
|
||||||
CU_ASSERT_EQUAL(nvmf_req.rsp->nvme_cpl.cdw0 & 0xffff, 63);
|
CU_ASSERT_EQUAL(nvmf_req.rsp->nvme_cpl.cdw0 & 0xffff, 63);
|
||||||
free(buf);
|
free(nvmf_req.data);
|
||||||
buf = NULL;
|
nvmf_req.data = NULL;
|
||||||
}
|
}
|
||||||
/* for property get and set only */
|
/* for property get and set only */
|
||||||
#define BUILD_PROPERTY_CMD(property_name, cmd_attr, cmd_cid) \
|
#define BUILD_PROPERTY_CMD(property_name, cmd_attr, cmd_cid) \
|
||||||
|
Loading…
Reference in New Issue
Block a user