libc_extra/android_linux/linux/ethtool/
mod.rs

1// This file is part of libc-extra. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/libc-extra/master/COPYRIGHT. No part of libc-extra, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
2// Copyright © 2016-2018 The developers of libc-extra. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/libc-extra/master/COPYRIGHT.
3
4
5#![allow(non_camel_case_types)] 
6
7use ::std::default::Default;
8use ::std::mem::transmute;
9use ::std::mem::zeroed;
10use ::libc::c_char;
11use ::libc::c_uchar;
12use ::libc::c_uint;
13use ::libc::c_ulonglong;
14use ::libc::c_ushort;
15use ::libc::c_void;
16use ::libc::size_t;
17use ::libc::ssize_t;
18use ::android_linux::netinet::if_ether::ethhdr;
19
20
21include!("constants/ADVERTISED.rs");
22include!("constants/ETH_MDIO_SUPPORTS.rs");
23include!("constants/ETH_MODULE_SFF.rs");
24include!("constants/ETH_TP_MDI.rs");
25include!("constants/FLOW.rs");
26include!("constants/lengthsAndMaxima.rs");
27include!("constants/miscellany.rs");
28include!("constants/PORT.rs");
29include!("constants/RXH.rs");
30include!("constants/RX_CLS.rs");
31include!("constants/SPEED.rs");
32include!("constants/SUPPORTED.rs");
33include!("constants/WAKE.rs");
34include!("constants/XCVR.rs");
35
36include!("ethtool_cmd.rs");
37include!("ethtool_coalesce.rs");
38include!("ethtool_drvinfo.rs");
39include!("ethtool_flow_union.rs");
40include!("ethtool_ringparam.rs");
41include!("ethtool_rx_ntuple.rs");
42include!("ethtool_rx_ntuple_flow_spec.rs");
43include!("ethtool_value.rs");
44include!("ethtool_wolinfo.rs");
45
46
47#[repr(u32)]
48#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
49pub enum tunable_id
50{
51	ETHTOOL_ID_UNSPEC = 0,
52	ETHTOOL_RX_COPYBREAK = 1,
53	ETHTOOL_TX_COPYBREAK = 2,
54	__ETHTOOL_TUNABLE_COUNT = 3,
55}
56
57#[repr(u32)]
58#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
59pub enum tunable_type_id
60{
61	ETHTOOL_TUNABLE_UNSPEC = 0,
62	ETHTOOL_TUNABLE_U8 = 1,
63	ETHTOOL_TUNABLE_U16 = 2,
64	ETHTOOL_TUNABLE_U32 = 3,
65	ETHTOOL_TUNABLE_U64 = 4,
66	ETHTOOL_TUNABLE_STRING = 5,
67	ETHTOOL_TUNABLE_S8 = 6,
68	ETHTOOL_TUNABLE_S16 = 7,
69	ETHTOOL_TUNABLE_S32 = 8,
70	ETHTOOL_TUNABLE_S64 = 9,
71}
72
73#[repr(C)]
74#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
75pub struct ethtool_tunable
76{
77	pub cmd: u32,
78	pub id: u32,
79	pub type_id: u32,
80	pub len: u32,
81	pub data: [*mut c_void; 0],
82}
83
84impl Default for ethtool_tunable
85{
86	fn default() -> Self
87	{
88		unsafe { zeroed() }
89	}
90}
91
92#[repr(C)]
93#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
94pub struct ethtool_regs
95{
96	pub cmd: u32,
97	pub version: u32,
98	pub len: u32,
99	pub data: [u8; 0],
100}
101
102impl Default for ethtool_regs
103{
104	fn default() -> Self
105	{
106		unsafe { zeroed() }
107	}
108}
109
110#[repr(C)]
111#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
112pub struct ethtool_eeprom
113{
114	pub cmd: u32,
115	pub magic: u32,
116	pub offset: u32,
117	pub len: u32,
118	pub data: [u8; 0],
119}
120
121impl Default for ethtool_eeprom
122{
123	fn default() -> Self
124	{
125		unsafe { zeroed() }
126	}
127}
128
129#[repr(C)]
130#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
131pub struct ethtool_eee
132{
133	pub cmd: u32,
134	pub supported: u32,
135	pub advertised: u32,
136	pub lp_advertised: u32,
137	pub eee_active: u32,
138	pub eee_enabled: u32,
139	pub tx_lpi_enabled: u32,
140	pub tx_lpi_timer: u32,
141	pub reserved: [u32; 2],
142}
143
144impl Default for ethtool_eee
145{
146	fn default() -> Self
147	{
148		unsafe { zeroed() }
149	}
150}
151
152#[repr(C)]
153#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
154pub struct ethtool_modinfo
155{
156	pub cmd: u32,
157	pub type_: u32,
158	pub eeprom_len: u32,
159	pub reserved: [u32; 8],
160}
161
162impl Default for ethtool_modinfo
163{
164	fn default() -> Self
165	{
166		unsafe { zeroed() }
167	}
168}
169
170#[repr(C)]
171#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
172pub struct ethtool_channels
173{
174	pub cmd: u32,
175	pub max_rx: u32,
176	pub max_tx: u32,
177	pub max_other: u32,
178	pub max_combined: u32,
179	pub rx_count: u32,
180	pub tx_count: u32,
181	pub other_count: u32,
182	pub combined_count: u32,
183}
184
185impl Default for ethtool_channels
186{
187	fn default() -> Self
188	{
189		unsafe { zeroed() }
190	}
191}
192
193#[repr(C)]
194#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
195pub struct ethtool_pauseparam
196{
197	pub cmd: u32,
198	pub autoneg: u32,
199	pub rx_pause: u32,
200	pub tx_pause: u32,
201}
202
203impl Default for ethtool_pauseparam
204{
205	fn default() -> Self
206	{
207		unsafe { zeroed() }
208	}
209}
210
211#[repr(u32)]
212#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
213pub enum ethtool_stringset
214{
215	ETH_SS_TEST = 0,
216	ETH_SS_STATS = 1,
217	ETH_SS_PRIV_FLAGS = 2,
218	ETH_SS_NTUPLE_FILTERS = 3,
219	ETH_SS_FEATURES = 4,
220	ETH_SS_RSS_HASH_FUNCS = 5,
221	ETH_SS_TUNABLES = 6,
222}
223
224#[repr(C)]
225#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
226pub struct ethtool_gstrings
227{
228	pub cmd: u32,
229	pub string_set: u32,
230	pub len: u32,
231	pub data: [u8; 0],
232}
233
234impl Default for ethtool_gstrings
235{
236	fn default() -> Self
237	{
238		unsafe { zeroed() }
239	}
240}
241
242#[repr(C)]
243#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
244pub struct ethtool_sset_info
245{
246	pub cmd: u32,
247	pub reserved: u32,
248	pub sset_mask: u64,
249	pub data: [u32; 0],
250}
251
252impl Default for ethtool_sset_info
253{
254	fn default() -> Self
255	{
256		unsafe { zeroed() }
257	}
258}
259
260#[repr(u32)]
261#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
262pub enum ethtool_test_flags
263{
264	ETH_TEST_FL_OFFLINE = 1,
265	ETH_TEST_FL_FAILED = 2,
266	ETH_TEST_FL_EXTERNAL_LB = 4,
267	ETH_TEST_FL_EXTERNAL_LB_DONE = 8,
268}
269
270#[repr(C)]
271#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
272pub struct ethtool_test
273{
274	pub cmd: u32,
275	pub flags: u32,
276	pub reserved: u32,
277	pub len: u32,
278	pub data: [u64; 0],
279}
280
281impl Default for ethtool_test
282{
283	fn default() -> Self
284	{
285		unsafe { zeroed() }
286	}
287}
288
289#[repr(C)]
290#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
291pub struct ethtool_stats
292{
293	pub cmd: u32,
294	pub n_stats: u32,
295	pub data: [u64; 0],
296}
297
298impl Default for ethtool_stats
299{
300	fn default() -> Self
301	{
302		unsafe { zeroed() }
303	}
304}
305
306#[repr(C)]
307#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
308pub struct ethtool_perm_addr
309{
310	pub cmd: u32,
311	pub size: u32,
312	pub data: [u8; 0],
313}
314
315impl Default for ethtool_perm_addr
316{
317	fn default() -> Self
318	{
319		unsafe { zeroed() }
320	}
321}
322
323#[repr(u32)]
324#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
325pub enum ethtool_flags
326{
327	ETH_FLAG_TXVLAN = 128,
328	ETH_FLAG_RXVLAN = 256,
329	ETH_FLAG_LRO = 32768,
330	ETH_FLAG_NTUPLE = 134217728,
331	ETH_FLAG_RXHASH = 268435456,
332}
333
334#[repr(C)]
335#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
336pub struct ethtool_tcpip4_spec
337{
338	pub ip4src: u32, // Big Endian Always
339	pub ip4dst: u32, // Big Endian Always
340	pub psrc: u16, // Big Endian Always
341	pub pdst: u16, // Big Endian Always
342	pub tos: u8,
343}
344
345impl Default for ethtool_tcpip4_spec
346{
347	fn default() -> Self
348	{
349		unsafe { zeroed() }
350	}
351}
352
353#[repr(C)]
354#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
355pub struct ethtool_ah_espip4_spec
356{
357	pub ip4src: u32, // Big Endian Always
358	pub ip4dst: u32, // Big Endian Always
359	pub spi: u32, // Big Endian Always
360	pub tos: u8,
361}
362
363impl Default for ethtool_ah_espip4_spec
364{
365	fn default() -> Self
366	{
367		unsafe { zeroed() }
368	}
369}
370
371#[repr(C)]
372#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
373pub struct ethtool_usrip4_spec
374{
375	pub ip4src: u32, // Big Endian Always
376	pub ip4dst: u32, // Big Endian Always
377	pub l4_4_bytes: u32, // Big Endian Always
378	pub tos: u8,
379	pub ip_ver: u8,
380	pub proto: u8,
381}
382
383impl Default for ethtool_usrip4_spec
384{
385	fn default() -> Self
386	{
387		unsafe { zeroed() }
388	}
389}
390
391#[repr(C)]
392#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
393pub struct ethtool_flow_ext
394{
395	pub padding: [u8; 2],
396	pub h_dest: [c_uchar; 6],
397	pub vlan_etype: u16, // Big Endian Always
398	pub vlan_tci: u16, // Big Endian Always
399	pub data: [u32; 2], // Big Endian Always
400}
401
402impl Default for ethtool_flow_ext
403{
404	fn default() -> Self
405	{
406		unsafe { zeroed() }
407	}
408}
409
410#[repr(C)]
411#[derive(Copy)]
412#[allow(missing_debug_implementations)]
413pub struct ethtool_rx_flow_spec
414{
415	pub flow_type: u32,
416	pub h_u: ethtool_flow_union,
417	pub h_ext: ethtool_flow_ext,
418	pub m_u: ethtool_flow_union,
419	pub m_ext: ethtool_flow_ext,
420	pub ring_cookie: u64,
421	pub location: u32,
422}
423
424impl Clone for ethtool_rx_flow_spec
425{
426	fn clone(&self) -> Self
427	{
428		*self
429	}
430}
431
432impl Default for ethtool_rx_flow_spec
433{
434	fn default() -> Self
435	{
436		unsafe { zeroed() }
437	}
438}
439
440#[repr(C)]
441#[derive(Copy)]
442#[allow(missing_debug_implementations)]
443pub struct ethtool_rxnfc
444{
445	pub cmd: u32,
446	pub flow_type: u32,
447	pub data: u64,
448	pub fs: ethtool_rx_flow_spec,
449	pub rule_cnt: u32,
450	pub rule_locs: [u32; 0],
451}
452
453impl Clone for ethtool_rxnfc
454{
455	fn clone(&self) -> Self
456	{
457		*self
458	}
459}
460
461impl Default for ethtool_rxnfc
462{
463	fn default() -> Self
464	{
465		unsafe { zeroed() }
466	}
467}
468
469#[repr(C)]
470#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
471pub struct ethtool_rxfh_indir
472{
473	pub cmd: u32,
474	pub size: u32,
475	pub ring_index: [u32; 0],
476}
477
478impl Default for ethtool_rxfh_indir
479{
480	fn default() -> Self
481	{
482		unsafe { zeroed() }
483	}
484}
485
486#[repr(C)]
487#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
488pub struct ethtool_rxfh
489{
490	pub cmd: u32,
491	pub rss_context: u32,
492	pub indir_size: u32,
493	pub key_size: u32,
494	pub hfunc: u8,
495	pub rsvd8: [u8; 3],
496	pub rsvd32: u32,
497	pub rss_config: [u32; 0],
498}
499
500impl Default for ethtool_rxfh
501{
502	fn default() -> Self
503	{
504		unsafe { zeroed() }
505	}
506}
507
508#[repr(u32)]
509#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
510pub enum ethtool_flash_op_type
511{
512	ETHTOOL_FLASH_ALL_REGIONS = 0,
513}
514
515#[repr(C)]
516#[derive(Copy)]
517#[allow(missing_debug_implementations)]
518pub struct ethtool_flash
519{
520	pub cmd: u32,
521	pub region: u32,
522	pub data: [c_char; 128],
523}
524
525impl Clone for ethtool_flash
526{
527	fn clone(&self) -> Self
528	{
529		*self
530	}
531}
532
533impl Default for ethtool_flash
534{
535	fn default() -> Self
536	{
537		unsafe { zeroed() }
538	}
539}
540
541#[repr(C)]
542#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
543pub struct ethtool_dump
544{
545	pub cmd: u32,
546	pub version: u32,
547	pub flag: u32,
548	pub len: u32,
549	pub data: [u8; 0],
550}
551
552impl Default for ethtool_dump
553{
554	fn default() -> Self
555	{
556		unsafe { zeroed() }
557	}
558}
559
560#[repr(C)]
561#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
562pub struct ethtool_get_features_block
563{
564	pub available: u32,
565	pub requested: u32,
566	pub active: u32,
567	pub never_changed: u32,
568}
569
570impl Default for ethtool_get_features_block
571{
572	fn default() -> Self
573	{
574		unsafe { zeroed() }
575	}
576}
577
578#[repr(C)]
579#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
580pub struct ethtool_gfeatures
581{
582	pub cmd: u32,
583	pub size: u32,
584	pub features: [ethtool_get_features_block; 0],
585}
586
587impl Default for ethtool_gfeatures
588{
589	fn default() -> Self
590	{
591		unsafe { zeroed() }
592	}
593}
594
595#[repr(C)]
596#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
597pub struct ethtool_set_features_block
598{
599	pub valid: u32,
600	pub requested: u32,
601}
602
603impl Default for ethtool_set_features_block
604{
605	fn default() -> Self
606	{
607		unsafe { zeroed() }
608	}
609}
610
611#[repr(C)]
612#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
613pub struct ethtool_sfeatures
614{
615	pub cmd: u32,
616	pub size: u32,
617	pub features: [ethtool_set_features_block; 0],
618}
619
620impl Default for ethtool_sfeatures
621{
622	fn default() -> Self
623	{
624		unsafe { zeroed() }
625	}
626}
627
628#[repr(C)]
629#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
630pub struct ethtool_ts_info
631{
632	pub cmd: u32,
633	pub so_timestamping: u32,
634	pub phc_index: i32,
635	pub tx_types: u32,
636	pub tx_reserved: [u32; 3],
637	pub rx_filters: u32,
638	pub rx_reserved: [u32; 3],
639}
640
641impl Default for ethtool_ts_info
642{
643	fn default() -> Self
644	{
645		unsafe { zeroed() }
646	}
647}
648
649#[repr(u32)]
650#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
651pub enum ethtool_sfeatures_retval_bits
652{
653	ETHTOOL_F_UNSUPPORTED__BIT = 0,
654	ETHTOOL_F_WISH__BIT = 1,
655	ETHTOOL_F_COMPAT__BIT = 2,
656}
657
658#[repr(u32)]
659#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
660pub enum ethtool_reset_flags
661{
662	ETH_RESET_MGMT = 1,
663	ETH_RESET_IRQ = 2,
664	ETH_RESET_DMA = 4,
665	ETH_RESET_FILTER = 8,
666	ETH_RESET_OFFLOAD = 16,
667	ETH_RESET_MAC = 32,
668	ETH_RESET_PHY = 64,
669	ETH_RESET_RAM = 128,
670	ETH_RESET_DEDICATED = 65535,
671	ETH_RESET_ALL = 4294967295,
672}