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. 34331772Shselasky * 35331772Shselasky * $FreeBSD: stable/11/sys/ofed/include/rdma/ib_cm.h 338557 2018-09-10 08:19:38Z hselasky $ 36219820Sjeff */ 37331772Shselasky 38219820Sjeff#if !defined(IB_CM_H) 39219820Sjeff#define IB_CM_H 40219820Sjeff 41219820Sjeff#include <rdma/ib_mad.h> 42219820Sjeff#include <rdma/ib_sa.h> 43219820Sjeff 44255932Salfred/* ib_cm and ib_user_cm modules share /sys/class/infiniband_cm */ 45255932Salfredextern struct class cm_class; 46255932Salfred 47219820Sjeffenum ib_cm_state { 48219820Sjeff IB_CM_IDLE, 49219820Sjeff IB_CM_LISTEN, 50219820Sjeff IB_CM_REQ_SENT, 51219820Sjeff IB_CM_REQ_RCVD, 52219820Sjeff IB_CM_MRA_REQ_SENT, 53219820Sjeff IB_CM_MRA_REQ_RCVD, 54219820Sjeff IB_CM_REP_SENT, 55219820Sjeff IB_CM_REP_RCVD, 56219820Sjeff IB_CM_MRA_REP_SENT, 57219820Sjeff IB_CM_MRA_REP_RCVD, 58219820Sjeff IB_CM_ESTABLISHED, 59219820Sjeff IB_CM_DREQ_SENT, 60219820Sjeff IB_CM_DREQ_RCVD, 61219820Sjeff IB_CM_TIMEWAIT, 62219820Sjeff IB_CM_SIDR_REQ_SENT, 63219820Sjeff IB_CM_SIDR_REQ_RCVD 64219820Sjeff}; 65219820Sjeff 66219820Sjeffenum ib_cm_lap_state { 67219820Sjeff IB_CM_LAP_UNINIT, 68219820Sjeff IB_CM_LAP_IDLE, 69219820Sjeff IB_CM_LAP_SENT, 70219820Sjeff IB_CM_LAP_RCVD, 71219820Sjeff IB_CM_MRA_LAP_SENT, 72219820Sjeff IB_CM_MRA_LAP_RCVD, 73219820Sjeff}; 74219820Sjeff 75219820Sjeffenum ib_cm_event_type { 76219820Sjeff IB_CM_REQ_ERROR, 77219820Sjeff IB_CM_REQ_RECEIVED, 78219820Sjeff IB_CM_REP_ERROR, 79219820Sjeff IB_CM_REP_RECEIVED, 80219820Sjeff IB_CM_RTU_RECEIVED, 81219820Sjeff IB_CM_USER_ESTABLISHED, 82219820Sjeff IB_CM_DREQ_ERROR, 83219820Sjeff IB_CM_DREQ_RECEIVED, 84219820Sjeff IB_CM_DREP_RECEIVED, 85219820Sjeff IB_CM_TIMEWAIT_EXIT, 86219820Sjeff IB_CM_MRA_RECEIVED, 87219820Sjeff IB_CM_REJ_RECEIVED, 88219820Sjeff IB_CM_LAP_ERROR, 89219820Sjeff IB_CM_LAP_RECEIVED, 90219820Sjeff IB_CM_APR_RECEIVED, 91219820Sjeff IB_CM_SIDR_REQ_ERROR, 92219820Sjeff IB_CM_SIDR_REQ_RECEIVED, 93219820Sjeff IB_CM_SIDR_REP_RECEIVED 94219820Sjeff}; 95219820Sjeff 96219820Sjeffenum ib_cm_data_size { 97219820Sjeff IB_CM_REQ_PRIVATE_DATA_SIZE = 92, 98219820Sjeff IB_CM_MRA_PRIVATE_DATA_SIZE = 222, 99219820Sjeff IB_CM_REJ_PRIVATE_DATA_SIZE = 148, 100219820Sjeff IB_CM_REP_PRIVATE_DATA_SIZE = 196, 101219820Sjeff IB_CM_RTU_PRIVATE_DATA_SIZE = 224, 102219820Sjeff IB_CM_DREQ_PRIVATE_DATA_SIZE = 220, 103219820Sjeff IB_CM_DREP_PRIVATE_DATA_SIZE = 224, 104219820Sjeff IB_CM_REJ_ARI_LENGTH = 72, 105219820Sjeff IB_CM_LAP_PRIVATE_DATA_SIZE = 168, 106219820Sjeff IB_CM_APR_PRIVATE_DATA_SIZE = 148, 107219820Sjeff IB_CM_APR_INFO_LENGTH = 72, 108219820Sjeff IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216, 109219820Sjeff IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136, 110219820Sjeff IB_CM_SIDR_REP_INFO_LENGTH = 72, 111219820Sjeff}; 112219820Sjeff 113219820Sjeffstruct ib_cm_id; 114219820Sjeff 115219820Sjeffstruct ib_cm_req_event_param { 116219820Sjeff struct ib_cm_id *listen_id; 117331769Shselasky 118331769Shselasky /* P_Key that was used by the GMP's BTH header */ 119331769Shselasky u16 bth_pkey; 120331769Shselasky 121219820Sjeff u8 port; 122219820Sjeff 123219820Sjeff struct ib_sa_path_rec *primary_path; 124219820Sjeff struct ib_sa_path_rec *alternate_path; 125219820Sjeff 126338557Shselasky /* 127338557Shselasky * SGID index of the primary path. Currently only 128338557Shselasky * useful for RoCE. Alternate path GID attributes 129338557Shselasky * are not yet supported. 130338557Shselasky */ 131338557Shselasky u8 ppath_sgid_index; 132338557Shselasky 133219820Sjeff __be64 remote_ca_guid; 134219820Sjeff u32 remote_qkey; 135219820Sjeff u32 remote_qpn; 136219820Sjeff enum ib_qp_type qp_type; 137219820Sjeff 138219820Sjeff u32 starting_psn; 139219820Sjeff u8 responder_resources; 140219820Sjeff u8 initiator_depth; 141219820Sjeff unsigned int local_cm_response_timeout:5; 142219820Sjeff unsigned int flow_control:1; 143219820Sjeff unsigned int remote_cm_response_timeout:5; 144219820Sjeff unsigned int retry_count:3; 145219820Sjeff unsigned int rnr_retry_count:3; 146219820Sjeff unsigned int srq:1; 147219820Sjeff}; 148219820Sjeff 149219820Sjeffstruct ib_cm_rep_event_param { 150219820Sjeff __be64 remote_ca_guid; 151219820Sjeff u32 remote_qkey; 152219820Sjeff u32 remote_qpn; 153219820Sjeff u32 starting_psn; 154219820Sjeff u8 responder_resources; 155219820Sjeff u8 initiator_depth; 156219820Sjeff unsigned int target_ack_delay:5; 157219820Sjeff unsigned int failover_accepted:2; 158219820Sjeff unsigned int flow_control:1; 159219820Sjeff unsigned int rnr_retry_count:3; 160219820Sjeff unsigned int srq:1; 161219820Sjeff}; 162219820Sjeff 163219820Sjeffenum ib_cm_rej_reason { 164219820Sjeff IB_CM_REJ_NO_QP = 1, 165219820Sjeff IB_CM_REJ_NO_EEC = 2, 166219820Sjeff IB_CM_REJ_NO_RESOURCES = 3, 167219820Sjeff IB_CM_REJ_TIMEOUT = 4, 168219820Sjeff IB_CM_REJ_UNSUPPORTED = 5, 169219820Sjeff IB_CM_REJ_INVALID_COMM_ID = 6, 170219820Sjeff IB_CM_REJ_INVALID_COMM_INSTANCE = 7, 171219820Sjeff IB_CM_REJ_INVALID_SERVICE_ID = 8, 172219820Sjeff IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9, 173219820Sjeff IB_CM_REJ_STALE_CONN = 10, 174219820Sjeff IB_CM_REJ_RDC_NOT_EXIST = 11, 175219820Sjeff IB_CM_REJ_INVALID_GID = 12, 176219820Sjeff IB_CM_REJ_INVALID_LID = 13, 177219820Sjeff IB_CM_REJ_INVALID_SL = 14, 178219820Sjeff IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15, 179219820Sjeff IB_CM_REJ_INVALID_HOP_LIMIT = 16, 180219820Sjeff IB_CM_REJ_INVALID_PACKET_RATE = 17, 181219820Sjeff IB_CM_REJ_INVALID_ALT_GID = 18, 182219820Sjeff IB_CM_REJ_INVALID_ALT_LID = 19, 183219820Sjeff IB_CM_REJ_INVALID_ALT_SL = 20, 184219820Sjeff IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21, 185219820Sjeff IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22, 186219820Sjeff IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23, 187219820Sjeff IB_CM_REJ_PORT_CM_REDIRECT = 24, 188219820Sjeff IB_CM_REJ_PORT_REDIRECT = 25, 189219820Sjeff IB_CM_REJ_INVALID_MTU = 26, 190219820Sjeff IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27, 191219820Sjeff IB_CM_REJ_CONSUMER_DEFINED = 28, 192219820Sjeff IB_CM_REJ_INVALID_RNR_RETRY = 29, 193219820Sjeff IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30, 194219820Sjeff IB_CM_REJ_INVALID_CLASS_VERSION = 31, 195219820Sjeff IB_CM_REJ_INVALID_FLOW_LABEL = 32, 196219820Sjeff IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33 197219820Sjeff}; 198219820Sjeff 199219820Sjeffstruct ib_cm_rej_event_param { 200219820Sjeff enum ib_cm_rej_reason reason; 201219820Sjeff void *ari; 202219820Sjeff u8 ari_length; 203219820Sjeff}; 204219820Sjeff 205219820Sjeffstruct ib_cm_mra_event_param { 206219820Sjeff u8 service_timeout; 207219820Sjeff}; 208219820Sjeff 209219820Sjeffstruct ib_cm_lap_event_param { 210219820Sjeff struct ib_sa_path_rec *alternate_path; 211219820Sjeff}; 212219820Sjeff 213219820Sjeffenum ib_cm_apr_status { 214219820Sjeff IB_CM_APR_SUCCESS, 215219820Sjeff IB_CM_APR_INVALID_COMM_ID, 216219820Sjeff IB_CM_APR_UNSUPPORTED, 217219820Sjeff IB_CM_APR_REJECT, 218219820Sjeff IB_CM_APR_REDIRECT, 219219820Sjeff IB_CM_APR_IS_CURRENT, 220219820Sjeff IB_CM_APR_INVALID_QPN_EECN, 221219820Sjeff IB_CM_APR_INVALID_LID, 222219820Sjeff IB_CM_APR_INVALID_GID, 223219820Sjeff IB_CM_APR_INVALID_FLOW_LABEL, 224219820Sjeff IB_CM_APR_INVALID_TCLASS, 225219820Sjeff IB_CM_APR_INVALID_HOP_LIMIT, 226219820Sjeff IB_CM_APR_INVALID_PACKET_RATE, 227219820Sjeff IB_CM_APR_INVALID_SL 228219820Sjeff}; 229219820Sjeff 230219820Sjeffstruct ib_cm_apr_event_param { 231219820Sjeff enum ib_cm_apr_status ap_status; 232219820Sjeff void *apr_info; 233219820Sjeff u8 info_len; 234219820Sjeff}; 235219820Sjeff 236219820Sjeffstruct ib_cm_sidr_req_event_param { 237219820Sjeff struct ib_cm_id *listen_id; 238331769Shselasky __be64 service_id; 239338557Shselasky 240338557Shselasky /* 241338557Shselasky * SGID index of the request. Currently only 242338557Shselasky * useful for RoCE. 243338557Shselasky */ 244338557Shselasky u8 sgid_index; 245338557Shselasky 246331769Shselasky /* P_Key that was used by the GMP's BTH header */ 247331769Shselasky u16 bth_pkey; 248219820Sjeff u8 port; 249219820Sjeff u16 pkey; 250219820Sjeff}; 251219820Sjeff 252219820Sjeffenum ib_cm_sidr_status { 253219820Sjeff IB_SIDR_SUCCESS, 254219820Sjeff IB_SIDR_UNSUPPORTED, 255219820Sjeff IB_SIDR_REJECT, 256219820Sjeff IB_SIDR_NO_QP, 257219820Sjeff IB_SIDR_REDIRECT, 258219820Sjeff IB_SIDR_UNSUPPORTED_VERSION 259219820Sjeff}; 260219820Sjeff 261219820Sjeffstruct ib_cm_sidr_rep_event_param { 262219820Sjeff enum ib_cm_sidr_status status; 263219820Sjeff u32 qkey; 264219820Sjeff u32 qpn; 265219820Sjeff void *info; 266219820Sjeff u8 info_len; 267219820Sjeff}; 268219820Sjeff 269219820Sjeffstruct ib_cm_event { 270219820Sjeff enum ib_cm_event_type event; 271219820Sjeff union { 272219820Sjeff struct ib_cm_req_event_param req_rcvd; 273219820Sjeff struct ib_cm_rep_event_param rep_rcvd; 274219820Sjeff /* No data for RTU received events. */ 275219820Sjeff struct ib_cm_rej_event_param rej_rcvd; 276219820Sjeff struct ib_cm_mra_event_param mra_rcvd; 277219820Sjeff struct ib_cm_lap_event_param lap_rcvd; 278219820Sjeff struct ib_cm_apr_event_param apr_rcvd; 279219820Sjeff /* No data for DREQ/DREP received events. */ 280219820Sjeff struct ib_cm_sidr_req_event_param sidr_req_rcvd; 281219820Sjeff struct ib_cm_sidr_rep_event_param sidr_rep_rcvd; 282219820Sjeff enum ib_wc_status send_status; 283219820Sjeff } param; 284219820Sjeff 285219820Sjeff void *private_data; 286219820Sjeff}; 287219820Sjeff 288255932Salfred#define CM_REQ_ATTR_ID cpu_to_be16(0x0010) 289255932Salfred#define CM_MRA_ATTR_ID cpu_to_be16(0x0011) 290255932Salfred#define CM_REJ_ATTR_ID cpu_to_be16(0x0012) 291255932Salfred#define CM_REP_ATTR_ID cpu_to_be16(0x0013) 292255932Salfred#define CM_RTU_ATTR_ID cpu_to_be16(0x0014) 293255932Salfred#define CM_DREQ_ATTR_ID cpu_to_be16(0x0015) 294255932Salfred#define CM_DREP_ATTR_ID cpu_to_be16(0x0016) 295255932Salfred#define CM_SIDR_REQ_ATTR_ID cpu_to_be16(0x0017) 296255932Salfred#define CM_SIDR_REP_ATTR_ID cpu_to_be16(0x0018) 297255932Salfred#define CM_LAP_ATTR_ID cpu_to_be16(0x0019) 298255932Salfred#define CM_APR_ATTR_ID cpu_to_be16(0x001A) 299255932Salfred 300219820Sjeff/** 301219820Sjeff * ib_cm_handler - User-defined callback to process communication events. 302219820Sjeff * @cm_id: Communication identifier associated with the reported event. 303219820Sjeff * @event: Information about the communication event. 304219820Sjeff * 305219820Sjeff * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events 306219820Sjeff * generated as a result of listen requests result in the allocation of a 307219820Sjeff * new @cm_id. The new @cm_id is returned to the user through this callback. 308219820Sjeff * Clients are responsible for destroying the new @cm_id. For peer-to-peer 309219820Sjeff * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds 310219820Sjeff * to a user's existing communication identifier. 311219820Sjeff * 312219820Sjeff * Users may not call ib_destroy_cm_id while in the context of this callback; 313219820Sjeff * however, returning a non-zero value instructs the communication manager to 314219820Sjeff * destroy the @cm_id after the callback completes. 315219820Sjeff */ 316219820Sjefftypedef int (*ib_cm_handler)(struct ib_cm_id *cm_id, 317219820Sjeff struct ib_cm_event *event); 318219820Sjeff 319219820Sjeffstruct ib_cm_id { 320219820Sjeff ib_cm_handler cm_handler; 321219820Sjeff void *context; 322219820Sjeff struct ib_device *device; 323219820Sjeff __be64 service_id; 324219820Sjeff __be64 service_mask; 325219820Sjeff enum ib_cm_state state; /* internal CM/debug use */ 326219820Sjeff enum ib_cm_lap_state lap_state; /* internal CM/debug use */ 327219820Sjeff __be32 local_id; 328219820Sjeff __be32 remote_id; 329219820Sjeff u32 remote_cm_qpn; /* 1 unless redirected */ 330219820Sjeff}; 331219820Sjeff 332219820Sjeff/** 333219820Sjeff * ib_create_cm_id - Allocate a communication identifier. 334219820Sjeff * @device: Device associated with the cm_id. All related communication will 335219820Sjeff * be associated with the specified device. 336219820Sjeff * @cm_handler: Callback invoked to notify the user of CM events. 337219820Sjeff * @context: User specified context associated with the communication 338219820Sjeff * identifier. 339219820Sjeff * 340219820Sjeff * Communication identifiers are used to track connection states, service 341219820Sjeff * ID resolution requests, and listen requests. 342219820Sjeff */ 343219820Sjeffstruct ib_cm_id *ib_create_cm_id(struct ib_device *device, 344219820Sjeff ib_cm_handler cm_handler, 345219820Sjeff void *context); 346219820Sjeff 347219820Sjeff/** 348219820Sjeff * ib_destroy_cm_id - Destroy a connection identifier. 349219820Sjeff * @cm_id: Connection identifier to destroy. 350219820Sjeff * 351219820Sjeff * This call blocks until the connection identifier is destroyed. 352219820Sjeff */ 353219820Sjeffvoid ib_destroy_cm_id(struct ib_cm_id *cm_id); 354219820Sjeff 355219820Sjeff#define IB_SERVICE_ID_AGN_MASK cpu_to_be64(0xFF00000000000000ULL) 356219820Sjeff#define IB_CM_ASSIGN_SERVICE_ID cpu_to_be64(0x0200000000000000ULL) 357219820Sjeff#define IB_CMA_SERVICE_ID cpu_to_be64(0x0000000001000000ULL) 358219820Sjeff#define IB_CMA_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFF000000ULL) 359219820Sjeff#define IB_SDP_SERVICE_ID cpu_to_be64(0x0000000000010000ULL) 360219820Sjeff#define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL) 361219820Sjeff 362219820Sjeff/** 363219820Sjeff * ib_cm_listen - Initiates listening on the specified service ID for 364219820Sjeff * connection and service ID resolution requests. 365219820Sjeff * @cm_id: Connection identifier associated with the listen request. 366219820Sjeff * @service_id: Service identifier matched against incoming connection 367219820Sjeff * and service ID resolution requests. The service ID should be specified 368219820Sjeff * network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will 369219820Sjeff * assign a service ID to the caller. 370219820Sjeff * @service_mask: Mask applied to service ID used to listen across a 371219820Sjeff * range of service IDs. If set to 0, the service ID is matched 372219820Sjeff * exactly. This parameter is ignored if %service_id is set to 373219820Sjeff * IB_CM_ASSIGN_SERVICE_ID. 374219820Sjeff */ 375331769Shselaskyint ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, 376331769Shselasky __be64 service_mask); 377219820Sjeff 378331769Shselaskystruct ib_cm_id *ib_cm_insert_listen(struct ib_device *device, 379331769Shselasky ib_cm_handler cm_handler, 380331769Shselasky __be64 service_id); 381331769Shselasky 382219820Sjeffstruct ib_cm_req_param { 383219820Sjeff struct ib_sa_path_rec *primary_path; 384219820Sjeff struct ib_sa_path_rec *alternate_path; 385219820Sjeff __be64 service_id; 386219820Sjeff u32 qp_num; 387219820Sjeff enum ib_qp_type qp_type; 388219820Sjeff u32 starting_psn; 389219820Sjeff const void *private_data; 390219820Sjeff u8 private_data_len; 391219820Sjeff u8 peer_to_peer; 392219820Sjeff u8 responder_resources; 393219820Sjeff u8 initiator_depth; 394219820Sjeff u8 remote_cm_response_timeout; 395219820Sjeff u8 flow_control; 396219820Sjeff u8 local_cm_response_timeout; 397219820Sjeff u8 retry_count; 398219820Sjeff u8 rnr_retry_count; 399219820Sjeff u8 max_cm_retries; 400219820Sjeff u8 srq; 401219820Sjeff}; 402219820Sjeff 403219820Sjeff/** 404219820Sjeff * ib_send_cm_req - Sends a connection request to the remote node. 405219820Sjeff * @cm_id: Connection identifier that will be associated with the 406219820Sjeff * connection request. 407219820Sjeff * @param: Connection request information needed to establish the 408219820Sjeff * connection. 409219820Sjeff */ 410219820Sjeffint ib_send_cm_req(struct ib_cm_id *cm_id, 411219820Sjeff struct ib_cm_req_param *param); 412219820Sjeff 413219820Sjeffstruct ib_cm_rep_param { 414219820Sjeff u32 qp_num; 415219820Sjeff u32 starting_psn; 416219820Sjeff const void *private_data; 417219820Sjeff u8 private_data_len; 418219820Sjeff u8 responder_resources; 419219820Sjeff u8 initiator_depth; 420219820Sjeff u8 failover_accepted; 421219820Sjeff u8 flow_control; 422219820Sjeff u8 rnr_retry_count; 423219820Sjeff u8 srq; 424219820Sjeff}; 425219820Sjeff 426219820Sjeff/** 427219820Sjeff * ib_send_cm_rep - Sends a connection reply in response to a connection 428219820Sjeff * request. 429219820Sjeff * @cm_id: Connection identifier that will be associated with the 430219820Sjeff * connection request. 431219820Sjeff * @param: Connection reply information needed to establish the 432219820Sjeff * connection. 433219820Sjeff */ 434219820Sjeffint ib_send_cm_rep(struct ib_cm_id *cm_id, 435219820Sjeff struct ib_cm_rep_param *param); 436219820Sjeff 437219820Sjeff/** 438219820Sjeff * ib_send_cm_rtu - Sends a connection ready to use message in response 439219820Sjeff * to a connection reply message. 440219820Sjeff * @cm_id: Connection identifier associated with the connection request. 441219820Sjeff * @private_data: Optional user-defined private data sent with the 442219820Sjeff * ready to use message. 443219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 444219820Sjeff */ 445219820Sjeffint ib_send_cm_rtu(struct ib_cm_id *cm_id, 446219820Sjeff const void *private_data, 447219820Sjeff u8 private_data_len); 448219820Sjeff 449219820Sjeff/** 450219820Sjeff * ib_send_cm_dreq - Sends a disconnection request for an existing 451219820Sjeff * connection. 452219820Sjeff * @cm_id: Connection identifier associated with the connection being 453219820Sjeff * released. 454219820Sjeff * @private_data: Optional user-defined private data sent with the 455219820Sjeff * disconnection request message. 456219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 457219820Sjeff */ 458219820Sjeffint ib_send_cm_dreq(struct ib_cm_id *cm_id, 459219820Sjeff const void *private_data, 460219820Sjeff u8 private_data_len); 461219820Sjeff 462219820Sjeff/** 463219820Sjeff * ib_send_cm_drep - Sends a disconnection reply to a disconnection request. 464219820Sjeff * @cm_id: Connection identifier associated with the connection being 465219820Sjeff * released. 466219820Sjeff * @private_data: Optional user-defined private data sent with the 467219820Sjeff * disconnection reply message. 468219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 469219820Sjeff * 470219820Sjeff * If the cm_id is in the correct state, the CM will transition the connection 471219820Sjeff * to the timewait state, even if an error occurs sending the DREP message. 472219820Sjeff */ 473219820Sjeffint ib_send_cm_drep(struct ib_cm_id *cm_id, 474219820Sjeff const void *private_data, 475219820Sjeff u8 private_data_len); 476219820Sjeff 477219820Sjeff/** 478219820Sjeff * ib_cm_notify - Notifies the CM of an event reported to the consumer. 479219820Sjeff * @cm_id: Connection identifier to transition to established. 480219820Sjeff * @event: Type of event. 481219820Sjeff * 482219820Sjeff * This routine should be invoked by users to notify the CM of relevant 483219820Sjeff * communication events. Events that should be reported to the CM and 484219820Sjeff * when to report them are: 485219820Sjeff * 486219820Sjeff * IB_EVENT_COMM_EST - Used when a message is received on a connected 487219820Sjeff * QP before an RTU has been received. 488219820Sjeff * IB_EVENT_PATH_MIG - Notifies the CM that the connection has failed over 489219820Sjeff * to the alternate path. 490219820Sjeff */ 491219820Sjeffint ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event); 492219820Sjeff 493219820Sjeff/** 494219820Sjeff * ib_send_cm_rej - Sends a connection rejection message to the 495219820Sjeff * remote node. 496219820Sjeff * @cm_id: Connection identifier associated with the connection being 497219820Sjeff * rejected. 498219820Sjeff * @reason: Reason for the connection request rejection. 499219820Sjeff * @ari: Optional additional rejection information. 500219820Sjeff * @ari_length: Size of the additional rejection information, in bytes. 501219820Sjeff * @private_data: Optional user-defined private data sent with the 502219820Sjeff * rejection message. 503219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 504219820Sjeff */ 505219820Sjeffint ib_send_cm_rej(struct ib_cm_id *cm_id, 506219820Sjeff enum ib_cm_rej_reason reason, 507219820Sjeff void *ari, 508219820Sjeff u8 ari_length, 509219820Sjeff const void *private_data, 510219820Sjeff u8 private_data_len); 511219820Sjeff 512219820Sjeff#define IB_CM_MRA_FLAG_DELAY 0x80 /* Send MRA only after a duplicate msg */ 513219820Sjeff 514219820Sjeff/** 515219820Sjeff * ib_send_cm_mra - Sends a message receipt acknowledgement to a connection 516219820Sjeff * message. 517219820Sjeff * @cm_id: Connection identifier associated with the connection message. 518219820Sjeff * @service_timeout: The lower 5-bits specify the maximum time required for 519278886Shselasky * the sender to reply to the connection message. The upper 3-bits 520219820Sjeff * specify additional control flags. 521219820Sjeff * @private_data: Optional user-defined private data sent with the 522219820Sjeff * message receipt acknowledgement. 523219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 524219820Sjeff */ 525219820Sjeffint ib_send_cm_mra(struct ib_cm_id *cm_id, 526219820Sjeff u8 service_timeout, 527219820Sjeff const void *private_data, 528219820Sjeff u8 private_data_len); 529219820Sjeff 530219820Sjeff/** 531219820Sjeff * ib_send_cm_lap - Sends a load alternate path request. 532219820Sjeff * @cm_id: Connection identifier associated with the load alternate path 533219820Sjeff * message. 534219820Sjeff * @alternate_path: A path record that identifies the alternate path to 535219820Sjeff * load. 536219820Sjeff * @private_data: Optional user-defined private data sent with the 537219820Sjeff * load alternate path message. 538219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 539219820Sjeff */ 540219820Sjeffint ib_send_cm_lap(struct ib_cm_id *cm_id, 541219820Sjeff struct ib_sa_path_rec *alternate_path, 542219820Sjeff const void *private_data, 543219820Sjeff u8 private_data_len); 544219820Sjeff 545219820Sjeff/** 546219820Sjeff * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning 547219820Sjeff * to a specified QP state. 548219820Sjeff * @cm_id: Communication identifier associated with the QP attributes to 549219820Sjeff * initialize. 550219820Sjeff * @qp_attr: On input, specifies the desired QP state. On output, the 551219820Sjeff * mandatory and desired optional attributes will be set in order to 552219820Sjeff * modify the QP to the specified state. 553219820Sjeff * @qp_attr_mask: The QP attribute mask that may be used to transition the 554219820Sjeff * QP to the specified state. 555219820Sjeff * 556219820Sjeff * Users must set the @qp_attr->qp_state to the desired QP state. This call 557219820Sjeff * will set all required attributes for the given transition, along with 558219820Sjeff * known optional attributes. Users may override the attributes returned from 559219820Sjeff * this call before calling ib_modify_qp. 560219820Sjeff */ 561219820Sjeffint ib_cm_init_qp_attr(struct ib_cm_id *cm_id, 562219820Sjeff struct ib_qp_attr *qp_attr, 563219820Sjeff int *qp_attr_mask); 564219820Sjeff 565219820Sjeff/** 566219820Sjeff * ib_send_cm_apr - Sends an alternate path response message in response to 567219820Sjeff * a load alternate path request. 568219820Sjeff * @cm_id: Connection identifier associated with the alternate path response. 569219820Sjeff * @status: Reply status sent with the alternate path response. 570219820Sjeff * @info: Optional additional information sent with the alternate path 571219820Sjeff * response. 572219820Sjeff * @info_length: Size of the additional information, in bytes. 573219820Sjeff * @private_data: Optional user-defined private data sent with the 574219820Sjeff * alternate path response message. 575219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 576219820Sjeff */ 577219820Sjeffint ib_send_cm_apr(struct ib_cm_id *cm_id, 578219820Sjeff enum ib_cm_apr_status status, 579219820Sjeff void *info, 580219820Sjeff u8 info_length, 581219820Sjeff const void *private_data, 582219820Sjeff u8 private_data_len); 583219820Sjeff 584219820Sjeffstruct ib_cm_sidr_req_param { 585219820Sjeff struct ib_sa_path_rec *path; 586219820Sjeff __be64 service_id; 587219820Sjeff int timeout_ms; 588219820Sjeff const void *private_data; 589219820Sjeff u8 private_data_len; 590219820Sjeff u8 max_cm_retries; 591219820Sjeff}; 592219820Sjeff 593219820Sjeff/** 594219820Sjeff * ib_send_cm_sidr_req - Sends a service ID resolution request to the 595219820Sjeff * remote node. 596219820Sjeff * @cm_id: Communication identifier that will be associated with the 597219820Sjeff * service ID resolution request. 598219820Sjeff * @param: Service ID resolution request information. 599219820Sjeff */ 600219820Sjeffint ib_send_cm_sidr_req(struct ib_cm_id *cm_id, 601219820Sjeff struct ib_cm_sidr_req_param *param); 602219820Sjeff 603219820Sjeffstruct ib_cm_sidr_rep_param { 604219820Sjeff u32 qp_num; 605219820Sjeff u32 qkey; 606219820Sjeff enum ib_cm_sidr_status status; 607219820Sjeff const void *info; 608219820Sjeff u8 info_length; 609219820Sjeff const void *private_data; 610219820Sjeff u8 private_data_len; 611219820Sjeff}; 612219820Sjeff 613219820Sjeff/** 614219820Sjeff * ib_send_cm_sidr_rep - Sends a service ID resolution reply to the 615219820Sjeff * remote node. 616219820Sjeff * @cm_id: Communication identifier associated with the received service ID 617219820Sjeff * resolution request. 618219820Sjeff * @param: Service ID resolution reply information. 619219820Sjeff */ 620219820Sjeffint ib_send_cm_sidr_rep(struct ib_cm_id *cm_id, 621219820Sjeff struct ib_cm_sidr_rep_param *param); 622219820Sjeff 623219820Sjeff#endif /* IB_CM_H */ 624