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 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 /* 26 * Copyright (c) 2005 SilverStorm Technologies, Inc. All rights reserved. 27 * 28 * This software is available to you under a choice of one of two 29 * licenses. You may choose to be licensed under the terms of the GNU 30 * General Public License (GPL) Version 2, available from the file 31 * COPYING in the main directory of this source tree, or the 32 * OpenIB.org BSD license below: 33 * 34 * Redistribution and use in source and binary forms, with or 35 * without modification, are permitted provided that the following 36 * conditions are met: 37 * 38 * - Redistributions of source code must retain the above 39 * copyright notice, this list of conditions and the following 40 * disclaimer. 41 * 42 * - Redistributions in binary form must reproduce the above 43 * copyright notice, this list of conditions and the following 44 * disclaimer in the documentation and/or other materials 45 * provided with the distribution. 46 * 47 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 48 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 49 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 50 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 51 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 52 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 53 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 54 * SOFTWARE. 55 * 56 */ 57 /* 58 * Sun elects to include this software in Sun product 59 * under the OpenIB BSD license. 60 * 61 * 62 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 63 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 64 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 65 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 66 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 67 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 68 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 69 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 70 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 71 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 72 * POSSIBILITY OF SUCH DAMAGE. 73 */ 74 75 #ifndef _RDSIB_IB_H 76 #define _RDSIB_IB_H 77 78 #pragma ident "%Z%%M% %I% %E% SMI" 79 80 #ifdef __cplusplus 81 extern "C" { 82 #endif 83 84 #include <sys/types.h> 85 #include <sys/ib/ibtl/ibti.h> 86 #include <sys/ib/ibtl/ibtl_types.h> 87 #include "rdsib_debug.h" 88 #include "rdsib_protocol.h" 89 90 /* 91 * Global Configuration Variables 92 * As defined in RDS proposal 93 */ 94 extern uint_t UserBufferSize; 95 extern uint_t RdsPktSize; 96 extern uint_t MaxRecvMemory; 97 extern uint_t MaxDataSendBuffers; 98 extern uint_t MaxDataRecvBuffers; 99 extern uint_t MaxCtrlSendBuffers; 100 extern uint_t MaxCtrlRecvBuffers; 101 extern uint_t DataRecvBufferLWM; 102 extern uint_t CtrlRecvBufferLWM; 103 extern uint_t PendingRxPktsHWM; 104 extern uint_t MinRnrRetry; 105 extern uint8_t IBPathRetryCount; 106 extern uint8_t IBPktLifeTime; 107 108 #ifdef DEBUG 109 extern uint32_t rdsdbglvl; 110 #else 111 extern uint32_t rdsdbglvl; 112 #endif 113 114 /* performance tunables */ 115 extern uint_t rds_no_interrupts; 116 extern uint_t rds_poll_percent_full; 117 extern uint_t rds_wc_signal; 118 extern uint_t rds_waittime_ms; 119 120 /* local port map */ 121 #define RDS_PORT_MAP_SIZE 8192 122 extern krwlock_t rds_local_portmap_lock; 123 extern uint8_t rds_local_portmap[RDS_PORT_MAP_SIZE]; 124 125 extern ddi_taskq_t *rds_taskq; 126 extern uint_t rds_rx_pkts_pending_hwm; /* readonly */ 127 128 /* Number of WCs to poll in a single call */ 129 #define RDS_NUM_DATA_SEND_WCS 10 130 #define RDS_RDMAW_WRID 0xdabadaba 131 #define RDS_NUM_ACKS 4 /* only 1 is used */ 132 133 /* 134 * There is one of this structure for each HCA in the system. 135 * This holds all the information about the HCA. 136 * 137 * hca_nextp - Points to the next hca in the system. 138 * hca_guid - HCA Guid 139 * hca_nports - Number of ports on the HCA 140 * hca_hdl - HCA hdl obtained after opening the HCA 141 * hca_pdhdl - PD hdl 142 * hca_lkey - LKey for the registered global receive buffer pool memory 143 * hca_rkey - Rkey for the registered global receive buffer pool memory 144 * hca_attrp - HCA attributes 145 * hca_pinfop - ptr to portinfo data, allocated by ibtf 146 * hca_pinfo_sz - Sizeof of portinfo data 147 */ 148 typedef struct rds_hca_s { 149 struct rds_hca_s *hca_nextp; 150 ib_guid_t hca_guid; 151 uint_t hca_nports; 152 ibt_hca_hdl_t hca_hdl; 153 ibt_pd_hdl_t hca_pdhdl; 154 ibt_mr_hdl_t hca_mrhdl; 155 ibt_lkey_t hca_lkey; 156 ibt_rkey_t hca_rkey; 157 ibt_hca_attr_t hca_attr; 158 ibt_hca_portinfo_t *hca_pinfop; 159 uint_t hca_pinfo_sz; 160 } rds_hca_t; 161 162 /* 163 * RDS Soft State 164 * NOTE: Only one soft state per driver and NOT per instance. 165 * 166 * sessionlock - protects the rds_session_t:session_nextp, this lock has 167 * to be taken for read/write acess of the sessions list. 168 * nsessions - Number of sessions in sessionlist 169 * sessionlistp - Pointer to the first session. 170 * ibhdl - Clnt handle acquired after registering with IBTF 171 * nhcas - Number of HCAs initialized. This is also the number of rds_hca_t 172 * structures in the rds_hcalistp. 173 * hcalistp - list of rds_hca_t. 174 * srvhdl - RDS service handle 175 */ 176 typedef struct rds_state_s { 177 krwlock_t rds_sessionlock; 178 uint_t rds_nsessions; 179 struct rds_session_s *rds_sessionlistp; 180 ibt_clnt_hdl_t rds_ibhdl; 181 krwlock_t rds_hca_lock; 182 uint_t rds_nhcas; 183 rds_hca_t *rds_hcalistp; 184 ibt_srv_hdl_t rds_srvhdl; 185 } rds_state_t; 186 187 extern rds_state_t *rdsib_statep; /* global */ 188 189 /* defined in rds_cm.c */ 190 ibt_srv_hdl_t rds_register_service(ibt_clnt_hdl_t rds_ibhdl); 191 int rds_bind_service(struct rds_state_s *statep); 192 193 /* defined in rds_ib.c */ 194 void rds_recvcq_handler(ibt_cq_hdl_t cq, void *); 195 rds_hca_t *rds_gid_to_hcap(rds_state_t *statep, ib_gid_t gid); 196 rds_hca_t *rds_get_hcap(rds_state_t *statep, ib_guid_t guid); 197 198 /* defined in rds_debug.c */ 199 void rds_logging_initialization(); 200 void rds_logging_destroy(); 201 202 #ifdef __cplusplus 203 } 204 #endif 205 206 #endif /* _RDSIB_IB_H */ 207