1
2
3
4
5
6
7
8
9
10#ifndef IB_CM_H
11#define IB_CM_H
12
13#include <rdma/ib_mad.h>
14#include <rdma/ib_sa.h>
15#include <rdma/rdma_cm.h>
16
17enum ib_cm_state {
18 IB_CM_IDLE,
19 IB_CM_LISTEN,
20 IB_CM_REQ_SENT,
21 IB_CM_REQ_RCVD,
22 IB_CM_MRA_REQ_SENT,
23 IB_CM_MRA_REQ_RCVD,
24 IB_CM_REP_SENT,
25 IB_CM_REP_RCVD,
26 IB_CM_MRA_REP_SENT,
27 IB_CM_MRA_REP_RCVD,
28 IB_CM_ESTABLISHED,
29 IB_CM_DREQ_SENT,
30 IB_CM_DREQ_RCVD,
31 IB_CM_TIMEWAIT,
32 IB_CM_SIDR_REQ_SENT,
33 IB_CM_SIDR_REQ_RCVD
34};
35
36enum ib_cm_lap_state {
37 IB_CM_LAP_UNINIT,
38 IB_CM_LAP_IDLE,
39 IB_CM_LAP_SENT,
40 IB_CM_LAP_RCVD,
41 IB_CM_MRA_LAP_SENT,
42 IB_CM_MRA_LAP_RCVD,
43};
44
45enum ib_cm_event_type {
46 IB_CM_REQ_ERROR,
47 IB_CM_REQ_RECEIVED,
48 IB_CM_REP_ERROR,
49 IB_CM_REP_RECEIVED,
50 IB_CM_RTU_RECEIVED,
51 IB_CM_USER_ESTABLISHED,
52 IB_CM_DREQ_ERROR,
53 IB_CM_DREQ_RECEIVED,
54 IB_CM_DREP_RECEIVED,
55 IB_CM_TIMEWAIT_EXIT,
56 IB_CM_MRA_RECEIVED,
57 IB_CM_REJ_RECEIVED,
58 IB_CM_LAP_ERROR,
59 IB_CM_LAP_RECEIVED,
60 IB_CM_APR_RECEIVED,
61 IB_CM_SIDR_REQ_ERROR,
62 IB_CM_SIDR_REQ_RECEIVED,
63 IB_CM_SIDR_REP_RECEIVED
64};
65
66enum ib_cm_data_size {
67 IB_CM_REQ_PRIVATE_DATA_SIZE = 92,
68 IB_CM_MRA_PRIVATE_DATA_SIZE = 222,
69 IB_CM_REJ_PRIVATE_DATA_SIZE = 148,
70 IB_CM_REP_PRIVATE_DATA_SIZE = 196,
71 IB_CM_RTU_PRIVATE_DATA_SIZE = 224,
72 IB_CM_DREQ_PRIVATE_DATA_SIZE = 220,
73 IB_CM_DREP_PRIVATE_DATA_SIZE = 224,
74 IB_CM_REJ_ARI_LENGTH = 72,
75 IB_CM_LAP_PRIVATE_DATA_SIZE = 168,
76 IB_CM_APR_PRIVATE_DATA_SIZE = 148,
77 IB_CM_APR_INFO_LENGTH = 72,
78 IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216,
79 IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136,
80 IB_CM_SIDR_REP_INFO_LENGTH = 72,
81};
82
83struct ib_cm_id;
84
85struct ib_cm_req_event_param {
86 struct ib_cm_id *listen_id;
87
88
89 u16 bth_pkey;
90
91 u8 port;
92
93 struct sa_path_rec *primary_path;
94 struct sa_path_rec *alternate_path;
95
96
97
98
99
100
101 const struct ib_gid_attr *ppath_sgid_attr;
102
103 __be64 remote_ca_guid;
104 u32 remote_qkey;
105 u32 remote_qpn;
106 enum ib_qp_type qp_type;
107
108 u32 starting_psn;
109 u8 responder_resources;
110 u8 initiator_depth;
111 unsigned int local_cm_response_timeout:5;
112 unsigned int flow_control:1;
113 unsigned int remote_cm_response_timeout:5;
114 unsigned int retry_count:3;
115 unsigned int rnr_retry_count:3;
116 unsigned int srq:1;
117 struct rdma_ucm_ece ece;
118};
119
120struct ib_cm_rep_event_param {
121 __be64 remote_ca_guid;
122 u32 remote_qkey;
123 u32 remote_qpn;
124 u32 starting_psn;
125 u8 responder_resources;
126 u8 initiator_depth;
127 unsigned int target_ack_delay:5;
128 unsigned int failover_accepted:2;
129 unsigned int flow_control:1;
130 unsigned int rnr_retry_count:3;
131 unsigned int srq:1;
132 struct rdma_ucm_ece ece;
133};
134
135enum ib_cm_rej_reason {
136 IB_CM_REJ_NO_QP = 1,
137 IB_CM_REJ_NO_EEC = 2,
138 IB_CM_REJ_NO_RESOURCES = 3,
139 IB_CM_REJ_TIMEOUT = 4,
140 IB_CM_REJ_UNSUPPORTED = 5,
141 IB_CM_REJ_INVALID_COMM_ID = 6,
142 IB_CM_REJ_INVALID_COMM_INSTANCE = 7,
143 IB_CM_REJ_INVALID_SERVICE_ID = 8,
144 IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9,
145 IB_CM_REJ_STALE_CONN = 10,
146 IB_CM_REJ_RDC_NOT_EXIST = 11,
147 IB_CM_REJ_INVALID_GID = 12,
148 IB_CM_REJ_INVALID_LID = 13,
149 IB_CM_REJ_INVALID_SL = 14,
150 IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15,
151 IB_CM_REJ_INVALID_HOP_LIMIT = 16,
152 IB_CM_REJ_INVALID_PACKET_RATE = 17,
153 IB_CM_REJ_INVALID_ALT_GID = 18,
154 IB_CM_REJ_INVALID_ALT_LID = 19,
155 IB_CM_REJ_INVALID_ALT_SL = 20,
156 IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21,
157 IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22,
158 IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23,
159 IB_CM_REJ_PORT_CM_REDIRECT = 24,
160 IB_CM_REJ_PORT_REDIRECT = 25,
161 IB_CM_REJ_INVALID_MTU = 26,
162 IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27,
163 IB_CM_REJ_CONSUMER_DEFINED = 28,
164 IB_CM_REJ_INVALID_RNR_RETRY = 29,
165 IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30,
166 IB_CM_REJ_INVALID_CLASS_VERSION = 31,
167 IB_CM_REJ_INVALID_FLOW_LABEL = 32,
168 IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33,
169 IB_CM_REJ_VENDOR_OPTION_NOT_SUPPORTED = 35,
170};
171
172struct ib_cm_rej_event_param {
173 enum ib_cm_rej_reason reason;
174 void *ari;
175 u8 ari_length;
176};
177
178struct ib_cm_mra_event_param {
179 u8 service_timeout;
180};
181
182struct ib_cm_lap_event_param {
183 struct sa_path_rec *alternate_path;
184};
185
186enum ib_cm_apr_status {
187 IB_CM_APR_SUCCESS,
188 IB_CM_APR_INVALID_COMM_ID,
189 IB_CM_APR_UNSUPPORTED,
190 IB_CM_APR_REJECT,
191 IB_CM_APR_REDIRECT,
192 IB_CM_APR_IS_CURRENT,
193 IB_CM_APR_INVALID_QPN_EECN,
194 IB_CM_APR_INVALID_LID,
195 IB_CM_APR_INVALID_GID,
196 IB_CM_APR_INVALID_FLOW_LABEL,
197 IB_CM_APR_INVALID_TCLASS,
198 IB_CM_APR_INVALID_HOP_LIMIT,
199 IB_CM_APR_INVALID_PACKET_RATE,
200 IB_CM_APR_INVALID_SL
201};
202
203struct ib_cm_apr_event_param {
204 enum ib_cm_apr_status ap_status;
205 void *apr_info;
206 u8 info_len;
207};
208
209struct ib_cm_sidr_req_event_param {
210 struct ib_cm_id *listen_id;
211 __be64 service_id;
212
213
214
215
216
217 const struct ib_gid_attr *sgid_attr;
218
219 u16 bth_pkey;
220 u8 port;
221 u16 pkey;
222};
223
224enum ib_cm_sidr_status {
225 IB_SIDR_SUCCESS,
226 IB_SIDR_UNSUPPORTED,
227 IB_SIDR_REJECT,
228 IB_SIDR_NO_QP,
229 IB_SIDR_REDIRECT,
230 IB_SIDR_UNSUPPORTED_VERSION
231};
232
233struct ib_cm_sidr_rep_event_param {
234 enum ib_cm_sidr_status status;
235 u32 qkey;
236 u32 qpn;
237 void *info;
238 const struct ib_gid_attr *sgid_attr;
239 u8 info_len;
240};
241
242struct ib_cm_event {
243 enum ib_cm_event_type event;
244 union {
245 struct ib_cm_req_event_param req_rcvd;
246 struct ib_cm_rep_event_param rep_rcvd;
247
248 struct ib_cm_rej_event_param rej_rcvd;
249 struct ib_cm_mra_event_param mra_rcvd;
250 struct ib_cm_lap_event_param lap_rcvd;
251 struct ib_cm_apr_event_param apr_rcvd;
252
253 struct ib_cm_sidr_req_event_param sidr_req_rcvd;
254 struct ib_cm_sidr_rep_event_param sidr_rep_rcvd;
255 enum ib_wc_status send_status;
256 } param;
257
258 void *private_data;
259};
260
261#define CM_REQ_ATTR_ID cpu_to_be16(0x0010)
262#define CM_MRA_ATTR_ID cpu_to_be16(0x0011)
263#define CM_REJ_ATTR_ID cpu_to_be16(0x0012)
264#define CM_REP_ATTR_ID cpu_to_be16(0x0013)
265#define CM_RTU_ATTR_ID cpu_to_be16(0x0014)
266#define CM_DREQ_ATTR_ID cpu_to_be16(0x0015)
267#define CM_DREP_ATTR_ID cpu_to_be16(0x0016)
268#define CM_SIDR_REQ_ATTR_ID cpu_to_be16(0x0017)
269#define CM_SIDR_REP_ATTR_ID cpu_to_be16(0x0018)
270#define CM_LAP_ATTR_ID cpu_to_be16(0x0019)
271#define CM_APR_ATTR_ID cpu_to_be16(0x001A)
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289typedef int (*ib_cm_handler)(struct ib_cm_id *cm_id,
290 const struct ib_cm_event *event);
291
292struct ib_cm_id {
293 ib_cm_handler cm_handler;
294 void *context;
295 struct ib_device *device;
296 __be64 service_id;
297 __be64 service_mask;
298 enum ib_cm_state state;
299 enum ib_cm_lap_state lap_state;
300 __be32 local_id;
301 __be32 remote_id;
302 u32 remote_cm_qpn;
303};
304
305
306
307
308
309
310
311
312
313
314
315
316struct ib_cm_id *ib_create_cm_id(struct ib_device *device,
317 ib_cm_handler cm_handler,
318 void *context);
319
320
321
322
323
324
325
326void ib_destroy_cm_id(struct ib_cm_id *cm_id);
327
328#define IB_SERVICE_ID_AGN_MASK cpu_to_be64(0xFF00000000000000ULL)
329#define IB_CM_ASSIGN_SERVICE_ID cpu_to_be64(0x0200000000000000ULL)
330#define IB_CMA_SERVICE_ID cpu_to_be64(0x0000000001000000ULL)
331#define IB_CMA_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFF000000ULL)
332#define IB_SDP_SERVICE_ID cpu_to_be64(0x0000000000010000ULL)
333#define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL)
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id,
349 __be64 service_mask);
350
351struct ib_cm_id *ib_cm_insert_listen(struct ib_device *device,
352 ib_cm_handler cm_handler,
353 __be64 service_id);
354
355struct ib_cm_req_param {
356 struct sa_path_rec *primary_path;
357 struct sa_path_rec *alternate_path;
358 const struct ib_gid_attr *ppath_sgid_attr;
359 __be64 service_id;
360 u32 qp_num;
361 enum ib_qp_type qp_type;
362 u32 starting_psn;
363 const void *private_data;
364 u8 private_data_len;
365 u8 responder_resources;
366 u8 initiator_depth;
367 u8 remote_cm_response_timeout;
368 u8 flow_control;
369 u8 local_cm_response_timeout;
370 u8 retry_count;
371 u8 rnr_retry_count;
372 u8 max_cm_retries;
373 u8 srq;
374 struct rdma_ucm_ece ece;
375};
376
377
378
379
380
381
382
383
384int ib_send_cm_req(struct ib_cm_id *cm_id,
385 struct ib_cm_req_param *param);
386
387struct ib_cm_rep_param {
388 u32 qp_num;
389 u32 starting_psn;
390 const void *private_data;
391 u8 private_data_len;
392 u8 responder_resources;
393 u8 initiator_depth;
394 u8 failover_accepted;
395 u8 flow_control;
396 u8 rnr_retry_count;
397 u8 srq;
398 struct rdma_ucm_ece ece;
399};
400
401
402
403
404
405
406
407
408
409int ib_send_cm_rep(struct ib_cm_id *cm_id,
410 struct ib_cm_rep_param *param);
411
412
413
414
415
416
417
418
419
420int ib_send_cm_rtu(struct ib_cm_id *cm_id,
421 const void *private_data,
422 u8 private_data_len);
423
424
425
426
427
428
429
430
431
432
433int ib_send_cm_dreq(struct ib_cm_id *cm_id,
434 const void *private_data,
435 u8 private_data_len);
436
437
438
439
440
441
442
443
444
445
446
447
448int ib_send_cm_drep(struct ib_cm_id *cm_id,
449 const void *private_data,
450 u8 private_data_len);
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466int ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event);
467
468
469
470
471
472
473
474
475
476
477
478
479
480int ib_send_cm_rej(struct ib_cm_id *cm_id,
481 enum ib_cm_rej_reason reason,
482 void *ari,
483 u8 ari_length,
484 const void *private_data,
485 u8 private_data_len);
486
487#define IB_CM_MRA_FLAG_DELAY 0x80
488
489
490
491
492
493
494
495
496
497
498
499
500int ib_send_cm_mra(struct ib_cm_id *cm_id,
501 u8 service_timeout,
502 const void *private_data,
503 u8 private_data_len);
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
522 struct ib_qp_attr *qp_attr,
523 int *qp_attr_mask);
524
525struct ib_cm_sidr_req_param {
526 struct sa_path_rec *path;
527 const struct ib_gid_attr *sgid_attr;
528 __be64 service_id;
529 unsigned long timeout_ms;
530 const void *private_data;
531 u8 private_data_len;
532 u8 max_cm_retries;
533};
534
535
536
537
538
539
540
541
542int ib_send_cm_sidr_req(struct ib_cm_id *cm_id,
543 struct ib_cm_sidr_req_param *param);
544
545struct ib_cm_sidr_rep_param {
546 u32 qp_num;
547 u32 qkey;
548 enum ib_cm_sidr_status status;
549 const void *info;
550 u8 info_length;
551 const void *private_data;
552 u8 private_data_len;
553 struct rdma_ucm_ece ece;
554};
555
556
557
558
559
560
561
562
563int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
564 struct ib_cm_sidr_rep_param *param);
565
566
567
568
569
570const char *__attribute_const__ ibcm_reject_msg(int reason);
571
572#endif
573