diff --git a/Cargo.lock b/Cargo.lock index 728c1919f..903597506 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2087,6 +2087,7 @@ dependencies = [ "build-i2c", "build-util", "cfg-if", + "counters", "drv-fpga-api", "drv-i2c-api", "drv-i2c-devices", diff --git a/drv/transceivers-server/Cargo.toml b/drv/transceivers-server/Cargo.toml index e9bb95d4b..e10c5c800 100644 --- a/drv/transceivers-server/Cargo.toml +++ b/drv/transceivers-server/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Aaron Hartwig "] edition = "2021" [dependencies] +counters = { path = "../../lib/counters" } drv-fpga-api = { path = "../fpga-api" } drv-i2c-api = { path = "../i2c-api" } drv-i2c-devices = { path = "../i2c-devices" } diff --git a/drv/transceivers-server/src/main.rs b/drv/transceivers-server/src/main.rs index fcad48fee..29f419a83 100644 --- a/drv/transceivers-server/src/main.rs +++ b/drv/transceivers-server/src/main.rs @@ -5,6 +5,13 @@ #![no_std] #![no_main] +use counters::Count; +use idol_runtime::{NotificationHandler, RequestError}; +use multitimer::{Multitimer, Repeat}; +use ringbuf::*; +use static_cell::ClaimOnceCell; +use userlib::{sys_get_timer, task_slot, units::Celsius}; + use drv_fpga_api::FpgaError; use drv_i2c_devices::pca9956b::Error; use drv_sidecar_front_io::{ @@ -17,16 +24,12 @@ use drv_transceivers_api::{ ModuleStatus, TransceiversError, NUM_PORTS, TRANSCEIVER_TEMPERATURE_SENSORS, }; use enum_map::Enum; -use idol_runtime::{NotificationHandler, RequestError}; -use multitimer::{Multitimer, Repeat}; -use ringbuf::*; -use static_cell::ClaimOnceCell; use task_sensor_api::{NoData, Sensor}; use task_thermal_api::{Thermal, ThermalError, ThermalProperties}; use transceiver_messages::{ message::LedState, mgmt::ManagementInterface, MAX_PACKET_SIZE, }; -use userlib::{sys_get_timer, task_slot, units::Celsius}; + use zerocopy::{AsBytes, FromBytes}; mod udp; // UDP API is implemented in a separate file @@ -41,10 +44,11 @@ task_slot!(SENSOR, sensor); include!(concat!(env!("OUT_DIR"), "/i2c_config.rs")); #[allow(dead_code)] -#[derive(Copy, Clone, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq, Count)] enum Trace { + #[count(skip)] None, - FrontIOBoardReady(bool), + FrontIOBoardReady(#[count(children)] bool), FrontIOSeqErr(SeqError), LEDInit, LEDInitComplete, @@ -55,7 +59,7 @@ enum Trace { LEDReadError(Error), LEDUpdateError(Error), ModulePresenceUpdate(LogicalPortMask), - TransceiversError(TransceiversError), + TransceiversError(#[count(children)] TransceiversError), GotInterface(u8, ManagementInterface), UnknownInterface(u8, ManagementInterface), UnpluggedModule(usize), @@ -70,7 +74,8 @@ enum Trace { DisableFailed(usize, LogicalPortMask), ClearDisabledPorts(LogicalPortMask), } -ringbuf!(Trace, 16, Trace::None); + +counted_ringbuf!(Trace, 16, Trace::None); //////////////////////////////////////////////////////////////////////////////// diff --git a/drv/transceivers-server/src/udp.rs b/drv/transceivers-server/src/udp.rs index 4092b82d3..38efe7711 100644 --- a/drv/transceivers-server/src/udp.rs +++ b/drv/transceivers-server/src/udp.rs @@ -10,13 +10,17 @@ //! //! All of the API types in `transceiver_messages` operate on **physical** //! ports, i.e. an FPGA paired by a physical port index (or mask). +//! +use counters::Count; +use hubpack::SerializedSize; +use ringbuf::*; +use userlib::UnwrapLite; + use crate::{FrontIOStatus, ServerImpl}; use drv_sidecar_front_io::transceivers::{ FpgaI2CFailure, LogicalPort, LogicalPortFailureTypes, LogicalPortMask, ModuleResult, ModuleResultNoFailure, ModuleResultSlim, PortI2CStatus, }; -use hubpack::SerializedSize; -use ringbuf::*; use task_net_api::*; use transceiver_messages::{ mac::MacAddrs, @@ -24,12 +28,12 @@ use transceiver_messages::{ mgmt::{ManagementInterface, MemoryRead, MemoryWrite, Page}, ModuleId, }; -use userlib::UnwrapLite; //////////////////////////////////////////////////////////////////////////////// -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, Count)] enum Trace { + #[count(skip)] None, DeserializeError(hubpack::Error), DeserializeHeaderError(hubpack::Error), @@ -63,7 +67,7 @@ enum Trace { WriteI2CFailures(LogicalPort, FpgaI2CFailure), } -ringbuf!(Trace, 16, Trace::None); +counted_ringbuf!(Trace, 32, Trace::None); //////////////////////////////////////////////////////////////////////////////// #[derive(Copy, Clone, PartialEq)]