Commit 460796a6 authored by Jim Harris's avatar Jim Harris
Browse files

test/bdevio: add another nvme passthrough test



This sends a known invalid opcode.  This is useful
for NVMe-oF target testing, since the target will
decode READ and WRITE opcodes and we want to exercise
its passthrough code path.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I82e16955f4965224e51c1617dbb2b9e5cc48f36d

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452932


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent a529ff94
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -919,6 +919,39 @@ blockdev_test_nvme_passthru_rw(void)
	}
}

static void
blockdev_nvme_passthru_vendor_specific(struct io_target *target)
{
	struct bdevio_passthrough_request pt_req;

	if (!spdk_bdev_io_type_supported(target->bdev, SPDK_BDEV_IO_TYPE_NVME_IO)) {
		return;
	}

	memset(&pt_req, 0, sizeof(pt_req));
	pt_req.target = target;
	pt_req.cmd.opc = 0x7F; /* choose known invalid opcode */
	pt_req.cmd.nsid = 1;

	pt_req.sct = SPDK_NVME_SCT_VENDOR_SPECIFIC;
	pt_req.sc = SPDK_NVME_SC_SUCCESS;
	execute_spdk_function(__blockdev_nvme_passthru, &pt_req, NULL);
	CU_ASSERT(pt_req.sct == SPDK_NVME_SCT_GENERIC);
	CU_ASSERT(pt_req.sc == SPDK_NVME_SC_INVALID_OPCODE);
}

static void
blockdev_test_nvme_passthru_vendor_specific(void)
{
	struct io_target	*target;

	target = g_io_targets;
	while (target != NULL) {
		blockdev_nvme_passthru_vendor_specific(target);
		target = target->next;
	}
}

static void
__stop_init_thread(void *arg1, void *arg2)
{
@@ -987,6 +1020,8 @@ __run_ut_thread(void *arg1, void *arg2)
			       blockdev_writev_readv_size_gt_128k_two_iov) == NULL
		|| CU_add_test(suite, "blockdev nvme passthru rw",
			       blockdev_test_nvme_passthru_rw) == NULL
		|| CU_add_test(suite, "blockdev nvme passthru vendor specific",
			       blockdev_test_nvme_passthru_vendor_specific) == NULL
		|| CU_add_test(suite, "blockdev reset",
			       blockdev_test_reset) == NULL
	) {