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: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
e1c602bdc3
commit
af058fd758
@ -68,6 +68,7 @@ static int io_complete_flag = 0;
|
|||||||
|
|
||||||
struct sgl_element {
|
struct sgl_element {
|
||||||
void *base;
|
void *base;
|
||||||
|
uint64_t phys_addr;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
size_t len;
|
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];
|
iov = &req->iovs[req->current_iov_index];
|
||||||
|
|
||||||
if (req->current_iov_bytes_left) {
|
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;
|
*length = req->current_iov_bytes_left;
|
||||||
req->current_iov_bytes_left = 0;
|
req->current_iov_bytes_left = 0;
|
||||||
} else {
|
} else {
|
||||||
*address = rte_malloc_virt2phy(iov->base) + iov->offset;
|
*address = iov->phys_addr;
|
||||||
*length = iov->len;
|
*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;
|
len = 0;
|
||||||
for (i = 0; i < req->nseg; i++) {
|
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);
|
lba_count = len / spdk_nvme_ns_get_sector_size(ns);
|
||||||
|
Loading…
Reference in New Issue
Block a user