Skip to content

Commit 151d581

Browse files
likebreathjinankjain
authored andcommitted
vfio: Use unmodified bindings from vfio-ioctls
The bindings now are re-generated according to the updated CONTRIBUTING.md, e.g. no manual modifications and `--impl-debug` and `--impl-partialeq` enabled. Small changes from `vfio-ioctls` crate required to fix the type compatibility issue with non-modified bindings. Signed-off-by: Bo Chen <[email protected]>
1 parent 5144541 commit 151d581

File tree

2 files changed

+51
-23
lines changed

2 files changed

+51
-23
lines changed

vfio-bindings/src/bindings_v5_0_0/vfio.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub const VFIO_EEH: u32 = 5;
6161
pub const VFIO_TYPE1_NESTING_IOMMU: u32 = 6;
6262
pub const VFIO_SPAPR_TCE_v2_IOMMU: u32 = 7;
6363
pub const VFIO_NOIOMMU_IOMMU: u32 = 8;
64-
pub const VFIO_TYPE: u32 = 59;
64+
pub const VFIO_TYPE: u8 = 59u8;
6565
pub const VFIO_BASE: u32 = 100;
6666
pub const VFIO_GROUP_FLAGS_VIABLE: u32 = 1;
6767
pub const VFIO_GROUP_FLAGS_CONTAINER_SET: u32 = 2;
@@ -598,6 +598,11 @@ impl Default for vfio_device_gfx_plane_info__bindgen_ty_1 {
598598
}
599599
}
600600
}
601+
impl ::std::fmt::Debug for vfio_device_gfx_plane_info__bindgen_ty_1 {
602+
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
603+
write!(f, "vfio_device_gfx_plane_info__bindgen_ty_1 {{ union }}")
604+
}
605+
}
601606
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
602607
const _: () = {
603608
["Size of vfio_device_gfx_plane_info"]
@@ -640,6 +645,11 @@ impl Default for vfio_device_gfx_plane_info {
640645
}
641646
}
642647
}
648+
impl ::std::fmt::Debug for vfio_device_gfx_plane_info {
649+
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
650+
write ! (f , "vfio_device_gfx_plane_info {{ argsz: {:?}, flags: {:?}, drm_plane_type: {:?}, drm_format: {:?}, drm_format_mod: {:?}, width: {:?}, height: {:?}, stride: {:?}, size: {:?}, x_pos: {:?}, y_pos: {:?}, x_hot: {:?}, y_hot: {:?}, __bindgen_anon_1: {:?} }}" , self . argsz , self . flags , self . drm_plane_type , self . drm_format , self . drm_format_mod , self . width , self . height , self . stride , self . size , self . x_pos , self . y_pos , self . x_hot , self . y_hot , self . __bindgen_anon_1)
651+
}
652+
}
643653
#[doc = " VFIO_DEVICE_IOEVENTFD - _IOW(VFIO_TYPE, VFIO_BASE + 16,\n struct vfio_device_ioeventfd)\n\n Perform a write to the device at the specified device fd offset, with\n the specified data and width when the provided eventfd is triggered.\n vfio bus drivers may not support this for all regions, for all widths,\n or at all. vfio-pci currently only enables support for BAR regions,\n excluding the MSI-X vector table.\n\n Return: 0 on success, -errno on failure."]
644654
#[repr(C)]
645655
#[derive(Debug, Default, Copy, Clone, PartialEq)]
@@ -837,6 +847,11 @@ impl Default for vfio_eeh_pe_op__bindgen_ty_1 {
837847
}
838848
}
839849
}
850+
impl ::std::fmt::Debug for vfio_eeh_pe_op__bindgen_ty_1 {
851+
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
852+
write!(f, "vfio_eeh_pe_op__bindgen_ty_1 {{ union }}")
853+
}
854+
}
840855
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
841856
const _: () = {
842857
["Size of vfio_eeh_pe_op"][::std::mem::size_of::<vfio_eeh_pe_op>() - 40usize];
@@ -856,6 +871,15 @@ impl Default for vfio_eeh_pe_op {
856871
}
857872
}
858873
}
874+
impl ::std::fmt::Debug for vfio_eeh_pe_op {
875+
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
876+
write!(
877+
f,
878+
"vfio_eeh_pe_op {{ argsz: {:?}, flags: {:?}, op: {:?}, __bindgen_anon_1: {:?} }}",
879+
self.argsz, self.flags, self.op, self.__bindgen_anon_1
880+
)
881+
}
882+
}
859883
#[doc = " VFIO_IOMMU_SPAPR_REGISTER_MEMORY - _IOW(VFIO_TYPE, VFIO_BASE + 17, struct vfio_iommu_spapr_register_memory)\n\n Registers user space memory where DMA is allowed. It pins\n user pages and does the locked memory accounting so\n subsequent VFIO_IOMMU_MAP_DMA/VFIO_IOMMU_UNMAP_DMA calls\n get faster."]
860884
#[repr(C)]
861885
#[derive(Debug, Default, Copy, Clone, PartialEq)]

vfio-ioctls/src/vfio_ioctls.rs

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,36 @@ use vmm_sys_util::errno::Error as SysError;
1717
use crate::vfio_device::{vfio_region_info_with_cap, VfioDeviceInfo};
1818
use crate::{Result, VfioContainer, VfioDevice, VfioError, VfioGroup};
1919

20-
ioctl_io_nr!(VFIO_GET_API_VERSION, VFIO_TYPE, VFIO_BASE);
21-
ioctl_io_nr!(VFIO_CHECK_EXTENSION, VFIO_TYPE, VFIO_BASE + 1);
22-
ioctl_io_nr!(VFIO_SET_IOMMU, VFIO_TYPE, VFIO_BASE + 2);
23-
ioctl_io_nr!(VFIO_GROUP_GET_STATUS, VFIO_TYPE, VFIO_BASE + 3);
24-
ioctl_io_nr!(VFIO_GROUP_SET_CONTAINER, VFIO_TYPE, VFIO_BASE + 4);
25-
ioctl_io_nr!(VFIO_GROUP_UNSET_CONTAINER, VFIO_TYPE, VFIO_BASE + 5);
26-
ioctl_io_nr!(VFIO_GROUP_GET_DEVICE_FD, VFIO_TYPE, VFIO_BASE + 6);
27-
ioctl_io_nr!(VFIO_DEVICE_GET_INFO, VFIO_TYPE, VFIO_BASE + 7);
28-
ioctl_io_nr!(VFIO_DEVICE_GET_REGION_INFO, VFIO_TYPE, VFIO_BASE + 8);
29-
ioctl_io_nr!(VFIO_DEVICE_GET_IRQ_INFO, VFIO_TYPE, VFIO_BASE + 9);
30-
ioctl_io_nr!(VFIO_DEVICE_SET_IRQS, VFIO_TYPE, VFIO_BASE + 10);
31-
ioctl_io_nr!(VFIO_DEVICE_RESET, VFIO_TYPE, VFIO_BASE + 11);
20+
ioctl_io_nr!(VFIO_GET_API_VERSION, VFIO_TYPE.into(), VFIO_BASE);
21+
ioctl_io_nr!(VFIO_CHECK_EXTENSION, VFIO_TYPE.into(), VFIO_BASE + 1);
22+
ioctl_io_nr!(VFIO_SET_IOMMU, VFIO_TYPE.into(), VFIO_BASE + 2);
23+
ioctl_io_nr!(VFIO_GROUP_GET_STATUS, VFIO_TYPE.into(), VFIO_BASE + 3);
24+
ioctl_io_nr!(VFIO_GROUP_SET_CONTAINER, VFIO_TYPE.into(), VFIO_BASE + 4);
25+
ioctl_io_nr!(VFIO_GROUP_UNSET_CONTAINER, VFIO_TYPE.into(), VFIO_BASE + 5);
26+
ioctl_io_nr!(VFIO_GROUP_GET_DEVICE_FD, VFIO_TYPE.into(), VFIO_BASE + 6);
27+
ioctl_io_nr!(VFIO_DEVICE_GET_INFO, VFIO_TYPE.into(), VFIO_BASE + 7);
28+
ioctl_io_nr!(VFIO_DEVICE_GET_REGION_INFO, VFIO_TYPE.into(), VFIO_BASE + 8);
29+
ioctl_io_nr!(VFIO_DEVICE_GET_IRQ_INFO, VFIO_TYPE.into(), VFIO_BASE + 9);
30+
ioctl_io_nr!(VFIO_DEVICE_SET_IRQS, VFIO_TYPE.into(), VFIO_BASE + 10);
31+
ioctl_io_nr!(VFIO_DEVICE_RESET, VFIO_TYPE.into(), VFIO_BASE + 11);
3232
ioctl_io_nr!(
3333
VFIO_DEVICE_GET_PCI_HOT_RESET_INFO,
34-
VFIO_TYPE,
34+
VFIO_TYPE.into(),
3535
VFIO_BASE + 12
3636
);
37-
ioctl_io_nr!(VFIO_DEVICE_PCI_HOT_RESET, VFIO_TYPE, VFIO_BASE + 13);
38-
ioctl_io_nr!(VFIO_DEVICE_QUERY_GFX_PLANE, VFIO_TYPE, VFIO_BASE + 14);
39-
ioctl_io_nr!(VFIO_DEVICE_GET_GFX_DMABUF, VFIO_TYPE, VFIO_BASE + 15);
40-
ioctl_io_nr!(VFIO_DEVICE_IOEVENTFD, VFIO_TYPE, VFIO_BASE + 16);
41-
ioctl_io_nr!(VFIO_IOMMU_GET_INFO, VFIO_TYPE, VFIO_BASE + 12);
42-
ioctl_io_nr!(VFIO_IOMMU_MAP_DMA, VFIO_TYPE, VFIO_BASE + 13);
43-
ioctl_io_nr!(VFIO_IOMMU_UNMAP_DMA, VFIO_TYPE, VFIO_BASE + 14);
44-
ioctl_io_nr!(VFIO_IOMMU_ENABLE, VFIO_TYPE, VFIO_BASE + 15);
45-
ioctl_io_nr!(VFIO_IOMMU_DISABLE, VFIO_TYPE, VFIO_BASE + 16);
37+
ioctl_io_nr!(VFIO_DEVICE_PCI_HOT_RESET, VFIO_TYPE.into(), VFIO_BASE + 13);
38+
ioctl_io_nr!(
39+
VFIO_DEVICE_QUERY_GFX_PLANE,
40+
VFIO_TYPE.into(),
41+
VFIO_BASE + 14
42+
);
43+
ioctl_io_nr!(VFIO_DEVICE_GET_GFX_DMABUF, VFIO_TYPE.into(), VFIO_BASE + 15);
44+
ioctl_io_nr!(VFIO_DEVICE_IOEVENTFD, VFIO_TYPE.into(), VFIO_BASE + 16);
45+
ioctl_io_nr!(VFIO_IOMMU_GET_INFO, VFIO_TYPE.into(), VFIO_BASE + 12);
46+
ioctl_io_nr!(VFIO_IOMMU_MAP_DMA, VFIO_TYPE.into(), VFIO_BASE + 13);
47+
ioctl_io_nr!(VFIO_IOMMU_UNMAP_DMA, VFIO_TYPE.into(), VFIO_BASE + 14);
48+
ioctl_io_nr!(VFIO_IOMMU_ENABLE, VFIO_TYPE.into(), VFIO_BASE + 15);
49+
ioctl_io_nr!(VFIO_IOMMU_DISABLE, VFIO_TYPE.into(), VFIO_BASE + 16);
4650

4751
#[cfg(not(test))]
4852
// Safety:

0 commit comments

Comments
 (0)