virtio_sys/
virtio_net.rs

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
12use zerocopy::FromBytes;
13use zerocopy::Immutable;
14use zerocopy::IntoBytes;
15use zerocopy::KnownLayout;
16
17#[repr(C)]
18#[derive(Default)]
19pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
20impl<T> __IncompleteArrayField<T> {
21    #[inline]
22    pub const fn new() -> Self {
23        __IncompleteArrayField(::std::marker::PhantomData, [])
24    }
25    #[inline]
26    pub fn as_ptr(&self) -> *const T {
27        self as *const _ as *const T
28    }
29    #[inline]
30    pub fn as_mut_ptr(&mut self) -> *mut T {
31        self as *mut _ as *mut T
32    }
33    #[inline]
34    pub unsafe fn as_slice(&self, len: usize) -> &[T] {
35        ::std::slice::from_raw_parts(self.as_ptr(), len)
36    }
37    #[inline]
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}
42impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
43    fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
44        fmt.write_str("__IncompleteArrayField")
45    }
46}
47pub const VIRTIO_NET_F_CSUM: u32 = 0;
48pub const VIRTIO_NET_F_GUEST_CSUM: u32 = 1;
49pub const VIRTIO_NET_F_CTRL_GUEST_OFFLOADS: u32 = 2;
50pub const VIRTIO_NET_F_MTU: u32 = 3;
51pub const VIRTIO_NET_F_MAC: u32 = 5;
52pub const VIRTIO_NET_F_GUEST_TSO4: u32 = 7;
53pub const VIRTIO_NET_F_GUEST_TSO6: u32 = 8;
54pub const VIRTIO_NET_F_GUEST_ECN: u32 = 9;
55pub const VIRTIO_NET_F_GUEST_UFO: u32 = 10;
56pub const VIRTIO_NET_F_HOST_TSO4: u32 = 11;
57pub const VIRTIO_NET_F_HOST_TSO6: u32 = 12;
58pub const VIRTIO_NET_F_HOST_ECN: u32 = 13;
59pub const VIRTIO_NET_F_HOST_UFO: u32 = 14;
60pub const VIRTIO_NET_F_MRG_RXBUF: u32 = 15;
61pub const VIRTIO_NET_F_STATUS: u32 = 16;
62pub const VIRTIO_NET_F_CTRL_VQ: u32 = 17;
63pub const VIRTIO_NET_F_CTRL_RX: u32 = 18;
64pub const VIRTIO_NET_F_CTRL_VLAN: u32 = 19;
65pub const VIRTIO_NET_F_CTRL_RX_EXTRA: u32 = 20;
66pub const VIRTIO_NET_F_GUEST_ANNOUNCE: u32 = 21;
67pub const VIRTIO_NET_F_MQ: u32 = 22;
68pub const VIRTIO_NET_F_CTRL_MAC_ADDR: u32 = 23;
69pub const VIRTIO_NET_F_DEVICE_STATS: u32 = 50;
70pub const VIRTIO_NET_F_VQ_NOTF_COAL: u32 = 52;
71pub const VIRTIO_NET_F_NOTF_COAL: u32 = 53;
72pub const VIRTIO_NET_F_GUEST_USO4: u32 = 54;
73pub const VIRTIO_NET_F_GUEST_USO6: u32 = 55;
74pub const VIRTIO_NET_F_HOST_USO: u32 = 56;
75pub const VIRTIO_NET_F_HASH_REPORT: u32 = 57;
76pub const VIRTIO_NET_F_GUEST_HDRLEN: u32 = 59;
77pub const VIRTIO_NET_F_RSS: u32 = 60;
78pub const VIRTIO_NET_F_RSC_EXT: u32 = 61;
79pub const VIRTIO_NET_F_STANDBY: u32 = 62;
80pub const VIRTIO_NET_F_SPEED_DUPLEX: u32 = 63;
81pub const VIRTIO_NET_F_GSO: u32 = 6;
82pub const VIRTIO_NET_S_LINK_UP: u32 = 1;
83pub const VIRTIO_NET_S_ANNOUNCE: u32 = 2;
84pub const VIRTIO_NET_RSS_HASH_TYPE_IPv4: u32 = 1;
85pub const VIRTIO_NET_RSS_HASH_TYPE_TCPv4: u32 = 2;
86pub const VIRTIO_NET_RSS_HASH_TYPE_UDPv4: u32 = 4;
87pub const VIRTIO_NET_RSS_HASH_TYPE_IPv6: u32 = 8;
88pub const VIRTIO_NET_RSS_HASH_TYPE_TCPv6: u32 = 16;
89pub const VIRTIO_NET_RSS_HASH_TYPE_UDPv6: u32 = 32;
90pub const VIRTIO_NET_RSS_HASH_TYPE_IP_EX: u32 = 64;
91pub const VIRTIO_NET_RSS_HASH_TYPE_TCP_EX: u32 = 128;
92pub const VIRTIO_NET_RSS_HASH_TYPE_UDP_EX: u32 = 256;
93pub const VIRTIO_NET_HDR_F_NEEDS_CSUM: u32 = 1;
94pub const VIRTIO_NET_HDR_F_DATA_VALID: u32 = 2;
95pub const VIRTIO_NET_HDR_F_RSC_INFO: u32 = 4;
96pub const VIRTIO_NET_HDR_GSO_NONE: u32 = 0;
97pub const VIRTIO_NET_HDR_GSO_TCPV4: u32 = 1;
98pub const VIRTIO_NET_HDR_GSO_UDP: u32 = 3;
99pub const VIRTIO_NET_HDR_GSO_TCPV6: u32 = 4;
100pub const VIRTIO_NET_HDR_GSO_UDP_L4: u32 = 5;
101pub const VIRTIO_NET_HDR_GSO_ECN: u32 = 128;
102pub const VIRTIO_NET_HASH_REPORT_NONE: u32 = 0;
103pub const VIRTIO_NET_HASH_REPORT_IPv4: u32 = 1;
104pub const VIRTIO_NET_HASH_REPORT_TCPv4: u32 = 2;
105pub const VIRTIO_NET_HASH_REPORT_UDPv4: u32 = 3;
106pub const VIRTIO_NET_HASH_REPORT_IPv6: u32 = 4;
107pub const VIRTIO_NET_HASH_REPORT_TCPv6: u32 = 5;
108pub const VIRTIO_NET_HASH_REPORT_UDPv6: u32 = 6;
109pub const VIRTIO_NET_HASH_REPORT_IPv6_EX: u32 = 7;
110pub const VIRTIO_NET_HASH_REPORT_TCPv6_EX: u32 = 8;
111pub const VIRTIO_NET_HASH_REPORT_UDPv6_EX: u32 = 9;
112pub const VIRTIO_NET_OK: u32 = 0;
113pub const VIRTIO_NET_ERR: u32 = 1;
114pub const VIRTIO_NET_CTRL_RX: u32 = 0;
115pub const VIRTIO_NET_CTRL_RX_PROMISC: u32 = 0;
116pub const VIRTIO_NET_CTRL_RX_ALLMULTI: u32 = 1;
117pub const VIRTIO_NET_CTRL_RX_ALLUNI: u32 = 2;
118pub const VIRTIO_NET_CTRL_RX_NOMULTI: u32 = 3;
119pub const VIRTIO_NET_CTRL_RX_NOUNI: u32 = 4;
120pub const VIRTIO_NET_CTRL_RX_NOBCAST: u32 = 5;
121pub const VIRTIO_NET_CTRL_MAC: u32 = 1;
122pub const VIRTIO_NET_CTRL_MAC_TABLE_SET: u32 = 0;
123pub const VIRTIO_NET_CTRL_MAC_ADDR_SET: u32 = 1;
124pub const VIRTIO_NET_CTRL_VLAN: u32 = 2;
125pub const VIRTIO_NET_CTRL_VLAN_ADD: u32 = 0;
126pub const VIRTIO_NET_CTRL_VLAN_DEL: u32 = 1;
127pub const VIRTIO_NET_CTRL_ANNOUNCE: u32 = 3;
128pub const VIRTIO_NET_CTRL_ANNOUNCE_ACK: u32 = 0;
129pub const VIRTIO_NET_CTRL_MQ: u32 = 4;
130pub const VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET: u32 = 0;
131pub const VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN: u32 = 1;
132pub const VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX: u32 = 32768;
133pub const VIRTIO_NET_CTRL_MQ_RSS_CONFIG: u32 = 1;
134pub const VIRTIO_NET_CTRL_MQ_HASH_CONFIG: u32 = 2;
135pub const VIRTIO_NET_CTRL_GUEST_OFFLOADS: u32 = 5;
136pub const VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET: u32 = 0;
137pub const VIRTIO_NET_CTRL_NOTF_COAL: u32 = 6;
138pub const VIRTIO_NET_CTRL_NOTF_COAL_TX_SET: u32 = 0;
139pub const VIRTIO_NET_CTRL_NOTF_COAL_RX_SET: u32 = 1;
140pub const VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET: u32 = 2;
141pub const VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET: u32 = 3;
142pub const VIRTIO_NET_CTRL_STATS: u32 = 8;
143pub const VIRTIO_NET_CTRL_STATS_QUERY: u32 = 0;
144pub const VIRTIO_NET_CTRL_STATS_GET: u32 = 1;
145pub const VIRTIO_NET_STATS_TYPE_CVQ: u64 = 4294967296;
146pub const VIRTIO_NET_STATS_TYPE_RX_BASIC: u32 = 1;
147pub const VIRTIO_NET_STATS_TYPE_RX_CSUM: u32 = 2;
148pub const VIRTIO_NET_STATS_TYPE_RX_GSO: u32 = 4;
149pub const VIRTIO_NET_STATS_TYPE_RX_SPEED: u32 = 8;
150pub const VIRTIO_NET_STATS_TYPE_TX_BASIC: u32 = 65536;
151pub const VIRTIO_NET_STATS_TYPE_TX_CSUM: u32 = 131072;
152pub const VIRTIO_NET_STATS_TYPE_TX_GSO: u32 = 262144;
153pub const VIRTIO_NET_STATS_TYPE_TX_SPEED: u32 = 524288;
154pub const VIRTIO_NET_STATS_TYPE_REPLY_CVQ: u32 = 32;
155pub const VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC: u32 = 0;
156pub const VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM: u32 = 1;
157pub const VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO: u32 = 2;
158pub const VIRTIO_NET_STATS_TYPE_REPLY_RX_SPEED: u32 = 3;
159pub const VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC: u32 = 16;
160pub const VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM: u32 = 17;
161pub const VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO: u32 = 18;
162pub const VIRTIO_NET_STATS_TYPE_REPLY_TX_SPEED: u32 = 19;
163pub type __le16 = u16;
164pub type __le32 = u32;
165pub type __le64 = u64;
166pub type __virtio16 = u16;
167pub type __virtio32 = u32;
168#[repr(C, packed)]
169#[derive(Debug, Default, Copy, Clone)]
170pub 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)]
183pub 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)]
193pub 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)]
200pub 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)]
206pub 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)]
212pub struct virtio_net_hdr_v1__bindgen_ty_1__bindgen_ty_3 {
213    pub segments: __le16,
214    pub dup_acks: __le16,
215}
216impl Default for virtio_net_hdr_v1__bindgen_ty_1 {
217    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}
225impl Default for virtio_net_hdr_v1 {
226    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)]
236pub 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}
242impl Default for virtio_net_hdr_v1_hash {
243    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)]
253pub 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)]
263pub 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)]
269pub struct virtio_net_ctrl_hdr {
270    pub class: u8,
271    pub cmd: u8,
272}
273pub type virtio_net_ctrl_ack = u8;
274#[repr(C)]
275#[derive(Debug, Default, Copy, Clone)]
276pub struct virtio_net_ctrl_mq {
277    pub virtqueue_pairs: __virtio16,
278}
279#[repr(C)]
280#[derive(Debug, Default)]
281pub 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)]
292pub 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)]
300pub 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)]
306pub 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)]
312pub 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)]
318pub 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)]
325pub struct virtio_net_stats_capabilities {
326    pub supported_stats_types: [__le64; 1usize],
327}
328#[repr(C)]
329#[derive(Debug, Default, Copy, Clone)]
330pub 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)]
335pub 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)]
342pub 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)]
351pub 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)]
358pub 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)]
369pub 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)]
380pub 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)]
389pub 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)]
396pub 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)]
405pub 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)]
416pub 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)]
423pub 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}