runtime: print ethmac preamble error count.

Also, print total error count, not the difference (but still compute
the difference to determine *when* to print).
This commit is contained in:
whitequark 2017-11-26 22:35:22 +00:00
parent e5995794be
commit 8e8f037971
3 changed files with 16 additions and 10 deletions

View File

@ -109,16 +109,18 @@ impl phy::TxToken for EthernetTxSlot {
#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct EthernetStatistics {
rx_errors: u32,
rx_dropped: u32,
rx_preamble_errors: u32,
rx_crc_errors: u32,
rx_dropped: u32,
}
impl EthernetStatistics {
pub fn new() -> Self {
unsafe {
EthernetStatistics {
rx_errors: csr::ethmac::crc_errors_read(),
rx_dropped: csr::ethmac::sram_writer_errors_read(),
rx_preamble_errors: csr::ethmac::preamble_errors_read(),
rx_crc_errors: csr::ethmac::crc_errors_read(),
rx_dropped: csr::ethmac::sram_writer_errors_read(),
}
}
}
@ -128,8 +130,9 @@ impl EthernetStatistics {
*self = Self::new();
let diff = EthernetStatistics {
rx_errors: self.rx_errors.wrapping_sub(old.rx_errors),
rx_dropped: self.rx_dropped.wrapping_sub(old.rx_dropped),
rx_preamble_errors: self.rx_preamble_errors.wrapping_sub(old.rx_preamble_errors),
rx_crc_errors: self.rx_crc_errors.wrapping_sub(old.rx_crc_errors),
rx_dropped: self.rx_dropped.wrapping_sub(old.rx_dropped),
};
if diff == EthernetStatistics::default() {
None
@ -141,8 +144,11 @@ impl EthernetStatistics {
impl fmt::Display for EthernetStatistics {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.rx_errors > 0 {
write!(f, " rx crc errors: {}", self.rx_errors)?
if self.rx_preamble_errors > 0 {
write!(f, " rx preamble errors: {}", self.rx_preamble_errors)?
}
if self.rx_crc_errors > 0 {
write!(f, " rx crc errors: {}", self.rx_crc_errors)?
}
if self.rx_dropped > 0 {
write!(f, " rx dropped: {}", self.rx_dropped)?

View File

@ -178,7 +178,7 @@ fn startup_ethernet() {
}
if let Some(net_stats_diff) = net_stats.update() {
warn!("ethernet mac:{}", net_stats_diff); // mac:{} (sic)
warn!("ethernet mac:{}", ethmac::EthernetStatistics::new());
}
}
}

View File

@ -15,7 +15,7 @@ requirements:
- python >=3.5.3,<3.6
- setuptools 33.1.1
- migen 0.5
- misoc 0.7.dev py35_8+git1ac1d7d9
- misoc 0.7.dev py35_32+30979b2e
- jesd204b 0.4
- binutils-or1k-linux >=2.27
- llvm-or1k