2 * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
3 * 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.
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:
13 * Redistribution and use in source and binary forms, with or
14 * without modification, are permitted provided that the following
17 * - Redistributions of source code must retain the above
18 * copyright notice, this list of conditions and the following
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.
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
35 * $Id: ib_cm.h 4311 2005-12-05 18:42:01Z sean.hefty $
40 #include <rdma/ib_mad.h>
41 #include <rdma/ib_sa.h>
62 enum ib_cm_lap_state
{
70 enum ib_cm_event_type
{
76 IB_CM_USER_ESTABLISHED
,
87 IB_CM_SIDR_REQ_RECEIVED
,
88 IB_CM_SIDR_REP_RECEIVED
91 enum ib_cm_data_size
{
92 IB_CM_REQ_PRIVATE_DATA_SIZE
= 92,
93 IB_CM_MRA_PRIVATE_DATA_SIZE
= 222,
94 IB_CM_REJ_PRIVATE_DATA_SIZE
= 148,
95 IB_CM_REP_PRIVATE_DATA_SIZE
= 196,
96 IB_CM_RTU_PRIVATE_DATA_SIZE
= 224,
97 IB_CM_DREQ_PRIVATE_DATA_SIZE
= 220,
98 IB_CM_DREP_PRIVATE_DATA_SIZE
= 224,
99 IB_CM_REJ_ARI_LENGTH
= 72,
100 IB_CM_LAP_PRIVATE_DATA_SIZE
= 168,
101 IB_CM_APR_PRIVATE_DATA_SIZE
= 148,
102 IB_CM_APR_INFO_LENGTH
= 72,
103 IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE
= 216,
104 IB_CM_SIDR_REP_PRIVATE_DATA_SIZE
= 136,
105 IB_CM_SIDR_REP_INFO_LENGTH
= 72,
106 IB_CM_COMPARE_SIZE
= 64
111 struct ib_cm_req_event_param
{
112 struct ib_cm_id
*listen_id
;
115 struct ib_sa_path_rec
*primary_path
;
116 struct ib_sa_path_rec
*alternate_path
;
118 __be64 remote_ca_guid
;
121 enum ib_qp_type qp_type
;
124 u8 responder_resources
;
126 unsigned int local_cm_response_timeout
:5;
127 unsigned int flow_control
:1;
128 unsigned int remote_cm_response_timeout
:5;
129 unsigned int retry_count
:3;
130 unsigned int rnr_retry_count
:3;
134 struct ib_cm_rep_event_param
{
135 __be64 remote_ca_guid
;
139 u8 responder_resources
;
141 unsigned int target_ack_delay
:5;
142 unsigned int failover_accepted
:2;
143 unsigned int flow_control
:1;
144 unsigned int rnr_retry_count
:3;
148 enum ib_cm_rej_reason
{
150 IB_CM_REJ_NO_EEC
= 2,
151 IB_CM_REJ_NO_RESOURCES
= 3,
152 IB_CM_REJ_TIMEOUT
= 4,
153 IB_CM_REJ_UNSUPPORTED
= 5,
154 IB_CM_REJ_INVALID_COMM_ID
= 6,
155 IB_CM_REJ_INVALID_COMM_INSTANCE
= 7,
156 IB_CM_REJ_INVALID_SERVICE_ID
= 8,
157 IB_CM_REJ_INVALID_TRANSPORT_TYPE
= 9,
158 IB_CM_REJ_STALE_CONN
= 10,
159 IB_CM_REJ_RDC_NOT_EXIST
= 11,
160 IB_CM_REJ_INVALID_GID
= 12,
161 IB_CM_REJ_INVALID_LID
= 13,
162 IB_CM_REJ_INVALID_SL
= 14,
163 IB_CM_REJ_INVALID_TRAFFIC_CLASS
= 15,
164 IB_CM_REJ_INVALID_HOP_LIMIT
= 16,
165 IB_CM_REJ_INVALID_PACKET_RATE
= 17,
166 IB_CM_REJ_INVALID_ALT_GID
= 18,
167 IB_CM_REJ_INVALID_ALT_LID
= 19,
168 IB_CM_REJ_INVALID_ALT_SL
= 20,
169 IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS
= 21,
170 IB_CM_REJ_INVALID_ALT_HOP_LIMIT
= 22,
171 IB_CM_REJ_INVALID_ALT_PACKET_RATE
= 23,
172 IB_CM_REJ_PORT_CM_REDIRECT
= 24,
173 IB_CM_REJ_PORT_REDIRECT
= 25,
174 IB_CM_REJ_INVALID_MTU
= 26,
175 IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES
= 27,
176 IB_CM_REJ_CONSUMER_DEFINED
= 28,
177 IB_CM_REJ_INVALID_RNR_RETRY
= 29,
178 IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID
= 30,
179 IB_CM_REJ_INVALID_CLASS_VERSION
= 31,
180 IB_CM_REJ_INVALID_FLOW_LABEL
= 32,
181 IB_CM_REJ_INVALID_ALT_FLOW_LABEL
= 33
184 struct ib_cm_rej_event_param
{
185 enum ib_cm_rej_reason reason
;
190 struct ib_cm_mra_event_param
{
194 struct ib_cm_lap_event_param
{
195 struct ib_sa_path_rec
*alternate_path
;
198 enum ib_cm_apr_status
{
200 IB_CM_APR_INVALID_COMM_ID
,
201 IB_CM_APR_UNSUPPORTED
,
204 IB_CM_APR_IS_CURRENT
,
205 IB_CM_APR_INVALID_QPN_EECN
,
206 IB_CM_APR_INVALID_LID
,
207 IB_CM_APR_INVALID_GID
,
208 IB_CM_APR_INVALID_FLOW_LABEL
,
209 IB_CM_APR_INVALID_TCLASS
,
210 IB_CM_APR_INVALID_HOP_LIMIT
,
211 IB_CM_APR_INVALID_PACKET_RATE
,
215 struct ib_cm_apr_event_param
{
216 enum ib_cm_apr_status ap_status
;
221 struct ib_cm_sidr_req_event_param
{
222 struct ib_cm_id
*listen_id
;
227 enum ib_cm_sidr_status
{
233 IB_SIDR_UNSUPPORTED_VERSION
236 struct ib_cm_sidr_rep_event_param
{
237 enum ib_cm_sidr_status status
;
245 enum ib_cm_event_type event
;
247 struct ib_cm_req_event_param req_rcvd
;
248 struct ib_cm_rep_event_param rep_rcvd
;
249 /* No data for RTU received events. */
250 struct ib_cm_rej_event_param rej_rcvd
;
251 struct ib_cm_mra_event_param mra_rcvd
;
252 struct ib_cm_lap_event_param lap_rcvd
;
253 struct ib_cm_apr_event_param apr_rcvd
;
254 /* No data for DREQ/DREP received events. */
255 struct ib_cm_sidr_req_event_param sidr_req_rcvd
;
256 struct ib_cm_sidr_rep_event_param sidr_rep_rcvd
;
257 enum ib_wc_status send_status
;
264 * ib_cm_handler - User-defined callback to process communication events.
265 * @cm_id: Communication identifier associated with the reported event.
266 * @event: Information about the communication event.
268 * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events
269 * generated as a result of listen requests result in the allocation of a
270 * new @cm_id. The new @cm_id is returned to the user through this callback.
271 * Clients are responsible for destroying the new @cm_id. For peer-to-peer
272 * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds
273 * to a user's existing communication identifier.
275 * Users may not call ib_destroy_cm_id while in the context of this callback;
276 * however, returning a non-zero value instructs the communication manager to
277 * destroy the @cm_id after the callback completes.
279 typedef int (*ib_cm_handler
)(struct ib_cm_id
*cm_id
,
280 struct ib_cm_event
*event
);
283 ib_cm_handler cm_handler
;
285 struct ib_device
*device
;
288 enum ib_cm_state state
; /* internal CM/debug use */
289 enum ib_cm_lap_state lap_state
; /* internal CM/debug use */
292 u32 remote_cm_qpn
; /* 1 unless redirected */
296 * ib_create_cm_id - Allocate a communication identifier.
297 * @device: Device associated with the cm_id. All related communication will
298 * be associated with the specified device.
299 * @cm_handler: Callback invoked to notify the user of CM events.
300 * @context: User specified context associated with the communication
303 * Communication identifiers are used to track connection states, service
304 * ID resolution requests, and listen requests.
306 struct ib_cm_id
*ib_create_cm_id(struct ib_device
*device
,
307 ib_cm_handler cm_handler
,
311 * ib_destroy_cm_id - Destroy a connection identifier.
312 * @cm_id: Connection identifier to destroy.
314 * This call blocks until the connection identifier is destroyed.
316 void ib_destroy_cm_id(struct ib_cm_id
*cm_id
);
318 #define IB_SERVICE_ID_AGN_MASK __constant_cpu_to_be64(0xFF00000000000000ULL)
319 #define IB_CM_ASSIGN_SERVICE_ID __constant_cpu_to_be64(0x0200000000000000ULL)
320 #define IB_CMA_SERVICE_ID __constant_cpu_to_be64(0x0000000001000000ULL)
321 #define IB_CMA_SERVICE_ID_MASK __constant_cpu_to_be64(0xFFFFFFFFFF000000ULL)
322 #define IB_SDP_SERVICE_ID __constant_cpu_to_be64(0x0000000000010000ULL)
323 #define IB_SDP_SERVICE_ID_MASK __constant_cpu_to_be64(0xFFFFFFFFFFFF0000ULL)
325 struct ib_cm_compare_data
{
326 u8 data
[IB_CM_COMPARE_SIZE
];
327 u8 mask
[IB_CM_COMPARE_SIZE
];
331 * ib_cm_listen - Initiates listening on the specified service ID for
332 * connection and service ID resolution requests.
333 * @cm_id: Connection identifier associated with the listen request.
334 * @service_id: Service identifier matched against incoming connection
335 * and service ID resolution requests. The service ID should be specified
336 * network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will
337 * assign a service ID to the caller.
338 * @service_mask: Mask applied to service ID used to listen across a
339 * range of service IDs. If set to 0, the service ID is matched
340 * exactly. This parameter is ignored if %service_id is set to
341 * IB_CM_ASSIGN_SERVICE_ID.
342 * @compare_data: This parameter is optional. It specifies data that must
343 * appear in the private data of a connection request for the specified
346 int ib_cm_listen(struct ib_cm_id
*cm_id
, __be64 service_id
, __be64 service_mask
,
347 struct ib_cm_compare_data
*compare_data
);
349 struct ib_cm_req_param
{
350 struct ib_sa_path_rec
*primary_path
;
351 struct ib_sa_path_rec
*alternate_path
;
354 enum ib_qp_type qp_type
;
356 const void *private_data
;
359 u8 responder_resources
;
361 u8 remote_cm_response_timeout
;
363 u8 local_cm_response_timeout
;
371 * ib_send_cm_req - Sends a connection request to the remote node.
372 * @cm_id: Connection identifier that will be associated with the
373 * connection request.
374 * @param: Connection request information needed to establish the
377 int ib_send_cm_req(struct ib_cm_id
*cm_id
,
378 struct ib_cm_req_param
*param
);
380 struct ib_cm_rep_param
{
383 const void *private_data
;
385 u8 responder_resources
;
388 u8 failover_accepted
;
395 * ib_send_cm_rep - Sends a connection reply in response to a connection
397 * @cm_id: Connection identifier that will be associated with the
398 * connection request.
399 * @param: Connection reply information needed to establish the
402 int ib_send_cm_rep(struct ib_cm_id
*cm_id
,
403 struct ib_cm_rep_param
*param
);
406 * ib_send_cm_rtu - Sends a connection ready to use message in response
407 * to a connection reply message.
408 * @cm_id: Connection identifier associated with the connection request.
409 * @private_data: Optional user-defined private data sent with the
410 * ready to use message.
411 * @private_data_len: Size of the private data buffer, in bytes.
413 int ib_send_cm_rtu(struct ib_cm_id
*cm_id
,
414 const void *private_data
,
415 u8 private_data_len
);
418 * ib_send_cm_dreq - Sends a disconnection request for an existing
420 * @cm_id: Connection identifier associated with the connection being
422 * @private_data: Optional user-defined private data sent with the
423 * disconnection request message.
424 * @private_data_len: Size of the private data buffer, in bytes.
426 int ib_send_cm_dreq(struct ib_cm_id
*cm_id
,
427 const void *private_data
,
428 u8 private_data_len
);
431 * ib_send_cm_drep - Sends a disconnection reply to a disconnection request.
432 * @cm_id: Connection identifier associated with the connection being
434 * @private_data: Optional user-defined private data sent with the
435 * disconnection reply message.
436 * @private_data_len: Size of the private data buffer, in bytes.
438 * If the cm_id is in the correct state, the CM will transition the connection
439 * to the timewait state, even if an error occurs sending the DREP message.
441 int ib_send_cm_drep(struct ib_cm_id
*cm_id
,
442 const void *private_data
,
443 u8 private_data_len
);
446 * ib_cm_establish - Forces a connection state to established.
447 * @cm_id: Connection identifier to transition to established.
449 * This routine should be invoked by users who receive messages on a
450 * connected QP before an RTU has been received.
452 int ib_cm_establish(struct ib_cm_id
*cm_id
);
455 * ib_send_cm_rej - Sends a connection rejection message to the
457 * @cm_id: Connection identifier associated with the connection being
459 * @reason: Reason for the connection request rejection.
460 * @ari: Optional additional rejection information.
461 * @ari_length: Size of the additional rejection information, in bytes.
462 * @private_data: Optional user-defined private data sent with the
464 * @private_data_len: Size of the private data buffer, in bytes.
466 int ib_send_cm_rej(struct ib_cm_id
*cm_id
,
467 enum ib_cm_rej_reason reason
,
470 const void *private_data
,
471 u8 private_data_len
);
474 * ib_send_cm_mra - Sends a message receipt acknowledgement to a connection
476 * @cm_id: Connection identifier associated with the connection message.
477 * @service_timeout: The maximum time required for the sender to reply to
478 * to the connection message.
479 * @private_data: Optional user-defined private data sent with the
480 * message receipt acknowledgement.
481 * @private_data_len: Size of the private data buffer, in bytes.
483 int ib_send_cm_mra(struct ib_cm_id
*cm_id
,
485 const void *private_data
,
486 u8 private_data_len
);
489 * ib_send_cm_lap - Sends a load alternate path request.
490 * @cm_id: Connection identifier associated with the load alternate path
492 * @alternate_path: A path record that identifies the alternate path to
494 * @private_data: Optional user-defined private data sent with the
495 * load alternate path message.
496 * @private_data_len: Size of the private data buffer, in bytes.
498 int ib_send_cm_lap(struct ib_cm_id
*cm_id
,
499 struct ib_sa_path_rec
*alternate_path
,
500 const void *private_data
,
501 u8 private_data_len
);
504 * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning
505 * to a specified QP state.
506 * @cm_id: Communication identifier associated with the QP attributes to
508 * @qp_attr: On input, specifies the desired QP state. On output, the
509 * mandatory and desired optional attributes will be set in order to
510 * modify the QP to the specified state.
511 * @qp_attr_mask: The QP attribute mask that may be used to transition the
512 * QP to the specified state.
514 * Users must set the @qp_attr->qp_state to the desired QP state. This call
515 * will set all required attributes for the given transition, along with
516 * known optional attributes. Users may override the attributes returned from
517 * this call before calling ib_modify_qp.
519 int ib_cm_init_qp_attr(struct ib_cm_id
*cm_id
,
520 struct ib_qp_attr
*qp_attr
,
524 * ib_send_cm_apr - Sends an alternate path response message in response to
525 * a load alternate path request.
526 * @cm_id: Connection identifier associated with the alternate path response.
527 * @status: Reply status sent with the alternate path response.
528 * @info: Optional additional information sent with the alternate path
530 * @info_length: Size of the additional information, in bytes.
531 * @private_data: Optional user-defined private data sent with the
532 * alternate path response message.
533 * @private_data_len: Size of the private data buffer, in bytes.
535 int ib_send_cm_apr(struct ib_cm_id
*cm_id
,
536 enum ib_cm_apr_status status
,
539 const void *private_data
,
540 u8 private_data_len
);
542 struct ib_cm_sidr_req_param
{
543 struct ib_sa_path_rec
*path
;
546 const void *private_data
;
552 * ib_send_cm_sidr_req - Sends a service ID resolution request to the
554 * @cm_id: Communication identifier that will be associated with the
555 * service ID resolution request.
556 * @param: Service ID resolution request information.
558 int ib_send_cm_sidr_req(struct ib_cm_id
*cm_id
,
559 struct ib_cm_sidr_req_param
*param
);
561 struct ib_cm_sidr_rep_param
{
564 enum ib_cm_sidr_status status
;
567 const void *private_data
;
572 * ib_send_cm_sidr_rep - Sends a service ID resolution reply to the
574 * @cm_id: Communication identifier associated with the received service ID
575 * resolution request.
576 * @param: Service ID resolution reply information.
578 int ib_send_cm_sidr_rep(struct ib_cm_id
*cm_id
,
579 struct ib_cm_sidr_rep_param
*param
);