From a8bdd24bc2b882fd593a7ab012ecbb0ae04790be Mon Sep 17 00:00:00 2001 From: Jin Yu Date: Tue, 25 Feb 2020 18:54:11 +0800 Subject: [PATCH] vhost: split desc_to_iovs function Use the payload to construct iovs so that split desc or packed desc can both work. Change-Id: Ib2c60b6eb53d0d615594e97b3d3ae1a365908b6c Signed-off-by: Jin Yu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1000 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Changpeng Liu Reviewed-by: Ben Walker Reviewed-by: Darek Stojaczyk --- lib/vhost/vhost.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index f55bc0538..89f6c4504 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -468,14 +468,12 @@ vhost_vring_desc_is_wr(struct vring_desc *cur_desc) return !!(cur_desc->flags & VRING_DESC_F_WRITE); } -int -vhost_vring_desc_to_iov(struct spdk_vhost_session *vsession, struct iovec *iov, - uint16_t *iov_index, const struct vring_desc *desc) +static int +vhost_vring_desc_payload_to_iov(struct spdk_vhost_session *vsession, struct iovec *iov, + uint16_t *iov_index, uintptr_t payload, uint64_t remaining) { - uint64_t len; - uint64_t remaining = desc->len; - uintptr_t payload = desc->addr; uintptr_t vva; + uint64_t len; do { if (*iov_index >= SPDK_VHOST_IOVS_MAX) { @@ -498,6 +496,14 @@ vhost_vring_desc_to_iov(struct spdk_vhost_session *vsession, struct iovec *iov, return 0; } +int +vhost_vring_desc_to_iov(struct spdk_vhost_session *vsession, struct iovec *iov, + uint16_t *iov_index, const struct vring_desc *desc) +{ + return vhost_vring_desc_payload_to_iov(vsession, iov, iov_index, + desc->addr, desc->len); +} + static struct spdk_vhost_session * vhost_session_find_by_id(struct spdk_vhost_dev *vdev, unsigned id) {