Repository navigation
(15) dpdk: typed flow rules - #1880
daniel-noland wants to merge 4 commits into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
| if let Some(vni) = self.vni { | ||
| let v = vni.as_u32(); | ||
| let bytes = [(v >> 16) as u8, (v >> 8) as u8, v as u8]; | ||
| // Writing a union field is safe (only reads are unsafe). |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Flow destruction can lose live handles, mlx5 actions are reordered incorrectly, and inner VXLAN patterns cannot be constructed.
Review effort: Balanced
Findings: 3
Open (3)
What changed in this PR
Replaces the previous flow API with typed DPDK flow construction, lowering, error handling, and RAII-managed rules.
Changes:
- Adds typestate-based flow domains and protocol ordering.
- Adds typed match/action lowering, including VLAN and VXLAN support.
- Adds structured PMD errors and automatic rule destruction.
| File | Description |
|---|---|
dpdk/src/flow/mod.rs |
Defines and exports the typed flow API. |
dpdk/src/flow/builder.rs |
Builds, validates, and creates hardware flow rules. |
dpdk/src/flow/pattern.rs |
Lowers typed match criteria into DPDK structures. |
dpdk/src/flow/error.rs |
Classifies PMD flow errors. |
dpdk/src/flow/rule.rs |
Manages installed rules through an RAII handle. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| /// mlx5 action order: remove headers, mark, rewrite, push headers, forward. | ||
| /// Actions of equal rank retain their insertion order. | ||
| fn rank(&self) -> u8 { | ||
| match self { | ||
| Action::OfPopVlan | Action::VxlanDecap => 0, |
| /// | ||
| /// Available only after UDP (VXLAN is UDP-encapsulated). Inner (decapsulated) headers can then be | ||
| /// matched as the pattern continues, since the `net` lattice resumes at the tunnel's inner start. | ||
| pub fn match_vxlan(mut self, criteria: VxlanMatch) -> FlowBuilder<'dev, D, Vxlan> |
| // Suppress the `Drop` below so the handle is freed exactly once. | ||
| let this = ManuallyDrop::new(self); | ||
| // SAFETY: `this.flow` is a live handle for `this.port`, owned solely by `self`, and the | ||
| // `ManuallyDrop` guarantees `Drop` will not free it a second time. | ||
| unsafe { destroy(this.port, this.flow) } |
12035f3 to
d1e0808
Compare
552639f to
ef9577f
Compare
d1e0808 to
88a8a33
Compare
c498514 to
b4ef0da
Compare
3fd6213 to
9aa41e2
Compare
b4ef0da to
bb4fb47
Compare
9aa41e2 to
9c2e32d
Compare
6ae5b96 to
77e730c
Compare
9c2e32d to
6ce5772
Compare
77e730c to
9c442cd
Compare
6ce5772 to
9a73ebc
Compare
9c442cd to
5349632
Compare
9a73ebc to
403fe04
Compare
403fe04 to
7f06ff9
Compare
5349632 to
7e10438
Compare
7f06ff9 to
c2d4969
Compare
0c8e642 to
dfa429f
Compare
c2d4969 to
e777c24
Compare
dfa429f to
b1b5db5
Compare
51239c8 to
b6fed81
Compare
b1b5db5 to
6cb84ce
Compare
Add domain markers, typed header matches, rewrite actions and device-borrowed rule handles. Destroy rules on drop and flush remaining rules before stopping the port. Doctests cover the rule's borrow of the device. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Daniel Noland <daniel@githedgehog.com>
Sort actions by mlx5 pipeline order, preserving order within each rank. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Daniel Noland <daniel@githedgehog.com>
Use MODIFY_FIELD for immediate values. mlx5 VNI changes still require decap and encap; per-VNI rules can stamp the VNI into META. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Daniel Noland <daniel@githedgehog.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Daniel Noland <daniel@githedgehog.com>
6cb84ce to
85d5b3e
Compare
b6fed81 to
67077be
Compare

Add typed flow builders for ingress, egress and transfer domains, with header matches, rewrite actions, VLAN actions and VXLAN encapsulation. Rule handles borrow their started device; stopping the port flushes remaining rules.
VXLAN encapsulation owns typed headers and borrows them through temporary FFI descriptors during validation and creation. Moving the builder no longer invalidates cached self-references.
Validation: 151 unit tests, one integration test and 24 doctests pass (two ignored); Clippy passes with warnings denied. The new move/reallocation regression also passes Miri using the actual lowering code extracted into an isolated harness with generated DPDK bindings.
Outstanding review items, deferred while earlier stack reviews are addressed: