virtio_sys/
vhost.rs

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