Skip to content

Commit 7b70a12

Browse files
stefano-garzarellajiangliu
authored andcommitted
vhost_kern: add VHOST_VDPA_* ioctls and structs
Add ioctls, structs, and test needed to support vhost-vdpa. Signed-off-by: Stefano Garzarella <[email protected]>
1 parent 58680d5 commit 7b70a12

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

src/vhost_kern/vhost_binding.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ ioctl_iow_nr!(VHOST_SCSI_SET_EVENTS_MISSED, VHOST, 0x43, raw::c_uint);
6565
ioctl_iow_nr!(VHOST_SCSI_GET_EVENTS_MISSED, VHOST, 0x44, raw::c_uint);
6666
ioctl_iow_nr!(VHOST_VSOCK_SET_GUEST_CID, VHOST, 0x60, raw::c_ulonglong);
6767
ioctl_iow_nr!(VHOST_VSOCK_SET_RUNNING, VHOST, 0x61, raw::c_int);
68+
ioctl_ior_nr!(VHOST_VDPA_GET_DEVICE_ID, VHOST, 0x70, raw::c_uint);
69+
ioctl_ior_nr!(VHOST_VDPA_GET_STATUS, VHOST, 0x71, raw::c_uchar);
70+
ioctl_iow_nr!(VHOST_VDPA_SET_STATUS, VHOST, 0x72, raw::c_uchar);
71+
ioctl_ior_nr!(VHOST_VDPA_GET_CONFIG, VHOST, 0x73, vhost_vdpa_config);
72+
ioctl_iow_nr!(VHOST_VDPA_SET_CONFIG, VHOST, 0x74, vhost_vdpa_config);
73+
ioctl_iow_nr!(VHOST_VDPA_SET_VRING_ENABLE, VHOST, 0x75, vhost_vring_state);
74+
ioctl_ior_nr!(VHOST_VDPA_GET_VRING_NUM, VHOST, 0x76, raw::c_ushort);
75+
ioctl_iow_nr!(VHOST_VDPA_SET_CONFIG_CALL, VHOST, 0x77, raw::c_int);
76+
ioctl_ior_nr!(
77+
VHOST_VDPA_GET_IOVA_RANGE,
78+
VHOST,
79+
0x78,
80+
vhost_vdpa_iova_range
81+
);
6882

6983
#[repr(C)]
7084
#[derive(Default)]
@@ -238,6 +252,21 @@ impl Default for vhost_scsi_target {
238252
}
239253
}
240254

255+
#[repr(C)]
256+
#[derive(Debug)]
257+
pub struct vhost_vdpa_config {
258+
pub off: raw::c_uint,
259+
pub len: raw::c_uint,
260+
pub buf: __IncompleteArrayField<raw::c_uchar>,
261+
}
262+
263+
#[repr(C)]
264+
#[derive(Debug, Copy, Clone)]
265+
pub struct vhost_vdpa_iova_range {
266+
pub first: raw::c_ulonglong,
267+
pub last: raw::c_ulonglong,
268+
}
269+
241270
/// Helper to support vhost::set_mem_table()
242271
pub struct VhostMemory {
243272
buf: Vec<vhost_memory>,
@@ -440,6 +469,34 @@ mod tests {
440469
);
441470
}
442471

472+
#[test]
473+
fn bindgen_test_layout_vhost_vdpa_config() {
474+
assert_eq!(
475+
::std::mem::size_of::<vhost_vdpa_config>(),
476+
8usize,
477+
concat!("Size of: ", stringify!(vhost_vdpa_config))
478+
);
479+
assert_eq!(
480+
::std::mem::align_of::<vhost_vdpa_config>(),
481+
4usize,
482+
concat!("Alignment of ", stringify!(vhost_vdpa_config))
483+
);
484+
}
485+
486+
#[test]
487+
fn bindgen_test_layout_vhost_vdpa_iova_range() {
488+
assert_eq!(
489+
::std::mem::size_of::<vhost_vdpa_iova_range>(),
490+
16usize,
491+
concat!("Size of: ", stringify!(vhost_vdpa_iova_range))
492+
);
493+
assert_eq!(
494+
::std::mem::align_of::<vhost_vdpa_iova_range>(),
495+
8usize,
496+
concat!("Alignment of ", stringify!(vhost_vdpa_iova_range))
497+
);
498+
}
499+
443500
#[test]
444501
fn test_vhostmemory() {
445502
let mut obj = VhostMemory::new(2);

0 commit comments

Comments
 (0)