virtio_sys/
virtio_net.rs

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