Skip to content

Commit 6daba73

Browse files
authored
fec: Expose EthtoolFecMode and EthtoolFecStat (#19)
Signed-off-by: Gris Ge <[email protected]>
1 parent 3181ee7 commit 6daba73

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/fec/attr.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ pub(crate) fn parse_fec_nlas(
141141
Ok(nlas)
142142
}
143143

144-
#[derive(Debug, PartialEq, Eq, Clone)]
144+
#[derive(Debug, PartialEq, Eq, Clone, Default)]
145145
pub enum EthtoolFecMode {
146+
#[default]
146147
None,
147148
Rs,
148149
Baser,
@@ -191,6 +192,18 @@ impl From<u32> for EthtoolFecMode {
191192
}
192193
}
193194

195+
impl From<EthtoolFecMode> for u32 {
196+
fn from(v: EthtoolFecMode) -> u32 {
197+
match v {
198+
EthtoolFecMode::None => ETHTOOL_LINK_MODE_FEC_NONE_BIT,
199+
EthtoolFecMode::Rs => ETHTOOL_LINK_MODE_FEC_RS_BIT,
200+
EthtoolFecMode::Baser => ETHTOOL_LINK_MODE_FEC_BASER_BIT,
201+
EthtoolFecMode::Llrs => ETHTOOL_LINK_MODE_FEC_LLRS_BIT,
202+
EthtoolFecMode::Other(d, _) => d,
203+
}
204+
}
205+
}
206+
194207
const ETHTOOL_A_FEC_STAT_CORRECTED: u16 = 2;
195208
const ETHTOOL_A_FEC_STAT_UNCORR: u16 = 3;
196209
const ETHTOOL_A_FEC_STAT_CORR_BITS: u16 = 4;

src/fec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ mod get;
55
mod handle;
66

77
pub(crate) use self::attr::parse_fec_nlas;
8-
pub use self::attr::EthtoolFecAttr;
8+
pub use self::attr::{EthtoolFecAttr, EthtoolFecMode, EthtoolFecStat};
99
pub use self::get::EthtoolFecGetRequest;
1010
pub use self::handle::EthtoolFecHandle;

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ mod pause;
1515
mod ring;
1616
mod tsinfo;
1717

18-
pub use self::fec::{EthtoolFecAttr, EthtoolFecGetRequest, EthtoolFecHandle};
18+
pub use self::fec::{
19+
EthtoolFecAttr, EthtoolFecGetRequest, EthtoolFecHandle, EthtoolFecMode,
20+
EthtoolFecStat,
21+
};
1922
pub use coalesce::{
2023
EthtoolCoalesceAttr, EthtoolCoalesceGetRequest, EthtoolCoalesceHandle,
2124
};

0 commit comments

Comments
 (0)