logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

vhost_types.h (5267B)


  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _LINUX_VHOST_TYPES_H
  3. #define _LINUX_VHOST_TYPES_H
  4. /* Userspace interface for in-kernel virtio accelerators. */
  5. /* vhost is used to reduce the number of system calls involved in virtio.
  6. *
  7. * Existing virtio net code is used in the guest without modification.
  8. *
  9. * This header includes interface used by userspace hypervisor for
  10. * device configuration.
  11. */
  12. #include <linux/types.h>
  13. #include <linux/virtio_config.h>
  14. #include <linux/virtio_ring.h>
  15. struct vhost_vring_state {
  16. unsigned int index;
  17. unsigned int num;
  18. };
  19. struct vhost_vring_file {
  20. unsigned int index;
  21. int fd; /* Pass -1 to unbind from file. */
  22. };
  23. struct vhost_vring_addr {
  24. unsigned int index;
  25. /* Option flags. */
  26. unsigned int flags;
  27. /* Flag values: */
  28. /* Whether log address is valid. If set enables logging. */
  29. #define VHOST_VRING_F_LOG 0
  30. /* Start of array of descriptors (virtually contiguous) */
  31. __u64 desc_user_addr;
  32. /* Used structure address. Must be 32 bit aligned */
  33. __u64 used_user_addr;
  34. /* Available structure address. Must be 16 bit aligned */
  35. __u64 avail_user_addr;
  36. /* Logging support. */
  37. /* Log writes to used structure, at offset calculated from specified
  38. * address. Address must be 32 bit aligned. */
  39. __u64 log_guest_addr;
  40. };
  41. struct vhost_worker_state {
  42. /*
  43. * For VHOST_NEW_WORKER the kernel will return the new vhost_worker id.
  44. * For VHOST_FREE_WORKER this must be set to the id of the vhost_worker
  45. * to free.
  46. */
  47. unsigned int worker_id;
  48. };
  49. struct vhost_vring_worker {
  50. /* vring index */
  51. unsigned int index;
  52. /* The id of the vhost_worker returned from VHOST_NEW_WORKER */
  53. unsigned int worker_id;
  54. };
  55. /* no alignment requirement */
  56. struct vhost_iotlb_msg {
  57. __u64 iova;
  58. __u64 size;
  59. __u64 uaddr;
  60. #define VHOST_ACCESS_RO 0x1
  61. #define VHOST_ACCESS_WO 0x2
  62. #define VHOST_ACCESS_RW 0x3
  63. __u8 perm;
  64. #define VHOST_IOTLB_MISS 1
  65. #define VHOST_IOTLB_UPDATE 2
  66. #define VHOST_IOTLB_INVALIDATE 3
  67. #define VHOST_IOTLB_ACCESS_FAIL 4
  68. /*
  69. * VHOST_IOTLB_BATCH_BEGIN and VHOST_IOTLB_BATCH_END allow modifying
  70. * multiple mappings in one go: beginning with
  71. * VHOST_IOTLB_BATCH_BEGIN, followed by any number of
  72. * VHOST_IOTLB_UPDATE messages, and ending with VHOST_IOTLB_BATCH_END.
  73. * When one of these two values is used as the message type, the rest
  74. * of the fields in the message are ignored. There's no guarantee that
  75. * these changes take place automatically in the device.
  76. */
  77. #define VHOST_IOTLB_BATCH_BEGIN 5
  78. #define VHOST_IOTLB_BATCH_END 6
  79. __u8 type;
  80. };
  81. #define VHOST_IOTLB_MSG 0x1
  82. #define VHOST_IOTLB_MSG_V2 0x2
  83. struct vhost_msg {
  84. int type;
  85. union {
  86. struct vhost_iotlb_msg iotlb;
  87. __u8 padding[64];
  88. };
  89. };
  90. struct vhost_msg_v2 {
  91. __u32 type;
  92. __u32 asid;
  93. union {
  94. struct vhost_iotlb_msg iotlb;
  95. __u8 padding[64];
  96. };
  97. };
  98. struct vhost_memory_region {
  99. __u64 guest_phys_addr;
  100. __u64 memory_size; /* bytes */
  101. __u64 userspace_addr;
  102. __u64 flags_padding; /* No flags are currently specified. */
  103. };
  104. /* All region addresses and sizes must be 4K aligned. */
  105. #define VHOST_PAGE_SIZE 0x1000
  106. struct vhost_memory {
  107. __u32 nregions;
  108. __u32 padding;
  109. struct vhost_memory_region regions[];
  110. };
  111. /* VHOST_SCSI specific definitions */
  112. /*
  113. * Used by QEMU userspace to ensure a consistent vhost-scsi ABI.
  114. *
  115. * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate +
  116. * RFC-v2 vhost-scsi userspace. Add GET_ABI_VERSION ioctl usage
  117. * ABI Rev 1: January 2013. Ignore vhost_tpgt field in struct vhost_scsi_target.
  118. * All the targets under vhost_wwpn can be seen and used by guset.
  119. */
  120. #define VHOST_SCSI_ABI_VERSION 1
  121. struct vhost_scsi_target {
  122. int abi_version;
  123. char vhost_wwpn[224]; /* TRANSPORT_IQN_LEN */
  124. unsigned short vhost_tpgt;
  125. unsigned short reserved;
  126. };
  127. /* VHOST_VDPA specific definitions */
  128. struct vhost_vdpa_config {
  129. __u32 off;
  130. __u32 len;
  131. __u8 buf[];
  132. };
  133. /* vhost vdpa IOVA range
  134. * @first: First address that can be mapped by vhost-vDPA
  135. * @last: Last address that can be mapped by vhost-vDPA
  136. */
  137. struct vhost_vdpa_iova_range {
  138. __u64 first;
  139. __u64 last;
  140. };
  141. /* Feature bits */
  142. /* Log all write descriptors. Can be changed while device is active. */
  143. #define VHOST_F_LOG_ALL 26
  144. /* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */
  145. #define VHOST_NET_F_VIRTIO_NET_HDR 27
  146. /* Use message type V2 */
  147. #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1
  148. /* IOTLB can accept batching hints */
  149. #define VHOST_BACKEND_F_IOTLB_BATCH 0x2
  150. /* IOTLB can accept address space identifier through V2 type of IOTLB
  151. * message
  152. */
  153. #define VHOST_BACKEND_F_IOTLB_ASID 0x3
  154. /* Device can be suspended */
  155. #define VHOST_BACKEND_F_SUSPEND 0x4
  156. /* Device can be resumed */
  157. #define VHOST_BACKEND_F_RESUME 0x5
  158. /* Device supports the driver enabling virtqueues both before and after
  159. * DRIVER_OK
  160. */
  161. #define VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK 0x6
  162. /* Device may expose the virtqueue's descriptor area, driver area and
  163. * device area to a different group for ASID binding than where its
  164. * buffers may reside. Requires VHOST_BACKEND_F_IOTLB_ASID.
  165. */
  166. #define VHOST_BACKEND_F_DESC_ASID 0x7
  167. /* IOTLB don't flush memory mapping across device reset */
  168. #define VHOST_BACKEND_F_IOTLB_PERSIST 0x8
  169. #endif