Struct async_rdma::RdmaBuilder

source ·
pub struct RdmaBuilder { /* private fields */ }
Expand description

The builder for the Rdma, it follows the builder pattern.

Implementations§

source§

impl RdmaBuilder

source

pub fn new() -> Self

Create a default builder The default settings are: dev name: None access right: LocalWrite | RemoteRead | RemoteWrite | RemoteAtomic complete queue size: 16 port number: 1 gid index: 1

Note: We highly recommend setting the port number and the gid index.

source

pub fn build(&self) -> Result<Rdma>

Create a Rdma from this builder

source

pub async fn connect<A: ToSocketAddrs>(self, addr: A) -> Result<Rdma>

Establish connection with RDMA server

Used with listen

Examples
use async_rdma::RdmaBuilder;
use portpicker::pick_unused_port;
use std::{
    io,
    net::{Ipv4Addr, SocketAddrV4},
    time::Duration,
};

async fn client(addr: SocketAddrV4) -> io::Result<()> {
    let _rdma = RdmaBuilder::default().connect(addr).await?;
    Ok(())
}

#[tokio::main]
async fn server(addr: SocketAddrV4) -> io::Result<()> {
    let _rdma = RdmaBuilder::default().listen(addr).await?;
    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::from_secs(3)).await;
    client(addr)
        .await
        .map_err(|err| println!("{}", err))
        .unwrap();
}
source

pub async fn ibv_connect(self, remote: QueuePairEndpoint) -> Result<Rdma>

Connect to remote end by raw ibv information.

You can get the destination qp information in any way and use this interface to establish connection.

The example is the same as Rdma::ibv_connect.

source

pub async fn listen<A: ToSocketAddrs>(self, addr: A) -> Result<Rdma>

Listen to the address to wait for a connection to be established

Used with connect

Examples
use async_rdma::RdmaBuilder;
use portpicker::pick_unused_port;
use std::{
    io,
    net::{Ipv4Addr, SocketAddrV4},
    time::Duration,
};

async fn client(addr: SocketAddrV4) -> io::Result<()> {
    let _rdma = RdmaBuilder::default().connect(addr).await?;
    Ok(())
}

#[tokio::main]
async fn server(addr: SocketAddrV4) -> io::Result<()> {
    let _rdma = RdmaBuilder::default().listen(addr).await?;
    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::from_secs(3)).await;
    client(addr)
        .await
        .map_err(|err| println!("{}", err))
        .unwrap();
}
source

pub fn set_dev(self, dev: &str) -> Self

Set device name

source

pub fn set_cq_size(self, cq_size: u32) -> Self

Set the complete queue size

source

pub fn set_max_cqe(self, max_ceq: i32) -> Self

Set the max number of CQE in a polling.

source

pub fn set_gid_index(self, gid_index: usize) -> Self

Set the gid index

source

pub fn set_port_num(self, port_num: u8) -> Self

Set the port number

source

pub fn set_conn_type(self, conn_type: ConnectionType) -> Self

Set the connection type

source

pub fn set_raw(self, raw: bool) -> Self

Set if send/recv raw data

source

pub fn set_qp_max_send_wr(self, max_send_wr: u32) -> Self

Set maximum number of outstanding send requests in the send queue

source

pub fn set_qp_max_recv_wr(self, max_recv_wr: u32) -> Self

Set maximum number of outstanding receive requests in the receive queue

source

pub fn set_qp_max_send_sge(self, max_send_sge: u32) -> Self

Set maximum number of scatter/gather elements (SGE) in a WR on the send queue

source

pub fn set_qp_max_recv_sge(self, max_recv_sge: u32) -> Self

Set maximum number of scatter/gather elements (SGE) in a WR on the receive queue

source

pub fn set_qp_access(self, flags: BitFlags<AccessFlag>) -> Self

Set default QP access

source

pub fn set_mr_access(self, flags: BitFlags<AccessFlag>) -> Self

Set default MR access

source

pub fn set_mr_strategy(self, strategy: MRManageStrategy) -> Self

Set the stragety to manage MRs

source

pub fn set_max_message_length(self, max_msg_len: usize) -> Self

Set max length of message send/recv by Agent

source

pub fn set_max_rmr_access(self, flags: BitFlags<AccessFlag>) -> Self

Set max access permission for remote mr requests

source

pub fn set_max_dest_rd_atomic(self, max_dest_rd_atomic: u8) -> Self

Set the number of RDMA Reads & atomic operations outstanding at any time that can be handled by this QP as a destination. Relevant only for RC QPs.

source

pub fn set_min_rnr_timer(self, min_rnr_timer: u8) -> Self

Set the minimum RNR NAK Timer Field Value. When an incoming message to this QP should consume a Work Request from the Receive Queue, but not Work Request is outstanding on that Queue, the QP will send an RNR NAK packet to the initiator. It does not affect RNR NAKs sent for other reasons.

The value can be one of the following numeric values since those values aren’t enumerated:

0 - 655.36 milliseconds delay

1 - 0.01 milliseconds delay

2 - 0.02 milliseconds delay

3 - 0.03 milliseconds delay

4 - 0.04 milliseconds delay

5 - 0.06 milliseconds delay

6 - 0.08 milliseconds delay

7 - 0.12 milliseconds delay

8 - 0.16 milliseconds delay

9 - 0.24 milliseconds delay

10 - 0.32 milliseconds delay

11 - 0.48 milliseconds delay

12 - 0.64 milliseconds delay

13 - 0.96 milliseconds delay

14 - 1.28 milliseconds delay

15 - 1.92 milliseconds delay

16 - 2.56 milliseconds delay

17 - 3.84 milliseconds delay

18 - 5.12 milliseconds delay

19 - 7.68 milliseconds delay

20 - 10.24 milliseconds delay

21 - 15.36 milliseconds delay

22 - 20.48 milliseconds delay

23 - 30.72 milliseconds delay

24 - 40.96 milliseconds delay

25 - 61.44 milliseconds delay

26 - 81.92 milliseconds delay

27 - 122.88 milliseconds delay

28 - 163.84 milliseconds delay

29 - 245.76 milliseconds delay

30 - 327.68 milliseconds delay

31 - 491.52 milliseconds delay

Relevant only for RC QPs

source

pub fn set_rq_psn(self, rq_psn: u32) -> Self

Set a 24 bits value of the Packet Sequence Number of the received packets for RC and UC QPs

source

pub fn set_max_rd_atomic(self, max_rd_atomic: u8) -> Self

Set the number of RDMA Reads & atomic operations outstanding at any time that can be handled by this QP as an initiator. Relevant only for RC QPs.

source

pub fn set_retry_cnt(self, retry_cnt: u8) -> Self

Set a 3 bits value of the total number of times that the QP will try to resend the packets before reporting an error because the remote side doesn’t answer in the primary path

source

pub fn set_rnr_retry(self, rnr_retry: u8) -> Self

Set a 3 bits value of the total number of times that the QP will try to resend the packets when an RNR NACK was sent by the remote QP before reporting an error. The value 7 is special and specify to retry infinite times in case of RNR.

source

pub fn set_sq_psn(self, sq_psn: u32) -> Self

Set a 24 bits value of the Packet Sequence Number of the sent packets for any QP.

source

pub fn set_timeout(self, timeout: u8) -> Self

Set the minimum timeout that a QP waits for ACK/NACK from remote QP before retransmitting the packet. The value zero is special value which means wait an infinite time for the ACK/NACK (useful for debugging). For any other value of timeout, the time calculation is: 4.09*2^timeout. Relevant only to RC QPs.

source

pub fn set_service_level(self, sl: u8) -> Self

Set the Service Level to be used. 4 bits.

source

pub fn set_src_path_bits(self, src_path_bits: u8) -> Self

Set the used Source Path Bits. This is useful when LMC is used in the port, i.e. each port covers a range of LIDs. The packets are being sent with the port’s base LID, bitwised ORed with the value of the source path bits. The value 0 indicates the port’s base LID is used.

source

pub fn set_static_rate(self, static_rate: u8) -> Self

Set the value which limits the rate of packets that being sent to the subnet. This can be useful if the rate of the packet origin is higher than the rate of the destination.

source

pub fn set_flow_label(self, flow_label: u32) -> Self

If this value is set to a non-zero value, it gives a hint for switches and routers with multiple outbound paths that these sequence of packets must be delivered in order, those staying on the same path, so that they won’t be reordered. 20 bits.

source

pub fn set_hop_limit(self, hop_limit: u8) -> Self

Set the number of hops (i.e. the number of routers) that the packet is permitted to take before being discarded. This ensures that a packet will not loop indefinitely between routers if a routing loop occur. Each router decrement by one this value at the packet and when this value reaches 0, this packet is discarded. Setting the value to 0 or 1 will ensure that the packet won’t leave the local subnet.

source

pub fn set_traffic_class(self, traffic_class: u8) -> Self

Using this value, the originator of the packets specifies the required delivery priority for handling them by the routers.

source

pub fn set_pkey_index(self, pkey_index: u16) -> Self

Set Primary key index. The value of the entry in the pkey table that outgoing packets from this QP will be sent with and incoming packets to this QP will be verified within the Primary path.

source

pub fn set_mtu(self, mtu: MTU) -> Self

Set the path MTU (Maximum Transfer Unit) i.e. the maximum payload size of a packet that can be transferred in the path. For UC and RC QPs, when needed, the RDMA device will automatically fragment the messages to packet of this size.

source

pub fn set_imm_flag_in_wc(self, imm_flag: u32) -> Result<Self>

Set the immediate data flag in ibv_wc of rdma device.

This value is 3 as default for Soft-RoCE, and may be 2 for other devices.

source

pub fn set_cc_evnet_timeout(self, timeout: Duration) -> Self

Set the timeout value for event listener to wait for the notification of completion channel.

When a completion queue entry (CQE) is placed on the CQ, a completion event will be sent to the completion channel (CC) associated with the CQ.

The listener will wait for the CC’s notification to poll the related CQ until timeout. After timeout, listener will poll the CQ to make sure no cqe there, and wait again.

For the devices or drivers not support notification mechanism, this value will be the polling period, and as a protective measure in other cases.

source

pub fn set_polling_trigger(self, pt_type: PollingTriggerType) -> Self

Set the polling trigger type of cq. Used with Rdma.poll() and Rmda.get_manual_trigger().

When a completion queue entry (CQE) is placed on the CQ, a completion event will be sent to the completion channel (CC) associated with the CQ.

As default(PollingTriggerType::AsyncFd), the listener will wait for the CC’s notification to poll the related CQ. If you want to ignore the notification and poll by yourself, you can input pt_type as PollingTriggerType::Channel and call Rdma.poll() to poll the CQ.

Trait Implementations§

source§

impl Debug for RdmaBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for RdmaBuilder

source§

fn default() -> RdmaBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<U> Cast for U

source§

fn cast<T>(self) -> Twhere
    T: TryFrom<Self>,
    Self: Sized + Display + Copy,

Performs the conversion.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere
    V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
    S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more