Commit 8f3d0a64 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Jim Harris
Browse files

hello_world: If supported, use CMB WDS buffer



If the NVMe controller to be tested supports a CMB with the WDS
feature then we use that for the write phase of hello_world.

Change-Id: Ide6ee1005a892ca977bd32a974cd644256e95c8a
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Signed-off-by: default avatarStephen Bates <sbates@raithlin.com>
Reviewed-on: https://review.gerrithub.io/397039


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent 38396397
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ register_ns(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns *ns)
struct hello_world_sequence {
	struct ns_entry	*ns_entry;
	char		*buf;
	unsigned        using_cmb_io;
	int		is_completed;
};

@@ -124,7 +125,11 @@ write_complete(void *arg, const struct spdk_nvme_cpl *completion)
	 *  the write I/O and allocate a new zeroed buffer for reading
	 *  the data back from the NVMe namespace.
	 */
	if (sequence->using_cmb_io) {
		spdk_nvme_ctrlr_free_cmb_io_buffer(ns_entry->ctrlr, sequence->buf, 0x1000);
	} else {
		spdk_dma_free(sequence->buf);
	}
	sequence->buf = spdk_dma_zmalloc(0x1000, 0x1000, NULL);

	rc = spdk_nvme_ns_cmd_read(ns_entry->ns, ns_entry->qpair, sequence->buf,
@@ -169,7 +174,21 @@ hello_world(void)
		 * will be pinned, which is required for data buffers used for SPDK NVMe
		 * I/O operations.
		 */
		sequence.using_cmb_io = 1;
		sequence.buf = spdk_nvme_ctrlr_alloc_cmb_io_buffer(ns_entry->ctrlr, 0x1000);
		if (sequence.buf == NULL) {
			sequence.using_cmb_io = 0;
			sequence.buf = spdk_dma_zmalloc(0x1000, 0x1000, NULL);
		}
		if (sequence.buf == NULL) {
			printf("ERROR: write buffer allocation failed\n");
			return;
		}
		if (sequence.using_cmb_io) {
			printf("INFO: using controller memory buffer for IO\n");
		} else {
			printf("INFO: using host memory buffer for IO\n");
		}
		sequence.is_completed = 0;
		sequence.ns_entry = ns_entry;