peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame qemu-kvm-add-vhost.h-header.patch

Justin M. Forbes 272dfe
This makes it possible to build vhost support
Justin M. Forbes 272dfe
on systems which do not have this header.
Justin M. Forbes 272dfe
Justin M. Forbes 272dfe
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Justin M. Forbes 272dfe
---
Justin M. Forbes 272dfe
 kvm/include/linux/vhost.h |  130 +++++++++++++++++++++++++++++++++++++++++++++
Justin M. Forbes 272dfe
 1 files changed, 130 insertions(+), 0 deletions(-)
Justin M. Forbes 272dfe
 create mode 100644 kvm/include/linux/vhost.h
Justin M. Forbes 272dfe
Justin M. Forbes 272dfe
diff --git a/kvm/include/linux/vhost.h b/kvm/include/linux/vhost.h
Justin M. Forbes 272dfe
new file mode 100644
Justin M. Forbes 272dfe
index 0000000..165a484
Justin M. Forbes 272dfe
--- /dev/null
Justin M. Forbes 272dfe
+++ b/kvm/include/linux/vhost.h
Justin M. Forbes 272dfe
@@ -0,0 +1,130 @@
Justin M. Forbes 272dfe
+#ifndef _LINUX_VHOST_H
Justin M. Forbes 272dfe
+#define _LINUX_VHOST_H
Justin M. Forbes 272dfe
+/* Userspace interface for in-kernel virtio accelerators. */
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+/* vhost is used to reduce the number of system calls involved in virtio.
Justin M. Forbes 272dfe
+ *
Justin M. Forbes 272dfe
+ * Existing virtio net code is used in the guest without modification.
Justin M. Forbes 272dfe
+ *
Justin M. Forbes 272dfe
+ * This header includes interface used by userspace hypervisor for
Justin M. Forbes 272dfe
+ * device configuration.
Justin M. Forbes 272dfe
+ */
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+#include <linux/types.h>
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+#include <linux/ioctl.h>
Justin M. Forbes 272dfe
+#include <linux/virtio_config.h>
Justin M. Forbes 272dfe
+#include <linux/virtio_ring.h>
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+struct vhost_vring_state {
Justin M. Forbes 272dfe
+	unsigned int index;
Justin M. Forbes 272dfe
+	unsigned int num;
Justin M. Forbes 272dfe
+};
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+struct vhost_vring_file {
Justin M. Forbes 272dfe
+	unsigned int index;
Justin M. Forbes 272dfe
+	int fd; /* Pass -1 to unbind from file. */
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+};
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+struct vhost_vring_addr {
Justin M. Forbes 272dfe
+	unsigned int index;
Justin M. Forbes 272dfe
+	/* Option flags. */
Justin M. Forbes 272dfe
+	unsigned int flags;
Justin M. Forbes 272dfe
+	/* Flag values: */
Justin M. Forbes 272dfe
+	/* Whether log address is valid. If set enables logging. */
Justin M. Forbes 272dfe
+#define VHOST_VRING_F_LOG 0
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+	/* Start of array of descriptors (virtually contiguous) */
Justin M. Forbes 272dfe
+	__u64 desc_user_addr;
Justin M. Forbes 272dfe
+	/* Used structure address. Must be 32 bit aligned */
Justin M. Forbes 272dfe
+	__u64 used_user_addr;
Justin M. Forbes 272dfe
+	/* Available structure address. Must be 16 bit aligned */
Justin M. Forbes 272dfe
+	__u64 avail_user_addr;
Justin M. Forbes 272dfe
+	/* Logging support. */
Justin M. Forbes 272dfe
+	/* Log writes to used structure, at offset calculated from specified
Justin M. Forbes 272dfe
+	 * address. Address must be 32 bit aligned. */
Justin M. Forbes 272dfe
+	__u64 log_guest_addr;
Justin M. Forbes 272dfe
+};
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+struct vhost_memory_region {
Justin M. Forbes 272dfe
+	__u64 guest_phys_addr;
Justin M. Forbes 272dfe
+	__u64 memory_size; /* bytes */
Justin M. Forbes 272dfe
+	__u64 userspace_addr;
Justin M. Forbes 272dfe
+	__u64 flags_padding; /* No flags are currently specified. */
Justin M. Forbes 272dfe
+};
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+/* All region addresses and sizes must be 4K aligned. */
Justin M. Forbes 272dfe
+#define VHOST_PAGE_SIZE 0x1000
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+struct vhost_memory {
Justin M. Forbes 272dfe
+	__u32 nregions;
Justin M. Forbes 272dfe
+	__u32 padding;
Justin M. Forbes 272dfe
+	struct vhost_memory_region regions[0];
Justin M. Forbes 272dfe
+};
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+/* ioctls */
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+#define VHOST_VIRTIO 0xAF
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+/* Features bitmask for forward compatibility.  Transport bits are used for
Justin M. Forbes 272dfe
+ * vhost specific features. */
Justin M. Forbes 272dfe
+#define VHOST_GET_FEATURES	_IOR(VHOST_VIRTIO, 0x00, __u64)
Justin M. Forbes 272dfe
+#define VHOST_SET_FEATURES	_IOW(VHOST_VIRTIO, 0x00, __u64)
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+/* Set current process as the (exclusive) owner of this file descriptor.  This
Justin M. Forbes 272dfe
+ * must be called before any other vhost command.  Further calls to
Justin M. Forbes 272dfe
+ * VHOST_OWNER_SET fail until VHOST_OWNER_RESET is called. */
Justin M. Forbes 272dfe
+#define VHOST_SET_OWNER _IO(VHOST_VIRTIO, 0x01)
Justin M. Forbes 272dfe
+/* Give up ownership, and reset the device to default values.
Justin M. Forbes 272dfe
+ * Allows subsequent call to VHOST_OWNER_SET to succeed. */
Justin M. Forbes 272dfe
+#define VHOST_RESET_OWNER _IO(VHOST_VIRTIO, 0x02)
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+/* Set up/modify memory layout */
Justin M. Forbes 272dfe
+#define VHOST_SET_MEM_TABLE	_IOW(VHOST_VIRTIO, 0x03, struct vhost_memory)
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+/* Write logging setup. */
Justin M. Forbes 272dfe
+/* Memory writes can optionally be logged by setting bit at an offset
Justin M. Forbes 272dfe
+ * (calculated from the physical address) from specified log base.
Justin M. Forbes 272dfe
+ * The bit is set using an atomic 32 bit operation. */
Justin M. Forbes 272dfe
+/* Set base address for logging. */
Justin M. Forbes 272dfe
+#define VHOST_SET_LOG_BASE _IOW(VHOST_VIRTIO, 0x04, __u64)
Justin M. Forbes 272dfe
+/* Specify an eventfd file descriptor to signal on log write. */
Justin M. Forbes 272dfe
+#define VHOST_SET_LOG_FD _IOW(VHOST_VIRTIO, 0x07, int)
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+/* Ring setup. */
Justin M. Forbes 272dfe
+/* Set number of descriptors in ring. This parameter can not
Justin M. Forbes 272dfe
+ * be modified while ring is running (bound to a device). */
Justin M. Forbes 272dfe
+#define VHOST_SET_VRING_NUM _IOW(VHOST_VIRTIO, 0x10, struct vhost_vring_state)
Justin M. Forbes 272dfe
+/* Set addresses for the ring. */
Justin M. Forbes 272dfe
+#define VHOST_SET_VRING_ADDR _IOW(VHOST_VIRTIO, 0x11, struct vhost_vring_addr)
Justin M. Forbes 272dfe
+/* Base value where queue looks for available descriptors */
Justin M. Forbes 272dfe
+#define VHOST_SET_VRING_BASE _IOW(VHOST_VIRTIO, 0x12, struct vhost_vring_state)
Justin M. Forbes 272dfe
+/* Get accessor: reads index, writes value in num */
Justin M. Forbes 272dfe
+#define VHOST_GET_VRING_BASE _IOWR(VHOST_VIRTIO, 0x12, struct vhost_vring_state)
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+/* The following ioctls use eventfd file descriptors to signal and poll
Justin M. Forbes 272dfe
+ * for events. */
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+/* Set eventfd to poll for added buffers */
Justin M. Forbes 272dfe
+#define VHOST_SET_VRING_KICK _IOW(VHOST_VIRTIO, 0x20, struct vhost_vring_file)
Justin M. Forbes 272dfe
+/* Set eventfd to signal when buffers have beed used */
Justin M. Forbes 272dfe
+#define VHOST_SET_VRING_CALL _IOW(VHOST_VIRTIO, 0x21, struct vhost_vring_file)
Justin M. Forbes 272dfe
+/* Set eventfd to signal an error */
Justin M. Forbes 272dfe
+#define VHOST_SET_VRING_ERR _IOW(VHOST_VIRTIO, 0x22, struct vhost_vring_file)
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+/* VHOST_NET specific defines */
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+/* Attach virtio net ring to a raw socket, or tap device.
Justin M. Forbes 272dfe
+ * The socket must be already bound to an ethernet device, this device will be
Justin M. Forbes 272dfe
+ * used for transmit.  Pass fd -1 to unbind from the socket and the transmit
Justin M. Forbes 272dfe
+ * device.  This can be used to stop the ring (e.g. for migration). */
Justin M. Forbes 272dfe
+#define VHOST_NET_SET_BACKEND _IOW(VHOST_VIRTIO, 0x30, struct vhost_vring_file)
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+/* Feature bits */
Justin M. Forbes 272dfe
+/* Log all write descriptors. Can be changed while device is active. */
Justin M. Forbes 272dfe
+#define VHOST_F_LOG_ALL 26
Justin M. Forbes 272dfe
+/* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */
Justin M. Forbes 272dfe
+#define VHOST_NET_F_VIRTIO_NET_HDR 27
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+#endif
Justin M. Forbes 272dfe
-- 
Justin M. Forbes 272dfe
1.6.6.144.g5c3af