summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bhyve/virtio.h
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/bhyve/virtio.h')
-rw-r--r--usr.sbin/bhyve/virtio.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/usr.sbin/bhyve/virtio.h b/usr.sbin/bhyve/virtio.h
index 04ef586..fe6fb1a 100644
--- a/usr.sbin/bhyve/virtio.h
+++ b/usr.sbin/bhyve/virtio.h
@@ -85,4 +85,19 @@ struct virtio_used {
#define VTCFG_R_CFG1 24 /* With MSI-X */
#define VTCFG_R_MSIX 20
+/* From section 2.3, "Virtqueue Configuration", of the virtio specification */
+static inline u_int
+vring_size(u_int qsz)
+{
+ u_int size;
+
+ size = sizeof(struct virtio_desc) * qsz + sizeof(uint16_t) * (3 + qsz);
+ size = roundup2(size, VRING_ALIGN);
+
+ size += sizeof(uint16_t) * 3 + sizeof(struct virtio_used) * qsz;
+ size = roundup2(size, VRING_ALIGN);
+
+ return (size);
+}
+
#endif /* _VIRTIO_H_ */
OpenPOWER on IntegriCloud