blob: b01a8a8d4de9c8dfcf7ea4aa7a3de2369f8a0269 [file] [log] [blame]
Leon Romanovsky24f52142019-10-20 10:15:56 +03001/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
Hal Rosenstockc3e01642005-07-27 11:45:39 -07002/*
Sean Hefty07d357d2005-10-17 15:37:43 -07003 * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
Hal Rosenstockc3e01642005-07-27 11:45:39 -07004 * Copyright (c) 2004 Topspin Corporation. All rights reserved.
5 * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
6 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
Leon Romanovsky24f52142019-10-20 10:15:56 +03007 * Copyright (c) 2019, Mellanox Technologies inc. All rights reserved.
Hal Rosenstockc3e01642005-07-27 11:45:39 -07008 */
Leon Romanovskya9160512019-10-20 10:15:55 +03009#ifndef IB_CM_H
Hal Rosenstockc3e01642005-07-27 11:45:39 -070010#define IB_CM_H
11
Roland Dreiera4d61e82005-08-25 13:40:04 -070012#include <rdma/ib_mad.h>
13#include <rdma/ib_sa.h>
Hal Rosenstockc3e01642005-07-27 11:45:39 -070014
Sean Heftyc89d1be2011-12-06 21:13:10 +000015/* ib_cm and ib_user_cm modules share /sys/class/infiniband_cm */
16extern struct class cm_class;
17
Hal Rosenstockc3e01642005-07-27 11:45:39 -070018enum ib_cm_state {
19 IB_CM_IDLE,
20 IB_CM_LISTEN,
21 IB_CM_REQ_SENT,
22 IB_CM_REQ_RCVD,
23 IB_CM_MRA_REQ_SENT,
24 IB_CM_MRA_REQ_RCVD,
25 IB_CM_REP_SENT,
26 IB_CM_REP_RCVD,
27 IB_CM_MRA_REP_SENT,
28 IB_CM_MRA_REP_RCVD,
29 IB_CM_ESTABLISHED,
30 IB_CM_DREQ_SENT,
31 IB_CM_DREQ_RCVD,
32 IB_CM_TIMEWAIT,
33 IB_CM_SIDR_REQ_SENT,
34 IB_CM_SIDR_REQ_RCVD
35};
36
37enum ib_cm_lap_state {
Sean Heftye1444b52006-11-28 14:57:13 -080038 IB_CM_LAP_UNINIT,
Hal Rosenstockc3e01642005-07-27 11:45:39 -070039 IB_CM_LAP_IDLE,
40 IB_CM_LAP_SENT,
41 IB_CM_LAP_RCVD,
42 IB_CM_MRA_LAP_SENT,
43 IB_CM_MRA_LAP_RCVD,
44};
45
46enum ib_cm_event_type {
47 IB_CM_REQ_ERROR,
48 IB_CM_REQ_RECEIVED,
49 IB_CM_REP_ERROR,
50 IB_CM_REP_RECEIVED,
51 IB_CM_RTU_RECEIVED,
52 IB_CM_USER_ESTABLISHED,
53 IB_CM_DREQ_ERROR,
54 IB_CM_DREQ_RECEIVED,
55 IB_CM_DREP_RECEIVED,
56 IB_CM_TIMEWAIT_EXIT,
57 IB_CM_MRA_RECEIVED,
58 IB_CM_REJ_RECEIVED,
59 IB_CM_LAP_ERROR,
60 IB_CM_LAP_RECEIVED,
61 IB_CM_APR_RECEIVED,
62 IB_CM_SIDR_REQ_ERROR,
63 IB_CM_SIDR_REQ_RECEIVED,
64 IB_CM_SIDR_REP_RECEIVED
65};
66
67enum ib_cm_data_size {
68 IB_CM_REQ_PRIVATE_DATA_SIZE = 92,
69 IB_CM_MRA_PRIVATE_DATA_SIZE = 222,
70 IB_CM_REJ_PRIVATE_DATA_SIZE = 148,
71 IB_CM_REP_PRIVATE_DATA_SIZE = 196,
72 IB_CM_RTU_PRIVATE_DATA_SIZE = 224,
73 IB_CM_DREQ_PRIVATE_DATA_SIZE = 220,
74 IB_CM_DREP_PRIVATE_DATA_SIZE = 224,
75 IB_CM_REJ_ARI_LENGTH = 72,
76 IB_CM_LAP_PRIVATE_DATA_SIZE = 168,
77 IB_CM_APR_PRIVATE_DATA_SIZE = 148,
78 IB_CM_APR_INFO_LENGTH = 72,
79 IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216,
80 IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136,
Sean Hefty6e61d042006-06-17 20:37:28 -070081 IB_CM_SIDR_REP_INFO_LENGTH = 72,
Hal Rosenstockc3e01642005-07-27 11:45:39 -070082};
83
84struct ib_cm_id;
85
86struct ib_cm_req_event_param {
87 struct ib_cm_id *listen_id;
Haggai Eran24cad9a2015-07-30 17:50:21 +030088
89 /* P_Key that was used by the GMP's BTH header */
90 u16 bth_pkey;
91
Hal Rosenstockc3e01642005-07-27 11:45:39 -070092 u8 port;
93
Dasaratharaman Chandramoulic2f8fc42017-04-27 19:05:58 -040094 struct sa_path_rec *primary_path;
95 struct sa_path_rec *alternate_path;
Hal Rosenstockc3e01642005-07-27 11:45:39 -070096
Parav Panditcee10432018-07-16 11:50:11 +030097 /*
98 * SGID attribute of the primary path. Currently only
99 * useful for RoCE. Alternate path GID attributes
100 * are not yet supported.
101 */
102 const struct ib_gid_attr *ppath_sgid_attr;
103
Sean Hefty97f52eb2005-08-13 21:05:57 -0700104 __be64 remote_ca_guid;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700105 u32 remote_qkey;
106 u32 remote_qpn;
107 enum ib_qp_type qp_type;
108
109 u32 starting_psn;
110 u8 responder_resources;
111 u8 initiator_depth;
112 unsigned int local_cm_response_timeout:5;
113 unsigned int flow_control:1;
114 unsigned int remote_cm_response_timeout:5;
115 unsigned int retry_count:3;
116 unsigned int rnr_retry_count:3;
117 unsigned int srq:1;
118};
119
120struct ib_cm_rep_event_param {
Sean Hefty97f52eb2005-08-13 21:05:57 -0700121 __be64 remote_ca_guid;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700122 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};
133
134enum ib_cm_rej_reason {
Sean Hefty97f52eb2005-08-13 21:05:57 -0700135 IB_CM_REJ_NO_QP = 1,
136 IB_CM_REJ_NO_EEC = 2,
137 IB_CM_REJ_NO_RESOURCES = 3,
138 IB_CM_REJ_TIMEOUT = 4,
139 IB_CM_REJ_UNSUPPORTED = 5,
140 IB_CM_REJ_INVALID_COMM_ID = 6,
141 IB_CM_REJ_INVALID_COMM_INSTANCE = 7,
142 IB_CM_REJ_INVALID_SERVICE_ID = 8,
143 IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9,
144 IB_CM_REJ_STALE_CONN = 10,
145 IB_CM_REJ_RDC_NOT_EXIST = 11,
146 IB_CM_REJ_INVALID_GID = 12,
147 IB_CM_REJ_INVALID_LID = 13,
148 IB_CM_REJ_INVALID_SL = 14,
149 IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15,
150 IB_CM_REJ_INVALID_HOP_LIMIT = 16,
151 IB_CM_REJ_INVALID_PACKET_RATE = 17,
152 IB_CM_REJ_INVALID_ALT_GID = 18,
153 IB_CM_REJ_INVALID_ALT_LID = 19,
154 IB_CM_REJ_INVALID_ALT_SL = 20,
155 IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21,
156 IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22,
157 IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23,
158 IB_CM_REJ_PORT_CM_REDIRECT = 24,
159 IB_CM_REJ_PORT_REDIRECT = 25,
160 IB_CM_REJ_INVALID_MTU = 26,
161 IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27,
162 IB_CM_REJ_CONSUMER_DEFINED = 28,
163 IB_CM_REJ_INVALID_RNR_RETRY = 29,
164 IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30,
165 IB_CM_REJ_INVALID_CLASS_VERSION = 31,
166 IB_CM_REJ_INVALID_FLOW_LABEL = 32,
167 IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700168};
169
170struct ib_cm_rej_event_param {
171 enum ib_cm_rej_reason reason;
172 void *ari;
173 u8 ari_length;
174};
175
176struct ib_cm_mra_event_param {
177 u8 service_timeout;
178};
179
180struct ib_cm_lap_event_param {
Dasaratharaman Chandramoulic2f8fc42017-04-27 19:05:58 -0400181 struct sa_path_rec *alternate_path;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700182};
183
184enum ib_cm_apr_status {
185 IB_CM_APR_SUCCESS,
186 IB_CM_APR_INVALID_COMM_ID,
187 IB_CM_APR_UNSUPPORTED,
188 IB_CM_APR_REJECT,
189 IB_CM_APR_REDIRECT,
190 IB_CM_APR_IS_CURRENT,
191 IB_CM_APR_INVALID_QPN_EECN,
192 IB_CM_APR_INVALID_LID,
193 IB_CM_APR_INVALID_GID,
194 IB_CM_APR_INVALID_FLOW_LABEL,
195 IB_CM_APR_INVALID_TCLASS,
196 IB_CM_APR_INVALID_HOP_LIMIT,
197 IB_CM_APR_INVALID_PACKET_RATE,
198 IB_CM_APR_INVALID_SL
199};
200
201struct ib_cm_apr_event_param {
202 enum ib_cm_apr_status ap_status;
203 void *apr_info;
204 u8 info_len;
205};
206
207struct ib_cm_sidr_req_event_param {
208 struct ib_cm_id *listen_id;
Haggai Eran15865e7d2015-07-30 17:50:17 +0300209 __be64 service_id;
Parav Panditcee10432018-07-16 11:50:11 +0300210
211 /*
212 * SGID attribute of the request. Currently only
213 * useful for RoCE.
214 */
215 const struct ib_gid_attr *sgid_attr;
Haggai Eran24cad9a2015-07-30 17:50:21 +0300216 /* P_Key that was used by the GMP's BTH header */
217 u16 bth_pkey;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700218 u8 port;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700219 u16 pkey;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700220};
221
222enum ib_cm_sidr_status {
223 IB_SIDR_SUCCESS,
224 IB_SIDR_UNSUPPORTED,
225 IB_SIDR_REJECT,
226 IB_SIDR_NO_QP,
227 IB_SIDR_REDIRECT,
228 IB_SIDR_UNSUPPORTED_VERSION
229};
230
231struct ib_cm_sidr_rep_event_param {
232 enum ib_cm_sidr_status status;
233 u32 qkey;
234 u32 qpn;
235 void *info;
Parav Pandit815d4562018-06-19 10:59:18 +0300236 const struct ib_gid_attr *sgid_attr;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700237 u8 info_len;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700238};
239
240struct ib_cm_event {
241 enum ib_cm_event_type event;
242 union {
243 struct ib_cm_req_event_param req_rcvd;
244 struct ib_cm_rep_event_param rep_rcvd;
245 /* No data for RTU received events. */
246 struct ib_cm_rej_event_param rej_rcvd;
247 struct ib_cm_mra_event_param mra_rcvd;
248 struct ib_cm_lap_event_param lap_rcvd;
249 struct ib_cm_apr_event_param apr_rcvd;
250 /* No data for DREQ/DREP received events. */
251 struct ib_cm_sidr_req_event_param sidr_req_rcvd;
252 struct ib_cm_sidr_rep_event_param sidr_rep_rcvd;
253 enum ib_wc_status send_status;
254 } param;
255
256 void *private_data;
257};
258
Jack Morgenstein3045f092012-06-19 11:21:39 +0300259#define CM_REQ_ATTR_ID cpu_to_be16(0x0010)
260#define CM_MRA_ATTR_ID cpu_to_be16(0x0011)
261#define CM_REJ_ATTR_ID cpu_to_be16(0x0012)
262#define CM_REP_ATTR_ID cpu_to_be16(0x0013)
263#define CM_RTU_ATTR_ID cpu_to_be16(0x0014)
264#define CM_DREQ_ATTR_ID cpu_to_be16(0x0015)
265#define CM_DREP_ATTR_ID cpu_to_be16(0x0016)
266#define CM_SIDR_REQ_ATTR_ID cpu_to_be16(0x0017)
267#define CM_SIDR_REP_ATTR_ID cpu_to_be16(0x0018)
268#define CM_LAP_ATTR_ID cpu_to_be16(0x0019)
269#define CM_APR_ATTR_ID cpu_to_be16(0x001A)
270
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700271/**
272 * ib_cm_handler - User-defined callback to process communication events.
273 * @cm_id: Communication identifier associated with the reported event.
274 * @event: Information about the communication event.
275 *
276 * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events
277 * generated as a result of listen requests result in the allocation of a
278 * new @cm_id. The new @cm_id is returned to the user through this callback.
279 * Clients are responsible for destroying the new @cm_id. For peer-to-peer
280 * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds
281 * to a user's existing communication identifier.
282 *
283 * Users may not call ib_destroy_cm_id while in the context of this callback;
284 * however, returning a non-zero value instructs the communication manager to
285 * destroy the @cm_id after the callback completes.
286 */
287typedef int (*ib_cm_handler)(struct ib_cm_id *cm_id,
Parav Pandite7ff98a2018-07-29 11:53:11 +0300288 const struct ib_cm_event *event);
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700289
290struct ib_cm_id {
291 ib_cm_handler cm_handler;
292 void *context;
Sean Hefty07d357d2005-10-17 15:37:43 -0700293 struct ib_device *device;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700294 __be64 service_id;
295 __be64 service_mask;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700296 enum ib_cm_state state; /* internal CM/debug use */
297 enum ib_cm_lap_state lap_state; /* internal CM/debug use */
Sean Hefty97f52eb2005-08-13 21:05:57 -0700298 __be32 local_id;
299 __be32 remote_id;
John Kingman354ba392005-09-09 18:23:32 -0700300 u32 remote_cm_qpn; /* 1 unless redirected */
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700301};
302
303/**
304 * ib_create_cm_id - Allocate a communication identifier.
Sean Hefty07d357d2005-10-17 15:37:43 -0700305 * @device: Device associated with the cm_id. All related communication will
306 * be associated with the specified device.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700307 * @cm_handler: Callback invoked to notify the user of CM events.
308 * @context: User specified context associated with the communication
309 * identifier.
310 *
311 * Communication identifiers are used to track connection states, service
312 * ID resolution requests, and listen requests.
313 */
Sean Hefty07d357d2005-10-17 15:37:43 -0700314struct ib_cm_id *ib_create_cm_id(struct ib_device *device,
315 ib_cm_handler cm_handler,
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700316 void *context);
317
318/**
319 * ib_destroy_cm_id - Destroy a connection identifier.
320 * @cm_id: Connection identifier to destroy.
321 *
322 * This call blocks until the connection identifier is destroyed.
323 */
324void ib_destroy_cm_id(struct ib_cm_id *cm_id);
325
Harvey Harrison9c3da092009-01-17 17:11:57 -0800326#define IB_SERVICE_ID_AGN_MASK cpu_to_be64(0xFF00000000000000ULL)
327#define IB_CM_ASSIGN_SERVICE_ID cpu_to_be64(0x0200000000000000ULL)
328#define IB_CMA_SERVICE_ID cpu_to_be64(0x0000000001000000ULL)
329#define IB_CMA_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFF000000ULL)
330#define IB_SDP_SERVICE_ID cpu_to_be64(0x0000000000010000ULL)
331#define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL)
Sean Hefty6e61d042006-06-17 20:37:28 -0700332
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700333/**
334 * ib_cm_listen - Initiates listening on the specified service ID for
335 * connection and service ID resolution requests.
336 * @cm_id: Connection identifier associated with the listen request.
337 * @service_id: Service identifier matched against incoming connection
338 * and service ID resolution requests. The service ID should be specified
339 * network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will
340 * assign a service ID to the caller.
341 * @service_mask: Mask applied to service ID used to listen across a
342 * range of service IDs. If set to 0, the service ID is matched
343 * exactly. This parameter is ignored if %service_id is set to
344 * IB_CM_ASSIGN_SERVICE_ID.
345 */
Haggai Eran73fec7f2015-07-30 17:50:26 +0300346int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id,
347 __be64 service_mask);
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700348
Haggai Eran067b1712015-07-30 17:50:18 +0300349struct ib_cm_id *ib_cm_insert_listen(struct ib_device *device,
350 ib_cm_handler cm_handler,
351 __be64 service_id);
352
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700353struct ib_cm_req_param {
Dasaratharaman Chandramoulic2f8fc42017-04-27 19:05:58 -0400354 struct sa_path_rec *primary_path;
355 struct sa_path_rec *alternate_path;
Parav Pandit815d4562018-06-19 10:59:18 +0300356 const struct ib_gid_attr *ppath_sgid_attr;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700357 __be64 service_id;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700358 u32 qp_num;
359 enum ib_qp_type qp_type;
360 u32 starting_psn;
361 const void *private_data;
362 u8 private_data_len;
363 u8 peer_to_peer;
364 u8 responder_resources;
365 u8 initiator_depth;
366 u8 remote_cm_response_timeout;
367 u8 flow_control;
368 u8 local_cm_response_timeout;
369 u8 retry_count;
370 u8 rnr_retry_count;
371 u8 max_cm_retries;
372 u8 srq;
373};
374
375/**
376 * ib_send_cm_req - Sends a connection request to the remote node.
377 * @cm_id: Connection identifier that will be associated with the
378 * connection request.
379 * @param: Connection request information needed to establish the
380 * connection.
381 */
382int ib_send_cm_req(struct ib_cm_id *cm_id,
383 struct ib_cm_req_param *param);
384
385struct ib_cm_rep_param {
386 u32 qp_num;
387 u32 starting_psn;
388 const void *private_data;
389 u8 private_data_len;
390 u8 responder_resources;
391 u8 initiator_depth;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700392 u8 failover_accepted;
393 u8 flow_control;
394 u8 rnr_retry_count;
395 u8 srq;
396};
397
398/**
399 * ib_send_cm_rep - Sends a connection reply in response to a connection
400 * request.
401 * @cm_id: Connection identifier that will be associated with the
402 * connection request.
403 * @param: Connection reply information needed to establish the
404 * connection.
405 */
406int ib_send_cm_rep(struct ib_cm_id *cm_id,
407 struct ib_cm_rep_param *param);
408
409/**
410 * ib_send_cm_rtu - Sends a connection ready to use message in response
411 * to a connection reply message.
412 * @cm_id: Connection identifier associated with the connection request.
413 * @private_data: Optional user-defined private data sent with the
414 * ready to use message.
415 * @private_data_len: Size of the private data buffer, in bytes.
416 */
417int ib_send_cm_rtu(struct ib_cm_id *cm_id,
418 const void *private_data,
419 u8 private_data_len);
420
421/**
422 * ib_send_cm_dreq - Sends a disconnection request for an existing
423 * connection.
424 * @cm_id: Connection identifier associated with the connection being
425 * released.
426 * @private_data: Optional user-defined private data sent with the
427 * disconnection request message.
428 * @private_data_len: Size of the private data buffer, in bytes.
429 */
430int ib_send_cm_dreq(struct ib_cm_id *cm_id,
431 const void *private_data,
432 u8 private_data_len);
433
434/**
435 * ib_send_cm_drep - Sends a disconnection reply to a disconnection request.
436 * @cm_id: Connection identifier associated with the connection being
437 * released.
438 * @private_data: Optional user-defined private data sent with the
439 * disconnection reply message.
440 * @private_data_len: Size of the private data buffer, in bytes.
441 *
442 * If the cm_id is in the correct state, the CM will transition the connection
443 * to the timewait state, even if an error occurs sending the DREP message.
444 */
445int ib_send_cm_drep(struct ib_cm_id *cm_id,
446 const void *private_data,
447 u8 private_data_len);
448
449/**
Sean Heftye1444b52006-11-28 14:57:13 -0800450 * ib_cm_notify - Notifies the CM of an event reported to the consumer.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700451 * @cm_id: Connection identifier to transition to established.
Sean Heftye1444b52006-11-28 14:57:13 -0800452 * @event: Type of event.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700453 *
Sean Heftye1444b52006-11-28 14:57:13 -0800454 * This routine should be invoked by users to notify the CM of relevant
455 * communication events. Events that should be reported to the CM and
456 * when to report them are:
457 *
458 * IB_EVENT_COMM_EST - Used when a message is received on a connected
459 * QP before an RTU has been received.
460 * IB_EVENT_PATH_MIG - Notifies the CM that the connection has failed over
461 * to the alternate path.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700462 */
Sean Heftye1444b52006-11-28 14:57:13 -0800463int ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event);
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700464
465/**
466 * ib_send_cm_rej - Sends a connection rejection message to the
467 * remote node.
468 * @cm_id: Connection identifier associated with the connection being
469 * rejected.
470 * @reason: Reason for the connection request rejection.
471 * @ari: Optional additional rejection information.
472 * @ari_length: Size of the additional rejection information, in bytes.
473 * @private_data: Optional user-defined private data sent with the
474 * rejection message.
475 * @private_data_len: Size of the private data buffer, in bytes.
476 */
477int ib_send_cm_rej(struct ib_cm_id *cm_id,
478 enum ib_cm_rej_reason reason,
479 void *ari,
480 u8 ari_length,
481 const void *private_data,
482 u8 private_data_len);
483
Sean Heftyde98b692007-08-01 13:49:53 -0700484#define IB_CM_MRA_FLAG_DELAY 0x80 /* Send MRA only after a duplicate msg */
485
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700486/**
487 * ib_send_cm_mra - Sends a message receipt acknowledgement to a connection
488 * message.
489 * @cm_id: Connection identifier associated with the connection message.
Sean Heftyde98b692007-08-01 13:49:53 -0700490 * @service_timeout: The lower 5-bits specify the maximum time required for
Anand Gadiyarfd589a82009-07-16 17:13:03 +0200491 * the sender to reply to the connection message. The upper 3-bits
Sean Heftyde98b692007-08-01 13:49:53 -0700492 * specify additional control flags.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700493 * @private_data: Optional user-defined private data sent with the
494 * message receipt acknowledgement.
495 * @private_data_len: Size of the private data buffer, in bytes.
496 */
497int ib_send_cm_mra(struct ib_cm_id *cm_id,
498 u8 service_timeout,
499 const void *private_data,
500 u8 private_data_len);
501
502/**
503 * ib_send_cm_lap - Sends a load alternate path request.
504 * @cm_id: Connection identifier associated with the load alternate path
505 * message.
506 * @alternate_path: A path record that identifies the alternate path to
507 * load.
508 * @private_data: Optional user-defined private data sent with the
509 * load alternate path message.
510 * @private_data_len: Size of the private data buffer, in bytes.
511 */
512int ib_send_cm_lap(struct ib_cm_id *cm_id,
Dasaratharaman Chandramoulic2f8fc42017-04-27 19:05:58 -0400513 struct sa_path_rec *alternate_path,
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700514 const void *private_data,
515 u8 private_data_len);
516
517/**
518 * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning
519 * to a specified QP state.
520 * @cm_id: Communication identifier associated with the QP attributes to
521 * initialize.
522 * @qp_attr: On input, specifies the desired QP state. On output, the
523 * mandatory and desired optional attributes will be set in order to
524 * modify the QP to the specified state.
525 * @qp_attr_mask: The QP attribute mask that may be used to transition the
526 * QP to the specified state.
527 *
528 * Users must set the @qp_attr->qp_state to the desired QP state. This call
529 * will set all required attributes for the given transition, along with
530 * known optional attributes. Users may override the attributes returned from
531 * this call before calling ib_modify_qp.
532 */
533int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
534 struct ib_qp_attr *qp_attr,
535 int *qp_attr_mask);
536
537/**
538 * ib_send_cm_apr - Sends an alternate path response message in response to
539 * a load alternate path request.
540 * @cm_id: Connection identifier associated with the alternate path response.
541 * @status: Reply status sent with the alternate path response.
542 * @info: Optional additional information sent with the alternate path
543 * response.
544 * @info_length: Size of the additional information, in bytes.
545 * @private_data: Optional user-defined private data sent with the
546 * alternate path response message.
547 * @private_data_len: Size of the private data buffer, in bytes.
548 */
549int ib_send_cm_apr(struct ib_cm_id *cm_id,
550 enum ib_cm_apr_status status,
551 void *info,
552 u8 info_length,
553 const void *private_data,
554 u8 private_data_len);
555
556struct ib_cm_sidr_req_param {
Dasaratharaman Chandramoulic2f8fc42017-04-27 19:05:58 -0400557 struct sa_path_rec *path;
Parav Pandit815d4562018-06-19 10:59:18 +0300558 const struct ib_gid_attr *sgid_attr;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700559 __be64 service_id;
Leon Romanovskydbace112018-10-11 17:30:05 +0300560 unsigned long timeout_ms;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700561 const void *private_data;
562 u8 private_data_len;
563 u8 max_cm_retries;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700564};
565
566/**
567 * ib_send_cm_sidr_req - Sends a service ID resolution request to the
568 * remote node.
569 * @cm_id: Communication identifier that will be associated with the
570 * service ID resolution request.
571 * @param: Service ID resolution request information.
572 */
573int ib_send_cm_sidr_req(struct ib_cm_id *cm_id,
574 struct ib_cm_sidr_req_param *param);
575
576struct ib_cm_sidr_rep_param {
577 u32 qp_num;
578 u32 qkey;
579 enum ib_cm_sidr_status status;
580 const void *info;
581 u8 info_length;
582 const void *private_data;
583 u8 private_data_len;
584};
585
586/**
Sean Hefty75af9082006-06-17 20:37:39 -0700587 * ib_send_cm_sidr_rep - Sends a service ID resolution reply to the
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700588 * remote node.
589 * @cm_id: Communication identifier associated with the received service ID
590 * resolution request.
591 * @param: Service ID resolution reply information.
592 */
593int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
594 struct ib_cm_sidr_rep_param *param);
595
Steve Wise77a5db12016-10-26 12:36:40 -0700596/**
597 * ibcm_reject_msg - return a pointer to a reject message string.
598 * @reason: Value returned in the REJECT event status field.
599 */
600const char *__attribute_const__ ibcm_reject_msg(int reason);
601
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700602#endif /* IB_CM_H */