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