• Stars
    star
    335
  • Rank 125,904 (Top 3 %)
  • Language
    Rust
  • License
    GNU General Publi...
  • Created over 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Easy to use RDMA API in Rust async

async-rdma

A framework for writing RDMA applications with high-level abstraction and asynchronous APIs.

Join the chat at https://gitter.im/datenlord/async-rdma Crates.io Docs GPL licensed Build Status

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.

The ChangeLog file contains a brief summary of changes for each release.

Environment Setup

This section is for RDMA novices who want to try this library.

You can skip if your Machines have been configured with RDMA.

Next we will configure the RDMA environment in an Ubuntu20.04 VM. If you are using another operating system distribution, please search and replace the relevant commands.

1. Check whether the current kernel supports RXE

Run the following command and if the CONFIG_RDMA_RXE = y or m, the current operating system supports RXE. If not you need to search how to recompile the kernel to support RDMA.

cat /boot/config-$(uname -r) | grep RXE

2. Install Dependencies

sudo apt install -y libibverbs1 ibverbs-utils librdmacm1 libibumad3 ibverbs-providers rdma-core libibverbs-dev iproute2 perftest build-essential net-tools git librdmacm-dev rdmacm-utils cmake libprotobuf-dev protobuf-compiler clang curl

3. Configure RDMA netdev

(1) Load kernel driver

modprobe rdma_rxe

(2) User mode RDMA netdev configuration.

sudo rdma link add rxe_0 type rxe netdev ens33

rxe_0 is the RDMA device name, and you can name it whatever you want. ens33 is the name of the network device. The name of the network device may be different in each VM, and we can see it by running command "ifconfig".

(3) Check the RDMA device state

Run the following command and check if the state is ACTIVE.

rdma link

(4) Test it

Ib_send_bw is a program used to test the bandwidth of RDMA SEND operations.

Run the following command in a terminal.

ib_send_bw -d rxe_0

And run the following command in another terminal.

ib_send_bw -d rxe_0 localhost

4. Install Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env

5. Try an example

git clone https://github.com/datenlord/async-rdma.git
cd async-rdma
cargo run --example rpc

if run rpc example failed, you can try run it with sudo permission.

cargo build --example rpc
sudo ./target/debug/examples/rpc

Example

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.

use async_rdma::{LocalMrReadAccess, LocalMrWriteAccess, RdmaBuilder};
use portpicker::pick_unused_port;
use std::{
    alloc::Layout,
    io::{self, Write},
    net::{Ipv4Addr, SocketAddrV4},
    time::Duration,
};

async fn client(addr: SocketAddrV4) -> io::Result<()> {
    let layout = Layout::new::<[u8; 8]>();
    let rdma = RdmaBuilder::default().connect(addr).await?;
    // alloc 8 bytes remote memory
    let mut rmr = rdma.request_remote_mr(layout).await?;
    // alloc 8 bytes local memory
    let mut lmr = rdma.alloc_local_mr(layout)?;
    // write data into lmr
    let _num = lmr.as_mut_slice().write(&[1_u8; 8])?;
    // write the second half of the data in lmr to the rmr
    rdma.write(&lmr.get(4..8).unwrap(), &mut rmr.get_mut(4..8).unwrap())
        .await?;
    // send rmr's meta data to the remote end
    rdma.send_remote_mr(rmr).await?;
    Ok(())
}

#[tokio::main]
async fn server(addr: SocketAddrV4) -> io::Result<()> {
    let rdma = RdmaBuilder::default().listen(addr).await?;
    // receive mr's meta data from client
    let lmr = rdma.receive_local_mr().await?;
    let data = *lmr.as_slice();
    println!("Data written by the client using RDMA WRITE: {:?}", data);
    assert_eq!(data, [[0_u8; 4], [1_u8; 4]].concat());
    Ok(())
}

#[tokio::main]
async fn main() {
    let addr = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), pick_unused_port().unwrap());
    std::thread::spawn(move || server(addr));
    tokio::time::sleep(Duration::new(1, 0)).await;
    client(addr)
        .await
        .map_err(|err| println!("{}", err))
        .unwrap();
}

Getting Help

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.

More Repositories

1

datenlord

DatenLord, Computing Defined Storage, an application-orientated, cloud-native distributed storage system
Rust
872
star
2

Xline

A geo-distributed KV store for metadata management
Rust
232
star
3

open-rdma

RoCE v2 hardware and software implementation
87
star
4

s3-server

Generic S3 server implementation
Rust
80
star
5

lockfree-cuckoohash

A rust implementation of lock free cuckoo hashmap
Rust
67
star
6

rdma-sys

Rust bindings for RDMA fundamental libraries: libibverbs-dev and librdmacm-dev
Rust
37
star
7

r-epaxos

Rust
27
star
8

wavebpf

High-performance eBPF implementation in hardware.
Scala
25
star
9

ring-io

An easy-to-use interface for io_uring
Rust
17
star
10

TRIDENT

A Hardware Implemented Poseidon Hasher
C++
16
star
11

blue-rdma

RoCEv2 hardware implementation in Bluespec SystemVerilog
Bluespec
15
star
12

etcd-client

Rust
15
star
13

poseidon-spinal

The hardware implementation of Poseidon hash function in SpinalHDL
Python
14
star
14

open-rdma-driver

Datanlord's RDMA nic driver
C
8
star
15

roce-sim

Python
7
star
16

async-dpdk

DPDK API in async Rust
Rust
7
star
17

blue-crc

A high-throughput, parameterized, parallel crc hardware implementation.
Bluespec
7
star
18

aligned-utils

Rust
5
star
19

hardware-agile-dev-workshop

4
star
20

blue-udp

The hardware implementation of UDP in Bluespec SystemVerilog
Bluespec
4
star
21

async-fuse

[WIP] asynchronous FUSE implementation
Rust
3
star
22

datenlord.github.io

TypeScript
3
star
23

concurrent-btree

Rust
3
star
24

LordOS

distributed containerized OS
Shell
3
star
25

dpdk-sys

Rust bindings for DPDK fundamental libraries.
Rust
3
star
26

training

3
star
27

DistroSim

C++
3
star
28

r4l_playground

Rust
3
star
29

rustChinaHackathon22

2
star
30

better-as

Explicit type casting
Rust
2
star
31

wbpf-driver

wBPF Linux driver.
C
2
star
32

rdma-env-setup

Shell
2
star
33

xline-home

Xline's Home Page
TypeScript
2
star
34

blake2b_compress

verilog implementation of blake2b_compress
Verilog
2
star
35

arc

Container engine with OCI specification
Rust
2
star
36

utilities

Rust
1
star
37

fp-err-handle

Rust
1
star
38

wbpf-userspace

Userspace utilities for wBPF.
Rust
1
star
39

raft_kv_training

Rust
1
star
40

merged_range

Rust
1
star
41

cgroup2

Rust
1
star
42

blue-dmac

Bluespec
1
star