forked from wxdwfc/rlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.hpp
107 lines (94 loc) · 1.77 KB
/
common.hpp
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#pragma once
#include <cstdint>
#include "logging.hpp"
#include "rnic.hpp"
#include "mr.hpp"
namespace rdmaio {
// connection status
enum ConnStatus {
SUCC = 0,
TIMEOUT = 1,
WRONG_ARG = 2,
ERR = 3,
NOT_READY = 4,
UNKNOWN = 5
};
/**
* The connection information exchanged between different QPs.
* RC/UC QPs uses lid & addr to conncet to remote QPs, while qpn is used upon send requests.
* node_id & port_id is used for UD QP to create addresses.
*/
struct QPAttr {
address_t addr;
uint16_t lid;
uint32_t qpn;
uint32_t psn;
uint16_t node_id;
uint16_t port_id;
};
/**
* The QP connection requests sent to remote.
* from_node & from_worker identifies which QP it shall connect to
*/
struct QPConnArg {
uint16_t from_node;
uint8_t from_worker;
uint8_t qp_type; // RC QP or UD QP
};
/**
* The MR connection requests sent to remote.
*/
struct MRConnArg {
uint64_t mr_id;
};
struct ConnArg {
enum { MR, QP } type;
union {
QPConnArg qp;
MRConnArg mr;
} payload;
};
struct ConnReply {
ConnStatus ack;
union {
QPAttr qp;
MemoryAttr mr;
} payload;
};
inline int convert_mtu(ibv_mtu type) {
int mtu = 0;
switch(type) {
case IBV_MTU_256:
mtu = 256;
break;
case IBV_MTU_512:
mtu = 512;
break;
case IBV_MTU_1024:
mtu = 1024;
break;
case IBV_MTU_2048:
mtu = 2048;
break;
case IBV_MTU_4096:
mtu = 4096;
break;
}
return mtu;
}
// The structure used to configure UDQP
typedef struct {
int max_send_size;
int max_recv_size;
int qkey;
int psn;
} UDConfig;
typedef struct {
int access_flags;
int max_rd_atomic;
int max_dest_rd_atomic;
int rq_psn;
int sq_psn;
int timeout;
} RCConfig;
} // namespace rdmaio