Loading lib/nvmf/conn.c +1 −1 Original line number Diff line number Diff line Loading @@ -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); /* 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) { /* library failed the request and should have Updated the response */ Loading lib/nvmf/nvmf_admin_cmd.c +14 −16 Original line number Diff line number Diff line Loading @@ -42,23 +42,21 @@ #include "spdk/trace.h" int nvmf_process_admin_cmd(struct nvmf_session *session, struct spdk_nvme_cmd *cmd, void *buf, uint32_t len, struct nvmf_request *req_state) nvmf_process_admin_cmd(struct nvmf_request *req) { 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_nvme_ctrlr *ctrlr = NULL; uint32_t nsid = 0; int rc = 0; uint8_t feature; SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_process_admin_cmd: req_state %p\n", req_state); SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_process_admin_cmd: req %p\n", req); /* pre-set response details for this command */ response = &req_state->rsp->nvme_cpl; response->status.sc = SPDK_NVME_SC_SUCCESS; response->cid = cmd->cid; Loading Loading @@ -94,7 +92,7 @@ nvmf_process_admin_cmd(struct nvmf_session *session, switch (cmd->opc) { case SPDK_NVME_OPC_IDENTIFY: if (buf == NULL) { if (req->data == NULL) { SPDK_ERRLOG("identify command with no buffer\n"); response->status.sc = SPDK_NVME_SC_INVALID_FIELD; rc = -1; Loading @@ -120,14 +118,14 @@ nvmf_process_admin_cmd(struct nvmf_session *session, break; } nsdata = spdk_nvme_ns_get_data(ns); memcpy((char *)buf, (char *)nsdata, sizeof(struct spdk_nvme_ns_data)); req_state->cb_fn(req_state); memcpy(req->data, (char *)nsdata, sizeof(struct spdk_nvme_ns_data)); req->cb_fn(req); } else if (cmd->cdw10 == 1) { /* identify controller */ SPDK_TRACELOG(SPDK_TRACE_NVMF, "Identify Controller\n"); /* pull from virtual controller context */ memcpy(buf, (char *)&session->vcdata, sizeof(struct spdk_nvme_ctrlr_data)); req_state->cb_fn(req_state); memcpy(req->data, (char *)&session->vcdata, sizeof(struct spdk_nvme_ctrlr_data)); req->cb_fn(req); } else { SPDK_TRACELOG(SPDK_TRACE_NVMF, "Identify Namespace List\n"); response->status.sc = SPDK_NVME_SC_INVALID_OPCODE; Loading Loading @@ -279,7 +277,7 @@ nvmf_process_admin_cmd(struct nvmf_session *session, until NVMe library indicates some event. */ if (session->aer_req_state == NULL) { session->aer_req_state = req_state; session->aer_req_state = req; } else { /* AER already recorded, send error response */ SPDK_TRACELOG(SPDK_TRACE_NVMF, "AER already active!\n"); Loading Loading @@ -307,9 +305,9 @@ passthrough: cmd->nsid = nsid; rc = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, cmd, buf, len, req->data, req->length, nvmf_complete_cmd, (void *)req_state); req); if (rc) { SPDK_ERRLOG("nvmf_process_admin_cmd: Error to submit Admin Opcode %x\n", cmd->opc); response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR; Loading lib/nvmf/session.h +1 −4 Original line number Diff line number Diff line Loading @@ -120,10 +120,7 @@ void nvmf_init_session_properties(struct nvmf_session *session, int aq_depth); int nvmf_process_admin_cmd(struct nvmf_session *session, struct spdk_nvme_cmd *cmd, void *buf, uint32_t len, struct nvmf_request *req_state); nvmf_process_admin_cmd(struct nvmf_request *req); int nvmf_process_io_cmd(struct nvmf_request *req); Loading test/lib/nvmf/nvmf_c/nvmf_ut.c +10 −9 Original line number Diff line number Diff line Loading @@ -583,9 +583,10 @@ nvmf_test_process_admin_cmd(void) struct nvmf_request nvmf_req = {}; struct spdk_nvmf_subsystem *subsystem; int buf_len = sizeof(struct spdk_nvme_ns_data); uint8_t *buf; 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.cb_fn = admin_nvmf_cmd_complete; #define BUILD_CMD(cmd_opc, cmd_nsid, cmd_cid, cmd_cdw10) \ Loading @@ -598,13 +599,13 @@ nvmf_test_process_admin_cmd(void) #define RUN_AND_CHECK_PROPERT_GET_RESULT(expect_ret, cmd_cid, sts) \ 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.status.sc, sts); \ } while (0) /* check subsys=NULL condition */ buf = malloc(buf_len); nvmf_req.data = malloc(buf_len); subsystem = sess->subsys; sess->subsys = NULL; BUILD_CMD(SPDK_NVME_OPC_IDENTIFY, 2, 100, 0); Loading @@ -622,16 +623,16 @@ nvmf_test_process_admin_cmd(void) /* identify namespace */ BUILD_CMD(SPDK_NVME_OPC_IDENTIFY, 2, 8, 0); RUN_AND_CHECK_PROPERT_GET_RESULT(0, 8, SPDK_NVME_SC_SUCCESS); free(buf); free(nvmf_req.data); /* identify controller */ 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); RUN_AND_CHECK_PROPERT_GET_RESULT(0, 9, SPDK_NVME_SC_SUCCESS); free(buf); free(nvmf_req.data); /* identify controller with invalid cdw10=2 */ 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); RUN_AND_CHECK_PROPERT_GET_RESULT(-1, 9, SPDK_NVME_SC_INVALID_OPCODE); /* create IO SQ whose qid > MAX_SESSION_IO_QUEUES */ Loading Loading @@ -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); RUN_AND_CHECK_PROPERT_GET_RESULT(1, 19, SPDK_NVME_SC_SUCCESS); CU_ASSERT_EQUAL(nvmf_req.rsp->nvme_cpl.cdw0 & 0xffff, 63); free(buf); buf = NULL; free(nvmf_req.data); nvmf_req.data = NULL; } /* for property get and set only */ #define BUILD_PROPERTY_CMD(property_name, cmd_attr, cmd_cid) \ Loading Loading
lib/nvmf/conn.c +1 −1 Original line number Diff line number Diff line Loading @@ -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); /* 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) { /* library failed the request and should have Updated the response */ Loading
lib/nvmf/nvmf_admin_cmd.c +14 −16 Original line number Diff line number Diff line Loading @@ -42,23 +42,21 @@ #include "spdk/trace.h" int nvmf_process_admin_cmd(struct nvmf_session *session, struct spdk_nvme_cmd *cmd, void *buf, uint32_t len, struct nvmf_request *req_state) nvmf_process_admin_cmd(struct nvmf_request *req) { 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_nvme_ctrlr *ctrlr = NULL; uint32_t nsid = 0; int rc = 0; uint8_t feature; SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_process_admin_cmd: req_state %p\n", req_state); SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_process_admin_cmd: req %p\n", req); /* pre-set response details for this command */ response = &req_state->rsp->nvme_cpl; response->status.sc = SPDK_NVME_SC_SUCCESS; response->cid = cmd->cid; Loading Loading @@ -94,7 +92,7 @@ nvmf_process_admin_cmd(struct nvmf_session *session, switch (cmd->opc) { case SPDK_NVME_OPC_IDENTIFY: if (buf == NULL) { if (req->data == NULL) { SPDK_ERRLOG("identify command with no buffer\n"); response->status.sc = SPDK_NVME_SC_INVALID_FIELD; rc = -1; Loading @@ -120,14 +118,14 @@ nvmf_process_admin_cmd(struct nvmf_session *session, break; } nsdata = spdk_nvme_ns_get_data(ns); memcpy((char *)buf, (char *)nsdata, sizeof(struct spdk_nvme_ns_data)); req_state->cb_fn(req_state); memcpy(req->data, (char *)nsdata, sizeof(struct spdk_nvme_ns_data)); req->cb_fn(req); } else if (cmd->cdw10 == 1) { /* identify controller */ SPDK_TRACELOG(SPDK_TRACE_NVMF, "Identify Controller\n"); /* pull from virtual controller context */ memcpy(buf, (char *)&session->vcdata, sizeof(struct spdk_nvme_ctrlr_data)); req_state->cb_fn(req_state); memcpy(req->data, (char *)&session->vcdata, sizeof(struct spdk_nvme_ctrlr_data)); req->cb_fn(req); } else { SPDK_TRACELOG(SPDK_TRACE_NVMF, "Identify Namespace List\n"); response->status.sc = SPDK_NVME_SC_INVALID_OPCODE; Loading Loading @@ -279,7 +277,7 @@ nvmf_process_admin_cmd(struct nvmf_session *session, until NVMe library indicates some event. */ if (session->aer_req_state == NULL) { session->aer_req_state = req_state; session->aer_req_state = req; } else { /* AER already recorded, send error response */ SPDK_TRACELOG(SPDK_TRACE_NVMF, "AER already active!\n"); Loading Loading @@ -307,9 +305,9 @@ passthrough: cmd->nsid = nsid; rc = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, cmd, buf, len, req->data, req->length, nvmf_complete_cmd, (void *)req_state); req); if (rc) { SPDK_ERRLOG("nvmf_process_admin_cmd: Error to submit Admin Opcode %x\n", cmd->opc); response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR; Loading
lib/nvmf/session.h +1 −4 Original line number Diff line number Diff line Loading @@ -120,10 +120,7 @@ void nvmf_init_session_properties(struct nvmf_session *session, int aq_depth); int nvmf_process_admin_cmd(struct nvmf_session *session, struct spdk_nvme_cmd *cmd, void *buf, uint32_t len, struct nvmf_request *req_state); nvmf_process_admin_cmd(struct nvmf_request *req); int nvmf_process_io_cmd(struct nvmf_request *req); Loading
test/lib/nvmf/nvmf_c/nvmf_ut.c +10 −9 Original line number Diff line number Diff line Loading @@ -583,9 +583,10 @@ nvmf_test_process_admin_cmd(void) struct nvmf_request nvmf_req = {}; struct spdk_nvmf_subsystem *subsystem; int buf_len = sizeof(struct spdk_nvme_ns_data); uint8_t *buf; 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.cb_fn = admin_nvmf_cmd_complete; #define BUILD_CMD(cmd_opc, cmd_nsid, cmd_cid, cmd_cdw10) \ Loading @@ -598,13 +599,13 @@ nvmf_test_process_admin_cmd(void) #define RUN_AND_CHECK_PROPERT_GET_RESULT(expect_ret, cmd_cid, sts) \ 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.status.sc, sts); \ } while (0) /* check subsys=NULL condition */ buf = malloc(buf_len); nvmf_req.data = malloc(buf_len); subsystem = sess->subsys; sess->subsys = NULL; BUILD_CMD(SPDK_NVME_OPC_IDENTIFY, 2, 100, 0); Loading @@ -622,16 +623,16 @@ nvmf_test_process_admin_cmd(void) /* identify namespace */ BUILD_CMD(SPDK_NVME_OPC_IDENTIFY, 2, 8, 0); RUN_AND_CHECK_PROPERT_GET_RESULT(0, 8, SPDK_NVME_SC_SUCCESS); free(buf); free(nvmf_req.data); /* identify controller */ 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); RUN_AND_CHECK_PROPERT_GET_RESULT(0, 9, SPDK_NVME_SC_SUCCESS); free(buf); free(nvmf_req.data); /* identify controller with invalid cdw10=2 */ 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); RUN_AND_CHECK_PROPERT_GET_RESULT(-1, 9, SPDK_NVME_SC_INVALID_OPCODE); /* create IO SQ whose qid > MAX_SESSION_IO_QUEUES */ Loading Loading @@ -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); RUN_AND_CHECK_PROPERT_GET_RESULT(1, 19, SPDK_NVME_SC_SUCCESS); CU_ASSERT_EQUAL(nvmf_req.rsp->nvme_cpl.cdw0 & 0xffff, 63); free(buf); buf = NULL; free(nvmf_req.data); nvmf_req.data = NULL; } /* for property get and set only */ #define BUILD_PROPERTY_CMD(property_name, cmd_attr, cmd_cid) \ Loading