1219820Sjeff/* 2219820Sjeff * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved. 3219820Sjeff * Copyright (c) 2004 Topspin Corporation. All rights reserved. 4219820Sjeff * Copyright (c) 2004 Voltaire Corporation. All rights reserved. 5219820Sjeff * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 6219820Sjeff * 7219820Sjeff * This software is available to you under a choice of one of two 8219820Sjeff * licenses. You may choose to be licensed under the terms of the GNU 9219820Sjeff * General Public License (GPL) Version 2, available from the file 10219820Sjeff * COPYING in the main directory of this source tree, or the 11219820Sjeff * OpenIB.org BSD license below: 12219820Sjeff * 13219820Sjeff * Redistribution and use in source and binary forms, with or 14219820Sjeff * without modification, are permitted provided that the following 15219820Sjeff * conditions are met: 16219820Sjeff * 17219820Sjeff * - Redistributions of source code must retain the above 18219820Sjeff * copyright notice, this list of conditions and the following 19219820Sjeff * disclaimer. 20219820Sjeff * 21219820Sjeff * - Redistributions in binary form must reproduce the above 22219820Sjeff * copyright notice, this list of conditions and the following 23219820Sjeff * disclaimer in the documentation and/or other materials 24219820Sjeff * provided with the distribution. 25219820Sjeff * 26219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 27219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 28219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 29219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 30219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 31219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33219820Sjeff * SOFTWARE. 34219820Sjeff */ 35219820Sjeff#if !defined(IB_CM_H) 36219820Sjeff#define IB_CM_H 37219820Sjeff 38219820Sjeff#include <rdma/ib_mad.h> 39219820Sjeff#include <rdma/ib_sa.h> 40219820Sjeff 41255932Salfred/* ib_cm and ib_user_cm modules share /sys/class/infiniband_cm */ 42255932Salfredextern struct class cm_class; 43255932Salfred 44219820Sjeffenum ib_cm_state { 45219820Sjeff IB_CM_IDLE, 46219820Sjeff IB_CM_LISTEN, 47219820Sjeff IB_CM_REQ_SENT, 48219820Sjeff IB_CM_REQ_RCVD, 49219820Sjeff IB_CM_MRA_REQ_SENT, 50219820Sjeff IB_CM_MRA_REQ_RCVD, 51219820Sjeff IB_CM_REP_SENT, 52219820Sjeff IB_CM_REP_RCVD, 53219820Sjeff IB_CM_MRA_REP_SENT, 54219820Sjeff IB_CM_MRA_REP_RCVD, 55219820Sjeff IB_CM_ESTABLISHED, 56219820Sjeff IB_CM_DREQ_SENT, 57219820Sjeff IB_CM_DREQ_RCVD, 58219820Sjeff IB_CM_TIMEWAIT, 59219820Sjeff IB_CM_SIDR_REQ_SENT, 60219820Sjeff IB_CM_SIDR_REQ_RCVD 61219820Sjeff}; 62219820Sjeff 63219820Sjeffenum ib_cm_lap_state { 64219820Sjeff IB_CM_LAP_UNINIT, 65219820Sjeff IB_CM_LAP_IDLE, 66219820Sjeff IB_CM_LAP_SENT, 67219820Sjeff IB_CM_LAP_RCVD, 68219820Sjeff IB_CM_MRA_LAP_SENT, 69219820Sjeff IB_CM_MRA_LAP_RCVD, 70219820Sjeff}; 71219820Sjeff 72219820Sjeffenum ib_cm_event_type { 73219820Sjeff IB_CM_REQ_ERROR, 74219820Sjeff IB_CM_REQ_RECEIVED, 75219820Sjeff IB_CM_REP_ERROR, 76219820Sjeff IB_CM_REP_RECEIVED, 77219820Sjeff IB_CM_RTU_RECEIVED, 78219820Sjeff IB_CM_USER_ESTABLISHED, 79219820Sjeff IB_CM_DREQ_ERROR, 80219820Sjeff IB_CM_DREQ_RECEIVED, 81219820Sjeff IB_CM_DREP_RECEIVED, 82219820Sjeff IB_CM_TIMEWAIT_EXIT, 83219820Sjeff IB_CM_MRA_RECEIVED, 84219820Sjeff IB_CM_REJ_RECEIVED, 85219820Sjeff IB_CM_LAP_ERROR, 86219820Sjeff IB_CM_LAP_RECEIVED, 87219820Sjeff IB_CM_APR_RECEIVED, 88219820Sjeff IB_CM_SIDR_REQ_ERROR, 89219820Sjeff IB_CM_SIDR_REQ_RECEIVED, 90219820Sjeff IB_CM_SIDR_REP_RECEIVED 91219820Sjeff}; 92219820Sjeff 93219820Sjeffenum ib_cm_data_size { 94219820Sjeff IB_CM_REQ_PRIVATE_DATA_SIZE = 92, 95219820Sjeff IB_CM_MRA_PRIVATE_DATA_SIZE = 222, 96219820Sjeff IB_CM_REJ_PRIVATE_DATA_SIZE = 148, 97219820Sjeff IB_CM_REP_PRIVATE_DATA_SIZE = 196, 98219820Sjeff IB_CM_RTU_PRIVATE_DATA_SIZE = 224, 99219820Sjeff IB_CM_DREQ_PRIVATE_DATA_SIZE = 220, 100219820Sjeff IB_CM_DREP_PRIVATE_DATA_SIZE = 224, 101219820Sjeff IB_CM_REJ_ARI_LENGTH = 72, 102219820Sjeff IB_CM_LAP_PRIVATE_DATA_SIZE = 168, 103219820Sjeff IB_CM_APR_PRIVATE_DATA_SIZE = 148, 104219820Sjeff IB_CM_APR_INFO_LENGTH = 72, 105219820Sjeff IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216, 106219820Sjeff IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136, 107219820Sjeff IB_CM_SIDR_REP_INFO_LENGTH = 72, 108219820Sjeff IB_CM_COMPARE_SIZE = 64 109219820Sjeff}; 110219820Sjeff 111219820Sjeffstruct ib_cm_id; 112219820Sjeff 113219820Sjeffstruct ib_cm_req_event_param { 114219820Sjeff struct ib_cm_id *listen_id; 115219820Sjeff u8 port; 116219820Sjeff 117219820Sjeff struct ib_sa_path_rec *primary_path; 118219820Sjeff struct ib_sa_path_rec *alternate_path; 119219820Sjeff 120219820Sjeff __be64 remote_ca_guid; 121219820Sjeff u32 remote_qkey; 122219820Sjeff u32 remote_qpn; 123219820Sjeff enum ib_qp_type qp_type; 124219820Sjeff 125219820Sjeff u32 starting_psn; 126219820Sjeff u8 responder_resources; 127219820Sjeff u8 initiator_depth; 128219820Sjeff unsigned int local_cm_response_timeout:5; 129219820Sjeff unsigned int flow_control:1; 130219820Sjeff unsigned int remote_cm_response_timeout:5; 131219820Sjeff unsigned int retry_count:3; 132219820Sjeff unsigned int rnr_retry_count:3; 133219820Sjeff unsigned int srq:1; 134219820Sjeff}; 135219820Sjeff 136219820Sjeffstruct ib_cm_rep_event_param { 137219820Sjeff __be64 remote_ca_guid; 138219820Sjeff u32 remote_qkey; 139219820Sjeff u32 remote_qpn; 140219820Sjeff u32 starting_psn; 141219820Sjeff u8 responder_resources; 142219820Sjeff u8 initiator_depth; 143219820Sjeff unsigned int target_ack_delay:5; 144219820Sjeff unsigned int failover_accepted:2; 145219820Sjeff unsigned int flow_control:1; 146219820Sjeff unsigned int rnr_retry_count:3; 147219820Sjeff unsigned int srq:1; 148219820Sjeff}; 149219820Sjeff 150219820Sjeffenum ib_cm_rej_reason { 151219820Sjeff IB_CM_REJ_NO_QP = 1, 152219820Sjeff IB_CM_REJ_NO_EEC = 2, 153219820Sjeff IB_CM_REJ_NO_RESOURCES = 3, 154219820Sjeff IB_CM_REJ_TIMEOUT = 4, 155219820Sjeff IB_CM_REJ_UNSUPPORTED = 5, 156219820Sjeff IB_CM_REJ_INVALID_COMM_ID = 6, 157219820Sjeff IB_CM_REJ_INVALID_COMM_INSTANCE = 7, 158219820Sjeff IB_CM_REJ_INVALID_SERVICE_ID = 8, 159219820Sjeff IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9, 160219820Sjeff IB_CM_REJ_STALE_CONN = 10, 161219820Sjeff IB_CM_REJ_RDC_NOT_EXIST = 11, 162219820Sjeff IB_CM_REJ_INVALID_GID = 12, 163219820Sjeff IB_CM_REJ_INVALID_LID = 13, 164219820Sjeff IB_CM_REJ_INVALID_SL = 14, 165219820Sjeff IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15, 166219820Sjeff IB_CM_REJ_INVALID_HOP_LIMIT = 16, 167219820Sjeff IB_CM_REJ_INVALID_PACKET_RATE = 17, 168219820Sjeff IB_CM_REJ_INVALID_ALT_GID = 18, 169219820Sjeff IB_CM_REJ_INVALID_ALT_LID = 19, 170219820Sjeff IB_CM_REJ_INVALID_ALT_SL = 20, 171219820Sjeff IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21, 172219820Sjeff IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22, 173219820Sjeff IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23, 174219820Sjeff IB_CM_REJ_PORT_CM_REDIRECT = 24, 175219820Sjeff IB_CM_REJ_PORT_REDIRECT = 25, 176219820Sjeff IB_CM_REJ_INVALID_MTU = 26, 177219820Sjeff IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27, 178219820Sjeff IB_CM_REJ_CONSUMER_DEFINED = 28, 179219820Sjeff IB_CM_REJ_INVALID_RNR_RETRY = 29, 180219820Sjeff IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30, 181219820Sjeff IB_CM_REJ_INVALID_CLASS_VERSION = 31, 182219820Sjeff IB_CM_REJ_INVALID_FLOW_LABEL = 32, 183219820Sjeff IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33 184219820Sjeff}; 185219820Sjeff 186219820Sjeffstruct ib_cm_rej_event_param { 187219820Sjeff enum ib_cm_rej_reason reason; 188219820Sjeff void *ari; 189219820Sjeff u8 ari_length; 190219820Sjeff}; 191219820Sjeff 192219820Sjeffstruct ib_cm_mra_event_param { 193219820Sjeff u8 service_timeout; 194219820Sjeff}; 195219820Sjeff 196219820Sjeffstruct ib_cm_lap_event_param { 197219820Sjeff struct ib_sa_path_rec *alternate_path; 198219820Sjeff}; 199219820Sjeff 200219820Sjeffenum ib_cm_apr_status { 201219820Sjeff IB_CM_APR_SUCCESS, 202219820Sjeff IB_CM_APR_INVALID_COMM_ID, 203219820Sjeff IB_CM_APR_UNSUPPORTED, 204219820Sjeff IB_CM_APR_REJECT, 205219820Sjeff IB_CM_APR_REDIRECT, 206219820Sjeff IB_CM_APR_IS_CURRENT, 207219820Sjeff IB_CM_APR_INVALID_QPN_EECN, 208219820Sjeff IB_CM_APR_INVALID_LID, 209219820Sjeff IB_CM_APR_INVALID_GID, 210219820Sjeff IB_CM_APR_INVALID_FLOW_LABEL, 211219820Sjeff IB_CM_APR_INVALID_TCLASS, 212219820Sjeff IB_CM_APR_INVALID_HOP_LIMIT, 213219820Sjeff IB_CM_APR_INVALID_PACKET_RATE, 214219820Sjeff IB_CM_APR_INVALID_SL 215219820Sjeff}; 216219820Sjeff 217219820Sjeffstruct ib_cm_apr_event_param { 218219820Sjeff enum ib_cm_apr_status ap_status; 219219820Sjeff void *apr_info; 220219820Sjeff u8 info_len; 221219820Sjeff}; 222219820Sjeff 223219820Sjeffstruct ib_cm_sidr_req_event_param { 224219820Sjeff struct ib_cm_id *listen_id; 225219820Sjeff u8 port; 226219820Sjeff u16 pkey; 227219820Sjeff}; 228219820Sjeff 229219820Sjeffenum ib_cm_sidr_status { 230219820Sjeff IB_SIDR_SUCCESS, 231219820Sjeff IB_SIDR_UNSUPPORTED, 232219820Sjeff IB_SIDR_REJECT, 233219820Sjeff IB_SIDR_NO_QP, 234219820Sjeff IB_SIDR_REDIRECT, 235219820Sjeff IB_SIDR_UNSUPPORTED_VERSION 236219820Sjeff}; 237219820Sjeff 238219820Sjeffstruct ib_cm_sidr_rep_event_param { 239219820Sjeff enum ib_cm_sidr_status status; 240219820Sjeff u32 qkey; 241219820Sjeff u32 qpn; 242219820Sjeff void *info; 243219820Sjeff u8 info_len; 244219820Sjeff}; 245219820Sjeff 246219820Sjeffstruct ib_cm_event { 247219820Sjeff enum ib_cm_event_type event; 248219820Sjeff union { 249219820Sjeff struct ib_cm_req_event_param req_rcvd; 250219820Sjeff struct ib_cm_rep_event_param rep_rcvd; 251219820Sjeff /* No data for RTU received events. */ 252219820Sjeff struct ib_cm_rej_event_param rej_rcvd; 253219820Sjeff struct ib_cm_mra_event_param mra_rcvd; 254219820Sjeff struct ib_cm_lap_event_param lap_rcvd; 255219820Sjeff struct ib_cm_apr_event_param apr_rcvd; 256219820Sjeff /* No data for DREQ/DREP received events. */ 257219820Sjeff struct ib_cm_sidr_req_event_param sidr_req_rcvd; 258219820Sjeff struct ib_cm_sidr_rep_event_param sidr_rep_rcvd; 259219820Sjeff enum ib_wc_status send_status; 260219820Sjeff } param; 261219820Sjeff 262219820Sjeff void *private_data; 263219820Sjeff}; 264219820Sjeff 265255932Salfred#define CM_REQ_ATTR_ID cpu_to_be16(0x0010) 266255932Salfred#define CM_MRA_ATTR_ID cpu_to_be16(0x0011) 267255932Salfred#define CM_REJ_ATTR_ID cpu_to_be16(0x0012) 268255932Salfred#define CM_REP_ATTR_ID cpu_to_be16(0x0013) 269255932Salfred#define CM_RTU_ATTR_ID cpu_to_be16(0x0014) 270255932Salfred#define CM_DREQ_ATTR_ID cpu_to_be16(0x0015) 271255932Salfred#define CM_DREP_ATTR_ID cpu_to_be16(0x0016) 272255932Salfred#define CM_SIDR_REQ_ATTR_ID cpu_to_be16(0x0017) 273255932Salfred#define CM_SIDR_REP_ATTR_ID cpu_to_be16(0x0018) 274255932Salfred#define CM_LAP_ATTR_ID cpu_to_be16(0x0019) 275255932Salfred#define CM_APR_ATTR_ID cpu_to_be16(0x001A) 276255932Salfred 277219820Sjeff/** 278219820Sjeff * ib_cm_handler - User-defined callback to process communication events. 279219820Sjeff * @cm_id: Communication identifier associated with the reported event. 280219820Sjeff * @event: Information about the communication event. 281219820Sjeff * 282219820Sjeff * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events 283219820Sjeff * generated as a result of listen requests result in the allocation of a 284219820Sjeff * new @cm_id. The new @cm_id is returned to the user through this callback. 285219820Sjeff * Clients are responsible for destroying the new @cm_id. For peer-to-peer 286219820Sjeff * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds 287219820Sjeff * to a user's existing communication identifier. 288219820Sjeff * 289219820Sjeff * Users may not call ib_destroy_cm_id while in the context of this callback; 290219820Sjeff * however, returning a non-zero value instructs the communication manager to 291219820Sjeff * destroy the @cm_id after the callback completes. 292219820Sjeff */ 293219820Sjefftypedef int (*ib_cm_handler)(struct ib_cm_id *cm_id, 294219820Sjeff struct ib_cm_event *event); 295219820Sjeff 296219820Sjeffstruct ib_cm_id { 297219820Sjeff ib_cm_handler cm_handler; 298219820Sjeff void *context; 299219820Sjeff struct ib_device *device; 300219820Sjeff __be64 service_id; 301219820Sjeff __be64 service_mask; 302219820Sjeff enum ib_cm_state state; /* internal CM/debug use */ 303219820Sjeff enum ib_cm_lap_state lap_state; /* internal CM/debug use */ 304219820Sjeff __be32 local_id; 305219820Sjeff __be32 remote_id; 306219820Sjeff u32 remote_cm_qpn; /* 1 unless redirected */ 307219820Sjeff}; 308219820Sjeff 309219820Sjeff/** 310219820Sjeff * ib_create_cm_id - Allocate a communication identifier. 311219820Sjeff * @device: Device associated with the cm_id. All related communication will 312219820Sjeff * be associated with the specified device. 313219820Sjeff * @cm_handler: Callback invoked to notify the user of CM events. 314219820Sjeff * @context: User specified context associated with the communication 315219820Sjeff * identifier. 316219820Sjeff * 317219820Sjeff * Communication identifiers are used to track connection states, service 318219820Sjeff * ID resolution requests, and listen requests. 319219820Sjeff */ 320219820Sjeffstruct ib_cm_id *ib_create_cm_id(struct ib_device *device, 321219820Sjeff ib_cm_handler cm_handler, 322219820Sjeff void *context); 323219820Sjeff 324219820Sjeff/** 325219820Sjeff * ib_destroy_cm_id - Destroy a connection identifier. 326219820Sjeff * @cm_id: Connection identifier to destroy. 327219820Sjeff * 328219820Sjeff * This call blocks until the connection identifier is destroyed. 329219820Sjeff */ 330219820Sjeffvoid ib_destroy_cm_id(struct ib_cm_id *cm_id); 331219820Sjeff 332219820Sjeff#define IB_SERVICE_ID_AGN_MASK cpu_to_be64(0xFF00000000000000ULL) 333219820Sjeff#define IB_CM_ASSIGN_SERVICE_ID cpu_to_be64(0x0200000000000000ULL) 334219820Sjeff#define IB_CMA_SERVICE_ID cpu_to_be64(0x0000000001000000ULL) 335219820Sjeff#define IB_CMA_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFF000000ULL) 336219820Sjeff#define IB_SDP_SERVICE_ID cpu_to_be64(0x0000000000010000ULL) 337219820Sjeff#define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL) 338219820Sjeff 339219820Sjeffstruct ib_cm_compare_data { 340219820Sjeff u8 data[IB_CM_COMPARE_SIZE]; 341219820Sjeff u8 mask[IB_CM_COMPARE_SIZE]; 342219820Sjeff}; 343219820Sjeff 344219820Sjeff/** 345219820Sjeff * ib_cm_listen - Initiates listening on the specified service ID for 346219820Sjeff * connection and service ID resolution requests. 347219820Sjeff * @cm_id: Connection identifier associated with the listen request. 348219820Sjeff * @service_id: Service identifier matched against incoming connection 349219820Sjeff * and service ID resolution requests. The service ID should be specified 350219820Sjeff * network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will 351219820Sjeff * assign a service ID to the caller. 352219820Sjeff * @service_mask: Mask applied to service ID used to listen across a 353219820Sjeff * range of service IDs. If set to 0, the service ID is matched 354219820Sjeff * exactly. This parameter is ignored if %service_id is set to 355219820Sjeff * IB_CM_ASSIGN_SERVICE_ID. 356219820Sjeff * @compare_data: This parameter is optional. It specifies data that must 357219820Sjeff * appear in the private data of a connection request for the specified 358219820Sjeff * listen request. 359219820Sjeff */ 360219820Sjeffint ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask, 361219820Sjeff struct ib_cm_compare_data *compare_data); 362219820Sjeff 363219820Sjeffstruct ib_cm_req_param { 364219820Sjeff struct ib_sa_path_rec *primary_path; 365219820Sjeff struct ib_sa_path_rec *alternate_path; 366219820Sjeff __be64 service_id; 367219820Sjeff u32 qp_num; 368219820Sjeff enum ib_qp_type qp_type; 369219820Sjeff u32 starting_psn; 370219820Sjeff const void *private_data; 371219820Sjeff u8 private_data_len; 372219820Sjeff u8 peer_to_peer; 373219820Sjeff u8 responder_resources; 374219820Sjeff u8 initiator_depth; 375219820Sjeff u8 remote_cm_response_timeout; 376219820Sjeff u8 flow_control; 377219820Sjeff u8 local_cm_response_timeout; 378219820Sjeff u8 retry_count; 379219820Sjeff u8 rnr_retry_count; 380219820Sjeff u8 max_cm_retries; 381219820Sjeff u8 srq; 382219820Sjeff}; 383219820Sjeff 384219820Sjeff/** 385219820Sjeff * ib_send_cm_req - Sends a connection request to the remote node. 386219820Sjeff * @cm_id: Connection identifier that will be associated with the 387219820Sjeff * connection request. 388219820Sjeff * @param: Connection request information needed to establish the 389219820Sjeff * connection. 390219820Sjeff */ 391219820Sjeffint ib_send_cm_req(struct ib_cm_id *cm_id, 392219820Sjeff struct ib_cm_req_param *param); 393219820Sjeff 394219820Sjeffstruct ib_cm_rep_param { 395219820Sjeff u32 qp_num; 396219820Sjeff u32 starting_psn; 397219820Sjeff const void *private_data; 398219820Sjeff u8 private_data_len; 399219820Sjeff u8 responder_resources; 400219820Sjeff u8 initiator_depth; 401219820Sjeff u8 failover_accepted; 402219820Sjeff u8 flow_control; 403219820Sjeff u8 rnr_retry_count; 404219820Sjeff u8 srq; 405219820Sjeff}; 406219820Sjeff 407219820Sjeff/** 408219820Sjeff * ib_send_cm_rep - Sends a connection reply in response to a connection 409219820Sjeff * request. 410219820Sjeff * @cm_id: Connection identifier that will be associated with the 411219820Sjeff * connection request. 412219820Sjeff * @param: Connection reply information needed to establish the 413219820Sjeff * connection. 414219820Sjeff */ 415219820Sjeffint ib_send_cm_rep(struct ib_cm_id *cm_id, 416219820Sjeff struct ib_cm_rep_param *param); 417219820Sjeff 418219820Sjeff/** 419219820Sjeff * ib_send_cm_rtu - Sends a connection ready to use message in response 420219820Sjeff * to a connection reply message. 421219820Sjeff * @cm_id: Connection identifier associated with the connection request. 422219820Sjeff * @private_data: Optional user-defined private data sent with the 423219820Sjeff * ready to use message. 424219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 425219820Sjeff */ 426219820Sjeffint ib_send_cm_rtu(struct ib_cm_id *cm_id, 427219820Sjeff const void *private_data, 428219820Sjeff u8 private_data_len); 429219820Sjeff 430219820Sjeff/** 431219820Sjeff * ib_send_cm_dreq - Sends a disconnection request for an existing 432219820Sjeff * connection. 433219820Sjeff * @cm_id: Connection identifier associated with the connection being 434219820Sjeff * released. 435219820Sjeff * @private_data: Optional user-defined private data sent with the 436219820Sjeff * disconnection request message. 437219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 438219820Sjeff */ 439219820Sjeffint ib_send_cm_dreq(struct ib_cm_id *cm_id, 440219820Sjeff const void *private_data, 441219820Sjeff u8 private_data_len); 442219820Sjeff 443219820Sjeff/** 444219820Sjeff * ib_send_cm_drep - Sends a disconnection reply to a disconnection request. 445219820Sjeff * @cm_id: Connection identifier associated with the connection being 446219820Sjeff * released. 447219820Sjeff * @private_data: Optional user-defined private data sent with the 448219820Sjeff * disconnection reply message. 449219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 450219820Sjeff * 451219820Sjeff * If the cm_id is in the correct state, the CM will transition the connection 452219820Sjeff * to the timewait state, even if an error occurs sending the DREP message. 453219820Sjeff */ 454219820Sjeffint ib_send_cm_drep(struct ib_cm_id *cm_id, 455219820Sjeff const void *private_data, 456219820Sjeff u8 private_data_len); 457219820Sjeff 458219820Sjeff/** 459219820Sjeff * ib_cm_notify - Notifies the CM of an event reported to the consumer. 460219820Sjeff * @cm_id: Connection identifier to transition to established. 461219820Sjeff * @event: Type of event. 462219820Sjeff * 463219820Sjeff * This routine should be invoked by users to notify the CM of relevant 464219820Sjeff * communication events. Events that should be reported to the CM and 465219820Sjeff * when to report them are: 466219820Sjeff * 467219820Sjeff * IB_EVENT_COMM_EST - Used when a message is received on a connected 468219820Sjeff * QP before an RTU has been received. 469219820Sjeff * IB_EVENT_PATH_MIG - Notifies the CM that the connection has failed over 470219820Sjeff * to the alternate path. 471219820Sjeff */ 472219820Sjeffint ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event); 473219820Sjeff 474219820Sjeff/** 475219820Sjeff * ib_send_cm_rej - Sends a connection rejection message to the 476219820Sjeff * remote node. 477219820Sjeff * @cm_id: Connection identifier associated with the connection being 478219820Sjeff * rejected. 479219820Sjeff * @reason: Reason for the connection request rejection. 480219820Sjeff * @ari: Optional additional rejection information. 481219820Sjeff * @ari_length: Size of the additional rejection information, in bytes. 482219820Sjeff * @private_data: Optional user-defined private data sent with the 483219820Sjeff * rejection message. 484219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 485219820Sjeff */ 486219820Sjeffint ib_send_cm_rej(struct ib_cm_id *cm_id, 487219820Sjeff enum ib_cm_rej_reason reason, 488219820Sjeff void *ari, 489219820Sjeff u8 ari_length, 490219820Sjeff const void *private_data, 491219820Sjeff u8 private_data_len); 492219820Sjeff 493219820Sjeff#define IB_CM_MRA_FLAG_DELAY 0x80 /* Send MRA only after a duplicate msg */ 494219820Sjeff 495219820Sjeff/** 496219820Sjeff * ib_send_cm_mra - Sends a message receipt acknowledgement to a connection 497219820Sjeff * message. 498219820Sjeff * @cm_id: Connection identifier associated with the connection message. 499219820Sjeff * @service_timeout: The lower 5-bits specify the maximum time required for 500219820Sjeff * the sender to reply to to the connection message. The upper 3-bits 501219820Sjeff * specify additional control flags. 502219820Sjeff * @private_data: Optional user-defined private data sent with the 503219820Sjeff * message receipt acknowledgement. 504219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 505219820Sjeff */ 506219820Sjeffint ib_send_cm_mra(struct ib_cm_id *cm_id, 507219820Sjeff u8 service_timeout, 508219820Sjeff const void *private_data, 509219820Sjeff u8 private_data_len); 510219820Sjeff 511219820Sjeff/** 512219820Sjeff * ib_send_cm_lap - Sends a load alternate path request. 513219820Sjeff * @cm_id: Connection identifier associated with the load alternate path 514219820Sjeff * message. 515219820Sjeff * @alternate_path: A path record that identifies the alternate path to 516219820Sjeff * load. 517219820Sjeff * @private_data: Optional user-defined private data sent with the 518219820Sjeff * load alternate path message. 519219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 520219820Sjeff */ 521219820Sjeffint ib_send_cm_lap(struct ib_cm_id *cm_id, 522219820Sjeff struct ib_sa_path_rec *alternate_path, 523219820Sjeff const void *private_data, 524219820Sjeff u8 private_data_len); 525219820Sjeff 526219820Sjeff/** 527219820Sjeff * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning 528219820Sjeff * to a specified QP state. 529219820Sjeff * @cm_id: Communication identifier associated with the QP attributes to 530219820Sjeff * initialize. 531219820Sjeff * @qp_attr: On input, specifies the desired QP state. On output, the 532219820Sjeff * mandatory and desired optional attributes will be set in order to 533219820Sjeff * modify the QP to the specified state. 534219820Sjeff * @qp_attr_mask: The QP attribute mask that may be used to transition the 535219820Sjeff * QP to the specified state. 536219820Sjeff * 537219820Sjeff * Users must set the @qp_attr->qp_state to the desired QP state. This call 538219820Sjeff * will set all required attributes for the given transition, along with 539219820Sjeff * known optional attributes. Users may override the attributes returned from 540219820Sjeff * this call before calling ib_modify_qp. 541219820Sjeff */ 542219820Sjeffint ib_cm_init_qp_attr(struct ib_cm_id *cm_id, 543219820Sjeff struct ib_qp_attr *qp_attr, 544219820Sjeff int *qp_attr_mask); 545219820Sjeff 546219820Sjeff/** 547219820Sjeff * ib_send_cm_apr - Sends an alternate path response message in response to 548219820Sjeff * a load alternate path request. 549219820Sjeff * @cm_id: Connection identifier associated with the alternate path response. 550219820Sjeff * @status: Reply status sent with the alternate path response. 551219820Sjeff * @info: Optional additional information sent with the alternate path 552219820Sjeff * response. 553219820Sjeff * @info_length: Size of the additional information, in bytes. 554219820Sjeff * @private_data: Optional user-defined private data sent with the 555219820Sjeff * alternate path response message. 556219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 557219820Sjeff */ 558219820Sjeffint ib_send_cm_apr(struct ib_cm_id *cm_id, 559219820Sjeff enum ib_cm_apr_status status, 560219820Sjeff void *info, 561219820Sjeff u8 info_length, 562219820Sjeff const void *private_data, 563219820Sjeff u8 private_data_len); 564219820Sjeff 565219820Sjeffstruct ib_cm_sidr_req_param { 566219820Sjeff struct ib_sa_path_rec *path; 567219820Sjeff __be64 service_id; 568219820Sjeff int timeout_ms; 569219820Sjeff const void *private_data; 570219820Sjeff u8 private_data_len; 571219820Sjeff u8 max_cm_retries; 572219820Sjeff}; 573219820Sjeff 574219820Sjeff/** 575219820Sjeff * ib_send_cm_sidr_req - Sends a service ID resolution request to the 576219820Sjeff * remote node. 577219820Sjeff * @cm_id: Communication identifier that will be associated with the 578219820Sjeff * service ID resolution request. 579219820Sjeff * @param: Service ID resolution request information. 580219820Sjeff */ 581219820Sjeffint ib_send_cm_sidr_req(struct ib_cm_id *cm_id, 582219820Sjeff struct ib_cm_sidr_req_param *param); 583219820Sjeff 584219820Sjeffstruct ib_cm_sidr_rep_param { 585219820Sjeff u32 qp_num; 586219820Sjeff u32 qkey; 587219820Sjeff enum ib_cm_sidr_status status; 588219820Sjeff const void *info; 589219820Sjeff u8 info_length; 590219820Sjeff const void *private_data; 591219820Sjeff u8 private_data_len; 592219820Sjeff}; 593219820Sjeff 594219820Sjeff/** 595219820Sjeff * ib_send_cm_sidr_rep - Sends a service ID resolution reply to the 596219820Sjeff * remote node. 597219820Sjeff * @cm_id: Communication identifier associated with the received service ID 598219820Sjeff * resolution request. 599219820Sjeff * @param: Service ID resolution reply information. 600219820Sjeff */ 601219820Sjeffint ib_send_cm_sidr_rep(struct ib_cm_id *cm_id, 602219820Sjeff struct ib_cm_sidr_rep_param *param); 603219820Sjeff 604219820Sjeff#endif /* IB_CM_H */ 605