Skip to content
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
4 changes: 3 additions & 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
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ apob = { git = "https://github.com/oxidecomputer/apob", default-features = false
# for the migration.
attest-data = { git = "https://github.com/oxidecomputer/dice-util", default-features = false, version = "0.4.0", rev = "a0811d06c75c757a6e12c91ed6ea81fde137ba43" }
dice-mfg-msgs = { git = "https://github.com/oxidecomputer/dice-util", default-features = false, version = "0.2.1", rev = "a0811d06c75c757a6e12c91ed6ea81fde137ba43" }
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", default-features = false, features = ["smoltcp"] }
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", default-features = false, features = ["smoltcp"], branch = "james/host-fails" }
gateway-ereport-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", default-features = false }
gimlet-inspector-protocol = { git = "https://github.com/oxidecomputer/gimlet-inspector-protocol", version = "0.1.0" }
hif = { git = "https://github.com/oxidecomputer/hif", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions app/cosmo/base.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ notifications = ["i2c1-irq", "i2c2-irq", "i2c3-irq", "i2c4-irq"]
[tasks.packrat]
name = "task-packrat"
priority = 1
stacksize = 1400
stacksize = 1600
start = true
task-slots = ["jefe"]
features = ["cosmo", "ereport"]
Expand Down Expand Up @@ -258,7 +258,7 @@ features = ["stm32h753", "usart6", "baud_rate_3M", "hardware_flow_control", "vla
uses = ["usart6", "dbgmcu"]
interrupts = {"usart6.irq" = "usart-irq"}
priority = 9
max-sizes = {flash = 74000, ram = 65536}
max-sizes = {flash = 75000, ram = 65536}
stacksize = 5400
start = true
task-slots = ["sys", { cpu_seq = "cosmo_seq" }, "hf", "control_plane_agent", "net", "packrat", "i2c_driver", { spi_driver = "spi2_driver" }, "sprot", "auxflash"]
Expand Down
4 changes: 2 additions & 2 deletions app/gimlet/base.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ notifications = ["i2c1-irq", "jefe-state-change"]
[tasks.packrat]
name = "task-packrat"
priority = 1
stacksize = 1400
stacksize = 1504
start = true
task-slots = ["jefe"]
features = ["gimlet", "ereport"]
Expand Down Expand Up @@ -243,7 +243,7 @@ features = ["stm32h753", "uart7", "baud_rate_3M", "hardware_flow_control", "vlan
uses = ["uart7", "dbgmcu"]
interrupts = {"uart7.irq" = "usart-irq"}
priority = 8
max-sizes = {flash = 72000, ram = 65536}
max-sizes = {flash = 74000, ram = 65536}
stacksize = 5376
start = true
task-slots = ["sys", { cpu_seq = "gimlet_seq" }, "hf", "control_plane_agent", "net", "packrat", "i2c_driver", { spi_driver = "spi2_driver" }, "sprot"]
Expand Down
2 changes: 1 addition & 1 deletion app/grapefruit/standalone.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interrupts = {"uart8.irq" = "usart-irq"}

# Ereport stuff
[tasks.packrat]
stacksize = 1400
stacksize = 1504
task-slots = ["jefe"]
features = ["ereport"]
notifications = ["task-faulted"]
Expand Down
79 changes: 79 additions & 0 deletions idl/packrat.idol
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,84 @@ Interface(
),
idempotent: true,
),
"write_host_bootfail": (
doc: "Write a host's boot failure message and return the index of this failure",
args: {
"reason": "u8",
},
leases: {
"data": (type: "[u8]", read: true),
},
reply: Result(
ok: "HostInfoWriteOutput",
err: ServerDeath,
),
),
"read_first_host_bootfail_fragment": (
doc: "Read a portion of the host's boot failure message",
args: {
},
leases: {
"data": (type: "[u8]", write: true),
},
reply: Result(
ok: "HostBootfailReadOutput",
err: CLike("HostInfoReadError"),
),
idempotent: true,
),
"read_host_bootfail_fragment": (
doc: "Read a portion of the host's boot failure message",
args: {
"request": "HostInfoRequest",
},
leases: {
"data": (type: "[u8]", write: true),
},
reply: Result(
ok: "HostBootfailReadOutput",
err: CLike("HostInfoReadError"),
),
idempotent: true,
),
"write_host_panic": (
doc: "Write a host's panic message and return the index of this panic",
args: {
},
leases: {
"data": (type: "[u8]", read: true),
},
reply: Result(
ok: "HostInfoWriteOutput",
err: ServerDeath,
),
),
"read_first_host_panic_fragment": (
doc: "Read a portion of the host's panic message",
args: {
},
leases: {
"data": (type: "[u8]", write: true),
},
reply: Result(
ok: "HostPanicReadOutput",
err: CLike("HostInfoReadError"),
),
idempotent: true,
),
"read_host_panic_fragment": (
doc: "Read a portion of the host's panic message",
args: {
"request": "HostInfoRequest",
},
leases: {
"data": (type: "[u8]", write: true),
},
reply: Result(
ok: "HostPanicReadOutput",
err: CLike("HostInfoReadError"),
),
idempotent: true,
),
},
)
98 changes: 97 additions & 1 deletion task/control-plane-agent/src/mgs_compute_sled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use gateway_messages::sp_impl::{
use gateway_messages::{
ApobComponentAction, ComponentAction, ComponentActionResponse,
ComponentDetails, ComponentUpdatePrepare, DiscoverResponse, DumpSegment,
DumpTask, GpioToggleCount, Header, IgnitionCommand, IgnitionState,
DumpTask, GpioToggleCount, Header, HostBootfailPayloadData,
HostInfoRequest, HostPanicPayloadData, IgnitionCommand, IgnitionState,
LastPostCode, Message, MessageKind, MgsError, MgsRequest, MgsResponse,
PmbusStatus, PostCode, PowerRailName, PowerState, PowerStateTransition,
RotBootInfo, RotRequest, RotResponse, SERIAL_CONSOLE_IDLE_TIMEOUT,
Expand Down Expand Up @@ -1261,6 +1262,101 @@ impl SpHandler for MgsHandler {
self.host_flash_update.get_hash(slot)
}

fn get_host_panic_payload(
&mut self,
request: Option<HostInfoRequest>,
len: u32,
trailing_tx_buf: &mut [u8],
) -> Result<HostPanicPayloadData, SpError> {
let max_len_usize = len as usize;
let max_len_usize = max_len_usize.min(trailing_tx_buf.len());
let dest = &mut trailing_tx_buf[..max_len_usize];

let res = if let Some(req) = request {
self.common.packrat().read_host_panic_fragment(
task_packrat_api::HostInfoRequest {
offset: req.offset,
index: req.index,
},
dest,
)
} else {
self.common.packrat().read_first_host_panic_fragment(dest)
};
Comment on lines +1275 to +1285

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, it seems to me that this would be a bit simpler if we just made the packrat API take an option, too? do we really need two totally separate IPCs?


let info = res.map_err(|e| {
SpError::HostPanic(match e {
task_packrat_api::HostInfoReadError::NoHostInfo => {
gateway_messages::HostPanicError::NoHostInfo
}
task_packrat_api::HostInfoReadError::InvalidOffset => {
gateway_messages::HostPanicError::InvalidOffset
}
task_packrat_api::HostInfoReadError::InvalidIndex => {
gateway_messages::HostPanicError::InvalidIndex
}
task_packrat_api::HostInfoReadError::ServerRestarted => {
gateway_messages::HostPanicError::ServerRestarted
}
})
})?;

Ok(HostPanicPayloadData {
index: info.index,
len: info.read,
total_len: info.total_len as u32,
})
}

fn get_host_bootfail_payload(
&mut self,
request: Option<HostInfoRequest>,
len: u32,
trailing_tx_buf: &mut [u8],
) -> Result<HostBootfailPayloadData, SpError> {
let max_len_usize = len as usize;
let max_len_usize = max_len_usize.min(trailing_tx_buf.len());
let dest = &mut trailing_tx_buf[..max_len_usize];

let res = if let Some(req) = request {
self.common.packrat().read_host_bootfail_fragment(
task_packrat_api::HostInfoRequest {
offset: req.offset,
index: req.index,
},
dest,
)
} else {
self.common
.packrat()
.read_first_host_bootfail_fragment(dest)
};

let info = res.map_err(|e| {
SpError::HostBootfail(match e {
task_packrat_api::HostInfoReadError::NoHostInfo => {
gateway_messages::HostBootfailError::NoHostInfo
}
task_packrat_api::HostInfoReadError::InvalidOffset => {
gateway_messages::HostBootfailError::InvalidOffset
}
task_packrat_api::HostInfoReadError::InvalidIndex => {
gateway_messages::HostBootfailError::InvalidIndex
}
task_packrat_api::HostInfoReadError::ServerRestarted => {
gateway_messages::HostBootfailError::ServerRestarted
}
})
})?;

Ok(HostBootfailPayloadData {
index: info.index,
len: info.read,
total_len: info.total_len as u32,
reason: info.reason,
})
}

fn get_pmbus_status(
&mut self,
rail: &PowerRailName,
Expand Down
19 changes: 19 additions & 0 deletions task/control-plane-agent/src/mgs_minibar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use gateway_messages::sp_impl::{
use gateway_messages::{
ComponentAction, ComponentActionResponse, ComponentDetails,
ComponentUpdatePrepare, DiscoverResponse, DumpSegment, DumpTask,
HostBootfailPayloadData, HostInfoRequest, HostPanicPayloadData,
IgnitionCommand, IgnitionState, MgsError, MgsRequest, MgsResponse,
PmbusStatus, PowerRailName, PowerState, PowerStateTransition, RotBootInfo,
RotRequest, RotResponse, SensorRequest, SensorResponse, SpComponent,
Expand Down Expand Up @@ -695,4 +696,22 @@ impl SpHandler for MgsHandler {
) -> Result<PmbusStatus, SpError> {
self.common.get_pmbus_status(rail)
}

fn get_host_bootfail_payload(
&mut self,
_request: Option<HostInfoRequest>,
_len: u32,
_trailing_tx_buf: &mut [u8],
) -> Result<HostBootfailPayloadData, SpError> {
Err(SpError::RequestUnsupportedForSp)
}

fn get_host_panic_payload(
&mut self,
_request: Option<HostInfoRequest>,
_len: u32,
_trailing_tx_buf: &mut [u8],
) -> Result<HostPanicPayloadData, SpError> {
Err(SpError::RequestUnsupportedForSp)
}
}
19 changes: 19 additions & 0 deletions task/control-plane-agent/src/mgs_psc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use gateway_messages::sp_impl::{
use gateway_messages::{
ComponentAction, ComponentActionResponse, ComponentDetails,
ComponentUpdatePrepare, DiscoverResponse, DumpSegment, DumpTask,
HostBootfailPayloadData, HostInfoRequest, HostPanicPayloadData,
IgnitionCommand, IgnitionState, MgsError, MgsRequest, MgsResponse,
PmbusStatus, PowerRailName, PowerState, PowerStateTransition, RotBootInfo,
RotRequest, RotResponse, SensorRequest, SensorResponse, SpComponent,
Expand Down Expand Up @@ -710,4 +711,22 @@ impl SpHandler for MgsHandler {
) -> Result<PmbusStatus, SpError> {
self.common.get_pmbus_status(rail)
}

fn get_host_bootfail_payload(
&mut self,
_request: Option<HostInfoRequest>,
_len: u32,
_trailing_tx_buf: &mut [u8],
) -> Result<HostBootfailPayloadData, SpError> {
Err(SpError::RequestUnsupportedForSp)
}

fn get_host_panic_payload(
&mut self,
_request: Option<HostInfoRequest>,
_len: u32,
_trailing_tx_buf: &mut [u8],
) -> Result<HostPanicPayloadData, SpError> {
Err(SpError::RequestUnsupportedForSp)
}
}
34 changes: 26 additions & 8 deletions task/control-plane-agent/src/mgs_sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ use gateway_messages::sp_impl::{
use gateway_messages::{
ComponentAction, ComponentActionResponse, ComponentDetails,
ComponentUpdatePrepare, DiscoverResponse, DumpSegment, DumpTask,
EcdsaSha2Nistp256Challenge, IgnitionCommand, IgnitionState, MgsError,
MgsRequest, MgsResponse, MonorailComponentAction,
MonorailComponentActionResponse, MonorailError as GwMonorailError,
PcieRegisterRead, PmbusStatus, PowerRailName, PowerState,
PowerStateTransition, RotBootInfo, RotRequest, RotResponse, SensorRequest,
SensorResponse, SpComponent, SpError, SpStateV2, SpUpdatePrepare,
UnlockChallenge, UnlockResponse, UpdateChunk, UpdateId, UpdateStatus,
ignition,
EcdsaSha2Nistp256Challenge, HostBootfailPayloadData, HostInfoRequest,
HostPanicPayloadData, IgnitionCommand, IgnitionState, MgsError, MgsRequest,
MgsResponse, MonorailComponentAction, MonorailComponentActionResponse,
MonorailError as GwMonorailError, PcieRegisterRead, PmbusStatus,
PowerRailName, PowerState, PowerStateTransition, RotBootInfo, RotRequest,
RotResponse, SensorRequest, SensorResponse, SpComponent, SpError,
SpStateV2, SpUpdatePrepare, UnlockChallenge, UnlockResponse, UpdateChunk,
UpdateId, UpdateStatus, ignition,
};
use host_sp_messages::HostStartupOptions;
use idol_runtime::{Leased, RequestError};
Expand Down Expand Up @@ -1236,6 +1236,24 @@ impl SpHandler for MgsHandler {
) -> Result<PmbusStatus, SpError> {
self.common.get_pmbus_status(rail)
}

fn get_host_bootfail_payload(
&mut self,
_request: Option<HostInfoRequest>,
_len: u32,
_trailing_tx_buf: &mut [u8],
) -> Result<HostBootfailPayloadData, SpError> {
Err(SpError::RequestUnsupportedForSp)
}

fn get_host_panic_payload(
&mut self,
_request: Option<HostInfoRequest>,
_len: u32,
_trailing_tx_buf: &mut [u8],
) -> Result<HostPanicPayloadData, SpError> {
Err(SpError::RequestUnsupportedForSp)
}
}

fn get_ecdsa_challenge() -> Result<EcdsaSha2Nistp256Challenge, SpError> {
Expand Down
4 changes: 4 additions & 0 deletions task/host-sp-comms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ task-sensor-api = { path = "../../task/sensor-api", optional = true, features =
ksz8463 = { path = "../../drv/ksz8463", optional = true }
drv-sprot-api = { path = "../../drv/sprot-api"}

# ereports deps
ereports = { path = "../../lib/ereports", features = ["ereporter-macro"] }
microcbor = { path = "../../lib/microcbor" }

[build-dependencies]
build-util.path = "../../build/util"
build-i2c = { path = "../../build/i2c", optional = true }
Expand Down
Loading
Loading