Commit 1e2d5e50 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

nvmf: Add LBAFEE to Host Behavior Support features



Signed-off-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I910476470b6106b2b9935f208df0292b80f09b87
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24111


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
parent 1521bf3b
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1950,6 +1950,7 @@ nvmf_ctrlr_get_features_host_behavior_support(struct spdk_nvmf_request *req)
	}

	host_behavior.acre = ctrlr->acre_enabled;
	host_behavior.lbafee = ctrlr->lbafee_enabled;

	spdk_iov_xfer_init(&ix, req->iov, req->iovcnt);
	spdk_iov_xfer_from_buf(&ix, &host_behavior, sizeof(host_behavior));
@@ -1989,6 +1990,16 @@ nvmf_ctrlr_set_features_host_behavior_support(struct spdk_nvmf_request *req)
		response->status.sc = SPDK_NVME_SC_INVALID_FIELD;
		return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
	}
	if (host_behavior->lbafee == 0) {
		ctrlr->lbafee_enabled = false;
	} else if (host_behavior->lbafee == 1) {
		ctrlr->lbafee_enabled = true;
	} else {
		SPDK_ERRLOG("Host Behavior Support invalid acre: 0x%02x\n", host_behavior->lbafee);
		response->status.sct = SPDK_NVME_SCT_GENERIC;
		response->status.sc = SPDK_NVME_SC_INVALID_FIELD;
		return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
	}
	return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}

+2 −0
Original line number Diff line number Diff line
@@ -256,6 +256,8 @@ struct spdk_nvmf_ctrlr {
	bool				disconnect_is_shn;
	bool				acre_enabled;
	bool				dynamic_ctrlr;
	/* LBA Format Extension Enabled (LBAFEE) */
	bool				lbafee_enabled;

	TAILQ_ENTRY(spdk_nvmf_ctrlr)	link;
};
+20 −2
Original line number Diff line number Diff line
@@ -3111,11 +3111,14 @@ test_nvmf_ctrlr_get_features_host_behavior_support(void)
	SPDK_IOV_ONE(req.iov, &req.iovcnt, &behavior, req.length);

	ctrlr.acre_enabled = true;
	ctrlr.lbafee_enabled = true;
	behavior.acre = false;
	behavior.lbafee = false;

	rc = nvmf_ctrlr_get_features_host_behavior_support(&req);
	CU_ASSERT(rc == SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE);
	CU_ASSERT(behavior.acre == true);
	CU_ASSERT(behavior.lbafee == true);
}

static void
@@ -3159,8 +3162,9 @@ test_nvmf_ctrlr_set_features_host_behavior_support(void)
	CU_ASSERT(req.rsp->nvme_cpl.status.sct == SPDK_NVME_SCT_GENERIC);
	CU_ASSERT(req.rsp->nvme_cpl.status.sc == SPDK_NVME_SC_INVALID_FIELD);

	/* acre is false */
	/* acre is false but lbafee is true */
	host_behavior.acre = 0;
	host_behavior.lbafee = 1;
	req.iov[0].iov_len = sizeof(struct spdk_nvme_host_behavior);
	rc = SPDK_NVMF_REQUEST_EXEC_STATUS_ASYNCHRONOUS;
	req.rsp->nvme_cpl.status.sct = SPDK_NVME_SCT_GENERIC;
@@ -3171,9 +3175,11 @@ test_nvmf_ctrlr_set_features_host_behavior_support(void)
	CU_ASSERT(req.rsp->nvme_cpl.status.sct == SPDK_NVME_SCT_GENERIC);
	CU_ASSERT(req.rsp->nvme_cpl.status.sc == SPDK_NVME_SC_SUCCESS);
	CU_ASSERT(ctrlr.acre_enabled == false);
	CU_ASSERT(ctrlr.lbafee_enabled == true);

	/* acre is true */
	/* acre is true but lbafee is false */
	host_behavior.acre = 1;
	host_behavior.lbafee = 0;
	req.iov[0].iov_len = sizeof(struct spdk_nvme_host_behavior);
	rc = SPDK_NVMF_REQUEST_EXEC_STATUS_ASYNCHRONOUS;
	req.rsp->nvme_cpl.status.sct = SPDK_NVME_SCT_GENERIC;
@@ -3184,6 +3190,7 @@ test_nvmf_ctrlr_set_features_host_behavior_support(void)
	CU_ASSERT(req.rsp->nvme_cpl.status.sct == SPDK_NVME_SCT_GENERIC);
	CU_ASSERT(req.rsp->nvme_cpl.status.sc == SPDK_NVME_SC_SUCCESS);
	CU_ASSERT(ctrlr.acre_enabled == true);
	CU_ASSERT(ctrlr.lbafee_enabled == false);

	/* Invalid acre */
	host_behavior.acre = 2;
@@ -3195,6 +3202,17 @@ test_nvmf_ctrlr_set_features_host_behavior_support(void)
	CU_ASSERT(rc == SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE);
	CU_ASSERT(req.rsp->nvme_cpl.status.sct == SPDK_NVME_SCT_GENERIC);
	CU_ASSERT(req.rsp->nvme_cpl.status.sc == SPDK_NVME_SC_INVALID_FIELD);

	/* Invalid lbafee */
	host_behavior.lbafee = 3;
	rc = SPDK_NVMF_REQUEST_EXEC_STATUS_ASYNCHRONOUS;
	req.rsp->nvme_cpl.status.sct = SPDK_NVME_SCT_GENERIC;
	req.rsp->nvme_cpl.status.sc = SPDK_NVME_SC_SUCCESS;

	rc = nvmf_ctrlr_set_features_host_behavior_support(&req);
	CU_ASSERT(rc == SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE);
	CU_ASSERT(req.rsp->nvme_cpl.status.sct == SPDK_NVME_SCT_GENERIC);
	CU_ASSERT(req.rsp->nvme_cpl.status.sc == SPDK_NVME_SC_INVALID_FIELD);
}

static void