Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron-Hartwig committed Jan 23, 2024
1 parent 631e36e commit 6af05da
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -130,5 +130,5 @@ sprockets-common = { git = "https://github.com/oxidecomputer/sprockets.git", def
sprockets-rot = { git = "https://github.com/oxidecomputer/sprockets.git", default-features = false }
tlvc = { git = "https://github.com/oxidecomputer/tlvc", default-features = false, version = "0.3.1" }
tlvc-text = { git = "https://github.com/oxidecomputer/tlvc", default-features = false, version = "0.3.0" }
transceiver-messages = { git = "https://github.com/oxidecomputer/transceiver-control/", default-features = false }
transceiver-messages = { git = "https://github.com/oxidecomputer/transceiver-control/", default-features = false, branch = "moar-errors"}
vsc7448-pac = { git = "https://github.com/oxidecomputer/vsc7448", default-features = false }
76 changes: 43 additions & 33 deletions drv/transceivers-server/src/main.rs
Expand Up @@ -98,7 +98,11 @@ struct ServerImpl {
modules_present: LogicalPortMask,

/// The Front IO board is not guaranteed to be present and ready
check_front_io_status: bool,
///
/// None = Front IO is not yet ready
/// Some(false) = Front IO is not present
/// Some(true) = Front IO is present and ready.
front_io_board_present: Option<bool>,

/// State around LED management
led_error: FullErrorSummary,
Expand Down Expand Up @@ -618,7 +622,7 @@ fn main() -> ! {
leds,
net,
modules_present: LogicalPortMask(0),
check_front_io_status: true,
front_io_board_present: None,
led_error: Default::default(),
leds_initialized: false,
led_states: LedStates([LedState::Off; NUM_PORTS as usize]),
Expand Down Expand Up @@ -668,37 +672,43 @@ fn main() -> ! {
// Handle the Front IO status checking as part of this
// loop because the frequency is what we had before and
// the server itself has no knowledge of the sequencer.
if server.check_front_io_status {
let ready = seq.front_io_board_ready();

match ready {
Ok(true) => {
ringbuf_entry!(Trace::FrontIOBoardReady(
true
));
server.check_front_io_status = false;
ringbuf_entry!(Trace::LEDInit);
match server
.transceivers
.enable_led_controllers()
{
Ok(_) => server.led_init(),
Err(e) => ringbuf_entry!(
Trace::LEDEnableError(e)
),
};
}
Err(SeqError::NoFrontIOBoard) => {
ringbuf_entry!(Trace::FrontIOSeqErr(
SeqError::NoFrontIOBoard
));
server.check_front_io_status = false;
}
_ => {
ringbuf_entry!(Trace::FrontIOBoardReady(
false
));
}
if server.front_io_board_present.is_none() {
server.front_io_board_present =
match seq.front_io_board_ready() {
Ok(true) => {
ringbuf_entry!(
Trace::FrontIOBoardReady(true)
);
Some(true)
}
Err(SeqError::NoFrontIOBoard) => {
ringbuf_entry!(Trace::FrontIOSeqErr(
SeqError::NoFrontIOBoard
));
Some(false)
}
_ => {
ringbuf_entry!(
Trace::FrontIOBoardReady(false)
);
None
}
};

// If a board is present, attempt to initialize its
// LED drivers
if server.front_io_board_present.unwrap_or_default()
{
ringbuf_entry!(Trace::LEDInit);
match server
.transceivers
.enable_led_controllers()
{
Ok(_) => server.led_init(),
Err(e) => {
ringbuf_entry!(Trace::LEDEnableError(e))
}
};
}
}

Expand Down
64 changes: 43 additions & 21 deletions drv/transceivers-server/src/udp.rs
Expand Up @@ -305,15 +305,24 @@ impl ServerImpl {
HostRequest::Status(modules) => {
ringbuf_entry!(Trace::Status(modules));
let mask = LogicalPortMask::from(modules);
let (num_status_bytes, result) = self.get_status(mask, out);
let (data_len, result) = if self
.front_io_board_present
.unwrap_or_default()
{
self.get_status(mask, out)
} else {
(
0,
ModuleResultNoFailure::new(LogicalPortMask(0), mask)
.unwrap(),
)
};

ringbuf_entry!(Trace::OperationNoFailResult(result));
let success = ModuleId::from(result.success());
let (err_len, errored_modules) = self.handle_errors(
modules,
result,
&mut out[num_status_bytes..],
);
let final_payload_len = num_status_bytes + err_len;
let (err_len, errored_modules) =
self.handle_errors(modules, result, &mut out[data_len..]);
let final_payload_len = data_len + err_len;

(
MessageBody::SpResponse(SpResponse::Status {
Expand All @@ -326,16 +335,24 @@ impl ServerImpl {
HostRequest::ExtendedStatus(modules) => {
ringbuf_entry!(Trace::ExtendedStatus(modules));
let mask = LogicalPortMask::from(modules);
let (num_status_bytes, result) =
self.get_extended_status(mask, out);
let (data_len, result) = if self
.front_io_board_present
.unwrap_or_default()
{
self.get_extended_status(mask, out)
} else {
(
0,
ModuleResultNoFailure::new(LogicalPortMask(0), mask)
.unwrap(),
)
};

ringbuf_entry!(Trace::OperationNoFailResult(result));
let success = ModuleId::from(result.success());
let (err_len, errored_modules) = self.handle_errors(
modules,
result,
&mut out[num_status_bytes..],
);
let final_payload_len = num_status_bytes + err_len;
let (err_len, errored_modules) =
self.handle_errors(modules, result, &mut out[data_len..]);
let final_payload_len = data_len + err_len;

(
MessageBody::SpResponse(SpResponse::ExtendedStatus {
Expand Down Expand Up @@ -723,12 +740,17 @@ impl ServerImpl {
if module <= LogicalPortMask::MAX_PORT_INDEX
&& result.error().is_set(module)
{
// error: fpga communication issue
let err_size = hubpack::serialize(
&mut out[error_idx..],
&HwError::FpgaError,
)
.unwrap();
let err_type = match self.front_io_board_present {
// Front IO is present and ready, so the only other error
// path currently is if we handle an FpgaError.
Some(true) => HwError::FpgaError,
Some(false) => HwError::NoFrontIo,
None => HwError::FrontIoNotReady,
};

let err_size =
hubpack::serialize(&mut out[error_idx..], &err_type)
.unwrap();
error_idx += err_size;
} else if requested_invalid_modules.is_set(module.0).unwrap() {
// let the host know it requested unsupported modules
Expand Down

0 comments on commit 6af05da

Please sign in to comment.