Skip to main content

Device

Struct Device 

Source
pub struct Device<'a> { /* private fields */ }
Expand description

A reference to an RDMA device.

This type represents a borrowed handle to an RDMA device. It can be obtained from a DeviceList or a Context.

The reference is valid only as long as the source object (DeviceList or Context) remains alive.

To perform operations on the device, you must first open it to obtain a Context.

Implementations§

Source§

impl Device<'_>

Source

pub fn open(&self) -> IbvResult<Context>

Opens a context for this RDMA device.

The resulting Context is the primary object used for allocating resources (PDs, QPs, CQs) and managing the device.

§Errors

Returns an error if the device cannot be opened (e.g., due to permission issues or resource exhaustion).

Source

pub fn name(&self) -> Option<&str>

Returns the system name of the device (e.g., “mlx5_0”).

Returns None if the name cannot be retrieved or is not valid UTF-8.

Source

pub fn guid(&self) -> IbvResult<Guid>

Returns the Global Unique Identifier (GUID) of this RDMA device.

§Errors

Returns an error if the GUID is reserved (invalid) or cannot be read.

Source§

impl<'a> Device<'a>

Source

pub fn bind_thread_to_numa(&self) -> Result<()>

Bind the calling task (OS thread) to the NUMA node local to this InfiniBand device.

This reads the device’s NUMA node from sysfs (/sys/class/infiniband/<dev>/device/numa_node) and then applies the affinity using set_numa_node, which calls both numa_run_on_node() and numa_set_localalloc().

§Errors

Returns an error if:

  • The device name is not available (self.name() is None).
  • The sysfs file cannot be read (I/O error).
  • The sysfs contents cannot be parsed as an i32 (reported as InvalidData).
  • numa_run_on_node() fails (returns -1 and sets errno; returned via io::Error::last_os_error).
Source

pub fn bind_thread_to_numa_strict(&self) -> Result<()>

Like bind_thread_to_numa, but also sets a strict bind policy — memory allocations will only be served from the local NUMA node, with no fallback to other nodes.

§Errors

Same as bind_thread_to_numa.

Trait Implementations§

Source§

impl Debug for Device<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Send for Device<'_>

SAFETY: libibverbs components are thread safe.

Source§

impl Sync for Device<'_>

SAFETY: libibverbs components are thread safe.

Auto Trait Implementations§

§

impl<'a> Freeze for Device<'a>

§

impl<'a> RefUnwindSafe for Device<'a>

§

impl<'a> Unpin for Device<'a>

§

impl<'a> UnsafeUnpin for Device<'a>

§

impl<'a> UnwindSafe for Device<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.