Skip to content

Commit

Permalink
New reset-with-watchdog semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Apr 5, 2024
1 parent 493860e commit c5ee27b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 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.

10 changes: 7 additions & 3 deletions task/control-plane-agent/src/mgs_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,16 @@ impl MgsCommon {
Ok(cnt)
}

pub(crate) fn enable_sp_slot_watchdog(
pub(crate) fn reset_with_watchdog(
&mut self,
time_ms: u32,
) -> Result<(), SpError> {
) -> Result<core::convert::Infallible, SpError> {
if self.reset_component_requested != Some(SpComponent::SP_ITSELF) {
return Err(SpError::ResetComponentTriggerWithoutPrepare);
}
self.sprot.enable_sp_slot_watchdog(time_ms)?;
Ok(())
task_jefe_api::Jefe::from(crate::JEFE.get_task_id()).request_reset();
panic!(); // we really really shouldn't get here
}

pub(crate) fn disable_sp_slot_watchdog(&mut self) -> Result<(), SpError> {
Expand Down
12 changes: 9 additions & 3 deletions task/control-plane-agent/src/mgs_gimlet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use gateway_messages::{
DiscoverResponse, Header, IgnitionCommand, IgnitionState, Message,
MessageKind, MgsError, PowerState, RotRequest, RotResponse, SensorRequest,
SensorResponse, SpComponent, SpError, SpPort, SpRequest, SpStateV2,
SpUpdatePrepare, UpdateChunk, UpdateId, UpdateStatus,
SpUpdatePrepare, UpdateChunk, UpdateId, UpdateStatus, WatchdogError,
SERIAL_CONSOLE_IDLE_TIMEOUT,
};
use heapless::{Deque, Vec};
Expand Down Expand Up @@ -1112,8 +1112,14 @@ impl SpHandler for MgsHandler {
self.common.vpd_lock_status_all(buf)
}

fn enable_sp_slot_watchdog(&mut self, time_ms: u32) -> Result<(), SpError> {
self.common.enable_sp_slot_watchdog(time_ms)
fn reset_with_watchdog(
&mut self,
time_ms: u32,
) -> Result<core::convert::Infallible, SpError> {
if !matches!(self.sp_update.status(), UpdateStatus::Complete(..)) {
return Err(SpError::Watchdog(WatchdogError::NoCompletedUpdate));
}
self.common.reset_with_watchdog(time_ms)
}

fn disable_sp_slot_watchdog(&mut self) -> Result<(), SpError> {
Expand Down
10 changes: 8 additions & 2 deletions task/control-plane-agent/src/mgs_psc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,14 @@ impl SpHandler for MgsHandler {
self.common.vpd_lock_status_all(buf)
}

fn enable_sp_slot_watchdog(&mut self, time_ms: u32) -> Result<(), SpError> {
self.common.enable_sp_slot_watchdog(time_ms)
fn reset_with_watchdog(
&mut self,
time_ms: u32,
) -> Result<core::convert::Infallible, SpError> {
if !matches!(self.sp_update.status(), UpdateStatus::Complete(..)) {
return Err(SpError::Watchdog(WatchdogError::NoCompletedUpdate));
}
self.common.reset_with_watchdog(time_ms)
}

fn disable_sp_slot_watchdog(&mut self) -> Result<(), SpError> {
Expand Down
10 changes: 8 additions & 2 deletions task/control-plane-agent/src/mgs_sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,8 +759,14 @@ impl SpHandler for MgsHandler {
self.common.vpd_lock_status_all(buf)
}

fn enable_sp_slot_watchdog(&mut self, time_ms: u32) -> Result<(), SpError> {
self.common.enable_sp_slot_watchdog(time_ms)
fn reset_with_watchdog(
&mut self,
time_ms: u32,
) -> Result<core::convert::Infallible, SpError> {
if !matches!(self.sp_update.status(), UpdateStatus::Complete(..)) {
return Err(SpError::Watchdog(WatchdogError::NoCompletedUpdate));
}
self.common.reset_with_watchdog(time_ms)
}

fn disable_sp_slot_watchdog(&mut self) -> Result<(), SpError> {
Expand Down

0 comments on commit c5ee27b

Please sign in to comment.