-
Notifications
You must be signed in to change notification settings - Fork 1
/
ib.h
57 lines (45 loc) · 993 Bytes
/
ib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include <infiniband/verbs.h>
#include <cstdint>
#include <string>
#include <thread>
struct RemoteInfo {
// queue pair
uint32_t qpn;
uint32_t psn;
int lid;
// memory region
uint32_t rkey;
uintptr_t addr;
size_t size;
std::string ToString();
};
struct IbContext {
ibv_context *ibv_ctx_;
int port_;
int lid_;
int max_rd_atomic_;
ibv_pd *pd_;
ibv_mr *mr_;
volatile char *buf_;
size_t buf_size_;
IbContext(const std::string &devname, int port, volatile char *buf,
size_t buf_size);
~IbContext();
private:
void GetIbDevice(const std::string &devname, int port);
};
struct QpContext {
IbContext &ib_ctx_;
ibv_cq *cq_;
ibv_qp *qp_;
uint32_t psn_;
RemoteInfo remote_;
QpContext(IbContext &ib_ctx);
~QpContext();
void Activate();
};
void SendLocalInfo(void *sckt, const QpContext &ctx);
void RecvRemoteInfo(void *sckt, QpContext &ctx);
constexpr uint32_t kMaxSendWr = 64;
constexpr uint32_t kMaxRecvWr = 64;