This source file includes following definitions.
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
- IB_OPCODE
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 #ifndef IB_PACK_H
34 #define IB_PACK_H
35
36 #include <rdma/ib_verbs.h>
37 #include <uapi/linux/if_ether.h>
38
39 enum {
40 IB_LRH_BYTES = 8,
41 IB_ETH_BYTES = 14,
42 IB_VLAN_BYTES = 4,
43 IB_GRH_BYTES = 40,
44 IB_IP4_BYTES = 20,
45 IB_UDP_BYTES = 8,
46 IB_BTH_BYTES = 12,
47 IB_DETH_BYTES = 8,
48 IB_EXT_ATOMICETH_BYTES = 28,
49 IB_EXT_XRC_BYTES = 4,
50 IB_ICRC_BYTES = 4
51 };
52
53 struct ib_field {
54 size_t struct_offset_bytes;
55 size_t struct_size_bytes;
56 int offset_words;
57 int offset_bits;
58 int size_bits;
59 char *field_name;
60 };
61
62 #define RESERVED \
63 .field_name = "reserved"
64
65
66
67
68
69
70
71
72
73
74 #define IB_OPCODE(transport, op) \
75 IB_OPCODE_ ## transport ## _ ## op = \
76 IB_OPCODE_ ## transport + IB_OPCODE_ ## op
77
78 enum {
79
80 IB_OPCODE_RC = 0x00,
81 IB_OPCODE_UC = 0x20,
82 IB_OPCODE_RD = 0x40,
83 IB_OPCODE_UD = 0x60,
84
85 IB_OPCODE_CNP = 0x80,
86
87 IB_OPCODE_MSP = 0xe0,
88
89
90 IB_OPCODE_SEND_FIRST = 0x00,
91 IB_OPCODE_SEND_MIDDLE = 0x01,
92 IB_OPCODE_SEND_LAST = 0x02,
93 IB_OPCODE_SEND_LAST_WITH_IMMEDIATE = 0x03,
94 IB_OPCODE_SEND_ONLY = 0x04,
95 IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE = 0x05,
96 IB_OPCODE_RDMA_WRITE_FIRST = 0x06,
97 IB_OPCODE_RDMA_WRITE_MIDDLE = 0x07,
98 IB_OPCODE_RDMA_WRITE_LAST = 0x08,
99 IB_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE = 0x09,
100 IB_OPCODE_RDMA_WRITE_ONLY = 0x0a,
101 IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE = 0x0b,
102 IB_OPCODE_RDMA_READ_REQUEST = 0x0c,
103 IB_OPCODE_RDMA_READ_RESPONSE_FIRST = 0x0d,
104 IB_OPCODE_RDMA_READ_RESPONSE_MIDDLE = 0x0e,
105 IB_OPCODE_RDMA_READ_RESPONSE_LAST = 0x0f,
106 IB_OPCODE_RDMA_READ_RESPONSE_ONLY = 0x10,
107 IB_OPCODE_ACKNOWLEDGE = 0x11,
108 IB_OPCODE_ATOMIC_ACKNOWLEDGE = 0x12,
109 IB_OPCODE_COMPARE_SWAP = 0x13,
110 IB_OPCODE_FETCH_ADD = 0x14,
111
112 IB_OPCODE_SEND_LAST_WITH_INVALIDATE = 0x16,
113 IB_OPCODE_SEND_ONLY_WITH_INVALIDATE = 0x17,
114
115
116
117
118
119 IB_OPCODE(RC, SEND_FIRST),
120 IB_OPCODE(RC, SEND_MIDDLE),
121 IB_OPCODE(RC, SEND_LAST),
122 IB_OPCODE(RC, SEND_LAST_WITH_IMMEDIATE),
123 IB_OPCODE(RC, SEND_ONLY),
124 IB_OPCODE(RC, SEND_ONLY_WITH_IMMEDIATE),
125 IB_OPCODE(RC, RDMA_WRITE_FIRST),
126 IB_OPCODE(RC, RDMA_WRITE_MIDDLE),
127 IB_OPCODE(RC, RDMA_WRITE_LAST),
128 IB_OPCODE(RC, RDMA_WRITE_LAST_WITH_IMMEDIATE),
129 IB_OPCODE(RC, RDMA_WRITE_ONLY),
130 IB_OPCODE(RC, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
131 IB_OPCODE(RC, RDMA_READ_REQUEST),
132 IB_OPCODE(RC, RDMA_READ_RESPONSE_FIRST),
133 IB_OPCODE(RC, RDMA_READ_RESPONSE_MIDDLE),
134 IB_OPCODE(RC, RDMA_READ_RESPONSE_LAST),
135 IB_OPCODE(RC, RDMA_READ_RESPONSE_ONLY),
136 IB_OPCODE(RC, ACKNOWLEDGE),
137 IB_OPCODE(RC, ATOMIC_ACKNOWLEDGE),
138 IB_OPCODE(RC, COMPARE_SWAP),
139 IB_OPCODE(RC, FETCH_ADD),
140 IB_OPCODE(RC, SEND_LAST_WITH_INVALIDATE),
141 IB_OPCODE(RC, SEND_ONLY_WITH_INVALIDATE),
142
143
144 IB_OPCODE(UC, SEND_FIRST),
145 IB_OPCODE(UC, SEND_MIDDLE),
146 IB_OPCODE(UC, SEND_LAST),
147 IB_OPCODE(UC, SEND_LAST_WITH_IMMEDIATE),
148 IB_OPCODE(UC, SEND_ONLY),
149 IB_OPCODE(UC, SEND_ONLY_WITH_IMMEDIATE),
150 IB_OPCODE(UC, RDMA_WRITE_FIRST),
151 IB_OPCODE(UC, RDMA_WRITE_MIDDLE),
152 IB_OPCODE(UC, RDMA_WRITE_LAST),
153 IB_OPCODE(UC, RDMA_WRITE_LAST_WITH_IMMEDIATE),
154 IB_OPCODE(UC, RDMA_WRITE_ONLY),
155 IB_OPCODE(UC, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
156
157
158 IB_OPCODE(RD, SEND_FIRST),
159 IB_OPCODE(RD, SEND_MIDDLE),
160 IB_OPCODE(RD, SEND_LAST),
161 IB_OPCODE(RD, SEND_LAST_WITH_IMMEDIATE),
162 IB_OPCODE(RD, SEND_ONLY),
163 IB_OPCODE(RD, SEND_ONLY_WITH_IMMEDIATE),
164 IB_OPCODE(RD, RDMA_WRITE_FIRST),
165 IB_OPCODE(RD, RDMA_WRITE_MIDDLE),
166 IB_OPCODE(RD, RDMA_WRITE_LAST),
167 IB_OPCODE(RD, RDMA_WRITE_LAST_WITH_IMMEDIATE),
168 IB_OPCODE(RD, RDMA_WRITE_ONLY),
169 IB_OPCODE(RD, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
170 IB_OPCODE(RD, RDMA_READ_REQUEST),
171 IB_OPCODE(RD, RDMA_READ_RESPONSE_FIRST),
172 IB_OPCODE(RD, RDMA_READ_RESPONSE_MIDDLE),
173 IB_OPCODE(RD, RDMA_READ_RESPONSE_LAST),
174 IB_OPCODE(RD, RDMA_READ_RESPONSE_ONLY),
175 IB_OPCODE(RD, ACKNOWLEDGE),
176 IB_OPCODE(RD, ATOMIC_ACKNOWLEDGE),
177 IB_OPCODE(RD, COMPARE_SWAP),
178 IB_OPCODE(RD, FETCH_ADD),
179
180
181 IB_OPCODE(UD, SEND_ONLY),
182 IB_OPCODE(UD, SEND_ONLY_WITH_IMMEDIATE)
183 };
184
185 enum {
186 IB_LNH_RAW = 0,
187 IB_LNH_IP = 1,
188 IB_LNH_IBA_LOCAL = 2,
189 IB_LNH_IBA_GLOBAL = 3
190 };
191
192 struct ib_unpacked_lrh {
193 u8 virtual_lane;
194 u8 link_version;
195 u8 service_level;
196 u8 link_next_header;
197 __be16 destination_lid;
198 __be16 packet_length;
199 __be16 source_lid;
200 };
201
202 struct ib_unpacked_grh {
203 u8 ip_version;
204 u8 traffic_class;
205 __be32 flow_label;
206 __be16 payload_length;
207 u8 next_header;
208 u8 hop_limit;
209 union ib_gid source_gid;
210 union ib_gid destination_gid;
211 };
212
213 struct ib_unpacked_bth {
214 u8 opcode;
215 u8 solicited_event;
216 u8 mig_req;
217 u8 pad_count;
218 u8 transport_header_version;
219 __be16 pkey;
220 __be32 destination_qpn;
221 u8 ack_req;
222 __be32 psn;
223 };
224
225 struct ib_unpacked_deth {
226 __be32 qkey;
227 __be32 source_qpn;
228 };
229
230 struct ib_unpacked_eth {
231 u8 dmac_h[4];
232 u8 dmac_l[2];
233 u8 smac_h[2];
234 u8 smac_l[4];
235 __be16 type;
236 };
237
238 struct ib_unpacked_ip4 {
239 u8 ver;
240 u8 hdr_len;
241 u8 tos;
242 __be16 tot_len;
243 __be16 id;
244 __be16 frag_off;
245 u8 ttl;
246 u8 protocol;
247 __sum16 check;
248 __be32 saddr;
249 __be32 daddr;
250 };
251
252 struct ib_unpacked_udp {
253 __be16 sport;
254 __be16 dport;
255 __be16 length;
256 __be16 csum;
257 };
258
259 struct ib_unpacked_vlan {
260 __be16 tag;
261 __be16 type;
262 };
263
264 struct ib_ud_header {
265 int lrh_present;
266 struct ib_unpacked_lrh lrh;
267 int eth_present;
268 struct ib_unpacked_eth eth;
269 int vlan_present;
270 struct ib_unpacked_vlan vlan;
271 int grh_present;
272 struct ib_unpacked_grh grh;
273 int ipv4_present;
274 struct ib_unpacked_ip4 ip4;
275 int udp_present;
276 struct ib_unpacked_udp udp;
277 struct ib_unpacked_bth bth;
278 struct ib_unpacked_deth deth;
279 int immediate_present;
280 __be32 immediate_data;
281 };
282
283 void ib_pack(const struct ib_field *desc,
284 int desc_len,
285 void *structure,
286 void *buf);
287
288 void ib_unpack(const struct ib_field *desc,
289 int desc_len,
290 void *buf,
291 void *structure);
292
293 __sum16 ib_ud_ip4_csum(struct ib_ud_header *header);
294
295 int ib_ud_header_init(int payload_bytes,
296 int lrh_present,
297 int eth_present,
298 int vlan_present,
299 int grh_present,
300 int ip_version,
301 int udp_present,
302 int immediate_present,
303 struct ib_ud_header *header);
304
305 int ib_ud_header_pack(struct ib_ud_header *header,
306 void *buf);
307
308 int ib_ud_header_unpack(void *buf,
309 struct ib_ud_header *header);
310
311 #endif