Skip to content

feat: For BF4 get the pf0 mac address from NDF0 path#3115

Merged
hakhondzadeh merged 9 commits into
NVIDIA:mainfrom
hakhondzadeh:fix-bf4-pf0-base-mac
Jul 7, 2026
Merged

feat: For BF4 get the pf0 mac address from NDF0 path#3115
hakhondzadeh merged 9 commits into
NVIDIA:mainfrom
hakhondzadeh:fix-bf4-pf0-base-mac

Conversation

@hakhondzadeh

@hakhondzadeh hakhondzadeh commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

For BF4 none of the legacy paths to get the host facing PCIe function (PF0) from the BMC redfish is valid. This PR changes the code to get the PF0 base mac based on the following path:
/redfish/v1/Chassis/BlueField_0/NetworkAdapters/BlueField_NIC_0/NetworkDeviceFunctions/0
And applying a constant offset 0x10 to get the host side base mac.

Related issues

Path for PF0 base mac address on the BF4 BMC is now different.

Type of Change

  • Add - New feature or capability
  • [x ] Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Additional Notes

On the host OS:

ip link | grep -i -B 1 "f4"
16: enP5p65s0f0np0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether f4:20:4d:49:52:0c brd ff:ff:ff:ff:ff:ff
17: enP5p65s0f1np1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether f4:20:4d:49:52:0d brd ff:ff:ff:ff:ff:ff
--
34: enP13p65s0f0np0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether f4:20:4d:49:52:04 brd ff:ff:ff:ff:ff:ff
35: enP13p65s0f1np1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether f4:20:4d:49:52:05 brd ff:ff:ff:ff:ff:ff

On the BF4 BMC:
curl -k -x socks5h://127.0.0.1:30000 \ -u '$USER:$PASS' \ https://$IP/redfish/v1/Chassis/BlueField_0/NetworkAdapters/BlueField_NIC_0/NetworkDeviceFunctions/0 | grep -i MAC "PermanentMACAddress": "f4:20:4d:49:52:14"

@copy-pr-bot

copy-pr-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds BF4-specific MAC derivation paths across site-explorer and bmc-explorer. Redfish and chassis exploration now derive PF0 base MAC from BF4 NDF0 inventory when needed, while site-explorer adds BF4 report classification and changes PF0 fallback behavior accordingly.

Changes

BF4 base-MAC derivation

Layer / File(s) Summary
BF4 network-device wiring
crates/bmc-explorer/src/lib.rs, crates/bmc-explorer/src/network_adapter.rs
Extends chassis exploration configuration to request network-device functions for NVIDIA B4240V systems, and adds a slice accessor for explored network adapter members.
Manager default derive
crates/api-model/src/site_explorer/mod.rs
Adds Default to the public Manager derive list, and updates DPU identification to accept both Bluefield system id variants.
Redfish BF4 NDF0 MAC fallback
crates/site-explorer/src/redfish.rs
Adds ODataId import, a BF4 NDF0 permanent-MAC helper that queries hard-coded Redfish inventory resources, and wires the helper into fetch_system when the primary base-MAC retrieval returns None.
Chassis BF4 MAC derivation
crates/bmc-explorer/src/chassis.rs
Adds MAC-address imports, a BF4 offset constant, a chassis helper that derives PF0 base MAC from BF4 NDF0 permanent MAC, and the conversion helpers used for the offset arithmetic.
BF4 report classification and legacy fallback control flow
crates/site-explorer/src/lib.rs
Adds BF4 report classification from topology IDs, updates PF0 base-MAC resolution to skip the BMC eth0 offset fallback for BF4 reports, preserves the legacy DPU_SYS_IMAGE-derived error, and adjusts the warning text and visibility helpers.
BF4 detection and MAC precedence tests
crates/site-explorer/src/lib.rs
Adds a BF4-style exploration report fixture, tests BF4 report classification acceptance and rejection cases, and extends PF0 MAC derivation tests to cover systems[0].base_mac precedence.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the BF4 PF0 MAC derivation change from the NDF0 path.
Description check ✅ Passed The description matches the implemented BF4 NDF0 fallback and 0x10 MAC offset behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@hakhondzadeh hakhondzadeh marked this pull request as ready for review July 6, 2026 06:31
@hakhondzadeh hakhondzadeh requested a review from a team as a code owner July 6, 2026 06:31
@hakhondzadeh hakhondzadeh requested a review from krish-nvidia July 6, 2026 06:31

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
crates/site-explorer/src/lib.rs (1)

3583-3615: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider consolidating the is_bf4_dpu_report cases into a single value-driven table.

These three #[test] functions exercise the same total operation (is_bf4_dpu_reportbool) with differing report shapes — precisely the pattern value_scenarios! targets. A single table (accepts BF4, rejects missing NIC topology, rejects BF3 shape) keeps each case one labeled row and localizes future additions. This is optional; the current tests are correct.

As per coding guidelines: "Use value_scenarios! for total operations (those returning a plain value, Option, or bool)."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/site-explorer/src/lib.rs` around lines 3583 - 3615, Consolidate the
three `is_bf4_dpu_report` test cases into a single `value_scenarios!`-driven
table test, since this function is a total operation returning a bool. Replace
the separate `#[test]` functions with one scenario table covering the accepted
BF4 report, the rejected zero-suffix case without BF4 NIC topology, and the
rejected BF3-shaped report, using the existing helpers like
`bf4_report_with_zero_suffix_ids`, `bf3_report_with_eth0`, and
`is_bf4_dpu_report`.

Source: Coding guidelines

crates/site-explorer/src/redfish.rs (1)

1155-1160: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Collapse the identical Err arms.

The Err(RedfishError::NotSupported(_)) => continue arm is behaviorally indistinguishable from the catch-all Err(_) => continue; the explicit variant adds no value and will trip clippy::match_same_arms, which this workspace treats as an error. Consider folding the two, and if the distinction was intended to surface diagnostics, log the swallowed error at debug before continuing rather than discarding it silently.

♻️ Proposed simplification
-        let resource = match client.get_resource(ODataId::from(path)).await {
-            Ok(resource) => resource,
-            Err(RedfishError::NotSupported(_)) => continue,
-            Err(_) => continue,
-        };
+        let resource = match client.get_resource(ODataId::from(path)).await {
+            Ok(resource) => resource,
+            Err(err) => {
+                tracing::debug!(%path, error = %err, "BF4 NDF0 resource fetch failed");
+                continue;
+            }
+        };

As per coding guidelines: "Enable all clippy lints by default and treat all warnings as errors."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/site-explorer/src/redfish.rs` around lines 1155 - 1160, The `match` on
`client.get_resource(...).await` in `redfish.rs` has two `Err` arms that both do
`continue`, which will trigger `clippy::match_same_arms`. Collapse the
`Err(RedfishError::NotSupported(_))` and `Err(_)` handling into a single branch
in the `ndf0_paths` loop, or if you need to preserve the distinction, emit a
`debug` log before continuing. Keep the behavior in `client.get_resource` and
the surrounding loop unchanged.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/site-explorer/src/redfish.rs`:
- Around line 829-847: The BF4 NDF0 fallback in the base_mac resolution path is
currently applied for every BlueField when base_mac is missing, which can
trigger unnecessary lookups and BF4-specific warnings on BF2/BF3. Update the
logic around get_base_mac_from_bf4_ndf0 in redfish.rs to first verify BF4
topology before attempting the fallback, or otherwise make the warning generic
and less noisy if the fallback remains unconditional. Keep the later
BF3/BMC-eth0 handling in mind so base_mac remains absent unless the BF4 path
actually applies.

---

Nitpick comments:
In `@crates/site-explorer/src/lib.rs`:
- Around line 3583-3615: Consolidate the three `is_bf4_dpu_report` test cases
into a single `value_scenarios!`-driven table test, since this function is a
total operation returning a bool. Replace the separate `#[test]` functions with
one scenario table covering the accepted BF4 report, the rejected zero-suffix
case without BF4 NIC topology, and the rejected BF3-shaped report, using the
existing helpers like `bf4_report_with_zero_suffix_ids`, `bf3_report_with_eth0`,
and `is_bf4_dpu_report`.

In `@crates/site-explorer/src/redfish.rs`:
- Around line 1155-1160: The `match` on `client.get_resource(...).await` in
`redfish.rs` has two `Err` arms that both do `continue`, which will trigger
`clippy::match_same_arms`. Collapse the `Err(RedfishError::NotSupported(_))` and
`Err(_)` handling into a single branch in the `ndf0_paths` loop, or if you need
to preserve the distinction, emit a `debug` log before continuing. Keep the
behavior in `client.get_resource` and the surrounding loop unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c73fdb0c-2348-492f-9d4c-9bdb1f98b0c6

📥 Commits

Reviewing files that changed from the base of the PR and between 12ef832 and fe2d0c0.

📒 Files selected for processing (2)
  • crates/site-explorer/src/lib.rs
  • crates/site-explorer/src/redfish.rs

Comment thread crates/site-explorer/src/redfish.rs
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

🔍 Container Scan Summary

Service Total Critical High Medium Low Other
boot-artifacts-aarch64 3 0 0 3 0 0
boot-artifacts-x86_64 3 0 0 3 0 0
forge-admin-cli-x86_64 270 13 33 91 7 126
machine-validation-runner 771 37 219 281 40 194
machine_validation 771 37 219 281 40 194
machine_validation-aarch64 771 37 219 281 40 194
nvmetal-carbide 771 37 219 281 40 194
TOTAL 3360 161 909 1221 167 902

Per-CVE detail lives in the per-service grype-* artifacts (JSON + SARIF). Severity counts only — no CVE IDs published here.

@poroh poroh 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.

This change updates libredfish exploration mode which is legacy (backup) mode. Current default mode is nv-redfish. To update it you need to add collection of network-devices-functions for bluefield4 here:

need_network_device_fns: root.vendor() == Some(Vendor::new("Dell")),

And then use collected data here:

base_mac = oem_bf.base_mac().and_then(|v| {

Comment thread crates/site-explorer/src/redfish.rs

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (2)
crates/bmc-explorer/src/chassis.rs (2)

155-168: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Fragile positional path parsing for chassis/adapter/function IDs.

Splitting the hardcoded path string and indexing by fixed positions (parts.get(4), .get(6), .get(8)) silently breaks (falls through to continue) if the path format ever changes slightly (e.g., an extra/missing segment), with no diagnostic emitted. Since these IDs are already known at compile-time for each of the two BF4 topology variants, prefer expressing them directly as tuples instead of deriving them via string parsing.

♻️ Proposed refactor to avoid positional string parsing
     pub fn dpu_bf4_ndf0_permanent_mac(&self) -> Option<BaseMac> {
-        const BF4_NDF0_PATHS: [&str; 2] = [
-            "/redfish/v1/Chassis/BlueField_0/NetworkAdapters/BlueField_NIC_0/NetworkDeviceFunctions/0",
-            "/redfish/v1/Chassis/Card1/NetworkAdapters/Bluefield_NIC/NetworkDeviceFunctions/0",
-        ];
-        for path in BF4_NDF0_PATHS {
-            let parts: Vec<&str> = path.split('/').collect();
-            let (chassis_id, adapter_id, function_id) =
-                match (parts.get(4), parts.get(6), parts.get(8)) {
-                    (Some(chassis_id), Some(adapter_id), Some(function_id)) => {
-                        (*chassis_id, *adapter_id, *function_id)
-                    }
-                    _ => continue,
-                };
-
+        // BF4 NDF0 topology paths:
+        // /redfish/v1/Chassis/BlueField_0/NetworkAdapters/BlueField_NIC_0/NetworkDeviceFunctions/0
+        // /redfish/v1/Chassis/Card1/NetworkAdapters/Bluefield_NIC/NetworkDeviceFunctions/0
+        const BF4_NDF0_TARGETS: [(&str, &str, &str); 2] = [
+            ("BlueField_0", "BlueField_NIC_0", "0"),
+            ("Card1", "Bluefield_NIC", "0"),
+        ];
+        for (chassis_id, adapter_id, function_id) in BF4_NDF0_TARGETS {
             let mac = self
                 .members
                 .iter()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/bmc-explorer/src/chassis.rs` around lines 155 - 168, In the BF4 path
handling inside the chassis parsing logic, avoid deriving chassis_id,
adapter_id, and function_id by splitting hardcoded strings and indexing fixed
positions. Replace the fragile path parsing in the BF4_NDF0_PATHS loop with
direct tuple-based data for each topology variant, and use those values directly
where the IDs are needed so the code no longer silently skips valid cases if the
path shape changes.

150-196: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Duplicate MAC-offset derivation logic across crates.

The BF4_NDF0_TO_BASE_MAC_OFFSET constant and the mac_to_u64/u64_to_mac conversion helpers are independently re-implemented here and in crates/site-explorer/src/redfish.rs / crates/site-explorer/src/lib.rs (per the supplied cross-file context), all performing the identical "NDF0 MAC minus 0x10" derivation. Divergence between these copies (e.g., one crate updating the offset without the other) would silently produce inconsistent PF0 base MACs. Consider hoisting this derivation logic into a shared location (e.g., carbide-network) that both bmc-explorer and site-explorer can depend on.

Also applies to: 222-232

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/bmc-explorer/src/chassis.rs` around lines 150 - 196, The BF4 PF0
base-MAC derivation is duplicated here in dpu_bf4_ndf0_permanent_mac and in the
site-explorer Redfish helpers, so consolidate the shared “NDF0 minus 0x10” logic
into one reusable helper in a common crate such as carbide-network. Move
BF4_NDF0_TO_BASE_MAC_OFFSET and the mac_to_u64/u64_to_mac-based derivation into
that shared helper, then update both callers in chassis.rs and the site-explorer
codepaths to use it so the offset and conversion behavior stay consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/bmc-explorer/src/chassis.rs`:
- Around line 155-168: In the BF4 path handling inside the chassis parsing
logic, avoid deriving chassis_id, adapter_id, and function_id by splitting
hardcoded strings and indexing fixed positions. Replace the fragile path parsing
in the BF4_NDF0_PATHS loop with direct tuple-based data for each topology
variant, and use those values directly where the IDs are needed so the code no
longer silently skips valid cases if the path shape changes.
- Around line 150-196: The BF4 PF0 base-MAC derivation is duplicated here in
dpu_bf4_ndf0_permanent_mac and in the site-explorer Redfish helpers, so
consolidate the shared “NDF0 minus 0x10” logic into one reusable helper in a
common crate such as carbide-network. Move BF4_NDF0_TO_BASE_MAC_OFFSET and the
mac_to_u64/u64_to_mac-based derivation into that shared helper, then update both
callers in chassis.rs and the site-explorer codepaths to use it so the offset
and conversion behavior stay consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 679210f3-6656-47b9-9d27-ee23cf64237e

📥 Commits

Reviewing files that changed from the base of the PR and between fe2d0c0 and 626dc78.

📒 Files selected for processing (6)
  • crates/bmc-explorer/src/chassis.rs
  • crates/bmc-explorer/src/computer_system.rs
  • crates/bmc-explorer/src/lib.rs
  • crates/bmc-explorer/src/network_adapter.rs
  • crates/site-explorer/src/lib.rs
  • crates/site-explorer/src/redfish.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/site-explorer/src/redfish.rs
  • crates/site-explorer/src/lib.rs

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Comment thread crates/bmc-explorer/src/chassis.rs Outdated
Comment thread crates/site-explorer/src/lib.rs Outdated
Comment thread crates/site-explorer/src/lib.rs
@hakhondzadeh hakhondzadeh requested a review from poroh July 7, 2026 16:45
@hakhondzadeh hakhondzadeh merged commit 629037d into NVIDIA:main Jul 7, 2026
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants