feat: For BF4 get the pf0 mac address from NDF0 path#3115
Conversation
|
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. |
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds 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. ChangesBF4 base-MAC derivation
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
crates/site-explorer/src/lib.rs (1)
3583-3615: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider consolidating the
is_bf4_dpu_reportcases into a single value-driven table.These three
#[test]functions exercise the same total operation (is_bf4_dpu_report→bool) with differing report shapes — precisely the patternvalue_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, orbool)."🤖 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 winCollapse the identical
Errarms.The
Err(RedfishError::NotSupported(_)) => continuearm is behaviorally indistinguishable from the catch-allErr(_) => continue; the explicit variant adds no value and will tripclippy::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 atdebugbefore 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
📒 Files selected for processing (2)
crates/site-explorer/src/lib.rscrates/site-explorer/src/redfish.rs
🔍 Container Scan Summary
Per-CVE detail lives in the per-service |
poroh
left a comment
There was a problem hiding this comment.
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:
And then use collected data here:
There was a problem hiding this comment.
🧹 Nitpick comments (2)
crates/bmc-explorer/src/chassis.rs (2)
155-168: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFragile 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 tocontinue) 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 liftDuplicate MAC-offset derivation logic across crates.
The
BF4_NDF0_TO_BASE_MAC_OFFSETconstant and themac_to_u64/u64_to_macconversion helpers are independently re-implemented here and incrates/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 bothbmc-explorerandsite-explorercan 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
📒 Files selected for processing (6)
crates/bmc-explorer/src/chassis.rscrates/bmc-explorer/src/computer_system.rscrates/bmc-explorer/src/lib.rscrates/bmc-explorer/src/network_adapter.rscrates/site-explorer/src/lib.rscrates/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
|
🌿 Preview your docs: https://nvidia-preview-pull-request-3115.docs.buildwithfern.com/infra-controller |
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/0And 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
Additional Notes
On the host OS:
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"