1a4d61e84SRoland Dreier /* 207d357d0SSean Hefty * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved. 3a4d61e84SRoland Dreier * Copyright (c) 2004 Topspin Corporation. All rights reserved. 4a4d61e84SRoland Dreier * Copyright (c) 2004 Voltaire Corporation. All rights reserved. 5a4d61e84SRoland Dreier * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 6a4d61e84SRoland Dreier * 7a4d61e84SRoland Dreier * This software is available to you under a choice of one of two 8a4d61e84SRoland Dreier * licenses. You may choose to be licensed under the terms of the GNU 9a4d61e84SRoland Dreier * General Public License (GPL) Version 2, available from the file 10a4d61e84SRoland Dreier * COPYING in the main directory of this source tree, or the 11a4d61e84SRoland Dreier * OpenIB.org BSD license below: 12a4d61e84SRoland Dreier * 13a4d61e84SRoland Dreier * Redistribution and use in source and binary forms, with or 14a4d61e84SRoland Dreier * without modification, are permitted provided that the following 15a4d61e84SRoland Dreier * conditions are met: 16a4d61e84SRoland Dreier * 17a4d61e84SRoland Dreier * - Redistributions of source code must retain the above 18a4d61e84SRoland Dreier * copyright notice, this list of conditions and the following 19a4d61e84SRoland Dreier * disclaimer. 20a4d61e84SRoland Dreier * 21a4d61e84SRoland Dreier * - Redistributions in binary form must reproduce the above 22a4d61e84SRoland Dreier * copyright notice, this list of conditions and the following 23a4d61e84SRoland Dreier * disclaimer in the documentation and/or other materials 24a4d61e84SRoland Dreier * provided with the distribution. 25a4d61e84SRoland Dreier * 26a4d61e84SRoland Dreier * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 27a4d61e84SRoland Dreier * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 28a4d61e84SRoland Dreier * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 29a4d61e84SRoland Dreier * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 30a4d61e84SRoland Dreier * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 31a4d61e84SRoland Dreier * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32a4d61e84SRoland Dreier * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33a4d61e84SRoland Dreier * SOFTWARE. 34a4d61e84SRoland Dreier * 356e61d04fSSean Hefty * $Id: ib_cm.h 4311 2005-12-05 18:42:01Z sean.hefty $ 36a4d61e84SRoland Dreier */ 37a4d61e84SRoland Dreier #if !defined(IB_CM_H) 38a4d61e84SRoland Dreier #define IB_CM_H 39a4d61e84SRoland Dreier 40a4d61e84SRoland Dreier #include <rdma/ib_mad.h> 41a4d61e84SRoland Dreier #include <rdma/ib_sa.h> 42a4d61e84SRoland Dreier 43a4d61e84SRoland Dreier enum ib_cm_state { 44a4d61e84SRoland Dreier IB_CM_IDLE, 45a4d61e84SRoland Dreier IB_CM_LISTEN, 46a4d61e84SRoland Dreier IB_CM_REQ_SENT, 47a4d61e84SRoland Dreier IB_CM_REQ_RCVD, 48a4d61e84SRoland Dreier IB_CM_MRA_REQ_SENT, 49a4d61e84SRoland Dreier IB_CM_MRA_REQ_RCVD, 50a4d61e84SRoland Dreier IB_CM_REP_SENT, 51a4d61e84SRoland Dreier IB_CM_REP_RCVD, 52a4d61e84SRoland Dreier IB_CM_MRA_REP_SENT, 53a4d61e84SRoland Dreier IB_CM_MRA_REP_RCVD, 54a4d61e84SRoland Dreier IB_CM_ESTABLISHED, 55a4d61e84SRoland Dreier IB_CM_DREQ_SENT, 56a4d61e84SRoland Dreier IB_CM_DREQ_RCVD, 57a4d61e84SRoland Dreier IB_CM_TIMEWAIT, 58a4d61e84SRoland Dreier IB_CM_SIDR_REQ_SENT, 59a4d61e84SRoland Dreier IB_CM_SIDR_REQ_RCVD 60a4d61e84SRoland Dreier }; 61a4d61e84SRoland Dreier 62a4d61e84SRoland Dreier enum ib_cm_lap_state { 63e1444b5aSSean Hefty IB_CM_LAP_UNINIT, 64a4d61e84SRoland Dreier IB_CM_LAP_IDLE, 65a4d61e84SRoland Dreier IB_CM_LAP_SENT, 66a4d61e84SRoland Dreier IB_CM_LAP_RCVD, 67a4d61e84SRoland Dreier IB_CM_MRA_LAP_SENT, 68a4d61e84SRoland Dreier IB_CM_MRA_LAP_RCVD, 69a4d61e84SRoland Dreier }; 70a4d61e84SRoland Dreier 71a4d61e84SRoland Dreier enum ib_cm_event_type { 72a4d61e84SRoland Dreier IB_CM_REQ_ERROR, 73a4d61e84SRoland Dreier IB_CM_REQ_RECEIVED, 74a4d61e84SRoland Dreier IB_CM_REP_ERROR, 75a4d61e84SRoland Dreier IB_CM_REP_RECEIVED, 76a4d61e84SRoland Dreier IB_CM_RTU_RECEIVED, 77a4d61e84SRoland Dreier IB_CM_USER_ESTABLISHED, 78a4d61e84SRoland Dreier IB_CM_DREQ_ERROR, 79a4d61e84SRoland Dreier IB_CM_DREQ_RECEIVED, 80a4d61e84SRoland Dreier IB_CM_DREP_RECEIVED, 81a4d61e84SRoland Dreier IB_CM_TIMEWAIT_EXIT, 82a4d61e84SRoland Dreier IB_CM_MRA_RECEIVED, 83a4d61e84SRoland Dreier IB_CM_REJ_RECEIVED, 84a4d61e84SRoland Dreier IB_CM_LAP_ERROR, 85a4d61e84SRoland Dreier IB_CM_LAP_RECEIVED, 86a4d61e84SRoland Dreier IB_CM_APR_RECEIVED, 87a4d61e84SRoland Dreier IB_CM_SIDR_REQ_ERROR, 88a4d61e84SRoland Dreier IB_CM_SIDR_REQ_RECEIVED, 89a4d61e84SRoland Dreier IB_CM_SIDR_REP_RECEIVED 90a4d61e84SRoland Dreier }; 91a4d61e84SRoland Dreier 92a4d61e84SRoland Dreier enum ib_cm_data_size { 93a4d61e84SRoland Dreier IB_CM_REQ_PRIVATE_DATA_SIZE = 92, 94a4d61e84SRoland Dreier IB_CM_MRA_PRIVATE_DATA_SIZE = 222, 95a4d61e84SRoland Dreier IB_CM_REJ_PRIVATE_DATA_SIZE = 148, 96a4d61e84SRoland Dreier IB_CM_REP_PRIVATE_DATA_SIZE = 196, 97a4d61e84SRoland Dreier IB_CM_RTU_PRIVATE_DATA_SIZE = 224, 98a4d61e84SRoland Dreier IB_CM_DREQ_PRIVATE_DATA_SIZE = 220, 99a4d61e84SRoland Dreier IB_CM_DREP_PRIVATE_DATA_SIZE = 224, 100a4d61e84SRoland Dreier IB_CM_REJ_ARI_LENGTH = 72, 101a4d61e84SRoland Dreier IB_CM_LAP_PRIVATE_DATA_SIZE = 168, 102a4d61e84SRoland Dreier IB_CM_APR_PRIVATE_DATA_SIZE = 148, 103a4d61e84SRoland Dreier IB_CM_APR_INFO_LENGTH = 72, 104a4d61e84SRoland Dreier IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216, 105a4d61e84SRoland Dreier IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136, 1066e61d04fSSean Hefty IB_CM_SIDR_REP_INFO_LENGTH = 72, 1076e61d04fSSean Hefty IB_CM_COMPARE_SIZE = 64 108a4d61e84SRoland Dreier }; 109a4d61e84SRoland Dreier 110a4d61e84SRoland Dreier struct ib_cm_id; 111a4d61e84SRoland Dreier 112a4d61e84SRoland Dreier struct ib_cm_req_event_param { 113a4d61e84SRoland Dreier struct ib_cm_id *listen_id; 114a4d61e84SRoland Dreier u8 port; 115a4d61e84SRoland Dreier 116a4d61e84SRoland Dreier struct ib_sa_path_rec *primary_path; 117a4d61e84SRoland Dreier struct ib_sa_path_rec *alternate_path; 118a4d61e84SRoland Dreier 119a4d61e84SRoland Dreier __be64 remote_ca_guid; 120a4d61e84SRoland Dreier u32 remote_qkey; 121a4d61e84SRoland Dreier u32 remote_qpn; 122a4d61e84SRoland Dreier enum ib_qp_type qp_type; 123a4d61e84SRoland Dreier 124a4d61e84SRoland Dreier u32 starting_psn; 125a4d61e84SRoland Dreier u8 responder_resources; 126a4d61e84SRoland Dreier u8 initiator_depth; 127a4d61e84SRoland Dreier unsigned int local_cm_response_timeout:5; 128a4d61e84SRoland Dreier unsigned int flow_control:1; 129a4d61e84SRoland Dreier unsigned int remote_cm_response_timeout:5; 130a4d61e84SRoland Dreier unsigned int retry_count:3; 131a4d61e84SRoland Dreier unsigned int rnr_retry_count:3; 132a4d61e84SRoland Dreier unsigned int srq:1; 133a4d61e84SRoland Dreier }; 134a4d61e84SRoland Dreier 135a4d61e84SRoland Dreier struct ib_cm_rep_event_param { 136a4d61e84SRoland Dreier __be64 remote_ca_guid; 137a4d61e84SRoland Dreier u32 remote_qkey; 138a4d61e84SRoland Dreier u32 remote_qpn; 139a4d61e84SRoland Dreier u32 starting_psn; 140a4d61e84SRoland Dreier u8 responder_resources; 141a4d61e84SRoland Dreier u8 initiator_depth; 142a4d61e84SRoland Dreier unsigned int target_ack_delay:5; 143a4d61e84SRoland Dreier unsigned int failover_accepted:2; 144a4d61e84SRoland Dreier unsigned int flow_control:1; 145a4d61e84SRoland Dreier unsigned int rnr_retry_count:3; 146a4d61e84SRoland Dreier unsigned int srq:1; 147a4d61e84SRoland Dreier }; 148a4d61e84SRoland Dreier 149a4d61e84SRoland Dreier enum ib_cm_rej_reason { 150a4d61e84SRoland Dreier IB_CM_REJ_NO_QP = 1, 151a4d61e84SRoland Dreier IB_CM_REJ_NO_EEC = 2, 152a4d61e84SRoland Dreier IB_CM_REJ_NO_RESOURCES = 3, 153a4d61e84SRoland Dreier IB_CM_REJ_TIMEOUT = 4, 154a4d61e84SRoland Dreier IB_CM_REJ_UNSUPPORTED = 5, 155a4d61e84SRoland Dreier IB_CM_REJ_INVALID_COMM_ID = 6, 156a4d61e84SRoland Dreier IB_CM_REJ_INVALID_COMM_INSTANCE = 7, 157a4d61e84SRoland Dreier IB_CM_REJ_INVALID_SERVICE_ID = 8, 158a4d61e84SRoland Dreier IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9, 159a4d61e84SRoland Dreier IB_CM_REJ_STALE_CONN = 10, 160a4d61e84SRoland Dreier IB_CM_REJ_RDC_NOT_EXIST = 11, 161a4d61e84SRoland Dreier IB_CM_REJ_INVALID_GID = 12, 162a4d61e84SRoland Dreier IB_CM_REJ_INVALID_LID = 13, 163a4d61e84SRoland Dreier IB_CM_REJ_INVALID_SL = 14, 164a4d61e84SRoland Dreier IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15, 165a4d61e84SRoland Dreier IB_CM_REJ_INVALID_HOP_LIMIT = 16, 166a4d61e84SRoland Dreier IB_CM_REJ_INVALID_PACKET_RATE = 17, 167a4d61e84SRoland Dreier IB_CM_REJ_INVALID_ALT_GID = 18, 168a4d61e84SRoland Dreier IB_CM_REJ_INVALID_ALT_LID = 19, 169a4d61e84SRoland Dreier IB_CM_REJ_INVALID_ALT_SL = 20, 170a4d61e84SRoland Dreier IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21, 171a4d61e84SRoland Dreier IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22, 172a4d61e84SRoland Dreier IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23, 173a4d61e84SRoland Dreier IB_CM_REJ_PORT_CM_REDIRECT = 24, 174a4d61e84SRoland Dreier IB_CM_REJ_PORT_REDIRECT = 25, 175a4d61e84SRoland Dreier IB_CM_REJ_INVALID_MTU = 26, 176a4d61e84SRoland Dreier IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27, 177a4d61e84SRoland Dreier IB_CM_REJ_CONSUMER_DEFINED = 28, 178a4d61e84SRoland Dreier IB_CM_REJ_INVALID_RNR_RETRY = 29, 179a4d61e84SRoland Dreier IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30, 180a4d61e84SRoland Dreier IB_CM_REJ_INVALID_CLASS_VERSION = 31, 181a4d61e84SRoland Dreier IB_CM_REJ_INVALID_FLOW_LABEL = 32, 182a4d61e84SRoland Dreier IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33 183a4d61e84SRoland Dreier }; 184a4d61e84SRoland Dreier 185a4d61e84SRoland Dreier struct ib_cm_rej_event_param { 186a4d61e84SRoland Dreier enum ib_cm_rej_reason reason; 187a4d61e84SRoland Dreier void *ari; 188a4d61e84SRoland Dreier u8 ari_length; 189a4d61e84SRoland Dreier }; 190a4d61e84SRoland Dreier 191a4d61e84SRoland Dreier struct ib_cm_mra_event_param { 192a4d61e84SRoland Dreier u8 service_timeout; 193a4d61e84SRoland Dreier }; 194a4d61e84SRoland Dreier 195a4d61e84SRoland Dreier struct ib_cm_lap_event_param { 196a4d61e84SRoland Dreier struct ib_sa_path_rec *alternate_path; 197a4d61e84SRoland Dreier }; 198a4d61e84SRoland Dreier 199a4d61e84SRoland Dreier enum ib_cm_apr_status { 200a4d61e84SRoland Dreier IB_CM_APR_SUCCESS, 201a4d61e84SRoland Dreier IB_CM_APR_INVALID_COMM_ID, 202a4d61e84SRoland Dreier IB_CM_APR_UNSUPPORTED, 203a4d61e84SRoland Dreier IB_CM_APR_REJECT, 204a4d61e84SRoland Dreier IB_CM_APR_REDIRECT, 205a4d61e84SRoland Dreier IB_CM_APR_IS_CURRENT, 206a4d61e84SRoland Dreier IB_CM_APR_INVALID_QPN_EECN, 207a4d61e84SRoland Dreier IB_CM_APR_INVALID_LID, 208a4d61e84SRoland Dreier IB_CM_APR_INVALID_GID, 209a4d61e84SRoland Dreier IB_CM_APR_INVALID_FLOW_LABEL, 210a4d61e84SRoland Dreier IB_CM_APR_INVALID_TCLASS, 211a4d61e84SRoland Dreier IB_CM_APR_INVALID_HOP_LIMIT, 212a4d61e84SRoland Dreier IB_CM_APR_INVALID_PACKET_RATE, 213a4d61e84SRoland Dreier IB_CM_APR_INVALID_SL 214a4d61e84SRoland Dreier }; 215a4d61e84SRoland Dreier 216a4d61e84SRoland Dreier struct ib_cm_apr_event_param { 217a4d61e84SRoland Dreier enum ib_cm_apr_status ap_status; 218a4d61e84SRoland Dreier void *apr_info; 219a4d61e84SRoland Dreier u8 info_len; 220a4d61e84SRoland Dreier }; 221a4d61e84SRoland Dreier 222a4d61e84SRoland Dreier struct ib_cm_sidr_req_event_param { 223a4d61e84SRoland Dreier struct ib_cm_id *listen_id; 224a4d61e84SRoland Dreier u8 port; 225a4d61e84SRoland Dreier u16 pkey; 226a4d61e84SRoland Dreier }; 227a4d61e84SRoland Dreier 228a4d61e84SRoland Dreier enum ib_cm_sidr_status { 229a4d61e84SRoland Dreier IB_SIDR_SUCCESS, 230a4d61e84SRoland Dreier IB_SIDR_UNSUPPORTED, 231a4d61e84SRoland Dreier IB_SIDR_REJECT, 232a4d61e84SRoland Dreier IB_SIDR_NO_QP, 233a4d61e84SRoland Dreier IB_SIDR_REDIRECT, 234a4d61e84SRoland Dreier IB_SIDR_UNSUPPORTED_VERSION 235a4d61e84SRoland Dreier }; 236a4d61e84SRoland Dreier 237a4d61e84SRoland Dreier struct ib_cm_sidr_rep_event_param { 238a4d61e84SRoland Dreier enum ib_cm_sidr_status status; 239a4d61e84SRoland Dreier u32 qkey; 240a4d61e84SRoland Dreier u32 qpn; 241a4d61e84SRoland Dreier void *info; 242a4d61e84SRoland Dreier u8 info_len; 243a4d61e84SRoland Dreier }; 244a4d61e84SRoland Dreier 245a4d61e84SRoland Dreier struct ib_cm_event { 246a4d61e84SRoland Dreier enum ib_cm_event_type event; 247a4d61e84SRoland Dreier union { 248a4d61e84SRoland Dreier struct ib_cm_req_event_param req_rcvd; 249a4d61e84SRoland Dreier struct ib_cm_rep_event_param rep_rcvd; 250a4d61e84SRoland Dreier /* No data for RTU received events. */ 251a4d61e84SRoland Dreier struct ib_cm_rej_event_param rej_rcvd; 252a4d61e84SRoland Dreier struct ib_cm_mra_event_param mra_rcvd; 253a4d61e84SRoland Dreier struct ib_cm_lap_event_param lap_rcvd; 254a4d61e84SRoland Dreier struct ib_cm_apr_event_param apr_rcvd; 255a4d61e84SRoland Dreier /* No data for DREQ/DREP received events. */ 256a4d61e84SRoland Dreier struct ib_cm_sidr_req_event_param sidr_req_rcvd; 257a4d61e84SRoland Dreier struct ib_cm_sidr_rep_event_param sidr_rep_rcvd; 258a4d61e84SRoland Dreier enum ib_wc_status send_status; 259a4d61e84SRoland Dreier } param; 260a4d61e84SRoland Dreier 261a4d61e84SRoland Dreier void *private_data; 262a4d61e84SRoland Dreier }; 263a4d61e84SRoland Dreier 264a4d61e84SRoland Dreier /** 265a4d61e84SRoland Dreier * ib_cm_handler - User-defined callback to process communication events. 266a4d61e84SRoland Dreier * @cm_id: Communication identifier associated with the reported event. 267a4d61e84SRoland Dreier * @event: Information about the communication event. 268a4d61e84SRoland Dreier * 269a4d61e84SRoland Dreier * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events 270a4d61e84SRoland Dreier * generated as a result of listen requests result in the allocation of a 271a4d61e84SRoland Dreier * new @cm_id. The new @cm_id is returned to the user through this callback. 272a4d61e84SRoland Dreier * Clients are responsible for destroying the new @cm_id. For peer-to-peer 273a4d61e84SRoland Dreier * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds 274a4d61e84SRoland Dreier * to a user's existing communication identifier. 275a4d61e84SRoland Dreier * 276a4d61e84SRoland Dreier * Users may not call ib_destroy_cm_id while in the context of this callback; 277a4d61e84SRoland Dreier * however, returning a non-zero value instructs the communication manager to 278a4d61e84SRoland Dreier * destroy the @cm_id after the callback completes. 279a4d61e84SRoland Dreier */ 280a4d61e84SRoland Dreier typedef int (*ib_cm_handler)(struct ib_cm_id *cm_id, 281a4d61e84SRoland Dreier struct ib_cm_event *event); 282a4d61e84SRoland Dreier 283a4d61e84SRoland Dreier struct ib_cm_id { 284a4d61e84SRoland Dreier ib_cm_handler cm_handler; 285a4d61e84SRoland Dreier void *context; 28607d357d0SSean Hefty struct ib_device *device; 287a4d61e84SRoland Dreier __be64 service_id; 288a4d61e84SRoland Dreier __be64 service_mask; 289a4d61e84SRoland Dreier enum ib_cm_state state; /* internal CM/debug use */ 290a4d61e84SRoland Dreier enum ib_cm_lap_state lap_state; /* internal CM/debug use */ 291a4d61e84SRoland Dreier __be32 local_id; 292a4d61e84SRoland Dreier __be32 remote_id; 293354ba39cSJohn Kingman u32 remote_cm_qpn; /* 1 unless redirected */ 294a4d61e84SRoland Dreier }; 295a4d61e84SRoland Dreier 296a4d61e84SRoland Dreier /** 297a4d61e84SRoland Dreier * ib_create_cm_id - Allocate a communication identifier. 29807d357d0SSean Hefty * @device: Device associated with the cm_id. All related communication will 29907d357d0SSean Hefty * be associated with the specified device. 300a4d61e84SRoland Dreier * @cm_handler: Callback invoked to notify the user of CM events. 301a4d61e84SRoland Dreier * @context: User specified context associated with the communication 302a4d61e84SRoland Dreier * identifier. 303a4d61e84SRoland Dreier * 304a4d61e84SRoland Dreier * Communication identifiers are used to track connection states, service 305a4d61e84SRoland Dreier * ID resolution requests, and listen requests. 306a4d61e84SRoland Dreier */ 30707d357d0SSean Hefty struct ib_cm_id *ib_create_cm_id(struct ib_device *device, 30807d357d0SSean Hefty ib_cm_handler cm_handler, 309a4d61e84SRoland Dreier void *context); 310a4d61e84SRoland Dreier 311a4d61e84SRoland Dreier /** 312a4d61e84SRoland Dreier * ib_destroy_cm_id - Destroy a connection identifier. 313a4d61e84SRoland Dreier * @cm_id: Connection identifier to destroy. 314a4d61e84SRoland Dreier * 315a4d61e84SRoland Dreier * This call blocks until the connection identifier is destroyed. 316a4d61e84SRoland Dreier */ 317a4d61e84SRoland Dreier void ib_destroy_cm_id(struct ib_cm_id *cm_id); 318a4d61e84SRoland Dreier 319a4d61e84SRoland Dreier #define IB_SERVICE_ID_AGN_MASK __constant_cpu_to_be64(0xFF00000000000000ULL) 320a4d61e84SRoland Dreier #define IB_CM_ASSIGN_SERVICE_ID __constant_cpu_to_be64(0x0200000000000000ULL) 3216e61d04fSSean Hefty #define IB_CMA_SERVICE_ID __constant_cpu_to_be64(0x0000000001000000ULL) 3226e61d04fSSean Hefty #define IB_CMA_SERVICE_ID_MASK __constant_cpu_to_be64(0xFFFFFFFFFF000000ULL) 3236e61d04fSSean Hefty #define IB_SDP_SERVICE_ID __constant_cpu_to_be64(0x0000000000010000ULL) 3246e61d04fSSean Hefty #define IB_SDP_SERVICE_ID_MASK __constant_cpu_to_be64(0xFFFFFFFFFFFF0000ULL) 3256e61d04fSSean Hefty 3266e61d04fSSean Hefty struct ib_cm_compare_data { 3276e61d04fSSean Hefty u8 data[IB_CM_COMPARE_SIZE]; 3286e61d04fSSean Hefty u8 mask[IB_CM_COMPARE_SIZE]; 3296e61d04fSSean Hefty }; 330a4d61e84SRoland Dreier 331a4d61e84SRoland Dreier /** 332a4d61e84SRoland Dreier * ib_cm_listen - Initiates listening on the specified service ID for 333a4d61e84SRoland Dreier * connection and service ID resolution requests. 334a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the listen request. 335a4d61e84SRoland Dreier * @service_id: Service identifier matched against incoming connection 336a4d61e84SRoland Dreier * and service ID resolution requests. The service ID should be specified 337a4d61e84SRoland Dreier * network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will 338a4d61e84SRoland Dreier * assign a service ID to the caller. 339a4d61e84SRoland Dreier * @service_mask: Mask applied to service ID used to listen across a 340a4d61e84SRoland Dreier * range of service IDs. If set to 0, the service ID is matched 341a4d61e84SRoland Dreier * exactly. This parameter is ignored if %service_id is set to 342a4d61e84SRoland Dreier * IB_CM_ASSIGN_SERVICE_ID. 3436e61d04fSSean Hefty * @compare_data: This parameter is optional. It specifies data that must 3446e61d04fSSean Hefty * appear in the private data of a connection request for the specified 3456e61d04fSSean Hefty * listen request. 346a4d61e84SRoland Dreier */ 3476e61d04fSSean Hefty int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask, 3486e61d04fSSean Hefty struct ib_cm_compare_data *compare_data); 349a4d61e84SRoland Dreier 350a4d61e84SRoland Dreier struct ib_cm_req_param { 351a4d61e84SRoland Dreier struct ib_sa_path_rec *primary_path; 352a4d61e84SRoland Dreier struct ib_sa_path_rec *alternate_path; 353a4d61e84SRoland Dreier __be64 service_id; 354a4d61e84SRoland Dreier u32 qp_num; 355a4d61e84SRoland Dreier enum ib_qp_type qp_type; 356a4d61e84SRoland Dreier u32 starting_psn; 357a4d61e84SRoland Dreier const void *private_data; 358a4d61e84SRoland Dreier u8 private_data_len; 359a4d61e84SRoland Dreier u8 peer_to_peer; 360a4d61e84SRoland Dreier u8 responder_resources; 361a4d61e84SRoland Dreier u8 initiator_depth; 362a4d61e84SRoland Dreier u8 remote_cm_response_timeout; 363a4d61e84SRoland Dreier u8 flow_control; 364a4d61e84SRoland Dreier u8 local_cm_response_timeout; 365a4d61e84SRoland Dreier u8 retry_count; 366a4d61e84SRoland Dreier u8 rnr_retry_count; 367a4d61e84SRoland Dreier u8 max_cm_retries; 368a4d61e84SRoland Dreier u8 srq; 369a4d61e84SRoland Dreier }; 370a4d61e84SRoland Dreier 371a4d61e84SRoland Dreier /** 372a4d61e84SRoland Dreier * ib_send_cm_req - Sends a connection request to the remote node. 373a4d61e84SRoland Dreier * @cm_id: Connection identifier that will be associated with the 374a4d61e84SRoland Dreier * connection request. 375a4d61e84SRoland Dreier * @param: Connection request information needed to establish the 376a4d61e84SRoland Dreier * connection. 377a4d61e84SRoland Dreier */ 378a4d61e84SRoland Dreier int ib_send_cm_req(struct ib_cm_id *cm_id, 379a4d61e84SRoland Dreier struct ib_cm_req_param *param); 380a4d61e84SRoland Dreier 381a4d61e84SRoland Dreier struct ib_cm_rep_param { 382a4d61e84SRoland Dreier u32 qp_num; 383a4d61e84SRoland Dreier u32 starting_psn; 384a4d61e84SRoland Dreier const void *private_data; 385a4d61e84SRoland Dreier u8 private_data_len; 386a4d61e84SRoland Dreier u8 responder_resources; 387a4d61e84SRoland Dreier u8 initiator_depth; 388a4d61e84SRoland Dreier u8 target_ack_delay; 389a4d61e84SRoland Dreier u8 failover_accepted; 390a4d61e84SRoland Dreier u8 flow_control; 391a4d61e84SRoland Dreier u8 rnr_retry_count; 392a4d61e84SRoland Dreier u8 srq; 393a4d61e84SRoland Dreier }; 394a4d61e84SRoland Dreier 395a4d61e84SRoland Dreier /** 396a4d61e84SRoland Dreier * ib_send_cm_rep - Sends a connection reply in response to a connection 397a4d61e84SRoland Dreier * request. 398a4d61e84SRoland Dreier * @cm_id: Connection identifier that will be associated with the 399a4d61e84SRoland Dreier * connection request. 400a4d61e84SRoland Dreier * @param: Connection reply information needed to establish the 401a4d61e84SRoland Dreier * connection. 402a4d61e84SRoland Dreier */ 403a4d61e84SRoland Dreier int ib_send_cm_rep(struct ib_cm_id *cm_id, 404a4d61e84SRoland Dreier struct ib_cm_rep_param *param); 405a4d61e84SRoland Dreier 406a4d61e84SRoland Dreier /** 407a4d61e84SRoland Dreier * ib_send_cm_rtu - Sends a connection ready to use message in response 408a4d61e84SRoland Dreier * to a connection reply message. 409a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the connection request. 410a4d61e84SRoland Dreier * @private_data: Optional user-defined private data sent with the 411a4d61e84SRoland Dreier * ready to use message. 412a4d61e84SRoland Dreier * @private_data_len: Size of the private data buffer, in bytes. 413a4d61e84SRoland Dreier */ 414a4d61e84SRoland Dreier int ib_send_cm_rtu(struct ib_cm_id *cm_id, 415a4d61e84SRoland Dreier const void *private_data, 416a4d61e84SRoland Dreier u8 private_data_len); 417a4d61e84SRoland Dreier 418a4d61e84SRoland Dreier /** 419a4d61e84SRoland Dreier * ib_send_cm_dreq - Sends a disconnection request for an existing 420a4d61e84SRoland Dreier * connection. 421a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the connection being 422a4d61e84SRoland Dreier * released. 423a4d61e84SRoland Dreier * @private_data: Optional user-defined private data sent with the 424a4d61e84SRoland Dreier * disconnection request message. 425a4d61e84SRoland Dreier * @private_data_len: Size of the private data buffer, in bytes. 426a4d61e84SRoland Dreier */ 427a4d61e84SRoland Dreier int ib_send_cm_dreq(struct ib_cm_id *cm_id, 428a4d61e84SRoland Dreier const void *private_data, 429a4d61e84SRoland Dreier u8 private_data_len); 430a4d61e84SRoland Dreier 431a4d61e84SRoland Dreier /** 432a4d61e84SRoland Dreier * ib_send_cm_drep - Sends a disconnection reply to a disconnection request. 433a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the connection being 434a4d61e84SRoland Dreier * released. 435a4d61e84SRoland Dreier * @private_data: Optional user-defined private data sent with the 436a4d61e84SRoland Dreier * disconnection reply message. 437a4d61e84SRoland Dreier * @private_data_len: Size of the private data buffer, in bytes. 438a4d61e84SRoland Dreier * 439a4d61e84SRoland Dreier * If the cm_id is in the correct state, the CM will transition the connection 440a4d61e84SRoland Dreier * to the timewait state, even if an error occurs sending the DREP message. 441a4d61e84SRoland Dreier */ 442a4d61e84SRoland Dreier int ib_send_cm_drep(struct ib_cm_id *cm_id, 443a4d61e84SRoland Dreier const void *private_data, 444a4d61e84SRoland Dreier u8 private_data_len); 445a4d61e84SRoland Dreier 446a4d61e84SRoland Dreier /** 447e1444b5aSSean Hefty * ib_cm_notify - Notifies the CM of an event reported to the consumer. 448a4d61e84SRoland Dreier * @cm_id: Connection identifier to transition to established. 449e1444b5aSSean Hefty * @event: Type of event. 450a4d61e84SRoland Dreier * 451e1444b5aSSean Hefty * This routine should be invoked by users to notify the CM of relevant 452e1444b5aSSean Hefty * communication events. Events that should be reported to the CM and 453e1444b5aSSean Hefty * when to report them are: 454e1444b5aSSean Hefty * 455e1444b5aSSean Hefty * IB_EVENT_COMM_EST - Used when a message is received on a connected 456e1444b5aSSean Hefty * QP before an RTU has been received. 457e1444b5aSSean Hefty * IB_EVENT_PATH_MIG - Notifies the CM that the connection has failed over 458e1444b5aSSean Hefty * to the alternate path. 459a4d61e84SRoland Dreier */ 460e1444b5aSSean Hefty int ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event); 461a4d61e84SRoland Dreier 462a4d61e84SRoland Dreier /** 463a4d61e84SRoland Dreier * ib_send_cm_rej - Sends a connection rejection message to the 464a4d61e84SRoland Dreier * remote node. 465a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the connection being 466a4d61e84SRoland Dreier * rejected. 467a4d61e84SRoland Dreier * @reason: Reason for the connection request rejection. 468a4d61e84SRoland Dreier * @ari: Optional additional rejection information. 469a4d61e84SRoland Dreier * @ari_length: Size of the additional rejection information, in bytes. 470a4d61e84SRoland Dreier * @private_data: Optional user-defined private data sent with the 471a4d61e84SRoland Dreier * rejection message. 472a4d61e84SRoland Dreier * @private_data_len: Size of the private data buffer, in bytes. 473a4d61e84SRoland Dreier */ 474a4d61e84SRoland Dreier int ib_send_cm_rej(struct ib_cm_id *cm_id, 475a4d61e84SRoland Dreier enum ib_cm_rej_reason reason, 476a4d61e84SRoland Dreier void *ari, 477a4d61e84SRoland Dreier u8 ari_length, 478a4d61e84SRoland Dreier const void *private_data, 479a4d61e84SRoland Dreier u8 private_data_len); 480a4d61e84SRoland Dreier 481a4d61e84SRoland Dreier /** 482a4d61e84SRoland Dreier * ib_send_cm_mra - Sends a message receipt acknowledgement to a connection 483a4d61e84SRoland Dreier * message. 484a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the connection message. 485a4d61e84SRoland Dreier * @service_timeout: The maximum time required for the sender to reply to 486a4d61e84SRoland Dreier * to the connection message. 487a4d61e84SRoland Dreier * @private_data: Optional user-defined private data sent with the 488a4d61e84SRoland Dreier * message receipt acknowledgement. 489a4d61e84SRoland Dreier * @private_data_len: Size of the private data buffer, in bytes. 490a4d61e84SRoland Dreier */ 491a4d61e84SRoland Dreier int ib_send_cm_mra(struct ib_cm_id *cm_id, 492a4d61e84SRoland Dreier u8 service_timeout, 493a4d61e84SRoland Dreier const void *private_data, 494a4d61e84SRoland Dreier u8 private_data_len); 495a4d61e84SRoland Dreier 496a4d61e84SRoland Dreier /** 497a4d61e84SRoland Dreier * ib_send_cm_lap - Sends a load alternate path request. 498a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the load alternate path 499a4d61e84SRoland Dreier * message. 500a4d61e84SRoland Dreier * @alternate_path: A path record that identifies the alternate path to 501a4d61e84SRoland Dreier * load. 502a4d61e84SRoland Dreier * @private_data: Optional user-defined private data sent with the 503a4d61e84SRoland Dreier * load alternate path message. 504a4d61e84SRoland Dreier * @private_data_len: Size of the private data buffer, in bytes. 505a4d61e84SRoland Dreier */ 506a4d61e84SRoland Dreier int ib_send_cm_lap(struct ib_cm_id *cm_id, 507a4d61e84SRoland Dreier struct ib_sa_path_rec *alternate_path, 508a4d61e84SRoland Dreier const void *private_data, 509a4d61e84SRoland Dreier u8 private_data_len); 510a4d61e84SRoland Dreier 511a4d61e84SRoland Dreier /** 512a4d61e84SRoland Dreier * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning 513a4d61e84SRoland Dreier * to a specified QP state. 514a4d61e84SRoland Dreier * @cm_id: Communication identifier associated with the QP attributes to 515a4d61e84SRoland Dreier * initialize. 516a4d61e84SRoland Dreier * @qp_attr: On input, specifies the desired QP state. On output, the 517a4d61e84SRoland Dreier * mandatory and desired optional attributes will be set in order to 518a4d61e84SRoland Dreier * modify the QP to the specified state. 519a4d61e84SRoland Dreier * @qp_attr_mask: The QP attribute mask that may be used to transition the 520a4d61e84SRoland Dreier * QP to the specified state. 521a4d61e84SRoland Dreier * 522a4d61e84SRoland Dreier * Users must set the @qp_attr->qp_state to the desired QP state. This call 523a4d61e84SRoland Dreier * will set all required attributes for the given transition, along with 524a4d61e84SRoland Dreier * known optional attributes. Users may override the attributes returned from 525a4d61e84SRoland Dreier * this call before calling ib_modify_qp. 526a4d61e84SRoland Dreier */ 527a4d61e84SRoland Dreier int ib_cm_init_qp_attr(struct ib_cm_id *cm_id, 528a4d61e84SRoland Dreier struct ib_qp_attr *qp_attr, 529a4d61e84SRoland Dreier int *qp_attr_mask); 530a4d61e84SRoland Dreier 531a4d61e84SRoland Dreier /** 532a4d61e84SRoland Dreier * ib_send_cm_apr - Sends an alternate path response message in response to 533a4d61e84SRoland Dreier * a load alternate path request. 534a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the alternate path response. 535a4d61e84SRoland Dreier * @status: Reply status sent with the alternate path response. 536a4d61e84SRoland Dreier * @info: Optional additional information sent with the alternate path 537a4d61e84SRoland Dreier * response. 538a4d61e84SRoland Dreier * @info_length: Size of the additional information, in bytes. 539a4d61e84SRoland Dreier * @private_data: Optional user-defined private data sent with the 540a4d61e84SRoland Dreier * alternate path response message. 541a4d61e84SRoland Dreier * @private_data_len: Size of the private data buffer, in bytes. 542a4d61e84SRoland Dreier */ 543a4d61e84SRoland Dreier int ib_send_cm_apr(struct ib_cm_id *cm_id, 544a4d61e84SRoland Dreier enum ib_cm_apr_status status, 545a4d61e84SRoland Dreier void *info, 546a4d61e84SRoland Dreier u8 info_length, 547a4d61e84SRoland Dreier const void *private_data, 548a4d61e84SRoland Dreier u8 private_data_len); 549a4d61e84SRoland Dreier 550a4d61e84SRoland Dreier struct ib_cm_sidr_req_param { 551a4d61e84SRoland Dreier struct ib_sa_path_rec *path; 552a4d61e84SRoland Dreier __be64 service_id; 553a4d61e84SRoland Dreier int timeout_ms; 554a4d61e84SRoland Dreier const void *private_data; 555a4d61e84SRoland Dreier u8 private_data_len; 556a4d61e84SRoland Dreier u8 max_cm_retries; 557a4d61e84SRoland Dreier }; 558a4d61e84SRoland Dreier 559a4d61e84SRoland Dreier /** 560a4d61e84SRoland Dreier * ib_send_cm_sidr_req - Sends a service ID resolution request to the 561a4d61e84SRoland Dreier * remote node. 562a4d61e84SRoland Dreier * @cm_id: Communication identifier that will be associated with the 563a4d61e84SRoland Dreier * service ID resolution request. 564a4d61e84SRoland Dreier * @param: Service ID resolution request information. 565a4d61e84SRoland Dreier */ 566a4d61e84SRoland Dreier int ib_send_cm_sidr_req(struct ib_cm_id *cm_id, 567a4d61e84SRoland Dreier struct ib_cm_sidr_req_param *param); 568a4d61e84SRoland Dreier 569a4d61e84SRoland Dreier struct ib_cm_sidr_rep_param { 570a4d61e84SRoland Dreier u32 qp_num; 571a4d61e84SRoland Dreier u32 qkey; 572a4d61e84SRoland Dreier enum ib_cm_sidr_status status; 573a4d61e84SRoland Dreier const void *info; 574a4d61e84SRoland Dreier u8 info_length; 575a4d61e84SRoland Dreier const void *private_data; 576a4d61e84SRoland Dreier u8 private_data_len; 577a4d61e84SRoland Dreier }; 578a4d61e84SRoland Dreier 579a4d61e84SRoland Dreier /** 58075af9088SSean Hefty * ib_send_cm_sidr_rep - Sends a service ID resolution reply to the 581a4d61e84SRoland Dreier * remote node. 582a4d61e84SRoland Dreier * @cm_id: Communication identifier associated with the received service ID 583a4d61e84SRoland Dreier * resolution request. 584a4d61e84SRoland Dreier * @param: Service ID resolution reply information. 585a4d61e84SRoland Dreier */ 586a4d61e84SRoland Dreier int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id, 587a4d61e84SRoland Dreier struct ib_cm_sidr_rep_param *param); 588a4d61e84SRoland Dreier 589a4d61e84SRoland Dreier #endif /* IB_CM_H */ 590