summaryrefslogtreecommitdiff
path: root/include/linux/vringh.h
diff options
context:
space:
mode:
authorStefano Garzarella <sgarzare@redhat.com>2021-03-15 19:34:42 +0300
committerMichael S. Tsirkin <mst@redhat.com>2021-05-03 11:55:53 +0300
commit14c9ac05ce09c8c6a89ffcca6ffb68707cba36c2 (patch)
tree0f644ed5a53a370b95610705db52e8d1cd9cf293 /include/linux/vringh.h
parentb8c06ad4d67db56ed6bdfb685c134da74e92a2c7 (diff)
downloadlinux-14c9ac05ce09c8c6a89ffcca6ffb68707cba36c2.tar.xz
vringh: add vringh_kiov_length() helper
This new helper returns the total number of bytes covered by a vringh_kiov. Suggested-by: Jason Wang <jasowang@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Link: https://lore.kernel.org/r/20210315163450.254396-7-sgarzare@redhat.com Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'include/linux/vringh.h')
-rw-r--r--include/linux/vringh.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/vringh.h b/include/linux/vringh.h
index 755211ebd195..84db7b8f912f 100644
--- a/include/linux/vringh.h
+++ b/include/linux/vringh.h
@@ -199,6 +199,17 @@ static inline void vringh_kiov_cleanup(struct vringh_kiov *kiov)
kiov->iov = NULL;
}
+static inline size_t vringh_kiov_length(struct vringh_kiov *kiov)
+{
+ size_t len = 0;
+ int i;
+
+ for (i = kiov->i; i < kiov->used; i++)
+ len += kiov->iov[i].iov_len;
+
+ return len;
+}
+
void vringh_kiov_advance(struct vringh_kiov *kiov, size_t len);
int vringh_getdesc_kern(struct vringh *vrh,