1 /* automatically generated by tools/bindgen-all-the-things */ 2 3 #![allow(clippy::missing_safety_doc)] 4 #![allow(clippy::undocumented_unsafe_blocks)] 5 #![allow(clippy::upper_case_acronyms)] 6 #![allow(non_upper_case_globals)] 7 #![allow(non_camel_case_types)] 8 #![allow(non_snake_case)] 9 #![allow(dead_code)] 10 11 // Added by virtio_sys/bindgen.sh 12 use zerocopy::FromBytes; 13 use zerocopy::Immutable; 14 use zerocopy::IntoBytes; 15 use zerocopy::KnownLayout; 16 17 #[repr(C)] 18 #[derive(Default)] 19 pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]); 20 impl<T> __IncompleteArrayField<T> { 21 #[inline] new() -> Self22 pub const fn new() -> Self { 23 __IncompleteArrayField(::std::marker::PhantomData, []) 24 } 25 #[inline] as_ptr(&self) -> *const T26 pub fn as_ptr(&self) -> *const T { 27 self as *const _ as *const T 28 } 29 #[inline] as_mut_ptr(&mut self) -> *mut T30 pub fn as_mut_ptr(&mut self) -> *mut T { 31 self as *mut _ as *mut T 32 } 33 #[inline] as_slice(&self, len: usize) -> &[T]34 pub unsafe fn as_slice(&self, len: usize) -> &[T] { 35 ::std::slice::from_raw_parts(self.as_ptr(), len) 36 } 37 #[inline] as_mut_slice(&mut self, len: usize) -> &mut [T]38 pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { 39 ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) 40 } 41 } 42 impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> { fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result43 fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 44 fmt.write_str("__IncompleteArrayField") 45 } 46 } 47 pub const VIRTIO_NET_F_CSUM: u32 = 0; 48 pub const VIRTIO_NET_F_GUEST_CSUM: u32 = 1; 49 pub const VIRTIO_NET_F_CTRL_GUEST_OFFLOADS: u32 = 2; 50 pub const VIRTIO_NET_F_MTU: u32 = 3; 51 pub const VIRTIO_NET_F_MAC: u32 = 5; 52 pub const VIRTIO_NET_F_GUEST_TSO4: u32 = 7; 53 pub const VIRTIO_NET_F_GUEST_TSO6: u32 = 8; 54 pub const VIRTIO_NET_F_GUEST_ECN: u32 = 9; 55 pub const VIRTIO_NET_F_GUEST_UFO: u32 = 10; 56 pub const VIRTIO_NET_F_HOST_TSO4: u32 = 11; 57 pub const VIRTIO_NET_F_HOST_TSO6: u32 = 12; 58 pub const VIRTIO_NET_F_HOST_ECN: u32 = 13; 59 pub const VIRTIO_NET_F_HOST_UFO: u32 = 14; 60 pub const VIRTIO_NET_F_MRG_RXBUF: u32 = 15; 61 pub const VIRTIO_NET_F_STATUS: u32 = 16; 62 pub const VIRTIO_NET_F_CTRL_VQ: u32 = 17; 63 pub const VIRTIO_NET_F_CTRL_RX: u32 = 18; 64 pub const VIRTIO_NET_F_CTRL_VLAN: u32 = 19; 65 pub const VIRTIO_NET_F_CTRL_RX_EXTRA: u32 = 20; 66 pub const VIRTIO_NET_F_GUEST_ANNOUNCE: u32 = 21; 67 pub const VIRTIO_NET_F_MQ: u32 = 22; 68 pub const VIRTIO_NET_F_CTRL_MAC_ADDR: u32 = 23; 69 pub const VIRTIO_NET_F_DEVICE_STATS: u32 = 50; 70 pub const VIRTIO_NET_F_VQ_NOTF_COAL: u32 = 52; 71 pub const VIRTIO_NET_F_NOTF_COAL: u32 = 53; 72 pub const VIRTIO_NET_F_GUEST_USO4: u32 = 54; 73 pub const VIRTIO_NET_F_GUEST_USO6: u32 = 55; 74 pub const VIRTIO_NET_F_HOST_USO: u32 = 56; 75 pub const VIRTIO_NET_F_HASH_REPORT: u32 = 57; 76 pub const VIRTIO_NET_F_GUEST_HDRLEN: u32 = 59; 77 pub const VIRTIO_NET_F_RSS: u32 = 60; 78 pub const VIRTIO_NET_F_RSC_EXT: u32 = 61; 79 pub const VIRTIO_NET_F_STANDBY: u32 = 62; 80 pub const VIRTIO_NET_F_SPEED_DUPLEX: u32 = 63; 81 pub const VIRTIO_NET_F_GSO: u32 = 6; 82 pub const VIRTIO_NET_S_LINK_UP: u32 = 1; 83 pub const VIRTIO_NET_S_ANNOUNCE: u32 = 2; 84 pub const VIRTIO_NET_RSS_HASH_TYPE_IPv4: u32 = 1; 85 pub const VIRTIO_NET_RSS_HASH_TYPE_TCPv4: u32 = 2; 86 pub const VIRTIO_NET_RSS_HASH_TYPE_UDPv4: u32 = 4; 87 pub const VIRTIO_NET_RSS_HASH_TYPE_IPv6: u32 = 8; 88 pub const VIRTIO_NET_RSS_HASH_TYPE_TCPv6: u32 = 16; 89 pub const VIRTIO_NET_RSS_HASH_TYPE_UDPv6: u32 = 32; 90 pub const VIRTIO_NET_RSS_HASH_TYPE_IP_EX: u32 = 64; 91 pub const VIRTIO_NET_RSS_HASH_TYPE_TCP_EX: u32 = 128; 92 pub const VIRTIO_NET_RSS_HASH_TYPE_UDP_EX: u32 = 256; 93 pub const VIRTIO_NET_HDR_F_NEEDS_CSUM: u32 = 1; 94 pub const VIRTIO_NET_HDR_F_DATA_VALID: u32 = 2; 95 pub const VIRTIO_NET_HDR_F_RSC_INFO: u32 = 4; 96 pub const VIRTIO_NET_HDR_GSO_NONE: u32 = 0; 97 pub const VIRTIO_NET_HDR_GSO_TCPV4: u32 = 1; 98 pub const VIRTIO_NET_HDR_GSO_UDP: u32 = 3; 99 pub const VIRTIO_NET_HDR_GSO_TCPV6: u32 = 4; 100 pub const VIRTIO_NET_HDR_GSO_UDP_L4: u32 = 5; 101 pub const VIRTIO_NET_HDR_GSO_ECN: u32 = 128; 102 pub const VIRTIO_NET_HASH_REPORT_NONE: u32 = 0; 103 pub const VIRTIO_NET_HASH_REPORT_IPv4: u32 = 1; 104 pub const VIRTIO_NET_HASH_REPORT_TCPv4: u32 = 2; 105 pub const VIRTIO_NET_HASH_REPORT_UDPv4: u32 = 3; 106 pub const VIRTIO_NET_HASH_REPORT_IPv6: u32 = 4; 107 pub const VIRTIO_NET_HASH_REPORT_TCPv6: u32 = 5; 108 pub const VIRTIO_NET_HASH_REPORT_UDPv6: u32 = 6; 109 pub const VIRTIO_NET_HASH_REPORT_IPv6_EX: u32 = 7; 110 pub const VIRTIO_NET_HASH_REPORT_TCPv6_EX: u32 = 8; 111 pub const VIRTIO_NET_HASH_REPORT_UDPv6_EX: u32 = 9; 112 pub const VIRTIO_NET_OK: u32 = 0; 113 pub const VIRTIO_NET_ERR: u32 = 1; 114 pub const VIRTIO_NET_CTRL_RX: u32 = 0; 115 pub const VIRTIO_NET_CTRL_RX_PROMISC: u32 = 0; 116 pub const VIRTIO_NET_CTRL_RX_ALLMULTI: u32 = 1; 117 pub const VIRTIO_NET_CTRL_RX_ALLUNI: u32 = 2; 118 pub const VIRTIO_NET_CTRL_RX_NOMULTI: u32 = 3; 119 pub const VIRTIO_NET_CTRL_RX_NOUNI: u32 = 4; 120 pub const VIRTIO_NET_CTRL_RX_NOBCAST: u32 = 5; 121 pub const VIRTIO_NET_CTRL_MAC: u32 = 1; 122 pub const VIRTIO_NET_CTRL_MAC_TABLE_SET: u32 = 0; 123 pub const VIRTIO_NET_CTRL_MAC_ADDR_SET: u32 = 1; 124 pub const VIRTIO_NET_CTRL_VLAN: u32 = 2; 125 pub const VIRTIO_NET_CTRL_VLAN_ADD: u32 = 0; 126 pub const VIRTIO_NET_CTRL_VLAN_DEL: u32 = 1; 127 pub const VIRTIO_NET_CTRL_ANNOUNCE: u32 = 3; 128 pub const VIRTIO_NET_CTRL_ANNOUNCE_ACK: u32 = 0; 129 pub const VIRTIO_NET_CTRL_MQ: u32 = 4; 130 pub const VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET: u32 = 0; 131 pub const VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN: u32 = 1; 132 pub const VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX: u32 = 32768; 133 pub const VIRTIO_NET_CTRL_MQ_RSS_CONFIG: u32 = 1; 134 pub const VIRTIO_NET_CTRL_MQ_HASH_CONFIG: u32 = 2; 135 pub const VIRTIO_NET_CTRL_GUEST_OFFLOADS: u32 = 5; 136 pub const VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET: u32 = 0; 137 pub const VIRTIO_NET_CTRL_NOTF_COAL: u32 = 6; 138 pub const VIRTIO_NET_CTRL_NOTF_COAL_TX_SET: u32 = 0; 139 pub const VIRTIO_NET_CTRL_NOTF_COAL_RX_SET: u32 = 1; 140 pub const VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET: u32 = 2; 141 pub const VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET: u32 = 3; 142 pub const VIRTIO_NET_CTRL_STATS: u32 = 8; 143 pub const VIRTIO_NET_CTRL_STATS_QUERY: u32 = 0; 144 pub const VIRTIO_NET_CTRL_STATS_GET: u32 = 1; 145 pub const VIRTIO_NET_STATS_TYPE_CVQ: u64 = 4294967296; 146 pub const VIRTIO_NET_STATS_TYPE_RX_BASIC: u32 = 1; 147 pub const VIRTIO_NET_STATS_TYPE_RX_CSUM: u32 = 2; 148 pub const VIRTIO_NET_STATS_TYPE_RX_GSO: u32 = 4; 149 pub const VIRTIO_NET_STATS_TYPE_RX_SPEED: u32 = 8; 150 pub const VIRTIO_NET_STATS_TYPE_TX_BASIC: u32 = 65536; 151 pub const VIRTIO_NET_STATS_TYPE_TX_CSUM: u32 = 131072; 152 pub const VIRTIO_NET_STATS_TYPE_TX_GSO: u32 = 262144; 153 pub const VIRTIO_NET_STATS_TYPE_TX_SPEED: u32 = 524288; 154 pub const VIRTIO_NET_STATS_TYPE_REPLY_CVQ: u32 = 32; 155 pub const VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC: u32 = 0; 156 pub const VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM: u32 = 1; 157 pub const VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO: u32 = 2; 158 pub const VIRTIO_NET_STATS_TYPE_REPLY_RX_SPEED: u32 = 3; 159 pub const VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC: u32 = 16; 160 pub const VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM: u32 = 17; 161 pub const VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO: u32 = 18; 162 pub const VIRTIO_NET_STATS_TYPE_REPLY_TX_SPEED: u32 = 19; 163 pub type __le16 = u16; 164 pub type __le32 = u32; 165 pub type __le64 = u64; 166 pub type __virtio16 = u16; 167 pub type __virtio32 = u32; 168 #[repr(C, packed)] 169 #[derive(Debug, Default, Copy, Clone)] 170 pub struct virtio_net_config { 171 pub mac: [u8; 6usize], 172 pub status: __virtio16, 173 pub max_virtqueue_pairs: __virtio16, 174 pub mtu: __virtio16, 175 pub speed: __le32, 176 pub duplex: u8, 177 pub rss_max_key_size: u8, 178 pub rss_max_indirection_table_length: __le16, 179 pub supported_hash_types: __le32, 180 } 181 #[repr(C)] 182 #[derive(Copy, Clone)] 183 pub struct virtio_net_hdr_v1 { 184 pub flags: u8, 185 pub gso_type: u8, 186 pub hdr_len: __virtio16, 187 pub gso_size: __virtio16, 188 pub __bindgen_anon_1: virtio_net_hdr_v1__bindgen_ty_1, 189 pub num_buffers: __virtio16, 190 } 191 #[repr(C)] 192 #[derive(Copy, Clone)] 193 pub union virtio_net_hdr_v1__bindgen_ty_1 { 194 pub __bindgen_anon_1: virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_1, 195 pub csum: virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_2, 196 pub rsc: virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_3, 197 } 198 #[repr(C)] 199 #[derive(Debug, Default, Copy, Clone)] 200 pub struct virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_1 { 201 pub csum_start: __virtio16, 202 pub csum_offset: __virtio16, 203 } 204 #[repr(C)] 205 #[derive(Debug, Default, Copy, Clone)] 206 pub struct virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_2 { 207 pub start: __virtio16, 208 pub offset: __virtio16, 209 } 210 #[repr(C)] 211 #[derive(Debug, Default, Copy, Clone)] 212 pub struct virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_3 { 213 pub segments: __le16, 214 pub dup_acks: __le16, 215 } 216 impl Default for virtio_net_hdr_v1__bindgen_ty_1 { default() -> Self217 fn default() -> Self { 218 let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); 219 unsafe { 220 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); 221 s.assume_init() 222 } 223 } 224 } 225 impl Default for virtio_net_hdr_v1 { default() -> Self226 fn default() -> Self { 227 let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); 228 unsafe { 229 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); 230 s.assume_init() 231 } 232 } 233 } 234 #[repr(C)] 235 #[derive(Copy, Clone)] 236 pub struct virtio_net_hdr_v1_hash { 237 pub hdr: virtio_net_hdr_v1, 238 pub hash_value: __le32, 239 pub hash_report: __le16, 240 pub padding: __le16, 241 } 242 impl Default for virtio_net_hdr_v1_hash { default() -> Self243 fn default() -> Self { 244 let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); 245 unsafe { 246 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); 247 s.assume_init() 248 } 249 } 250 } 251 #[repr(C)] 252 #[derive(Debug, Default, Copy, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] 253 pub struct virtio_net_hdr { 254 pub flags: u8, 255 pub gso_type: u8, 256 pub hdr_len: __virtio16, 257 pub gso_size: __virtio16, 258 pub csum_start: __virtio16, 259 pub csum_offset: __virtio16, 260 } 261 #[repr(C)] 262 #[derive(Debug, Default, Copy, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] 263 pub struct virtio_net_hdr_mrg_rxbuf { 264 pub hdr: virtio_net_hdr, 265 pub num_buffers: __virtio16, 266 } 267 #[repr(C, packed)] 268 #[derive(Debug, Default, Copy, Clone)] 269 pub struct virtio_net_ctrl_hdr { 270 pub class: u8, 271 pub cmd: u8, 272 } 273 pub type virtio_net_ctrl_ack = u8; 274 #[repr(C)] 275 #[derive(Debug, Default, Copy, Clone)] 276 pub struct virtio_net_ctrl_mq { 277 pub virtqueue_pairs: __virtio16, 278 } 279 #[repr(C)] 280 #[derive(Debug, Default)] 281 pub struct virtio_net_rss_config { 282 pub hash_types: __le32, 283 pub indirection_table_mask: __le16, 284 pub unclassified_queue: __le16, 285 pub indirection_table: [__le16; 1usize], 286 pub max_tx_vq: __le16, 287 pub hash_key_length: u8, 288 pub hash_key_data: __IncompleteArrayField<u8>, 289 } 290 #[repr(C)] 291 #[derive(Debug, Default)] 292 pub struct virtio_net_hash_config { 293 pub hash_types: __le32, 294 pub reserved: [__le16; 4usize], 295 pub hash_key_length: u8, 296 pub hash_key_data: __IncompleteArrayField<u8>, 297 } 298 #[repr(C)] 299 #[derive(Debug, Default, Copy, Clone)] 300 pub struct virtio_net_ctrl_coal_tx { 301 pub tx_max_packets: __le32, 302 pub tx_usecs: __le32, 303 } 304 #[repr(C)] 305 #[derive(Debug, Default, Copy, Clone)] 306 pub struct virtio_net_ctrl_coal_rx { 307 pub rx_max_packets: __le32, 308 pub rx_usecs: __le32, 309 } 310 #[repr(C)] 311 #[derive(Debug, Default, Copy, Clone)] 312 pub struct virtio_net_ctrl_coal { 313 pub max_packets: __le32, 314 pub max_usecs: __le32, 315 } 316 #[repr(C)] 317 #[derive(Debug, Default, Copy, Clone)] 318 pub struct virtio_net_ctrl_coal_vq { 319 pub vqn: __le16, 320 pub reserved: __le16, 321 pub coal: virtio_net_ctrl_coal, 322 } 323 #[repr(C)] 324 #[derive(Debug, Default, Copy, Clone)] 325 pub struct virtio_net_stats_capabilities { 326 pub supported_stats_types: [__le64; 1usize], 327 } 328 #[repr(C)] 329 #[derive(Debug, Default, Copy, Clone)] 330 pub struct virtio_net_ctrl_queue_stats { 331 pub stats: [virtio_net_ctrl_queue_stats__bindgen_ty_1; 1usize], 332 } 333 #[repr(C)] 334 #[derive(Debug, Default, Copy, Clone)] 335 pub struct virtio_net_ctrl_queue_stats__bindgen_ty_1 { 336 pub vq_index: __le16, 337 pub reserved: [__le16; 3usize], 338 pub types_bitmap: [__le64; 1usize], 339 } 340 #[repr(C)] 341 #[derive(Debug, Default, Copy, Clone)] 342 pub struct virtio_net_stats_reply_hdr { 343 pub type_: u8, 344 pub reserved: u8, 345 pub vq_index: __le16, 346 pub reserved1: __le16, 347 pub size: __le16, 348 } 349 #[repr(C)] 350 #[derive(Debug, Default, Copy, Clone)] 351 pub struct virtio_net_stats_cvq { 352 pub hdr: virtio_net_stats_reply_hdr, 353 pub command_num: __le64, 354 pub ok_num: __le64, 355 } 356 #[repr(C)] 357 #[derive(Debug, Default, Copy, Clone)] 358 pub struct virtio_net_stats_rx_basic { 359 pub hdr: virtio_net_stats_reply_hdr, 360 pub rx_notifications: __le64, 361 pub rx_packets: __le64, 362 pub rx_bytes: __le64, 363 pub rx_interrupts: __le64, 364 pub rx_drops: __le64, 365 pub rx_drop_overruns: __le64, 366 } 367 #[repr(C)] 368 #[derive(Debug, Default, Copy, Clone)] 369 pub struct virtio_net_stats_tx_basic { 370 pub hdr: virtio_net_stats_reply_hdr, 371 pub tx_notifications: __le64, 372 pub tx_packets: __le64, 373 pub tx_bytes: __le64, 374 pub tx_interrupts: __le64, 375 pub tx_drops: __le64, 376 pub tx_drop_malformed: __le64, 377 } 378 #[repr(C)] 379 #[derive(Debug, Default, Copy, Clone)] 380 pub struct virtio_net_stats_rx_csum { 381 pub hdr: virtio_net_stats_reply_hdr, 382 pub rx_csum_valid: __le64, 383 pub rx_needs_csum: __le64, 384 pub rx_csum_none: __le64, 385 pub rx_csum_bad: __le64, 386 } 387 #[repr(C)] 388 #[derive(Debug, Default, Copy, Clone)] 389 pub struct virtio_net_stats_tx_csum { 390 pub hdr: virtio_net_stats_reply_hdr, 391 pub tx_csum_none: __le64, 392 pub tx_needs_csum: __le64, 393 } 394 #[repr(C)] 395 #[derive(Debug, Default, Copy, Clone)] 396 pub struct virtio_net_stats_rx_gso { 397 pub hdr: virtio_net_stats_reply_hdr, 398 pub rx_gso_packets: __le64, 399 pub rx_gso_bytes: __le64, 400 pub rx_gso_packets_coalesced: __le64, 401 pub rx_gso_bytes_coalesced: __le64, 402 } 403 #[repr(C)] 404 #[derive(Debug, Default, Copy, Clone)] 405 pub struct virtio_net_stats_tx_gso { 406 pub hdr: virtio_net_stats_reply_hdr, 407 pub tx_gso_packets: __le64, 408 pub tx_gso_bytes: __le64, 409 pub tx_gso_segments: __le64, 410 pub tx_gso_segments_bytes: __le64, 411 pub tx_gso_packets_noseg: __le64, 412 pub tx_gso_bytes_noseg: __le64, 413 } 414 #[repr(C)] 415 #[derive(Debug, Default, Copy, Clone)] 416 pub struct virtio_net_stats_rx_speed { 417 pub hdr: virtio_net_stats_reply_hdr, 418 pub rx_ratelimit_packets: __le64, 419 pub rx_ratelimit_bytes: __le64, 420 } 421 #[repr(C)] 422 #[derive(Debug, Default, Copy, Clone)] 423 pub struct virtio_net_stats_tx_speed { 424 pub hdr: virtio_net_stats_reply_hdr, 425 pub tx_ratelimit_packets: __le64, 426 pub tx_ratelimit_bytes: __le64, 427 } 428