1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Device — discovery, context management, and GUID handling.
//!
//! This module provides the entry point for working with RDMA devices.
//! Before allocating resources (Protection Domains, Queue Pairs, etc.), you must
//! identify a specific RDMA device available on the system and open a [`Context`] from it.
//!
//! # Core Concepts
//!
//! * **Discovery** — Use [`list_devices`] to enumerate all available hardware, or
//! [`open_device`] to look up a specific device by name (e.g., `"mlx5_0"`).
//! * **Device List** — The [`DeviceList`] struct owns the underlying list of devices
//! returned by the system. It handles memory management (freeing the list when dropped).
//! * **Device Reference** — A [`Device`] is a transient handle to a specific device.
//! It is obtained by iterating a list or querying a context.
//! * **Context** — The [`Context`] represents an active session with the hardware.
//! It is the root factory for creating all other resources.
//!
//! # Quick Start: Open by Name
//!
//! The easiest way to get started is to open a device directly if you know its name:
//!
//! ```no_run
//! use ibverbs_rs::ibverbs;
//!
//! let ctx = ibverbs::open_device("mlx5_0")?;
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! # Example: Enumerating Devices
//!
//! If you need to inspect devices (e.g., to check GUIDs) before opening:
//!
//! ```no_run
//! use ibverbs_rs::ibverbs;
//!
//! let dev_list = ibverbs::list_devices()?;
//!
//! if dev_list.is_empty() {
//! println!("No RDMA devices found.");
//! return Ok(());
//! }
//!
//! for dev in dev_list.iter() {
//! println!("Name: {:?}, GUID: {:?}", dev.name(), dev.guid());
//! }
//!
//! // Open the first available device
//! let first_dev = dev_list.get(0).unwrap();
//! let context = first_dev.open()?;
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
pub use Context;
pub use Guid;
pub use ;
/// Port number 1 of each HCA is the RDMA port.
pub const IB_PORT: u8 = 1;
/// Port number 2 of each HCA is the Ethernet port.
pub const _ETH_PORT: u8 = 2;