1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_IB_IBTL_IMPL_IBTL_CM_H 27 #define _SYS_IB_IBTL_IMPL_IBTL_CM_H 28 29 /* 30 * ibtl_cm.h 31 * 32 * All data structures and function prototypes that are specific to the 33 * IBTL <-> IBCM private interface. 34 */ 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 /* 41 * ibt_ud_dest_t is defined in ibtl_ci_types.h, it holds all the 42 * information needed to reach a UD destination. 43 * 44 * typedef struct ibt_ud_dest_s { 45 * ibc_ah_hdl_t ud_ah; * Address handle * 46 * ib_qpn_t ud_dst_qpn; * Destination QPN * 47 * ib_qkey_t ud_qkey; * Q_Key * 48 * 49 * * The following fields are CM-only, i.e., opaque to the CI * 50 * struct ibtl_hca_s *ud_hca; * IBTL HCA handle * 51 * } ibt_ud_dest_t; 52 */ 53 #define ud_dest_hca ud_dest_opaque1 54 55 /* CM private data */ 56 void ibtl_cm_set_chan_private(ibt_channel_hdl_t chan, void *cm_private); 57 void *ibtl_cm_get_chan_private(ibt_channel_hdl_t chan); 58 void ibtl_cm_release_chan_private(ibt_channel_hdl_t chan); 59 void ibtl_cm_wait_chan_private(ibt_channel_hdl_t chan); 60 61 /* 62 * ibtl_cm_get_hca_port() helper function will retrieve these for the 63 * specified SGID value. 64 */ 65 typedef struct ibtl_cm_hca_port_s { 66 ib_guid_t hp_hca_guid; /* HCA GUID. */ 67 ib_guid_t hp_port_guid; /* Port GUID. */ 68 ib_lid_t hp_base_lid; /* Base LID of Port. */ 69 uint8_t hp_port; /* HCA Port Number. */ 70 uint8_t hp_sgid_ix; /* SGID Index in SGID Table. */ 71 uint8_t hp_lmc:3; /* Local mask control */ 72 ib_mtu_t hp_mtu; /* Max transfer unit - pkt */ 73 } ibtl_cm_hca_port_t; 74 75 /* 76 * ibtl_cm_get_hca_port() 77 * 78 * A helper function to get HCA node GUID, Base LID, SGID Index, 79 * port number, LMC and MTU for the specified SGID. 80 * 81 * sgid Input Source GID. 82 * 83 * hca_guid Optional HCA Guid. 84 * 85 * hca_port Pointer to ibtl_cm_hca_port_t structure, 86 */ 87 ibt_status_t ibtl_cm_get_hca_port(ib_gid_t sgid, ib_guid_t hca_guid, 88 ibtl_cm_hca_port_t *hca_port); 89 90 91 ibt_status_t ibtl_cm_get_local_comp_gids(ib_guid_t hca_guid, ib_gid_t sgid, 92 ib_gid_t **gids_p, uint_t *num_gids_p); 93 94 int ibtl_cm_is_multi_sm(ib_guid_t hca_guid); 95 96 /* 97 * ibtl_cm_get_1st_full_pkey_ix() 98 * 99 * A helper function to get P_Key Index of the first full member P_Key 100 * available on the specified HCA and Port combination. 101 * 102 * hca_guid HCA GUID. 103 * 104 * port HCA port number. 105 */ 106 uint16_t ibtl_cm_get_1st_full_pkey_ix(ib_guid_t hca_guid, uint8_t port); 107 108 109 /* 110 * Functions to support CM and clients to reliably free RC QPs. 111 * 112 * ibtl_cm_chan_is_open() 113 * 114 * Inform IBTL that the connection has been established on this 115 * channel so that a later call to ibtl_cm_chan_is_closed() 116 * will be required to free the QPN used by this channel. 117 * 118 * ibtl_cm_chan_is_opening() 119 * 120 * Inform IBTL that the connection established on this channel is 121 * in progress. 122 * 123 * ibtl_cm_chan_is_closing() 124 * 125 * Inform IBTL that the TIMEWAIT delay for the connection has been 126 * started for this channel so that the QP can be freed. 127 * 128 * ibtl_cm_is_chan_closing() 129 * 130 * Returns 1 if the connection on this channel has been moved to TIME WAIT 131 * 132 * ibtl_cm_is_chan_closed() 133 * 134 * Returns 1 if the connection on this channel has completed TIME WAIT 135 * 136 * ibtl_cm_chan_is_closed() 137 * 138 * Inform IBTL that the TIMEWAIT delay for the connection has been 139 * reached for this channel so that the QPN can be reused. 140 * 141 * rc_chan Channel Handle 142 * 143 * ibtl_cm_chan_is_reused() 144 * 145 * Inform IBTL that the channel is going to be re-used for another 146 * connection. 147 * 148 * rc_chan Channel Handle 149 */ 150 void ibtl_cm_chan_is_open(ibt_channel_hdl_t rc_chan); 151 void ibtl_cm_chan_is_opening(ibt_channel_hdl_t rc_chan); 152 void ibtl_cm_chan_is_closing(ibt_channel_hdl_t rc_chan); 153 void ibtl_cm_chan_is_closed(ibt_channel_hdl_t rc_chan); 154 void ibtl_cm_chan_is_reused(ibt_channel_hdl_t rc_chan); 155 int ibtl_cm_is_chan_closing(ibt_channel_hdl_t rc_chan); 156 int ibtl_cm_is_chan_closed(ibt_channel_hdl_t rc_chan); 157 158 /* 159 * ibtl_cm_get_chan_type() 160 * 161 * A helper function to get channel transport type. 162 */ 163 ibt_tran_srv_t ibtl_cm_get_chan_type(ibt_channel_hdl_t chan); 164 165 /* 166 * ibtl_cm_change_service_cnt() 167 * 168 * Inform IBTL that service registration count has changed 169 * so that it can correctly manage whether or not it should 170 * allow ibt_detach() to succeed. 171 */ 172 void ibtl_cm_change_service_cnt(ibt_clnt_hdl_t ibt_hdl, int delta_num_sids); 173 174 /* 175 * ibtl_cm_query_hca_ports_byguid() 176 * 177 * Use the cached copy of the portinfo. 178 */ 179 ibt_status_t ibtl_cm_query_hca_ports_byguid(ib_guid_t hca_guid, uint8_t port, 180 ibt_hca_portinfo_t **port_info_p, uint_t *ports_p, uint_t *size_p); 181 182 183 /* 184 * ibtl_cm_get_active_plist 185 * 186 * Returns a list of active source points which satisfy the desired 187 * attribute. The memory allocated for the array "port_list_p" should 188 * be freed by the caller using ibtl_cm_free_active_plist(). 189 * 190 * ibtl_cm_free_active_plist 191 * 192 * Frees the memory allocated in ibtl_cm_get_active_plist(). 193 */ 194 195 #define IBTL_CM_SIMPLE_SETUP 0 196 #define IBTL_CM_MULTI_SM (1 << 0) 197 #define IBTL_CM_MULTI_HCA (1 << 1) 198 199 typedef struct ibtl_cm_port_list_s { 200 ib_guid_t p_hca_guid; 201 ib_gid_t p_sgid; 202 ib_lid_t p_base_lid; 203 ib_mtu_t p_mtu; 204 uint8_t p_sgid_ix; 205 uint8_t p_port_num; 206 uint8_t p_count; 207 uint8_t p_multi; 208 void *p_saa_hdl; 209 ibt_ip_addr_t p_src_ip; 210 } ibtl_cm_port_list_t; 211 212 ibt_status_t ibtl_cm_get_active_plist(ibt_path_attr_t *attr, 213 ibt_path_flags_t flags, ibtl_cm_port_list_t **port_list_p); 214 void ibtl_cm_free_active_plist(ibtl_cm_port_list_t *port_list); 215 216 /* 217 * Functions to support ibt_register_subnet_notices and the 218 * related callbacks. 219 * 220 * ibtl_cm_set_sm_notice_handler 221 * Pass the handler into IBTL where it will actually be used. 222 * 223 * ibtl_cm_sm_notice_handler 224 * Post an event to interested IBT clients. 225 * 226 * ibtl_cm_sm_notice_init_failure 227 * Inform the client that callbacks are not working. 228 */ 229 void ibtl_cm_sm_notice_handler(ib_gid_t sgid, ibt_subnet_event_code_t code, 230 ibt_subnet_event_t *event); 231 232 void ibtl_cm_set_sm_notice_handler(ibt_clnt_hdl_t ibt_hdl, 233 ibt_sm_notice_handler_t sm_notice_handler, void *private); 234 235 /* pass all failing sgids at once */ 236 typedef struct ibtl_cm_sm_init_fail_s { 237 int smf_num_sgids; 238 ibt_clnt_hdl_t smf_ibt_hdl; 239 ib_gid_t smf_sgid[1]; 240 } ibtl_cm_sm_init_fail_t; 241 242 void ibtl_cm_sm_notice_init_failure(ibtl_cm_sm_init_fail_t *ifail); 243 244 char *ibtl_cm_get_clnt_name(ibt_clnt_hdl_t ibt_hdl); 245 246 /* 247 * ibtl_cm_set_node_info_cb: This is a private interface between IBTL and IBCM 248 * to let IBTL get the Node Record of a remote port. This interface is used by 249 * IBCM to register a callback which can be used by IBTL to get the Node record. 250 */ 251 void ibtl_cm_set_node_info_cb(ibt_status_t (*)(ib_guid_t, uint8_t, ib_lid_t, 252 ibt_node_info_t *)); 253 254 #ifdef __cplusplus 255 } 256 #endif 257 258 #endif /* _SYS_IB_IBTL_IMPL_IBTL_CM_H */ 259