Skip to main content

monarch_rdma/backend/ibverbs/
efa_device.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 backend for [`IbvDevice`].
10
11use std::sync::Arc;
12
13use typeuri::Named;
14
15use super::device::IbvDeviceImpl;
16use super::efa_domain::EfaDomain;
17use super::primitives::IbvConfig;
18use super::primitives::IbvContext;
19use crate::register_ibv_device_impl;
20
21/// AWS EFA (Elastic Fabric Adapter) backend.
22#[derive(Debug, Named)]
23pub struct EfaDevice;
24
25impl IbvDeviceImpl for EfaDevice {
26    type Domain = EfaDomain;
27
28    fn backend_name() -> &'static str {
29        "efa"
30    }
31
32    fn is_instance(ctx: Arc<IbvContext>) -> bool {
33        // SAFETY: `ctx.as_ptr()` is a non-null context owned by
34        // the `Arc<IbvContext>` for the duration of this call.
35        unsafe { rdmaxcel_sys::rdmaxcel_is_efa_dev(ctx.as_ptr()) != 0 }
36    }
37
38    fn apply_config_defaults(config: &mut IbvConfig) {
39        config.max_send_sge = 1;
40        config.max_recv_sge = 1;
41        config.max_dest_rd_atomic = 0;
42        config.max_rd_atomic = 0;
43    }
44}
45
46register_ibv_device_impl!(EfaDevice);