Skip to content

(15) dpdk: typed flow rules - #1880

Draft
daniel-noland wants to merge 4 commits into
split/dpdk-core/04-rx-metadatafrom
split/dpdk-core/07-flow
Draft

daniel-noland wants to merge 4 commits into
split/dpdk-core/04-rx-metadatafrom
split/dpdk-core/07-flow

Conversation

@daniel-noland

@daniel-noland daniel-noland commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

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:

  • VLAN push/VID/PCP ordering: expose a combined push operation and keep its generated actions together. mlx5 requires PCP configuration after PUSH in the same action list; the current rank sort reverses them.
  • Match and action typestate: distinguish the original matching pattern from the packet shape after mutations. The current builder cannot continue into inner VXLAN headers. BlueField-3 tests with DPDK 26.07, dv_flow_en=1 and firmware 32.50.1002 confirm inner matching works before decap, direct inner IPv4 rewriting is rejected, and decap followed by rewriting changes the exposed inner address. The broader API design remains open.
  • Fallible destruction: failed explicit destroy currently loses the handle, and Drop only logs failure. Decide who retains failed rules and what teardown policy applies; a local table flush would invalidate other live handles.

@daniel-noland
daniel-noland requested a review from a team as a code owner October 3, 2026 05:32
@daniel-noland
daniel-noland requested review from qmonnet and removed request for a team October 3, 2026 05:32
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Comment thread dpdk/src/flow/pattern.rs Outdated
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).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

drop comment

@daniel-noland
daniel-noland marked this pull request as draft October 3, 2026 05:53
@codecov

codecov Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 35.04493% with 506 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
dpdk/src/flow/builder.rs 51.07% 250 Missing and 1 partial ⚠️
dpdk/src/flow/pattern.rs 0.00% 181 Missing ⚠️
dpdk/src/flow/rule.rs 0.00% 34 Missing ⚠️
dpdk/src/dev.rs 37.03% 15 Missing and 2 partials ⚠️
dpdk/src/flow/error.rs 0.00% 17 Missing ⚠️
dpdk/src/flow/mod.rs 0.00% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@daniel-noland
daniel-noland added this pull request to stack #1882 October 3, 2026 06:00
@daniel-noland daniel-noland self-assigned this Oct 3, 2026
@daniel-noland daniel-noland added the area/dpdk Related to DPDK (interface with or usage of the library) label Oct 3, 2026
@daniel-noland
daniel-noland requested a balanced review from Copilot October 3, 2026 17:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 High severity

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.

Comment thread dpdk/src/flow/builder.rs
Comment on lines +133 to +137
/// 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,
Comment thread dpdk/src/flow/builder.rs
///
/// 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>
Comment thread dpdk/src/flow/rule.rs Outdated
Comment on lines +38 to +42
// 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) }
@daniel-noland
daniel-noland removed this pull request from stack #1882 October 3, 2026 21:41
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/07-flow branch from 12035f3 to d1e0808 Compare October 3, 2026 23:39
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/06-rss branch 2 times, most recently from 552639f to ef9577f Compare October 4, 2026 06:05
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/07-flow branch from d1e0808 to 88a8a33 Compare October 4, 2026 06:05
Base automatically changed from split/dpdk-core/06-rss to split/dpdk-core/04-rx-metadata October 4, 2026 06:05
@daniel-noland daniel-noland changed the title (08) dpdk: typed flow wrappers (15) dpdk: typed flow rules Oct 4, 2026
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/04-rx-metadata branch 2 times, most recently from c498514 to b4ef0da Compare October 6, 2026 06:23
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/07-flow branch 3 times, most recently from 3fd6213 to 9aa41e2 Compare October 7, 2026 03:09
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/04-rx-metadata branch from b4ef0da to bb4fb47 Compare October 7, 2026 03:09
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/07-flow branch from 9aa41e2 to 9c2e32d Compare October 8, 2026 00:41
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/04-rx-metadata branch from 6ae5b96 to 77e730c Compare October 8, 2026 01:53
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/07-flow branch from 9c2e32d to 6ce5772 Compare October 8, 2026 01:53
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/04-rx-metadata branch from 77e730c to 9c442cd Compare October 8, 2026 03:32
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/07-flow branch from 6ce5772 to 9a73ebc Compare October 8, 2026 03:32
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/04-rx-metadata branch from 9c442cd to 5349632 Compare October 8, 2026 07:16
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/07-flow branch from 9a73ebc to 403fe04 Compare October 8, 2026 07:16
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/07-flow branch from 403fe04 to 7f06ff9 Compare October 16, 2026 05:47
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/04-rx-metadata branch from 5349632 to 7e10438 Compare October 16, 2026 05:47
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/07-flow branch from 7f06ff9 to c2d4969 Compare October 16, 2026 08:43
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/04-rx-metadata branch from 0c8e642 to dfa429f Compare October 17, 2026 03:26
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/07-flow branch from c2d4969 to e777c24 Compare October 17, 2026 03:26
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/04-rx-metadata branch from dfa429f to b1b5db5 Compare October 17, 2026 05:59
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/07-flow branch 2 times, most recently from 51239c8 to b6fed81 Compare October 17, 2026 06:17
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/04-rx-metadata branch from b1b5db5 to 6cb84ce Compare October 17, 2026 06:17
daniel-noland and others added 4 commits October 17, 2026 15:59
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>
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/04-rx-metadata branch from 6cb84ce to 85d5b3e Compare October 17, 2026 22:06
@daniel-noland
daniel-noland force-pushed the split/dpdk-core/07-flow branch from b6fed81 to 67077be Compare October 17, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dpdk Related to DPDK (interface with or usage of the library)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants