2016年4月29日 星期五

RDMA 範例程式

RDMA 範例程式 


此程式是由 Writing RDMA applications on Linux Example programs  Roland Dreier 這位工程師撰寫的,但是由2007年撰寫的所以在複製程式碼有許多的問題,內部也有一點小bug應該是不小心打錯的,花了一下下午的時間將他補足跟測式執行,為一個由C撰寫兩個數字相加並使用RDMA 傳送的小範例程式。

順便一提,這裡的cc在linux 中就是gcc的意思,可以檢查一下/usr/bin底下的link就可以了。

user @ /usr/bin $ ls -l /usr/bin/cc

lrwxrwxrwx. 1 root root 3 2015-12-08 04:46 /usr/bin/cc -> gcc


編譯前請確認是否有安裝 rdma 跟libibverbs 兩個類別庫,也請確認你的server網卡有支援RDMA。

編譯

client :

$ cc -o client client.c -lrdmacm -libverbs

server :

$ cc -o server server.c -lrdmacm 


執行
server :

$ ./server

client : (格式為  client <servername> <val1> <val2>)

$./client  192.168.1.2  123 567 

123 + 567 = 690



程式碼:

https://github.com/linzion/RDMA-example-application


參考:
http://www.digitalvampire.org/rdma-tutorial-2007/notes.pdf



ibv_wc defined in <infiniband/verbs.h>.
struct ibv_wc {
        uint64_t                wr_id;          /* ID of the completed Work Request (WR) */
        enum ibv_wc_status      status;         /* Status of the operation */
        enum ibv_wc_opcode      opcode;         /* Operation type specified in the completed WR */
        uint32_t                vendor_err;     /* Vendor error syndrome */
        uint32_t                byte_len;       /* Number of bytes transferred */
        uint32_t                imm_data;       /* Immediate data (in network byte order) */
        uint32_t                qp_num;         /* Local QP number of completed WR */
        uint32_t                src_qp;         /* Source QP number (remote QP number) of completed WR (valid only for UD QPs) */
        int                     wc_flags;       /* Flags of the completed WR */
        uint16_t                pkey_index;     /* P_Key index (valid only for GSI QPs) */
        uint16_t                slid;           /* Source LID */
        uint8_t                 sl;             /* Service Level */
        uint8_t                 dlid_path_bits; /* DLID path bits (not applicable for multicast messages) */
};

1 則留言: