virtio_sys/
vhost.rs

1/* automatically generated by tools/bindgen-all-the-things */
2
3#![allow(clippy::missing_safety_doc)]
4#![allow(clippy::undocumented_unsafe_blocks)]
5#![allow(clippy::upper_case_acronyms)]
6#![allow(non_upper_case_globals)]
7#![allow(non_camel_case_types)]
8#![allow(non_snake_case)]
9#![allow(dead_code)]
10
11#[repr(C)]
12#[derive(Default)]
13pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
14impl<T> __IncompleteArrayField<T> {
15    #[inline]
16    pub const fn new() -> Self {
17        __IncompleteArrayField(::std::marker::PhantomData, [])
18    }
19    #[inline]
20    pub fn as_ptr(&self) -> *const T {
21        self as *const _ as *const T
22    }
23    #[inline]
24    pub fn as_mut_ptr(&mut self) -> *mut T {
25        self as *mut _ as *mut T
26    }
27    #[inline]
28    pub unsafe fn as_slice(&self, len: usize) -> &[T] {
29        ::std::slice::from_raw_parts(self.as_ptr(), len)
30    }
31    #[inline]
32    pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
33        ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
34    }
35}
36impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
37    fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
38        fmt.write_str("__IncompleteArrayField")
39    }
40}
41pub const VHOST_VRING_F_LOG: u32 = 0;
42pub const VHOST_ACCESS_RO: u32 = 1;
43pub const VHOST_ACCESS_WO: u32 = 2;
44pub const VHOST_ACCESS_RW: u32 = 3;
45pub const VHOST_IOTLB_MISS: u32 = 1;
46pub const VHOST_IOTLB_UPDATE: u32 = 2;
47pub const VHOST_IOTLB_INVALIDATE: u32 = 3;
48pub const VHOST_IOTLB_ACCESS_FAIL: u32 = 4;
49pub const VHOST_IOTLB_BATCH_BEGIN: u32 = 5;
50pub const VHOST_IOTLB_BATCH_END: u32 = 6;
51pub const VHOST_IOTLB_MSG: u32 = 1;
52pub const VHOST_IOTLB_MSG_V2: u32 = 2;
53pub const VHOST_PAGE_SIZE: u32 = 4096;
54pub const VHOST_SCSI_ABI_VERSION: u32 = 1;
55pub const VHOST_F_LOG_ALL: u32 = 26;
56pub const VHOST_NET_F_VIRTIO_NET_HDR: u32 = 27;
57pub const VHOST_BACKEND_F_IOTLB_MSG_V2: u32 = 1;
58pub const VHOST_BACKEND_F_IOTLB_BATCH: u32 = 2;
59pub const VHOST_BACKEND_F_IOTLB_ASID: u32 = 3;
60pub const VHOST_BACKEND_F_SUSPEND: u32 = 4;
61pub const VHOST_BACKEND_F_RESUME: u32 = 5;
62pub const VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK: u32 = 6;
63pub const VHOST_BACKEND_F_DESC_ASID: u32 = 7;
64pub const VHOST_BACKEND_F_IOTLB_PERSIST: u32 = 8;
65pub const VHOST_FILE_UNBIND: i32 = -1;
66pub const VHOST_VIRTIO: u32 = 175;
67pub const VHOST_VRING_LITTLE_ENDIAN: u32 = 0;
68pub const VHOST_VRING_BIG_ENDIAN: u32 = 1;
69#[repr(C)]
70#[derive(Debug, Default, Copy, Clone)]
71pub struct vhost_vring_state {
72    pub index: ::std::os::raw::c_uint,
73    pub num: ::std::os::raw::c_uint,
74}
75#[repr(C)]
76#[derive(Debug, Default, Copy, Clone)]
77pub struct vhost_vring_file {
78    pub index: ::std::os::raw::c_uint,
79    pub fd: ::std::os::raw::c_int,
80}
81#[repr(C)]
82#[derive(Debug, Default, Copy, Clone)]
83pub struct vhost_vring_addr {
84    pub index: ::std::os::raw::c_uint,
85    pub flags: ::std::os::raw::c_uint,
86    pub desc_user_addr: u64,
87    pub used_user_addr: u64,
88    pub avail_user_addr: u64,
89    pub log_guest_addr: u64,
90}
91#[repr(C)]
92#[derive(Debug, Default, Copy, Clone)]
93pub struct vhost_worker_state {
94    pub worker_id: ::std::os::raw::c_uint,
95}
96#[repr(C)]
97#[derive(Debug, Default, Copy, Clone)]
98pub struct vhost_vring_worker {
99    pub index: ::std::os::raw::c_uint,
100    pub worker_id: ::std::os::raw::c_uint,
101}
102#[repr(C)]
103#[derive(Debug, Default, Copy, Clone)]
104pub struct vhost_iotlb_msg {
105    pub iova: u64,
106    pub size: u64,
107    pub uaddr: u64,
108    pub perm: u8,
109    pub type_: u8,
110}
111#[repr(C)]
112#[derive(Copy, Clone)]
113pub struct vhost_msg {
114    pub type_: ::std::os::raw::c_int,
115    pub __bindgen_anon_1: vhost_msg__bindgen_ty_1,
116}
117#[repr(C)]
118#[derive(Copy, Clone)]
119pub union vhost_msg__bindgen_ty_1 {
120    pub iotlb: vhost_iotlb_msg,
121    pub padding: [u8; 64usize],
122}
123impl Default for vhost_msg__bindgen_ty_1 {
124    fn default() -> Self {
125        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
126        unsafe {
127            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
128            s.assume_init()
129        }
130    }
131}
132impl Default for vhost_msg {
133    fn default() -> Self {
134        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
135        unsafe {
136            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
137            s.assume_init()
138        }
139    }
140}
141#[repr(C)]
142#[derive(Copy, Clone)]
143pub struct vhost_msg_v2 {
144    pub type_: u32,
145    pub asid: u32,
146    pub __bindgen_anon_1: vhost_msg_v2__bindgen_ty_1,
147}
148#[repr(C)]
149#[derive(Copy, Clone)]
150pub union vhost_msg_v2__bindgen_ty_1 {
151    pub iotlb: vhost_iotlb_msg,
152    pub padding: [u8; 64usize],
153}
154impl Default for vhost_msg_v2__bindgen_ty_1 {
155    fn default() -> Self {
156        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
157        unsafe {
158            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
159            s.assume_init()
160        }
161    }
162}
163impl Default for vhost_msg_v2 {
164    fn default() -> Self {
165        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
166        unsafe {
167            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
168            s.assume_init()
169        }
170    }
171}
172#[repr(C)]
173#[derive(Debug, Default, Copy, Clone)]
174pub struct vhost_memory_region {
175    pub guest_phys_addr: u64,
176    pub memory_size: u64,
177    pub userspace_addr: u64,
178    pub flags_padding: u64,
179}
180#[repr(C)]
181#[derive(Debug, Default)]
182pub struct vhost_memory {
183    pub nregions: u32,
184    pub padding: u32,
185    pub regions: __IncompleteArrayField<vhost_memory_region>,
186}
187#[repr(C)]
188#[derive(Debug, Copy, Clone)]
189pub struct vhost_scsi_target {
190    pub abi_version: ::std::os::raw::c_int,
191    pub vhost_wwpn: [::std::os::raw::c_char; 224usize],
192    pub vhost_tpgt: ::std::os::raw::c_ushort,
193    pub reserved: ::std::os::raw::c_ushort,
194}
195impl Default for vhost_scsi_target {
196    fn default() -> Self {
197        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
198        unsafe {
199            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
200            s.assume_init()
201        }
202    }
203}
204#[repr(C)]
205#[derive(Debug, Default)]
206pub struct vhost_vdpa_config {
207    pub off: u32,
208    pub len: u32,
209    pub buf: __IncompleteArrayField<u8>,
210}
211#[repr(C)]
212#[derive(Debug, Default, Copy, Clone)]
213pub struct vhost_vdpa_iova_range {
214    pub first: u64,
215    pub last: u64,
216}