Skip to main content

monarch_rdma/backend/ibverbs/
efa_domain.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//! EFA domain strategy for [`IbvDomainImpl`].
10
11use super::domain::IbvDomain;
12use super::domain::IbvDomainImpl;
13use super::primitives::IbvConfig;
14use super::primitives::IbvContext;
15use super::primitives::IbvDeviceInfo;
16use super::queue_pair::legacy::IbvQueuePair;
17
18/// EFA [`IbvDomainImpl`]. Uses the default host/dmabuf MR registration;
19/// EFA has no device-specific memory-key binding to add.
20#[derive(Debug)]
21pub struct EfaDomain;
22
23impl IbvDomainImpl for EfaDomain {
24    type QueuePair = IbvQueuePair;
25
26    unsafe fn new(
27        _context: &IbvContext,
28        _device_info: &IbvDeviceInfo,
29        _config: &IbvConfig,
30    ) -> Self {
31        EfaDomain
32    }
33
34    fn access_flags(&self) -> i32 {
35        // EFA does not support `IBV_ACCESS_REMOTE_ATOMIC`.
36        (rdmaxcel_sys::ibv_access_flags::IBV_ACCESS_LOCAL_WRITE
37            | rdmaxcel_sys::ibv_access_flags::IBV_ACCESS_REMOTE_WRITE
38            | rdmaxcel_sys::ibv_access_flags::IBV_ACCESS_REMOTE_READ)
39            .0 as i32
40    }
41
42    fn create_queue_pair(
43        domain: &IbvDomain<Self>,
44        config: &IbvConfig,
45    ) -> anyhow::Result<Self::QueuePair> {
46        // EFA builds the legacy single-type queue pair for now; it will
47        // become an EFA-specific queue pair.
48        IbvQueuePair::new(domain, config.clone())
49    }
50}