162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved. 462306a36Sopenharmony_ci * Copyright (c) 2004 Topspin Corporation. All rights reserved. 562306a36Sopenharmony_ci * Copyright (c) 2004 Voltaire Corporation. All rights reserved. 662306a36Sopenharmony_ci * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 762306a36Sopenharmony_ci * Copyright (c) 2019, Mellanox Technologies inc. All rights reserved. 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#ifndef IB_CM_H 1162306a36Sopenharmony_ci#define IB_CM_H 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#include <rdma/ib_mad.h> 1462306a36Sopenharmony_ci#include <rdma/ib_sa.h> 1562306a36Sopenharmony_ci#include <rdma/rdma_cm.h> 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_cienum ib_cm_state { 1862306a36Sopenharmony_ci IB_CM_IDLE, 1962306a36Sopenharmony_ci IB_CM_LISTEN, 2062306a36Sopenharmony_ci IB_CM_REQ_SENT, 2162306a36Sopenharmony_ci IB_CM_REQ_RCVD, 2262306a36Sopenharmony_ci IB_CM_MRA_REQ_SENT, 2362306a36Sopenharmony_ci IB_CM_MRA_REQ_RCVD, 2462306a36Sopenharmony_ci IB_CM_REP_SENT, 2562306a36Sopenharmony_ci IB_CM_REP_RCVD, 2662306a36Sopenharmony_ci IB_CM_MRA_REP_SENT, 2762306a36Sopenharmony_ci IB_CM_MRA_REP_RCVD, 2862306a36Sopenharmony_ci IB_CM_ESTABLISHED, 2962306a36Sopenharmony_ci IB_CM_DREQ_SENT, 3062306a36Sopenharmony_ci IB_CM_DREQ_RCVD, 3162306a36Sopenharmony_ci IB_CM_TIMEWAIT, 3262306a36Sopenharmony_ci IB_CM_SIDR_REQ_SENT, 3362306a36Sopenharmony_ci IB_CM_SIDR_REQ_RCVD 3462306a36Sopenharmony_ci}; 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_cienum ib_cm_lap_state { 3762306a36Sopenharmony_ci IB_CM_LAP_UNINIT, 3862306a36Sopenharmony_ci IB_CM_LAP_IDLE, 3962306a36Sopenharmony_ci IB_CM_LAP_SENT, 4062306a36Sopenharmony_ci IB_CM_LAP_RCVD, 4162306a36Sopenharmony_ci IB_CM_MRA_LAP_SENT, 4262306a36Sopenharmony_ci IB_CM_MRA_LAP_RCVD, 4362306a36Sopenharmony_ci}; 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_cienum ib_cm_event_type { 4662306a36Sopenharmony_ci IB_CM_REQ_ERROR, 4762306a36Sopenharmony_ci IB_CM_REQ_RECEIVED, 4862306a36Sopenharmony_ci IB_CM_REP_ERROR, 4962306a36Sopenharmony_ci IB_CM_REP_RECEIVED, 5062306a36Sopenharmony_ci IB_CM_RTU_RECEIVED, 5162306a36Sopenharmony_ci IB_CM_USER_ESTABLISHED, 5262306a36Sopenharmony_ci IB_CM_DREQ_ERROR, 5362306a36Sopenharmony_ci IB_CM_DREQ_RECEIVED, 5462306a36Sopenharmony_ci IB_CM_DREP_RECEIVED, 5562306a36Sopenharmony_ci IB_CM_TIMEWAIT_EXIT, 5662306a36Sopenharmony_ci IB_CM_MRA_RECEIVED, 5762306a36Sopenharmony_ci IB_CM_REJ_RECEIVED, 5862306a36Sopenharmony_ci IB_CM_LAP_ERROR, 5962306a36Sopenharmony_ci IB_CM_LAP_RECEIVED, 6062306a36Sopenharmony_ci IB_CM_APR_RECEIVED, 6162306a36Sopenharmony_ci IB_CM_SIDR_REQ_ERROR, 6262306a36Sopenharmony_ci IB_CM_SIDR_REQ_RECEIVED, 6362306a36Sopenharmony_ci IB_CM_SIDR_REP_RECEIVED 6462306a36Sopenharmony_ci}; 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_cienum ib_cm_data_size { 6762306a36Sopenharmony_ci IB_CM_REQ_PRIVATE_DATA_SIZE = 92, 6862306a36Sopenharmony_ci IB_CM_MRA_PRIVATE_DATA_SIZE = 222, 6962306a36Sopenharmony_ci IB_CM_REJ_PRIVATE_DATA_SIZE = 148, 7062306a36Sopenharmony_ci IB_CM_REP_PRIVATE_DATA_SIZE = 196, 7162306a36Sopenharmony_ci IB_CM_RTU_PRIVATE_DATA_SIZE = 224, 7262306a36Sopenharmony_ci IB_CM_DREQ_PRIVATE_DATA_SIZE = 220, 7362306a36Sopenharmony_ci IB_CM_DREP_PRIVATE_DATA_SIZE = 224, 7462306a36Sopenharmony_ci IB_CM_REJ_ARI_LENGTH = 72, 7562306a36Sopenharmony_ci IB_CM_LAP_PRIVATE_DATA_SIZE = 168, 7662306a36Sopenharmony_ci IB_CM_APR_PRIVATE_DATA_SIZE = 148, 7762306a36Sopenharmony_ci IB_CM_APR_INFO_LENGTH = 72, 7862306a36Sopenharmony_ci IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216, 7962306a36Sopenharmony_ci IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136, 8062306a36Sopenharmony_ci IB_CM_SIDR_REP_INFO_LENGTH = 72, 8162306a36Sopenharmony_ci}; 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_cistruct ib_cm_id; 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_cistruct ib_cm_req_event_param { 8662306a36Sopenharmony_ci struct ib_cm_id *listen_id; 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci /* P_Key that was used by the GMP's BTH header */ 8962306a36Sopenharmony_ci u16 bth_pkey; 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci u8 port; 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci struct sa_path_rec *primary_path; 9462306a36Sopenharmony_ci struct sa_path_rec *alternate_path; 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci /* 9762306a36Sopenharmony_ci * SGID attribute of the primary path. Currently only 9862306a36Sopenharmony_ci * useful for RoCE. Alternate path GID attributes 9962306a36Sopenharmony_ci * are not yet supported. 10062306a36Sopenharmony_ci */ 10162306a36Sopenharmony_ci const struct ib_gid_attr *ppath_sgid_attr; 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci __be64 remote_ca_guid; 10462306a36Sopenharmony_ci u32 remote_qkey; 10562306a36Sopenharmony_ci u32 remote_qpn; 10662306a36Sopenharmony_ci enum ib_qp_type qp_type; 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci u32 starting_psn; 10962306a36Sopenharmony_ci u8 responder_resources; 11062306a36Sopenharmony_ci u8 initiator_depth; 11162306a36Sopenharmony_ci unsigned int local_cm_response_timeout:5; 11262306a36Sopenharmony_ci unsigned int flow_control:1; 11362306a36Sopenharmony_ci unsigned int remote_cm_response_timeout:5; 11462306a36Sopenharmony_ci unsigned int retry_count:3; 11562306a36Sopenharmony_ci unsigned int rnr_retry_count:3; 11662306a36Sopenharmony_ci unsigned int srq:1; 11762306a36Sopenharmony_ci struct rdma_ucm_ece ece; 11862306a36Sopenharmony_ci}; 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_cistruct ib_cm_rep_event_param { 12162306a36Sopenharmony_ci __be64 remote_ca_guid; 12262306a36Sopenharmony_ci u32 remote_qkey; 12362306a36Sopenharmony_ci u32 remote_qpn; 12462306a36Sopenharmony_ci u32 starting_psn; 12562306a36Sopenharmony_ci u8 responder_resources; 12662306a36Sopenharmony_ci u8 initiator_depth; 12762306a36Sopenharmony_ci unsigned int target_ack_delay:5; 12862306a36Sopenharmony_ci unsigned int failover_accepted:2; 12962306a36Sopenharmony_ci unsigned int flow_control:1; 13062306a36Sopenharmony_ci unsigned int rnr_retry_count:3; 13162306a36Sopenharmony_ci unsigned int srq:1; 13262306a36Sopenharmony_ci struct rdma_ucm_ece ece; 13362306a36Sopenharmony_ci}; 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_cienum ib_cm_rej_reason { 13662306a36Sopenharmony_ci IB_CM_REJ_NO_QP = 1, 13762306a36Sopenharmony_ci IB_CM_REJ_NO_EEC = 2, 13862306a36Sopenharmony_ci IB_CM_REJ_NO_RESOURCES = 3, 13962306a36Sopenharmony_ci IB_CM_REJ_TIMEOUT = 4, 14062306a36Sopenharmony_ci IB_CM_REJ_UNSUPPORTED = 5, 14162306a36Sopenharmony_ci IB_CM_REJ_INVALID_COMM_ID = 6, 14262306a36Sopenharmony_ci IB_CM_REJ_INVALID_COMM_INSTANCE = 7, 14362306a36Sopenharmony_ci IB_CM_REJ_INVALID_SERVICE_ID = 8, 14462306a36Sopenharmony_ci IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9, 14562306a36Sopenharmony_ci IB_CM_REJ_STALE_CONN = 10, 14662306a36Sopenharmony_ci IB_CM_REJ_RDC_NOT_EXIST = 11, 14762306a36Sopenharmony_ci IB_CM_REJ_INVALID_GID = 12, 14862306a36Sopenharmony_ci IB_CM_REJ_INVALID_LID = 13, 14962306a36Sopenharmony_ci IB_CM_REJ_INVALID_SL = 14, 15062306a36Sopenharmony_ci IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15, 15162306a36Sopenharmony_ci IB_CM_REJ_INVALID_HOP_LIMIT = 16, 15262306a36Sopenharmony_ci IB_CM_REJ_INVALID_PACKET_RATE = 17, 15362306a36Sopenharmony_ci IB_CM_REJ_INVALID_ALT_GID = 18, 15462306a36Sopenharmony_ci IB_CM_REJ_INVALID_ALT_LID = 19, 15562306a36Sopenharmony_ci IB_CM_REJ_INVALID_ALT_SL = 20, 15662306a36Sopenharmony_ci IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21, 15762306a36Sopenharmony_ci IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22, 15862306a36Sopenharmony_ci IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23, 15962306a36Sopenharmony_ci IB_CM_REJ_PORT_CM_REDIRECT = 24, 16062306a36Sopenharmony_ci IB_CM_REJ_PORT_REDIRECT = 25, 16162306a36Sopenharmony_ci IB_CM_REJ_INVALID_MTU = 26, 16262306a36Sopenharmony_ci IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27, 16362306a36Sopenharmony_ci IB_CM_REJ_CONSUMER_DEFINED = 28, 16462306a36Sopenharmony_ci IB_CM_REJ_INVALID_RNR_RETRY = 29, 16562306a36Sopenharmony_ci IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30, 16662306a36Sopenharmony_ci IB_CM_REJ_INVALID_CLASS_VERSION = 31, 16762306a36Sopenharmony_ci IB_CM_REJ_INVALID_FLOW_LABEL = 32, 16862306a36Sopenharmony_ci IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33, 16962306a36Sopenharmony_ci IB_CM_REJ_VENDOR_OPTION_NOT_SUPPORTED = 35, 17062306a36Sopenharmony_ci}; 17162306a36Sopenharmony_ci 17262306a36Sopenharmony_cistruct ib_cm_rej_event_param { 17362306a36Sopenharmony_ci enum ib_cm_rej_reason reason; 17462306a36Sopenharmony_ci void *ari; 17562306a36Sopenharmony_ci u8 ari_length; 17662306a36Sopenharmony_ci}; 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_cistruct ib_cm_mra_event_param { 17962306a36Sopenharmony_ci u8 service_timeout; 18062306a36Sopenharmony_ci}; 18162306a36Sopenharmony_ci 18262306a36Sopenharmony_cistruct ib_cm_lap_event_param { 18362306a36Sopenharmony_ci struct sa_path_rec *alternate_path; 18462306a36Sopenharmony_ci}; 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_cienum ib_cm_apr_status { 18762306a36Sopenharmony_ci IB_CM_APR_SUCCESS, 18862306a36Sopenharmony_ci IB_CM_APR_INVALID_COMM_ID, 18962306a36Sopenharmony_ci IB_CM_APR_UNSUPPORTED, 19062306a36Sopenharmony_ci IB_CM_APR_REJECT, 19162306a36Sopenharmony_ci IB_CM_APR_REDIRECT, 19262306a36Sopenharmony_ci IB_CM_APR_IS_CURRENT, 19362306a36Sopenharmony_ci IB_CM_APR_INVALID_QPN_EECN, 19462306a36Sopenharmony_ci IB_CM_APR_INVALID_LID, 19562306a36Sopenharmony_ci IB_CM_APR_INVALID_GID, 19662306a36Sopenharmony_ci IB_CM_APR_INVALID_FLOW_LABEL, 19762306a36Sopenharmony_ci IB_CM_APR_INVALID_TCLASS, 19862306a36Sopenharmony_ci IB_CM_APR_INVALID_HOP_LIMIT, 19962306a36Sopenharmony_ci IB_CM_APR_INVALID_PACKET_RATE, 20062306a36Sopenharmony_ci IB_CM_APR_INVALID_SL 20162306a36Sopenharmony_ci}; 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_cistruct ib_cm_apr_event_param { 20462306a36Sopenharmony_ci enum ib_cm_apr_status ap_status; 20562306a36Sopenharmony_ci void *apr_info; 20662306a36Sopenharmony_ci u8 info_len; 20762306a36Sopenharmony_ci}; 20862306a36Sopenharmony_ci 20962306a36Sopenharmony_cistruct ib_cm_sidr_req_event_param { 21062306a36Sopenharmony_ci struct ib_cm_id *listen_id; 21162306a36Sopenharmony_ci __be64 service_id; 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci /* 21462306a36Sopenharmony_ci * SGID attribute of the request. Currently only 21562306a36Sopenharmony_ci * useful for RoCE. 21662306a36Sopenharmony_ci */ 21762306a36Sopenharmony_ci const struct ib_gid_attr *sgid_attr; 21862306a36Sopenharmony_ci /* P_Key that was used by the GMP's BTH header */ 21962306a36Sopenharmony_ci u16 bth_pkey; 22062306a36Sopenharmony_ci u8 port; 22162306a36Sopenharmony_ci u16 pkey; 22262306a36Sopenharmony_ci}; 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_cienum ib_cm_sidr_status { 22562306a36Sopenharmony_ci IB_SIDR_SUCCESS, 22662306a36Sopenharmony_ci IB_SIDR_UNSUPPORTED, 22762306a36Sopenharmony_ci IB_SIDR_REJECT, 22862306a36Sopenharmony_ci IB_SIDR_NO_QP, 22962306a36Sopenharmony_ci IB_SIDR_REDIRECT, 23062306a36Sopenharmony_ci IB_SIDR_UNSUPPORTED_VERSION 23162306a36Sopenharmony_ci}; 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_cistruct ib_cm_sidr_rep_event_param { 23462306a36Sopenharmony_ci enum ib_cm_sidr_status status; 23562306a36Sopenharmony_ci u32 qkey; 23662306a36Sopenharmony_ci u32 qpn; 23762306a36Sopenharmony_ci void *info; 23862306a36Sopenharmony_ci const struct ib_gid_attr *sgid_attr; 23962306a36Sopenharmony_ci u8 info_len; 24062306a36Sopenharmony_ci}; 24162306a36Sopenharmony_ci 24262306a36Sopenharmony_cistruct ib_cm_event { 24362306a36Sopenharmony_ci enum ib_cm_event_type event; 24462306a36Sopenharmony_ci union { 24562306a36Sopenharmony_ci struct ib_cm_req_event_param req_rcvd; 24662306a36Sopenharmony_ci struct ib_cm_rep_event_param rep_rcvd; 24762306a36Sopenharmony_ci /* No data for RTU received events. */ 24862306a36Sopenharmony_ci struct ib_cm_rej_event_param rej_rcvd; 24962306a36Sopenharmony_ci struct ib_cm_mra_event_param mra_rcvd; 25062306a36Sopenharmony_ci struct ib_cm_lap_event_param lap_rcvd; 25162306a36Sopenharmony_ci struct ib_cm_apr_event_param apr_rcvd; 25262306a36Sopenharmony_ci /* No data for DREQ/DREP received events. */ 25362306a36Sopenharmony_ci struct ib_cm_sidr_req_event_param sidr_req_rcvd; 25462306a36Sopenharmony_ci struct ib_cm_sidr_rep_event_param sidr_rep_rcvd; 25562306a36Sopenharmony_ci enum ib_wc_status send_status; 25662306a36Sopenharmony_ci } param; 25762306a36Sopenharmony_ci 25862306a36Sopenharmony_ci void *private_data; 25962306a36Sopenharmony_ci}; 26062306a36Sopenharmony_ci 26162306a36Sopenharmony_ci#define CM_REQ_ATTR_ID cpu_to_be16(0x0010) 26262306a36Sopenharmony_ci#define CM_MRA_ATTR_ID cpu_to_be16(0x0011) 26362306a36Sopenharmony_ci#define CM_REJ_ATTR_ID cpu_to_be16(0x0012) 26462306a36Sopenharmony_ci#define CM_REP_ATTR_ID cpu_to_be16(0x0013) 26562306a36Sopenharmony_ci#define CM_RTU_ATTR_ID cpu_to_be16(0x0014) 26662306a36Sopenharmony_ci#define CM_DREQ_ATTR_ID cpu_to_be16(0x0015) 26762306a36Sopenharmony_ci#define CM_DREP_ATTR_ID cpu_to_be16(0x0016) 26862306a36Sopenharmony_ci#define CM_SIDR_REQ_ATTR_ID cpu_to_be16(0x0017) 26962306a36Sopenharmony_ci#define CM_SIDR_REP_ATTR_ID cpu_to_be16(0x0018) 27062306a36Sopenharmony_ci#define CM_LAP_ATTR_ID cpu_to_be16(0x0019) 27162306a36Sopenharmony_ci#define CM_APR_ATTR_ID cpu_to_be16(0x001A) 27262306a36Sopenharmony_ci 27362306a36Sopenharmony_ci/** 27462306a36Sopenharmony_ci * ib_cm_handler - User-defined callback to process communication events. 27562306a36Sopenharmony_ci * @cm_id: Communication identifier associated with the reported event. 27662306a36Sopenharmony_ci * @event: Information about the communication event. 27762306a36Sopenharmony_ci * 27862306a36Sopenharmony_ci * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events 27962306a36Sopenharmony_ci * generated as a result of listen requests result in the allocation of a 28062306a36Sopenharmony_ci * new @cm_id. The new @cm_id is returned to the user through this callback. 28162306a36Sopenharmony_ci * Clients are responsible for destroying the new @cm_id. For peer-to-peer 28262306a36Sopenharmony_ci * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds 28362306a36Sopenharmony_ci * to a user's existing communication identifier. 28462306a36Sopenharmony_ci * 28562306a36Sopenharmony_ci * Users may not call ib_destroy_cm_id while in the context of this callback; 28662306a36Sopenharmony_ci * however, returning a non-zero value instructs the communication manager to 28762306a36Sopenharmony_ci * destroy the @cm_id after the callback completes. 28862306a36Sopenharmony_ci */ 28962306a36Sopenharmony_citypedef int (*ib_cm_handler)(struct ib_cm_id *cm_id, 29062306a36Sopenharmony_ci const struct ib_cm_event *event); 29162306a36Sopenharmony_ci 29262306a36Sopenharmony_cistruct ib_cm_id { 29362306a36Sopenharmony_ci ib_cm_handler cm_handler; 29462306a36Sopenharmony_ci void *context; 29562306a36Sopenharmony_ci struct ib_device *device; 29662306a36Sopenharmony_ci __be64 service_id; 29762306a36Sopenharmony_ci enum ib_cm_state state; /* internal CM/debug use */ 29862306a36Sopenharmony_ci enum ib_cm_lap_state lap_state; /* internal CM/debug use */ 29962306a36Sopenharmony_ci __be32 local_id; 30062306a36Sopenharmony_ci __be32 remote_id; 30162306a36Sopenharmony_ci u32 remote_cm_qpn; /* 1 unless redirected */ 30262306a36Sopenharmony_ci}; 30362306a36Sopenharmony_ci 30462306a36Sopenharmony_ci/** 30562306a36Sopenharmony_ci * ib_create_cm_id - Allocate a communication identifier. 30662306a36Sopenharmony_ci * @device: Device associated with the cm_id. All related communication will 30762306a36Sopenharmony_ci * be associated with the specified device. 30862306a36Sopenharmony_ci * @cm_handler: Callback invoked to notify the user of CM events. 30962306a36Sopenharmony_ci * @context: User specified context associated with the communication 31062306a36Sopenharmony_ci * identifier. 31162306a36Sopenharmony_ci * 31262306a36Sopenharmony_ci * Communication identifiers are used to track connection states, service 31362306a36Sopenharmony_ci * ID resolution requests, and listen requests. 31462306a36Sopenharmony_ci */ 31562306a36Sopenharmony_cistruct ib_cm_id *ib_create_cm_id(struct ib_device *device, 31662306a36Sopenharmony_ci ib_cm_handler cm_handler, 31762306a36Sopenharmony_ci void *context); 31862306a36Sopenharmony_ci 31962306a36Sopenharmony_ci/** 32062306a36Sopenharmony_ci * ib_destroy_cm_id - Destroy a connection identifier. 32162306a36Sopenharmony_ci * @cm_id: Connection identifier to destroy. 32262306a36Sopenharmony_ci * 32362306a36Sopenharmony_ci * This call blocks until the connection identifier is destroyed. 32462306a36Sopenharmony_ci */ 32562306a36Sopenharmony_civoid ib_destroy_cm_id(struct ib_cm_id *cm_id); 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci#define IB_SERVICE_ID_AGN_MASK cpu_to_be64(0xFF00000000000000ULL) 32862306a36Sopenharmony_ci#define IB_CM_ASSIGN_SERVICE_ID cpu_to_be64(0x0200000000000000ULL) 32962306a36Sopenharmony_ci#define IB_CMA_SERVICE_ID cpu_to_be64(0x0000000001000000ULL) 33062306a36Sopenharmony_ci#define IB_CMA_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFF000000ULL) 33162306a36Sopenharmony_ci#define IB_SDP_SERVICE_ID cpu_to_be64(0x0000000000010000ULL) 33262306a36Sopenharmony_ci#define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL) 33362306a36Sopenharmony_ci 33462306a36Sopenharmony_ci/** 33562306a36Sopenharmony_ci * ib_cm_listen - Initiates listening on the specified service ID for 33662306a36Sopenharmony_ci * connection and service ID resolution requests. 33762306a36Sopenharmony_ci * @cm_id: Connection identifier associated with the listen request. 33862306a36Sopenharmony_ci * @service_id: Service identifier matched against incoming connection 33962306a36Sopenharmony_ci * and service ID resolution requests. The service ID should be specified 34062306a36Sopenharmony_ci * network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will 34162306a36Sopenharmony_ci * assign a service ID to the caller. 34262306a36Sopenharmony_ci */ 34362306a36Sopenharmony_ciint ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id); 34462306a36Sopenharmony_ci 34562306a36Sopenharmony_cistruct ib_cm_id *ib_cm_insert_listen(struct ib_device *device, 34662306a36Sopenharmony_ci ib_cm_handler cm_handler, 34762306a36Sopenharmony_ci __be64 service_id); 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_cistruct ib_cm_req_param { 35062306a36Sopenharmony_ci struct sa_path_rec *primary_path; 35162306a36Sopenharmony_ci struct sa_path_rec *primary_path_inbound; 35262306a36Sopenharmony_ci struct sa_path_rec *primary_path_outbound; 35362306a36Sopenharmony_ci struct sa_path_rec *alternate_path; 35462306a36Sopenharmony_ci const struct ib_gid_attr *ppath_sgid_attr; 35562306a36Sopenharmony_ci __be64 service_id; 35662306a36Sopenharmony_ci u32 qp_num; 35762306a36Sopenharmony_ci enum ib_qp_type qp_type; 35862306a36Sopenharmony_ci u32 starting_psn; 35962306a36Sopenharmony_ci const void *private_data; 36062306a36Sopenharmony_ci u8 private_data_len; 36162306a36Sopenharmony_ci u8 responder_resources; 36262306a36Sopenharmony_ci u8 initiator_depth; 36362306a36Sopenharmony_ci u8 remote_cm_response_timeout; 36462306a36Sopenharmony_ci u8 flow_control; 36562306a36Sopenharmony_ci u8 local_cm_response_timeout; 36662306a36Sopenharmony_ci u8 retry_count; 36762306a36Sopenharmony_ci u8 rnr_retry_count; 36862306a36Sopenharmony_ci u8 max_cm_retries; 36962306a36Sopenharmony_ci u8 srq; 37062306a36Sopenharmony_ci struct rdma_ucm_ece ece; 37162306a36Sopenharmony_ci}; 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_ci/** 37462306a36Sopenharmony_ci * ib_send_cm_req - Sends a connection request to the remote node. 37562306a36Sopenharmony_ci * @cm_id: Connection identifier that will be associated with the 37662306a36Sopenharmony_ci * connection request. 37762306a36Sopenharmony_ci * @param: Connection request information needed to establish the 37862306a36Sopenharmony_ci * connection. 37962306a36Sopenharmony_ci */ 38062306a36Sopenharmony_ciint ib_send_cm_req(struct ib_cm_id *cm_id, 38162306a36Sopenharmony_ci struct ib_cm_req_param *param); 38262306a36Sopenharmony_ci 38362306a36Sopenharmony_cistruct ib_cm_rep_param { 38462306a36Sopenharmony_ci u32 qp_num; 38562306a36Sopenharmony_ci u32 starting_psn; 38662306a36Sopenharmony_ci const void *private_data; 38762306a36Sopenharmony_ci u8 private_data_len; 38862306a36Sopenharmony_ci u8 responder_resources; 38962306a36Sopenharmony_ci u8 initiator_depth; 39062306a36Sopenharmony_ci u8 failover_accepted; 39162306a36Sopenharmony_ci u8 flow_control; 39262306a36Sopenharmony_ci u8 rnr_retry_count; 39362306a36Sopenharmony_ci u8 srq; 39462306a36Sopenharmony_ci struct rdma_ucm_ece ece; 39562306a36Sopenharmony_ci}; 39662306a36Sopenharmony_ci 39762306a36Sopenharmony_ci/** 39862306a36Sopenharmony_ci * ib_send_cm_rep - Sends a connection reply in response to a connection 39962306a36Sopenharmony_ci * request. 40062306a36Sopenharmony_ci * @cm_id: Connection identifier that will be associated with the 40162306a36Sopenharmony_ci * connection request. 40262306a36Sopenharmony_ci * @param: Connection reply information needed to establish the 40362306a36Sopenharmony_ci * connection. 40462306a36Sopenharmony_ci */ 40562306a36Sopenharmony_ciint ib_send_cm_rep(struct ib_cm_id *cm_id, 40662306a36Sopenharmony_ci struct ib_cm_rep_param *param); 40762306a36Sopenharmony_ci 40862306a36Sopenharmony_ci/** 40962306a36Sopenharmony_ci * ib_send_cm_rtu - Sends a connection ready to use message in response 41062306a36Sopenharmony_ci * to a connection reply message. 41162306a36Sopenharmony_ci * @cm_id: Connection identifier associated with the connection request. 41262306a36Sopenharmony_ci * @private_data: Optional user-defined private data sent with the 41362306a36Sopenharmony_ci * ready to use message. 41462306a36Sopenharmony_ci * @private_data_len: Size of the private data buffer, in bytes. 41562306a36Sopenharmony_ci */ 41662306a36Sopenharmony_ciint ib_send_cm_rtu(struct ib_cm_id *cm_id, 41762306a36Sopenharmony_ci const void *private_data, 41862306a36Sopenharmony_ci u8 private_data_len); 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_ci/** 42162306a36Sopenharmony_ci * ib_send_cm_dreq - Sends a disconnection request for an existing 42262306a36Sopenharmony_ci * connection. 42362306a36Sopenharmony_ci * @cm_id: Connection identifier associated with the connection being 42462306a36Sopenharmony_ci * released. 42562306a36Sopenharmony_ci * @private_data: Optional user-defined private data sent with the 42662306a36Sopenharmony_ci * disconnection request message. 42762306a36Sopenharmony_ci * @private_data_len: Size of the private data buffer, in bytes. 42862306a36Sopenharmony_ci */ 42962306a36Sopenharmony_ciint ib_send_cm_dreq(struct ib_cm_id *cm_id, 43062306a36Sopenharmony_ci const void *private_data, 43162306a36Sopenharmony_ci u8 private_data_len); 43262306a36Sopenharmony_ci 43362306a36Sopenharmony_ci/** 43462306a36Sopenharmony_ci * ib_send_cm_drep - Sends a disconnection reply to a disconnection request. 43562306a36Sopenharmony_ci * @cm_id: Connection identifier associated with the connection being 43662306a36Sopenharmony_ci * released. 43762306a36Sopenharmony_ci * @private_data: Optional user-defined private data sent with the 43862306a36Sopenharmony_ci * disconnection reply message. 43962306a36Sopenharmony_ci * @private_data_len: Size of the private data buffer, in bytes. 44062306a36Sopenharmony_ci * 44162306a36Sopenharmony_ci * If the cm_id is in the correct state, the CM will transition the connection 44262306a36Sopenharmony_ci * to the timewait state, even if an error occurs sending the DREP message. 44362306a36Sopenharmony_ci */ 44462306a36Sopenharmony_ciint ib_send_cm_drep(struct ib_cm_id *cm_id, 44562306a36Sopenharmony_ci const void *private_data, 44662306a36Sopenharmony_ci u8 private_data_len); 44762306a36Sopenharmony_ci 44862306a36Sopenharmony_ci/** 44962306a36Sopenharmony_ci * ib_cm_notify - Notifies the CM of an event reported to the consumer. 45062306a36Sopenharmony_ci * @cm_id: Connection identifier to transition to established. 45162306a36Sopenharmony_ci * @event: Type of event. 45262306a36Sopenharmony_ci * 45362306a36Sopenharmony_ci * This routine should be invoked by users to notify the CM of relevant 45462306a36Sopenharmony_ci * communication events. Events that should be reported to the CM and 45562306a36Sopenharmony_ci * when to report them are: 45662306a36Sopenharmony_ci * 45762306a36Sopenharmony_ci * IB_EVENT_COMM_EST - Used when a message is received on a connected 45862306a36Sopenharmony_ci * QP before an RTU has been received. 45962306a36Sopenharmony_ci * IB_EVENT_PATH_MIG - Notifies the CM that the connection has failed over 46062306a36Sopenharmony_ci * to the alternate path. 46162306a36Sopenharmony_ci */ 46262306a36Sopenharmony_ciint ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event); 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_ci/** 46562306a36Sopenharmony_ci * ib_send_cm_rej - Sends a connection rejection message to the 46662306a36Sopenharmony_ci * remote node. 46762306a36Sopenharmony_ci * @cm_id: Connection identifier associated with the connection being 46862306a36Sopenharmony_ci * rejected. 46962306a36Sopenharmony_ci * @reason: Reason for the connection request rejection. 47062306a36Sopenharmony_ci * @ari: Optional additional rejection information. 47162306a36Sopenharmony_ci * @ari_length: Size of the additional rejection information, in bytes. 47262306a36Sopenharmony_ci * @private_data: Optional user-defined private data sent with the 47362306a36Sopenharmony_ci * rejection message. 47462306a36Sopenharmony_ci * @private_data_len: Size of the private data buffer, in bytes. 47562306a36Sopenharmony_ci */ 47662306a36Sopenharmony_ciint ib_send_cm_rej(struct ib_cm_id *cm_id, 47762306a36Sopenharmony_ci enum ib_cm_rej_reason reason, 47862306a36Sopenharmony_ci void *ari, 47962306a36Sopenharmony_ci u8 ari_length, 48062306a36Sopenharmony_ci const void *private_data, 48162306a36Sopenharmony_ci u8 private_data_len); 48262306a36Sopenharmony_ci 48362306a36Sopenharmony_ci#define IB_CM_MRA_FLAG_DELAY 0x80 /* Send MRA only after a duplicate msg */ 48462306a36Sopenharmony_ci 48562306a36Sopenharmony_ci/** 48662306a36Sopenharmony_ci * ib_send_cm_mra - Sends a message receipt acknowledgement to a connection 48762306a36Sopenharmony_ci * message. 48862306a36Sopenharmony_ci * @cm_id: Connection identifier associated with the connection message. 48962306a36Sopenharmony_ci * @service_timeout: The lower 5-bits specify the maximum time required for 49062306a36Sopenharmony_ci * the sender to reply to the connection message. The upper 3-bits 49162306a36Sopenharmony_ci * specify additional control flags. 49262306a36Sopenharmony_ci * @private_data: Optional user-defined private data sent with the 49362306a36Sopenharmony_ci * message receipt acknowledgement. 49462306a36Sopenharmony_ci * @private_data_len: Size of the private data buffer, in bytes. 49562306a36Sopenharmony_ci */ 49662306a36Sopenharmony_ciint ib_send_cm_mra(struct ib_cm_id *cm_id, 49762306a36Sopenharmony_ci u8 service_timeout, 49862306a36Sopenharmony_ci const void *private_data, 49962306a36Sopenharmony_ci u8 private_data_len); 50062306a36Sopenharmony_ci 50162306a36Sopenharmony_ci/** 50262306a36Sopenharmony_ci * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning 50362306a36Sopenharmony_ci * to a specified QP state. 50462306a36Sopenharmony_ci * @cm_id: Communication identifier associated with the QP attributes to 50562306a36Sopenharmony_ci * initialize. 50662306a36Sopenharmony_ci * @qp_attr: On input, specifies the desired QP state. On output, the 50762306a36Sopenharmony_ci * mandatory and desired optional attributes will be set in order to 50862306a36Sopenharmony_ci * modify the QP to the specified state. 50962306a36Sopenharmony_ci * @qp_attr_mask: The QP attribute mask that may be used to transition the 51062306a36Sopenharmony_ci * QP to the specified state. 51162306a36Sopenharmony_ci * 51262306a36Sopenharmony_ci * Users must set the @qp_attr->qp_state to the desired QP state. This call 51362306a36Sopenharmony_ci * will set all required attributes for the given transition, along with 51462306a36Sopenharmony_ci * known optional attributes. Users may override the attributes returned from 51562306a36Sopenharmony_ci * this call before calling ib_modify_qp. 51662306a36Sopenharmony_ci */ 51762306a36Sopenharmony_ciint ib_cm_init_qp_attr(struct ib_cm_id *cm_id, 51862306a36Sopenharmony_ci struct ib_qp_attr *qp_attr, 51962306a36Sopenharmony_ci int *qp_attr_mask); 52062306a36Sopenharmony_ci 52162306a36Sopenharmony_cistruct ib_cm_sidr_req_param { 52262306a36Sopenharmony_ci struct sa_path_rec *path; 52362306a36Sopenharmony_ci const struct ib_gid_attr *sgid_attr; 52462306a36Sopenharmony_ci __be64 service_id; 52562306a36Sopenharmony_ci unsigned long timeout_ms; 52662306a36Sopenharmony_ci const void *private_data; 52762306a36Sopenharmony_ci u8 private_data_len; 52862306a36Sopenharmony_ci u8 max_cm_retries; 52962306a36Sopenharmony_ci}; 53062306a36Sopenharmony_ci 53162306a36Sopenharmony_ci/** 53262306a36Sopenharmony_ci * ib_send_cm_sidr_req - Sends a service ID resolution request to the 53362306a36Sopenharmony_ci * remote node. 53462306a36Sopenharmony_ci * @cm_id: Communication identifier that will be associated with the 53562306a36Sopenharmony_ci * service ID resolution request. 53662306a36Sopenharmony_ci * @param: Service ID resolution request information. 53762306a36Sopenharmony_ci */ 53862306a36Sopenharmony_ciint ib_send_cm_sidr_req(struct ib_cm_id *cm_id, 53962306a36Sopenharmony_ci struct ib_cm_sidr_req_param *param); 54062306a36Sopenharmony_ci 54162306a36Sopenharmony_cistruct ib_cm_sidr_rep_param { 54262306a36Sopenharmony_ci u32 qp_num; 54362306a36Sopenharmony_ci u32 qkey; 54462306a36Sopenharmony_ci enum ib_cm_sidr_status status; 54562306a36Sopenharmony_ci const void *info; 54662306a36Sopenharmony_ci u8 info_length; 54762306a36Sopenharmony_ci const void *private_data; 54862306a36Sopenharmony_ci u8 private_data_len; 54962306a36Sopenharmony_ci struct rdma_ucm_ece ece; 55062306a36Sopenharmony_ci}; 55162306a36Sopenharmony_ci 55262306a36Sopenharmony_ci/** 55362306a36Sopenharmony_ci * ib_send_cm_sidr_rep - Sends a service ID resolution reply to the 55462306a36Sopenharmony_ci * remote node. 55562306a36Sopenharmony_ci * @cm_id: Communication identifier associated with the received service ID 55662306a36Sopenharmony_ci * resolution request. 55762306a36Sopenharmony_ci * @param: Service ID resolution reply information. 55862306a36Sopenharmony_ci */ 55962306a36Sopenharmony_ciint ib_send_cm_sidr_rep(struct ib_cm_id *cm_id, 56062306a36Sopenharmony_ci struct ib_cm_sidr_rep_param *param); 56162306a36Sopenharmony_ci 56262306a36Sopenharmony_ci/** 56362306a36Sopenharmony_ci * ibcm_reject_msg - return a pointer to a reject message string. 56462306a36Sopenharmony_ci * @reason: Value returned in the REJECT event status field. 56562306a36Sopenharmony_ci */ 56662306a36Sopenharmony_ciconst char *__attribute_const__ ibcm_reject_msg(int reason); 56762306a36Sopenharmony_ci 56862306a36Sopenharmony_ci#endif /* IB_CM_H */ 569