nvmf/vfio-user: use a better input parameter for vfio_user_map_prps
This will make the code easier to understand. Change-Id: I7112d3fd5f0d6dce9b66d44375b68ce7d1e8951d Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7072 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
e7f3142ca2
commit
8c4ac1f2ff
@ -522,14 +522,16 @@ acq_map(struct nvmf_vfio_user_ctrlr *ctrlr)
|
|||||||
static void *
|
static void *
|
||||||
_map_one(void *prv, uint64_t addr, uint64_t len)
|
_map_one(void *prv, uint64_t addr, uint64_t len)
|
||||||
{
|
{
|
||||||
|
struct spdk_nvmf_request *req = (struct spdk_nvmf_request *)prv;
|
||||||
|
struct spdk_nvmf_qpair *qpair;
|
||||||
struct nvmf_vfio_user_req *vu_req;
|
struct nvmf_vfio_user_req *vu_req;
|
||||||
struct nvmf_vfio_user_qpair *vu_qpair;
|
struct nvmf_vfio_user_qpair *vu_qpair;
|
||||||
void *ret;
|
void *ret;
|
||||||
|
|
||||||
assert(prv != NULL);
|
assert(req != NULL);
|
||||||
|
qpair = req->qpair;
|
||||||
vu_req = SPDK_CONTAINEROF(prv, struct nvmf_vfio_user_req, cmd);
|
vu_req = SPDK_CONTAINEROF(req, struct nvmf_vfio_user_req, req);
|
||||||
vu_qpair = SPDK_CONTAINEROF(vu_req->req.qpair, struct nvmf_vfio_user_qpair, qpair);
|
vu_qpair = SPDK_CONTAINEROF(qpair, struct nvmf_vfio_user_qpair, qpair);
|
||||||
|
|
||||||
assert(vu_req->iovcnt < NVMF_VFIO_USER_MAX_IOVECS);
|
assert(vu_req->iovcnt < NVMF_VFIO_USER_MAX_IOVECS);
|
||||||
ret = map_one(vu_qpair->ctrlr->endpoint->vfu_ctx, addr, len,
|
ret = map_one(vu_qpair->ctrlr->endpoint->vfu_ctx, addr, len,
|
||||||
@ -542,13 +544,13 @@ _map_one(void *prv, uint64_t addr, uint64_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vfio_user_map_prps(struct nvmf_vfio_user_ctrlr *ctrlr, struct spdk_nvme_cmd *cmd,
|
vfio_user_map_prps(struct nvmf_vfio_user_ctrlr *ctrlr, struct spdk_nvmf_request *req,
|
||||||
struct iovec *iov, uint32_t length)
|
struct iovec *iov, uint32_t length)
|
||||||
{
|
{
|
||||||
/* Map PRP list to from Guest physical memory to
|
/* Map PRP list to from Guest physical memory to
|
||||||
* virtual memory address.
|
* virtual memory address.
|
||||||
*/
|
*/
|
||||||
return spdk_nvme_map_prps(cmd, cmd, iov, length,
|
return spdk_nvme_map_prps(req, &req->cmd->nvme_cmd, iov, length,
|
||||||
4096, _map_one);
|
4096, _map_one);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2072,7 +2074,7 @@ map_admin_cmd_req(struct nvmf_vfio_user_ctrlr *ctrlr, struct spdk_nvmf_request *
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
iovcnt = vfio_user_map_prps(ctrlr, cmd, req->iov, len);
|
iovcnt = vfio_user_map_prps(ctrlr, req, req->iov, len);
|
||||||
if (iovcnt < 0) {
|
if (iovcnt < 0) {
|
||||||
SPDK_ERRLOG("%s: map Admin Opc %x failed\n",
|
SPDK_ERRLOG("%s: map Admin Opc %x failed\n",
|
||||||
ctrlr_id(ctrlr), cmd->opc);
|
ctrlr_id(ctrlr), cmd->opc);
|
||||||
@ -2115,8 +2117,7 @@ map_io_cmd_req(struct nvmf_vfio_user_ctrlr *ctrlr, struct spdk_nvmf_request *req
|
|||||||
}
|
}
|
||||||
|
|
||||||
req->length = err;
|
req->length = err;
|
||||||
err = vfio_user_map_prps(ctrlr, &req->cmd->nvme_cmd, req->iov,
|
err = vfio_user_map_prps(ctrlr, req, req->iov, req->length);
|
||||||
req->length);
|
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
SPDK_ERRLOG("%s: failed to map PRP: %d\n", ctrlr_id(ctrlr), err);
|
SPDK_ERRLOG("%s: failed to map PRP: %d\n", ctrlr_id(ctrlr), err);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
Loading…
Reference in New Issue
Block a user