nvme: add SPDK_NVME_IDENTIFY_BUFLEN

Add a define for the Identify command buffer instead of using a raw
value.

Signed-off-by: John Levon <john.levon@nutanix.com>
Change-Id: I9073ff84e2fa2ef9268051b898fe1027d8e97baa
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16119
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
John Levon 2023-01-04 09:59:40 +00:00 committed by Jim Harris
parent 4bb902a6f4
commit b6f674772c
3 changed files with 6 additions and 2 deletions

View File

@ -3809,6 +3809,9 @@ SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_ns_streams_status) == 131072, "Incorr
#define SPDK_NVME_IO_FLAGS_VALID_MASK 0xFFFF0003 #define SPDK_NVME_IO_FLAGS_VALID_MASK 0xFFFF0003
#define SPDK_NVME_IO_FLAGS_CDW12_MASK 0xFFFF0000 #define SPDK_NVME_IO_FLAGS_CDW12_MASK 0xFFFF0000
/** Identify command buffer response size */
#define SPDK_NVME_IDENTIFY_BUFLEN 4096
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -2895,7 +2895,7 @@ nvmf_ctrlr_identify(struct spdk_nvmf_request *req)
struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl; struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl;
struct spdk_nvmf_subsystem *subsystem = ctrlr->subsys; struct spdk_nvmf_subsystem *subsystem = ctrlr->subsys;
if (req->data == NULL || req->length < 4096) { if (req->data == NULL || req->length < SPDK_NVME_IDENTIFY_BUFLEN) {
SPDK_DEBUGLOG(nvmf, "identify command with invalid buffer\n"); SPDK_DEBUGLOG(nvmf, "identify command with invalid buffer\n");
rsp->status.sct = SPDK_NVME_SCT_GENERIC; rsp->status.sct = SPDK_NVME_SCT_GENERIC;
rsp->status.sc = SPDK_NVME_SC_INVALID_FIELD; rsp->status.sc = SPDK_NVME_SC_INVALID_FIELD;

View File

@ -968,7 +968,8 @@ test_nvme_ctrlr_cmd_identify(void)
int rc; int rc;
MOCK_SET(nvme_ctrlr_submit_admin_request, 0); MOCK_SET(nvme_ctrlr_submit_admin_request, 0);
rc = nvme_ctrlr_cmd_identify(&ctrlr, SPDK_NVME_IDENTIFY_NS, 2, 1, 0, &payload, 4096, NULL, NULL); rc = nvme_ctrlr_cmd_identify(&ctrlr, SPDK_NVME_IDENTIFY_NS, 2, 1, 0, &payload,
SPDK_NVME_IDENTIFY_BUFLEN, NULL, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(req.cmd.opc == SPDK_NVME_OPC_IDENTIFY); CU_ASSERT(req.cmd.opc == SPDK_NVME_OPC_IDENTIFY);
CU_ASSERT(req.cmd.cdw10_bits.identify.cns == SPDK_NVME_IDENTIFY_NS); CU_ASSERT(req.cmd.cdw10_bits.identify.cns == SPDK_NVME_IDENTIFY_NS);