Skip to content

services: Add the OCP recovery device dispatch - #629

Closed
chrysh wants to merge 3 commits into
OpenPRoT:ocp-global-demo-wipfrom
9elements:ocp-recovery-server
Closed

chrysh wants to merge 3 commits into
OpenPRoT:ocp-global-demo-wipfrom
9elements:ocp-recovery-server

Conversation

@chrysh

@chrysh chrysh commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Stacked on #628 (the first commit is that PR; review the second commit here).

The register file the eRoT serves to the Recovery Agent, and the dispatch that answers one access: reads serve register bytes, refused writes latch the protocol error into DEVICE_STATUS byte 1, and INDIRECT_FIFO_DATA payloads drain into a FifoSink. The DEVICE_STATUS read is the one place the clear-on-read of the protocol error happens.

Policy stays with the caller: an accepted RECOVERY_CTRL or DEVICE_RESET write only lands in the register, and the runtime finds it through take_activation and take_reset_request, which clear the field per the Write 1, Device Clears contract.

RamStaging backs the FIFO in tests and mirrors the ImageSource shape (len, read_at) without depending on the orchestrator driver; the trait impl lands in an orchestrator adapter at composition, the way the pldm adapter binds FdEvent.

Host-testable, no kernel deps, the services/i2c/server half of the pattern. The register file instance will live in the i2c server-runtime loop, which is the only placement that can answer an SMBus read within the clock-stretch budget.

Checked with bazel test //services/ocp-recovery/...:all, the clippy aspect, and ./pw format --all --check.

Fix failing CI on cargo audit and cargo deny checks

(cherry picked from commit 3d38f5d)
Signed-off-by: Christina Quast <christina.quast@9elements.com>
@chrysh
chrysh force-pushed the ocp-recovery-server branch 4 times, most recently from da4081c to 7243d9e Compare November 9, 2026 10:46
The eRoT serves the OCP Recovery interface as the device, and the BMC
drives it as the Recovery Agent. The new crate holds the part that does
not depend on the transport: the command codes 0x22 to 0x2f, the byte
layouts, the field encodings and the rules for which accesses the device
refuses. The SMBus framing, the PEC and the register file that the
server-runtime owns come later, so the crate stays host-testable and
free of kernel dependencies.

The AST1030 has no OCP recovery silicon, so the firmware has to keep the
access semantics the agent expects from hardware. Under "Write 1, Device
Clears", the agent writes the command value and the device zeroes the
field once it has acted. RECOVERY_CTRL, DEVICE_RESET and
INDIRECT_FIFO_CTRL each have an apply_agent_write that takes the write
and a clear_* for the device. A device that cleared the written bits
would turn a pending activation (0xf) into 0xe on a write of 0x1, so
RecoveryCtrl::apply_agent_write refuses 0x1.

Signed-off-by: Christina Quast <christina.quast@9elements.com>
RecoveryInterface holds the registers the eRoT serves to the Recovery
Agent, and the dispatch answers one access. The dispatch serves the
register bytes on a read, latches the protocol error of a refused access
into DEVICE_STATUS byte 1, and drains INDIRECT_FIFO_DATA payloads into a
FifoSink. The DEVICE_STATUS read is the only read that clears a value,
the protocol error.

Policy stays with the caller. An accepted RECOVERY_CTRL or DEVICE_RESET
write only sets the register, and the caller reads the command with
take_activation and take_reset_request, which clear the field under the
"Write 1, Device Clears" contract.

RamStaging backs the FIFO and implements ByteSource, the trait
VerifySession::poll reads a candidate through, so the verifier reads a
staged image with no adapter. ByteSource lives in util/io, a leaf crate,
so services/ocp-recovery/server takes no dependency on the orchestrator
driver. The inherent methods are staged_len and staged_is_empty,
because they answer for the bytes pushed so far, while the ByteSource
methods answer for the announced image.

services/ocp-recovery/server is host-testable with no kernel
dependencies, like services/i2c/server next to
services/i2c/server-runtime. The interface instance is meant to live in
the i2c server-runtime loop, because only that loop can answer an SMBus
read before the clock-stretch budget runs out.

Signed-off-by: Christina Quast <christina.quast@9elements.com>
@chrysh

chrysh commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Closing: the OCP code is not ready for upstream yet. The design proposal is up for review as #680.

@chrysh chrysh closed this Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants