vhost: introduce spdk_vhost_vring_desc_to_iov

Extract vring_dev to iovec translation logic to common place.


Change-Id: I0c6fc5582dfe341e867ce6749ff29d14a9d12d94
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/363582
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Pawel Wodkowski 2017-06-02 19:48:11 +02:00 committed by Ben Walker
parent 1b93872dbb
commit 8f371c7d64
3 changed files with 14 additions and 4 deletions

View File

@ -150,6 +150,15 @@ spdk_vhost_vring_desc_is_wr(struct vring_desc *cur_desc)
return !!(cur_desc->flags & VRING_DESC_F_WRITE);
}
bool
spdk_vhost_vring_desc_to_iov(struct spdk_vhost_dev *vdev, struct iovec *iov,
const struct vring_desc *desc)
{
iov->iov_base = spdk_vhost_gpa_to_vva(vdev, desc->addr);
iov->iov_len = desc->len;
return !iov->iov_base;
}
struct spdk_vhost_dev *
spdk_vhost_dev_find_by_vid(int vid)
{

View File

@ -100,6 +100,9 @@ struct vring_desc *spdk_vhost_vring_desc_get_next(struct vring_desc *vq_desc,
struct vring_desc *cur_desc);
bool spdk_vhost_vring_desc_is_wr(struct vring_desc *cur_desc);
bool spdk_vhost_vring_desc_to_iov(struct spdk_vhost_dev *vdev, struct iovec *iov,
const struct vring_desc *desc);
struct spdk_vhost_dev *spdk_vhost_dev_find_by_vid(int vid);
int spdk_vhost_dev_construct(struct spdk_vhost_dev *vdev, const char *name, uint64_t cpumask,

View File

@ -358,8 +358,7 @@ task_data_setup(struct spdk_vhost_task *task,
/* All remaining descriptors are data. */
while (iovcnt < iovcnt_max) {
iovs[iovcnt].iov_base = spdk_vhost_gpa_to_vva(vdev, desc->addr);
iovs[iovcnt].iov_len = desc->len;
spdk_vhost_vring_desc_to_iov(vdev, &iovs[iovcnt], desc);
len += desc->len;
iovcnt++;
@ -395,8 +394,7 @@ task_data_setup(struct spdk_vhost_task *task,
/* Process descriptors up to response. */
while (!spdk_vhost_vring_desc_is_wr(desc) && iovcnt < iovcnt_max) {
iovs[iovcnt].iov_base = spdk_vhost_gpa_to_vva(vdev, desc->addr);
iovs[iovcnt].iov_len = desc->len;
spdk_vhost_vring_desc_to_iov(vdev, &iovs[iovcnt], desc);
len += desc->len;
iovcnt++;