Commit af058fd7 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

test/nvme/sgl: calculate physical address earlier



The next_sge callback can be called multiple times for a single I/O if
the I/O is split.  Get the physical address for each element once
instead of every time the SGL is walked.

Also bake the SGL element offset into the physical address.

Change-Id: I5d83426a234ffe9d13b89621077dbbb1561181c9
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent e1c602bd
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ static int io_complete_flag = 0;

struct sgl_element {
	void *base;
	uint64_t phys_addr;
	size_t offset;
	size_t len;
};
@@ -111,11 +112,11 @@ static int nvme_request_next_sge(void *cb_arg, uint64_t *address, uint32_t *leng
	iov = &req->iovs[req->current_iov_index];

	if (req->current_iov_bytes_left) {
		*address = rte_malloc_virt2phy(iov->base) + iov->offset + iov->len - req->current_iov_bytes_left;
		*address = iov->phys_addr + iov->len - req->current_iov_bytes_left;
		*length = req->current_iov_bytes_left;
		req->current_iov_bytes_left = 0;
	} else {
		*address = rte_malloc_virt2phy(iov->base) + iov->offset;
		*address = iov->phys_addr;
		*length = iov->len;
	}

@@ -254,7 +255,10 @@ writev_readv_tests(struct dev *dev, nvme_build_io_req_fn_t build_io_fn, const ch

	len = 0;
	for (i = 0; i < req->nseg; i++) {
		len += req->iovs[i].len;
		struct sgl_element *sge = &req->iovs[i];

		sge->phys_addr = rte_malloc_virt2phy(sge->base) + sge->offset;
		len += sge->len;
	}

	lba_count = len / spdk_nvme_ns_get_sector_size(ns);