monarch_rdma/backend/ibverbs/
mlx_device.rs1use std::sync::Arc;
12
13use typeuri::Named;
14
15use super::device::IbvDeviceImpl;
16use super::mlx_domain::MlxDomain;
17use super::primitives::IbvConfig;
18use super::primitives::IbvContext;
19use crate::register_ibv_device_impl;
20
21const MELLANOX_VENDOR_ID: u32 = 0x02c9;
23
24#[derive(Debug, Named)]
26pub struct MlxDevice;
27
28impl IbvDeviceImpl for MlxDevice {
29 type Domain = MlxDomain;
30
31 fn backend_name() -> &'static str {
32 "mellanox"
33 }
34
35 fn is_instance(ctx: Arc<IbvContext>) -> bool {
36 let mut attr = rdmaxcel_sys::ibv_device_attr::default();
37 let queried = unsafe { rdmaxcel_sys::ibv_query_device(ctx.as_ptr(), &mut attr) } == 0;
42 queried && attr.vendor_id == MELLANOX_VENDOR_ID
43 }
44
45 fn apply_config_defaults(_config: &mut IbvConfig) {}
46}
47
48register_ibv_device_impl!(MlxDevice);