--- tags: 筆記 --- # 8/24 Verbs ## Verbs - 不是API - 有多種實現方法 - low level description for RDMA programming ## libibverbs low-level libraries ### 相關API - InfiniBand - RoCE(RDMA Over Converged Ethernet) - iWARP(Internet Wide Area RDMA Protocol) ### tips on libibverbs - 要使用得要 include 此 header - `#include<infiniband/verbs.h>` - 有使用 libibverbs 的可執行檔跟函式庫都要 link `-libverbs` - input struct 需要被預設為零 - 可使用 `memset` - 多數資源控制代碼(handle)是指標(pointer),所以當用了錯誤的控制代碼可能會造成記憶體區段錯誤 - 當回傳的是 pointer,其值為 valid value 代表成功,NULL 代表失敗 - 當回傳的是整數,0 為成功,-1 為失敗 ## libibverbs 細節 ### Memory Region (MR) memory block 被註冊, 準備給 RDMA 的 - Permission - Local(Local Read 是一直支援的) - IBV_ACCESS_LOCAL_WRITE - IBV_ACCESS_MW_BIND - Remote - IBV_ACCESS_REMOTE_WRITE - IBV_ACCESS_REMOTE_READ - IBV_ACCESS_REMOTE_ATOMIC - 如果 remote WRITE/ATOMIC 是啟用, local WRITE 也必須啟用 - 在 memory 註冊後, 產生兩個 key - Local Key (lkey) - Remote Key (rkey) #### API - struct ibv_mr *ibv_reg_mr(...) - 註冊 memory region - int ibv_dereg_mr(...) - 取消註冊 memory region ### Queue Pair (QP) - 包含 Send/Receive Queue - Send/Receive Queue 都會產生 Work Completion - 每一個都是獨立的 #### API - struct ibv_qp *ibv_create_qp(...) - 創建新的 queue pair - int ibv_destroy_qp(...) - 砍掉 queue pair - int ibv_modify_qp(...) - 改變 queue pair 屬性 - int ibv_query_qp(...) - 查詢 queue pair 屬性 ### transport types - Reliable Connected (RC) - 像 TCP - Unreliable Connected (UC) - Unreliable Datagram (UD) - 像 UDP ### Scatter/Gather (S/G) elements - 每一個 Work Request 會有一個或多個 S/G - 每個 S/G 指向 Memory Region - 沒有 S/G 代表 0-byte message - Gather - local data 通過網路 sent/read - Scatter - local data 在本機 write/recieve #### API - struct ibv_sge {...} ### Post Send/Receiev Request - 把 Send Request 傳到 Send/Receiev Queue #### API - int ibv_post_send(...) - struct ibv_send_wr {...} - intibv_post_recv(...) - structibv_recv_wr {...} ### Polling for Work Completion 檢查 Work Request 已經完成 #### API - intibv_poll_cq(...) - struct ibv_wc {...} - Work Completion status - IBV_WC_SUCCESS - Success - IBV_WC_LOC_LEN_ERR - Local length error - IBV_WC_LOC_PROT_ERR - Local Protection error; S/G 沒有指到正確的 MR - IBV_WC_WR_FLUSH_ERR - Work Request flush error; QP 在錯誤的狀態 - IBV_WC_RETRY_EXC_ERR - Retry exceeded; remote QP 沒有傳回 ACK/NACK - IBV_WC_RNR_RETRY_EXC_ERR - Receiver Not Ready; remote 沒有 Receive Request
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up