Skip to main content

monarch_rdma/backend/
ibverbs.rs

1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree.
7 */
8
9//! ibverbs backend implementation for RDMA operations.
10
11use hyperactor::ActorRef;
12use hyperactor::actor::Referable;
13use typeuri::Named;
14
15mod cq_actor;
16mod cq_pool;
17pub mod device;
18pub mod device_selection;
19pub(crate) mod domain;
20pub mod efa_device;
21pub mod efa_domain;
22pub mod efa_queue_pair;
23pub mod manager_actor;
24pub mod memory_region;
25pub mod mlx_device;
26pub mod mlx_domain;
27pub mod mlx_queue_pair;
28pub mod primitives;
29pub mod queue_pair;
30
31use manager_actor::IbvManagerActor;
32use memory_region::IbvRemoteMemoryRegionView;
33use mlx_device::MlxDevice;
34pub use queue_pair::IbvQueuePair;
35pub use queue_pair::PollTarget;
36
37#[cfg(test)]
38mod doorbell_test_utils;
39#[cfg(test)]
40mod doorbell_tests;
41#[cfg(test)]
42mod mlx5dv_tests;
43
44use crate::RdmaOpType;
45use crate::local_memory::KeepaliveLocalMemory;
46
47/// A single RDMA op for the [`IbvBackend`](manager_actor::IbvBackend).
48///
49/// Generic over the manager actor type so unit tests can swap in a
50/// mock; production code uses the default `IbvOp<IbvManagerActor>`.
51#[derive(Debug, Named)]
52pub struct IbvOp<M: Referable = IbvManagerActor<MlxDevice>> {
53    pub op_type: RdmaOpType,
54    pub local_memory: KeepaliveLocalMemory,
55    /// One memory registration for each NIC that the target memory
56    /// on the remote can be reached through.
57    pub remote_buffers: Vec<IbvRemoteMemoryRegionView>,
58    pub remote_manager: ActorRef<M>,
59}
60
61// Hand-rolled `Clone` to avoid the `M: Clone` bound the derive macro
62// would add (`ActorRef<M>` is `Clone` for all `M: Referable`).
63impl<M: Referable> Clone for IbvOp<M> {
64    fn clone(&self) -> Self {
65        Self {
66            op_type: self.op_type,
67            local_memory: self.local_memory.clone(),
68            remote_buffers: self.remote_buffers.clone(),
69            remote_manager: self.remote_manager.clone(),
70        }
71    }
72}