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

Add a front-io-server to service the front-io board #1805

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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 .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
target/
itm.txt
*.swp
.vscode/
87 changes: 54 additions & 33 deletions Cargo.lock

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

20 changes: 16 additions & 4 deletions app/sidecar/base.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ task-slots = [
"sprot",
"ignition",
"packrat",
"transceivers",
"front_io",
"vpd",
]
features = ["sidecar", "vlan", "auxflash", "vpd"]
Expand Down Expand Up @@ -158,7 +158,7 @@ max-sizes = {flash = 262144, ram = 16384}
features = ["mgmt", "sidecar", "vlan", "use-spi-core", "h753", "spi2"]
stacksize = 4096
start = true
task-slots = ["ecp5_front_io", "sys", { seq = "sequencer" }]
task-slots = ["front_io", "sys", { seq = "sequencer" }]
uses = ["spi2"]
notifications = ["spi-irq", "wake-timer"]
interrupts = {"spi2.irq" = "spi-irq"}
Expand Down Expand Up @@ -232,7 +232,6 @@ max-sizes = {flash = 65536, ram = 16384}
stacksize = 4096
start = true
task-slots = [
"i2c_driver",
"net",
"sensor",
"sys",
Expand All @@ -241,6 +240,19 @@ task-slots = [
{seq = "sequencer"}]
notifications = ["socket", "timer"]

[tasks.front_io]
name = "drv-front-io-server"
priority = 4
max-sizes = {flash = 65536, ram = 16384}
stacksize = 4096
start = true
task-slots = [
"sys",
"auxflash",
"i2c_driver",
{front_io = "ecp5_front_io"}]
notifications = ["timer"]

[tasks.packrat]
name = "task-packrat"
priority = 3
Expand Down Expand Up @@ -1134,7 +1146,7 @@ memory-size = 33_554_432 # 256 Mib / 32 MiB
slot-count = 16 # 2 MiB slots

[[auxflash.blobs]]
file = "drv/sidecar-front-io/sidecar_qsfp_x32_controller_rev_b_c.bit"
file = "drv/front-io-api/sidecar_qsfp_x32_controller_rev_b_c.bit"
compress = true
tag = "QSFP"

Expand Down
5 changes: 4 additions & 1 deletion build/fpga-regmap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ fn write_reg_fields(
writeln!(
output,
"
{prefix} #[derive(Copy, Clone, Eq, PartialEq)]
{prefix} use hubpack::SerializedSize;
{prefix} use serde::{{Deserialize, Serialize}};
{prefix} #[derive(Copy, Clone, Eq, PartialEq, Deserialize, Serialize, SerializedSize)]
{prefix} #[repr(u8)]
{prefix} #[allow(dead_code)]
{prefix} pub enum {encode_name} {{"
)
Expand Down
30 changes: 30 additions & 0 deletions drv/front-io-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "drv-front-io-api"
version = "0.1.0"
edition = "2021"

[dependencies]
hubpack.workspace = true
num-traits.workspace = true
idol-runtime.workspace = true
serde.workspace = true
transceiver-messages.workspace = true
zerocopy.workspace = true

counters = { path = "../../lib/counters", features = ["derive"] }
drv-auxflash-api = { path = "../../drv/auxflash-api" }
drv-fpga-api = { path = "../fpga-api", features = ["auxflash"] }
drv-i2c-api = { path = "../i2c-api" }
drv-i2c-devices = { path = "../i2c-devices" }
derive-idol-err = { path = "../../lib/derive-idol-err" }
userlib = { path = "../../sys/userlib" }

[build-dependencies]
build-fpga-regmap = { path = "../../build/fpga-regmap" }
build-util = { path = "../../build/util" }
idol.workspace = true

[lib]
test = false
doctest = false
bench = false
8 changes: 3 additions & 5 deletions drv/sidecar-front-io/build.rs → drv/front-io-api/build.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use build_fpga_regmap::fpga_regs;
use std::{fs, io::Write};

fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
build_util::expose_target_board();

let board = build_util::env_var("HUBRIS_BOARD")?;
if board != "sidecar-b" && board != "sidecar-c" && board != "sidecar-d" {
panic!("unknown target board");
}
idol::Generator::new()
.with_counters(idol::CounterSettings::default())
.build_client_stub("../../idl/front-io.idol", "client_stub.rs")?;

let out_dir = build_util::out_dir();
let out_file = out_dir.join("sidecar_qsfp_x32_controller_regs.rs");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use userlib::UnwrapLite;

pub struct FrontIOController {
fpga: Fpga,
user_design: FpgaUserDesign,
pub user_design: FpgaUserDesign,
}

impl FrontIOController {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
use super::transceivers::{LogicalPort, LogicalPortMask};
use crate::transceivers::{LogicalPort, LogicalPortMask, NUM_PORTS};
use drv_i2c_api::I2cDevice;
use drv_i2c_devices::pca9956b::{Error, LedErr, Pca9956B};
use drv_transceivers_api::NUM_PORTS;

/// Leds controllers and brightness state
pub struct Leds {
Expand Down
79 changes: 79 additions & 0 deletions drv/front-io-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! API crate for the Front IO server.

#![no_std]

use crate::phy_smi::PhyOscState;
use counters::Count;
use derive_idol_err::IdolError;
use drv_fpga_api::FpgaError;
use hubpack::SerializedSize;
use serde::{Deserialize, Serialize};
use userlib::*;

// Re-export for use in the server
pub use transceiver_messages::message::LedState;

pub mod controller;
pub mod leds;
pub mod phy_smi;
pub mod transceivers;

#[derive(
Copy, Clone, Debug, FromPrimitive, Eq, PartialEq, IdolError, Count,
)]
pub enum FrontIOError {
FpgaError = 1,
NotPresent,
NotReady,
InvalidPortNumber,
InvalidNumberOfBytes,
InvalidPhysicalToLogicalMap,
InvalidModuleResult,
LedInitFailure,

#[idol(server_death)]
ServerRestarted,
}

impl From<FpgaError> for FrontIOError {
fn from(_: FpgaError) -> Self {
Self::FpgaError
}
}

#[derive(
Copy,
Clone,
Debug,
Count,
Eq,
PartialEq,
Deserialize,
Serialize,
SerializedSize,
)]
pub enum FrontIOStatus {
/// No board detected
NotPresent,
/// The FPGAs are being configured
FpgaInit,
/// Confirming that the PHY oscillator is behaving
OscInit,
/// Board is present and fully operational
Ready,
}

include!(concat!(
env!("OUT_DIR"),
"/sidecar_qsfp_x32_controller_regs.rs"
));

use crate::transceivers::{
LogicalPort, LogicalPortMask, ModuleResult, ModuleResultNoFailure,
PortI2CStatus, TransceiverStatus,
};
include!(concat!(env!("OUT_DIR"), "/client_stub.rs"));
Loading
Loading