mod bitset;
mod connection;
mod types;
pub use bitset::EthtoolBitset;
pub use types::*;
pub const ETHTOOL_GENL_NAME: &str = "ethtool";
pub const ETHTOOL_GENL_VERSION: u8 = 1;
pub const ETHTOOL_MCGRP_MONITOR: &str = "monitor";
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolCmd {
StrsetGet = 1,
LinkinfoGet = 2,
LinkinfoSet = 3,
LinkmodesGet = 4,
LinkmodesSet = 5,
LinkstateGet = 6,
DebugGet = 7,
DebugSet = 8,
WolGet = 9,
WolSet = 10,
FeaturesGet = 11,
FeaturesSet = 12,
PrivflagsGet = 13,
PrivflagsSet = 14,
RingsGet = 15,
RingsSet = 16,
ChannelsGet = 17,
ChannelsSet = 18,
CoalesceGet = 19,
CoalesceSet = 20,
PauseGet = 21,
PauseSet = 22,
EeeGet = 23,
EeeSet = 24,
TsinfoGet = 25,
CableTestAct = 26,
CableTestTdrAct = 27,
TunnelInfoGet = 28,
FecGet = 29,
FecSet = 30,
ModuleEepromGet = 31,
StatsGet = 32,
PhcVclocksGet = 33,
ModuleGet = 34,
ModuleSet = 35,
PseGet = 36,
PseSet = 37,
RssGet = 38,
PlcaGetCfg = 39,
PlcaSetCfg = 40,
PlcaGetStatus = 41,
MmGet = 42,
MmSet = 43,
ModuleFwFlashAct = 44,
PhyGet = 45,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolHeaderAttr {
Unspec = 0,
DevIndex = 1,
DevName = 2,
Flags = 3,
PhyIndex = 4,
}
#[repr(u32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolFlag {
CompactBitsets = 1 << 0,
OmitReply = 1 << 1,
Stats = 1 << 2,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolBitsetAttr {
Unspec = 0,
Nomask = 1,
Size = 2,
Bits = 3,
Value = 4,
Mask = 5,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolBitsetBitAttr {
Unspec = 0,
Index = 1,
Name = 2,
Value = 3,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolStrsetAttr {
Unspec = 0,
Header = 1,
Stringsets = 2,
CountsOnly = 3,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolStringsetAttr {
Unspec = 0,
Id = 1,
Count = 2,
Strings = 3,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolStringAttr {
Unspec = 0,
Index = 1,
Value = 2,
}
#[repr(u32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolStringSet {
Test = 0,
Stats = 1,
PrivFlags = 2,
NtupleFltrs = 3,
Features = 4,
RssHashFuncs = 5,
Tunables = 6,
PhyStats = 7,
PhyTunables = 8,
LinkModes = 9,
MsgClasses = 10,
WolModes = 11,
SofTimestamping = 12,
TsTxTypes = 13,
TsRxFilters = 14,
UdpTunnelTypes = 15,
StatsStd = 16,
StatsEthPhy = 17,
StatsEthMac = 18,
StatsEthCtrl = 19,
StatsRmon = 20,
StatsPhy = 21,
TsFlags = 22,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolLinkinfoAttr {
Unspec = 0,
Header = 1,
Port = 2,
Phyaddr = 3,
TpMdix = 4,
TpMdiCtrl = 5,
Transceiver = 6,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolLinkmodesAttr {
Unspec = 0,
Header = 1,
Autoneg = 2,
Ours = 3,
Peer = 4,
Speed = 5,
Duplex = 6,
MasterSlaveCfg = 7,
MasterSlaveState = 8,
Lanes = 9,
RateMatching = 10,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolLinkstateAttr {
Unspec = 0,
Header = 1,
Link = 2,
Sqi = 3,
SqiMax = 4,
ExtState = 5,
ExtSubstate = 6,
ExtDownCnt = 7,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolFeaturesAttr {
Unspec = 0,
Header = 1,
Hw = 2,
Wanted = 3,
Active = 4,
NoChange = 5,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolRingsAttr {
Unspec = 0,
Header = 1,
RxMax = 2,
RxMiniMax = 3,
RxJumboMax = 4,
TxMax = 5,
Rx = 6,
RxMini = 7,
RxJumbo = 8,
Tx = 9,
RxBufLen = 10,
TcpDataSplit = 11,
CqeSize = 12,
TxPush = 13,
RxPush = 14,
TxPushBufLen = 15,
TxPushBufLenMax = 16,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolChannelsAttr {
Unspec = 0,
Header = 1,
RxMax = 2,
TxMax = 3,
OtherMax = 4,
CombinedMax = 5,
RxCount = 6,
TxCount = 7,
OtherCount = 8,
CombinedCount = 9,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolCoalesceAttr {
Unspec = 0,
Header = 1,
RxUsecs = 2,
RxMaxFrames = 3,
RxUsecsIrq = 4,
RxMaxFramesIrq = 5,
TxUsecs = 6,
TxMaxFrames = 7,
TxUsecsIrq = 8,
TxMaxFramesIrq = 9,
StatsBlockUsecs = 10,
UseAdaptiveRx = 11,
UseAdaptiveTx = 12,
PktRateLow = 13,
RxUsecsLow = 14,
RxMaxFramesLow = 15,
TxUsecsLow = 16,
TxMaxFramesLow = 17,
PktRateHigh = 18,
RxUsecsHigh = 19,
RxMaxFramesHigh = 20,
TxUsecsHigh = 21,
TxMaxFramesHigh = 22,
RateSampleInterval = 23,
UseCqeTx = 24,
UseCqeRx = 25,
TxAggrMaxBytes = 26,
TxAggrMaxFrames = 27,
TxAggrTimeUsecs = 28,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolPauseAttr {
Unspec = 0,
Header = 1,
Autoneg = 2,
Rx = 3,
Tx = 4,
Stats = 5,
StatsRxSrc = 6,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolWolAttr {
Unspec = 0,
Header = 1,
Modes = 2,
Sopass = 3,
}
pub const WOL_MODE_NAMES: [&str; 8] = [
"phy",
"ucast",
"mcast",
"bcast",
"arp",
"magic",
"magicsecure",
"filter",
];
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolEeeAttr {
Unspec = 0,
Header = 1,
ModesOurs = 2,
ModesPeer = 3,
Active = 4,
Enabled = 5,
TxLpiEnabled = 6,
TxLpiTimer = 7,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolFecAttr {
Unspec = 0,
Header = 1,
Modes = 2,
Auto = 3,
Active = 4,
Stats = 5,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolModuleEepromAttr {
Unspec = 0,
Header = 1,
Offset = 2,
Length = 3,
Page = 4,
Bank = 5,
I2cAddress = 6,
Data = 7,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolRssAttr {
Unspec = 0,
Header = 1,
Context = 2,
Hfunc = 3,
Indir = 4,
Hkey = 5,
InputXfrm = 6,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolStatsAttr {
Unspec = 0,
Pad = 1,
Header = 2,
Groups = 3,
Grp = 4,
Src = 5,
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum EthtoolStatsGrpAttr {
Unspec = 0,
Pad = 1,
Id = 2,
SsId = 3,
Stat = 4,
}
pub mod stats_group {
pub const ETH_PHY: u32 = 0;
pub const ETH_MAC: u32 = 1;
pub const ETH_CTRL: u32 = 2;
pub const RMON: u32 = 3;
}
#[cfg(test)]
mod uapi_conformance_tests {
use super::*;
#[test]
fn linkmodes_attrs_match_the_kernel() {
assert_eq!(EthtoolLinkmodesAttr::Header as u16, 1);
assert_eq!(EthtoolLinkmodesAttr::Autoneg as u16, 2);
assert_eq!(EthtoolLinkmodesAttr::Ours as u16, 3);
assert_eq!(EthtoolLinkmodesAttr::Peer as u16, 4);
assert_eq!(EthtoolLinkmodesAttr::Speed as u16, 5);
assert_eq!(EthtoolLinkmodesAttr::Duplex as u16, 6);
assert_eq!(EthtoolLinkmodesAttr::MasterSlaveCfg as u16, 7);
assert_eq!(EthtoolLinkmodesAttr::MasterSlaveState as u16, 8);
assert_eq!(EthtoolLinkmodesAttr::Lanes as u16, 9);
assert_eq!(EthtoolLinkmodesAttr::RateMatching as u16, 10);
}
#[test]
fn linkinfo_mdix_attrs_are_not_transposed() {
assert_eq!(EthtoolLinkinfoAttr::TpMdix as u16, 4);
assert_eq!(EthtoolLinkinfoAttr::TpMdiCtrl as u16, 5);
}
#[test]
fn string_set_ids_match_the_kernel() {
assert_eq!(EthtoolStringSet::NtupleFltrs as u32, 3);
assert_eq!(EthtoolStringSet::Features as u32, 4);
assert_eq!(EthtoolStringSet::RssHashFuncs as u32, 5);
assert_eq!(EthtoolStringSet::LinkModes as u32, 9);
assert_eq!(EthtoolStringSet::StatsStd as u32, 16);
}
#[test]
fn phy_get_is_not_the_firmware_flash_command() {
assert_eq!(EthtoolCmd::MmSet as u8, 43);
assert_eq!(EthtoolCmd::ModuleFwFlashAct as u8, 44);
assert_eq!(EthtoolCmd::PhyGet as u8, 45);
}
#[test]
fn stats_attrs_account_for_the_pad() {
assert_eq!(EthtoolStatsAttr::Pad as u16, 1);
assert_eq!(EthtoolStatsAttr::Header as u16, 2);
assert_eq!(EthtoolStatsAttr::Groups as u16, 3);
assert_eq!(EthtoolStatsAttr::Grp as u16, 4);
assert_eq!(EthtoolStatsAttr::Src as u16, 5);
}
#[test]
fn coalesce_cqe_mode_puts_tx_before_rx() {
assert_eq!(EthtoolCoalesceAttr::UseCqeTx as u16, 24);
assert_eq!(EthtoolCoalesceAttr::UseCqeRx as u16, 25);
}
}