A framework for writing RDMA applications with high-level abstraction and asynchronous APIs.
It provides a few major components:
Tools for establishing connections with rdma endpoints such as RdmaBuilder
.
High-level APIs for data transmission between endpoints including read
,
write
, send
, receive
.
High-level APIs for rdma memory region management including alloc_local_mr
,
request_remote_mr
, send_mr
, receive_local_mr
, receive_remote_mr
.
A framework including agent
and event_listener
working behind APIs for memory
region management and executing rdma requests such as post_send
and poll
.
A simple example: client request a remote memory region and put data into this remote
memory region by rdma write
.
And finally client send_mr
to make server aware of this memory region.
Server receive_local_mr
, and then get data from this mr.
```rust use asyncrdma::{Rdma, RdmaListener}; use std::{alloc::Layout, sync::Arc, io, time::Duration, net::{Ipv4Addr, SocketAddrV4}}; use portpicker::pickunused_port;
struct Data(String);
async fn client(addr: SocketAddrV4) -> io::Result<()> { let rdma = Rdma::connect(addr, 1, 1, 512).await?; let mut lmr = rdma.alloclocalmr(Layout::new::())?; let rmr = Arc::new(rdma.requestremotemr(Layout::new::()).await?); // then send this mr to server to make server aware of this mr. unsafe { *(lmr.asmutptr() as *mut Data) = Data("hello world".tostring()) }; rdma.write(&lmr, &rmr).await?; // send the content of lmr to server rdma.sendmr(rmr.clone()).await?; Ok(()) }
async fn server(addr: SocketAddrV4) -> io::Result<()> {
let rdmalistener = RdmaListener::bind(addr).await?;
let rdma = rdmalistener.accept(1, 1, 512).await?;
let lmr = rdma.receivelocalmr().await?;
// print the content of lmr, which was write
by client
unsafe { println!("{}", &((lmr.as_ptr() as *const Data)).0) };
Ok(())
}
async fn main() { let addr = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), pickunusedport().unwrap()); std::thread::spawn(move || server(addr.clone())); tokio::time::sleep(Duration::new(1, 0)).await; client(addr).await.map_err(|err| println!("{}", err)).unwrap(); } ```
First, see if the answer to your question can be found in the found [API doc] or [Design doc]. If the answer is not here, please open an issue and describe your problem in detail.
rdma-sys
]: Rust bindings for RDMA fundamental libraries: libibverbs-dev and librdmacm-dev.