Skip to content

Commit 561b577

Browse files
transceivers: convert to counted_ringbufs (#1780)
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
1 parent d4b844d commit 561b577

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

drv/transceivers-server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ authors = ["Aaron Hartwig <[email protected]>"]
55
edition = "2021"
66

77
[dependencies]
8+
counters = { path = "../../lib/counters" }
89
drv-fpga-api = { path = "../fpga-api" }
910
drv-i2c-api = { path = "../i2c-api" }
1011
drv-i2c-devices = { path = "../i2c-devices" }

drv/transceivers-server/src/main.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
#![no_std]
66
#![no_main]
77

8+
use counters::Count;
9+
use idol_runtime::{NotificationHandler, RequestError};
10+
use multitimer::{Multitimer, Repeat};
11+
use ringbuf::*;
12+
use static_cell::ClaimOnceCell;
13+
use userlib::{sys_get_timer, task_slot, units::Celsius};
14+
815
use drv_fpga_api::FpgaError;
916
use drv_i2c_devices::pca9956b::Error;
1017
use drv_sidecar_front_io::{
@@ -17,16 +24,12 @@ use drv_transceivers_api::{
1724
ModuleStatus, TransceiversError, NUM_PORTS, TRANSCEIVER_TEMPERATURE_SENSORS,
1825
};
1926
use enum_map::Enum;
20-
use idol_runtime::{NotificationHandler, RequestError};
21-
use multitimer::{Multitimer, Repeat};
22-
use ringbuf::*;
23-
use static_cell::ClaimOnceCell;
2427
use task_sensor_api::{NoData, Sensor};
2528
use task_thermal_api::{Thermal, ThermalError, ThermalProperties};
2629
use transceiver_messages::{
2730
message::LedState, mgmt::ManagementInterface, MAX_PACKET_SIZE,
2831
};
29-
use userlib::{sys_get_timer, task_slot, units::Celsius};
32+
3033
use zerocopy::{AsBytes, FromBytes};
3134

3235
mod udp; // UDP API is implemented in a separate file
@@ -41,10 +44,11 @@ task_slot!(SENSOR, sensor);
4144
include!(concat!(env!("OUT_DIR"), "/i2c_config.rs"));
4245

4346
#[allow(dead_code)]
44-
#[derive(Copy, Clone, PartialEq, Eq)]
47+
#[derive(Copy, Clone, PartialEq, Eq, Count)]
4548
enum Trace {
49+
#[count(skip)]
4650
None,
47-
FrontIOBoardReady(bool),
51+
FrontIOBoardReady(#[count(children)] bool),
4852
FrontIOSeqErr(SeqError),
4953
LEDInit,
5054
LEDInitComplete,
@@ -55,7 +59,7 @@ enum Trace {
5559
LEDReadError(Error),
5660
LEDUpdateError(Error),
5761
ModulePresenceUpdate(LogicalPortMask),
58-
TransceiversError(TransceiversError),
62+
TransceiversError(#[count(children)] TransceiversError),
5963
GotInterface(u8, ManagementInterface),
6064
UnknownInterface(u8, ManagementInterface),
6165
UnpluggedModule(usize),
@@ -70,7 +74,8 @@ enum Trace {
7074
DisableFailed(usize, LogicalPortMask),
7175
ClearDisabledPorts(LogicalPortMask),
7276
}
73-
ringbuf!(Trace, 16, Trace::None);
77+
78+
counted_ringbuf!(Trace, 16, Trace::None);
7479

7580
////////////////////////////////////////////////////////////////////////////////
7681

drv/transceivers-server/src/udp.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,30 @@
1010
//!
1111
//! All of the API types in `transceiver_messages` operate on **physical**
1212
//! ports, i.e. an FPGA paired by a physical port index (or mask).
13+
//!
14+
use counters::Count;
15+
use hubpack::SerializedSize;
16+
use ringbuf::*;
17+
use userlib::UnwrapLite;
18+
1319
use crate::{FrontIOStatus, ServerImpl};
1420
use drv_sidecar_front_io::transceivers::{
1521
FpgaI2CFailure, LogicalPort, LogicalPortFailureTypes, LogicalPortMask,
1622
ModuleResult, ModuleResultNoFailure, ModuleResultSlim, PortI2CStatus,
1723
};
18-
use hubpack::SerializedSize;
19-
use ringbuf::*;
2024
use task_net_api::*;
2125
use transceiver_messages::{
2226
mac::MacAddrs,
2327
message::*,
2428
mgmt::{ManagementInterface, MemoryRead, MemoryWrite, Page},
2529
ModuleId,
2630
};
27-
use userlib::UnwrapLite;
2831

2932
////////////////////////////////////////////////////////////////////////////////
3033

31-
#[derive(Copy, Clone, PartialEq)]
34+
#[derive(Copy, Clone, PartialEq, Count)]
3235
enum Trace {
36+
#[count(skip)]
3337
None,
3438
DeserializeError(hubpack::Error),
3539
DeserializeHeaderError(hubpack::Error),
@@ -63,7 +67,7 @@ enum Trace {
6367
WriteI2CFailures(LogicalPort, FpgaI2CFailure),
6468
}
6569

66-
ringbuf!(Trace, 16, Trace::None);
70+
counted_ringbuf!(Trace, 32, Trace::None);
6771

6872
////////////////////////////////////////////////////////////////////////////////
6973
#[derive(Copy, Clone, PartialEq)]

0 commit comments

Comments
 (0)