18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved. 48c2ecf20Sopenharmony_ci * Copyright (c) 2004 Topspin Corporation. All rights reserved. 58c2ecf20Sopenharmony_ci * Copyright (c) 2004 Voltaire Corporation. All rights reserved. 68c2ecf20Sopenharmony_ci * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 78c2ecf20Sopenharmony_ci * Copyright (c) 2019, Mellanox Technologies inc. All rights reserved. 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef IB_CM_H 118c2ecf20Sopenharmony_ci#define IB_CM_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <rdma/ib_mad.h> 148c2ecf20Sopenharmony_ci#include <rdma/ib_sa.h> 158c2ecf20Sopenharmony_ci#include <rdma/rdma_cm.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cienum ib_cm_state { 188c2ecf20Sopenharmony_ci IB_CM_IDLE, 198c2ecf20Sopenharmony_ci IB_CM_LISTEN, 208c2ecf20Sopenharmony_ci IB_CM_REQ_SENT, 218c2ecf20Sopenharmony_ci IB_CM_REQ_RCVD, 228c2ecf20Sopenharmony_ci IB_CM_MRA_REQ_SENT, 238c2ecf20Sopenharmony_ci IB_CM_MRA_REQ_RCVD, 248c2ecf20Sopenharmony_ci IB_CM_REP_SENT, 258c2ecf20Sopenharmony_ci IB_CM_REP_RCVD, 268c2ecf20Sopenharmony_ci IB_CM_MRA_REP_SENT, 278c2ecf20Sopenharmony_ci IB_CM_MRA_REP_RCVD, 288c2ecf20Sopenharmony_ci IB_CM_ESTABLISHED, 298c2ecf20Sopenharmony_ci IB_CM_DREQ_SENT, 308c2ecf20Sopenharmony_ci IB_CM_DREQ_RCVD, 318c2ecf20Sopenharmony_ci IB_CM_TIMEWAIT, 328c2ecf20Sopenharmony_ci IB_CM_SIDR_REQ_SENT, 338c2ecf20Sopenharmony_ci IB_CM_SIDR_REQ_RCVD 348c2ecf20Sopenharmony_ci}; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cienum ib_cm_lap_state { 378c2ecf20Sopenharmony_ci IB_CM_LAP_UNINIT, 388c2ecf20Sopenharmony_ci IB_CM_LAP_IDLE, 398c2ecf20Sopenharmony_ci IB_CM_LAP_SENT, 408c2ecf20Sopenharmony_ci IB_CM_LAP_RCVD, 418c2ecf20Sopenharmony_ci IB_CM_MRA_LAP_SENT, 428c2ecf20Sopenharmony_ci IB_CM_MRA_LAP_RCVD, 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cienum ib_cm_event_type { 468c2ecf20Sopenharmony_ci IB_CM_REQ_ERROR, 478c2ecf20Sopenharmony_ci IB_CM_REQ_RECEIVED, 488c2ecf20Sopenharmony_ci IB_CM_REP_ERROR, 498c2ecf20Sopenharmony_ci IB_CM_REP_RECEIVED, 508c2ecf20Sopenharmony_ci IB_CM_RTU_RECEIVED, 518c2ecf20Sopenharmony_ci IB_CM_USER_ESTABLISHED, 528c2ecf20Sopenharmony_ci IB_CM_DREQ_ERROR, 538c2ecf20Sopenharmony_ci IB_CM_DREQ_RECEIVED, 548c2ecf20Sopenharmony_ci IB_CM_DREP_RECEIVED, 558c2ecf20Sopenharmony_ci IB_CM_TIMEWAIT_EXIT, 568c2ecf20Sopenharmony_ci IB_CM_MRA_RECEIVED, 578c2ecf20Sopenharmony_ci IB_CM_REJ_RECEIVED, 588c2ecf20Sopenharmony_ci IB_CM_LAP_ERROR, 598c2ecf20Sopenharmony_ci IB_CM_LAP_RECEIVED, 608c2ecf20Sopenharmony_ci IB_CM_APR_RECEIVED, 618c2ecf20Sopenharmony_ci IB_CM_SIDR_REQ_ERROR, 628c2ecf20Sopenharmony_ci IB_CM_SIDR_REQ_RECEIVED, 638c2ecf20Sopenharmony_ci IB_CM_SIDR_REP_RECEIVED 648c2ecf20Sopenharmony_ci}; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cienum ib_cm_data_size { 678c2ecf20Sopenharmony_ci IB_CM_REQ_PRIVATE_DATA_SIZE = 92, 688c2ecf20Sopenharmony_ci IB_CM_MRA_PRIVATE_DATA_SIZE = 222, 698c2ecf20Sopenharmony_ci IB_CM_REJ_PRIVATE_DATA_SIZE = 148, 708c2ecf20Sopenharmony_ci IB_CM_REP_PRIVATE_DATA_SIZE = 196, 718c2ecf20Sopenharmony_ci IB_CM_RTU_PRIVATE_DATA_SIZE = 224, 728c2ecf20Sopenharmony_ci IB_CM_DREQ_PRIVATE_DATA_SIZE = 220, 738c2ecf20Sopenharmony_ci IB_CM_DREP_PRIVATE_DATA_SIZE = 224, 748c2ecf20Sopenharmony_ci IB_CM_REJ_ARI_LENGTH = 72, 758c2ecf20Sopenharmony_ci IB_CM_LAP_PRIVATE_DATA_SIZE = 168, 768c2ecf20Sopenharmony_ci IB_CM_APR_PRIVATE_DATA_SIZE = 148, 778c2ecf20Sopenharmony_ci IB_CM_APR_INFO_LENGTH = 72, 788c2ecf20Sopenharmony_ci IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216, 798c2ecf20Sopenharmony_ci IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136, 808c2ecf20Sopenharmony_ci IB_CM_SIDR_REP_INFO_LENGTH = 72, 818c2ecf20Sopenharmony_ci}; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_cistruct ib_cm_id; 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_cistruct ib_cm_req_event_param { 868c2ecf20Sopenharmony_ci struct ib_cm_id *listen_id; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci /* P_Key that was used by the GMP's BTH header */ 898c2ecf20Sopenharmony_ci u16 bth_pkey; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci u8 port; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci struct sa_path_rec *primary_path; 948c2ecf20Sopenharmony_ci struct sa_path_rec *alternate_path; 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci /* 978c2ecf20Sopenharmony_ci * SGID attribute of the primary path. Currently only 988c2ecf20Sopenharmony_ci * useful for RoCE. Alternate path GID attributes 998c2ecf20Sopenharmony_ci * are not yet supported. 1008c2ecf20Sopenharmony_ci */ 1018c2ecf20Sopenharmony_ci const struct ib_gid_attr *ppath_sgid_attr; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci __be64 remote_ca_guid; 1048c2ecf20Sopenharmony_ci u32 remote_qkey; 1058c2ecf20Sopenharmony_ci u32 remote_qpn; 1068c2ecf20Sopenharmony_ci enum ib_qp_type qp_type; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci u32 starting_psn; 1098c2ecf20Sopenharmony_ci u8 responder_resources; 1108c2ecf20Sopenharmony_ci u8 initiator_depth; 1118c2ecf20Sopenharmony_ci unsigned int local_cm_response_timeout:5; 1128c2ecf20Sopenharmony_ci unsigned int flow_control:1; 1138c2ecf20Sopenharmony_ci unsigned int remote_cm_response_timeout:5; 1148c2ecf20Sopenharmony_ci unsigned int retry_count:3; 1158c2ecf20Sopenharmony_ci unsigned int rnr_retry_count:3; 1168c2ecf20Sopenharmony_ci unsigned int srq:1; 1178c2ecf20Sopenharmony_ci struct rdma_ucm_ece ece; 1188c2ecf20Sopenharmony_ci}; 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_cistruct ib_cm_rep_event_param { 1218c2ecf20Sopenharmony_ci __be64 remote_ca_guid; 1228c2ecf20Sopenharmony_ci u32 remote_qkey; 1238c2ecf20Sopenharmony_ci u32 remote_qpn; 1248c2ecf20Sopenharmony_ci u32 starting_psn; 1258c2ecf20Sopenharmony_ci u8 responder_resources; 1268c2ecf20Sopenharmony_ci u8 initiator_depth; 1278c2ecf20Sopenharmony_ci unsigned int target_ack_delay:5; 1288c2ecf20Sopenharmony_ci unsigned int failover_accepted:2; 1298c2ecf20Sopenharmony_ci unsigned int flow_control:1; 1308c2ecf20Sopenharmony_ci unsigned int rnr_retry_count:3; 1318c2ecf20Sopenharmony_ci unsigned int srq:1; 1328c2ecf20Sopenharmony_ci struct rdma_ucm_ece ece; 1338c2ecf20Sopenharmony_ci}; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_cienum ib_cm_rej_reason { 1368c2ecf20Sopenharmony_ci IB_CM_REJ_NO_QP = 1, 1378c2ecf20Sopenharmony_ci IB_CM_REJ_NO_EEC = 2, 1388c2ecf20Sopenharmony_ci IB_CM_REJ_NO_RESOURCES = 3, 1398c2ecf20Sopenharmony_ci IB_CM_REJ_TIMEOUT = 4, 1408c2ecf20Sopenharmony_ci IB_CM_REJ_UNSUPPORTED = 5, 1418c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_COMM_ID = 6, 1428c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_COMM_INSTANCE = 7, 1438c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_SERVICE_ID = 8, 1448c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9, 1458c2ecf20Sopenharmony_ci IB_CM_REJ_STALE_CONN = 10, 1468c2ecf20Sopenharmony_ci IB_CM_REJ_RDC_NOT_EXIST = 11, 1478c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_GID = 12, 1488c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_LID = 13, 1498c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_SL = 14, 1508c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15, 1518c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_HOP_LIMIT = 16, 1528c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_PACKET_RATE = 17, 1538c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_ALT_GID = 18, 1548c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_ALT_LID = 19, 1558c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_ALT_SL = 20, 1568c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21, 1578c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22, 1588c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23, 1598c2ecf20Sopenharmony_ci IB_CM_REJ_PORT_CM_REDIRECT = 24, 1608c2ecf20Sopenharmony_ci IB_CM_REJ_PORT_REDIRECT = 25, 1618c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_MTU = 26, 1628c2ecf20Sopenharmony_ci IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27, 1638c2ecf20Sopenharmony_ci IB_CM_REJ_CONSUMER_DEFINED = 28, 1648c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_RNR_RETRY = 29, 1658c2ecf20Sopenharmony_ci IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30, 1668c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_CLASS_VERSION = 31, 1678c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_FLOW_LABEL = 32, 1688c2ecf20Sopenharmony_ci IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33, 1698c2ecf20Sopenharmony_ci IB_CM_REJ_VENDOR_OPTION_NOT_SUPPORTED = 35, 1708c2ecf20Sopenharmony_ci}; 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_cistruct ib_cm_rej_event_param { 1738c2ecf20Sopenharmony_ci enum ib_cm_rej_reason reason; 1748c2ecf20Sopenharmony_ci void *ari; 1758c2ecf20Sopenharmony_ci u8 ari_length; 1768c2ecf20Sopenharmony_ci}; 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_cistruct ib_cm_mra_event_param { 1798c2ecf20Sopenharmony_ci u8 service_timeout; 1808c2ecf20Sopenharmony_ci}; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_cistruct ib_cm_lap_event_param { 1838c2ecf20Sopenharmony_ci struct sa_path_rec *alternate_path; 1848c2ecf20Sopenharmony_ci}; 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_cienum ib_cm_apr_status { 1878c2ecf20Sopenharmony_ci IB_CM_APR_SUCCESS, 1888c2ecf20Sopenharmony_ci IB_CM_APR_INVALID_COMM_ID, 1898c2ecf20Sopenharmony_ci IB_CM_APR_UNSUPPORTED, 1908c2ecf20Sopenharmony_ci IB_CM_APR_REJECT, 1918c2ecf20Sopenharmony_ci IB_CM_APR_REDIRECT, 1928c2ecf20Sopenharmony_ci IB_CM_APR_IS_CURRENT, 1938c2ecf20Sopenharmony_ci IB_CM_APR_INVALID_QPN_EECN, 1948c2ecf20Sopenharmony_ci IB_CM_APR_INVALID_LID, 1958c2ecf20Sopenharmony_ci IB_CM_APR_INVALID_GID, 1968c2ecf20Sopenharmony_ci IB_CM_APR_INVALID_FLOW_LABEL, 1978c2ecf20Sopenharmony_ci IB_CM_APR_INVALID_TCLASS, 1988c2ecf20Sopenharmony_ci IB_CM_APR_INVALID_HOP_LIMIT, 1998c2ecf20Sopenharmony_ci IB_CM_APR_INVALID_PACKET_RATE, 2008c2ecf20Sopenharmony_ci IB_CM_APR_INVALID_SL 2018c2ecf20Sopenharmony_ci}; 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_cistruct ib_cm_apr_event_param { 2048c2ecf20Sopenharmony_ci enum ib_cm_apr_status ap_status; 2058c2ecf20Sopenharmony_ci void *apr_info; 2068c2ecf20Sopenharmony_ci u8 info_len; 2078c2ecf20Sopenharmony_ci}; 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_cistruct ib_cm_sidr_req_event_param { 2108c2ecf20Sopenharmony_ci struct ib_cm_id *listen_id; 2118c2ecf20Sopenharmony_ci __be64 service_id; 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci /* 2148c2ecf20Sopenharmony_ci * SGID attribute of the request. Currently only 2158c2ecf20Sopenharmony_ci * useful for RoCE. 2168c2ecf20Sopenharmony_ci */ 2178c2ecf20Sopenharmony_ci const struct ib_gid_attr *sgid_attr; 2188c2ecf20Sopenharmony_ci /* P_Key that was used by the GMP's BTH header */ 2198c2ecf20Sopenharmony_ci u16 bth_pkey; 2208c2ecf20Sopenharmony_ci u8 port; 2218c2ecf20Sopenharmony_ci u16 pkey; 2228c2ecf20Sopenharmony_ci}; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_cienum ib_cm_sidr_status { 2258c2ecf20Sopenharmony_ci IB_SIDR_SUCCESS, 2268c2ecf20Sopenharmony_ci IB_SIDR_UNSUPPORTED, 2278c2ecf20Sopenharmony_ci IB_SIDR_REJECT, 2288c2ecf20Sopenharmony_ci IB_SIDR_NO_QP, 2298c2ecf20Sopenharmony_ci IB_SIDR_REDIRECT, 2308c2ecf20Sopenharmony_ci IB_SIDR_UNSUPPORTED_VERSION 2318c2ecf20Sopenharmony_ci}; 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_cistruct ib_cm_sidr_rep_event_param { 2348c2ecf20Sopenharmony_ci enum ib_cm_sidr_status status; 2358c2ecf20Sopenharmony_ci u32 qkey; 2368c2ecf20Sopenharmony_ci u32 qpn; 2378c2ecf20Sopenharmony_ci void *info; 2388c2ecf20Sopenharmony_ci const struct ib_gid_attr *sgid_attr; 2398c2ecf20Sopenharmony_ci u8 info_len; 2408c2ecf20Sopenharmony_ci}; 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_cistruct ib_cm_event { 2438c2ecf20Sopenharmony_ci enum ib_cm_event_type event; 2448c2ecf20Sopenharmony_ci union { 2458c2ecf20Sopenharmony_ci struct ib_cm_req_event_param req_rcvd; 2468c2ecf20Sopenharmony_ci struct ib_cm_rep_event_param rep_rcvd; 2478c2ecf20Sopenharmony_ci /* No data for RTU received events. */ 2488c2ecf20Sopenharmony_ci struct ib_cm_rej_event_param rej_rcvd; 2498c2ecf20Sopenharmony_ci struct ib_cm_mra_event_param mra_rcvd; 2508c2ecf20Sopenharmony_ci struct ib_cm_lap_event_param lap_rcvd; 2518c2ecf20Sopenharmony_ci struct ib_cm_apr_event_param apr_rcvd; 2528c2ecf20Sopenharmony_ci /* No data for DREQ/DREP received events. */ 2538c2ecf20Sopenharmony_ci struct ib_cm_sidr_req_event_param sidr_req_rcvd; 2548c2ecf20Sopenharmony_ci struct ib_cm_sidr_rep_event_param sidr_rep_rcvd; 2558c2ecf20Sopenharmony_ci enum ib_wc_status send_status; 2568c2ecf20Sopenharmony_ci } param; 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci void *private_data; 2598c2ecf20Sopenharmony_ci}; 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci#define CM_REQ_ATTR_ID cpu_to_be16(0x0010) 2628c2ecf20Sopenharmony_ci#define CM_MRA_ATTR_ID cpu_to_be16(0x0011) 2638c2ecf20Sopenharmony_ci#define CM_REJ_ATTR_ID cpu_to_be16(0x0012) 2648c2ecf20Sopenharmony_ci#define CM_REP_ATTR_ID cpu_to_be16(0x0013) 2658c2ecf20Sopenharmony_ci#define CM_RTU_ATTR_ID cpu_to_be16(0x0014) 2668c2ecf20Sopenharmony_ci#define CM_DREQ_ATTR_ID cpu_to_be16(0x0015) 2678c2ecf20Sopenharmony_ci#define CM_DREP_ATTR_ID cpu_to_be16(0x0016) 2688c2ecf20Sopenharmony_ci#define CM_SIDR_REQ_ATTR_ID cpu_to_be16(0x0017) 2698c2ecf20Sopenharmony_ci#define CM_SIDR_REP_ATTR_ID cpu_to_be16(0x0018) 2708c2ecf20Sopenharmony_ci#define CM_LAP_ATTR_ID cpu_to_be16(0x0019) 2718c2ecf20Sopenharmony_ci#define CM_APR_ATTR_ID cpu_to_be16(0x001A) 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci/** 2748c2ecf20Sopenharmony_ci * ib_cm_handler - User-defined callback to process communication events. 2758c2ecf20Sopenharmony_ci * @cm_id: Communication identifier associated with the reported event. 2768c2ecf20Sopenharmony_ci * @event: Information about the communication event. 2778c2ecf20Sopenharmony_ci * 2788c2ecf20Sopenharmony_ci * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events 2798c2ecf20Sopenharmony_ci * generated as a result of listen requests result in the allocation of a 2808c2ecf20Sopenharmony_ci * new @cm_id. The new @cm_id is returned to the user through this callback. 2818c2ecf20Sopenharmony_ci * Clients are responsible for destroying the new @cm_id. For peer-to-peer 2828c2ecf20Sopenharmony_ci * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds 2838c2ecf20Sopenharmony_ci * to a user's existing communication identifier. 2848c2ecf20Sopenharmony_ci * 2858c2ecf20Sopenharmony_ci * Users may not call ib_destroy_cm_id while in the context of this callback; 2868c2ecf20Sopenharmony_ci * however, returning a non-zero value instructs the communication manager to 2878c2ecf20Sopenharmony_ci * destroy the @cm_id after the callback completes. 2888c2ecf20Sopenharmony_ci */ 2898c2ecf20Sopenharmony_citypedef int (*ib_cm_handler)(struct ib_cm_id *cm_id, 2908c2ecf20Sopenharmony_ci const struct ib_cm_event *event); 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_cistruct ib_cm_id { 2938c2ecf20Sopenharmony_ci ib_cm_handler cm_handler; 2948c2ecf20Sopenharmony_ci void *context; 2958c2ecf20Sopenharmony_ci struct ib_device *device; 2968c2ecf20Sopenharmony_ci __be64 service_id; 2978c2ecf20Sopenharmony_ci __be64 service_mask; 2988c2ecf20Sopenharmony_ci enum ib_cm_state state; /* internal CM/debug use */ 2998c2ecf20Sopenharmony_ci enum ib_cm_lap_state lap_state; /* internal CM/debug use */ 3008c2ecf20Sopenharmony_ci __be32 local_id; 3018c2ecf20Sopenharmony_ci __be32 remote_id; 3028c2ecf20Sopenharmony_ci u32 remote_cm_qpn; /* 1 unless redirected */ 3038c2ecf20Sopenharmony_ci}; 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ci/** 3068c2ecf20Sopenharmony_ci * ib_create_cm_id - Allocate a communication identifier. 3078c2ecf20Sopenharmony_ci * @device: Device associated with the cm_id. All related communication will 3088c2ecf20Sopenharmony_ci * be associated with the specified device. 3098c2ecf20Sopenharmony_ci * @cm_handler: Callback invoked to notify the user of CM events. 3108c2ecf20Sopenharmony_ci * @context: User specified context associated with the communication 3118c2ecf20Sopenharmony_ci * identifier. 3128c2ecf20Sopenharmony_ci * 3138c2ecf20Sopenharmony_ci * Communication identifiers are used to track connection states, service 3148c2ecf20Sopenharmony_ci * ID resolution requests, and listen requests. 3158c2ecf20Sopenharmony_ci */ 3168c2ecf20Sopenharmony_cistruct ib_cm_id *ib_create_cm_id(struct ib_device *device, 3178c2ecf20Sopenharmony_ci ib_cm_handler cm_handler, 3188c2ecf20Sopenharmony_ci void *context); 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci/** 3218c2ecf20Sopenharmony_ci * ib_destroy_cm_id - Destroy a connection identifier. 3228c2ecf20Sopenharmony_ci * @cm_id: Connection identifier to destroy. 3238c2ecf20Sopenharmony_ci * 3248c2ecf20Sopenharmony_ci * This call blocks until the connection identifier is destroyed. 3258c2ecf20Sopenharmony_ci */ 3268c2ecf20Sopenharmony_civoid ib_destroy_cm_id(struct ib_cm_id *cm_id); 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci#define IB_SERVICE_ID_AGN_MASK cpu_to_be64(0xFF00000000000000ULL) 3298c2ecf20Sopenharmony_ci#define IB_CM_ASSIGN_SERVICE_ID cpu_to_be64(0x0200000000000000ULL) 3308c2ecf20Sopenharmony_ci#define IB_CMA_SERVICE_ID cpu_to_be64(0x0000000001000000ULL) 3318c2ecf20Sopenharmony_ci#define IB_CMA_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFF000000ULL) 3328c2ecf20Sopenharmony_ci#define IB_SDP_SERVICE_ID cpu_to_be64(0x0000000000010000ULL) 3338c2ecf20Sopenharmony_ci#define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL) 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci/** 3368c2ecf20Sopenharmony_ci * ib_cm_listen - Initiates listening on the specified service ID for 3378c2ecf20Sopenharmony_ci * connection and service ID resolution requests. 3388c2ecf20Sopenharmony_ci * @cm_id: Connection identifier associated with the listen request. 3398c2ecf20Sopenharmony_ci * @service_id: Service identifier matched against incoming connection 3408c2ecf20Sopenharmony_ci * and service ID resolution requests. The service ID should be specified 3418c2ecf20Sopenharmony_ci * network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will 3428c2ecf20Sopenharmony_ci * assign a service ID to the caller. 3438c2ecf20Sopenharmony_ci * @service_mask: Mask applied to service ID used to listen across a 3448c2ecf20Sopenharmony_ci * range of service IDs. If set to 0, the service ID is matched 3458c2ecf20Sopenharmony_ci * exactly. This parameter is ignored if %service_id is set to 3468c2ecf20Sopenharmony_ci * IB_CM_ASSIGN_SERVICE_ID. 3478c2ecf20Sopenharmony_ci */ 3488c2ecf20Sopenharmony_ciint ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, 3498c2ecf20Sopenharmony_ci __be64 service_mask); 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_cistruct ib_cm_id *ib_cm_insert_listen(struct ib_device *device, 3528c2ecf20Sopenharmony_ci ib_cm_handler cm_handler, 3538c2ecf20Sopenharmony_ci __be64 service_id); 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_cistruct ib_cm_req_param { 3568c2ecf20Sopenharmony_ci struct sa_path_rec *primary_path; 3578c2ecf20Sopenharmony_ci struct sa_path_rec *alternate_path; 3588c2ecf20Sopenharmony_ci const struct ib_gid_attr *ppath_sgid_attr; 3598c2ecf20Sopenharmony_ci __be64 service_id; 3608c2ecf20Sopenharmony_ci u32 qp_num; 3618c2ecf20Sopenharmony_ci enum ib_qp_type qp_type; 3628c2ecf20Sopenharmony_ci u32 starting_psn; 3638c2ecf20Sopenharmony_ci const void *private_data; 3648c2ecf20Sopenharmony_ci u8 private_data_len; 3658c2ecf20Sopenharmony_ci u8 responder_resources; 3668c2ecf20Sopenharmony_ci u8 initiator_depth; 3678c2ecf20Sopenharmony_ci u8 remote_cm_response_timeout; 3688c2ecf20Sopenharmony_ci u8 flow_control; 3698c2ecf20Sopenharmony_ci u8 local_cm_response_timeout; 3708c2ecf20Sopenharmony_ci u8 retry_count; 3718c2ecf20Sopenharmony_ci u8 rnr_retry_count; 3728c2ecf20Sopenharmony_ci u8 max_cm_retries; 3738c2ecf20Sopenharmony_ci u8 srq; 3748c2ecf20Sopenharmony_ci struct rdma_ucm_ece ece; 3758c2ecf20Sopenharmony_ci}; 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci/** 3788c2ecf20Sopenharmony_ci * ib_send_cm_req - Sends a connection request to the remote node. 3798c2ecf20Sopenharmony_ci * @cm_id: Connection identifier that will be associated with the 3808c2ecf20Sopenharmony_ci * connection request. 3818c2ecf20Sopenharmony_ci * @param: Connection request information needed to establish the 3828c2ecf20Sopenharmony_ci * connection. 3838c2ecf20Sopenharmony_ci */ 3848c2ecf20Sopenharmony_ciint ib_send_cm_req(struct ib_cm_id *cm_id, 3858c2ecf20Sopenharmony_ci struct ib_cm_req_param *param); 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_cistruct ib_cm_rep_param { 3888c2ecf20Sopenharmony_ci u32 qp_num; 3898c2ecf20Sopenharmony_ci u32 starting_psn; 3908c2ecf20Sopenharmony_ci const void *private_data; 3918c2ecf20Sopenharmony_ci u8 private_data_len; 3928c2ecf20Sopenharmony_ci u8 responder_resources; 3938c2ecf20Sopenharmony_ci u8 initiator_depth; 3948c2ecf20Sopenharmony_ci u8 failover_accepted; 3958c2ecf20Sopenharmony_ci u8 flow_control; 3968c2ecf20Sopenharmony_ci u8 rnr_retry_count; 3978c2ecf20Sopenharmony_ci u8 srq; 3988c2ecf20Sopenharmony_ci struct rdma_ucm_ece ece; 3998c2ecf20Sopenharmony_ci}; 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_ci/** 4028c2ecf20Sopenharmony_ci * ib_send_cm_rep - Sends a connection reply in response to a connection 4038c2ecf20Sopenharmony_ci * request. 4048c2ecf20Sopenharmony_ci * @cm_id: Connection identifier that will be associated with the 4058c2ecf20Sopenharmony_ci * connection request. 4068c2ecf20Sopenharmony_ci * @param: Connection reply information needed to establish the 4078c2ecf20Sopenharmony_ci * connection. 4088c2ecf20Sopenharmony_ci */ 4098c2ecf20Sopenharmony_ciint ib_send_cm_rep(struct ib_cm_id *cm_id, 4108c2ecf20Sopenharmony_ci struct ib_cm_rep_param *param); 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci/** 4138c2ecf20Sopenharmony_ci * ib_send_cm_rtu - Sends a connection ready to use message in response 4148c2ecf20Sopenharmony_ci * to a connection reply message. 4158c2ecf20Sopenharmony_ci * @cm_id: Connection identifier associated with the connection request. 4168c2ecf20Sopenharmony_ci * @private_data: Optional user-defined private data sent with the 4178c2ecf20Sopenharmony_ci * ready to use message. 4188c2ecf20Sopenharmony_ci * @private_data_len: Size of the private data buffer, in bytes. 4198c2ecf20Sopenharmony_ci */ 4208c2ecf20Sopenharmony_ciint ib_send_cm_rtu(struct ib_cm_id *cm_id, 4218c2ecf20Sopenharmony_ci const void *private_data, 4228c2ecf20Sopenharmony_ci u8 private_data_len); 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_ci/** 4258c2ecf20Sopenharmony_ci * ib_send_cm_dreq - Sends a disconnection request for an existing 4268c2ecf20Sopenharmony_ci * connection. 4278c2ecf20Sopenharmony_ci * @cm_id: Connection identifier associated with the connection being 4288c2ecf20Sopenharmony_ci * released. 4298c2ecf20Sopenharmony_ci * @private_data: Optional user-defined private data sent with the 4308c2ecf20Sopenharmony_ci * disconnection request message. 4318c2ecf20Sopenharmony_ci * @private_data_len: Size of the private data buffer, in bytes. 4328c2ecf20Sopenharmony_ci */ 4338c2ecf20Sopenharmony_ciint ib_send_cm_dreq(struct ib_cm_id *cm_id, 4348c2ecf20Sopenharmony_ci const void *private_data, 4358c2ecf20Sopenharmony_ci u8 private_data_len); 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_ci/** 4388c2ecf20Sopenharmony_ci * ib_send_cm_drep - Sends a disconnection reply to a disconnection request. 4398c2ecf20Sopenharmony_ci * @cm_id: Connection identifier associated with the connection being 4408c2ecf20Sopenharmony_ci * released. 4418c2ecf20Sopenharmony_ci * @private_data: Optional user-defined private data sent with the 4428c2ecf20Sopenharmony_ci * disconnection reply message. 4438c2ecf20Sopenharmony_ci * @private_data_len: Size of the private data buffer, in bytes. 4448c2ecf20Sopenharmony_ci * 4458c2ecf20Sopenharmony_ci * If the cm_id is in the correct state, the CM will transition the connection 4468c2ecf20Sopenharmony_ci * to the timewait state, even if an error occurs sending the DREP message. 4478c2ecf20Sopenharmony_ci */ 4488c2ecf20Sopenharmony_ciint ib_send_cm_drep(struct ib_cm_id *cm_id, 4498c2ecf20Sopenharmony_ci const void *private_data, 4508c2ecf20Sopenharmony_ci u8 private_data_len); 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci/** 4538c2ecf20Sopenharmony_ci * ib_cm_notify - Notifies the CM of an event reported to the consumer. 4548c2ecf20Sopenharmony_ci * @cm_id: Connection identifier to transition to established. 4558c2ecf20Sopenharmony_ci * @event: Type of event. 4568c2ecf20Sopenharmony_ci * 4578c2ecf20Sopenharmony_ci * This routine should be invoked by users to notify the CM of relevant 4588c2ecf20Sopenharmony_ci * communication events. Events that should be reported to the CM and 4598c2ecf20Sopenharmony_ci * when to report them are: 4608c2ecf20Sopenharmony_ci * 4618c2ecf20Sopenharmony_ci * IB_EVENT_COMM_EST - Used when a message is received on a connected 4628c2ecf20Sopenharmony_ci * QP before an RTU has been received. 4638c2ecf20Sopenharmony_ci * IB_EVENT_PATH_MIG - Notifies the CM that the connection has failed over 4648c2ecf20Sopenharmony_ci * to the alternate path. 4658c2ecf20Sopenharmony_ci */ 4668c2ecf20Sopenharmony_ciint ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event); 4678c2ecf20Sopenharmony_ci 4688c2ecf20Sopenharmony_ci/** 4698c2ecf20Sopenharmony_ci * ib_send_cm_rej - Sends a connection rejection message to the 4708c2ecf20Sopenharmony_ci * remote node. 4718c2ecf20Sopenharmony_ci * @cm_id: Connection identifier associated with the connection being 4728c2ecf20Sopenharmony_ci * rejected. 4738c2ecf20Sopenharmony_ci * @reason: Reason for the connection request rejection. 4748c2ecf20Sopenharmony_ci * @ari: Optional additional rejection information. 4758c2ecf20Sopenharmony_ci * @ari_length: Size of the additional rejection information, in bytes. 4768c2ecf20Sopenharmony_ci * @private_data: Optional user-defined private data sent with the 4778c2ecf20Sopenharmony_ci * rejection message. 4788c2ecf20Sopenharmony_ci * @private_data_len: Size of the private data buffer, in bytes. 4798c2ecf20Sopenharmony_ci */ 4808c2ecf20Sopenharmony_ciint ib_send_cm_rej(struct ib_cm_id *cm_id, 4818c2ecf20Sopenharmony_ci enum ib_cm_rej_reason reason, 4828c2ecf20Sopenharmony_ci void *ari, 4838c2ecf20Sopenharmony_ci u8 ari_length, 4848c2ecf20Sopenharmony_ci const void *private_data, 4858c2ecf20Sopenharmony_ci u8 private_data_len); 4868c2ecf20Sopenharmony_ci 4878c2ecf20Sopenharmony_ci#define IB_CM_MRA_FLAG_DELAY 0x80 /* Send MRA only after a duplicate msg */ 4888c2ecf20Sopenharmony_ci 4898c2ecf20Sopenharmony_ci/** 4908c2ecf20Sopenharmony_ci * ib_send_cm_mra - Sends a message receipt acknowledgement to a connection 4918c2ecf20Sopenharmony_ci * message. 4928c2ecf20Sopenharmony_ci * @cm_id: Connection identifier associated with the connection message. 4938c2ecf20Sopenharmony_ci * @service_timeout: The lower 5-bits specify the maximum time required for 4948c2ecf20Sopenharmony_ci * the sender to reply to the connection message. The upper 3-bits 4958c2ecf20Sopenharmony_ci * specify additional control flags. 4968c2ecf20Sopenharmony_ci * @private_data: Optional user-defined private data sent with the 4978c2ecf20Sopenharmony_ci * message receipt acknowledgement. 4988c2ecf20Sopenharmony_ci * @private_data_len: Size of the private data buffer, in bytes. 4998c2ecf20Sopenharmony_ci */ 5008c2ecf20Sopenharmony_ciint ib_send_cm_mra(struct ib_cm_id *cm_id, 5018c2ecf20Sopenharmony_ci u8 service_timeout, 5028c2ecf20Sopenharmony_ci const void *private_data, 5038c2ecf20Sopenharmony_ci u8 private_data_len); 5048c2ecf20Sopenharmony_ci 5058c2ecf20Sopenharmony_ci/** 5068c2ecf20Sopenharmony_ci * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning 5078c2ecf20Sopenharmony_ci * to a specified QP state. 5088c2ecf20Sopenharmony_ci * @cm_id: Communication identifier associated with the QP attributes to 5098c2ecf20Sopenharmony_ci * initialize. 5108c2ecf20Sopenharmony_ci * @qp_attr: On input, specifies the desired QP state. On output, the 5118c2ecf20Sopenharmony_ci * mandatory and desired optional attributes will be set in order to 5128c2ecf20Sopenharmony_ci * modify the QP to the specified state. 5138c2ecf20Sopenharmony_ci * @qp_attr_mask: The QP attribute mask that may be used to transition the 5148c2ecf20Sopenharmony_ci * QP to the specified state. 5158c2ecf20Sopenharmony_ci * 5168c2ecf20Sopenharmony_ci * Users must set the @qp_attr->qp_state to the desired QP state. This call 5178c2ecf20Sopenharmony_ci * will set all required attributes for the given transition, along with 5188c2ecf20Sopenharmony_ci * known optional attributes. Users may override the attributes returned from 5198c2ecf20Sopenharmony_ci * this call before calling ib_modify_qp. 5208c2ecf20Sopenharmony_ci */ 5218c2ecf20Sopenharmony_ciint ib_cm_init_qp_attr(struct ib_cm_id *cm_id, 5228c2ecf20Sopenharmony_ci struct ib_qp_attr *qp_attr, 5238c2ecf20Sopenharmony_ci int *qp_attr_mask); 5248c2ecf20Sopenharmony_ci 5258c2ecf20Sopenharmony_cistruct ib_cm_sidr_req_param { 5268c2ecf20Sopenharmony_ci struct sa_path_rec *path; 5278c2ecf20Sopenharmony_ci const struct ib_gid_attr *sgid_attr; 5288c2ecf20Sopenharmony_ci __be64 service_id; 5298c2ecf20Sopenharmony_ci unsigned long timeout_ms; 5308c2ecf20Sopenharmony_ci const void *private_data; 5318c2ecf20Sopenharmony_ci u8 private_data_len; 5328c2ecf20Sopenharmony_ci u8 max_cm_retries; 5338c2ecf20Sopenharmony_ci}; 5348c2ecf20Sopenharmony_ci 5358c2ecf20Sopenharmony_ci/** 5368c2ecf20Sopenharmony_ci * ib_send_cm_sidr_req - Sends a service ID resolution request to the 5378c2ecf20Sopenharmony_ci * remote node. 5388c2ecf20Sopenharmony_ci * @cm_id: Communication identifier that will be associated with the 5398c2ecf20Sopenharmony_ci * service ID resolution request. 5408c2ecf20Sopenharmony_ci * @param: Service ID resolution request information. 5418c2ecf20Sopenharmony_ci */ 5428c2ecf20Sopenharmony_ciint ib_send_cm_sidr_req(struct ib_cm_id *cm_id, 5438c2ecf20Sopenharmony_ci struct ib_cm_sidr_req_param *param); 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_cistruct ib_cm_sidr_rep_param { 5468c2ecf20Sopenharmony_ci u32 qp_num; 5478c2ecf20Sopenharmony_ci u32 qkey; 5488c2ecf20Sopenharmony_ci enum ib_cm_sidr_status status; 5498c2ecf20Sopenharmony_ci const void *info; 5508c2ecf20Sopenharmony_ci u8 info_length; 5518c2ecf20Sopenharmony_ci const void *private_data; 5528c2ecf20Sopenharmony_ci u8 private_data_len; 5538c2ecf20Sopenharmony_ci struct rdma_ucm_ece ece; 5548c2ecf20Sopenharmony_ci}; 5558c2ecf20Sopenharmony_ci 5568c2ecf20Sopenharmony_ci/** 5578c2ecf20Sopenharmony_ci * ib_send_cm_sidr_rep - Sends a service ID resolution reply to the 5588c2ecf20Sopenharmony_ci * remote node. 5598c2ecf20Sopenharmony_ci * @cm_id: Communication identifier associated with the received service ID 5608c2ecf20Sopenharmony_ci * resolution request. 5618c2ecf20Sopenharmony_ci * @param: Service ID resolution reply information. 5628c2ecf20Sopenharmony_ci */ 5638c2ecf20Sopenharmony_ciint ib_send_cm_sidr_rep(struct ib_cm_id *cm_id, 5648c2ecf20Sopenharmony_ci struct ib_cm_sidr_rep_param *param); 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ci/** 5678c2ecf20Sopenharmony_ci * ibcm_reject_msg - return a pointer to a reject message string. 5688c2ecf20Sopenharmony_ci * @reason: Value returned in the REJECT event status field. 5698c2ecf20Sopenharmony_ci */ 5708c2ecf20Sopenharmony_ciconst char *__attribute_const__ ibcm_reject_msg(int reason); 5718c2ecf20Sopenharmony_ci 5728c2ecf20Sopenharmony_ci#endif /* IB_CM_H */ 573