blob: e3f48632e23799ffcb6fb78d33139d4a3431059a [file] [log] [blame]
Hal Rosenstockc3e01642005-07-27 11:45:39 -07001/*
Sean Hefty07d357d2005-10-17 15:37:43 -07002 * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
Hal Rosenstockc3e01642005-07-27 11:45:39 -07003 * Copyright (c) 2004 Topspin Corporation. All rights reserved.
4 * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
5 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
6 *
7 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU
9 * General Public License (GPL) Version 2, available from the file
10 * COPYING in the main directory of this source tree, or the
11 * OpenIB.org BSD license below:
12 *
13 * Redistribution and use in source and binary forms, with or
14 * without modification, are permitted provided that the following
15 * conditions are met:
16 *
17 * - Redistributions of source code must retain the above
18 * copyright notice, this list of conditions and the following
19 * disclaimer.
20 *
21 * - Redistributions in binary form must reproduce the above
22 * copyright notice, this list of conditions and the following
23 * disclaimer in the documentation and/or other materials
24 * provided with the distribution.
25 *
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
30 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE.
Hal Rosenstockc3e01642005-07-27 11:45:39 -070034 */
35#if !defined(IB_CM_H)
36#define IB_CM_H
37
Roland Dreiera4d61e82005-08-25 13:40:04 -070038#include <rdma/ib_mad.h>
39#include <rdma/ib_sa.h>
Hal Rosenstockc3e01642005-07-27 11:45:39 -070040
Sean Heftyc89d1be2011-12-06 21:13:10 +000041/* ib_cm and ib_user_cm modules share /sys/class/infiniband_cm */
42extern struct class cm_class;
43
Hal Rosenstockc3e01642005-07-27 11:45:39 -070044enum 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
63enum ib_cm_lap_state {
Sean Heftye1444b52006-11-28 14:57:13 -080064 IB_CM_LAP_UNINIT,
Hal Rosenstockc3e01642005-07-27 11:45:39 -070065 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
72enum 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
93enum 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,
Sean Hefty6e61d042006-06-17 20:37:28 -0700107 IB_CM_SIDR_REP_INFO_LENGTH = 72,
David Ahern0d0f7382015-05-03 09:48:26 -0400108 /* compare done u32 at a time */
109 IB_CM_COMPARE_SIZE = (64 / sizeof(u32))
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700110};
111
112struct ib_cm_id;
113
114struct ib_cm_req_event_param {
115 struct ib_cm_id *listen_id;
Haggai Eran24cad9a2015-07-30 17:50:21 +0300116
117 /* P_Key that was used by the GMP's BTH header */
118 u16 bth_pkey;
119
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700120 u8 port;
121
122 struct ib_sa_path_rec *primary_path;
123 struct ib_sa_path_rec *alternate_path;
124
Sean Hefty97f52eb2005-08-13 21:05:57 -0700125 __be64 remote_ca_guid;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700126 u32 remote_qkey;
127 u32 remote_qpn;
128 enum ib_qp_type qp_type;
129
130 u32 starting_psn;
131 u8 responder_resources;
132 u8 initiator_depth;
133 unsigned int local_cm_response_timeout:5;
134 unsigned int flow_control:1;
135 unsigned int remote_cm_response_timeout:5;
136 unsigned int retry_count:3;
137 unsigned int rnr_retry_count:3;
138 unsigned int srq:1;
139};
140
141struct ib_cm_rep_event_param {
Sean Hefty97f52eb2005-08-13 21:05:57 -0700142 __be64 remote_ca_guid;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700143 u32 remote_qkey;
144 u32 remote_qpn;
145 u32 starting_psn;
146 u8 responder_resources;
147 u8 initiator_depth;
148 unsigned int target_ack_delay:5;
149 unsigned int failover_accepted:2;
150 unsigned int flow_control:1;
151 unsigned int rnr_retry_count:3;
152 unsigned int srq:1;
153};
154
155enum ib_cm_rej_reason {
Sean Hefty97f52eb2005-08-13 21:05:57 -0700156 IB_CM_REJ_NO_QP = 1,
157 IB_CM_REJ_NO_EEC = 2,
158 IB_CM_REJ_NO_RESOURCES = 3,
159 IB_CM_REJ_TIMEOUT = 4,
160 IB_CM_REJ_UNSUPPORTED = 5,
161 IB_CM_REJ_INVALID_COMM_ID = 6,
162 IB_CM_REJ_INVALID_COMM_INSTANCE = 7,
163 IB_CM_REJ_INVALID_SERVICE_ID = 8,
164 IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9,
165 IB_CM_REJ_STALE_CONN = 10,
166 IB_CM_REJ_RDC_NOT_EXIST = 11,
167 IB_CM_REJ_INVALID_GID = 12,
168 IB_CM_REJ_INVALID_LID = 13,
169 IB_CM_REJ_INVALID_SL = 14,
170 IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15,
171 IB_CM_REJ_INVALID_HOP_LIMIT = 16,
172 IB_CM_REJ_INVALID_PACKET_RATE = 17,
173 IB_CM_REJ_INVALID_ALT_GID = 18,
174 IB_CM_REJ_INVALID_ALT_LID = 19,
175 IB_CM_REJ_INVALID_ALT_SL = 20,
176 IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21,
177 IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22,
178 IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23,
179 IB_CM_REJ_PORT_CM_REDIRECT = 24,
180 IB_CM_REJ_PORT_REDIRECT = 25,
181 IB_CM_REJ_INVALID_MTU = 26,
182 IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27,
183 IB_CM_REJ_CONSUMER_DEFINED = 28,
184 IB_CM_REJ_INVALID_RNR_RETRY = 29,
185 IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30,
186 IB_CM_REJ_INVALID_CLASS_VERSION = 31,
187 IB_CM_REJ_INVALID_FLOW_LABEL = 32,
188 IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700189};
190
191struct ib_cm_rej_event_param {
192 enum ib_cm_rej_reason reason;
193 void *ari;
194 u8 ari_length;
195};
196
197struct ib_cm_mra_event_param {
198 u8 service_timeout;
199};
200
201struct ib_cm_lap_event_param {
202 struct ib_sa_path_rec *alternate_path;
203};
204
205enum ib_cm_apr_status {
206 IB_CM_APR_SUCCESS,
207 IB_CM_APR_INVALID_COMM_ID,
208 IB_CM_APR_UNSUPPORTED,
209 IB_CM_APR_REJECT,
210 IB_CM_APR_REDIRECT,
211 IB_CM_APR_IS_CURRENT,
212 IB_CM_APR_INVALID_QPN_EECN,
213 IB_CM_APR_INVALID_LID,
214 IB_CM_APR_INVALID_GID,
215 IB_CM_APR_INVALID_FLOW_LABEL,
216 IB_CM_APR_INVALID_TCLASS,
217 IB_CM_APR_INVALID_HOP_LIMIT,
218 IB_CM_APR_INVALID_PACKET_RATE,
219 IB_CM_APR_INVALID_SL
220};
221
222struct ib_cm_apr_event_param {
223 enum ib_cm_apr_status ap_status;
224 void *apr_info;
225 u8 info_len;
226};
227
228struct ib_cm_sidr_req_event_param {
229 struct ib_cm_id *listen_id;
Haggai Eran15865e7d2015-07-30 17:50:17 +0300230 __be64 service_id;
Haggai Eran24cad9a2015-07-30 17:50:21 +0300231 /* P_Key that was used by the GMP's BTH header */
232 u16 bth_pkey;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700233 u8 port;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700234 u16 pkey;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700235};
236
237enum ib_cm_sidr_status {
238 IB_SIDR_SUCCESS,
239 IB_SIDR_UNSUPPORTED,
240 IB_SIDR_REJECT,
241 IB_SIDR_NO_QP,
242 IB_SIDR_REDIRECT,
243 IB_SIDR_UNSUPPORTED_VERSION
244};
245
246struct ib_cm_sidr_rep_event_param {
247 enum ib_cm_sidr_status status;
248 u32 qkey;
249 u32 qpn;
250 void *info;
251 u8 info_len;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700252};
253
254struct ib_cm_event {
255 enum ib_cm_event_type event;
256 union {
257 struct ib_cm_req_event_param req_rcvd;
258 struct ib_cm_rep_event_param rep_rcvd;
259 /* No data for RTU received events. */
260 struct ib_cm_rej_event_param rej_rcvd;
261 struct ib_cm_mra_event_param mra_rcvd;
262 struct ib_cm_lap_event_param lap_rcvd;
263 struct ib_cm_apr_event_param apr_rcvd;
264 /* No data for DREQ/DREP received events. */
265 struct ib_cm_sidr_req_event_param sidr_req_rcvd;
266 struct ib_cm_sidr_rep_event_param sidr_rep_rcvd;
267 enum ib_wc_status send_status;
268 } param;
269
270 void *private_data;
271};
272
Jack Morgenstein3045f092012-06-19 11:21:39 +0300273#define CM_REQ_ATTR_ID cpu_to_be16(0x0010)
274#define CM_MRA_ATTR_ID cpu_to_be16(0x0011)
275#define CM_REJ_ATTR_ID cpu_to_be16(0x0012)
276#define CM_REP_ATTR_ID cpu_to_be16(0x0013)
277#define CM_RTU_ATTR_ID cpu_to_be16(0x0014)
278#define CM_DREQ_ATTR_ID cpu_to_be16(0x0015)
279#define CM_DREP_ATTR_ID cpu_to_be16(0x0016)
280#define CM_SIDR_REQ_ATTR_ID cpu_to_be16(0x0017)
281#define CM_SIDR_REP_ATTR_ID cpu_to_be16(0x0018)
282#define CM_LAP_ATTR_ID cpu_to_be16(0x0019)
283#define CM_APR_ATTR_ID cpu_to_be16(0x001A)
284
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700285/**
286 * ib_cm_handler - User-defined callback to process communication events.
287 * @cm_id: Communication identifier associated with the reported event.
288 * @event: Information about the communication event.
289 *
290 * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events
291 * generated as a result of listen requests result in the allocation of a
292 * new @cm_id. The new @cm_id is returned to the user through this callback.
293 * Clients are responsible for destroying the new @cm_id. For peer-to-peer
294 * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds
295 * to a user's existing communication identifier.
296 *
297 * Users may not call ib_destroy_cm_id while in the context of this callback;
298 * however, returning a non-zero value instructs the communication manager to
299 * destroy the @cm_id after the callback completes.
300 */
301typedef int (*ib_cm_handler)(struct ib_cm_id *cm_id,
302 struct ib_cm_event *event);
303
304struct ib_cm_id {
305 ib_cm_handler cm_handler;
306 void *context;
Sean Hefty07d357d2005-10-17 15:37:43 -0700307 struct ib_device *device;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700308 __be64 service_id;
309 __be64 service_mask;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700310 enum ib_cm_state state; /* internal CM/debug use */
311 enum ib_cm_lap_state lap_state; /* internal CM/debug use */
Sean Hefty97f52eb2005-08-13 21:05:57 -0700312 __be32 local_id;
313 __be32 remote_id;
John Kingman354ba392005-09-09 18:23:32 -0700314 u32 remote_cm_qpn; /* 1 unless redirected */
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700315};
316
317/**
318 * ib_create_cm_id - Allocate a communication identifier.
Sean Hefty07d357d2005-10-17 15:37:43 -0700319 * @device: Device associated with the cm_id. All related communication will
320 * be associated with the specified device.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700321 * @cm_handler: Callback invoked to notify the user of CM events.
322 * @context: User specified context associated with the communication
323 * identifier.
324 *
325 * Communication identifiers are used to track connection states, service
326 * ID resolution requests, and listen requests.
327 */
Sean Hefty07d357d2005-10-17 15:37:43 -0700328struct ib_cm_id *ib_create_cm_id(struct ib_device *device,
329 ib_cm_handler cm_handler,
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700330 void *context);
331
332/**
333 * ib_destroy_cm_id - Destroy a connection identifier.
334 * @cm_id: Connection identifier to destroy.
335 *
336 * This call blocks until the connection identifier is destroyed.
337 */
338void ib_destroy_cm_id(struct ib_cm_id *cm_id);
339
Harvey Harrison9c3da092009-01-17 17:11:57 -0800340#define IB_SERVICE_ID_AGN_MASK cpu_to_be64(0xFF00000000000000ULL)
341#define IB_CM_ASSIGN_SERVICE_ID cpu_to_be64(0x0200000000000000ULL)
342#define IB_CMA_SERVICE_ID cpu_to_be64(0x0000000001000000ULL)
343#define IB_CMA_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFF000000ULL)
344#define IB_SDP_SERVICE_ID cpu_to_be64(0x0000000000010000ULL)
345#define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL)
Sean Hefty6e61d042006-06-17 20:37:28 -0700346
347struct ib_cm_compare_data {
David Ahern0d0f7382015-05-03 09:48:26 -0400348 u32 data[IB_CM_COMPARE_SIZE];
349 u32 mask[IB_CM_COMPARE_SIZE];
Sean Hefty6e61d042006-06-17 20:37:28 -0700350};
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700351
352/**
353 * ib_cm_listen - Initiates listening on the specified service ID for
354 * connection and service ID resolution requests.
355 * @cm_id: Connection identifier associated with the listen request.
356 * @service_id: Service identifier matched against incoming connection
357 * and service ID resolution requests. The service ID should be specified
358 * network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will
359 * assign a service ID to the caller.
360 * @service_mask: Mask applied to service ID used to listen across a
361 * range of service IDs. If set to 0, the service ID is matched
362 * exactly. This parameter is ignored if %service_id is set to
363 * IB_CM_ASSIGN_SERVICE_ID.
Sean Hefty6e61d042006-06-17 20:37:28 -0700364 * @compare_data: This parameter is optional. It specifies data that must
365 * appear in the private data of a connection request for the specified
366 * listen request.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700367 */
Sean Hefty6e61d042006-06-17 20:37:28 -0700368int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask,
369 struct ib_cm_compare_data *compare_data);
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700370
Haggai Eran067b1712015-07-30 17:50:18 +0300371struct ib_cm_id *ib_cm_insert_listen(struct ib_device *device,
372 ib_cm_handler cm_handler,
373 __be64 service_id);
374
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700375struct ib_cm_req_param {
376 struct ib_sa_path_rec *primary_path;
377 struct ib_sa_path_rec *alternate_path;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700378 __be64 service_id;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700379 u32 qp_num;
380 enum ib_qp_type qp_type;
381 u32 starting_psn;
382 const void *private_data;
383 u8 private_data_len;
384 u8 peer_to_peer;
385 u8 responder_resources;
386 u8 initiator_depth;
387 u8 remote_cm_response_timeout;
388 u8 flow_control;
389 u8 local_cm_response_timeout;
390 u8 retry_count;
391 u8 rnr_retry_count;
392 u8 max_cm_retries;
393 u8 srq;
394};
395
396/**
397 * ib_send_cm_req - Sends a connection request to the remote node.
398 * @cm_id: Connection identifier that will be associated with the
399 * connection request.
400 * @param: Connection request information needed to establish the
401 * connection.
402 */
403int ib_send_cm_req(struct ib_cm_id *cm_id,
404 struct ib_cm_req_param *param);
405
406struct ib_cm_rep_param {
407 u32 qp_num;
408 u32 starting_psn;
409 const void *private_data;
410 u8 private_data_len;
411 u8 responder_resources;
412 u8 initiator_depth;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700413 u8 failover_accepted;
414 u8 flow_control;
415 u8 rnr_retry_count;
416 u8 srq;
417};
418
419/**
420 * ib_send_cm_rep - Sends a connection reply in response to a connection
421 * request.
422 * @cm_id: Connection identifier that will be associated with the
423 * connection request.
424 * @param: Connection reply information needed to establish the
425 * connection.
426 */
427int ib_send_cm_rep(struct ib_cm_id *cm_id,
428 struct ib_cm_rep_param *param);
429
430/**
431 * ib_send_cm_rtu - Sends a connection ready to use message in response
432 * to a connection reply message.
433 * @cm_id: Connection identifier associated with the connection request.
434 * @private_data: Optional user-defined private data sent with the
435 * ready to use message.
436 * @private_data_len: Size of the private data buffer, in bytes.
437 */
438int ib_send_cm_rtu(struct ib_cm_id *cm_id,
439 const void *private_data,
440 u8 private_data_len);
441
442/**
443 * ib_send_cm_dreq - Sends a disconnection request for an existing
444 * connection.
445 * @cm_id: Connection identifier associated with the connection being
446 * released.
447 * @private_data: Optional user-defined private data sent with the
448 * disconnection request message.
449 * @private_data_len: Size of the private data buffer, in bytes.
450 */
451int ib_send_cm_dreq(struct ib_cm_id *cm_id,
452 const void *private_data,
453 u8 private_data_len);
454
455/**
456 * ib_send_cm_drep - Sends a disconnection reply to a disconnection request.
457 * @cm_id: Connection identifier associated with the connection being
458 * released.
459 * @private_data: Optional user-defined private data sent with the
460 * disconnection reply message.
461 * @private_data_len: Size of the private data buffer, in bytes.
462 *
463 * If the cm_id is in the correct state, the CM will transition the connection
464 * to the timewait state, even if an error occurs sending the DREP message.
465 */
466int ib_send_cm_drep(struct ib_cm_id *cm_id,
467 const void *private_data,
468 u8 private_data_len);
469
470/**
Sean Heftye1444b52006-11-28 14:57:13 -0800471 * ib_cm_notify - Notifies the CM of an event reported to the consumer.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700472 * @cm_id: Connection identifier to transition to established.
Sean Heftye1444b52006-11-28 14:57:13 -0800473 * @event: Type of event.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700474 *
Sean Heftye1444b52006-11-28 14:57:13 -0800475 * This routine should be invoked by users to notify the CM of relevant
476 * communication events. Events that should be reported to the CM and
477 * when to report them are:
478 *
479 * IB_EVENT_COMM_EST - Used when a message is received on a connected
480 * QP before an RTU has been received.
481 * IB_EVENT_PATH_MIG - Notifies the CM that the connection has failed over
482 * to the alternate path.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700483 */
Sean Heftye1444b52006-11-28 14:57:13 -0800484int ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event);
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700485
486/**
487 * ib_send_cm_rej - Sends a connection rejection message to the
488 * remote node.
489 * @cm_id: Connection identifier associated with the connection being
490 * rejected.
491 * @reason: Reason for the connection request rejection.
492 * @ari: Optional additional rejection information.
493 * @ari_length: Size of the additional rejection information, in bytes.
494 * @private_data: Optional user-defined private data sent with the
495 * rejection message.
496 * @private_data_len: Size of the private data buffer, in bytes.
497 */
498int ib_send_cm_rej(struct ib_cm_id *cm_id,
499 enum ib_cm_rej_reason reason,
500 void *ari,
501 u8 ari_length,
502 const void *private_data,
503 u8 private_data_len);
504
Sean Heftyde98b692007-08-01 13:49:53 -0700505#define IB_CM_MRA_FLAG_DELAY 0x80 /* Send MRA only after a duplicate msg */
506
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700507/**
508 * ib_send_cm_mra - Sends a message receipt acknowledgement to a connection
509 * message.
510 * @cm_id: Connection identifier associated with the connection message.
Sean Heftyde98b692007-08-01 13:49:53 -0700511 * @service_timeout: The lower 5-bits specify the maximum time required for
Anand Gadiyarfd589a82009-07-16 17:13:03 +0200512 * the sender to reply to the connection message. The upper 3-bits
Sean Heftyde98b692007-08-01 13:49:53 -0700513 * specify additional control flags.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700514 * @private_data: Optional user-defined private data sent with the
515 * message receipt acknowledgement.
516 * @private_data_len: Size of the private data buffer, in bytes.
517 */
518int ib_send_cm_mra(struct ib_cm_id *cm_id,
519 u8 service_timeout,
520 const void *private_data,
521 u8 private_data_len);
522
523/**
524 * ib_send_cm_lap - Sends a load alternate path request.
525 * @cm_id: Connection identifier associated with the load alternate path
526 * message.
527 * @alternate_path: A path record that identifies the alternate path to
528 * load.
529 * @private_data: Optional user-defined private data sent with the
530 * load alternate path message.
531 * @private_data_len: Size of the private data buffer, in bytes.
532 */
533int ib_send_cm_lap(struct ib_cm_id *cm_id,
534 struct ib_sa_path_rec *alternate_path,
535 const void *private_data,
536 u8 private_data_len);
537
538/**
539 * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning
540 * to a specified QP state.
541 * @cm_id: Communication identifier associated with the QP attributes to
542 * initialize.
543 * @qp_attr: On input, specifies the desired QP state. On output, the
544 * mandatory and desired optional attributes will be set in order to
545 * modify the QP to the specified state.
546 * @qp_attr_mask: The QP attribute mask that may be used to transition the
547 * QP to the specified state.
548 *
549 * Users must set the @qp_attr->qp_state to the desired QP state. This call
550 * will set all required attributes for the given transition, along with
551 * known optional attributes. Users may override the attributes returned from
552 * this call before calling ib_modify_qp.
553 */
554int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
555 struct ib_qp_attr *qp_attr,
556 int *qp_attr_mask);
557
558/**
559 * ib_send_cm_apr - Sends an alternate path response message in response to
560 * a load alternate path request.
561 * @cm_id: Connection identifier associated with the alternate path response.
562 * @status: Reply status sent with the alternate path response.
563 * @info: Optional additional information sent with the alternate path
564 * response.
565 * @info_length: Size of the additional information, in bytes.
566 * @private_data: Optional user-defined private data sent with the
567 * alternate path response message.
568 * @private_data_len: Size of the private data buffer, in bytes.
569 */
570int ib_send_cm_apr(struct ib_cm_id *cm_id,
571 enum ib_cm_apr_status status,
572 void *info,
573 u8 info_length,
574 const void *private_data,
575 u8 private_data_len);
576
577struct ib_cm_sidr_req_param {
578 struct ib_sa_path_rec *path;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700579 __be64 service_id;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700580 int timeout_ms;
581 const void *private_data;
582 u8 private_data_len;
583 u8 max_cm_retries;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700584};
585
586/**
587 * ib_send_cm_sidr_req - Sends a service ID resolution request to the
588 * remote node.
589 * @cm_id: Communication identifier that will be associated with the
590 * service ID resolution request.
591 * @param: Service ID resolution request information.
592 */
593int ib_send_cm_sidr_req(struct ib_cm_id *cm_id,
594 struct ib_cm_sidr_req_param *param);
595
596struct ib_cm_sidr_rep_param {
597 u32 qp_num;
598 u32 qkey;
599 enum ib_cm_sidr_status status;
600 const void *info;
601 u8 info_length;
602 const void *private_data;
603 u8 private_data_len;
604};
605
606/**
Sean Hefty75af9082006-06-17 20:37:39 -0700607 * ib_send_cm_sidr_rep - Sends a service ID resolution reply to the
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700608 * remote node.
609 * @cm_id: Communication identifier associated with the received service ID
610 * resolution request.
611 * @param: Service ID resolution reply information.
612 */
613int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
614 struct ib_cm_sidr_rep_param *param);
615
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700616#endif /* IB_CM_H */