13302Sagiri /* 23302Sagiri * CDDL HEADER START 33302Sagiri * 43302Sagiri * The contents of this file are subject to the terms of the 53302Sagiri * Common Development and Distribution License (the "License"). 63302Sagiri * You may not use this file except in compliance with the License. 73302Sagiri * 83302Sagiri * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93302Sagiri * or http://www.opensolaris.org/os/licensing. 103302Sagiri * See the License for the specific language governing permissions 113302Sagiri * and limitations under the License. 123302Sagiri * 133302Sagiri * When distributing Covered Code, include this CDDL HEADER in each 143302Sagiri * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153302Sagiri * If applicable, add the following below this CDDL HEADER, with the 163302Sagiri * fields enclosed by brackets "[]" replaced with your own identifying 173302Sagiri * information: Portions Copyright [yyyy] [name of copyright owner] 183302Sagiri * 193302Sagiri * CDDL HEADER END 203302Sagiri */ 213302Sagiri /* 226438Sagiri * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 233302Sagiri * Use is subject to license terms. 243302Sagiri */ 253302Sagiri /* 263302Sagiri * Copyright (c) 2005 SilverStorm Technologies, Inc. All rights reserved. 273302Sagiri * 283302Sagiri * This software is available to you under a choice of one of two 293302Sagiri * licenses. You may choose to be licensed under the terms of the GNU 303302Sagiri * General Public License (GPL) Version 2, available from the file 313302Sagiri * COPYING in the main directory of this source tree, or the 323302Sagiri * OpenIB.org BSD license below: 333302Sagiri * 343302Sagiri * Redistribution and use in source and binary forms, with or 353302Sagiri * without modification, are permitted provided that the following 363302Sagiri * conditions are met: 373302Sagiri * 383302Sagiri * - Redistributions of source code must retain the above 393302Sagiri * copyright notice, this list of conditions and the following 403302Sagiri * disclaimer. 413302Sagiri * 423302Sagiri * - Redistributions in binary form must reproduce the above 433302Sagiri * copyright notice, this list of conditions and the following 443302Sagiri * disclaimer in the documentation and/or other materials 453302Sagiri * provided with the distribution. 463302Sagiri * 473302Sagiri * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 483302Sagiri * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 493302Sagiri * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 503302Sagiri * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 513302Sagiri * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 523302Sagiri * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 533302Sagiri * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 543302Sagiri * SOFTWARE. 553302Sagiri * 563302Sagiri */ 573302Sagiri /* 583302Sagiri * Sun elects to include this software in Sun product 593302Sagiri * under the OpenIB BSD license. 603302Sagiri * 613302Sagiri * 623302Sagiri * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 633302Sagiri * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 643302Sagiri * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 653302Sagiri * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 663302Sagiri * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 673302Sagiri * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 683302Sagiri * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 693302Sagiri * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 703302Sagiri * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 713302Sagiri * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 723302Sagiri * POSSIBILITY OF SUCH DAMAGE. 733302Sagiri */ 743302Sagiri 753302Sagiri #ifndef _RDSIB_IB_H 763302Sagiri #define _RDSIB_IB_H 773302Sagiri 783302Sagiri #ifdef __cplusplus 793302Sagiri extern "C" { 803302Sagiri #endif 813302Sagiri 823302Sagiri #include <sys/types.h> 833302Sagiri #include <sys/ib/ibtl/ibti.h> 843302Sagiri #include "rdsib_debug.h" 853302Sagiri #include "rdsib_protocol.h" 863302Sagiri 873302Sagiri /* 883302Sagiri * Global Configuration Variables 893302Sagiri * As defined in RDS proposal 903302Sagiri */ 915342Sagiri extern uint_t MaxNodes; 923302Sagiri extern uint_t UserBufferSize; 933302Sagiri extern uint_t RdsPktSize; 945342Sagiri extern uint_t NDataRX; 953302Sagiri extern uint_t MaxDataSendBuffers; 963302Sagiri extern uint_t MaxDataRecvBuffers; 973302Sagiri extern uint_t MaxCtrlSendBuffers; 983302Sagiri extern uint_t MaxCtrlRecvBuffers; 993302Sagiri extern uint_t DataRecvBufferLWM; 1003302Sagiri extern uint_t CtrlRecvBufferLWM; 1013302Sagiri extern uint_t PendingRxPktsHWM; 1023302Sagiri extern uint_t MinRnrRetry; 1033302Sagiri extern uint8_t IBPathRetryCount; 1043302Sagiri extern uint8_t IBPktLifeTime; 1053302Sagiri 1063302Sagiri #ifdef DEBUG 1073302Sagiri extern uint32_t rdsdbglvl; 1083302Sagiri #else 1093302Sagiri extern uint32_t rdsdbglvl; 1103302Sagiri #endif 1113302Sagiri 1123302Sagiri /* performance tunables */ 1133302Sagiri extern uint_t rds_no_interrupts; 1143302Sagiri extern uint_t rds_poll_percent_full; 1153302Sagiri extern uint_t rds_wc_signal; 1163302Sagiri extern uint_t rds_waittime_ms; 1173302Sagiri 1184467Sagiri /* loopback port map */ 1193302Sagiri #define RDS_PORT_MAP_SIZE 8192 1204467Sagiri extern krwlock_t rds_loopback_portmap_lock; 1214467Sagiri extern uint8_t rds_loopback_portmap[RDS_PORT_MAP_SIZE]; 1223302Sagiri 1233302Sagiri extern ddi_taskq_t *rds_taskq; 1243302Sagiri extern uint_t rds_rx_pkts_pending_hwm; /* readonly */ 1253302Sagiri 1263302Sagiri /* Number of WCs to poll in a single call */ 1273302Sagiri #define RDS_NUM_DATA_SEND_WCS 10 1283302Sagiri #define RDS_RDMAW_WRID 0xdabadaba 1293302Sagiri #define RDS_NUM_ACKS 4 /* only 1 is used */ 1303302Sagiri 131*8082SRamaswamy.Tummala@Sun.COM typedef enum rds_hca_state_s { 132*8082SRamaswamy.Tummala@Sun.COM RDS_HCA_STATE_ADDED = 0, 133*8082SRamaswamy.Tummala@Sun.COM RDS_HCA_STATE_OPEN = 1, 134*8082SRamaswamy.Tummala@Sun.COM RDS_HCA_STATE_MEM_REGISTERED = 2, 135*8082SRamaswamy.Tummala@Sun.COM RDS_HCA_STATE_STOPPING = 3, 136*8082SRamaswamy.Tummala@Sun.COM RDS_HCA_STATE_REMOVED = 4 137*8082SRamaswamy.Tummala@Sun.COM } rds_hca_state_t; 138*8082SRamaswamy.Tummala@Sun.COM 1393302Sagiri /* 1403302Sagiri * There is one of this structure for each HCA in the system. 1413302Sagiri * This holds all the information about the HCA. 1423302Sagiri * 1433302Sagiri * hca_nextp - Points to the next hca in the system. 144*8082SRamaswamy.Tummala@Sun.COM * hca_state - State of the hca (only modified on HCA attach/detach) 1453302Sagiri * hca_guid - HCA Guid 1463302Sagiri * hca_nports - Number of ports on the HCA 1473302Sagiri * hca_hdl - HCA hdl obtained after opening the HCA 1483302Sagiri * hca_pdhdl - PD hdl 1493302Sagiri * hca_lkey - LKey for the registered global receive buffer pool memory 1503302Sagiri * hca_rkey - Rkey for the registered global receive buffer pool memory 1513302Sagiri * hca_attrp - HCA attributes 1523302Sagiri * hca_pinfop - ptr to portinfo data, allocated by ibtf 1533302Sagiri * hca_pinfo_sz - Sizeof of portinfo data 1543302Sagiri */ 1553302Sagiri typedef struct rds_hca_s { 1563302Sagiri struct rds_hca_s *hca_nextp; 157*8082SRamaswamy.Tummala@Sun.COM rds_hca_state_t hca_state; 1583302Sagiri ib_guid_t hca_guid; 1593302Sagiri uint_t hca_nports; 1603302Sagiri ibt_hca_hdl_t hca_hdl; 1613302Sagiri ibt_pd_hdl_t hca_pdhdl; 1623302Sagiri ibt_mr_hdl_t hca_mrhdl; 1633302Sagiri ibt_lkey_t hca_lkey; 1643302Sagiri ibt_rkey_t hca_rkey; 165*8082SRamaswamy.Tummala@Sun.COM ibt_sbind_hdl_t hca_bindhdl[4]; 1663302Sagiri ibt_hca_attr_t hca_attr; 1673302Sagiri ibt_hca_portinfo_t *hca_pinfop; 1683302Sagiri uint_t hca_pinfo_sz; 1693302Sagiri } rds_hca_t; 1703302Sagiri 1713302Sagiri /* 1723302Sagiri * RDS Soft State 1733302Sagiri * NOTE: Only one soft state per driver and NOT per instance. 1743302Sagiri * 1753302Sagiri * sessionlock - protects the rds_session_t:session_nextp, this lock has 1763302Sagiri * to be taken for read/write acess of the sessions list. 1773302Sagiri * nsessions - Number of sessions in sessionlist 1783302Sagiri * sessionlistp - Pointer to the first session. 1793302Sagiri * ibhdl - Clnt handle acquired after registering with IBTF 1803302Sagiri * nhcas - Number of HCAs initialized. This is also the number of rds_hca_t 1813302Sagiri * structures in the rds_hcalistp. 1823302Sagiri * hcalistp - list of rds_hca_t. 1833302Sagiri * srvhdl - RDS service handle 1843302Sagiri */ 1853302Sagiri typedef struct rds_state_s { 1863302Sagiri krwlock_t rds_sessionlock; 1873302Sagiri uint_t rds_nsessions; 1883302Sagiri struct rds_session_s *rds_sessionlistp; 1893302Sagiri ibt_clnt_hdl_t rds_ibhdl; 1903302Sagiri krwlock_t rds_hca_lock; 1913302Sagiri uint_t rds_nhcas; 1923302Sagiri rds_hca_t *rds_hcalistp; 1933302Sagiri ibt_srv_hdl_t rds_srvhdl; 1944703Shiremath ib_svc_id_t rds_service_id; 1953302Sagiri } rds_state_t; 1963302Sagiri 1973302Sagiri extern rds_state_t *rdsib_statep; /* global */ 1983302Sagiri 1993302Sagiri /* defined in rds_cm.c */ 2003302Sagiri ibt_srv_hdl_t rds_register_service(ibt_clnt_hdl_t rds_ibhdl); 2013302Sagiri int rds_bind_service(struct rds_state_s *statep); 2023302Sagiri 2033302Sagiri /* defined in rds_ib.c */ 2043302Sagiri void rds_recvcq_handler(ibt_cq_hdl_t cq, void *); 2053302Sagiri rds_hca_t *rds_gid_to_hcap(rds_state_t *statep, ib_gid_t gid); 2063302Sagiri rds_hca_t *rds_get_hcap(rds_state_t *statep, ib_guid_t guid); 2076438Sagiri int rdsib_initialize_ib(); 2086438Sagiri void rdsib_deinitialize_ib(); 2093302Sagiri 2103302Sagiri /* defined in rds_debug.c */ 2113302Sagiri void rds_logging_initialization(); 2123302Sagiri void rds_logging_destroy(); 2133302Sagiri 2143302Sagiri #ifdef __cplusplus 2153302Sagiri } 2163302Sagiri #endif 2173302Sagiri 2183302Sagiri #endif /* _RDSIB_IB_H */ 219