Skip to content

Commit

Permalink
transceivers: convert to counted_ringbufs
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron-Hartwig committed May 10, 2024
1 parent a4fa6f7 commit f719f20
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 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
12 changes: 8 additions & 4 deletions drv/transceivers-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#![no_std]
#![no_main]

use counters::Count;
use ringbuf::*;
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 @@ -19,14 +23,13 @@ use drv_transceivers_api::{
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,7 +44,7 @@ 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 {
None,
FrontIOBoardReady(bool),
Expand Down Expand Up @@ -70,7 +73,8 @@ enum Trace {
DisableFailed(usize, LogicalPortMask),
ClearDisabledPorts(LogicalPortMask),
}
ringbuf!(Trace, 16, Trace::None);

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

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

Expand Down
11 changes: 7 additions & 4 deletions drv/transceivers-server/src/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,28 @@
//!
//! 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 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 {
None,
DeserializeError(hubpack::Error),
Expand Down Expand Up @@ -63,7 +66,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 f719f20

Please sign in to comment.