nvme/pcie: add controller specific vtophys
Libvfio-user assumes the memory translation is IOVA=VA mode, since SPDK CI is running inside a VM, the memory mode is IOVA=PA mode, so when testing NVMe vfio-user transport inside a VM spdk_vtophys doesn't work with libvfio-user, so here we add a function to return memory address based on TRTYPE. Change-Id: I11d1c87197f7bbfc243b6bf368795c9a74bd1303 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5958 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: <dongx.yi@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
349895a25f
commit
1b0ec0b7c2
@ -40,6 +40,17 @@
|
||||
#include "nvme_internal.h"
|
||||
#include "nvme_pcie_internal.h"
|
||||
|
||||
static uint64_t
|
||||
nvme_pcie_vtophys(struct spdk_nvme_ctrlr *ctrlr, const void *buf)
|
||||
{
|
||||
if (spdk_likely(ctrlr->trid.trtype == SPDK_NVME_TRANSPORT_PCIE)) {
|
||||
return spdk_vtophys(buf, NULL);
|
||||
} else {
|
||||
/* vfio-user address translation with IOVA=VA mode */
|
||||
return (uint64_t)(uintptr_t)buf;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
nvme_pcie_qpair_reset(struct spdk_nvme_qpair *qpair)
|
||||
{
|
||||
@ -173,7 +184,7 @@ nvme_pcie_qpair_construct(struct spdk_nvme_qpair *qpair,
|
||||
assert(pqpair->sq_vaddr != NULL);
|
||||
pqpair->cmd_bus_addr = sq_paddr;
|
||||
} else {
|
||||
pqpair->cmd_bus_addr = spdk_vtophys(pqpair->cmd, NULL);
|
||||
pqpair->cmd_bus_addr = nvme_pcie_vtophys(ctrlr, pqpair->cmd);
|
||||
if (pqpair->cmd_bus_addr == SPDK_VTOPHYS_ERROR) {
|
||||
SPDK_ERRLOG("spdk_vtophys(pqpair->cmd) failed\n");
|
||||
return -EFAULT;
|
||||
@ -196,7 +207,7 @@ nvme_pcie_qpair_construct(struct spdk_nvme_qpair *qpair,
|
||||
assert(pqpair->cq_vaddr != NULL);
|
||||
pqpair->cpl_bus_addr = cq_paddr;
|
||||
} else {
|
||||
pqpair->cpl_bus_addr = spdk_vtophys(pqpair->cpl, NULL);
|
||||
pqpair->cpl_bus_addr = nvme_pcie_vtophys(ctrlr, pqpair->cpl);
|
||||
if (pqpair->cpl_bus_addr == SPDK_VTOPHYS_ERROR) {
|
||||
SPDK_ERRLOG("spdk_vtophys(pqpair->cpl) failed\n");
|
||||
return -EFAULT;
|
||||
@ -224,7 +235,7 @@ nvme_pcie_qpair_construct(struct spdk_nvme_qpair *qpair,
|
||||
|
||||
for (i = 0; i < num_trackers; i++) {
|
||||
tr = &pqpair->tr[i];
|
||||
nvme_qpair_construct_tracker(tr, i, spdk_vtophys(tr, NULL));
|
||||
nvme_qpair_construct_tracker(tr, i, nvme_pcie_vtophys(ctrlr, tr));
|
||||
TAILQ_INSERT_HEAD(&pqpair->free_tr, tr, tq_list);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user