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 2007 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 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 /* 32 * ibtl_cm.h 33 * 34 * All data structures and function prototypes that are specific to the 35 * IBTL <-> IBCM private interface. 36 */ 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /* 43 * ibt_ud_dest_t is defined in ibtl_ci_types.h, it holds all the 44 * information needed to reach a UD destination. 45 * 46 * typedef struct ibt_ud_dest_s { 47 * ibc_ah_hdl_t ud_ah; * Address handle * 48 * ib_qpn_t ud_dst_qpn; * Destination QPN * 49 * ib_qkey_t ud_qkey; * Q_Key * 50 * 51 * * The following fields are CM-only, i.e., opaque to the CI * 52 * struct ibtl_hca_s *ud_hca; * IBTL HCA handle * 53 * } ibt_ud_dest_t; 54 */ 55 #define ud_dest_hca ud_dest_opaque1 56 57 /* CM private data */ 58 void ibtl_cm_set_chan_private(ibt_channel_hdl_t chan, void *cm_private); 59 void *ibtl_cm_get_chan_private(ibt_channel_hdl_t chan); 60 void ibtl_cm_release_chan_private(ibt_channel_hdl_t chan); 61 void ibtl_cm_wait_chan_private(ibt_channel_hdl_t chan); 62 63 /* 64 * ibtl_cm_get_hca_port() helper function will retrieve these for the 65 * specified SGID value. 66 */ 67 typedef struct ibtl_cm_hca_port_s { 68 ib_guid_t hp_hca_guid; /* HCA GUID. */ 69 ib_guid_t hp_port_guid; /* Port GUID. */ 70 ib_lid_t hp_base_lid; /* Base LID of Port. */ 71 uint8_t hp_port; /* HCA Port Number. */ 72 uint8_t hp_sgid_ix; /* SGID Index in SGID Table. */ 73 uint8_t hp_lmc:3; /* Local mask control */ 74 ib_mtu_t hp_mtu; /* Max transfer unit - pkt */ 75 } ibtl_cm_hca_port_t; 76 77 /* 78 * ibtl_cm_get_hca_port() 79 * 80 * A helper function to get HCA node GUID, Base LID, SGID Index, 81 * port number, LMC and MTU for the specified SGID. 82 * 83 * sgid Input Source GID. 84 * 85 * hca_guid Optional HCA Guid. 86 * 87 * hca_port Pointer to ibtl_cm_hca_port_t structure, 88 */ 89 ibt_status_t ibtl_cm_get_hca_port(ib_gid_t sgid, ib_guid_t hca_guid, 90 ibtl_cm_hca_port_t *hca_port); 91 92 93 ibt_status_t ibtl_cm_get_local_comp_gids(ib_guid_t hca_guid, ib_gid_t sgid, 94 ib_gid_t **gids_p, uint_t *num_gids_p); 95 96 int ibtl_cm_is_multi_sm(ib_guid_t hca_guid); 97 98 /* 99 * ibtl_cm_get_1st_full_pkey_ix() 100 * 101 * A helper function to get P_Key Index of the first full member P_Key 102 * available on the specified HCA and Port combination. 103 * 104 * hca_guid HCA GUID. 105 * 106 * port HCA port number. 107 */ 108 uint16_t ibtl_cm_get_1st_full_pkey_ix(ib_guid_t hca_guid, uint8_t port); 109 110 111 /* 112 * Functions to support CM and clients to reliably free RC QPs. 113 * 114 * ibtl_cm_chan_is_open() 115 * 116 * Inform IBTL that the connection has been established on this 117 * channel so that a later call to ibtl_cm_chan_is_closed() 118 * will be required to free the QPN used by this channel. 119 * 120 * ibtl_cm_chan_is_closing() 121 * 122 * Inform IBTL that the TIMEWAIT delay for the connection has been 123 * started for this channel so that the QP can be freed. 124 * 125 * ibtl_cm_is_chan_closing() 126 * 127 * Returns 1 if the connection on this channel has been moved to TIME WAIT 128 * 129 * ibtl_cm_is_chan_closed() 130 * 131 * Returns 1 if the connection on this channel has completed TIME WAIT 132 * 133 * ibtl_cm_chan_is_closed() 134 * 135 * Inform IBTL that the TIMEWAIT delay for the connection has been 136 * reached for this channel so that the QPN can be reused. 137 * 138 * rc_chan Channel Handle 139 * 140 * ibtl_cm_chan_is_reused() 141 * 142 * Inform IBTL that the channel is going to be re-used for another 143 * connection. 144 * 145 * rc_chan Channel Handle 146 */ 147 void ibtl_cm_chan_is_open(ibt_channel_hdl_t rc_chan); 148 void ibtl_cm_chan_is_closing(ibt_channel_hdl_t rc_chan); 149 void ibtl_cm_chan_is_closed(ibt_channel_hdl_t rc_chan); 150 void ibtl_cm_chan_is_reused(ibt_channel_hdl_t rc_chan); 151 int ibtl_cm_is_chan_closing(ibt_channel_hdl_t rc_chan); 152 int ibtl_cm_is_chan_closed(ibt_channel_hdl_t rc_chan); 153 154 /* 155 * ibtl_cm_get_chan_type() 156 * 157 * A helper function to get channel transport type. 158 */ 159 ibt_tran_srv_t ibtl_cm_get_chan_type(ibt_channel_hdl_t chan); 160 161 /* 162 * ibtl_cm_change_service_cnt() 163 * 164 * Inform IBTL that service registration count has changed 165 * so that it can correctly manage whether or not it should 166 * allow ibt_detach() to succeed. 167 */ 168 void ibtl_cm_change_service_cnt(ibt_clnt_hdl_t ibt_hdl, int delta_num_sids); 169 170 /* 171 * ibtl_cm_query_hca_ports_byguid() 172 * 173 * Use the cached copy of the portinfo. 174 */ 175 ibt_status_t ibtl_cm_query_hca_ports_byguid(ib_guid_t hca_guid, uint8_t port, 176 ibt_hca_portinfo_t **port_info_p, uint_t *ports_p, uint_t *size_p); 177 178 179 /* 180 * ibtl_cm_get_active_plist 181 * 182 * Returns a list of active source points which satisfy the desired 183 * attribute. The memory allocated for the array "port_list_p" should 184 * be freed by the caller using ibtl_cm_free_active_plist(). 185 * 186 * ibtl_cm_free_active_plist 187 * 188 * Frees the memory allocated in ibtl_cm_get_active_plist(). 189 */ 190 191 #define IBTL_CM_SIMPLE_SETUP 0 192 #define IBTL_CM_MULTI_SM (1 << 0) 193 #define IBTL_CM_MULTI_HCA (1 << 1) 194 195 typedef struct ibtl_cm_port_list_s { 196 ib_guid_t p_hca_guid; 197 ib_gid_t p_sgid; 198 ib_lid_t p_base_lid; 199 ib_mtu_t p_mtu; 200 uint8_t p_sgid_ix; 201 uint8_t p_port_num; 202 uint8_t p_count; 203 uint8_t p_multi; 204 void *p_saa_hdl; 205 ibt_ip_addr_t p_src_ip; 206 } ibtl_cm_port_list_t; 207 208 ibt_status_t ibtl_cm_get_active_plist(ibt_path_attr_t *attr, 209 ibt_path_flags_t flags, ibtl_cm_port_list_t **port_list_p); 210 void ibtl_cm_free_active_plist(ibtl_cm_port_list_t *port_list); 211 212 /* 213 * Functions to support ibt_register_subnet_notices and the 214 * related callbacks. 215 * 216 * ibtl_cm_set_sm_notice_handler 217 * Pass the handler into IBTL where it will actually be used. 218 * 219 * ibtl_cm_sm_notice_handler 220 * Post an event to interested IBT clients. 221 * 222 * ibtl_cm_sm_notice_init_failure 223 * Inform the client that callbacks are not working. 224 */ 225 void ibtl_cm_sm_notice_handler(ib_gid_t sgid, ibt_subnet_event_code_t code, 226 ibt_subnet_event_t *event); 227 228 void ibtl_cm_set_sm_notice_handler(ibt_clnt_hdl_t ibt_hdl, 229 ibt_sm_notice_handler_t sm_notice_handler, void *private); 230 231 /* pass all failing sgids at once */ 232 typedef struct ibtl_cm_sm_init_fail_s { 233 int smf_num_sgids; 234 ibt_clnt_hdl_t smf_ibt_hdl; 235 ib_gid_t smf_sgid[1]; 236 } ibtl_cm_sm_init_fail_t; 237 238 void ibtl_cm_sm_notice_init_failure(ibtl_cm_sm_init_fail_t *ifail); 239 240 #ifdef __cplusplus 241 } 242 #endif 243 244 #endif /* _SYS_IB_IBTL_IMPL_IBTL_CM_H */ 245