diff --git a/src/fec/attr.rs b/src/fec/attr.rs index 6a5ebf0..6c33c9e 100644 --- a/src/fec/attr.rs +++ b/src/fec/attr.rs @@ -141,8 +141,9 @@ pub(crate) fn parse_fec_nlas( Ok(nlas) } -#[derive(Debug, PartialEq, Eq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone, Default)] pub enum EthtoolFecMode { + #[default] None, Rs, Baser, @@ -191,6 +192,18 @@ impl From for EthtoolFecMode { } } +impl From for u32 { + fn from(v: EthtoolFecMode) -> u32 { + match v { + EthtoolFecMode::None => ETHTOOL_LINK_MODE_FEC_NONE_BIT, + EthtoolFecMode::Rs => ETHTOOL_LINK_MODE_FEC_RS_BIT, + EthtoolFecMode::Baser => ETHTOOL_LINK_MODE_FEC_BASER_BIT, + EthtoolFecMode::Llrs => ETHTOOL_LINK_MODE_FEC_LLRS_BIT, + EthtoolFecMode::Other(d, _) => d, + } + } +} + const ETHTOOL_A_FEC_STAT_CORRECTED: u16 = 2; const ETHTOOL_A_FEC_STAT_UNCORR: u16 = 3; const ETHTOOL_A_FEC_STAT_CORR_BITS: u16 = 4; diff --git a/src/fec/mod.rs b/src/fec/mod.rs index dd4cc70..e6de603 100644 --- a/src/fec/mod.rs +++ b/src/fec/mod.rs @@ -5,6 +5,6 @@ mod get; mod handle; pub(crate) use self::attr::parse_fec_nlas; -pub use self::attr::EthtoolFecAttr; +pub use self::attr::{EthtoolFecAttr, EthtoolFecMode, EthtoolFecStat}; pub use self::get::EthtoolFecGetRequest; pub use self::handle::EthtoolFecHandle; diff --git a/src/lib.rs b/src/lib.rs index d7c6521..9fc2436 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,7 +15,10 @@ mod pause; mod ring; mod tsinfo; -pub use self::fec::{EthtoolFecAttr, EthtoolFecGetRequest, EthtoolFecHandle}; +pub use self::fec::{ + EthtoolFecAttr, EthtoolFecGetRequest, EthtoolFecHandle, EthtoolFecMode, + EthtoolFecStat, +}; pub use coalesce::{ EthtoolCoalesceAttr, EthtoolCoalesceGetRequest, EthtoolCoalesceHandle, };