Skip to content

Conversation

daniel-noland
Copy link
Collaborator

@daniel-noland daniel-noland commented Oct 9, 2025

This is a first installment of the init package.

It will eventually be responsible for starting the dataplane, but is not currently and will not be even if this is merged.

That will require a few extra steps.

As such, this code, merged or not, will have no impact on the rest of the development for this workspace just yet. I'm only submitting this part early to try to keep the PRs as byte size and manageable chunks.

@daniel-noland daniel-noland force-pushed the pr/daniel-noland/dpdk-back branch from 7658bd3 to 4b3877d Compare October 9, 2025 01:37
@daniel-noland daniel-noland requested a review from Copilot October 9, 2025 01:38
@daniel-noland daniel-noland self-assigned this Oct 9, 2025
@daniel-noland daniel-noland added the enhancement New feature or request label Oct 9, 2025
Copy link
Contributor

@Copilot 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 pull request introduces the foundation for a dataplane initialization system with new NIC management capabilities. The changes focus on creating infrastructure for binding network cards to appropriate drivers and setting up the system initialization flow.

Key changes:

  • Created a new init crate with PCI device and driver management functionality
  • Added comprehensive documentation and configuration for the initialization system
  • Updated various crates to use embedded README documentation and improved error handling

Reviewed Changes

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

Show a summary per file
File Description
init/ New crate for dataplane initialization with PCI device management
the-rules.md Comprehensive documentation of DPDK + async threading rules
start-up.mmd Mermaid diagram for proposed startup sequence
tracectl/ Updated to use embedded README documentation
dpdk/ Improved error handling and memory management
dataplane/ Disabled some components and added build dependencies
Various config files Updated dependencies, build settings, and documentation

@daniel-noland daniel-noland force-pushed the pr/daniel-noland/dpdk-back branch from 4b3877d to 43ffbfe Compare October 9, 2025 01:39
@daniel-noland daniel-noland requested a review from Copilot October 9, 2025 01:41
Copy link
Contributor

@Copilot 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 no new comments.

@daniel-noland daniel-noland force-pushed the pr/daniel-noland/dpdk-back branch 2 times, most recently from a2b236f to 77bdba9 Compare October 9, 2025 02:05
@daniel-noland daniel-noland changed the title dataplane init system dataplane init system part 1 Oct 9, 2025
The init package (more properly `dataplane-init`), is responsible
for starting up the dataplane and forwarding computed or augmented
command line arguments to it.

This commit only includes basic documentation and mission statement.
This commit series focuses on initializing the network card in a
manor suitable for use by DPDK.

Signed-off-by: Daniel Noland <[email protected]>
@daniel-noland daniel-noland force-pushed the pr/daniel-noland/dpdk-back branch 2 times, most recently from dba8f78 to 11c261e Compare October 9, 2025 05:00
@daniel-noland daniel-noland marked this pull request as ready for review October 9, 2025 05:07
@daniel-noland daniel-noland requested a review from a team as a code owner October 9, 2025 05:07
@daniel-noland daniel-noland requested review from Copilot and sergeymatov and removed request for a team October 9, 2025 05:07
Copy link
Contributor

@Copilot 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 8 out of 9 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

init/src/nic.rs:1

  • Redundant error handling: the ? operator is unnecessary after Err(...) since Err is already being returned. Remove the ? operator.
// SPDX-License-Identifier: Apache-2.0

@daniel-noland daniel-noland force-pushed the pr/daniel-noland/dpdk-back branch from 11c261e to 96b6a25 Compare October 9, 2025 05:18
@daniel-noland daniel-noland requested a review from Copilot October 9, 2025 05:21
Copy link
Contributor

@Copilot 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 8 out of 9 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

init/src/nic.rs:1

  • The ? operator is unnecessary here since this is already the final expression in the match arm. The expression should be simplified to just Err(InitErr::IoError(e.into())).
// SPDX-License-Identifier: Apache-2.0

@daniel-noland daniel-noland force-pushed the pr/daniel-noland/dpdk-back branch 2 times, most recently from 45f5d60 to 51bc4f9 Compare October 9, 2025 05:25
Introduce a package wide application error type.

This is very different from our more typical library level error types
in that it is intended to be a catch-all error type for fatal errors.

Almost nothing which can go wrong in this crate is expected to be
recoverable without human intervention.

Signed-off-by: Daniel Noland <[email protected]>
This will require extension to customize log level.

Signed-off-by: Daniel Noland <[email protected]>
@daniel-noland daniel-noland force-pushed the pr/daniel-noland/dpdk-back branch 3 times, most recently from d9b6290 to 5803d40 Compare October 9, 2025 05:54
@daniel-noland daniel-noland requested a review from Copilot October 10, 2025 01:45
Copy link
Contributor

@Copilot 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 8 out of 9 changed files in this pull request and generated 3 comments.

fn driver(&self) -> Result<Option<PciDriver>, InitErr> {
let device_path = self.device_path()?;
info!("found device {self} under device path {:?}", device_path);
let driver_path = device_path.relative("driver")?;
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

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

The code attempts to get the driver path but doesn't handle the case where the device has no driver bound (symlink doesn't exist). This will cause relative() to fail with an IO error instead of returning Ok(None) as the function signature suggests.

Copilot generated this review using guidance from repository custom instructions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

true. Will fix in the next PR

Basic guard rails which discourage us from making some mistakes.

Features:
- SysfsPath type ensuring paths are under sysfs mount
- UTF-8 validation to prevent log injection attacks
- Filesystem type verification using statfs
- Path canonicalization to handle symlinks safely

Signed-off-by: Daniel Noland <[email protected]>
This function finds our sysfs mount and panics if it is missing.
It also sets up tracing.

Signed-off-by: Daniel Noland <[email protected]>
Introduces PCI NIC abstraction for driver management with:
- Driver detection and identification
- Unbinding from kernel drivers
- Binding to vfio-pci for DPDK
- Support for i40e, mlx5 (partial), virtio-net, and vfio-pci drivers

Implements traits for safe driver manipulation through sysfs.

Signed-off-by: Daniel Noland <[email protected]>
Implements basic NIC driver binding for DPDK compatibility.
Binds PCI network devices to vfio-pci driver as required
by DPDK for device control.

This is part 1 of the dataplane initialization system,
focusing on minimal viable functionality for team testing.

Future work:
- Add proper argument parsing
- Implement privilege dropping (especially CAP_SYS_ADMIN)
- Add exec to dataplane process after success

Signed-off-by: Daniel Noland <[email protected]>
@daniel-noland daniel-noland force-pushed the pr/daniel-noland/dpdk-back branch from 5803d40 to 0b5aad6 Compare October 10, 2025 01:52
Copy link
Member

@qmonnet qmonnet left a comment

Choose a reason for hiding this comment

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

I've got concerns about the name for the crate. init sounds like we initialise the dataplane itself, not like a preliminary step to set up the NICs etc. before launching the dataplane executable. I also fear it might lead to confusion (if not for us, for users/costumers) with the init process on some Linux distribs. How about bootstrap, maybe?

Great work otherwise!

init/src/main.rs Outdated
#![doc = include_str!("../README.md")]
#![deny(clippy::pedantic, missing_docs)]

fn main() {}
Copy link
Member

Choose a reason for hiding this comment

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

Your process will be named init (unless I'm mistaken). I think it would maybe make sense to find another name instead to avoid any confusion with the init process on some Linux distributions. Even if it might be clear to us in the context, it will become a source of confusion when debugging customer issues if we mention an init process.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps hwinit is a better name?

/// Some [`std::io::Error`] error occurred
#[error(transparent)]
IoError(#[from] std::io::Error),
/// Invalid UTF-8 in a path under sysfs is an absolutely wild error case I expect to
Copy link
Member

Choose a reason for hiding this comment

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

This is a rustdoc comment for API docs. Who is “I”? 🙂

Suggested change
/// Invalid UTF-8 in a path under sysfs is an absolutely wild error case I expect to
/// Invalid UTF-8 in a path under sysfs is an absolutely wild error case we expect to

///
/// Note that the NIC may or may not be visible to the OS, depending on the state of
/// the system.
pub struct PciNic {
Copy link
Member

Choose a reason for hiding this comment

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

I can't help but read this “PicNic” every time I see it 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants