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