uart-service: add default_mctp_serial constructor#906
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends uart-service with a convenience type alias and constructor for running the relay over DSP0253-framed MCTP-over-serial, mirroring the existing DefaultService / default_smbusespi pattern. It introduces MctpSerialService<R> (a Service<R, MctpSerialMedium> specialization) plus default_mctp_serial() that preconfigures the canonical EC<->SP reply context defaults. To make the medium type available, it also enables the serial feature on the workspace mctp-rs dependency for this crate. The change is additive and should not alter behavior for existing SmbusEspi users.
Changes:
- Add
MctpSerialService<R>type alias to specializeServiceformctp_rs::MctpSerialMedium. - Add
MctpSerialService::default_mctp_serial()constructor that builds aServicewith the canonical reply-context defaults used by the QEMU EC<->SP serial relay path. - Enable
mctp-rs’sserialfeature (pulling in the serial medium implementation and its CRC support).
Step-by-step review guide
-
New serial-medium specialization
pub type MctpSerialService<R> = Service<R, mctp_rs::MctpSerialMedium>;- This matches the existing
DefaultService<R> = Service<R, SmbusEspiMedium>pattern and gives callers a stable, intention-revealing name for the serial configuration.
-
Default constructor semantics
default_mctp_serial()callsService::new(...)withMctpSerialMediumand a pre-filledMctpReplyContextusingEC_EID,SP_EID,message_tag = 0,packet_sequence_number = 0, andmedium_context = ().- Non-obvious detail to confirm:
process_response()overridesdestination_endpoint_idper response usinghandler_service_id, so the constructor’sdestination_endpoint_idis effectively an initialization value (even if it matches the common case).
-
Dependency feature enabling
uart-servicenow depends onmctp-rswithfeatures = ["serial"], ensuringMctpSerialMediumand the EC/SP EID constants are available.- This is a build-time surface-area change (more code gets compiled into
mctp-rsfor this crate), but it is consistent with other crates in this repo enabling themctp-rsfeatures they require.
Potential issues
| # | Severity | File | Description | Code |
|---|---|---|---|---|
| 1 | Low | uart-service/src/lib.rs:198-202 |
The doc comment says destination = SP_EID is hardcoded, but process_response overrides destination_endpoint_id per response; the comment is a bit contradictory and could be clarified. |
/// EC ↔ SP reply context (... destination = SP_EID ...) ... overridden per-response |
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| uart-service/src/lib.rs | Adds a serial-medium service alias and default_mctp_serial() constructor with preconfigured reply context. |
| uart-service/Cargo.toml | Enables mctp-rs’s serial feature so the serial medium type and constants are available. |
kurtjd
left a comment
There was a problem hiding this comment.
Is the plan to follow this up with a PR in odp-embedded-controller changing the constructor used (on all platforms, not just dev-qemu) then a co-PR in odp-platform-common updating the serial backend of the TUI to use this new framing?
|
@kurtjd Correct, that's basically the plan. |
Add MctpSerialService<R> and default_mctp_serial(), the MctpSerialMedium twin of the existing DefaultService/default_smbusespi pair. The constructor hardcodes the canonical EC->SP serial reply context (source=EC_EID, destination=SP_EID, tag=0, medium_context=()), so serial consumers (the QEMU EC<->SP relay path) call one constructor instead of hand-assembling an MctpReplyContext. Enables mctp-rs/serial so the MctpSerialMedium type is available. Assisted-by: GitHub Copilot:claude-opus-4.8
13f7caa to
b8d0f59
Compare
Adds
MctpSerialService<R>anddefault_mctp_serial()touart-service— theMctpSerialMediumtwin of the existingDefaultService/default_smbusespipair.The constructor hardcodes the canonical EC↔SP serial reply context (
source = EC_EID,destination = SP_EID,message_tag = 0,medium_context = ()), mirroringdefault_smbusespifield-for-field. Serial consumers (the QEMU EC↔SP relay path) can then call one constructor instead of hand-assembling anMctpReplyContext. Enablesmctp-rs/serialso theMctpSerialMediumtype is available.No behaviour change to existing callers — purely additive (a new type alias + constructor, plus turning on the
serialfeature of themctp-rsdependency).Unblocks the EC
dev-qemuMCTP-over-serial work inodp-embedded-controller, which will call this constructor to speak the SP's DSP0253 framing over the two-QEMU serial link.Assisted-by: GitHub Copilot:claude-opus-4.8