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 */ 35a4d61e84SRoland Dreier #if !defined(IB_CM_H) 36a4d61e84SRoland Dreier #define IB_CM_H 37a4d61e84SRoland Dreier 38a4d61e84SRoland Dreier #include <rdma/ib_mad.h> 39a4d61e84SRoland Dreier #include <rdma/ib_sa.h> 40a4d61e84SRoland Dreier 41c89d1bedSSean Hefty /* ib_cm and ib_user_cm modules share /sys/class/infiniband_cm */ 42c89d1bedSSean Hefty extern struct class cm_class; 43c89d1bedSSean Hefty 44a4d61e84SRoland Dreier enum ib_cm_state { 45a4d61e84SRoland Dreier IB_CM_IDLE, 46a4d61e84SRoland Dreier IB_CM_LISTEN, 47a4d61e84SRoland Dreier IB_CM_REQ_SENT, 48a4d61e84SRoland Dreier IB_CM_REQ_RCVD, 49a4d61e84SRoland Dreier IB_CM_MRA_REQ_SENT, 50a4d61e84SRoland Dreier IB_CM_MRA_REQ_RCVD, 51a4d61e84SRoland Dreier IB_CM_REP_SENT, 52a4d61e84SRoland Dreier IB_CM_REP_RCVD, 53a4d61e84SRoland Dreier IB_CM_MRA_REP_SENT, 54a4d61e84SRoland Dreier IB_CM_MRA_REP_RCVD, 55a4d61e84SRoland Dreier IB_CM_ESTABLISHED, 56a4d61e84SRoland Dreier IB_CM_DREQ_SENT, 57a4d61e84SRoland Dreier IB_CM_DREQ_RCVD, 58a4d61e84SRoland Dreier IB_CM_TIMEWAIT, 59a4d61e84SRoland Dreier IB_CM_SIDR_REQ_SENT, 60a4d61e84SRoland Dreier IB_CM_SIDR_REQ_RCVD 61a4d61e84SRoland Dreier }; 62a4d61e84SRoland Dreier 63a4d61e84SRoland Dreier enum ib_cm_lap_state { 64e1444b5aSSean Hefty IB_CM_LAP_UNINIT, 65a4d61e84SRoland Dreier IB_CM_LAP_IDLE, 66a4d61e84SRoland Dreier IB_CM_LAP_SENT, 67a4d61e84SRoland Dreier IB_CM_LAP_RCVD, 68a4d61e84SRoland Dreier IB_CM_MRA_LAP_SENT, 69a4d61e84SRoland Dreier IB_CM_MRA_LAP_RCVD, 70a4d61e84SRoland Dreier }; 71a4d61e84SRoland Dreier 72a4d61e84SRoland Dreier enum ib_cm_event_type { 73a4d61e84SRoland Dreier IB_CM_REQ_ERROR, 74a4d61e84SRoland Dreier IB_CM_REQ_RECEIVED, 75a4d61e84SRoland Dreier IB_CM_REP_ERROR, 76a4d61e84SRoland Dreier IB_CM_REP_RECEIVED, 77a4d61e84SRoland Dreier IB_CM_RTU_RECEIVED, 78a4d61e84SRoland Dreier IB_CM_USER_ESTABLISHED, 79a4d61e84SRoland Dreier IB_CM_DREQ_ERROR, 80a4d61e84SRoland Dreier IB_CM_DREQ_RECEIVED, 81a4d61e84SRoland Dreier IB_CM_DREP_RECEIVED, 82a4d61e84SRoland Dreier IB_CM_TIMEWAIT_EXIT, 83a4d61e84SRoland Dreier IB_CM_MRA_RECEIVED, 84a4d61e84SRoland Dreier IB_CM_REJ_RECEIVED, 85a4d61e84SRoland Dreier IB_CM_LAP_ERROR, 86a4d61e84SRoland Dreier IB_CM_LAP_RECEIVED, 87a4d61e84SRoland Dreier IB_CM_APR_RECEIVED, 88a4d61e84SRoland Dreier IB_CM_SIDR_REQ_ERROR, 89a4d61e84SRoland Dreier IB_CM_SIDR_REQ_RECEIVED, 90a4d61e84SRoland Dreier IB_CM_SIDR_REP_RECEIVED 91a4d61e84SRoland Dreier }; 92a4d61e84SRoland Dreier 93a4d61e84SRoland Dreier enum ib_cm_data_size { 94a4d61e84SRoland Dreier IB_CM_REQ_PRIVATE_DATA_SIZE = 92, 95a4d61e84SRoland Dreier IB_CM_MRA_PRIVATE_DATA_SIZE = 222, 96a4d61e84SRoland Dreier IB_CM_REJ_PRIVATE_DATA_SIZE = 148, 97a4d61e84SRoland Dreier IB_CM_REP_PRIVATE_DATA_SIZE = 196, 98a4d61e84SRoland Dreier IB_CM_RTU_PRIVATE_DATA_SIZE = 224, 99a4d61e84SRoland Dreier IB_CM_DREQ_PRIVATE_DATA_SIZE = 220, 100a4d61e84SRoland Dreier IB_CM_DREP_PRIVATE_DATA_SIZE = 224, 101a4d61e84SRoland Dreier IB_CM_REJ_ARI_LENGTH = 72, 102a4d61e84SRoland Dreier IB_CM_LAP_PRIVATE_DATA_SIZE = 168, 103a4d61e84SRoland Dreier IB_CM_APR_PRIVATE_DATA_SIZE = 148, 104a4d61e84SRoland Dreier IB_CM_APR_INFO_LENGTH = 72, 105a4d61e84SRoland Dreier IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216, 106a4d61e84SRoland Dreier IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136, 1076e61d04fSSean Hefty IB_CM_SIDR_REP_INFO_LENGTH = 72, 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; 11424cad9a7SHaggai Eran 11524cad9a7SHaggai Eran /* P_Key that was used by the GMP's BTH header */ 11624cad9a7SHaggai Eran u16 bth_pkey; 11724cad9a7SHaggai Eran 118a4d61e84SRoland Dreier u8 port; 119a4d61e84SRoland Dreier 120c2f8fc4eSDasaratharaman Chandramouli struct sa_path_rec *primary_path; 121c2f8fc4eSDasaratharaman Chandramouli struct sa_path_rec *alternate_path; 122a4d61e84SRoland Dreier 123cee10433SParav Pandit /* 124cee10433SParav Pandit * SGID attribute of the primary path. Currently only 125cee10433SParav Pandit * useful for RoCE. Alternate path GID attributes 126cee10433SParav Pandit * are not yet supported. 127cee10433SParav Pandit */ 128cee10433SParav Pandit const struct ib_gid_attr *ppath_sgid_attr; 129cee10433SParav Pandit 130a4d61e84SRoland Dreier __be64 remote_ca_guid; 131a4d61e84SRoland Dreier u32 remote_qkey; 132a4d61e84SRoland Dreier u32 remote_qpn; 133a4d61e84SRoland Dreier enum ib_qp_type qp_type; 134a4d61e84SRoland Dreier 135a4d61e84SRoland Dreier u32 starting_psn; 136a4d61e84SRoland Dreier u8 responder_resources; 137a4d61e84SRoland Dreier u8 initiator_depth; 138a4d61e84SRoland Dreier unsigned int local_cm_response_timeout:5; 139a4d61e84SRoland Dreier unsigned int flow_control:1; 140a4d61e84SRoland Dreier unsigned int remote_cm_response_timeout:5; 141a4d61e84SRoland Dreier unsigned int retry_count:3; 142a4d61e84SRoland Dreier unsigned int rnr_retry_count:3; 143a4d61e84SRoland Dreier unsigned int srq:1; 144a4d61e84SRoland Dreier }; 145a4d61e84SRoland Dreier 146a4d61e84SRoland Dreier struct ib_cm_rep_event_param { 147a4d61e84SRoland Dreier __be64 remote_ca_guid; 148a4d61e84SRoland Dreier u32 remote_qkey; 149a4d61e84SRoland Dreier u32 remote_qpn; 150a4d61e84SRoland Dreier u32 starting_psn; 151a4d61e84SRoland Dreier u8 responder_resources; 152a4d61e84SRoland Dreier u8 initiator_depth; 153a4d61e84SRoland Dreier unsigned int target_ack_delay:5; 154a4d61e84SRoland Dreier unsigned int failover_accepted:2; 155a4d61e84SRoland Dreier unsigned int flow_control:1; 156a4d61e84SRoland Dreier unsigned int rnr_retry_count:3; 157a4d61e84SRoland Dreier unsigned int srq:1; 158a4d61e84SRoland Dreier }; 159a4d61e84SRoland Dreier 160a4d61e84SRoland Dreier enum ib_cm_rej_reason { 161a4d61e84SRoland Dreier IB_CM_REJ_NO_QP = 1, 162a4d61e84SRoland Dreier IB_CM_REJ_NO_EEC = 2, 163a4d61e84SRoland Dreier IB_CM_REJ_NO_RESOURCES = 3, 164a4d61e84SRoland Dreier IB_CM_REJ_TIMEOUT = 4, 165a4d61e84SRoland Dreier IB_CM_REJ_UNSUPPORTED = 5, 166a4d61e84SRoland Dreier IB_CM_REJ_INVALID_COMM_ID = 6, 167a4d61e84SRoland Dreier IB_CM_REJ_INVALID_COMM_INSTANCE = 7, 168a4d61e84SRoland Dreier IB_CM_REJ_INVALID_SERVICE_ID = 8, 169a4d61e84SRoland Dreier IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9, 170a4d61e84SRoland Dreier IB_CM_REJ_STALE_CONN = 10, 171a4d61e84SRoland Dreier IB_CM_REJ_RDC_NOT_EXIST = 11, 172a4d61e84SRoland Dreier IB_CM_REJ_INVALID_GID = 12, 173a4d61e84SRoland Dreier IB_CM_REJ_INVALID_LID = 13, 174a4d61e84SRoland Dreier IB_CM_REJ_INVALID_SL = 14, 175a4d61e84SRoland Dreier IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15, 176a4d61e84SRoland Dreier IB_CM_REJ_INVALID_HOP_LIMIT = 16, 177a4d61e84SRoland Dreier IB_CM_REJ_INVALID_PACKET_RATE = 17, 178a4d61e84SRoland Dreier IB_CM_REJ_INVALID_ALT_GID = 18, 179a4d61e84SRoland Dreier IB_CM_REJ_INVALID_ALT_LID = 19, 180a4d61e84SRoland Dreier IB_CM_REJ_INVALID_ALT_SL = 20, 181a4d61e84SRoland Dreier IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21, 182a4d61e84SRoland Dreier IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22, 183a4d61e84SRoland Dreier IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23, 184a4d61e84SRoland Dreier IB_CM_REJ_PORT_CM_REDIRECT = 24, 185a4d61e84SRoland Dreier IB_CM_REJ_PORT_REDIRECT = 25, 186a4d61e84SRoland Dreier IB_CM_REJ_INVALID_MTU = 26, 187a4d61e84SRoland Dreier IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27, 188a4d61e84SRoland Dreier IB_CM_REJ_CONSUMER_DEFINED = 28, 189a4d61e84SRoland Dreier IB_CM_REJ_INVALID_RNR_RETRY = 29, 190a4d61e84SRoland Dreier IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30, 191a4d61e84SRoland Dreier IB_CM_REJ_INVALID_CLASS_VERSION = 31, 192a4d61e84SRoland Dreier IB_CM_REJ_INVALID_FLOW_LABEL = 32, 193a4d61e84SRoland Dreier IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33 194a4d61e84SRoland Dreier }; 195a4d61e84SRoland Dreier 196a4d61e84SRoland Dreier struct ib_cm_rej_event_param { 197a4d61e84SRoland Dreier enum ib_cm_rej_reason reason; 198a4d61e84SRoland Dreier void *ari; 199a4d61e84SRoland Dreier u8 ari_length; 200a4d61e84SRoland Dreier }; 201a4d61e84SRoland Dreier 202a4d61e84SRoland Dreier struct ib_cm_mra_event_param { 203a4d61e84SRoland Dreier u8 service_timeout; 204a4d61e84SRoland Dreier }; 205a4d61e84SRoland Dreier 206a4d61e84SRoland Dreier struct ib_cm_lap_event_param { 207c2f8fc4eSDasaratharaman Chandramouli struct sa_path_rec *alternate_path; 208a4d61e84SRoland Dreier }; 209a4d61e84SRoland Dreier 210a4d61e84SRoland Dreier enum ib_cm_apr_status { 211a4d61e84SRoland Dreier IB_CM_APR_SUCCESS, 212a4d61e84SRoland Dreier IB_CM_APR_INVALID_COMM_ID, 213a4d61e84SRoland Dreier IB_CM_APR_UNSUPPORTED, 214a4d61e84SRoland Dreier IB_CM_APR_REJECT, 215a4d61e84SRoland Dreier IB_CM_APR_REDIRECT, 216a4d61e84SRoland Dreier IB_CM_APR_IS_CURRENT, 217a4d61e84SRoland Dreier IB_CM_APR_INVALID_QPN_EECN, 218a4d61e84SRoland Dreier IB_CM_APR_INVALID_LID, 219a4d61e84SRoland Dreier IB_CM_APR_INVALID_GID, 220a4d61e84SRoland Dreier IB_CM_APR_INVALID_FLOW_LABEL, 221a4d61e84SRoland Dreier IB_CM_APR_INVALID_TCLASS, 222a4d61e84SRoland Dreier IB_CM_APR_INVALID_HOP_LIMIT, 223a4d61e84SRoland Dreier IB_CM_APR_INVALID_PACKET_RATE, 224a4d61e84SRoland Dreier IB_CM_APR_INVALID_SL 225a4d61e84SRoland Dreier }; 226a4d61e84SRoland Dreier 227a4d61e84SRoland Dreier struct ib_cm_apr_event_param { 228a4d61e84SRoland Dreier enum ib_cm_apr_status ap_status; 229a4d61e84SRoland Dreier void *apr_info; 230a4d61e84SRoland Dreier u8 info_len; 231a4d61e84SRoland Dreier }; 232a4d61e84SRoland Dreier 233a4d61e84SRoland Dreier struct ib_cm_sidr_req_event_param { 234a4d61e84SRoland Dreier struct ib_cm_id *listen_id; 23515865e7dSHaggai Eran __be64 service_id; 236cee10433SParav Pandit 237cee10433SParav Pandit /* 238cee10433SParav Pandit * SGID attribute of the request. Currently only 239cee10433SParav Pandit * useful for RoCE. 240cee10433SParav Pandit */ 241cee10433SParav Pandit const struct ib_gid_attr *sgid_attr; 24224cad9a7SHaggai Eran /* P_Key that was used by the GMP's BTH header */ 24324cad9a7SHaggai Eran u16 bth_pkey; 244a4d61e84SRoland Dreier u8 port; 245a4d61e84SRoland Dreier u16 pkey; 246a4d61e84SRoland Dreier }; 247a4d61e84SRoland Dreier 248a4d61e84SRoland Dreier enum ib_cm_sidr_status { 249a4d61e84SRoland Dreier IB_SIDR_SUCCESS, 250a4d61e84SRoland Dreier IB_SIDR_UNSUPPORTED, 251a4d61e84SRoland Dreier IB_SIDR_REJECT, 252a4d61e84SRoland Dreier IB_SIDR_NO_QP, 253a4d61e84SRoland Dreier IB_SIDR_REDIRECT, 254a4d61e84SRoland Dreier IB_SIDR_UNSUPPORTED_VERSION 255a4d61e84SRoland Dreier }; 256a4d61e84SRoland Dreier 257a4d61e84SRoland Dreier struct ib_cm_sidr_rep_event_param { 258a4d61e84SRoland Dreier enum ib_cm_sidr_status status; 259a4d61e84SRoland Dreier u32 qkey; 260a4d61e84SRoland Dreier u32 qpn; 261a4d61e84SRoland Dreier void *info; 262815d456eSParav Pandit const struct ib_gid_attr *sgid_attr; 263a4d61e84SRoland Dreier u8 info_len; 264a4d61e84SRoland Dreier }; 265a4d61e84SRoland Dreier 266a4d61e84SRoland Dreier struct ib_cm_event { 267a4d61e84SRoland Dreier enum ib_cm_event_type event; 268a4d61e84SRoland Dreier union { 269a4d61e84SRoland Dreier struct ib_cm_req_event_param req_rcvd; 270a4d61e84SRoland Dreier struct ib_cm_rep_event_param rep_rcvd; 271a4d61e84SRoland Dreier /* No data for RTU received events. */ 272a4d61e84SRoland Dreier struct ib_cm_rej_event_param rej_rcvd; 273a4d61e84SRoland Dreier struct ib_cm_mra_event_param mra_rcvd; 274a4d61e84SRoland Dreier struct ib_cm_lap_event_param lap_rcvd; 275a4d61e84SRoland Dreier struct ib_cm_apr_event_param apr_rcvd; 276a4d61e84SRoland Dreier /* No data for DREQ/DREP received events. */ 277a4d61e84SRoland Dreier struct ib_cm_sidr_req_event_param sidr_req_rcvd; 278a4d61e84SRoland Dreier struct ib_cm_sidr_rep_event_param sidr_rep_rcvd; 279a4d61e84SRoland Dreier enum ib_wc_status send_status; 280a4d61e84SRoland Dreier } param; 281a4d61e84SRoland Dreier 282a4d61e84SRoland Dreier void *private_data; 283a4d61e84SRoland Dreier }; 284a4d61e84SRoland Dreier 2853045f092SJack Morgenstein #define CM_REQ_ATTR_ID cpu_to_be16(0x0010) 2863045f092SJack Morgenstein #define CM_MRA_ATTR_ID cpu_to_be16(0x0011) 2873045f092SJack Morgenstein #define CM_REJ_ATTR_ID cpu_to_be16(0x0012) 2883045f092SJack Morgenstein #define CM_REP_ATTR_ID cpu_to_be16(0x0013) 2893045f092SJack Morgenstein #define CM_RTU_ATTR_ID cpu_to_be16(0x0014) 2903045f092SJack Morgenstein #define CM_DREQ_ATTR_ID cpu_to_be16(0x0015) 2913045f092SJack Morgenstein #define CM_DREP_ATTR_ID cpu_to_be16(0x0016) 2923045f092SJack Morgenstein #define CM_SIDR_REQ_ATTR_ID cpu_to_be16(0x0017) 2933045f092SJack Morgenstein #define CM_SIDR_REP_ATTR_ID cpu_to_be16(0x0018) 2943045f092SJack Morgenstein #define CM_LAP_ATTR_ID cpu_to_be16(0x0019) 2953045f092SJack Morgenstein #define CM_APR_ATTR_ID cpu_to_be16(0x001A) 2963045f092SJack Morgenstein 297a4d61e84SRoland Dreier /** 298a4d61e84SRoland Dreier * ib_cm_handler - User-defined callback to process communication events. 299a4d61e84SRoland Dreier * @cm_id: Communication identifier associated with the reported event. 300a4d61e84SRoland Dreier * @event: Information about the communication event. 301a4d61e84SRoland Dreier * 302a4d61e84SRoland Dreier * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events 303a4d61e84SRoland Dreier * generated as a result of listen requests result in the allocation of a 304a4d61e84SRoland Dreier * new @cm_id. The new @cm_id is returned to the user through this callback. 305a4d61e84SRoland Dreier * Clients are responsible for destroying the new @cm_id. For peer-to-peer 306a4d61e84SRoland Dreier * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds 307a4d61e84SRoland Dreier * to a user's existing communication identifier. 308a4d61e84SRoland Dreier * 309a4d61e84SRoland Dreier * Users may not call ib_destroy_cm_id while in the context of this callback; 310a4d61e84SRoland Dreier * however, returning a non-zero value instructs the communication manager to 311a4d61e84SRoland Dreier * destroy the @cm_id after the callback completes. 312a4d61e84SRoland Dreier */ 313a4d61e84SRoland Dreier typedef int (*ib_cm_handler)(struct ib_cm_id *cm_id, 314e7ff98aeSParav Pandit const struct ib_cm_event *event); 315a4d61e84SRoland Dreier 316a4d61e84SRoland Dreier struct ib_cm_id { 317a4d61e84SRoland Dreier ib_cm_handler cm_handler; 318a4d61e84SRoland Dreier void *context; 31907d357d0SSean Hefty struct ib_device *device; 320a4d61e84SRoland Dreier __be64 service_id; 321a4d61e84SRoland Dreier __be64 service_mask; 322a4d61e84SRoland Dreier enum ib_cm_state state; /* internal CM/debug use */ 323a4d61e84SRoland Dreier enum ib_cm_lap_state lap_state; /* internal CM/debug use */ 324a4d61e84SRoland Dreier __be32 local_id; 325a4d61e84SRoland Dreier __be32 remote_id; 326354ba39cSJohn Kingman u32 remote_cm_qpn; /* 1 unless redirected */ 327a4d61e84SRoland Dreier }; 328a4d61e84SRoland Dreier 329a4d61e84SRoland Dreier /** 330a4d61e84SRoland Dreier * ib_create_cm_id - Allocate a communication identifier. 33107d357d0SSean Hefty * @device: Device associated with the cm_id. All related communication will 33207d357d0SSean Hefty * be associated with the specified device. 333a4d61e84SRoland Dreier * @cm_handler: Callback invoked to notify the user of CM events. 334a4d61e84SRoland Dreier * @context: User specified context associated with the communication 335a4d61e84SRoland Dreier * identifier. 336a4d61e84SRoland Dreier * 337a4d61e84SRoland Dreier * Communication identifiers are used to track connection states, service 338a4d61e84SRoland Dreier * ID resolution requests, and listen requests. 339a4d61e84SRoland Dreier */ 34007d357d0SSean Hefty struct ib_cm_id *ib_create_cm_id(struct ib_device *device, 34107d357d0SSean Hefty ib_cm_handler cm_handler, 342a4d61e84SRoland Dreier void *context); 343a4d61e84SRoland Dreier 344a4d61e84SRoland Dreier /** 345a4d61e84SRoland Dreier * ib_destroy_cm_id - Destroy a connection identifier. 346a4d61e84SRoland Dreier * @cm_id: Connection identifier to destroy. 347a4d61e84SRoland Dreier * 348a4d61e84SRoland Dreier * This call blocks until the connection identifier is destroyed. 349a4d61e84SRoland Dreier */ 350a4d61e84SRoland Dreier void ib_destroy_cm_id(struct ib_cm_id *cm_id); 351a4d61e84SRoland Dreier 3529c3da099SHarvey Harrison #define IB_SERVICE_ID_AGN_MASK cpu_to_be64(0xFF00000000000000ULL) 3539c3da099SHarvey Harrison #define IB_CM_ASSIGN_SERVICE_ID cpu_to_be64(0x0200000000000000ULL) 3549c3da099SHarvey Harrison #define IB_CMA_SERVICE_ID cpu_to_be64(0x0000000001000000ULL) 3559c3da099SHarvey Harrison #define IB_CMA_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFF000000ULL) 3569c3da099SHarvey Harrison #define IB_SDP_SERVICE_ID cpu_to_be64(0x0000000000010000ULL) 3579c3da099SHarvey Harrison #define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL) 3586e61d04fSSean Hefty 359a4d61e84SRoland Dreier /** 360a4d61e84SRoland Dreier * ib_cm_listen - Initiates listening on the specified service ID for 361a4d61e84SRoland Dreier * connection and service ID resolution requests. 362a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the listen request. 363a4d61e84SRoland Dreier * @service_id: Service identifier matched against incoming connection 364a4d61e84SRoland Dreier * and service ID resolution requests. The service ID should be specified 365a4d61e84SRoland Dreier * network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will 366a4d61e84SRoland Dreier * assign a service ID to the caller. 367a4d61e84SRoland Dreier * @service_mask: Mask applied to service ID used to listen across a 368a4d61e84SRoland Dreier * range of service IDs. If set to 0, the service ID is matched 369a4d61e84SRoland Dreier * exactly. This parameter is ignored if %service_id is set to 370a4d61e84SRoland Dreier * IB_CM_ASSIGN_SERVICE_ID. 371a4d61e84SRoland Dreier */ 37273fec7fdSHaggai Eran int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, 37373fec7fdSHaggai Eran __be64 service_mask); 374a4d61e84SRoland Dreier 375067b171bSHaggai Eran struct ib_cm_id *ib_cm_insert_listen(struct ib_device *device, 376067b171bSHaggai Eran ib_cm_handler cm_handler, 377067b171bSHaggai Eran __be64 service_id); 378067b171bSHaggai Eran 379a4d61e84SRoland Dreier struct ib_cm_req_param { 380c2f8fc4eSDasaratharaman Chandramouli struct sa_path_rec *primary_path; 381c2f8fc4eSDasaratharaman Chandramouli struct sa_path_rec *alternate_path; 382815d456eSParav Pandit const struct ib_gid_attr *ppath_sgid_attr; 383a4d61e84SRoland Dreier __be64 service_id; 384a4d61e84SRoland Dreier u32 qp_num; 385a4d61e84SRoland Dreier enum ib_qp_type qp_type; 386a4d61e84SRoland Dreier u32 starting_psn; 387a4d61e84SRoland Dreier const void *private_data; 388a4d61e84SRoland Dreier u8 private_data_len; 389a4d61e84SRoland Dreier u8 peer_to_peer; 390a4d61e84SRoland Dreier u8 responder_resources; 391a4d61e84SRoland Dreier u8 initiator_depth; 392a4d61e84SRoland Dreier u8 remote_cm_response_timeout; 393a4d61e84SRoland Dreier u8 flow_control; 394a4d61e84SRoland Dreier u8 local_cm_response_timeout; 395a4d61e84SRoland Dreier u8 retry_count; 396a4d61e84SRoland Dreier u8 rnr_retry_count; 397a4d61e84SRoland Dreier u8 max_cm_retries; 398a4d61e84SRoland Dreier u8 srq; 399a4d61e84SRoland Dreier }; 400a4d61e84SRoland Dreier 401a4d61e84SRoland Dreier /** 402a4d61e84SRoland Dreier * ib_send_cm_req - Sends a connection request to the remote node. 403a4d61e84SRoland Dreier * @cm_id: Connection identifier that will be associated with the 404a4d61e84SRoland Dreier * connection request. 405a4d61e84SRoland Dreier * @param: Connection request information needed to establish the 406a4d61e84SRoland Dreier * connection. 407a4d61e84SRoland Dreier */ 408a4d61e84SRoland Dreier int ib_send_cm_req(struct ib_cm_id *cm_id, 409a4d61e84SRoland Dreier struct ib_cm_req_param *param); 410a4d61e84SRoland Dreier 411a4d61e84SRoland Dreier struct ib_cm_rep_param { 412a4d61e84SRoland Dreier u32 qp_num; 413a4d61e84SRoland Dreier u32 starting_psn; 414a4d61e84SRoland Dreier const void *private_data; 415a4d61e84SRoland Dreier u8 private_data_len; 416a4d61e84SRoland Dreier u8 responder_resources; 417a4d61e84SRoland Dreier u8 initiator_depth; 418a4d61e84SRoland Dreier u8 failover_accepted; 419a4d61e84SRoland Dreier u8 flow_control; 420a4d61e84SRoland Dreier u8 rnr_retry_count; 421a4d61e84SRoland Dreier u8 srq; 422a4d61e84SRoland Dreier }; 423a4d61e84SRoland Dreier 424a4d61e84SRoland Dreier /** 425a4d61e84SRoland Dreier * ib_send_cm_rep - Sends a connection reply in response to a connection 426a4d61e84SRoland Dreier * request. 427a4d61e84SRoland Dreier * @cm_id: Connection identifier that will be associated with the 428a4d61e84SRoland Dreier * connection request. 429a4d61e84SRoland Dreier * @param: Connection reply information needed to establish the 430a4d61e84SRoland Dreier * connection. 431a4d61e84SRoland Dreier */ 432a4d61e84SRoland Dreier int ib_send_cm_rep(struct ib_cm_id *cm_id, 433a4d61e84SRoland Dreier struct ib_cm_rep_param *param); 434a4d61e84SRoland Dreier 435a4d61e84SRoland Dreier /** 436a4d61e84SRoland Dreier * ib_send_cm_rtu - Sends a connection ready to use message in response 437a4d61e84SRoland Dreier * to a connection reply message. 438a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the connection request. 439a4d61e84SRoland Dreier * @private_data: Optional user-defined private data sent with the 440a4d61e84SRoland Dreier * ready to use message. 441a4d61e84SRoland Dreier * @private_data_len: Size of the private data buffer, in bytes. 442a4d61e84SRoland Dreier */ 443a4d61e84SRoland Dreier int ib_send_cm_rtu(struct ib_cm_id *cm_id, 444a4d61e84SRoland Dreier const void *private_data, 445a4d61e84SRoland Dreier u8 private_data_len); 446a4d61e84SRoland Dreier 447a4d61e84SRoland Dreier /** 448a4d61e84SRoland Dreier * ib_send_cm_dreq - Sends a disconnection request for an existing 449a4d61e84SRoland Dreier * connection. 450a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the connection being 451a4d61e84SRoland Dreier * released. 452a4d61e84SRoland Dreier * @private_data: Optional user-defined private data sent with the 453a4d61e84SRoland Dreier * disconnection request message. 454a4d61e84SRoland Dreier * @private_data_len: Size of the private data buffer, in bytes. 455a4d61e84SRoland Dreier */ 456a4d61e84SRoland Dreier int ib_send_cm_dreq(struct ib_cm_id *cm_id, 457a4d61e84SRoland Dreier const void *private_data, 458a4d61e84SRoland Dreier u8 private_data_len); 459a4d61e84SRoland Dreier 460a4d61e84SRoland Dreier /** 461a4d61e84SRoland Dreier * ib_send_cm_drep - Sends a disconnection reply to a disconnection request. 462a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the connection being 463a4d61e84SRoland Dreier * released. 464a4d61e84SRoland Dreier * @private_data: Optional user-defined private data sent with the 465a4d61e84SRoland Dreier * disconnection reply message. 466a4d61e84SRoland Dreier * @private_data_len: Size of the private data buffer, in bytes. 467a4d61e84SRoland Dreier * 468a4d61e84SRoland Dreier * If the cm_id is in the correct state, the CM will transition the connection 469a4d61e84SRoland Dreier * to the timewait state, even if an error occurs sending the DREP message. 470a4d61e84SRoland Dreier */ 471a4d61e84SRoland Dreier int ib_send_cm_drep(struct ib_cm_id *cm_id, 472a4d61e84SRoland Dreier const void *private_data, 473a4d61e84SRoland Dreier u8 private_data_len); 474a4d61e84SRoland Dreier 475a4d61e84SRoland Dreier /** 476e1444b5aSSean Hefty * ib_cm_notify - Notifies the CM of an event reported to the consumer. 477a4d61e84SRoland Dreier * @cm_id: Connection identifier to transition to established. 478e1444b5aSSean Hefty * @event: Type of event. 479a4d61e84SRoland Dreier * 480e1444b5aSSean Hefty * This routine should be invoked by users to notify the CM of relevant 481e1444b5aSSean Hefty * communication events. Events that should be reported to the CM and 482e1444b5aSSean Hefty * when to report them are: 483e1444b5aSSean Hefty * 484e1444b5aSSean Hefty * IB_EVENT_COMM_EST - Used when a message is received on a connected 485e1444b5aSSean Hefty * QP before an RTU has been received. 486e1444b5aSSean Hefty * IB_EVENT_PATH_MIG - Notifies the CM that the connection has failed over 487e1444b5aSSean Hefty * to the alternate path. 488a4d61e84SRoland Dreier */ 489e1444b5aSSean Hefty int ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event); 490a4d61e84SRoland Dreier 491a4d61e84SRoland Dreier /** 492a4d61e84SRoland Dreier * ib_send_cm_rej - Sends a connection rejection message to the 493a4d61e84SRoland Dreier * remote node. 494a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the connection being 495a4d61e84SRoland Dreier * rejected. 496a4d61e84SRoland Dreier * @reason: Reason for the connection request rejection. 497a4d61e84SRoland Dreier * @ari: Optional additional rejection information. 498a4d61e84SRoland Dreier * @ari_length: Size of the additional rejection information, in bytes. 499a4d61e84SRoland Dreier * @private_data: Optional user-defined private data sent with the 500a4d61e84SRoland Dreier * rejection message. 501a4d61e84SRoland Dreier * @private_data_len: Size of the private data buffer, in bytes. 502a4d61e84SRoland Dreier */ 503a4d61e84SRoland Dreier int ib_send_cm_rej(struct ib_cm_id *cm_id, 504a4d61e84SRoland Dreier enum ib_cm_rej_reason reason, 505a4d61e84SRoland Dreier void *ari, 506a4d61e84SRoland Dreier u8 ari_length, 507a4d61e84SRoland Dreier const void *private_data, 508a4d61e84SRoland Dreier u8 private_data_len); 509a4d61e84SRoland Dreier 510de98b693SSean Hefty #define IB_CM_MRA_FLAG_DELAY 0x80 /* Send MRA only after a duplicate msg */ 511de98b693SSean Hefty 512a4d61e84SRoland Dreier /** 513a4d61e84SRoland Dreier * ib_send_cm_mra - Sends a message receipt acknowledgement to a connection 514a4d61e84SRoland Dreier * message. 515a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the connection message. 516de98b693SSean Hefty * @service_timeout: The lower 5-bits specify the maximum time required for 517fd589a8fSAnand Gadiyar * the sender to reply to the connection message. The upper 3-bits 518de98b693SSean Hefty * specify additional control flags. 519a4d61e84SRoland Dreier * @private_data: Optional user-defined private data sent with the 520a4d61e84SRoland Dreier * message receipt acknowledgement. 521a4d61e84SRoland Dreier * @private_data_len: Size of the private data buffer, in bytes. 522a4d61e84SRoland Dreier */ 523a4d61e84SRoland Dreier int ib_send_cm_mra(struct ib_cm_id *cm_id, 524a4d61e84SRoland Dreier u8 service_timeout, 525a4d61e84SRoland Dreier const void *private_data, 526a4d61e84SRoland Dreier u8 private_data_len); 527a4d61e84SRoland Dreier 528a4d61e84SRoland Dreier /** 529a4d61e84SRoland Dreier * ib_send_cm_lap - Sends a load alternate path request. 530a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the load alternate path 531a4d61e84SRoland Dreier * message. 532a4d61e84SRoland Dreier * @alternate_path: A path record that identifies the alternate path to 533a4d61e84SRoland Dreier * load. 534a4d61e84SRoland Dreier * @private_data: Optional user-defined private data sent with the 535a4d61e84SRoland Dreier * load alternate path message. 536a4d61e84SRoland Dreier * @private_data_len: Size of the private data buffer, in bytes. 537a4d61e84SRoland Dreier */ 538a4d61e84SRoland Dreier int ib_send_cm_lap(struct ib_cm_id *cm_id, 539c2f8fc4eSDasaratharaman Chandramouli struct sa_path_rec *alternate_path, 540a4d61e84SRoland Dreier const void *private_data, 541a4d61e84SRoland Dreier u8 private_data_len); 542a4d61e84SRoland Dreier 543a4d61e84SRoland Dreier /** 544a4d61e84SRoland Dreier * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning 545a4d61e84SRoland Dreier * to a specified QP state. 546a4d61e84SRoland Dreier * @cm_id: Communication identifier associated with the QP attributes to 547a4d61e84SRoland Dreier * initialize. 548a4d61e84SRoland Dreier * @qp_attr: On input, specifies the desired QP state. On output, the 549a4d61e84SRoland Dreier * mandatory and desired optional attributes will be set in order to 550a4d61e84SRoland Dreier * modify the QP to the specified state. 551a4d61e84SRoland Dreier * @qp_attr_mask: The QP attribute mask that may be used to transition the 552a4d61e84SRoland Dreier * QP to the specified state. 553a4d61e84SRoland Dreier * 554a4d61e84SRoland Dreier * Users must set the @qp_attr->qp_state to the desired QP state. This call 555a4d61e84SRoland Dreier * will set all required attributes for the given transition, along with 556a4d61e84SRoland Dreier * known optional attributes. Users may override the attributes returned from 557a4d61e84SRoland Dreier * this call before calling ib_modify_qp. 558a4d61e84SRoland Dreier */ 559a4d61e84SRoland Dreier int ib_cm_init_qp_attr(struct ib_cm_id *cm_id, 560a4d61e84SRoland Dreier struct ib_qp_attr *qp_attr, 561a4d61e84SRoland Dreier int *qp_attr_mask); 562a4d61e84SRoland Dreier 563a4d61e84SRoland Dreier /** 564a4d61e84SRoland Dreier * ib_send_cm_apr - Sends an alternate path response message in response to 565a4d61e84SRoland Dreier * a load alternate path request. 566a4d61e84SRoland Dreier * @cm_id: Connection identifier associated with the alternate path response. 567a4d61e84SRoland Dreier * @status: Reply status sent with the alternate path response. 568a4d61e84SRoland Dreier * @info: Optional additional information sent with the alternate path 569a4d61e84SRoland Dreier * response. 570a4d61e84SRoland Dreier * @info_length: Size of the additional information, in bytes. 571a4d61e84SRoland Dreier * @private_data: Optional user-defined private data sent with the 572a4d61e84SRoland Dreier * alternate path response message. 573a4d61e84SRoland Dreier * @private_data_len: Size of the private data buffer, in bytes. 574a4d61e84SRoland Dreier */ 575a4d61e84SRoland Dreier int ib_send_cm_apr(struct ib_cm_id *cm_id, 576a4d61e84SRoland Dreier enum ib_cm_apr_status status, 577a4d61e84SRoland Dreier void *info, 578a4d61e84SRoland Dreier u8 info_length, 579a4d61e84SRoland Dreier const void *private_data, 580a4d61e84SRoland Dreier u8 private_data_len); 581a4d61e84SRoland Dreier 582a4d61e84SRoland Dreier struct ib_cm_sidr_req_param { 583c2f8fc4eSDasaratharaman Chandramouli struct sa_path_rec *path; 584815d456eSParav Pandit const struct ib_gid_attr *sgid_attr; 585a4d61e84SRoland Dreier __be64 service_id; 586dbace111SLeon Romanovsky unsigned long timeout_ms; 587a4d61e84SRoland Dreier const void *private_data; 588a4d61e84SRoland Dreier u8 private_data_len; 589a4d61e84SRoland Dreier u8 max_cm_retries; 590a4d61e84SRoland Dreier }; 591a4d61e84SRoland Dreier 592a4d61e84SRoland Dreier /** 593a4d61e84SRoland Dreier * ib_send_cm_sidr_req - Sends a service ID resolution request to the 594a4d61e84SRoland Dreier * remote node. 595a4d61e84SRoland Dreier * @cm_id: Communication identifier that will be associated with the 596a4d61e84SRoland Dreier * service ID resolution request. 597a4d61e84SRoland Dreier * @param: Service ID resolution request information. 598a4d61e84SRoland Dreier */ 599a4d61e84SRoland Dreier int ib_send_cm_sidr_req(struct ib_cm_id *cm_id, 600a4d61e84SRoland Dreier struct ib_cm_sidr_req_param *param); 601a4d61e84SRoland Dreier 602a4d61e84SRoland Dreier struct ib_cm_sidr_rep_param { 603a4d61e84SRoland Dreier u32 qp_num; 604a4d61e84SRoland Dreier u32 qkey; 605a4d61e84SRoland Dreier enum ib_cm_sidr_status status; 606a4d61e84SRoland Dreier const void *info; 607a4d61e84SRoland Dreier u8 info_length; 608a4d61e84SRoland Dreier const void *private_data; 609a4d61e84SRoland Dreier u8 private_data_len; 610a4d61e84SRoland Dreier }; 611a4d61e84SRoland Dreier 612a4d61e84SRoland Dreier /** 61375af9088SSean Hefty * ib_send_cm_sidr_rep - Sends a service ID resolution reply to the 614a4d61e84SRoland Dreier * remote node. 615a4d61e84SRoland Dreier * @cm_id: Communication identifier associated with the received service ID 616a4d61e84SRoland Dreier * resolution request. 617a4d61e84SRoland Dreier * @param: Service ID resolution reply information. 618a4d61e84SRoland Dreier */ 619a4d61e84SRoland Dreier int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id, 620a4d61e84SRoland Dreier struct ib_cm_sidr_rep_param *param); 621a4d61e84SRoland Dreier 62277a5db13SSteve Wise /** 62377a5db13SSteve Wise * ibcm_reject_msg - return a pointer to a reject message string. 62477a5db13SSteve Wise * @reason: Value returned in the REJECT event status field. 62577a5db13SSteve Wise */ 62677a5db13SSteve Wise const char *__attribute_const__ ibcm_reject_msg(int reason); 62777a5db13SSteve Wise 628a4d61e84SRoland Dreier #endif /* IB_CM_H */ 629