1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
// 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.
// 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.


#![allow(non_camel_case_types)] 

use ::std::default::Default;
use ::std::mem::transmute;
use ::std::mem::zeroed;
use ::libc::c_char;
use ::libc::c_uchar;
use ::libc::c_uint;
use ::libc::c_ulonglong;
use ::libc::c_ushort;
use ::libc::c_void;
use ::libc::size_t;
use ::libc::ssize_t;
use ::android_linux::netinet::if_ether::ethhdr;


include!("constants/ADVERTISED.rs");
include!("constants/ETH_MDIO_SUPPORTS.rs");
include!("constants/ETH_MODULE_SFF.rs");
include!("constants/ETH_TP_MDI.rs");
include!("constants/FLOW.rs");
include!("constants/lengthsAndMaxima.rs");
include!("constants/miscellany.rs");
include!("constants/PORT.rs");
include!("constants/RXH.rs");
include!("constants/RX_CLS.rs");
include!("constants/SPEED.rs");
include!("constants/SUPPORTED.rs");
include!("constants/WAKE.rs");
include!("constants/XCVR.rs");

include!("ethtool_cmd.rs");
include!("ethtool_coalesce.rs");
include!("ethtool_drvinfo.rs");
include!("ethtool_flow_union.rs");
include!("ethtool_ringparam.rs");
include!("ethtool_rx_ntuple.rs");
include!("ethtool_rx_ntuple_flow_spec.rs");
include!("ethtool_value.rs");
include!("ethtool_wolinfo.rs");


#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum tunable_id
{
	ETHTOOL_ID_UNSPEC = 0,
	ETHTOOL_RX_COPYBREAK = 1,
	ETHTOOL_TX_COPYBREAK = 2,
	__ETHTOOL_TUNABLE_COUNT = 3,
}

#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum tunable_type_id
{
	ETHTOOL_TUNABLE_UNSPEC = 0,
	ETHTOOL_TUNABLE_U8 = 1,
	ETHTOOL_TUNABLE_U16 = 2,
	ETHTOOL_TUNABLE_U32 = 3,
	ETHTOOL_TUNABLE_U64 = 4,
	ETHTOOL_TUNABLE_STRING = 5,
	ETHTOOL_TUNABLE_S8 = 6,
	ETHTOOL_TUNABLE_S16 = 7,
	ETHTOOL_TUNABLE_S32 = 8,
	ETHTOOL_TUNABLE_S64 = 9,
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_tunable
{
	pub cmd: u32,
	pub id: u32,
	pub type_id: u32,
	pub len: u32,
	pub data: [*mut c_void; 0],
}

impl Default for ethtool_tunable
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_regs
{
	pub cmd: u32,
	pub version: u32,
	pub len: u32,
	pub data: [u8; 0],
}

impl Default for ethtool_regs
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_eeprom
{
	pub cmd: u32,
	pub magic: u32,
	pub offset: u32,
	pub len: u32,
	pub data: [u8; 0],
}

impl Default for ethtool_eeprom
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_eee
{
	pub cmd: u32,
	pub supported: u32,
	pub advertised: u32,
	pub lp_advertised: u32,
	pub eee_active: u32,
	pub eee_enabled: u32,
	pub tx_lpi_enabled: u32,
	pub tx_lpi_timer: u32,
	pub reserved: [u32; 2],
}

impl Default for ethtool_eee
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_modinfo
{
	pub cmd: u32,
	pub type_: u32,
	pub eeprom_len: u32,
	pub reserved: [u32; 8],
}

impl Default for ethtool_modinfo
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_channels
{
	pub cmd: u32,
	pub max_rx: u32,
	pub max_tx: u32,
	pub max_other: u32,
	pub max_combined: u32,
	pub rx_count: u32,
	pub tx_count: u32,
	pub other_count: u32,
	pub combined_count: u32,
}

impl Default for ethtool_channels
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_pauseparam
{
	pub cmd: u32,
	pub autoneg: u32,
	pub rx_pause: u32,
	pub tx_pause: u32,
}

impl Default for ethtool_pauseparam
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ethtool_stringset
{
	ETH_SS_TEST = 0,
	ETH_SS_STATS = 1,
	ETH_SS_PRIV_FLAGS = 2,
	ETH_SS_NTUPLE_FILTERS = 3,
	ETH_SS_FEATURES = 4,
	ETH_SS_RSS_HASH_FUNCS = 5,
	ETH_SS_TUNABLES = 6,
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_gstrings
{
	pub cmd: u32,
	pub string_set: u32,
	pub len: u32,
	pub data: [u8; 0],
}

impl Default for ethtool_gstrings
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_sset_info
{
	pub cmd: u32,
	pub reserved: u32,
	pub sset_mask: u64,
	pub data: [u32; 0],
}

impl Default for ethtool_sset_info
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ethtool_test_flags
{
	ETH_TEST_FL_OFFLINE = 1,
	ETH_TEST_FL_FAILED = 2,
	ETH_TEST_FL_EXTERNAL_LB = 4,
	ETH_TEST_FL_EXTERNAL_LB_DONE = 8,
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_test
{
	pub cmd: u32,
	pub flags: u32,
	pub reserved: u32,
	pub len: u32,
	pub data: [u64; 0],
}

impl Default for ethtool_test
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_stats
{
	pub cmd: u32,
	pub n_stats: u32,
	pub data: [u64; 0],
}

impl Default for ethtool_stats
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_perm_addr
{
	pub cmd: u32,
	pub size: u32,
	pub data: [u8; 0],
}

impl Default for ethtool_perm_addr
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ethtool_flags
{
	ETH_FLAG_TXVLAN = 128,
	ETH_FLAG_RXVLAN = 256,
	ETH_FLAG_LRO = 32768,
	ETH_FLAG_NTUPLE = 134217728,
	ETH_FLAG_RXHASH = 268435456,
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_tcpip4_spec
{
	pub ip4src: u32, // Big Endian Always
	pub ip4dst: u32, // Big Endian Always
	pub psrc: u16, // Big Endian Always
	pub pdst: u16, // Big Endian Always
	pub tos: u8,
}

impl Default for ethtool_tcpip4_spec
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_ah_espip4_spec
{
	pub ip4src: u32, // Big Endian Always
	pub ip4dst: u32, // Big Endian Always
	pub spi: u32, // Big Endian Always
	pub tos: u8,
}

impl Default for ethtool_ah_espip4_spec
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_usrip4_spec
{
	pub ip4src: u32, // Big Endian Always
	pub ip4dst: u32, // Big Endian Always
	pub l4_4_bytes: u32, // Big Endian Always
	pub tos: u8,
	pub ip_ver: u8,
	pub proto: u8,
}

impl Default for ethtool_usrip4_spec
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_flow_ext
{
	pub padding: [u8; 2],
	pub h_dest: [c_uchar; 6],
	pub vlan_etype: u16, // Big Endian Always
	pub vlan_tci: u16, // Big Endian Always
	pub data: [u32; 2], // Big Endian Always
}

impl Default for ethtool_flow_ext
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Copy)]
#[allow(missing_debug_implementations)]
pub struct ethtool_rx_flow_spec
{
	pub flow_type: u32,
	pub h_u: ethtool_flow_union,
	pub h_ext: ethtool_flow_ext,
	pub m_u: ethtool_flow_union,
	pub m_ext: ethtool_flow_ext,
	pub ring_cookie: u64,
	pub location: u32,
}

impl Clone for ethtool_rx_flow_spec
{
	fn clone(&self) -> Self
	{
		*self
	}
}

impl Default for ethtool_rx_flow_spec
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Copy)]
#[allow(missing_debug_implementations)]
pub struct ethtool_rxnfc
{
	pub cmd: u32,
	pub flow_type: u32,
	pub data: u64,
	pub fs: ethtool_rx_flow_spec,
	pub rule_cnt: u32,
	pub rule_locs: [u32; 0],
}

impl Clone for ethtool_rxnfc
{
	fn clone(&self) -> Self
	{
		*self
	}
}

impl Default for ethtool_rxnfc
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_rxfh_indir
{
	pub cmd: u32,
	pub size: u32,
	pub ring_index: [u32; 0],
}

impl Default for ethtool_rxfh_indir
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_rxfh
{
	pub cmd: u32,
	pub rss_context: u32,
	pub indir_size: u32,
	pub key_size: u32,
	pub hfunc: u8,
	pub rsvd8: [u8; 3],
	pub rsvd32: u32,
	pub rss_config: [u32; 0],
}

impl Default for ethtool_rxfh
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ethtool_flash_op_type
{
	ETHTOOL_FLASH_ALL_REGIONS = 0,
}

#[repr(C)]
#[derive(Copy)]
#[allow(missing_debug_implementations)]
pub struct ethtool_flash
{
	pub cmd: u32,
	pub region: u32,
	pub data: [c_char; 128],
}

impl Clone for ethtool_flash
{
	fn clone(&self) -> Self
	{
		*self
	}
}

impl Default for ethtool_flash
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_dump
{
	pub cmd: u32,
	pub version: u32,
	pub flag: u32,
	pub len: u32,
	pub data: [u8; 0],
}

impl Default for ethtool_dump
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_get_features_block
{
	pub available: u32,
	pub requested: u32,
	pub active: u32,
	pub never_changed: u32,
}

impl Default for ethtool_get_features_block
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_gfeatures
{
	pub cmd: u32,
	pub size: u32,
	pub features: [ethtool_get_features_block; 0],
}

impl Default for ethtool_gfeatures
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_set_features_block
{
	pub valid: u32,
	pub requested: u32,
}

impl Default for ethtool_set_features_block
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_sfeatures
{
	pub cmd: u32,
	pub size: u32,
	pub features: [ethtool_set_features_block; 0],
}

impl Default for ethtool_sfeatures
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ethtool_ts_info
{
	pub cmd: u32,
	pub so_timestamping: u32,
	pub phc_index: i32,
	pub tx_types: u32,
	pub tx_reserved: [u32; 3],
	pub rx_filters: u32,
	pub rx_reserved: [u32; 3],
}

impl Default for ethtool_ts_info
{
	fn default() -> Self
	{
		unsafe { zeroed() }
	}
}

#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ethtool_sfeatures_retval_bits
{
	ETHTOOL_F_UNSUPPORTED__BIT = 0,
	ETHTOOL_F_WISH__BIT = 1,
	ETHTOOL_F_COMPAT__BIT = 2,
}

#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ethtool_reset_flags
{
	ETH_RESET_MGMT = 1,
	ETH_RESET_IRQ = 2,
	ETH_RESET_DMA = 4,
	ETH_RESET_FILTER = 8,
	ETH_RESET_OFFLOAD = 16,
	ETH_RESET_MAC = 32,
	ETH_RESET_PHY = 64,
	ETH_RESET_RAM = 128,
	ETH_RESET_DEDICATED = 65535,
	ETH_RESET_ALL = 4294967295,
}