Skip to content

Commit

Permalink
transceivers: convert to counted_ringbufs (#1780)
Browse files Browse the repository at this point in the history
I'm going to use a `counted_ringbuf` in the `transceivers` task because
there is a lot of activity that happens, specifically in the UDP
handler. I also bumped up the size from 16 -> 32 of that one because
there's nearly constant activity and each UDP message involves at least
three entries.

Fixes #1778
  • Loading branch information
Aaron-Hartwig committed May 15, 2024
1 parent d4b844d commit 561b577
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions drv/transceivers-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ authors = ["Aaron Hartwig <aaron@oxide.computer>"]
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" }
Expand Down
23 changes: 14 additions & 9 deletions drv/transceivers-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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),
Expand All @@ -70,7 +74,8 @@ enum Trace {
DisableFailed(usize, LogicalPortMask),
ClearDisabledPorts(LogicalPortMask),
}
ringbuf!(Trace, 16, Trace::None);

counted_ringbuf!(Trace, 16, Trace::None);

////////////////////////////////////////////////////////////////////////////////

Expand Down
14 changes: 9 additions & 5 deletions drv/transceivers-server/src/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,30 @@
//!
//! 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,
message::*,
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),
Expand Down Expand Up @@ -63,7 +67,7 @@ enum Trace {
WriteI2CFailures(LogicalPort, FpgaI2CFailure),
}

ringbuf!(Trace, 16, Trace::None);
counted_ringbuf!(Trace, 32, Trace::None);

////////////////////////////////////////////////////////////////////////////////
#[derive(Copy, Clone, PartialEq)]
Expand Down

0 comments on commit 561b577

Please sign in to comment.