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
impl RdmaBuilder
sourcepub fn new() -> Self
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.
sourcepub async fn connect<A: ToSocketAddrs>(self, addr: A) -> Result<Rdma>
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();
}
sourcepub async fn ibv_connect(self, remote: QueuePairEndpoint) -> Result<Rdma>
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
.
sourcepub async fn listen<A: ToSocketAddrs>(self, addr: A) -> Result<Rdma>
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();
}
sourcepub fn set_cq_size(self, cq_size: u32) -> Self
pub fn set_cq_size(self, cq_size: u32) -> Self
Set the complete queue size
sourcepub fn set_max_cqe(self, max_ceq: i32) -> Self
pub fn set_max_cqe(self, max_ceq: i32) -> Self
Set the max number of CQE in a polling.
sourcepub fn set_gid_index(self, gid_index: usize) -> Self
pub fn set_gid_index(self, gid_index: usize) -> Self
Set the gid index
sourcepub fn set_port_num(self, port_num: u8) -> Self
pub fn set_port_num(self, port_num: u8) -> Self
Set the port number
sourcepub fn set_conn_type(self, conn_type: ConnectionType) -> Self
pub fn set_conn_type(self, conn_type: ConnectionType) -> Self
Set the connection type
sourcepub fn set_qp_max_send_wr(self, max_send_wr: u32) -> Self
pub fn set_qp_max_send_wr(self, max_send_wr: u32) -> Self
Set maximum number of outstanding send requests in the send queue
sourcepub fn set_qp_max_recv_wr(self, max_recv_wr: u32) -> Self
pub fn set_qp_max_recv_wr(self, max_recv_wr: u32) -> Self
Set maximum number of outstanding receive requests in the receive queue
sourcepub fn set_qp_max_send_sge(self, max_send_sge: u32) -> Self
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
sourcepub fn set_qp_max_recv_sge(self, max_recv_sge: u32) -> Self
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
sourcepub fn set_qp_access(self, flags: BitFlags<AccessFlag>) -> Self
pub fn set_qp_access(self, flags: BitFlags<AccessFlag>) -> Self
Set default QP
access
sourcepub fn set_mr_access(self, flags: BitFlags<AccessFlag>) -> Self
pub fn set_mr_access(self, flags: BitFlags<AccessFlag>) -> Self
Set default MR
access
sourcepub fn set_mr_strategy(self, strategy: MRManageStrategy) -> Self
pub fn set_mr_strategy(self, strategy: MRManageStrategy) -> Self
Set the stragety to manage MR
s
sourcepub fn set_max_message_length(self, max_msg_len: usize) -> Self
pub fn set_max_message_length(self, max_msg_len: usize) -> Self
Set max length of message send/recv by Agent
sourcepub fn set_max_rmr_access(self, flags: BitFlags<AccessFlag>) -> Self
pub fn set_max_rmr_access(self, flags: BitFlags<AccessFlag>) -> Self
Set max access permission for remote mr requests
sourcepub fn set_max_dest_rd_atomic(self, max_dest_rd_atomic: u8) -> Self
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.
sourcepub fn set_min_rnr_timer(self, min_rnr_timer: u8) -> Self
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
sourcepub fn set_rq_psn(self, rq_psn: u32) -> Self
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
sourcepub fn set_max_rd_atomic(self, max_rd_atomic: u8) -> Self
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.
sourcepub fn set_retry_cnt(self, retry_cnt: u8) -> Self
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
sourcepub fn set_rnr_retry(self, rnr_retry: u8) -> Self
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.
sourcepub fn set_sq_psn(self, sq_psn: u32) -> Self
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.
sourcepub fn set_timeout(self, timeout: u8) -> Self
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.
sourcepub fn set_service_level(self, sl: u8) -> Self
pub fn set_service_level(self, sl: u8) -> Self
Set the Service Level to be used. 4 bits.
sourcepub fn set_src_path_bits(self, src_path_bits: u8) -> Self
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.
sourcepub fn set_static_rate(self, static_rate: u8) -> Self
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.
sourcepub fn set_flow_label(self, flow_label: u32) -> Self
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.
sourcepub fn set_hop_limit(self, hop_limit: u8) -> Self
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.
sourcepub fn set_traffic_class(self, traffic_class: u8) -> Self
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.
sourcepub fn set_pkey_index(self, pkey_index: u16) -> Self
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.
sourcepub fn set_mtu(self, mtu: MTU) -> Self
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.
sourcepub fn set_imm_flag_in_wc(self, imm_flag: u32) -> Result<Self>
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.
sourcepub fn set_cc_evnet_timeout(self, timeout: Duration) -> Self
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.
sourcepub fn set_polling_trigger(self, pt_type: PollingTriggerType) -> Self
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.