Skip to content

Wire accepted RequestUpdate to the orchestrator's UpdateRequest event - #442

Open
chrysh wants to merge 4 commits into
OpenPRoT:mainfrom
9elements:pldm-update-request-event
Open

Wire accepted RequestUpdate to the orchestrator's UpdateRequest event#442
chrysh wants to merge 4 commits into
OpenPRoT:mainfrom
9elements:pldm-update-request-event

Conversation

@chrysh

@chrysh chrysh commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What

The PLDM firmware-device loop (run_terminus) now notifies an FdEventSink with FdEvent::UpdateRequested once per accepted RequestUpdate, and a new orchestrator-pldm-adapter crate maps that notification to Event::UpdateRequest for the orchestrator. Only RequestUpdate is wired; cancel/completion edges and the run-loop composition are untouched seams.

How

  • The seam is a #[non_exhaustive] FdEvent enum plus a single FdEventSink::notify method, so the coming FD lifecycle events (cancel, transfer/verify/apply complete, activate) are one new variant each instead of a trait break for every implementor.
  • Every FdEvent payload is Copy and lifetime-free by design. Across the DSP0267 FD surface the orchestrator-relevant edges carry only small integers (result codes, component ids, bitmaps); buffer-shaped data (image chunks, package data, version strings) lands behind FdOps and events name it instead of carrying it.
  • The accepted RequestUpdate is detected as the FD's only Idle → non-Idle transition, sampled around the responder poll, after the success response is sent. Rejected requests (ALREADY_IN_UPDATE_MODE, bad transfer size) leave the state unchanged and never notify.
  • The sink trait stays PLDM-flavored so the service crate never depends on the orchestrator stack. The mapping lives in services/orchestrator/adapters/pldm as UpdateRequestLatch, following the same rule that keeps HAL adapters out of orchestrator-capabilities. The latch matches UpdateRequested and drops unmapped variants.
  • The latch is a bool, not a counter: the FD rejects a second RequestUpdate while one is in progress, and an undrained latch across update cycles coalesces into the single UpdateRequest the state machine would act on anyway.

Tests

  • firmware_update_host drives the latch end to end: the accepted RequestUpdate latches exactly one Event::UpdateRequest, a duplicate is rejected with AlreadyInUpdateMode and latches nothing, and no later command in the flow latches anything.
  • The adapter crate tests latch semantics (empty, exactly-once, coalescing).

The PLDM firmware-device loop now notifies an UpdateEventSink once per
accepted RequestUpdate, detected as the FD's only Idle -> non-Idle
transition, after the success response is sent. Rejected requests
(already in update mode, bad transfer size) leave the state unchanged
and never notify.

The sink trait stays PLDM-flavored so this crate never depends on the
orchestrator stack. The mapping to Event::UpdateRequest lives in the
new orchestrator-pldm-adapter crate as UpdateRequestLatch, following
the same rule that keeps HAL adapters out of orchestrator-capabilities.
The latch is a bool, not a counter: the FD rejects a second
RequestUpdate while one is in progress, and an undrained latch across
update cycles coalesces into the single UpdateRequest the state
machine would act on anyway.

The firmware-update host test drives the latch end to end: the accepted
RequestUpdate latches exactly one Event::UpdateRequest, the duplicate
is rejected with AlreadyInUpdateMode and latches nothing, and no later
command in the flow latches anything.

Signed-off-by: Christina Quast <christina.quast@9elements.com>
@chrysh
chrysh requested review from FerralCoder, leongross and rusty1968 and removed request for FerralCoder, leongross and rusty1968 August 25, 2026 19:07
chrysh added 2 commits August 25, 2026 21:17
hal-adapters moves to adapters/hal and the new PLDM adapter to
adapters/pldm, so the growing family of producer-to-orchestrator
adapter crates (HAL, PLDM, later SPDM) sits under one directory.
Crate and target names are unchanged; each adapter keeps its own
crate so composing one stack never pulls in another.

Signed-off-by: Christina Quast <christina.quast@9elements.com>
More PLDM lifecycle events are coming (cancel, transfer/verify/apply
complete, activate). Replace UpdateEventSink's per-event method with a
non_exhaustive FdEvent enum and a single FdEventSink::notify, so new
events are one variant instead of a trait break.

Every variant payload stays Copy and lifetime-free: across the DSP0267
FD surface the orchestrator-relevant edges carry only small integers;
buffer-shaped data (image chunks, package data, version strings) lands
behind FdOps and events name it instead of carrying it.

UpdateRequested is the only variant for now. The adapter latch keeps
its semantics and drops unmapped events.

Signed-off-by: Christina Quast <christina.quast@9elements.com>
@chrysh
chrysh marked this pull request as ready for review August 26, 2026 20:07
Clippy's single_match lint (denied under -D warnings in presubmit)
rejects a one-arm match with a wildcard. FdEvent derives no PartialEq,
so use matches! rather than an equality check.

Signed-off-by: Christina Quast <christina.quast@9elements.com>
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.

dep: PLDM-T5 Update of single downstream device firmware

1 participant