Skip to content

type-c-service/wrapper: Break-out existing wrapper code into per-port structs#818

Merged
RobertZ2011 merged 11 commits into
OpenDevicePartnership:v0.2.0from
RobertZ2011:type-c-per-port-transition
May 6, 2026
Merged

type-c-service/wrapper: Break-out existing wrapper code into per-port structs#818
RobertZ2011 merged 11 commits into
OpenDevicePartnership:v0.2.0from
RobertZ2011:type-c-per-port-transition

Conversation

@RobertZ2011
Copy link
Copy Markdown
Contributor

@RobertZ2011 RobertZ2011 commented Apr 28, 2026

This PR moves the existing logic from the wrapper module, which manages multiple ports on a PD controller, into individual structs for each port. This is done in several steps:

  • Remaining power policy messaging is removed in favor of function calls
  • EventReceiver struct is broken up into per-port event receivers
  • Logic from wrapper is moved into the existing port proxy structs.
  • Module structure is simplified and port proxy structs renamed to just Port.

@RobertZ2011 RobertZ2011 force-pushed the type-c-per-port-transition branch 4 times, most recently from dde13a4 to d41aaf7 Compare April 29, 2026 22:07
@RobertZ2011 RobertZ2011 self-assigned this May 1, 2026
@RobertZ2011 RobertZ2011 force-pushed the type-c-per-port-transition branch from e32cadc to 31afce1 Compare May 1, 2026 17:47
@RobertZ2011 RobertZ2011 changed the title Type c per port transition type-c-service/wrapper: Break-out existing wrapper code into per-port structs May 1, 2026
@RobertZ2011 RobertZ2011 force-pushed the type-c-per-port-transition branch 4 times, most recently from 8d95207 to 5b5dc20 Compare May 4, 2026 21:16
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

Cargo Vet Audit Passed

cargo vet has passed in this PR. No new unvetted dependencies were found.

@github-actions github-actions Bot added the cargo vet PRs pending auditor review label May 4, 2026
@RobertZ2011 RobertZ2011 force-pushed the type-c-per-port-transition branch from 915c055 to 8b523bc Compare May 4, 2026 21:38
@RobertZ2011 RobertZ2011 requested a review from Copilot May 4, 2026 21:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Type‑C controller “wrapper” (which previously managed multiple PD ports in one struct) into per‑port Port structs under a new type-c-service::controller module. It also removes the power‑policy proxy/messaging layer in favor of direct Psu trait calls, updates the Type‑C service event shapes accordingly, and adjusts examples/tests and supply‑chain metadata to match.

Changes:

  • Replace type-c-service/src/wrapper/* with type-c-service/src/controller/* (per‑port Port, per‑port event receiver, shared state).
  • Remove power‑policy proxy command/response plumbing; rely on Psu trait methods and device‑maintained PSU state.
  • Update Type‑C interface/service event payloads (status changed data + DP status value) and update examples, tests, lockfiles, and cargo‑vet config.

Reviewed changes

Copilot reviewed 35 out of 39 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
type-c-service/src/wrapper/vdm.rs Removed; VDM handling moved into per‑port controller code.
type-c-service/src/wrapper/proxy.rs Removed power proxy channel/device abstraction.
type-c-service/src/wrapper/power.rs Removed wrapper power‑policy command handling.
type-c-service/src/wrapper/pd.rs Removed wrapper PD helper logic (sink‑ready timeout moved).
type-c-service/src/wrapper/mod.rs Removed the multi‑port ControllerWrapper implementation.
type-c-service/src/wrapper/message.rs Removed wrapper event/output message types.
type-c-service/src/wrapper/event_receiver.rs Removed wrapper event receivers (replaced by controller event receiver/splitter).
type-c-service/src/wrapper/dp.rs Removed; DP status handling moved into controller PD module.
type-c-service/src/wrapper/backing.rs Removed wrapper backing storage/registration/proxy state.
type-c-service/src/task.rs Simplified Type‑C task signature; no longer registers wrappers/controllers.
type-c-service/src/service/mod.rs Updated to consume new StatusChangedData payload shape.
type-c-service/src/lib.rs Exposes new controller module; removes wrapper module export.
type-c-service/src/driver/tps6699x.rs Retargets interrupt receiver trait impl to the new controller event receiver module.
type-c-service/src/controller/state.rs New shared per‑port state (sink‑ready timeout) between port + receiver.
type-c-service/src/controller/power.rs New per‑port power policy logic and Psu impl on Port.
type-c-service/src/controller/pd.rs New per‑port PD helpers (VDM/DP status/alert) and event emission.
type-c-service/src/controller/mod.rs New per‑port Port struct: state cache, sync, event processing, and event emission.
type-c-service/src/controller/event.rs New per‑port event/loopback event types.
type-c-service/src/controller/event_receiver.rs New per‑port event receiver + interrupt splitter and sink‑ready timeout selection.
type-c-service/src/controller/config.rs New controller config (unconstrained sink behavior).
type-c-interface/src/service/event.rs Changes service port event payloads (StatusChangedData, DpStatusUpdate(DpStatus)).
supply-chain/imports.lock Updates imported audit metadata/audits set.
supply-chain/config.toml Removes broad exemptions (tightens cargo‑vet policy configuration).
supply-chain/audits.toml Adds audits for device-driver v1.0.9 (safe‑to‑deploy + safe‑to‑run).
power-policy-service/tests/common/mock.rs Updates mock PSU to mutate internal state on simulated events and direct calls.
power-policy-service/src/service/provider.rs Removes redundant PSU state mutation after connect_provider.
power-policy-service/src/service/mod.rs Stops mutating PSU internal state on notifications (assumes device updates its own state).
power-policy-service/src/service/consumer.rs Removes redundant PSU state mutation after connect/disconnect operations.
power-policy-interface/src/psu/mod.rs Loosens State::disconnect to allow Idle; removes proxy command/response types.
power-policy-interface/src/psu/event.rs Removes power policy response types from event module.
examples/std/src/lib/type_c/mock_controller.rs Updates mock controller types/aliases to use new per‑port controller wiring.
examples/std/src/bin/type_c/unconstrained.rs Reworks example wiring: per‑port tasks + interrupt splitter + loopback channels.
examples/std/src/bin/type_c/ucsi.rs Reworks example wiring for new per‑port controller model.
examples/std/src/bin/type_c/service.rs Reworks service example wiring; adjusts alert handling return type.
examples/std/src/bin/power_policy.rs Updates example PSU to maintain its own State transitions.
examples/rt685s-evk/src/bin/type_c.rs Reworks embedded example wiring: per‑port tasks + interrupt splitter + new registration.
examples/rt685s-evk/src/bin/type_c_cfu.rs Reworks CFU example wiring similarly to per‑port controller model.
examples/rt685s-evk/Cargo.lock Updates dependency lockfile (e.g., device-driver / git deps).
Cargo.lock Updates workspace lockfile (e.g., device-driver / git deps).

Comment thread type-c-service/src/controller/pd.rs Outdated
Comment thread type-c-service/src/controller/pd.rs
Comment thread type-c-service/src/controller/mod.rs Outdated
Comment thread type-c-interface/src/service/event.rs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 35 out of 39 changed files in this pull request and generated 1 comment.

Comment thread type-c-service/src/controller/event_receiver.rs
@RobertZ2011 RobertZ2011 marked this pull request as ready for review May 4, 2026 21:59
@RobertZ2011 RobertZ2011 requested review from a team as code owners May 4, 2026 21:59
Comment thread examples/rt685s-evk/src/bin/type_c.rs Outdated
Comment thread type-c-service/src/controller/event_receiver.rs
@RobertZ2011 RobertZ2011 requested a review from jerrysxie May 5, 2026 21:03
jerrysxie
jerrysxie previously approved these changes May 5, 2026
RobertZ2011 added 11 commits May 6, 2026 11:04
This implementation currently takes responsibility for updating the
state of each PSU. This is not as flexible when it comes to the PSU
recovering if something goes wrong during a state transition. This also
sets a standard that is less applicable to other uses, e.g. charger.
Remove power policy messaging in favor of direct async function calls.
Move existing proxy code into this directory.
Convert the current controller-level event receiver into a per-port
event receiver.
Also remove finalize functions since they were mostly for message
passing. Change `trace` -> `debug` in a couple of places.
Flatten `wrapper/proxy` into `controller` as the previous `wrapper`
module no longer contains any code of its own and `controller` is a
better name than `wrapper`.
The imprevious implementation wouldn't work correctly if `sync_state`
were called from the port object if the event receiver's `wait_next`
function had already been called. Introduce a loopback channel to
support this functionality.
* Fix comment
* Shorten lock liftime in VDM code
@RobertZ2011
Copy link
Copy Markdown
Contributor Author

Rebased and resolved conflicts in cargo vet files.

@RobertZ2011 RobertZ2011 requested a review from jerrysxie May 6, 2026 18:08
@RobertZ2011 RobertZ2011 merged commit 77905ee into OpenDevicePartnership:v0.2.0 May 6, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cargo vet PRs pending auditor review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants