├── CODEOWNERS ├── .gitmodules ├── coverage_config_x86_64.json ├── .cargo └── config ├── .github └── dependabot.yml ├── src ├── bindings_v5_0_0 │ ├── mod.rs │ └── vfio.rs ├── lib.rs └── fam_wrappers.rs ├── Cargo.toml ├── CHANGELOG.md ├── .buildkite └── custom-tests.json ├── README.md ├── LICENSE-BSD ├── CONTRIBUTING.md └── LICENSE-APACHE /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Add the list of code owners here (using their GitHub username) 2 | * @chao-p @sameo @jiangliu 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "rust-vmm-ci"] 2 | path = rust-vmm-ci 3 | url = https://github.com/rust-vmm/rust-vmm-ci.git 4 | -------------------------------------------------------------------------------- /coverage_config_x86_64.json: -------------------------------------------------------------------------------- 1 | { 2 | "coverage_score": 69.2, 3 | "exclude_path": "", 4 | "crate_features": "" 5 | } 6 | -------------------------------------------------------------------------------- /.cargo/config: -------------------------------------------------------------------------------- 1 | [target.aarch64-unknown-linux-musl] 2 | rustflags = [ "-C", "target-feature=+crt-static", "-C", "link-arg=-lgcc" ] 3 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: gitsubmodule 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | open-pull-requests-limit: 10 8 | -------------------------------------------------------------------------------- /src/bindings_v5_0_0/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Intel Corporation. All Rights Reserved. 2 | // SPDX-License-Identifier: (BSD-3-Clause OR Apache-2.0) 3 | 4 | #![allow(clippy::all)] 5 | #![allow(non_upper_case_globals)] 6 | #![allow(non_camel_case_types)] 7 | #![allow(non_snake_case)] 8 | 9 | pub mod vfio; 10 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "vfio-bindings" 3 | version = "0.3.0" 4 | authors = ["The Cloud Hypervisor Authors"] 5 | license = "Apache-2.0 OR BSD-3-Clause" 6 | description = "Rust FFI bindings to vfio generated using bindgen." 7 | repository = "https://github.com/rust-vmm/vfio-bindings" 8 | readme = "README.md" 9 | edition = "2018" 10 | keywords = ["vfio"] 11 | 12 | [features] 13 | vfio-v5_0_0 = [] 14 | fam-wrappers = ["vmm-sys-util"] 15 | 16 | [dependencies] 17 | vmm-sys-util = { version = ">=0.8.0", optional = true } 18 | 19 | [dev-dependencies] 20 | byteorder = ">=1.2.1" 21 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # [v0.3.0] 2 | 3 | ## Added 4 | 5 | - Update vmm-sys-util version to ">=0.8.0" 6 | 7 | # [v0.2.0] 8 | 9 | ## Added 10 | 11 | - Add FAM wrappers for vfio\_irq\_set 12 | - Update vmm-sys-util version to ">=0.2.0" 13 | 14 | # [v0.1.0] 15 | 16 | This is the first `vfio-bindings` crate release. 17 | 18 | This crate provides Rust FFI bindings to the 19 | [Virtual Function I/O (VFIO)](https://www.kernel.org/doc/Documentation/vfio.txt) 20 | Linux kernel API. With this first release, the bindings are for the Linux kernel 21 | version 5.0. 22 | 23 | The bindings are generated using [bindgen](https://crates.io/crates/bindgen). 24 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Intel Corporation. All Rights Reserved. 2 | // SPDX-License-Identifier: (BSD-3-Clause OR Apache-2.0) 3 | 4 | #[cfg(feature = "fam-wrappers")] 5 | #[macro_use] 6 | extern crate vmm_sys_util; 7 | 8 | #[cfg(feature = "fam-wrappers")] 9 | mod fam_wrappers; 10 | 11 | #[cfg(feature = "vfio-v5_0_0")] 12 | mod bindings_v5_0_0; 13 | 14 | // Default to latest version if no version is specified by using the features. 15 | #[cfg(not(feature = "vfio-v5_0_0"))] 16 | mod bindings_v5_0_0; 17 | 18 | pub mod bindings { 19 | #[cfg(feature = "vfio-v5_0_0")] 20 | pub use super::bindings_v5_0_0::*; 21 | 22 | #[cfg(not(feature = "vfio-v5_0_0"))] 23 | pub use super::bindings_v5_0_0::*; 24 | 25 | #[cfg(feature = "fam-wrappers")] 26 | pub use super::fam_wrappers::*; 27 | } 28 | -------------------------------------------------------------------------------- /.buildkite/custom-tests.json: -------------------------------------------------------------------------------- 1 | { 2 | "tests": [ 3 | { 4 | "test_name": "build-v5.0-fam-gnu", 5 | "command": "cargo build --release --features=fam-wrappers,vfio-v5_0_0", 6 | "platform": [ 7 | "x86_64", 8 | "aarch64" 9 | ] 10 | }, 11 | { 12 | "test_name": "build-v5.0-fam-musl", 13 | "command": "cargo build --release --features=fam-wrappers,vfio-v5_0_0 --target {target_platform}-unknown-linux-musl", 14 | "platform": [ 15 | "x86_64", 16 | "aarch64" 17 | ] 18 | }, 19 | { 20 | "test_name": "check-warnings-fam", 21 | "command": "RUSTFLAGS=\"-D warnings\" cargo check --features=vfio-v5_0_0,fam-wrappers", 22 | "platform": [ 23 | "x86_64", 24 | "aarch64" 25 | ] 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vfio-bindings 2 | 3 | ## Design 4 | 5 | The vfio-bindings crate is designed as rust FFI bindings to vfio 6 | generated using [bindgen](https://crates.io/crates/bindgen). 7 | 8 | Multiple Linux versions are supported through rust 'features'. For each 9 | supported Linux version, a feature is introduced. 10 | 11 | Currently supported features/Linux versions: 12 | - vfio-v5_0_0 contains the bindings for the Linux kernel version 5.0 13 | 14 | ## Usage 15 | 16 | First, add the following to your Cargo.toml: 17 | ```toml 18 | vfio-bindings = "0.2" 19 | ``` 20 | Next, add this to your crate root: 21 | 22 | ```rust 23 | extern crate vfio_bindings; 24 | ``` 25 | 26 | By default vfio-bindings will export a wrapper over the latest available kernel 27 | version it supported, but you can select a different version by specifying it in 28 | your Cargo.toml: 29 | ```toml 30 | vfio-bindings = { version = "0.2", features = ["vfio-v5_0_0"]} 31 | ``` 32 | 33 | ## Examples 34 | 35 | To use this bindings, you can do: 36 | ```rust 37 | use vfio_bindings::bindings::vfio::*; 38 | ``` 39 | 40 | ## License 41 | 42 | This code is licensed under Apache-2.0 or BSD-3-Clause. 43 | -------------------------------------------------------------------------------- /LICENSE-BSD: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright 2019 Intel Corporation. All Rights Reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of the copyright holder nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to vfio-bindings 2 | 3 | ## Dependencies 4 | 5 | ### Bindgen 6 | The bindings are currently generated using 7 | [bindgen](https://crates.io/crates/bindgen): 8 | 9 | ```bash 10 | cargo install bindgen 11 | ``` 12 | 13 | ### Linux Kernel 14 | Generating bindings depends on the Linux kernel, so you need to have the 15 | repository on your machine: 16 | 17 | ```bash 18 | git clone https://github.com/torvalds/linux.git 19 | ``` 20 | 21 | ## Example for adding a new version 22 | 23 | For this example we assume that you have both linux and vfio-bindings 24 | repositories in your root and we will use linux version v5.2 as example. 25 | 26 | ```bash 27 | # Step 1: Crate a new module using a name with format "bindings_vVERSION" in 28 | # src/ 29 | cd vfio-bindings 30 | mkdir src/bindings_v5_2_0 31 | cd ~ 32 | 33 | # Step 2: Copy the "mod.rs" file from the directory of an already existing 34 | # version module to the one we've just created. 35 | cd vfio-bindings/src 36 | cp bindings_v5_0_0/mod.rs bindings_v5_2_0/mod.rs 37 | 38 | # linux is the repository that you cloned at the previous step. 39 | cd linux 40 | 41 | # Step 3: Checkout the version you want to generate the bindings for. 42 | git checkout v5.2 43 | 44 | # Step 4: Generate the bindings from the kernel headers. 45 | make headers_install INSTALL_HDR_PATH=v5_2_headers 46 | cd v5_2_headers 47 | bindgen include/linux/vfio.h -o vfio.rs \ 48 | --with-derive-default \ 49 | --with-derive-partialeq \ 50 | -- -Iinclude 51 | 52 | cd ~ 53 | 54 | # Step 5: Copy the generated files to the new version module. 55 | cp linux/v5_2_headers/vfio.rs vfio-bindings/src/bindings_v5_2_0 56 | ``` 57 | 58 | Once this is done, you need some modifications to the generated vfio.rs. 59 | First change below line: 60 | ```rust 61 | pub const VFIO_TYPE: u8 = 59u8; 62 | ``` 63 | to 64 | ```rust 65 | pub const VFIO_TYPE: u32 = 59; 66 | ``` 67 | 68 | This is required due to that bindgen can not generate VFIO_TYPE correctly 69 | at this moment. You might also want to add the proper license header to 70 | the file. 71 | 72 | Finally add the new version module to `vfio-bindings/lib.rs`. If this version 73 | is newer than the others already present, make this version the default one by 74 | getting it imported when there isn't any other version specified as a feature: 75 | 76 | ```rust 77 | #[cfg(all(not(feature = "vfio-v5_0_0"), not(feature = "vfio-v5_2_0")))] 78 | pub use super::bindings_v5_2_0::*; 79 | ``` 80 | -------------------------------------------------------------------------------- /src/fam_wrappers.rs: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 Intel Corporation 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause 4 | // 5 | 6 | use crate::bindings::vfio::*; 7 | use vmm_sys_util::fam::{FamStruct, FamStructWrapper}; 8 | 9 | const MSIX_MAX_VECTORS: usize = 2048; 10 | 11 | // Implement the FamStruct trait vfio_irq_set. 12 | generate_fam_struct_impl!(vfio_irq_set, u8, data, u32, count, MSIX_MAX_VECTORS); 13 | 14 | /// Wrapper over the `vfio_irq_set` structure. 15 | /// 16 | /// The `vfio_irq_set` structure contains a flexible array member. For details check the 17 | /// [VFIO userspace API](https://github.com/torvalds/linux/blob/master/include/uapi/linux/vfio.h) 18 | /// documentation on `vfio_irq_set`. To provide safe access to the array 19 | /// elements, this type is implemented using 20 | /// [FamStructWrapper](../vmm_sys_util/fam/struct.FamStructWrapper.html). 21 | pub type IrqSet = FamStructWrapper; 22 | 23 | #[cfg(test)] 24 | mod tests { 25 | extern crate byteorder; 26 | 27 | use super::*; 28 | use byteorder::{ByteOrder, LittleEndian}; 29 | use std::mem; 30 | 31 | fn vec_with_size_in_bytes(size_in_bytes: usize) -> Vec { 32 | let rounded_size = (size_in_bytes + mem::size_of::() - 1) / mem::size_of::(); 33 | let mut v = Vec::with_capacity(rounded_size); 34 | for _ in 0..rounded_size { 35 | v.push(T::default()) 36 | } 37 | v 38 | } 39 | 40 | fn vec_with_array_field(count: usize) -> Vec { 41 | let element_space = count * mem::size_of::(); 42 | let vec_size_bytes = mem::size_of::() + element_space; 43 | vec_with_size_in_bytes(vec_size_bytes) 44 | } 45 | 46 | // Opinionated PartialEq implementation for vfio_irq_set. 47 | impl PartialEq for vfio_irq_set { 48 | fn eq(&self, other: &Self) -> bool { 49 | if self.argsz != other.argsz 50 | || self.flags != other.flags 51 | || self.index != other.index 52 | || self.start != other.start 53 | || self.count != other.count 54 | { 55 | return false; 56 | } 57 | true 58 | } 59 | } 60 | 61 | #[test] 62 | fn irqset_fam_test() { 63 | let event_fds: Vec = vec![0, 1, 2, 3, 4, 5]; 64 | 65 | // Build a FAM wrapper for this vfio_irq_set. 66 | let mut irq_set_wrapper = IrqSet::new(event_fds.len() * mem::size_of::()).unwrap(); 67 | let mut irq_set_fam = irq_set_wrapper.as_mut_fam_struct(); 68 | 69 | let fds_fam = irq_set_fam.as_mut_slice(); 70 | for (index, event_fd) in event_fds.iter().enumerate() { 71 | let fds_offset = index * mem::size_of::(); 72 | let fd = &mut fds_fam[fds_offset..fds_offset + mem::size_of::()]; 73 | LittleEndian::write_u32(fd, *event_fd); 74 | } 75 | 76 | irq_set_fam.argsz = mem::size_of::() as u32 77 | + (event_fds.len() * mem::size_of::()) as u32; 78 | irq_set_fam.flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER; 79 | irq_set_fam.index = 1; 80 | irq_set_fam.start = 0; 81 | irq_set_fam.count = event_fds.len() as u32; 82 | 83 | // Build the same vfio_irq_set structure with the vec_with_array routines 84 | let mut irq_set_vec = vec_with_array_field::(event_fds.len()); 85 | irq_set_vec[0].argsz = mem::size_of::() as u32 86 | + (event_fds.len() * mem::size_of::()) as u32; 87 | irq_set_vec[0].flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER; 88 | irq_set_vec[0].index = 1; 89 | irq_set_vec[0].start = 0; 90 | irq_set_vec[0].count = event_fds.len() as u32; 91 | 92 | let fds_vec = unsafe { 93 | irq_set_vec[0] 94 | .data 95 | .as_mut_slice(event_fds.len() * mem::size_of::()) 96 | }; 97 | for (index, event_fd) in event_fds.iter().enumerate() { 98 | let fds_offset = index * mem::size_of::(); 99 | let fd = &mut fds_vec[fds_offset..fds_offset + mem::size_of::()]; 100 | LittleEndian::write_u32(fd, *event_fd); 101 | } 102 | 103 | // Both sets should be identical. 104 | assert_eq!( 105 | irq_set_vec 106 | .iter() 107 | .zip(irq_set_wrapper.into_raw().iter()) 108 | .filter(|&(a, b)| a == b) 109 | .count(), 110 | irq_set_vec.len() 111 | ); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /src/bindings_v5_0_0/vfio.rs: -------------------------------------------------------------------------------- 1 | /* automatically generated by rust-bindgen */ 2 | 3 | #[repr(C)] 4 | #[derive(Default)] 5 | pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); 6 | impl __IncompleteArrayField { 7 | #[inline] 8 | pub const fn new() -> Self { 9 | __IncompleteArrayField(::std::marker::PhantomData, []) 10 | } 11 | #[inline] 12 | pub unsafe fn as_ptr(&self) -> *const T { 13 | ::std::mem::transmute(self) 14 | } 15 | #[inline] 16 | pub unsafe fn as_mut_ptr(&mut self) -> *mut T { 17 | ::std::mem::transmute(self) 18 | } 19 | #[inline] 20 | pub unsafe fn as_slice(&self, len: usize) -> &[T] { 21 | ::std::slice::from_raw_parts(self.as_ptr(), len) 22 | } 23 | #[inline] 24 | pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { 25 | ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) 26 | } 27 | } 28 | impl ::std::fmt::Debug for __IncompleteArrayField { 29 | fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 30 | fmt.write_str("__IncompleteArrayField") 31 | } 32 | } 33 | impl ::std::clone::Clone for __IncompleteArrayField { 34 | #[inline] 35 | fn clone(&self) -> Self { 36 | Self::new() 37 | } 38 | } 39 | pub const __BITS_PER_LONG: u32 = 64; 40 | pub const __FD_SETSIZE: u32 = 1024; 41 | pub const _IOC_NRBITS: u32 = 8; 42 | pub const _IOC_TYPEBITS: u32 = 8; 43 | pub const _IOC_SIZEBITS: u32 = 14; 44 | pub const _IOC_DIRBITS: u32 = 2; 45 | pub const _IOC_NRMASK: u32 = 255; 46 | pub const _IOC_TYPEMASK: u32 = 255; 47 | pub const _IOC_SIZEMASK: u32 = 16383; 48 | pub const _IOC_DIRMASK: u32 = 3; 49 | pub const _IOC_NRSHIFT: u32 = 0; 50 | pub const _IOC_TYPESHIFT: u32 = 8; 51 | pub const _IOC_SIZESHIFT: u32 = 16; 52 | pub const _IOC_DIRSHIFT: u32 = 30; 53 | pub const _IOC_NONE: u32 = 0; 54 | pub const _IOC_WRITE: u32 = 1; 55 | pub const _IOC_READ: u32 = 2; 56 | pub const IOC_IN: u32 = 1073741824; 57 | pub const IOC_OUT: u32 = 2147483648; 58 | pub const IOC_INOUT: u32 = 3221225472; 59 | pub const IOCSIZE_MASK: u32 = 1073676288; 60 | pub const IOCSIZE_SHIFT: u32 = 16; 61 | pub const VFIO_API_VERSION: u32 = 0; 62 | pub const VFIO_TYPE1_IOMMU: u32 = 1; 63 | pub const VFIO_SPAPR_TCE_IOMMU: u32 = 2; 64 | pub const VFIO_TYPE1v2_IOMMU: u32 = 3; 65 | pub const VFIO_DMA_CC_IOMMU: u32 = 4; 66 | pub const VFIO_EEH: u32 = 5; 67 | pub const VFIO_TYPE1_NESTING_IOMMU: u32 = 6; 68 | pub const VFIO_SPAPR_TCE_v2_IOMMU: u32 = 7; 69 | pub const VFIO_NOIOMMU_IOMMU: u32 = 8; 70 | pub const VFIO_TYPE: u32 = 59; 71 | pub const VFIO_BASE: u32 = 100; 72 | pub const VFIO_GROUP_FLAGS_VIABLE: u32 = 1; 73 | pub const VFIO_GROUP_FLAGS_CONTAINER_SET: u32 = 2; 74 | pub const VFIO_DEVICE_FLAGS_RESET: u32 = 1; 75 | pub const VFIO_DEVICE_FLAGS_PCI: u32 = 2; 76 | pub const VFIO_DEVICE_FLAGS_PLATFORM: u32 = 4; 77 | pub const VFIO_DEVICE_FLAGS_AMBA: u32 = 8; 78 | pub const VFIO_DEVICE_FLAGS_CCW: u32 = 16; 79 | pub const VFIO_DEVICE_FLAGS_AP: u32 = 32; 80 | pub const VFIO_DEVICE_API_PCI_STRING: &'static [u8; 9usize] = b"vfio-pci\0"; 81 | pub const VFIO_DEVICE_API_PLATFORM_STRING: &'static [u8; 14usize] = b"vfio-platform\0"; 82 | pub const VFIO_DEVICE_API_AMBA_STRING: &'static [u8; 10usize] = b"vfio-amba\0"; 83 | pub const VFIO_DEVICE_API_CCW_STRING: &'static [u8; 9usize] = b"vfio-ccw\0"; 84 | pub const VFIO_DEVICE_API_AP_STRING: &'static [u8; 8usize] = b"vfio-ap\0"; 85 | pub const VFIO_REGION_INFO_FLAG_READ: u32 = 1; 86 | pub const VFIO_REGION_INFO_FLAG_WRITE: u32 = 2; 87 | pub const VFIO_REGION_INFO_FLAG_MMAP: u32 = 4; 88 | pub const VFIO_REGION_INFO_FLAG_CAPS: u32 = 8; 89 | pub const VFIO_REGION_INFO_CAP_SPARSE_MMAP: u32 = 1; 90 | pub const VFIO_REGION_INFO_CAP_TYPE: u32 = 2; 91 | pub const VFIO_REGION_TYPE_PCI_VENDOR_TYPE: u32 = 2147483648; 92 | pub const VFIO_REGION_TYPE_PCI_VENDOR_MASK: u32 = 65535; 93 | pub const VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION: u32 = 1; 94 | pub const VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG: u32 = 2; 95 | pub const VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG: u32 = 3; 96 | pub const VFIO_REGION_TYPE_GFX: u32 = 1; 97 | pub const VFIO_REGION_SUBTYPE_GFX_EDID: u32 = 1; 98 | pub const VFIO_DEVICE_GFX_LINK_STATE_UP: u32 = 1; 99 | pub const VFIO_DEVICE_GFX_LINK_STATE_DOWN: u32 = 2; 100 | pub const VFIO_REGION_SUBTYPE_NVIDIA_NVLINK2_RAM: u32 = 1; 101 | pub const VFIO_REGION_SUBTYPE_IBM_NVLINK2_ATSD: u32 = 1; 102 | pub const VFIO_REGION_INFO_CAP_MSIX_MAPPABLE: u32 = 3; 103 | pub const VFIO_REGION_INFO_CAP_NVLINK2_SSATGT: u32 = 4; 104 | pub const VFIO_REGION_INFO_CAP_NVLINK2_LNKSPD: u32 = 5; 105 | pub const VFIO_IRQ_INFO_EVENTFD: u32 = 1; 106 | pub const VFIO_IRQ_INFO_MASKABLE: u32 = 2; 107 | pub const VFIO_IRQ_INFO_AUTOMASKED: u32 = 4; 108 | pub const VFIO_IRQ_INFO_NORESIZE: u32 = 8; 109 | pub const VFIO_IRQ_SET_DATA_NONE: u32 = 1; 110 | pub const VFIO_IRQ_SET_DATA_BOOL: u32 = 2; 111 | pub const VFIO_IRQ_SET_DATA_EVENTFD: u32 = 4; 112 | pub const VFIO_IRQ_SET_ACTION_MASK: u32 = 8; 113 | pub const VFIO_IRQ_SET_ACTION_UNMASK: u32 = 16; 114 | pub const VFIO_IRQ_SET_ACTION_TRIGGER: u32 = 32; 115 | pub const VFIO_IRQ_SET_DATA_TYPE_MASK: u32 = 7; 116 | pub const VFIO_IRQ_SET_ACTION_TYPE_MASK: u32 = 56; 117 | pub const VFIO_GFX_PLANE_TYPE_PROBE: u32 = 1; 118 | pub const VFIO_GFX_PLANE_TYPE_DMABUF: u32 = 2; 119 | pub const VFIO_GFX_PLANE_TYPE_REGION: u32 = 4; 120 | pub const VFIO_DEVICE_IOEVENTFD_8: u32 = 1; 121 | pub const VFIO_DEVICE_IOEVENTFD_16: u32 = 2; 122 | pub const VFIO_DEVICE_IOEVENTFD_32: u32 = 4; 123 | pub const VFIO_DEVICE_IOEVENTFD_64: u32 = 8; 124 | pub const VFIO_DEVICE_IOEVENTFD_SIZE_MASK: u32 = 15; 125 | pub const VFIO_IOMMU_INFO_PGSIZES: u32 = 1; 126 | pub const VFIO_DMA_MAP_FLAG_READ: u32 = 1; 127 | pub const VFIO_DMA_MAP_FLAG_WRITE: u32 = 2; 128 | pub const VFIO_IOMMU_SPAPR_INFO_DDW: u32 = 1; 129 | pub const VFIO_EEH_PE_DISABLE: u32 = 0; 130 | pub const VFIO_EEH_PE_ENABLE: u32 = 1; 131 | pub const VFIO_EEH_PE_UNFREEZE_IO: u32 = 2; 132 | pub const VFIO_EEH_PE_UNFREEZE_DMA: u32 = 3; 133 | pub const VFIO_EEH_PE_GET_STATE: u32 = 4; 134 | pub const VFIO_EEH_PE_STATE_NORMAL: u32 = 0; 135 | pub const VFIO_EEH_PE_STATE_RESET: u32 = 1; 136 | pub const VFIO_EEH_PE_STATE_STOPPED: u32 = 2; 137 | pub const VFIO_EEH_PE_STATE_STOPPED_DMA: u32 = 4; 138 | pub const VFIO_EEH_PE_STATE_UNAVAIL: u32 = 5; 139 | pub const VFIO_EEH_PE_RESET_DEACTIVATE: u32 = 5; 140 | pub const VFIO_EEH_PE_RESET_HOT: u32 = 6; 141 | pub const VFIO_EEH_PE_RESET_FUNDAMENTAL: u32 = 7; 142 | pub const VFIO_EEH_PE_CONFIGURE: u32 = 8; 143 | pub const VFIO_EEH_PE_INJECT_ERR: u32 = 9; 144 | pub type __s8 = ::std::os::raw::c_schar; 145 | pub type __u8 = ::std::os::raw::c_uchar; 146 | pub type __s16 = ::std::os::raw::c_short; 147 | pub type __u16 = ::std::os::raw::c_ushort; 148 | pub type __s32 = ::std::os::raw::c_int; 149 | pub type __u32 = ::std::os::raw::c_uint; 150 | pub type __s64 = ::std::os::raw::c_longlong; 151 | pub type __u64 = ::std::os::raw::c_ulonglong; 152 | #[repr(C)] 153 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 154 | pub struct __kernel_fd_set { 155 | pub fds_bits: [::std::os::raw::c_ulong; 16usize], 156 | } 157 | #[test] 158 | fn bindgen_test_layout___kernel_fd_set() { 159 | assert_eq!( 160 | ::std::mem::size_of::<__kernel_fd_set>(), 161 | 128usize, 162 | concat!("Size of: ", stringify!(__kernel_fd_set)) 163 | ); 164 | assert_eq!( 165 | ::std::mem::align_of::<__kernel_fd_set>(), 166 | 8usize, 167 | concat!("Alignment of ", stringify!(__kernel_fd_set)) 168 | ); 169 | assert_eq!( 170 | unsafe { &(*(::std::ptr::null::<__kernel_fd_set>())).fds_bits as *const _ as usize }, 171 | 0usize, 172 | concat!( 173 | "Offset of field: ", 174 | stringify!(__kernel_fd_set), 175 | "::", 176 | stringify!(fds_bits) 177 | ) 178 | ); 179 | } 180 | pub type __kernel_sighandler_t = 181 | ::std::option::Option; 182 | pub type __kernel_key_t = ::std::os::raw::c_int; 183 | pub type __kernel_mqd_t = ::std::os::raw::c_int; 184 | pub type __kernel_old_uid_t = ::std::os::raw::c_ushort; 185 | pub type __kernel_old_gid_t = ::std::os::raw::c_ushort; 186 | pub type __kernel_old_dev_t = ::std::os::raw::c_ulong; 187 | pub type __kernel_long_t = ::std::os::raw::c_long; 188 | pub type __kernel_ulong_t = ::std::os::raw::c_ulong; 189 | pub type __kernel_ino_t = __kernel_ulong_t; 190 | pub type __kernel_mode_t = ::std::os::raw::c_uint; 191 | pub type __kernel_pid_t = ::std::os::raw::c_int; 192 | pub type __kernel_ipc_pid_t = ::std::os::raw::c_int; 193 | pub type __kernel_uid_t = ::std::os::raw::c_uint; 194 | pub type __kernel_gid_t = ::std::os::raw::c_uint; 195 | pub type __kernel_suseconds_t = __kernel_long_t; 196 | pub type __kernel_daddr_t = ::std::os::raw::c_int; 197 | pub type __kernel_uid32_t = ::std::os::raw::c_uint; 198 | pub type __kernel_gid32_t = ::std::os::raw::c_uint; 199 | pub type __kernel_size_t = __kernel_ulong_t; 200 | pub type __kernel_ssize_t = __kernel_long_t; 201 | pub type __kernel_ptrdiff_t = __kernel_long_t; 202 | #[repr(C)] 203 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 204 | pub struct __kernel_fsid_t { 205 | pub val: [::std::os::raw::c_int; 2usize], 206 | } 207 | #[test] 208 | fn bindgen_test_layout___kernel_fsid_t() { 209 | assert_eq!( 210 | ::std::mem::size_of::<__kernel_fsid_t>(), 211 | 8usize, 212 | concat!("Size of: ", stringify!(__kernel_fsid_t)) 213 | ); 214 | assert_eq!( 215 | ::std::mem::align_of::<__kernel_fsid_t>(), 216 | 4usize, 217 | concat!("Alignment of ", stringify!(__kernel_fsid_t)) 218 | ); 219 | assert_eq!( 220 | unsafe { &(*(::std::ptr::null::<__kernel_fsid_t>())).val as *const _ as usize }, 221 | 0usize, 222 | concat!( 223 | "Offset of field: ", 224 | stringify!(__kernel_fsid_t), 225 | "::", 226 | stringify!(val) 227 | ) 228 | ); 229 | } 230 | pub type __kernel_off_t = __kernel_long_t; 231 | pub type __kernel_loff_t = ::std::os::raw::c_longlong; 232 | pub type __kernel_time_t = __kernel_long_t; 233 | pub type __kernel_time64_t = ::std::os::raw::c_longlong; 234 | pub type __kernel_clock_t = __kernel_long_t; 235 | pub type __kernel_timer_t = ::std::os::raw::c_int; 236 | pub type __kernel_clockid_t = ::std::os::raw::c_int; 237 | pub type __kernel_caddr_t = *mut ::std::os::raw::c_char; 238 | pub type __kernel_uid16_t = ::std::os::raw::c_ushort; 239 | pub type __kernel_gid16_t = ::std::os::raw::c_ushort; 240 | pub type __le16 = __u16; 241 | pub type __be16 = __u16; 242 | pub type __le32 = __u32; 243 | pub type __be32 = __u32; 244 | pub type __le64 = __u64; 245 | pub type __be64 = __u64; 246 | pub type __sum16 = __u16; 247 | pub type __wsum = __u32; 248 | pub type __poll_t = ::std::os::raw::c_uint; 249 | #[repr(C)] 250 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 251 | pub struct vfio_info_cap_header { 252 | pub id: __u16, 253 | pub version: __u16, 254 | pub next: __u32, 255 | } 256 | #[test] 257 | fn bindgen_test_layout_vfio_info_cap_header() { 258 | assert_eq!( 259 | ::std::mem::size_of::(), 260 | 8usize, 261 | concat!("Size of: ", stringify!(vfio_info_cap_header)) 262 | ); 263 | assert_eq!( 264 | ::std::mem::align_of::(), 265 | 4usize, 266 | concat!("Alignment of ", stringify!(vfio_info_cap_header)) 267 | ); 268 | assert_eq!( 269 | unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, 270 | 0usize, 271 | concat!( 272 | "Offset of field: ", 273 | stringify!(vfio_info_cap_header), 274 | "::", 275 | stringify!(id) 276 | ) 277 | ); 278 | assert_eq!( 279 | unsafe { &(*(::std::ptr::null::())).version as *const _ as usize }, 280 | 2usize, 281 | concat!( 282 | "Offset of field: ", 283 | stringify!(vfio_info_cap_header), 284 | "::", 285 | stringify!(version) 286 | ) 287 | ); 288 | assert_eq!( 289 | unsafe { &(*(::std::ptr::null::())).next as *const _ as usize }, 290 | 4usize, 291 | concat!( 292 | "Offset of field: ", 293 | stringify!(vfio_info_cap_header), 294 | "::", 295 | stringify!(next) 296 | ) 297 | ); 298 | } 299 | #[doc = " VFIO_GROUP_GET_STATUS - _IOR(VFIO_TYPE, VFIO_BASE + 3,"] 300 | #[doc = "\t\t\t\t\t\tstruct vfio_group_status)"] 301 | #[doc = ""] 302 | #[doc = " Retrieve information about the group. Fills in provided"] 303 | #[doc = " struct vfio_group_info. Caller sets argsz."] 304 | #[doc = " Return: 0 on succes, -errno on failure."] 305 | #[doc = " Availability: Always"] 306 | #[repr(C)] 307 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 308 | pub struct vfio_group_status { 309 | pub argsz: __u32, 310 | pub flags: __u32, 311 | } 312 | #[test] 313 | fn bindgen_test_layout_vfio_group_status() { 314 | assert_eq!( 315 | ::std::mem::size_of::(), 316 | 8usize, 317 | concat!("Size of: ", stringify!(vfio_group_status)) 318 | ); 319 | assert_eq!( 320 | ::std::mem::align_of::(), 321 | 4usize, 322 | concat!("Alignment of ", stringify!(vfio_group_status)) 323 | ); 324 | assert_eq!( 325 | unsafe { &(*(::std::ptr::null::())).argsz as *const _ as usize }, 326 | 0usize, 327 | concat!( 328 | "Offset of field: ", 329 | stringify!(vfio_group_status), 330 | "::", 331 | stringify!(argsz) 332 | ) 333 | ); 334 | assert_eq!( 335 | unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, 336 | 4usize, 337 | concat!( 338 | "Offset of field: ", 339 | stringify!(vfio_group_status), 340 | "::", 341 | stringify!(flags) 342 | ) 343 | ); 344 | } 345 | #[doc = " VFIO_DEVICE_GET_INFO - _IOR(VFIO_TYPE, VFIO_BASE + 7,"] 346 | #[doc = "\t\t\t\t\t\tstruct vfio_device_info)"] 347 | #[doc = ""] 348 | #[doc = " Retrieve information about the device. Fills in provided"] 349 | #[doc = " struct vfio_device_info. Caller sets argsz."] 350 | #[doc = " Return: 0 on success, -errno on failure."] 351 | #[repr(C)] 352 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 353 | pub struct vfio_device_info { 354 | pub argsz: __u32, 355 | pub flags: __u32, 356 | pub num_regions: __u32, 357 | pub num_irqs: __u32, 358 | } 359 | #[test] 360 | fn bindgen_test_layout_vfio_device_info() { 361 | assert_eq!( 362 | ::std::mem::size_of::(), 363 | 16usize, 364 | concat!("Size of: ", stringify!(vfio_device_info)) 365 | ); 366 | assert_eq!( 367 | ::std::mem::align_of::(), 368 | 4usize, 369 | concat!("Alignment of ", stringify!(vfio_device_info)) 370 | ); 371 | assert_eq!( 372 | unsafe { &(*(::std::ptr::null::())).argsz as *const _ as usize }, 373 | 0usize, 374 | concat!( 375 | "Offset of field: ", 376 | stringify!(vfio_device_info), 377 | "::", 378 | stringify!(argsz) 379 | ) 380 | ); 381 | assert_eq!( 382 | unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, 383 | 4usize, 384 | concat!( 385 | "Offset of field: ", 386 | stringify!(vfio_device_info), 387 | "::", 388 | stringify!(flags) 389 | ) 390 | ); 391 | assert_eq!( 392 | unsafe { &(*(::std::ptr::null::())).num_regions as *const _ as usize }, 393 | 8usize, 394 | concat!( 395 | "Offset of field: ", 396 | stringify!(vfio_device_info), 397 | "::", 398 | stringify!(num_regions) 399 | ) 400 | ); 401 | assert_eq!( 402 | unsafe { &(*(::std::ptr::null::())).num_irqs as *const _ as usize }, 403 | 12usize, 404 | concat!( 405 | "Offset of field: ", 406 | stringify!(vfio_device_info), 407 | "::", 408 | stringify!(num_irqs) 409 | ) 410 | ); 411 | } 412 | #[doc = " VFIO_DEVICE_GET_REGION_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 8,"] 413 | #[doc = "\t\t\t\t struct vfio_region_info)"] 414 | #[doc = ""] 415 | #[doc = " Retrieve information about a device region. Caller provides"] 416 | #[doc = " struct vfio_region_info with index value set. Caller sets argsz."] 417 | #[doc = " Implementation of region mapping is bus driver specific. This is"] 418 | #[doc = " intended to describe MMIO, I/O port, as well as bus specific"] 419 | #[doc = " regions (ex. PCI config space). Zero sized regions may be used"] 420 | #[doc = " to describe unimplemented regions (ex. unimplemented PCI BARs)."] 421 | #[doc = " Return: 0 on success, -errno on failure."] 422 | #[repr(C)] 423 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 424 | pub struct vfio_region_info { 425 | pub argsz: __u32, 426 | pub flags: __u32, 427 | pub index: __u32, 428 | pub cap_offset: __u32, 429 | pub size: __u64, 430 | pub offset: __u64, 431 | } 432 | #[test] 433 | fn bindgen_test_layout_vfio_region_info() { 434 | assert_eq!( 435 | ::std::mem::size_of::(), 436 | 32usize, 437 | concat!("Size of: ", stringify!(vfio_region_info)) 438 | ); 439 | assert_eq!( 440 | ::std::mem::align_of::(), 441 | 8usize, 442 | concat!("Alignment of ", stringify!(vfio_region_info)) 443 | ); 444 | assert_eq!( 445 | unsafe { &(*(::std::ptr::null::())).argsz as *const _ as usize }, 446 | 0usize, 447 | concat!( 448 | "Offset of field: ", 449 | stringify!(vfio_region_info), 450 | "::", 451 | stringify!(argsz) 452 | ) 453 | ); 454 | assert_eq!( 455 | unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, 456 | 4usize, 457 | concat!( 458 | "Offset of field: ", 459 | stringify!(vfio_region_info), 460 | "::", 461 | stringify!(flags) 462 | ) 463 | ); 464 | assert_eq!( 465 | unsafe { &(*(::std::ptr::null::())).index as *const _ as usize }, 466 | 8usize, 467 | concat!( 468 | "Offset of field: ", 469 | stringify!(vfio_region_info), 470 | "::", 471 | stringify!(index) 472 | ) 473 | ); 474 | assert_eq!( 475 | unsafe { &(*(::std::ptr::null::())).cap_offset as *const _ as usize }, 476 | 12usize, 477 | concat!( 478 | "Offset of field: ", 479 | stringify!(vfio_region_info), 480 | "::", 481 | stringify!(cap_offset) 482 | ) 483 | ); 484 | assert_eq!( 485 | unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, 486 | 16usize, 487 | concat!( 488 | "Offset of field: ", 489 | stringify!(vfio_region_info), 490 | "::", 491 | stringify!(size) 492 | ) 493 | ); 494 | assert_eq!( 495 | unsafe { &(*(::std::ptr::null::())).offset as *const _ as usize }, 496 | 24usize, 497 | concat!( 498 | "Offset of field: ", 499 | stringify!(vfio_region_info), 500 | "::", 501 | stringify!(offset) 502 | ) 503 | ); 504 | } 505 | #[repr(C)] 506 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 507 | pub struct vfio_region_sparse_mmap_area { 508 | pub offset: __u64, 509 | pub size: __u64, 510 | } 511 | #[test] 512 | fn bindgen_test_layout_vfio_region_sparse_mmap_area() { 513 | assert_eq!( 514 | ::std::mem::size_of::(), 515 | 16usize, 516 | concat!("Size of: ", stringify!(vfio_region_sparse_mmap_area)) 517 | ); 518 | assert_eq!( 519 | ::std::mem::align_of::(), 520 | 8usize, 521 | concat!("Alignment of ", stringify!(vfio_region_sparse_mmap_area)) 522 | ); 523 | assert_eq!( 524 | unsafe { 525 | &(*(::std::ptr::null::())).offset as *const _ as usize 526 | }, 527 | 0usize, 528 | concat!( 529 | "Offset of field: ", 530 | stringify!(vfio_region_sparse_mmap_area), 531 | "::", 532 | stringify!(offset) 533 | ) 534 | ); 535 | assert_eq!( 536 | unsafe { 537 | &(*(::std::ptr::null::())).size as *const _ as usize 538 | }, 539 | 8usize, 540 | concat!( 541 | "Offset of field: ", 542 | stringify!(vfio_region_sparse_mmap_area), 543 | "::", 544 | stringify!(size) 545 | ) 546 | ); 547 | } 548 | #[repr(C)] 549 | #[derive(Debug, Default)] 550 | pub struct vfio_region_info_cap_sparse_mmap { 551 | pub header: vfio_info_cap_header, 552 | pub nr_areas: __u32, 553 | pub reserved: __u32, 554 | pub areas: __IncompleteArrayField, 555 | } 556 | #[test] 557 | fn bindgen_test_layout_vfio_region_info_cap_sparse_mmap() { 558 | assert_eq!( 559 | ::std::mem::size_of::(), 560 | 16usize, 561 | concat!("Size of: ", stringify!(vfio_region_info_cap_sparse_mmap)) 562 | ); 563 | assert_eq!( 564 | ::std::mem::align_of::(), 565 | 8usize, 566 | concat!( 567 | "Alignment of ", 568 | stringify!(vfio_region_info_cap_sparse_mmap) 569 | ) 570 | ); 571 | } 572 | #[repr(C)] 573 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 574 | pub struct vfio_region_info_cap_type { 575 | pub header: vfio_info_cap_header, 576 | pub type_: __u32, 577 | pub subtype: __u32, 578 | } 579 | #[test] 580 | fn bindgen_test_layout_vfio_region_info_cap_type() { 581 | assert_eq!( 582 | ::std::mem::size_of::(), 583 | 16usize, 584 | concat!("Size of: ", stringify!(vfio_region_info_cap_type)) 585 | ); 586 | assert_eq!( 587 | ::std::mem::align_of::(), 588 | 4usize, 589 | concat!("Alignment of ", stringify!(vfio_region_info_cap_type)) 590 | ); 591 | assert_eq!( 592 | unsafe { 593 | &(*(::std::ptr::null::())).header as *const _ as usize 594 | }, 595 | 0usize, 596 | concat!( 597 | "Offset of field: ", 598 | stringify!(vfio_region_info_cap_type), 599 | "::", 600 | stringify!(header) 601 | ) 602 | ); 603 | assert_eq!( 604 | unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, 605 | 8usize, 606 | concat!( 607 | "Offset of field: ", 608 | stringify!(vfio_region_info_cap_type), 609 | "::", 610 | stringify!(type_) 611 | ) 612 | ); 613 | assert_eq!( 614 | unsafe { 615 | &(*(::std::ptr::null::())).subtype as *const _ as usize 616 | }, 617 | 12usize, 618 | concat!( 619 | "Offset of field: ", 620 | stringify!(vfio_region_info_cap_type), 621 | "::", 622 | stringify!(subtype) 623 | ) 624 | ); 625 | } 626 | #[doc = " struct vfio_region_gfx_edid - EDID region layout."] 627 | #[doc = ""] 628 | #[doc = " Set display link state and EDID blob."] 629 | #[doc = ""] 630 | #[doc = " The EDID blob has monitor information such as brand, name, serial"] 631 | #[doc = " number, physical size, supported video modes and more."] 632 | #[doc = ""] 633 | #[doc = " This special region allows userspace (typically qemu) set a virtual"] 634 | #[doc = " EDID for the virtual monitor, which allows a flexible display"] 635 | #[doc = " configuration."] 636 | #[doc = ""] 637 | #[doc = " For the edid blob spec look here:"] 638 | #[doc = " https://en.wikipedia.org/wiki/Extended_Display_Identification_Data"] 639 | #[doc = ""] 640 | #[doc = " On linux systems you can find the EDID blob in sysfs:"] 641 | #[doc = " /sys/class/drm/${card}/${connector}/edid"] 642 | #[doc = ""] 643 | #[doc = " You can use the edid-decode ulility (comes with xorg-x11-utils) to"] 644 | #[doc = " decode the EDID blob."] 645 | #[doc = ""] 646 | #[doc = " @edid_offset: location of the edid blob, relative to the"] 647 | #[doc = " start of the region (readonly)."] 648 | #[doc = " @edid_max_size: max size of the edid blob (readonly)."] 649 | #[doc = " @edid_size: actual edid size (read/write)."] 650 | #[doc = " @link_state: display link state (read/write)."] 651 | #[doc = " VFIO_DEVICE_GFX_LINK_STATE_UP: Monitor is turned on."] 652 | #[doc = " VFIO_DEVICE_GFX_LINK_STATE_DOWN: Monitor is turned off."] 653 | #[doc = " @max_xres: max display width (0 == no limitation, readonly)."] 654 | #[doc = " @max_yres: max display height (0 == no limitation, readonly)."] 655 | #[doc = ""] 656 | #[doc = " EDID update protocol:"] 657 | #[doc = " (1) set link-state to down."] 658 | #[doc = " (2) update edid blob and size."] 659 | #[doc = " (3) set link-state to up."] 660 | #[repr(C)] 661 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 662 | pub struct vfio_region_gfx_edid { 663 | pub edid_offset: __u32, 664 | pub edid_max_size: __u32, 665 | pub edid_size: __u32, 666 | pub max_xres: __u32, 667 | pub max_yres: __u32, 668 | pub link_state: __u32, 669 | } 670 | #[test] 671 | fn bindgen_test_layout_vfio_region_gfx_edid() { 672 | assert_eq!( 673 | ::std::mem::size_of::(), 674 | 24usize, 675 | concat!("Size of: ", stringify!(vfio_region_gfx_edid)) 676 | ); 677 | assert_eq!( 678 | ::std::mem::align_of::(), 679 | 4usize, 680 | concat!("Alignment of ", stringify!(vfio_region_gfx_edid)) 681 | ); 682 | assert_eq!( 683 | unsafe { 684 | &(*(::std::ptr::null::())).edid_offset as *const _ as usize 685 | }, 686 | 0usize, 687 | concat!( 688 | "Offset of field: ", 689 | stringify!(vfio_region_gfx_edid), 690 | "::", 691 | stringify!(edid_offset) 692 | ) 693 | ); 694 | assert_eq!( 695 | unsafe { 696 | &(*(::std::ptr::null::())).edid_max_size as *const _ as usize 697 | }, 698 | 4usize, 699 | concat!( 700 | "Offset of field: ", 701 | stringify!(vfio_region_gfx_edid), 702 | "::", 703 | stringify!(edid_max_size) 704 | ) 705 | ); 706 | assert_eq!( 707 | unsafe { &(*(::std::ptr::null::())).edid_size as *const _ as usize }, 708 | 8usize, 709 | concat!( 710 | "Offset of field: ", 711 | stringify!(vfio_region_gfx_edid), 712 | "::", 713 | stringify!(edid_size) 714 | ) 715 | ); 716 | assert_eq!( 717 | unsafe { &(*(::std::ptr::null::())).max_xres as *const _ as usize }, 718 | 12usize, 719 | concat!( 720 | "Offset of field: ", 721 | stringify!(vfio_region_gfx_edid), 722 | "::", 723 | stringify!(max_xres) 724 | ) 725 | ); 726 | assert_eq!( 727 | unsafe { &(*(::std::ptr::null::())).max_yres as *const _ as usize }, 728 | 16usize, 729 | concat!( 730 | "Offset of field: ", 731 | stringify!(vfio_region_gfx_edid), 732 | "::", 733 | stringify!(max_yres) 734 | ) 735 | ); 736 | assert_eq!( 737 | unsafe { &(*(::std::ptr::null::())).link_state as *const _ as usize }, 738 | 20usize, 739 | concat!( 740 | "Offset of field: ", 741 | stringify!(vfio_region_gfx_edid), 742 | "::", 743 | stringify!(link_state) 744 | ) 745 | ); 746 | } 747 | #[repr(C)] 748 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 749 | pub struct vfio_region_info_cap_nvlink2_ssatgt { 750 | pub header: vfio_info_cap_header, 751 | pub tgt: __u64, 752 | } 753 | #[test] 754 | fn bindgen_test_layout_vfio_region_info_cap_nvlink2_ssatgt() { 755 | assert_eq!( 756 | ::std::mem::size_of::(), 757 | 16usize, 758 | concat!("Size of: ", stringify!(vfio_region_info_cap_nvlink2_ssatgt)) 759 | ); 760 | assert_eq!( 761 | ::std::mem::align_of::(), 762 | 8usize, 763 | concat!( 764 | "Alignment of ", 765 | stringify!(vfio_region_info_cap_nvlink2_ssatgt) 766 | ) 767 | ); 768 | assert_eq!( 769 | unsafe { 770 | &(*(::std::ptr::null::())).header as *const _ 771 | as usize 772 | }, 773 | 0usize, 774 | concat!( 775 | "Offset of field: ", 776 | stringify!(vfio_region_info_cap_nvlink2_ssatgt), 777 | "::", 778 | stringify!(header) 779 | ) 780 | ); 781 | assert_eq!( 782 | unsafe { 783 | &(*(::std::ptr::null::())).tgt as *const _ as usize 784 | }, 785 | 8usize, 786 | concat!( 787 | "Offset of field: ", 788 | stringify!(vfio_region_info_cap_nvlink2_ssatgt), 789 | "::", 790 | stringify!(tgt) 791 | ) 792 | ); 793 | } 794 | #[repr(C)] 795 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 796 | pub struct vfio_region_info_cap_nvlink2_lnkspd { 797 | pub header: vfio_info_cap_header, 798 | pub link_speed: __u32, 799 | pub __pad: __u32, 800 | } 801 | #[test] 802 | fn bindgen_test_layout_vfio_region_info_cap_nvlink2_lnkspd() { 803 | assert_eq!( 804 | ::std::mem::size_of::(), 805 | 16usize, 806 | concat!("Size of: ", stringify!(vfio_region_info_cap_nvlink2_lnkspd)) 807 | ); 808 | assert_eq!( 809 | ::std::mem::align_of::(), 810 | 4usize, 811 | concat!( 812 | "Alignment of ", 813 | stringify!(vfio_region_info_cap_nvlink2_lnkspd) 814 | ) 815 | ); 816 | assert_eq!( 817 | unsafe { 818 | &(*(::std::ptr::null::())).header as *const _ 819 | as usize 820 | }, 821 | 0usize, 822 | concat!( 823 | "Offset of field: ", 824 | stringify!(vfio_region_info_cap_nvlink2_lnkspd), 825 | "::", 826 | stringify!(header) 827 | ) 828 | ); 829 | assert_eq!( 830 | unsafe { 831 | &(*(::std::ptr::null::())).link_speed as *const _ 832 | as usize 833 | }, 834 | 8usize, 835 | concat!( 836 | "Offset of field: ", 837 | stringify!(vfio_region_info_cap_nvlink2_lnkspd), 838 | "::", 839 | stringify!(link_speed) 840 | ) 841 | ); 842 | assert_eq!( 843 | unsafe { 844 | &(*(::std::ptr::null::())).__pad as *const _ 845 | as usize 846 | }, 847 | 12usize, 848 | concat!( 849 | "Offset of field: ", 850 | stringify!(vfio_region_info_cap_nvlink2_lnkspd), 851 | "::", 852 | stringify!(__pad) 853 | ) 854 | ); 855 | } 856 | #[doc = " VFIO_DEVICE_GET_IRQ_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 9,"] 857 | #[doc = "\t\t\t\t struct vfio_irq_info)"] 858 | #[doc = ""] 859 | #[doc = " Retrieve information about a device IRQ. Caller provides"] 860 | #[doc = " struct vfio_irq_info with index value set. Caller sets argsz."] 861 | #[doc = " Implementation of IRQ mapping is bus driver specific. Indexes"] 862 | #[doc = " using multiple IRQs are primarily intended to support MSI-like"] 863 | #[doc = " interrupt blocks. Zero count irq blocks may be used to describe"] 864 | #[doc = " unimplemented interrupt types."] 865 | #[doc = ""] 866 | #[doc = " The EVENTFD flag indicates the interrupt index supports eventfd based"] 867 | #[doc = " signaling."] 868 | #[doc = ""] 869 | #[doc = " The MASKABLE flags indicates the index supports MASK and UNMASK"] 870 | #[doc = " actions described below."] 871 | #[doc = ""] 872 | #[doc = " AUTOMASKED indicates that after signaling, the interrupt line is"] 873 | #[doc = " automatically masked by VFIO and the user needs to unmask the line"] 874 | #[doc = " to receive new interrupts. This is primarily intended to distinguish"] 875 | #[doc = " level triggered interrupts."] 876 | #[doc = ""] 877 | #[doc = " The NORESIZE flag indicates that the interrupt lines within the index"] 878 | #[doc = " are setup as a set and new subindexes cannot be enabled without first"] 879 | #[doc = " disabling the entire index. This is used for interrupts like PCI MSI"] 880 | #[doc = " and MSI-X where the driver may only use a subset of the available"] 881 | #[doc = " indexes, but VFIO needs to enable a specific number of vectors"] 882 | #[doc = " upfront. In the case of MSI-X, where the user can enable MSI-X and"] 883 | #[doc = " then add and unmask vectors, it's up to userspace to make the decision"] 884 | #[doc = " whether to allocate the maximum supported number of vectors or tear"] 885 | #[doc = " down setup and incrementally increase the vectors as each is enabled."] 886 | #[repr(C)] 887 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 888 | pub struct vfio_irq_info { 889 | pub argsz: __u32, 890 | pub flags: __u32, 891 | pub index: __u32, 892 | pub count: __u32, 893 | } 894 | #[test] 895 | fn bindgen_test_layout_vfio_irq_info() { 896 | assert_eq!( 897 | ::std::mem::size_of::(), 898 | 16usize, 899 | concat!("Size of: ", stringify!(vfio_irq_info)) 900 | ); 901 | assert_eq!( 902 | ::std::mem::align_of::(), 903 | 4usize, 904 | concat!("Alignment of ", stringify!(vfio_irq_info)) 905 | ); 906 | assert_eq!( 907 | unsafe { &(*(::std::ptr::null::())).argsz as *const _ as usize }, 908 | 0usize, 909 | concat!( 910 | "Offset of field: ", 911 | stringify!(vfio_irq_info), 912 | "::", 913 | stringify!(argsz) 914 | ) 915 | ); 916 | assert_eq!( 917 | unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, 918 | 4usize, 919 | concat!( 920 | "Offset of field: ", 921 | stringify!(vfio_irq_info), 922 | "::", 923 | stringify!(flags) 924 | ) 925 | ); 926 | assert_eq!( 927 | unsafe { &(*(::std::ptr::null::())).index as *const _ as usize }, 928 | 8usize, 929 | concat!( 930 | "Offset of field: ", 931 | stringify!(vfio_irq_info), 932 | "::", 933 | stringify!(index) 934 | ) 935 | ); 936 | assert_eq!( 937 | unsafe { &(*(::std::ptr::null::())).count as *const _ as usize }, 938 | 12usize, 939 | concat!( 940 | "Offset of field: ", 941 | stringify!(vfio_irq_info), 942 | "::", 943 | stringify!(count) 944 | ) 945 | ); 946 | } 947 | #[doc = " VFIO_DEVICE_SET_IRQS - _IOW(VFIO_TYPE, VFIO_BASE + 10, struct vfio_irq_set)"] 948 | #[doc = ""] 949 | #[doc = " Set signaling, masking, and unmasking of interrupts. Caller provides"] 950 | #[doc = " struct vfio_irq_set with all fields set. 'start' and 'count' indicate"] 951 | #[doc = " the range of subindexes being specified."] 952 | #[doc = ""] 953 | #[doc = " The DATA flags specify the type of data provided. If DATA_NONE, the"] 954 | #[doc = " operation performs the specified action immediately on the specified"] 955 | #[doc = " interrupt(s). For example, to unmask AUTOMASKED interrupt [0,0]:"] 956 | #[doc = " flags = (DATA_NONE|ACTION_UNMASK), index = 0, start = 0, count = 1."] 957 | #[doc = ""] 958 | #[doc = " DATA_BOOL allows sparse support for the same on arrays of interrupts."] 959 | #[doc = " For example, to mask interrupts [0,1] and [0,3] (but not [0,2]):"] 960 | #[doc = " flags = (DATA_BOOL|ACTION_MASK), index = 0, start = 1, count = 3,"] 961 | #[doc = " data = {1,0,1}"] 962 | #[doc = ""] 963 | #[doc = " DATA_EVENTFD binds the specified ACTION to the provided __s32 eventfd."] 964 | #[doc = " A value of -1 can be used to either de-assign interrupts if already"] 965 | #[doc = " assigned or skip un-assigned interrupts. For example, to set an eventfd"] 966 | #[doc = " to be trigger for interrupts [0,0] and [0,2]:"] 967 | #[doc = " flags = (DATA_EVENTFD|ACTION_TRIGGER), index = 0, start = 0, count = 3,"] 968 | #[doc = " data = {fd1, -1, fd2}"] 969 | #[doc = " If index [0,1] is previously set, two count = 1 ioctls calls would be"] 970 | #[doc = " required to set [0,0] and [0,2] without changing [0,1]."] 971 | #[doc = ""] 972 | #[doc = " Once a signaling mechanism is set, DATA_BOOL or DATA_NONE can be used"] 973 | #[doc = " with ACTION_TRIGGER to perform kernel level interrupt loopback testing"] 974 | #[doc = " from userspace (ie. simulate hardware triggering)."] 975 | #[doc = ""] 976 | #[doc = " Setting of an event triggering mechanism to userspace for ACTION_TRIGGER"] 977 | #[doc = " enables the interrupt index for the device. Individual subindex interrupts"] 978 | #[doc = " can be disabled using the -1 value for DATA_EVENTFD or the index can be"] 979 | #[doc = " disabled as a whole with: flags = (DATA_NONE|ACTION_TRIGGER), count = 0."] 980 | #[doc = ""] 981 | #[doc = " Note that ACTION_[UN]MASK specify user->kernel signaling (irqfds) while"] 982 | #[doc = " ACTION_TRIGGER specifies kernel->user signaling."] 983 | #[repr(C)] 984 | #[derive(Debug, Default)] 985 | pub struct vfio_irq_set { 986 | pub argsz: __u32, 987 | pub flags: __u32, 988 | pub index: __u32, 989 | pub start: __u32, 990 | pub count: __u32, 991 | pub data: __IncompleteArrayField<__u8>, 992 | } 993 | #[test] 994 | fn bindgen_test_layout_vfio_irq_set() { 995 | assert_eq!( 996 | ::std::mem::size_of::(), 997 | 20usize, 998 | concat!("Size of: ", stringify!(vfio_irq_set)) 999 | ); 1000 | assert_eq!( 1001 | ::std::mem::align_of::(), 1002 | 4usize, 1003 | concat!("Alignment of ", stringify!(vfio_irq_set)) 1004 | ); 1005 | } 1006 | pub const VFIO_PCI_BAR0_REGION_INDEX: _bindgen_ty_1 = 0; 1007 | pub const VFIO_PCI_BAR1_REGION_INDEX: _bindgen_ty_1 = 1; 1008 | pub const VFIO_PCI_BAR2_REGION_INDEX: _bindgen_ty_1 = 2; 1009 | pub const VFIO_PCI_BAR3_REGION_INDEX: _bindgen_ty_1 = 3; 1010 | pub const VFIO_PCI_BAR4_REGION_INDEX: _bindgen_ty_1 = 4; 1011 | pub const VFIO_PCI_BAR5_REGION_INDEX: _bindgen_ty_1 = 5; 1012 | pub const VFIO_PCI_ROM_REGION_INDEX: _bindgen_ty_1 = 6; 1013 | pub const VFIO_PCI_CONFIG_REGION_INDEX: _bindgen_ty_1 = 7; 1014 | pub const VFIO_PCI_VGA_REGION_INDEX: _bindgen_ty_1 = 8; 1015 | pub const VFIO_PCI_NUM_REGIONS: _bindgen_ty_1 = 9; 1016 | pub type _bindgen_ty_1 = u32; 1017 | pub const VFIO_PCI_INTX_IRQ_INDEX: _bindgen_ty_2 = 0; 1018 | pub const VFIO_PCI_MSI_IRQ_INDEX: _bindgen_ty_2 = 1; 1019 | pub const VFIO_PCI_MSIX_IRQ_INDEX: _bindgen_ty_2 = 2; 1020 | pub const VFIO_PCI_ERR_IRQ_INDEX: _bindgen_ty_2 = 3; 1021 | pub const VFIO_PCI_REQ_IRQ_INDEX: _bindgen_ty_2 = 4; 1022 | pub const VFIO_PCI_NUM_IRQS: _bindgen_ty_2 = 5; 1023 | pub type _bindgen_ty_2 = u32; 1024 | pub const VFIO_CCW_CONFIG_REGION_INDEX: _bindgen_ty_3 = 0; 1025 | pub const VFIO_CCW_NUM_REGIONS: _bindgen_ty_3 = 1; 1026 | pub type _bindgen_ty_3 = u32; 1027 | pub const VFIO_CCW_IO_IRQ_INDEX: _bindgen_ty_4 = 0; 1028 | pub const VFIO_CCW_NUM_IRQS: _bindgen_ty_4 = 1; 1029 | pub type _bindgen_ty_4 = u32; 1030 | #[doc = " VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IORW(VFIO_TYPE, VFIO_BASE + 12,"] 1031 | #[doc = "\t\t\t\t\t struct vfio_pci_hot_reset_info)"] 1032 | #[doc = ""] 1033 | #[doc = " Return: 0 on success, -errno on failure:"] 1034 | #[doc = "\t-enospc = insufficient buffer, -enodev = unsupported for device."] 1035 | #[repr(C)] 1036 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 1037 | pub struct vfio_pci_dependent_device { 1038 | pub group_id: __u32, 1039 | pub segment: __u16, 1040 | pub bus: __u8, 1041 | pub devfn: __u8, 1042 | } 1043 | #[test] 1044 | fn bindgen_test_layout_vfio_pci_dependent_device() { 1045 | assert_eq!( 1046 | ::std::mem::size_of::(), 1047 | 8usize, 1048 | concat!("Size of: ", stringify!(vfio_pci_dependent_device)) 1049 | ); 1050 | assert_eq!( 1051 | ::std::mem::align_of::(), 1052 | 4usize, 1053 | concat!("Alignment of ", stringify!(vfio_pci_dependent_device)) 1054 | ); 1055 | assert_eq!( 1056 | unsafe { 1057 | &(*(::std::ptr::null::())).group_id as *const _ as usize 1058 | }, 1059 | 0usize, 1060 | concat!( 1061 | "Offset of field: ", 1062 | stringify!(vfio_pci_dependent_device), 1063 | "::", 1064 | stringify!(group_id) 1065 | ) 1066 | ); 1067 | assert_eq!( 1068 | unsafe { 1069 | &(*(::std::ptr::null::())).segment as *const _ as usize 1070 | }, 1071 | 4usize, 1072 | concat!( 1073 | "Offset of field: ", 1074 | stringify!(vfio_pci_dependent_device), 1075 | "::", 1076 | stringify!(segment) 1077 | ) 1078 | ); 1079 | assert_eq!( 1080 | unsafe { &(*(::std::ptr::null::())).bus as *const _ as usize }, 1081 | 6usize, 1082 | concat!( 1083 | "Offset of field: ", 1084 | stringify!(vfio_pci_dependent_device), 1085 | "::", 1086 | stringify!(bus) 1087 | ) 1088 | ); 1089 | assert_eq!( 1090 | unsafe { &(*(::std::ptr::null::())).devfn as *const _ as usize }, 1091 | 7usize, 1092 | concat!( 1093 | "Offset of field: ", 1094 | stringify!(vfio_pci_dependent_device), 1095 | "::", 1096 | stringify!(devfn) 1097 | ) 1098 | ); 1099 | } 1100 | #[repr(C)] 1101 | #[derive(Debug, Default)] 1102 | pub struct vfio_pci_hot_reset_info { 1103 | pub argsz: __u32, 1104 | pub flags: __u32, 1105 | pub count: __u32, 1106 | pub devices: __IncompleteArrayField, 1107 | } 1108 | #[test] 1109 | fn bindgen_test_layout_vfio_pci_hot_reset_info() { 1110 | assert_eq!( 1111 | ::std::mem::size_of::(), 1112 | 12usize, 1113 | concat!("Size of: ", stringify!(vfio_pci_hot_reset_info)) 1114 | ); 1115 | assert_eq!( 1116 | ::std::mem::align_of::(), 1117 | 4usize, 1118 | concat!("Alignment of ", stringify!(vfio_pci_hot_reset_info)) 1119 | ); 1120 | } 1121 | #[doc = " VFIO_DEVICE_PCI_HOT_RESET - _IOW(VFIO_TYPE, VFIO_BASE + 13,"] 1122 | #[doc = "\t\t\t\t struct vfio_pci_hot_reset)"] 1123 | #[doc = ""] 1124 | #[doc = " Return: 0 on success, -errno on failure."] 1125 | #[repr(C)] 1126 | #[derive(Debug, Default)] 1127 | pub struct vfio_pci_hot_reset { 1128 | pub argsz: __u32, 1129 | pub flags: __u32, 1130 | pub count: __u32, 1131 | pub group_fds: __IncompleteArrayField<__s32>, 1132 | } 1133 | #[test] 1134 | fn bindgen_test_layout_vfio_pci_hot_reset() { 1135 | assert_eq!( 1136 | ::std::mem::size_of::(), 1137 | 12usize, 1138 | concat!("Size of: ", stringify!(vfio_pci_hot_reset)) 1139 | ); 1140 | assert_eq!( 1141 | ::std::mem::align_of::(), 1142 | 4usize, 1143 | concat!("Alignment of ", stringify!(vfio_pci_hot_reset)) 1144 | ); 1145 | } 1146 | #[doc = " VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14,"] 1147 | #[doc = " struct vfio_device_query_gfx_plane)"] 1148 | #[doc = ""] 1149 | #[doc = " Set the drm_plane_type and flags, then retrieve the gfx plane info."] 1150 | #[doc = ""] 1151 | #[doc = " flags supported:"] 1152 | #[doc = " - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_DMABUF are set"] 1153 | #[doc = " to ask if the mdev supports dma-buf. 0 on support, -EINVAL on no"] 1154 | #[doc = " support for dma-buf."] 1155 | #[doc = " - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_REGION are set"] 1156 | #[doc = " to ask if the mdev supports region. 0 on support, -EINVAL on no"] 1157 | #[doc = " support for region."] 1158 | #[doc = " - VFIO_GFX_PLANE_TYPE_DMABUF or VFIO_GFX_PLANE_TYPE_REGION is set"] 1159 | #[doc = " with each call to query the plane info."] 1160 | #[doc = " - Others are invalid and return -EINVAL."] 1161 | #[doc = ""] 1162 | #[doc = " Note:"] 1163 | #[doc = " 1. Plane could be disabled by guest. In that case, success will be"] 1164 | #[doc = " returned with zero-initialized drm_format, size, width and height"] 1165 | #[doc = " fields."] 1166 | #[doc = " 2. x_hot/y_hot is set to 0xFFFFFFFF if no hotspot information available"] 1167 | #[doc = ""] 1168 | #[doc = " Return: 0 on success, -errno on other failure."] 1169 | #[repr(C)] 1170 | #[derive(Copy, Clone)] 1171 | pub struct vfio_device_gfx_plane_info { 1172 | pub argsz: __u32, 1173 | pub flags: __u32, 1174 | pub drm_plane_type: __u32, 1175 | pub drm_format: __u32, 1176 | pub drm_format_mod: __u64, 1177 | pub width: __u32, 1178 | pub height: __u32, 1179 | pub stride: __u32, 1180 | pub size: __u32, 1181 | pub x_pos: __u32, 1182 | pub y_pos: __u32, 1183 | pub x_hot: __u32, 1184 | pub y_hot: __u32, 1185 | pub __bindgen_anon_1: vfio_device_gfx_plane_info__bindgen_ty_1, 1186 | } 1187 | #[repr(C)] 1188 | #[derive(Copy, Clone)] 1189 | pub union vfio_device_gfx_plane_info__bindgen_ty_1 { 1190 | pub region_index: __u32, 1191 | pub dmabuf_id: __u32, 1192 | _bindgen_union_align: u32, 1193 | } 1194 | #[test] 1195 | fn bindgen_test_layout_vfio_device_gfx_plane_info__bindgen_ty_1() { 1196 | assert_eq!( 1197 | ::std::mem::size_of::(), 1198 | 4usize, 1199 | concat!( 1200 | "Size of: ", 1201 | stringify!(vfio_device_gfx_plane_info__bindgen_ty_1) 1202 | ) 1203 | ); 1204 | assert_eq!( 1205 | ::std::mem::align_of::(), 1206 | 4usize, 1207 | concat!( 1208 | "Alignment of ", 1209 | stringify!(vfio_device_gfx_plane_info__bindgen_ty_1) 1210 | ) 1211 | ); 1212 | assert_eq!( 1213 | unsafe { 1214 | &(*(::std::ptr::null::())).region_index 1215 | as *const _ as usize 1216 | }, 1217 | 0usize, 1218 | concat!( 1219 | "Offset of field: ", 1220 | stringify!(vfio_device_gfx_plane_info__bindgen_ty_1), 1221 | "::", 1222 | stringify!(region_index) 1223 | ) 1224 | ); 1225 | assert_eq!( 1226 | unsafe { 1227 | &(*(::std::ptr::null::())).dmabuf_id 1228 | as *const _ as usize 1229 | }, 1230 | 0usize, 1231 | concat!( 1232 | "Offset of field: ", 1233 | stringify!(vfio_device_gfx_plane_info__bindgen_ty_1), 1234 | "::", 1235 | stringify!(dmabuf_id) 1236 | ) 1237 | ); 1238 | } 1239 | impl Default for vfio_device_gfx_plane_info__bindgen_ty_1 { 1240 | fn default() -> Self { 1241 | unsafe { ::std::mem::zeroed() } 1242 | } 1243 | } 1244 | #[test] 1245 | fn bindgen_test_layout_vfio_device_gfx_plane_info() { 1246 | assert_eq!( 1247 | ::std::mem::size_of::(), 1248 | 64usize, 1249 | concat!("Size of: ", stringify!(vfio_device_gfx_plane_info)) 1250 | ); 1251 | assert_eq!( 1252 | ::std::mem::align_of::(), 1253 | 8usize, 1254 | concat!("Alignment of ", stringify!(vfio_device_gfx_plane_info)) 1255 | ); 1256 | assert_eq!( 1257 | unsafe { 1258 | &(*(::std::ptr::null::())).argsz as *const _ as usize 1259 | }, 1260 | 0usize, 1261 | concat!( 1262 | "Offset of field: ", 1263 | stringify!(vfio_device_gfx_plane_info), 1264 | "::", 1265 | stringify!(argsz) 1266 | ) 1267 | ); 1268 | assert_eq!( 1269 | unsafe { 1270 | &(*(::std::ptr::null::())).flags as *const _ as usize 1271 | }, 1272 | 4usize, 1273 | concat!( 1274 | "Offset of field: ", 1275 | stringify!(vfio_device_gfx_plane_info), 1276 | "::", 1277 | stringify!(flags) 1278 | ) 1279 | ); 1280 | assert_eq!( 1281 | unsafe { 1282 | &(*(::std::ptr::null::())).drm_plane_type as *const _ 1283 | as usize 1284 | }, 1285 | 8usize, 1286 | concat!( 1287 | "Offset of field: ", 1288 | stringify!(vfio_device_gfx_plane_info), 1289 | "::", 1290 | stringify!(drm_plane_type) 1291 | ) 1292 | ); 1293 | assert_eq!( 1294 | unsafe { 1295 | &(*(::std::ptr::null::())).drm_format as *const _ as usize 1296 | }, 1297 | 12usize, 1298 | concat!( 1299 | "Offset of field: ", 1300 | stringify!(vfio_device_gfx_plane_info), 1301 | "::", 1302 | stringify!(drm_format) 1303 | ) 1304 | ); 1305 | assert_eq!( 1306 | unsafe { 1307 | &(*(::std::ptr::null::())).drm_format_mod as *const _ 1308 | as usize 1309 | }, 1310 | 16usize, 1311 | concat!( 1312 | "Offset of field: ", 1313 | stringify!(vfio_device_gfx_plane_info), 1314 | "::", 1315 | stringify!(drm_format_mod) 1316 | ) 1317 | ); 1318 | assert_eq!( 1319 | unsafe { 1320 | &(*(::std::ptr::null::())).width as *const _ as usize 1321 | }, 1322 | 24usize, 1323 | concat!( 1324 | "Offset of field: ", 1325 | stringify!(vfio_device_gfx_plane_info), 1326 | "::", 1327 | stringify!(width) 1328 | ) 1329 | ); 1330 | assert_eq!( 1331 | unsafe { 1332 | &(*(::std::ptr::null::())).height as *const _ as usize 1333 | }, 1334 | 28usize, 1335 | concat!( 1336 | "Offset of field: ", 1337 | stringify!(vfio_device_gfx_plane_info), 1338 | "::", 1339 | stringify!(height) 1340 | ) 1341 | ); 1342 | assert_eq!( 1343 | unsafe { 1344 | &(*(::std::ptr::null::())).stride as *const _ as usize 1345 | }, 1346 | 32usize, 1347 | concat!( 1348 | "Offset of field: ", 1349 | stringify!(vfio_device_gfx_plane_info), 1350 | "::", 1351 | stringify!(stride) 1352 | ) 1353 | ); 1354 | assert_eq!( 1355 | unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, 1356 | 36usize, 1357 | concat!( 1358 | "Offset of field: ", 1359 | stringify!(vfio_device_gfx_plane_info), 1360 | "::", 1361 | stringify!(size) 1362 | ) 1363 | ); 1364 | assert_eq!( 1365 | unsafe { 1366 | &(*(::std::ptr::null::())).x_pos as *const _ as usize 1367 | }, 1368 | 40usize, 1369 | concat!( 1370 | "Offset of field: ", 1371 | stringify!(vfio_device_gfx_plane_info), 1372 | "::", 1373 | stringify!(x_pos) 1374 | ) 1375 | ); 1376 | assert_eq!( 1377 | unsafe { 1378 | &(*(::std::ptr::null::())).y_pos as *const _ as usize 1379 | }, 1380 | 44usize, 1381 | concat!( 1382 | "Offset of field: ", 1383 | stringify!(vfio_device_gfx_plane_info), 1384 | "::", 1385 | stringify!(y_pos) 1386 | ) 1387 | ); 1388 | assert_eq!( 1389 | unsafe { 1390 | &(*(::std::ptr::null::())).x_hot as *const _ as usize 1391 | }, 1392 | 48usize, 1393 | concat!( 1394 | "Offset of field: ", 1395 | stringify!(vfio_device_gfx_plane_info), 1396 | "::", 1397 | stringify!(x_hot) 1398 | ) 1399 | ); 1400 | assert_eq!( 1401 | unsafe { 1402 | &(*(::std::ptr::null::())).y_hot as *const _ as usize 1403 | }, 1404 | 52usize, 1405 | concat!( 1406 | "Offset of field: ", 1407 | stringify!(vfio_device_gfx_plane_info), 1408 | "::", 1409 | stringify!(y_hot) 1410 | ) 1411 | ); 1412 | } 1413 | impl Default for vfio_device_gfx_plane_info { 1414 | fn default() -> Self { 1415 | unsafe { ::std::mem::zeroed() } 1416 | } 1417 | } 1418 | #[doc = " VFIO_DEVICE_IOEVENTFD - _IOW(VFIO_TYPE, VFIO_BASE + 16,"] 1419 | #[doc = " struct vfio_device_ioeventfd)"] 1420 | #[doc = ""] 1421 | #[doc = " Perform a write to the device at the specified device fd offset, with"] 1422 | #[doc = " the specified data and width when the provided eventfd is triggered."] 1423 | #[doc = " vfio bus drivers may not support this for all regions, for all widths,"] 1424 | #[doc = " or at all. vfio-pci currently only enables support for BAR regions,"] 1425 | #[doc = " excluding the MSI-X vector table."] 1426 | #[doc = ""] 1427 | #[doc = " Return: 0 on success, -errno on failure."] 1428 | #[repr(C)] 1429 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 1430 | pub struct vfio_device_ioeventfd { 1431 | pub argsz: __u32, 1432 | pub flags: __u32, 1433 | pub offset: __u64, 1434 | pub data: __u64, 1435 | pub fd: __s32, 1436 | } 1437 | #[test] 1438 | fn bindgen_test_layout_vfio_device_ioeventfd() { 1439 | assert_eq!( 1440 | ::std::mem::size_of::(), 1441 | 32usize, 1442 | concat!("Size of: ", stringify!(vfio_device_ioeventfd)) 1443 | ); 1444 | assert_eq!( 1445 | ::std::mem::align_of::(), 1446 | 8usize, 1447 | concat!("Alignment of ", stringify!(vfio_device_ioeventfd)) 1448 | ); 1449 | assert_eq!( 1450 | unsafe { &(*(::std::ptr::null::())).argsz as *const _ as usize }, 1451 | 0usize, 1452 | concat!( 1453 | "Offset of field: ", 1454 | stringify!(vfio_device_ioeventfd), 1455 | "::", 1456 | stringify!(argsz) 1457 | ) 1458 | ); 1459 | assert_eq!( 1460 | unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, 1461 | 4usize, 1462 | concat!( 1463 | "Offset of field: ", 1464 | stringify!(vfio_device_ioeventfd), 1465 | "::", 1466 | stringify!(flags) 1467 | ) 1468 | ); 1469 | assert_eq!( 1470 | unsafe { &(*(::std::ptr::null::())).offset as *const _ as usize }, 1471 | 8usize, 1472 | concat!( 1473 | "Offset of field: ", 1474 | stringify!(vfio_device_ioeventfd), 1475 | "::", 1476 | stringify!(offset) 1477 | ) 1478 | ); 1479 | assert_eq!( 1480 | unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, 1481 | 16usize, 1482 | concat!( 1483 | "Offset of field: ", 1484 | stringify!(vfio_device_ioeventfd), 1485 | "::", 1486 | stringify!(data) 1487 | ) 1488 | ); 1489 | assert_eq!( 1490 | unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, 1491 | 24usize, 1492 | concat!( 1493 | "Offset of field: ", 1494 | stringify!(vfio_device_ioeventfd), 1495 | "::", 1496 | stringify!(fd) 1497 | ) 1498 | ); 1499 | } 1500 | #[doc = " VFIO_IOMMU_GET_INFO - _IOR(VFIO_TYPE, VFIO_BASE + 12, struct vfio_iommu_info)"] 1501 | #[doc = ""] 1502 | #[doc = " Retrieve information about the IOMMU object. Fills in provided"] 1503 | #[doc = " struct vfio_iommu_info. Caller sets argsz."] 1504 | #[doc = ""] 1505 | #[doc = " XXX Should we do these by CHECK_EXTENSION too?"] 1506 | #[repr(C)] 1507 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 1508 | pub struct vfio_iommu_type1_info { 1509 | pub argsz: __u32, 1510 | pub flags: __u32, 1511 | pub iova_pgsizes: __u64, 1512 | } 1513 | #[test] 1514 | fn bindgen_test_layout_vfio_iommu_type1_info() { 1515 | assert_eq!( 1516 | ::std::mem::size_of::(), 1517 | 16usize, 1518 | concat!("Size of: ", stringify!(vfio_iommu_type1_info)) 1519 | ); 1520 | assert_eq!( 1521 | ::std::mem::align_of::(), 1522 | 8usize, 1523 | concat!("Alignment of ", stringify!(vfio_iommu_type1_info)) 1524 | ); 1525 | assert_eq!( 1526 | unsafe { &(*(::std::ptr::null::())).argsz as *const _ as usize }, 1527 | 0usize, 1528 | concat!( 1529 | "Offset of field: ", 1530 | stringify!(vfio_iommu_type1_info), 1531 | "::", 1532 | stringify!(argsz) 1533 | ) 1534 | ); 1535 | assert_eq!( 1536 | unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, 1537 | 4usize, 1538 | concat!( 1539 | "Offset of field: ", 1540 | stringify!(vfio_iommu_type1_info), 1541 | "::", 1542 | stringify!(flags) 1543 | ) 1544 | ); 1545 | assert_eq!( 1546 | unsafe { 1547 | &(*(::std::ptr::null::())).iova_pgsizes as *const _ as usize 1548 | }, 1549 | 8usize, 1550 | concat!( 1551 | "Offset of field: ", 1552 | stringify!(vfio_iommu_type1_info), 1553 | "::", 1554 | stringify!(iova_pgsizes) 1555 | ) 1556 | ); 1557 | } 1558 | #[doc = " VFIO_IOMMU_MAP_DMA - _IOW(VFIO_TYPE, VFIO_BASE + 13, struct vfio_dma_map)"] 1559 | #[doc = ""] 1560 | #[doc = " Map process virtual addresses to IO virtual addresses using the"] 1561 | #[doc = " provided struct vfio_dma_map. Caller sets argsz. READ &/ WRITE required."] 1562 | #[repr(C)] 1563 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 1564 | pub struct vfio_iommu_type1_dma_map { 1565 | pub argsz: __u32, 1566 | pub flags: __u32, 1567 | pub vaddr: __u64, 1568 | pub iova: __u64, 1569 | pub size: __u64, 1570 | } 1571 | #[test] 1572 | fn bindgen_test_layout_vfio_iommu_type1_dma_map() { 1573 | assert_eq!( 1574 | ::std::mem::size_of::(), 1575 | 32usize, 1576 | concat!("Size of: ", stringify!(vfio_iommu_type1_dma_map)) 1577 | ); 1578 | assert_eq!( 1579 | ::std::mem::align_of::(), 1580 | 8usize, 1581 | concat!("Alignment of ", stringify!(vfio_iommu_type1_dma_map)) 1582 | ); 1583 | assert_eq!( 1584 | unsafe { &(*(::std::ptr::null::())).argsz as *const _ as usize }, 1585 | 0usize, 1586 | concat!( 1587 | "Offset of field: ", 1588 | stringify!(vfio_iommu_type1_dma_map), 1589 | "::", 1590 | stringify!(argsz) 1591 | ) 1592 | ); 1593 | assert_eq!( 1594 | unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, 1595 | 4usize, 1596 | concat!( 1597 | "Offset of field: ", 1598 | stringify!(vfio_iommu_type1_dma_map), 1599 | "::", 1600 | stringify!(flags) 1601 | ) 1602 | ); 1603 | assert_eq!( 1604 | unsafe { &(*(::std::ptr::null::())).vaddr as *const _ as usize }, 1605 | 8usize, 1606 | concat!( 1607 | "Offset of field: ", 1608 | stringify!(vfio_iommu_type1_dma_map), 1609 | "::", 1610 | stringify!(vaddr) 1611 | ) 1612 | ); 1613 | assert_eq!( 1614 | unsafe { &(*(::std::ptr::null::())).iova as *const _ as usize }, 1615 | 16usize, 1616 | concat!( 1617 | "Offset of field: ", 1618 | stringify!(vfio_iommu_type1_dma_map), 1619 | "::", 1620 | stringify!(iova) 1621 | ) 1622 | ); 1623 | assert_eq!( 1624 | unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, 1625 | 24usize, 1626 | concat!( 1627 | "Offset of field: ", 1628 | stringify!(vfio_iommu_type1_dma_map), 1629 | "::", 1630 | stringify!(size) 1631 | ) 1632 | ); 1633 | } 1634 | #[doc = " VFIO_IOMMU_UNMAP_DMA - _IOWR(VFIO_TYPE, VFIO_BASE + 14,"] 1635 | #[doc = "\t\t\t\t\t\t\tstruct vfio_dma_unmap)"] 1636 | #[doc = ""] 1637 | #[doc = " Unmap IO virtual addresses using the provided struct vfio_dma_unmap."] 1638 | #[doc = " Caller sets argsz. The actual unmapped size is returned in the size"] 1639 | #[doc = " field. No guarantee is made to the user that arbitrary unmaps of iova"] 1640 | #[doc = " or size different from those used in the original mapping call will"] 1641 | #[doc = " succeed."] 1642 | #[repr(C)] 1643 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 1644 | pub struct vfio_iommu_type1_dma_unmap { 1645 | pub argsz: __u32, 1646 | pub flags: __u32, 1647 | pub iova: __u64, 1648 | pub size: __u64, 1649 | } 1650 | #[test] 1651 | fn bindgen_test_layout_vfio_iommu_type1_dma_unmap() { 1652 | assert_eq!( 1653 | ::std::mem::size_of::(), 1654 | 24usize, 1655 | concat!("Size of: ", stringify!(vfio_iommu_type1_dma_unmap)) 1656 | ); 1657 | assert_eq!( 1658 | ::std::mem::align_of::(), 1659 | 8usize, 1660 | concat!("Alignment of ", stringify!(vfio_iommu_type1_dma_unmap)) 1661 | ); 1662 | assert_eq!( 1663 | unsafe { 1664 | &(*(::std::ptr::null::())).argsz as *const _ as usize 1665 | }, 1666 | 0usize, 1667 | concat!( 1668 | "Offset of field: ", 1669 | stringify!(vfio_iommu_type1_dma_unmap), 1670 | "::", 1671 | stringify!(argsz) 1672 | ) 1673 | ); 1674 | assert_eq!( 1675 | unsafe { 1676 | &(*(::std::ptr::null::())).flags as *const _ as usize 1677 | }, 1678 | 4usize, 1679 | concat!( 1680 | "Offset of field: ", 1681 | stringify!(vfio_iommu_type1_dma_unmap), 1682 | "::", 1683 | stringify!(flags) 1684 | ) 1685 | ); 1686 | assert_eq!( 1687 | unsafe { &(*(::std::ptr::null::())).iova as *const _ as usize }, 1688 | 8usize, 1689 | concat!( 1690 | "Offset of field: ", 1691 | stringify!(vfio_iommu_type1_dma_unmap), 1692 | "::", 1693 | stringify!(iova) 1694 | ) 1695 | ); 1696 | assert_eq!( 1697 | unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, 1698 | 16usize, 1699 | concat!( 1700 | "Offset of field: ", 1701 | stringify!(vfio_iommu_type1_dma_unmap), 1702 | "::", 1703 | stringify!(size) 1704 | ) 1705 | ); 1706 | } 1707 | #[repr(C)] 1708 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 1709 | pub struct vfio_iommu_spapr_tce_ddw_info { 1710 | pub pgsizes: __u64, 1711 | pub max_dynamic_windows_supported: __u32, 1712 | pub levels: __u32, 1713 | } 1714 | #[test] 1715 | fn bindgen_test_layout_vfio_iommu_spapr_tce_ddw_info() { 1716 | assert_eq!( 1717 | ::std::mem::size_of::(), 1718 | 16usize, 1719 | concat!("Size of: ", stringify!(vfio_iommu_spapr_tce_ddw_info)) 1720 | ); 1721 | assert_eq!( 1722 | ::std::mem::align_of::(), 1723 | 8usize, 1724 | concat!("Alignment of ", stringify!(vfio_iommu_spapr_tce_ddw_info)) 1725 | ); 1726 | assert_eq!( 1727 | unsafe { 1728 | &(*(::std::ptr::null::())).pgsizes as *const _ as usize 1729 | }, 1730 | 0usize, 1731 | concat!( 1732 | "Offset of field: ", 1733 | stringify!(vfio_iommu_spapr_tce_ddw_info), 1734 | "::", 1735 | stringify!(pgsizes) 1736 | ) 1737 | ); 1738 | assert_eq!( 1739 | unsafe { 1740 | &(*(::std::ptr::null::())).max_dynamic_windows_supported 1741 | as *const _ as usize 1742 | }, 1743 | 8usize, 1744 | concat!( 1745 | "Offset of field: ", 1746 | stringify!(vfio_iommu_spapr_tce_ddw_info), 1747 | "::", 1748 | stringify!(max_dynamic_windows_supported) 1749 | ) 1750 | ); 1751 | assert_eq!( 1752 | unsafe { 1753 | &(*(::std::ptr::null::())).levels as *const _ as usize 1754 | }, 1755 | 12usize, 1756 | concat!( 1757 | "Offset of field: ", 1758 | stringify!(vfio_iommu_spapr_tce_ddw_info), 1759 | "::", 1760 | stringify!(levels) 1761 | ) 1762 | ); 1763 | } 1764 | #[repr(C)] 1765 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 1766 | pub struct vfio_iommu_spapr_tce_info { 1767 | pub argsz: __u32, 1768 | pub flags: __u32, 1769 | pub dma32_window_start: __u32, 1770 | pub dma32_window_size: __u32, 1771 | pub ddw: vfio_iommu_spapr_tce_ddw_info, 1772 | } 1773 | #[test] 1774 | fn bindgen_test_layout_vfio_iommu_spapr_tce_info() { 1775 | assert_eq!( 1776 | ::std::mem::size_of::(), 1777 | 32usize, 1778 | concat!("Size of: ", stringify!(vfio_iommu_spapr_tce_info)) 1779 | ); 1780 | assert_eq!( 1781 | ::std::mem::align_of::(), 1782 | 8usize, 1783 | concat!("Alignment of ", stringify!(vfio_iommu_spapr_tce_info)) 1784 | ); 1785 | assert_eq!( 1786 | unsafe { &(*(::std::ptr::null::())).argsz as *const _ as usize }, 1787 | 0usize, 1788 | concat!( 1789 | "Offset of field: ", 1790 | stringify!(vfio_iommu_spapr_tce_info), 1791 | "::", 1792 | stringify!(argsz) 1793 | ) 1794 | ); 1795 | assert_eq!( 1796 | unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, 1797 | 4usize, 1798 | concat!( 1799 | "Offset of field: ", 1800 | stringify!(vfio_iommu_spapr_tce_info), 1801 | "::", 1802 | stringify!(flags) 1803 | ) 1804 | ); 1805 | assert_eq!( 1806 | unsafe { 1807 | &(*(::std::ptr::null::())).dma32_window_start as *const _ 1808 | as usize 1809 | }, 1810 | 8usize, 1811 | concat!( 1812 | "Offset of field: ", 1813 | stringify!(vfio_iommu_spapr_tce_info), 1814 | "::", 1815 | stringify!(dma32_window_start) 1816 | ) 1817 | ); 1818 | assert_eq!( 1819 | unsafe { 1820 | &(*(::std::ptr::null::())).dma32_window_size as *const _ 1821 | as usize 1822 | }, 1823 | 12usize, 1824 | concat!( 1825 | "Offset of field: ", 1826 | stringify!(vfio_iommu_spapr_tce_info), 1827 | "::", 1828 | stringify!(dma32_window_size) 1829 | ) 1830 | ); 1831 | assert_eq!( 1832 | unsafe { &(*(::std::ptr::null::())).ddw as *const _ as usize }, 1833 | 16usize, 1834 | concat!( 1835 | "Offset of field: ", 1836 | stringify!(vfio_iommu_spapr_tce_info), 1837 | "::", 1838 | stringify!(ddw) 1839 | ) 1840 | ); 1841 | } 1842 | #[repr(C)] 1843 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 1844 | pub struct vfio_eeh_pe_err { 1845 | pub type_: __u32, 1846 | pub func: __u32, 1847 | pub addr: __u64, 1848 | pub mask: __u64, 1849 | } 1850 | #[test] 1851 | fn bindgen_test_layout_vfio_eeh_pe_err() { 1852 | assert_eq!( 1853 | ::std::mem::size_of::(), 1854 | 24usize, 1855 | concat!("Size of: ", stringify!(vfio_eeh_pe_err)) 1856 | ); 1857 | assert_eq!( 1858 | ::std::mem::align_of::(), 1859 | 8usize, 1860 | concat!("Alignment of ", stringify!(vfio_eeh_pe_err)) 1861 | ); 1862 | assert_eq!( 1863 | unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, 1864 | 0usize, 1865 | concat!( 1866 | "Offset of field: ", 1867 | stringify!(vfio_eeh_pe_err), 1868 | "::", 1869 | stringify!(type_) 1870 | ) 1871 | ); 1872 | assert_eq!( 1873 | unsafe { &(*(::std::ptr::null::())).func as *const _ as usize }, 1874 | 4usize, 1875 | concat!( 1876 | "Offset of field: ", 1877 | stringify!(vfio_eeh_pe_err), 1878 | "::", 1879 | stringify!(func) 1880 | ) 1881 | ); 1882 | assert_eq!( 1883 | unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, 1884 | 8usize, 1885 | concat!( 1886 | "Offset of field: ", 1887 | stringify!(vfio_eeh_pe_err), 1888 | "::", 1889 | stringify!(addr) 1890 | ) 1891 | ); 1892 | assert_eq!( 1893 | unsafe { &(*(::std::ptr::null::())).mask as *const _ as usize }, 1894 | 16usize, 1895 | concat!( 1896 | "Offset of field: ", 1897 | stringify!(vfio_eeh_pe_err), 1898 | "::", 1899 | stringify!(mask) 1900 | ) 1901 | ); 1902 | } 1903 | #[repr(C)] 1904 | #[derive(Copy, Clone)] 1905 | pub struct vfio_eeh_pe_op { 1906 | pub argsz: __u32, 1907 | pub flags: __u32, 1908 | pub op: __u32, 1909 | pub __bindgen_anon_1: vfio_eeh_pe_op__bindgen_ty_1, 1910 | } 1911 | #[repr(C)] 1912 | #[derive(Copy, Clone)] 1913 | pub union vfio_eeh_pe_op__bindgen_ty_1 { 1914 | pub err: vfio_eeh_pe_err, 1915 | _bindgen_union_align: [u64; 3usize], 1916 | } 1917 | #[test] 1918 | fn bindgen_test_layout_vfio_eeh_pe_op__bindgen_ty_1() { 1919 | assert_eq!( 1920 | ::std::mem::size_of::(), 1921 | 24usize, 1922 | concat!("Size of: ", stringify!(vfio_eeh_pe_op__bindgen_ty_1)) 1923 | ); 1924 | assert_eq!( 1925 | ::std::mem::align_of::(), 1926 | 8usize, 1927 | concat!("Alignment of ", stringify!(vfio_eeh_pe_op__bindgen_ty_1)) 1928 | ); 1929 | assert_eq!( 1930 | unsafe { 1931 | &(*(::std::ptr::null::())).err as *const _ as usize 1932 | }, 1933 | 0usize, 1934 | concat!( 1935 | "Offset of field: ", 1936 | stringify!(vfio_eeh_pe_op__bindgen_ty_1), 1937 | "::", 1938 | stringify!(err) 1939 | ) 1940 | ); 1941 | } 1942 | impl Default for vfio_eeh_pe_op__bindgen_ty_1 { 1943 | fn default() -> Self { 1944 | unsafe { ::std::mem::zeroed() } 1945 | } 1946 | } 1947 | #[test] 1948 | fn bindgen_test_layout_vfio_eeh_pe_op() { 1949 | assert_eq!( 1950 | ::std::mem::size_of::(), 1951 | 40usize, 1952 | concat!("Size of: ", stringify!(vfio_eeh_pe_op)) 1953 | ); 1954 | assert_eq!( 1955 | ::std::mem::align_of::(), 1956 | 8usize, 1957 | concat!("Alignment of ", stringify!(vfio_eeh_pe_op)) 1958 | ); 1959 | assert_eq!( 1960 | unsafe { &(*(::std::ptr::null::())).argsz as *const _ as usize }, 1961 | 0usize, 1962 | concat!( 1963 | "Offset of field: ", 1964 | stringify!(vfio_eeh_pe_op), 1965 | "::", 1966 | stringify!(argsz) 1967 | ) 1968 | ); 1969 | assert_eq!( 1970 | unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, 1971 | 4usize, 1972 | concat!( 1973 | "Offset of field: ", 1974 | stringify!(vfio_eeh_pe_op), 1975 | "::", 1976 | stringify!(flags) 1977 | ) 1978 | ); 1979 | assert_eq!( 1980 | unsafe { &(*(::std::ptr::null::())).op as *const _ as usize }, 1981 | 8usize, 1982 | concat!( 1983 | "Offset of field: ", 1984 | stringify!(vfio_eeh_pe_op), 1985 | "::", 1986 | stringify!(op) 1987 | ) 1988 | ); 1989 | } 1990 | impl Default for vfio_eeh_pe_op { 1991 | fn default() -> Self { 1992 | unsafe { ::std::mem::zeroed() } 1993 | } 1994 | } 1995 | #[doc = " VFIO_IOMMU_SPAPR_REGISTER_MEMORY - _IOW(VFIO_TYPE, VFIO_BASE + 17, struct vfio_iommu_spapr_register_memory)"] 1996 | #[doc = ""] 1997 | #[doc = " Registers user space memory where DMA is allowed. It pins"] 1998 | #[doc = " user pages and does the locked memory accounting so"] 1999 | #[doc = " subsequent VFIO_IOMMU_MAP_DMA/VFIO_IOMMU_UNMAP_DMA calls"] 2000 | #[doc = " get faster."] 2001 | #[repr(C)] 2002 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 2003 | pub struct vfio_iommu_spapr_register_memory { 2004 | pub argsz: __u32, 2005 | pub flags: __u32, 2006 | pub vaddr: __u64, 2007 | pub size: __u64, 2008 | } 2009 | #[test] 2010 | fn bindgen_test_layout_vfio_iommu_spapr_register_memory() { 2011 | assert_eq!( 2012 | ::std::mem::size_of::(), 2013 | 24usize, 2014 | concat!("Size of: ", stringify!(vfio_iommu_spapr_register_memory)) 2015 | ); 2016 | assert_eq!( 2017 | ::std::mem::align_of::(), 2018 | 8usize, 2019 | concat!( 2020 | "Alignment of ", 2021 | stringify!(vfio_iommu_spapr_register_memory) 2022 | ) 2023 | ); 2024 | assert_eq!( 2025 | unsafe { 2026 | &(*(::std::ptr::null::())).argsz as *const _ as usize 2027 | }, 2028 | 0usize, 2029 | concat!( 2030 | "Offset of field: ", 2031 | stringify!(vfio_iommu_spapr_register_memory), 2032 | "::", 2033 | stringify!(argsz) 2034 | ) 2035 | ); 2036 | assert_eq!( 2037 | unsafe { 2038 | &(*(::std::ptr::null::())).flags as *const _ as usize 2039 | }, 2040 | 4usize, 2041 | concat!( 2042 | "Offset of field: ", 2043 | stringify!(vfio_iommu_spapr_register_memory), 2044 | "::", 2045 | stringify!(flags) 2046 | ) 2047 | ); 2048 | assert_eq!( 2049 | unsafe { 2050 | &(*(::std::ptr::null::())).vaddr as *const _ as usize 2051 | }, 2052 | 8usize, 2053 | concat!( 2054 | "Offset of field: ", 2055 | stringify!(vfio_iommu_spapr_register_memory), 2056 | "::", 2057 | stringify!(vaddr) 2058 | ) 2059 | ); 2060 | assert_eq!( 2061 | unsafe { 2062 | &(*(::std::ptr::null::())).size as *const _ as usize 2063 | }, 2064 | 16usize, 2065 | concat!( 2066 | "Offset of field: ", 2067 | stringify!(vfio_iommu_spapr_register_memory), 2068 | "::", 2069 | stringify!(size) 2070 | ) 2071 | ); 2072 | } 2073 | #[doc = " VFIO_IOMMU_SPAPR_TCE_CREATE - _IOWR(VFIO_TYPE, VFIO_BASE + 19, struct vfio_iommu_spapr_tce_create)"] 2074 | #[doc = ""] 2075 | #[doc = " Creates an additional TCE table and programs it (sets a new DMA window)"] 2076 | #[doc = " to every IOMMU group in the container. It receives page shift, window"] 2077 | #[doc = " size and number of levels in the TCE table being created."] 2078 | #[doc = ""] 2079 | #[doc = " It allocates and returns an offset on a PCI bus of the new DMA window."] 2080 | #[repr(C)] 2081 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 2082 | pub struct vfio_iommu_spapr_tce_create { 2083 | pub argsz: __u32, 2084 | pub flags: __u32, 2085 | pub page_shift: __u32, 2086 | pub __resv1: __u32, 2087 | pub window_size: __u64, 2088 | pub levels: __u32, 2089 | pub __resv2: __u32, 2090 | pub start_addr: __u64, 2091 | } 2092 | #[test] 2093 | fn bindgen_test_layout_vfio_iommu_spapr_tce_create() { 2094 | assert_eq!( 2095 | ::std::mem::size_of::(), 2096 | 40usize, 2097 | concat!("Size of: ", stringify!(vfio_iommu_spapr_tce_create)) 2098 | ); 2099 | assert_eq!( 2100 | ::std::mem::align_of::(), 2101 | 8usize, 2102 | concat!("Alignment of ", stringify!(vfio_iommu_spapr_tce_create)) 2103 | ); 2104 | assert_eq!( 2105 | unsafe { 2106 | &(*(::std::ptr::null::())).argsz as *const _ as usize 2107 | }, 2108 | 0usize, 2109 | concat!( 2110 | "Offset of field: ", 2111 | stringify!(vfio_iommu_spapr_tce_create), 2112 | "::", 2113 | stringify!(argsz) 2114 | ) 2115 | ); 2116 | assert_eq!( 2117 | unsafe { 2118 | &(*(::std::ptr::null::())).flags as *const _ as usize 2119 | }, 2120 | 4usize, 2121 | concat!( 2122 | "Offset of field: ", 2123 | stringify!(vfio_iommu_spapr_tce_create), 2124 | "::", 2125 | stringify!(flags) 2126 | ) 2127 | ); 2128 | assert_eq!( 2129 | unsafe { 2130 | &(*(::std::ptr::null::())).page_shift as *const _ as usize 2131 | }, 2132 | 8usize, 2133 | concat!( 2134 | "Offset of field: ", 2135 | stringify!(vfio_iommu_spapr_tce_create), 2136 | "::", 2137 | stringify!(page_shift) 2138 | ) 2139 | ); 2140 | assert_eq!( 2141 | unsafe { 2142 | &(*(::std::ptr::null::())).__resv1 as *const _ as usize 2143 | }, 2144 | 12usize, 2145 | concat!( 2146 | "Offset of field: ", 2147 | stringify!(vfio_iommu_spapr_tce_create), 2148 | "::", 2149 | stringify!(__resv1) 2150 | ) 2151 | ); 2152 | assert_eq!( 2153 | unsafe { 2154 | &(*(::std::ptr::null::())).window_size as *const _ as usize 2155 | }, 2156 | 16usize, 2157 | concat!( 2158 | "Offset of field: ", 2159 | stringify!(vfio_iommu_spapr_tce_create), 2160 | "::", 2161 | stringify!(window_size) 2162 | ) 2163 | ); 2164 | assert_eq!( 2165 | unsafe { 2166 | &(*(::std::ptr::null::())).levels as *const _ as usize 2167 | }, 2168 | 24usize, 2169 | concat!( 2170 | "Offset of field: ", 2171 | stringify!(vfio_iommu_spapr_tce_create), 2172 | "::", 2173 | stringify!(levels) 2174 | ) 2175 | ); 2176 | assert_eq!( 2177 | unsafe { 2178 | &(*(::std::ptr::null::())).__resv2 as *const _ as usize 2179 | }, 2180 | 28usize, 2181 | concat!( 2182 | "Offset of field: ", 2183 | stringify!(vfio_iommu_spapr_tce_create), 2184 | "::", 2185 | stringify!(__resv2) 2186 | ) 2187 | ); 2188 | assert_eq!( 2189 | unsafe { 2190 | &(*(::std::ptr::null::())).start_addr as *const _ as usize 2191 | }, 2192 | 32usize, 2193 | concat!( 2194 | "Offset of field: ", 2195 | stringify!(vfio_iommu_spapr_tce_create), 2196 | "::", 2197 | stringify!(start_addr) 2198 | ) 2199 | ); 2200 | } 2201 | #[doc = " VFIO_IOMMU_SPAPR_TCE_REMOVE - _IOW(VFIO_TYPE, VFIO_BASE + 20, struct vfio_iommu_spapr_tce_remove)"] 2202 | #[doc = ""] 2203 | #[doc = " Unprograms a TCE table from all groups in the container and destroys it."] 2204 | #[doc = " It receives a PCI bus offset as a window id."] 2205 | #[repr(C)] 2206 | #[derive(Debug, Default, Copy, Clone, PartialEq)] 2207 | pub struct vfio_iommu_spapr_tce_remove { 2208 | pub argsz: __u32, 2209 | pub flags: __u32, 2210 | pub start_addr: __u64, 2211 | } 2212 | #[test] 2213 | fn bindgen_test_layout_vfio_iommu_spapr_tce_remove() { 2214 | assert_eq!( 2215 | ::std::mem::size_of::(), 2216 | 16usize, 2217 | concat!("Size of: ", stringify!(vfio_iommu_spapr_tce_remove)) 2218 | ); 2219 | assert_eq!( 2220 | ::std::mem::align_of::(), 2221 | 8usize, 2222 | concat!("Alignment of ", stringify!(vfio_iommu_spapr_tce_remove)) 2223 | ); 2224 | assert_eq!( 2225 | unsafe { 2226 | &(*(::std::ptr::null::())).argsz as *const _ as usize 2227 | }, 2228 | 0usize, 2229 | concat!( 2230 | "Offset of field: ", 2231 | stringify!(vfio_iommu_spapr_tce_remove), 2232 | "::", 2233 | stringify!(argsz) 2234 | ) 2235 | ); 2236 | assert_eq!( 2237 | unsafe { 2238 | &(*(::std::ptr::null::())).flags as *const _ as usize 2239 | }, 2240 | 4usize, 2241 | concat!( 2242 | "Offset of field: ", 2243 | stringify!(vfio_iommu_spapr_tce_remove), 2244 | "::", 2245 | stringify!(flags) 2246 | ) 2247 | ); 2248 | assert_eq!( 2249 | unsafe { 2250 | &(*(::std::ptr::null::())).start_addr as *const _ as usize 2251 | }, 2252 | 8usize, 2253 | concat!( 2254 | "Offset of field: ", 2255 | stringify!(vfio_iommu_spapr_tce_remove), 2256 | "::", 2257 | stringify!(start_addr) 2258 | ) 2259 | ); 2260 | } 2261 | --------------------------------------------------------------------------------