monarch_rdma/backend/ibverbs/
efa_domain.rs1use super::domain::IbvDomainImpl;
12use super::efa_queue_pair::EfaQueuePair;
13use super::primitives::IbvConfig;
14use super::primitives::IbvContext;
15use super::primitives::IbvDeviceInfo;
16
17#[derive(Debug)]
20pub struct EfaDomain;
21
22impl IbvDomainImpl for EfaDomain {
23 type QueuePair = EfaQueuePair;
24
25 unsafe fn new(
26 _context: &IbvContext,
27 _device_info: &IbvDeviceInfo,
28 _config: &IbvConfig,
29 ) -> Self {
30 EfaDomain
31 }
32
33 fn access_flags(&self) -> i32 {
34 (rdmaxcel_sys::ibv_access_flags::IBV_ACCESS_LOCAL_WRITE
36 | rdmaxcel_sys::ibv_access_flags::IBV_ACCESS_REMOTE_WRITE
37 | rdmaxcel_sys::ibv_access_flags::IBV_ACCESS_REMOTE_READ)
38 .0 as i32
39 }
40}
41
42#[cfg(test)]
43mod tests {
44 use std::sync::Arc;
45
46 use super::*;
47 use crate::backend::ibverbs::domain::IbvDomain;
48 use crate::backend::ibverbs::primitives::IbvCq;
49 use crate::backend::ibverbs::primitives::IbvPd;
50
51 #[test]
54 fn create_queue_pair_rejects_null_pd() {
55 let domain = unsafe {
58 IbvDomain::for_test(
59 Arc::new(IbvPd::null()),
60 IbvDeviceInfo::for_test_named("efa0"),
61 EfaDomain,
62 )
63 };
64 let err = domain
65 .create_queue_pair(&IbvConfig::default(), Arc::new(IbvCq::null()))
66 .expect_err("a null protection domain cannot back a queue pair");
67 assert!(
68 err.to_string().contains("null protection domain"),
69 "unexpected error: {err}"
70 );
71 }
72}