Skip to content

feat: expose more fields in device_attr, expose raw handles for device_attr and port_attr#97

Open
dragonJACson wants to merge 3 commits intomainfrom
dev/expose-more-fields
Open

feat: expose more fields in device_attr, expose raw handles for device_attr and port_attr#97
dragonJACson wants to merge 3 commits intomainfrom
dev/expose-more-fields

Conversation

@dragonJACson
Copy link
Contributor

No description provided.

Signed-off-by: Luke Yue <lukedyue@gmail.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the rdma-mummy library's ability to query detailed information about RDMA devices and their ports. It introduces new Rust types to represent various device capabilities and exposes a comprehensive set of device attributes, moving beyond the previously limited set. Furthermore, it provides direct, unsafe access to the underlying C ibv_device_attr_ex, ibv_device_attr, and ibv_port_attr structures, enabling advanced users to interact with the raw RDMA API when necessary. These changes enhance the library's utility for applications requiring fine-grained control and inspection of RDMA hardware.

Highlights

  • New Device Attributes: Exposed additional fields from ibv_device_attr_ex and ibv_device_attr including atomic capabilities, device capability flags, PCI atomic operation sizes, and various resource limits.
  • Raw Handle Access: Introduced unsafe methods device_attr, orig_device_attr for DeviceAttr and port_attr for PortAttr to provide direct access to the underlying ibv_device_attr_ex, ibv_device_attr, and ibv_port_attr C structures.
  • Enum and Bitmask Definitions: Added new Rust enums and bitmasks (AtomicCapability, DeviceCapabilityFlags, PciAtomicOperationSize) to represent C ibv_atomic_cap, ibv_device_cap_flags, and ibv_pci_atomic_op_size values in a type-safe manner.
  • Enhanced Testing: Included new unit tests to verify the correct exposure and functionality of the newly added device and port attribute fields and raw accessors.
Changelog
  • src/ibverbs/device_context.rs
    • Imported new ibv_* types for atomic capabilities, device capabilities, and PCI atomic operations.
    • Defined AtomicCapability enum for ibv_atomic_cap.
    • Defined DeviceCapabilityFlags bitmask enum for ibv_device_cap_flags.
    • Defined PciAtomicOperationSize bitmask enum for ibv_pci_atomic_op_size.
    • Implemented PciAtomicCapabilities struct to encapsulate PCI atomic operation capabilities.
    • Added port_attr unsafe method to PortAttr to expose the raw ibv_port_attr handle.
    • Added hca_core_clock and pci_atomic_caps methods to DeviceAttr.
    • Added numerous getter methods to DeviceAttr for various fields from ibv_device_attr (e.g., node_guid, max_mr_size, max_qp, max_cq, atomic_capability, etc.).
    • Added device_attr and orig_device_attr unsafe methods to DeviceAttr to expose raw ibv_device_attr_ex and ibv_device_attr handles.
    • Added new unit tests to validate the functionality of the newly exposed attributes and raw accessors.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request exposes a significant number of fields from ibv_device_attr and ibv_device_attr_ex, along with related enums and structs, providing a more comprehensive API for device capabilities. It also introduces unsafe methods to get raw pointers to device_attr and port_attr. My review focuses on improving the safety of these new raw pointer accessors. I've suggested changing them to return *const pointers instead of NonNull (which is *mut) to prevent accidental mutations through shared references, which could lead to undefined behavior. Corresponding changes to the new tests are also suggested.

@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 95.72193% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/ibverbs/device_context.rs 95.72% 8 Missing ⚠️
Files with missing lines Coverage Δ
src/ibverbs/device_context.rs 86.25% <95.72%> (+4.57%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dragonJACson dragonJACson force-pushed the dev/expose-more-fields branch from 9be9edb to 7b10594 Compare March 10, 2026 13:54
Signed-off-by: Luke Yue <lukedyue@gmail.com>
Signed-off-by: Luke Yue <lukedyue@gmail.com>
@dragonJACson dragonJACson force-pushed the dev/expose-more-fields branch from 7b10594 to c41a8e8 Compare March 11, 2026 16:05
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.

1 participant