Skip to content

Commit fd944f7

Browse files
committed
sidecar-b compiles
1 parent a2398f7 commit fd944f7

File tree

15 files changed

+246
-60
lines changed

15 files changed

+246
-60
lines changed

app/sidecar/base.toml

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ task-slots = ["sys", "packrat", { seq = "sequencer" }, "jefe"]
105105
[tasks.control_plane_agent]
106106
name = "task-control-plane-agent"
107107
priority = 7
108-
max-sizes = {flash = 142900, ram = 65536 }
109108
# This is a big number -- do we need to tune this?
110109
stacksize = 12000
111110
start = true

drv/fpga-api/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl FpgaUserDesign {
368368
value: T,
369369
) -> Result<(), FpgaError>
370370
where
371-
T: IntoBytes,
371+
T: IntoBytes + Immutable,
372372
{
373373
self.write_bytes(op, addr, value.as_bytes())
374374
}

drv/ignition-api/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,8 @@ impl From<TransceiverEvents> for u8 {
644644
FromPrimitive,
645645
ToPrimitive,
646646
IntoBytes,
647+
Immutable,
648+
KnownLayout,
647649
)]
648650
#[repr(u8)]
649651
pub enum TransceiverSelect {

drv/monorail-api/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub struct PhyStatus {
251251
zerocopy::IntoBytes,
252252
zerocopy::FromBytes,
253253
zerocopy::Immutable,
254-
KnownLayout,
254+
zerocopy::KnownLayout,
255255
)]
256256
#[repr(C)]
257257
pub struct MacTableEntry {

drv/sidecar-front-io/src/phy_smi.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ use core::cell::Cell;
77
use crate::{Addr, Reg};
88
use drv_fpga_api::{FpgaError, FpgaUserDesign, WriteOp};
99
use vsc85xx::{PhyRw, VscError};
10-
use zerocopy::{byteorder, FromBytes, IntoBytes, Unaligned, U16};
10+
use zerocopy::{
11+
byteorder::little_endian, FromBytes, Immutable, IntoBytes, KnownLayout,
12+
Unaligned,
13+
};
1114

1215
#[derive(Copy, Clone, Eq, Debug, PartialEq)]
1316
pub enum PhyOscState {
@@ -159,7 +162,7 @@ impl PhySmi {
159162
value: u16,
160163
) -> Result<(), FpgaError> {
161164
let request = SmiWriteRequest {
162-
wdata: U16::new(value),
165+
wdata: little_endian::U16::new(value),
163166
phy,
164167
reg,
165168
ctrl: Reg::VSC8562::PHY_SMI_CTRL::RW
@@ -188,26 +191,26 @@ impl PhyRw for PhySmi {
188191
}
189192
}
190193

191-
#[derive(IntoBytes, FromBytes, Unaligned)]
194+
#[derive(IntoBytes, FromBytes, Unaligned, Immutable, KnownLayout)]
192195
#[repr(C)]
193196
struct SmiWriteRequest {
194-
wdata: U16<byteorder::LittleEndian>,
197+
wdata: little_endian::U16,
195198
phy: u8,
196199
reg: u8,
197200
ctrl: u8,
198201
}
199202

200-
#[derive(IntoBytes, FromBytes, Unaligned)]
203+
#[derive(IntoBytes, FromBytes, Unaligned, Immutable, KnownLayout)]
201204
#[repr(C)]
202205
struct SmiReadRequest {
203206
phy: u8,
204207
reg: u8,
205208
ctrl: u8,
206209
}
207210

208-
#[derive(IntoBytes, FromBytes, Unaligned, Default)]
211+
#[derive(IntoBytes, FromBytes, Unaligned, Default, Immutable, KnownLayout)]
209212
#[repr(C)]
210213
struct SmiReadData {
211214
status: u8,
212-
rdata: U16<byteorder::LittleEndian>,
215+
rdata: little_endian::U16,
213216
}

drv/sidecar-front-io/src/transceivers.rs

+14-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ use drv_fpga_api::{FpgaError, FpgaUserDesign, ReadOp, WriteOp};
77
use drv_transceivers_api::{ModuleStatus, TransceiversError, NUM_PORTS};
88
use transceiver_messages::ModuleId;
99
use userlib::UnwrapLite;
10-
use zerocopy::{byteorder, FromBytes, IntoBytes, Unaligned, U16};
10+
use zerocopy::{
11+
byteorder::little_endian, FromBytes, Immutable, IntoBytes, KnownLayout,
12+
Unaligned,
13+
};
1114

1215
// The transceiver modules are split across two FPGAs on the QSFP Front IO
1316
// board, so while we present the modules as a unit, the communication is
@@ -732,7 +735,7 @@ impl Transceivers {
732735
let mask = fpga_masks.get(fpga_index);
733736
if !mask.is_empty() {
734737
let fpga = self.fpga(fpga_index);
735-
let wdata: U16<byteorder::LittleEndian> = U16::new(mask.get());
738+
let wdata = little_endian::U16::new(mask.get());
736739
// mark that an error occurred so we can modify the success mask
737740
if fpga.write(op, addr, wdata).is_err() {
738741
error |= match fpga_index {
@@ -832,11 +835,11 @@ impl Transceivers {
832835
/// success: we were able to read from the FPGA
833836
/// error: an `FpgaError` occurred
834837
pub fn get_module_status(&self) -> (ModuleStatus, ModuleResultNoFailure) {
835-
let ldata: Option<[U16<byteorder::LittleEndian>; 8]> = self
838+
let ldata: Option<[little_endian::U16; 8]> = self
836839
.fpga(FpgaController::Left)
837840
.read(Addr::QSFP_POWER_EN0)
838841
.ok();
839-
let rdata: Option<[U16<byteorder::LittleEndian>; 8]> = self
842+
let rdata: Option<[little_endian::U16; 8]> = self
840843
.fpga(FpgaController::Right)
841844
.read(Addr::QSFP_POWER_EN0)
842845
.ok();
@@ -877,7 +880,8 @@ impl Transceivers {
877880
let error = !success;
878881

879882
(
880-
ModuleStatus::read_from(status_masks.as_bytes()).unwrap_lite(),
883+
ModuleStatus::read_from_bytes(status_masks.as_bytes())
884+
.unwrap_lite(),
881885
ModuleResultNoFailure::new(success, error).unwrap_lite(),
882886
)
883887
}
@@ -988,7 +992,7 @@ impl Transceivers {
988992
let request = TransceiversI2CRequest {
989993
reg,
990994
num_bytes,
991-
mask: U16::new(fpga_masks.left.0),
995+
mask: little_endian::U16::new(fpga_masks.left.0),
992996
op: i2c_op as u8,
993997
};
994998

@@ -1005,7 +1009,7 @@ impl Transceivers {
10051009
let request = TransceiversI2CRequest {
10061010
reg,
10071011
num_bytes,
1008-
mask: U16::new(fpga_masks.right.0),
1012+
mask: little_endian::U16::new(fpga_masks.right.0),
10091013
op: i2c_op as u8,
10101014
};
10111015
if self
@@ -1243,7 +1247,7 @@ impl Transceivers {
12431247
// The I2C control register looks like:
12441248
// [2..1] - Operation (0 - Read, 1 - Write, 2 - RandomRead)
12451249
// [0] - Start
1246-
#[derive(Copy, Clone, Debug, IntoBytes)]
1250+
#[derive(Copy, Clone, Debug, IntoBytes, Immutable, KnownLayout)]
12471251
#[repr(u8)]
12481252
pub enum TransceiverI2COperation {
12491253
Read = 0x01,
@@ -1258,11 +1262,11 @@ impl From<TransceiverI2COperation> for u8 {
12581262
}
12591263
}
12601264

1261-
#[derive(IntoBytes, FromBytes, Unaligned)]
1265+
#[derive(IntoBytes, FromBytes, Immutable, KnownLayout, Unaligned)]
12621266
#[repr(C)]
12631267
pub struct TransceiversI2CRequest {
12641268
reg: u8,
12651269
num_bytes: u8,
1266-
mask: U16<byteorder::LittleEndian>,
1270+
mask: little_endian::U16,
12671271
op: u8,
12681272
}

drv/sidecar-mainboard-controller/src/fan_modules.rs

+23-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@ use crate::{Addr, MainboardController, Reg};
66
use bitfield::bitfield;
77
use drv_fpga_api::{FpgaError, FpgaUserDesign, WriteOp};
88
use userlib::FromPrimitive;
9-
use zerocopy::{FromBytes, IntoBytes};
9+
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
1010

1111
use Reg::FAN0_STATE;
1212
bitfield! {
13-
#[derive(Copy, Clone, PartialEq, Eq, FromPrimitive, IntoBytes, FromBytes)]
13+
#[derive(
14+
Copy,
15+
Clone,
16+
PartialEq,
17+
Eq,
18+
FromPrimitive,
19+
IntoBytes,
20+
FromBytes,
21+
Immutable,
22+
KnownLayout
23+
)]
1424
#[repr(C)]
1525
pub struct FanModuleStatus(u8);
1626
pub enable, set_enable: FAN0_STATE::ENABLE.trailing_zeros() as usize;
@@ -41,7 +51,17 @@ pub enum FanModulePowerState {
4151
///
4252
/// The SP applies control at the individual fan level. Power control and
4353
/// status, module presence, and module LED control exist at the module level.
44-
#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoBytes)]
54+
#[derive(
55+
Copy,
56+
Clone,
57+
Debug,
58+
PartialEq,
59+
Eq,
60+
FromPrimitive,
61+
IntoBytes,
62+
Immutable,
63+
KnownLayout,
64+
)]
4565
#[repr(u8)]
4666
pub enum FanModuleIndex {
4767
Zero = 0,

drv/sidecar-mainboard-controller/src/ignition.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use crate::{Addr as MainboardControllerAddr, MainboardController};
66
use drv_fpga_api::{FpgaError, FpgaUserDesign, WriteOp};
77
use drv_ignition_api::{Addr as IgnitionPageAddr, *};
8-
use zerocopy::{FromBytes, IntoBytes};
8+
use zerocopy::{FromBytes, Immutable, IntoBytes};
99

1010
pub struct IgnitionController {
1111
fpga: FpgaUserDesign,
@@ -49,7 +49,7 @@ impl IgnitionController {
4949
value: T,
5050
) -> Result<(), FpgaError>
5151
where
52-
T: IntoBytes + FromBytes,
52+
T: IntoBytes + FromBytes + Immutable,
5353
{
5454
self.fpga
5555
.write(WriteOp::Write, self.port_addr(port, offset), value)
@@ -64,7 +64,7 @@ impl IgnitionController {
6464
value: T,
6565
) -> Result<(), FpgaError>
6666
where
67-
T: IntoBytes + FromBytes,
67+
T: IntoBytes + FromBytes + Immutable,
6868
{
6969
self.fpga.write(op, self.port_addr(port, offset), value)
7070
}

0 commit comments

Comments
 (0)