1219820Sjeff/* 2219820Sjeff * Copyright (c) 2004-2006 Intel Corporation. All rights reserved. 3219820Sjeff * Copyright (c) 2004 Topspin Corporation. All rights reserved. 4219820Sjeff * Copyright (c) 2004 Voltaire Corporation. All rights reserved. 5219820Sjeff * 6219820Sjeff * This software is available to you under a choice of one of two 7219820Sjeff * licenses. You may choose to be licensed under the terms of the GNU 8219820Sjeff * General Public License (GPL) Version 2, available from the file 9219820Sjeff * COPYING in the main directory of this source tree, or the 10219820Sjeff * OpenIB.org BSD license below: 11219820Sjeff * 12219820Sjeff * Redistribution and use in source and binary forms, with or 13219820Sjeff * without modification, are permitted provided that the following 14219820Sjeff * conditions are met: 15219820Sjeff * 16219820Sjeff * - Redistributions of source code must retain the above 17219820Sjeff * copyright notice, this list of conditions and the following 18219820Sjeff * disclaimer. 19219820Sjeff * 20219820Sjeff * - Redistributions in binary form must reproduce the above 21219820Sjeff * copyright notice, this list of conditions and the following 22219820Sjeff * disclaimer in the documentation and/or other materials 23219820Sjeff * provided with the distribution. 24219820Sjeff * 25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32219820Sjeff * SOFTWARE. 33219820Sjeff * 34219820Sjeff * $Id$ 35219820Sjeff */ 36219820Sjeff#if !defined(CM_H) 37219820Sjeff#define CM_H 38219820Sjeff 39219820Sjeff#include <infiniband/verbs.h> 40219820Sjeff#include <infiniband/sa.h> 41219820Sjeff#include <infiniband/byteorder.h> 42219820Sjeff 43219820Sjeff#ifdef __cplusplus 44219820Sjeffextern "C" { 45219820Sjeff#endif 46219820Sjeff 47219820Sjeffenum ib_cm_event_type { 48219820Sjeff IB_CM_REQ_ERROR, 49219820Sjeff IB_CM_REQ_RECEIVED, 50219820Sjeff IB_CM_REP_ERROR, 51219820Sjeff IB_CM_REP_RECEIVED, 52219820Sjeff IB_CM_RTU_RECEIVED, 53219820Sjeff IB_CM_USER_ESTABLISHED, 54219820Sjeff IB_CM_DREQ_ERROR, 55219820Sjeff IB_CM_DREQ_RECEIVED, 56219820Sjeff IB_CM_DREP_RECEIVED, 57219820Sjeff IB_CM_TIMEWAIT_EXIT, 58219820Sjeff IB_CM_MRA_RECEIVED, 59219820Sjeff IB_CM_REJ_RECEIVED, 60219820Sjeff IB_CM_LAP_ERROR, 61219820Sjeff IB_CM_LAP_RECEIVED, 62219820Sjeff IB_CM_APR_RECEIVED, 63219820Sjeff IB_CM_SIDR_REQ_ERROR, 64219820Sjeff IB_CM_SIDR_REQ_RECEIVED, 65219820Sjeff IB_CM_SIDR_REP_RECEIVED 66219820Sjeff}; 67219820Sjeff 68219820Sjeffenum ib_cm_data_size { 69219820Sjeff IB_CM_REQ_PRIVATE_DATA_SIZE = 92, 70219820Sjeff IB_CM_MRA_PRIVATE_DATA_SIZE = 222, 71219820Sjeff IB_CM_REJ_PRIVATE_DATA_SIZE = 148, 72219820Sjeff IB_CM_REP_PRIVATE_DATA_SIZE = 196, 73219820Sjeff IB_CM_RTU_PRIVATE_DATA_SIZE = 224, 74219820Sjeff IB_CM_DREQ_PRIVATE_DATA_SIZE = 220, 75219820Sjeff IB_CM_DREP_PRIVATE_DATA_SIZE = 224, 76219820Sjeff IB_CM_REJ_ARI_LENGTH = 72, 77219820Sjeff IB_CM_LAP_PRIVATE_DATA_SIZE = 168, 78219820Sjeff IB_CM_APR_PRIVATE_DATA_SIZE = 148, 79219820Sjeff IB_CM_APR_INFO_LENGTH = 72, 80219820Sjeff IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216, 81219820Sjeff IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136, 82219820Sjeff IB_CM_SIDR_REP_INFO_LENGTH = 72 83219820Sjeff}; 84219820Sjeff 85219820Sjeffstruct ib_cm_device { 86219820Sjeff struct ibv_context *device_context; 87219820Sjeff int fd; 88219820Sjeff}; 89219820Sjeff 90219820Sjeffstruct ib_cm_id { 91219820Sjeff void *context; 92219820Sjeff struct ib_cm_device *device; 93219820Sjeff uint32_t handle; 94219820Sjeff}; 95219820Sjeff 96219820Sjeffstruct ib_cm_req_event_param { 97219820Sjeff struct ib_cm_id *listen_id; 98219820Sjeff uint8_t port; 99219820Sjeff 100219820Sjeff struct ibv_sa_path_rec *primary_path; 101219820Sjeff struct ibv_sa_path_rec *alternate_path; 102219820Sjeff 103219820Sjeff uint64_t remote_ca_guid; /* netork-byte order */ 104219820Sjeff uint32_t remote_qkey; 105219820Sjeff uint32_t remote_qpn; 106219820Sjeff enum ibv_qp_type qp_type; 107219820Sjeff 108219820Sjeff uint32_t starting_psn; 109219820Sjeff uint8_t responder_resources; 110219820Sjeff uint8_t initiator_depth; 111219820Sjeff unsigned int local_cm_response_timeout:5; 112219820Sjeff unsigned int flow_control:1; 113219820Sjeff unsigned int remote_cm_response_timeout:5; 114219820Sjeff unsigned int retry_count:3; 115219820Sjeff unsigned int rnr_retry_count:3; 116219820Sjeff unsigned int srq:1; 117219820Sjeff}; 118219820Sjeff 119219820Sjeffstruct ib_cm_rep_event_param { 120219820Sjeff uint64_t remote_ca_guid; /* network-byte order */ 121219820Sjeff uint32_t remote_qkey; 122219820Sjeff uint32_t remote_qpn; 123219820Sjeff uint32_t starting_psn; 124219820Sjeff uint8_t responder_resources; 125219820Sjeff uint8_t initiator_depth; 126219820Sjeff unsigned int target_ack_delay:5; 127219820Sjeff unsigned int failover_accepted:2; 128219820Sjeff unsigned int flow_control:1; 129219820Sjeff unsigned int rnr_retry_count:3; 130219820Sjeff unsigned int srq:1; 131219820Sjeff}; 132219820Sjeff 133219820Sjeffenum ib_cm_rej_reason { 134219820Sjeff IB_CM_REJ_NO_QP = 1, 135219820Sjeff IB_CM_REJ_NO_EEC = 2, 136219820Sjeff IB_CM_REJ_NO_RESOURCES = 3, 137219820Sjeff IB_CM_REJ_TIMEOUT = 4, 138219820Sjeff IB_CM_REJ_UNSUPPORTED = 5, 139219820Sjeff IB_CM_REJ_INVALID_COMM_ID = 6, 140219820Sjeff IB_CM_REJ_INVALID_COMM_INSTANCE = 7, 141219820Sjeff IB_CM_REJ_INVALID_SERVICE_ID = 8, 142219820Sjeff IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9, 143219820Sjeff IB_CM_REJ_STALE_CONN = 10, 144219820Sjeff IB_CM_REJ_RDC_NOT_EXIST = 11, 145219820Sjeff IB_CM_REJ_INVALID_GID = 12, 146219820Sjeff IB_CM_REJ_INVALID_LID = 13, 147219820Sjeff IB_CM_REJ_INVALID_SL = 14, 148219820Sjeff IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15, 149219820Sjeff IB_CM_REJ_INVALID_HOP_LIMIT = 16, 150219820Sjeff IB_CM_REJ_INVALID_PACKET_RATE = 17, 151219820Sjeff IB_CM_REJ_INVALID_ALT_GID = 18, 152219820Sjeff IB_CM_REJ_INVALID_ALT_LID = 19, 153219820Sjeff IB_CM_REJ_INVALID_ALT_SL = 20, 154219820Sjeff IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21, 155219820Sjeff IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22, 156219820Sjeff IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23, 157219820Sjeff IB_CM_REJ_PORT_CM_REDIRECT = 24, 158219820Sjeff IB_CM_REJ_PORT_REDIRECT = 25, 159219820Sjeff IB_CM_REJ_INVALID_MTU = 26, 160219820Sjeff IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27, 161219820Sjeff IB_CM_REJ_CONSUMER_DEFINED = 28, 162219820Sjeff IB_CM_REJ_INVALID_RNR_RETRY = 29, 163219820Sjeff IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30, 164219820Sjeff IB_CM_REJ_INVALID_CLASS_VERSION = 31, 165219820Sjeff IB_CM_REJ_INVALID_FLOW_LABEL = 32, 166219820Sjeff IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33 167219820Sjeff}; 168219820Sjeff 169219820Sjeffstruct ib_cm_rej_event_param { 170219820Sjeff enum ib_cm_rej_reason reason; 171219820Sjeff void *ari; 172219820Sjeff uint8_t ari_length; 173219820Sjeff}; 174219820Sjeff 175219820Sjeffstruct ib_cm_mra_event_param { 176219820Sjeff uint8_t service_timeout; 177219820Sjeff}; 178219820Sjeff 179219820Sjeffstruct ib_cm_lap_event_param { 180219820Sjeff struct ibv_sa_path_rec *alternate_path; 181219820Sjeff}; 182219820Sjeff 183219820Sjeffenum ib_cm_apr_status { 184219820Sjeff IB_CM_APR_SUCCESS, 185219820Sjeff IB_CM_APR_INVALID_COMM_ID, 186219820Sjeff IB_CM_APR_UNSUPPORTED, 187219820Sjeff IB_CM_APR_REJECT, 188219820Sjeff IB_CM_APR_REDIRECT, 189219820Sjeff IB_CM_APR_IS_CURRENT, 190219820Sjeff IB_CM_APR_INVALID_QPN_EECN, 191219820Sjeff IB_CM_APR_INVALID_LID, 192219820Sjeff IB_CM_APR_INVALID_GID, 193219820Sjeff IB_CM_APR_INVALID_FLOW_LABEL, 194219820Sjeff IB_CM_APR_INVALID_TCLASS, 195219820Sjeff IB_CM_APR_INVALID_HOP_LIMIT, 196219820Sjeff IB_CM_APR_INVALID_PACKET_RATE, 197219820Sjeff IB_CM_APR_INVALID_SL 198219820Sjeff}; 199219820Sjeff 200219820Sjeffstruct ib_cm_apr_event_param { 201219820Sjeff enum ib_cm_apr_status ap_status; 202219820Sjeff void *apr_info; 203219820Sjeff uint8_t info_len; 204219820Sjeff}; 205219820Sjeff 206219820Sjeffstruct ib_cm_sidr_req_event_param { 207219820Sjeff struct ib_cm_id *listen_id; 208219820Sjeff uint8_t port; 209219820Sjeff uint16_t pkey; 210219820Sjeff}; 211219820Sjeff 212219820Sjeffenum ib_cm_sidr_status { 213219820Sjeff IB_SIDR_SUCCESS, 214219820Sjeff IB_SIDR_UNSUPPORTED, 215219820Sjeff IB_SIDR_REJECT, 216219820Sjeff IB_SIDR_NO_QP, 217219820Sjeff IB_SIDR_REDIRECT, 218219820Sjeff IB_SIDR_UNSUPPORTED_VERSION 219219820Sjeff}; 220219820Sjeff 221219820Sjeffstruct ib_cm_sidr_rep_event_param { 222219820Sjeff enum ib_cm_sidr_status status; 223219820Sjeff uint32_t qkey; 224219820Sjeff uint32_t qpn; 225219820Sjeff void *info; 226219820Sjeff uint8_t info_len; 227219820Sjeff}; 228219820Sjeff 229219820Sjeffstruct ib_cm_event { 230219820Sjeff struct ib_cm_id *cm_id; 231219820Sjeff enum ib_cm_event_type event; 232219820Sjeff union { 233219820Sjeff struct ib_cm_req_event_param req_rcvd; 234219820Sjeff struct ib_cm_rep_event_param rep_rcvd; 235219820Sjeff /* No data for RTU received events. */ 236219820Sjeff struct ib_cm_rej_event_param rej_rcvd; 237219820Sjeff struct ib_cm_mra_event_param mra_rcvd; 238219820Sjeff struct ib_cm_lap_event_param lap_rcvd; 239219820Sjeff struct ib_cm_apr_event_param apr_rcvd; 240219820Sjeff /* No data for DREQ/DREP received events. */ 241219820Sjeff struct ib_cm_sidr_req_event_param sidr_req_rcvd; 242219820Sjeff struct ib_cm_sidr_rep_event_param sidr_rep_rcvd; 243219820Sjeff enum ibv_wc_status send_status; 244219820Sjeff } param; 245219820Sjeff 246219820Sjeff void *private_data; 247219820Sjeff}; 248219820Sjeff 249219820Sjeff/** 250219820Sjeff * ib_cm_get_event - Retrieves the next pending communications event, 251219820Sjeff * if no event is pending waits for an event. 252219820Sjeff * @device: CM device to retrieve the event. 253219820Sjeff * @event: Allocated information about the next communication event. 254219820Sjeff * Event should be freed using ib_cm_ack_event() 255219820Sjeff * 256219820Sjeff * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events 257219820Sjeff * generated as a result of listen requests result in the allocation of a 258219820Sjeff * new @cm_id. 259219820Sjeff * Clients are responsible for destroying the new @cm_id. For peer-to-peer 260219820Sjeff * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds 261219820Sjeff * to a user's existing communication identifier. 262219820Sjeff */ 263219820Sjeffint ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event); 264219820Sjeff 265219820Sjeff/** 266219820Sjeff * ib_cm_ack_event - Free a communications event. 267219820Sjeff * @event: Event to be released. 268219820Sjeff * 269219820Sjeff * All events which are allocated by ib_cm_get_event() must be released, 270219820Sjeff * there should be a one-to-one correspondence between successful gets 271219820Sjeff * and puts. 272219820Sjeff */ 273219820Sjeffint ib_cm_ack_event(struct ib_cm_event *event); 274219820Sjeff 275219820Sjeff/** 276219820Sjeff * ib_cm_open_device - Returns the device the CM uses to submit requests 277219820Sjeff * and retrieve events, corresponding to the specified verbs device. 278219820Sjeff * 279219820Sjeff * The CM device contains the file descriptor that the CM uses to 280219820Sjeff * communicate with the kernel CM component. The primary use of the 281219820Sjeff * file descriptor is to test for CM readiness events. When the CM 282219820Sjeff * becomes ready to READ there is a pending event ready, and a subsequent 283219820Sjeff * call to ib_cm_get_event will not block. 284219820Sjeff * Note: The user should not read or write directly to the CM file 285219820Sjeff * descriptor, it will likely result in an error or unexpected 286219820Sjeff * results. 287219820Sjeff */ 288219820Sjeffstruct ib_cm_device* ib_cm_open_device(struct ibv_context *device_context); 289219820Sjeff 290219820Sjeff/** 291219820Sjeff * ib_cm_close_device - Close a CM device. 292219820Sjeff * @device: Device to close. 293219820Sjeff */ 294219820Sjeffvoid ib_cm_close_device(struct ib_cm_device *device); 295219820Sjeff 296219820Sjeff/** 297219820Sjeff * ib_cm_create_id - Allocate a communication identifier. 298219820Sjeff * 299219820Sjeff * Communication identifiers are used to track connection states, service 300219820Sjeff * ID resolution requests, and listen requests. 301219820Sjeff */ 302219820Sjeffint ib_cm_create_id(struct ib_cm_device *device, 303219820Sjeff struct ib_cm_id **cm_id, void *context); 304219820Sjeff 305219820Sjeff/** 306219820Sjeff * ib_cm_destroy_id - Destroy a connection identifier. 307219820Sjeff * @cm_id: Connection identifier to destroy. 308219820Sjeff */ 309219820Sjeffint ib_cm_destroy_id(struct ib_cm_id *cm_id); 310219820Sjeff 311219820Sjeffstruct ib_cm_attr_param { 312219820Sjeff uint64_t service_id; /* network-byte order */ 313219820Sjeff uint64_t service_mask; /* network-byte order */ 314219820Sjeff uint32_t local_id; 315219820Sjeff uint32_t remote_id; 316219820Sjeff}; 317219820Sjeff 318219820Sjeff/** 319219820Sjeff * ib_cm_attr_id - Get connection identifier attributes. 320219820Sjeff * @cm_id: Connection identifier to retrieve attributes. 321219820Sjeff * @param: Destination of retreived parameters. 322219820Sjeff * 323219820Sjeff * Not all parameters are valid during all connection states. 324219820Sjeff */ 325219820Sjeffint ib_cm_attr_id(struct ib_cm_id *cm_id, 326219820Sjeff struct ib_cm_attr_param *param); 327219820Sjeff 328219820Sjeff#define IB_CM_ASSIGN_SERVICE_ID_MASK __constant_cpu_to_be64(0xFF00000000000000ULL) 329219820Sjeff#define IB_CM_ASSIGN_SERVICE_ID __constant_cpu_to_be64(0x0200000000000000ULL) 330219820Sjeff 331219820Sjeff/** 332219820Sjeff * ib_cm_listen - Initiates listening on the specified service ID for 333219820Sjeff * connection and service ID resolution requests. 334219820Sjeff * @cm_id: Connection identifier associated with the listen request. 335219820Sjeff * @service_id: Service identifier matched against incoming connection 336219820Sjeff * and service ID resolution requests. The service ID should be specified 337219820Sjeff * network-byte order. 338219820Sjeff * @service_mask: Mask applied to service ID used to listen across a 339219820Sjeff * range of service IDs. If set to 0, the service ID is matched 340219820Sjeff * exactly. 341219820Sjeff */ 342219820Sjeffint ib_cm_listen(struct ib_cm_id *cm_id, 343219820Sjeff uint64_t service_id, 344219820Sjeff uint64_t service_mask); 345219820Sjeff 346219820Sjeffstruct ib_cm_req_param { 347219820Sjeff struct ibv_sa_path_rec *primary_path; 348219820Sjeff struct ibv_sa_path_rec *alternate_path; 349219820Sjeff uint64_t service_id; /* network-byte order */ 350219820Sjeff uint32_t qp_num; 351219820Sjeff enum ibv_qp_type qp_type; 352219820Sjeff uint32_t starting_psn; 353219820Sjeff void *private_data; 354219820Sjeff uint8_t private_data_len; 355219820Sjeff uint8_t peer_to_peer; 356219820Sjeff uint8_t responder_resources; 357219820Sjeff uint8_t initiator_depth; 358219820Sjeff uint8_t remote_cm_response_timeout; 359219820Sjeff uint8_t flow_control; 360219820Sjeff uint8_t local_cm_response_timeout; 361219820Sjeff uint8_t retry_count; 362219820Sjeff uint8_t rnr_retry_count; 363219820Sjeff uint8_t max_cm_retries; 364219820Sjeff uint8_t srq; 365219820Sjeff}; 366219820Sjeff 367219820Sjeff/** 368219820Sjeff * ib_cm_send_req - Sends a connection request to the remote node. 369219820Sjeff * @cm_id: Connection identifier that will be associated with the 370219820Sjeff * connection request. 371219820Sjeff * @param: Connection request information needed to establish the 372219820Sjeff * connection. 373219820Sjeff */ 374219820Sjeffint ib_cm_send_req(struct ib_cm_id *cm_id, 375219820Sjeff struct ib_cm_req_param *param); 376219820Sjeff 377219820Sjeffstruct ib_cm_rep_param { 378219820Sjeff uint32_t qp_num; 379219820Sjeff uint32_t starting_psn; 380219820Sjeff void *private_data; 381219820Sjeff uint8_t private_data_len; 382219820Sjeff uint8_t responder_resources; 383219820Sjeff uint8_t initiator_depth; 384219820Sjeff uint8_t target_ack_delay; 385219820Sjeff uint8_t failover_accepted; 386219820Sjeff uint8_t flow_control; 387219820Sjeff uint8_t rnr_retry_count; 388219820Sjeff uint8_t srq; 389219820Sjeff}; 390219820Sjeff 391219820Sjeff/** 392219820Sjeff * ib_cm_send_rep - Sends a connection reply in response to a connection 393219820Sjeff * request. 394219820Sjeff * @cm_id: Connection identifier that will be associated with the 395219820Sjeff * connection request. 396219820Sjeff * @param: Connection reply information needed to establish the 397219820Sjeff * connection. 398219820Sjeff */ 399219820Sjeffint ib_cm_send_rep(struct ib_cm_id *cm_id, 400219820Sjeff struct ib_cm_rep_param *param); 401219820Sjeff 402219820Sjeff/** 403219820Sjeff * ib_cm_send_rtu - Sends a connection ready to use message in response 404219820Sjeff * to a connection reply message. 405219820Sjeff * @cm_id: Connection identifier associated with the connection request. 406219820Sjeff * @private_data: Optional user-defined private data sent with the 407219820Sjeff * ready to use message. 408219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 409219820Sjeff */ 410219820Sjeffint ib_cm_send_rtu(struct ib_cm_id *cm_id, 411219820Sjeff void *private_data, 412219820Sjeff uint8_t private_data_len); 413219820Sjeff 414219820Sjeff/** 415219820Sjeff * ib_cm_send_dreq - Sends a disconnection request for an existing 416219820Sjeff * connection. 417219820Sjeff * @cm_id: Connection identifier associated with the connection being 418219820Sjeff * released. 419219820Sjeff * @private_data: Optional user-defined private data sent with the 420219820Sjeff * disconnection request message. 421219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 422219820Sjeff */ 423219820Sjeffint ib_cm_send_dreq(struct ib_cm_id *cm_id, 424219820Sjeff void *private_data, 425219820Sjeff uint8_t private_data_len); 426219820Sjeff 427219820Sjeff/** 428219820Sjeff * ib_cm_send_drep - Sends a disconnection reply to a disconnection request. 429219820Sjeff * @cm_id: Connection identifier associated with the connection being 430219820Sjeff * released. 431219820Sjeff * @private_data: Optional user-defined private data sent with the 432219820Sjeff * disconnection reply message. 433219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 434219820Sjeff */ 435219820Sjeffint ib_cm_send_drep(struct ib_cm_id *cm_id, 436219820Sjeff void *private_data, 437219820Sjeff uint8_t private_data_len); 438219820Sjeff 439219820Sjeff/** 440219820Sjeff * ib_cm_notify - Notifies the CM of an event reported to the consumer. 441219820Sjeff * @cm_id: Connection identifier to transition to established. 442219820Sjeff * @event: Type of event. 443219820Sjeff * 444219820Sjeff * This routine should be invoked by users to notify the CM of relevant 445219820Sjeff * communication events. Events that should be reported to the CM and 446219820Sjeff * when to report them are: 447219820Sjeff * 448219820Sjeff * IBV_EVENT_COMM_EST - Used when a message is received on a connected 449219820Sjeff * QP before an RTU has been received. 450219820Sjeff * IBV_EVENT_PATH_MIG - Notifies the CM that the connection has failed over 451219820Sjeff * to the alternate path. 452219820Sjeff */ 453219820Sjeffint ib_cm_notify(struct ib_cm_id *cm_id, enum ibv_event_type event); 454219820Sjeff 455219820Sjeff/** 456219820Sjeff * ib_cm_send_rej - Sends a connection rejection message to the 457219820Sjeff * remote node. 458219820Sjeff * @cm_id: Connection identifier associated with the connection being 459219820Sjeff * rejected. 460219820Sjeff * @reason: Reason for the connection request rejection. 461219820Sjeff * @ari: Optional additional rejection information. 462219820Sjeff * @ari_length: Size of the additional rejection information, in bytes. 463219820Sjeff * @private_data: Optional user-defined private data sent with the 464219820Sjeff * rejection message. 465219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 466219820Sjeff */ 467219820Sjeffint ib_cm_send_rej(struct ib_cm_id *cm_id, 468219820Sjeff enum ib_cm_rej_reason reason, 469219820Sjeff void *ari, 470219820Sjeff uint8_t ari_length, 471219820Sjeff void *private_data, 472219820Sjeff uint8_t private_data_len); 473219820Sjeff 474219820Sjeff/** 475219820Sjeff * ib_cm_send_mra - Sends a message receipt acknowledgement to a connection 476219820Sjeff * message. 477219820Sjeff * @cm_id: Connection identifier associated with the connection message. 478219820Sjeff * @service_timeout: The maximum time required for the sender to reply to 479219820Sjeff * to the connection message. 480219820Sjeff * @private_data: Optional user-defined private data sent with the 481219820Sjeff * message receipt acknowledgement. 482219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 483219820Sjeff */ 484219820Sjeffint ib_cm_send_mra(struct ib_cm_id *cm_id, 485219820Sjeff uint8_t service_timeout, 486219820Sjeff void *private_data, 487219820Sjeff uint8_t private_data_len); 488219820Sjeff 489219820Sjeff/** 490219820Sjeff * ib_cm_send_lap - Sends a load alternate path request. 491219820Sjeff * @cm_id: Connection identifier associated with the load alternate path 492219820Sjeff * message. 493219820Sjeff * @alternate_path: A path record that identifies the alternate path to 494219820Sjeff * load. 495219820Sjeff * @private_data: Optional user-defined private data sent with the 496219820Sjeff * load alternate path message. 497219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 498219820Sjeff */ 499219820Sjeffint ib_cm_send_lap(struct ib_cm_id *cm_id, 500219820Sjeff struct ibv_sa_path_rec *alternate_path, 501219820Sjeff void *private_data, 502219820Sjeff uint8_t private_data_len); 503219820Sjeff 504219820Sjeff/** 505219820Sjeff * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning 506219820Sjeff * to a specified QP state. 507219820Sjeff * @cm_id: Communication identifier associated with the QP attributes to 508219820Sjeff * initialize. 509219820Sjeff * @qp_attr: On input, specifies the desired QP state. On output, the 510219820Sjeff * mandatory and desired optional attributes will be set in order to 511219820Sjeff * modify the QP to the specified state. 512219820Sjeff * @qp_attr_mask: The QP attribute mask that may be used to transition the 513219820Sjeff * QP to the specified state. 514219820Sjeff * 515219820Sjeff * Users must set the @qp_attr->qp_state to the desired QP state. This call 516219820Sjeff * will set all required attributes for the given transition, along with 517219820Sjeff * known optional attributes. Users may override the attributes returned from 518219820Sjeff * this call before calling ib_modify_qp. 519219820Sjeff */ 520219820Sjeffint ib_cm_init_qp_attr(struct ib_cm_id *cm_id, 521219820Sjeff struct ibv_qp_attr *qp_attr, 522219820Sjeff int *qp_attr_mask); 523219820Sjeff 524219820Sjeff/** 525219820Sjeff * ib_cm_send_apr - Sends an alternate path response message in response to 526219820Sjeff * a load alternate path request. 527219820Sjeff * @cm_id: Connection identifier associated with the alternate path response. 528219820Sjeff * @status: Reply status sent with the alternate path response. 529219820Sjeff * @info: Optional additional information sent with the alternate path 530219820Sjeff * response. 531219820Sjeff * @info_length: Size of the additional information, in bytes. 532219820Sjeff * @private_data: Optional user-defined private data sent with the 533219820Sjeff * alternate path response message. 534219820Sjeff * @private_data_len: Size of the private data buffer, in bytes. 535219820Sjeff */ 536219820Sjeffint ib_cm_send_apr(struct ib_cm_id *cm_id, 537219820Sjeff enum ib_cm_apr_status status, 538219820Sjeff void *info, 539219820Sjeff uint8_t info_length, 540219820Sjeff void *private_data, 541219820Sjeff uint8_t private_data_len); 542219820Sjeff 543219820Sjeffstruct ib_cm_sidr_req_param { 544219820Sjeff struct ibv_sa_path_rec *path; 545219820Sjeff uint64_t service_id; /* network-byte order */ 546219820Sjeff int timeout_ms; 547219820Sjeff void *private_data; 548219820Sjeff uint8_t private_data_len; 549219820Sjeff uint8_t max_cm_retries; 550219820Sjeff}; 551219820Sjeff 552219820Sjeff/** 553219820Sjeff * ib_cm_send_sidr_req - Sends a service ID resolution request to the 554219820Sjeff * remote node. 555219820Sjeff * @cm_id: Communication identifier that will be associated with the 556219820Sjeff * service ID resolution request. 557219820Sjeff * @param: Service ID resolution request information. 558219820Sjeff */ 559219820Sjeffint ib_cm_send_sidr_req(struct ib_cm_id *cm_id, 560219820Sjeff struct ib_cm_sidr_req_param *param); 561219820Sjeff 562219820Sjeffstruct ib_cm_sidr_rep_param { 563219820Sjeff uint32_t qp_num; 564219820Sjeff uint32_t qkey; 565219820Sjeff enum ib_cm_sidr_status status; 566219820Sjeff void *info; 567219820Sjeff uint8_t info_length; 568219820Sjeff void *private_data; 569219820Sjeff uint8_t private_data_len; 570219820Sjeff}; 571219820Sjeff 572219820Sjeff/** 573219820Sjeff * ib_cm_send_sidr_rep - Sends a service ID resolution reply to the 574219820Sjeff * remote node. 575219820Sjeff * @cm_id: Communication identifier associated with the received service ID 576219820Sjeff * resolution request. 577219820Sjeff * @param: Service ID resolution reply information. 578219820Sjeff */ 579219820Sjeffint ib_cm_send_sidr_rep(struct ib_cm_id *cm_id, 580219820Sjeff struct ib_cm_sidr_rep_param *param); 581219820Sjeff 582219820Sjeff#ifdef __cplusplus 583219820Sjeff} 584219820Sjeff#endif 585219820Sjeff 586219820Sjeff#endif /* CM_H */ 587