Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transceivers: convert to counted_ringbufs #1780

Merged
merged 3 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Aaron-Hartwig marked this conversation as resolved.
Show resolved Hide resolved
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,
Aaron-Hartwig marked this conversation as resolved.
Show resolved Hide resolved
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,
Aaron-Hartwig marked this conversation as resolved.
Show resolved Hide resolved
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
Loading