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