10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 53241Shiremath * Common Development and Distribution License (the "License"). 63241Shiremath * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*12965SWilliam.Taylor@Oracle.COM * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef _SYS_IB_MGT_IBCM_IBCM_IMPL_H 260Sstevel@tonic-gate #define _SYS_IB_MGT_IBCM_IBCM_IMPL_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* 290Sstevel@tonic-gate * ibcm_impl.h 300Sstevel@tonic-gate * 310Sstevel@tonic-gate * This file contains all of the internal data structures and 320Sstevel@tonic-gate * definitions for IBCM. 330Sstevel@tonic-gate * 340Sstevel@tonic-gate * The general state transition processing of CM is achieved by the 350Sstevel@tonic-gate * following callgraph: 360Sstevel@tonic-gate * 370Sstevel@tonic-gate * CM INIT : Register for hca attach and detach callbacks, and other asyncs 380Sstevel@tonic-gate * 390Sstevel@tonic-gate * On new HCA attach: Register with IBMF on all ports of upcoming HCA 400Sstevel@tonic-gate * Specify CM callback and callback "per HCA arg" 410Sstevel@tonic-gate * Register with SA, allocate AVL trees etc. 420Sstevel@tonic-gate * 430Sstevel@tonic-gate * IBMF Callback 440Sstevel@tonic-gate * Validate combination of method and attribute Id in the generic MAD hdr 450Sstevel@tonic-gate * -> Call CM Connection state transition function based on attribute ID 460Sstevel@tonic-gate * Create/lookup/delete CM state structure and save it into avl tree 470Sstevel@tonic-gate * Handle duplicate messages and MRA to adjust timers etc. 480Sstevel@tonic-gate * Handle stale connections 490Sstevel@tonic-gate * Allocate reply MADs 500Sstevel@tonic-gate * -> Call CM QP/EEC state transition function based on CM message 510Sstevel@tonic-gate * Change QP/EEC state (to enable recvQ posting by client) 520Sstevel@tonic-gate * Call Client/Server handler callback function 530Sstevel@tonic-gate * Modify QP/EEC attributes 540Sstevel@tonic-gate * Optionally fill up some fields of response MAD 550Sstevel@tonic-gate * Post reply MADs 560Sstevel@tonic-gate * Store reply MADs and reply MAD address, if necessary 570Sstevel@tonic-gate * Initialize timeouts for the message 580Sstevel@tonic-gate * Change CM state 590Sstevel@tonic-gate * Deallocate reply MADs 600Sstevel@tonic-gate * 610Sstevel@tonic-gate * NOTES: 620Sstevel@tonic-gate * o There are *NO* explicit CM allocation and deallocation routines for 630Sstevel@tonic-gate * CM MADs and state data structures 640Sstevel@tonic-gate * o CM timeouts are scheduled using timeout(9f), and cancelled using 650Sstevel@tonic-gate * untimeout(9f) 660Sstevel@tonic-gate * o svc_id allocation scheme 670Sstevel@tonic-gate * A new counter for svcid is maintained in ibcm_hca_info_t 680Sstevel@tonic-gate * which is used to allocate svcid. The svcids are incremented 690Sstevel@tonic-gate * sequentially and allocated (with wrap around on overflow) with 700Sstevel@tonic-gate * these considerations: 710Sstevel@tonic-gate * The WellKnown service id's and locally allocated svcid's 720Sstevel@tonic-gate * could be maintained in separate lists, thus allowing the 730Sstevel@tonic-gate * lists to be kept apart and sorted easily. 740Sstevel@tonic-gate * The insertions are done at the end of the list 750Sstevel@tonic-gate * o reqid allocation scheme 760Sstevel@tonic-gate * The list is a sorted one (as reqid's are allocated sequentially). 770Sstevel@tonic-gate * If there is a code required for wrap around, it would search for 780Sstevel@tonic-gate * a reqid from the head of the list. 790Sstevel@tonic-gate * The insertions are always done at the end of the lists 800Sstevel@tonic-gate * o XXX svc_id allocation scheme and req_id allocation scheme will 810Sstevel@tonic-gate * be revisited. 820Sstevel@tonic-gate */ 830Sstevel@tonic-gate 840Sstevel@tonic-gate #include <sys/sysmacros.h> 850Sstevel@tonic-gate #include <sys/systm.h> 860Sstevel@tonic-gate #include <sys/kmem.h> 870Sstevel@tonic-gate #include <sys/modctl.h> 880Sstevel@tonic-gate #include <sys/avl.h> 890Sstevel@tonic-gate #include <sys/taskq.h> 900Sstevel@tonic-gate #include <sys/vmem.h> 910Sstevel@tonic-gate #include <sys/note.h> 920Sstevel@tonic-gate #include <sys/t_lock.h> 930Sstevel@tonic-gate 940Sstevel@tonic-gate #include <sys/ib/ibtl/ibvti.h> 950Sstevel@tonic-gate #include <sys/ib/ibtl/impl/ibtl_cm.h> 960Sstevel@tonic-gate #include <sys/ib/ibtl/impl/ibtl_util.h> 970Sstevel@tonic-gate #include <sys/ib/mgt/ibmf/ibmf.h> 980Sstevel@tonic-gate #include <sys/ib/mgt/ibcm/ibcm_trace.h> 994703Shiremath #include <inet/ip.h> 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate #ifdef __cplusplus 1020Sstevel@tonic-gate extern "C" { 1030Sstevel@tonic-gate #endif 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Private", sa_service_record_s)) 1060Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Exclusive access to ibmf msg buf based on state", 1070Sstevel@tonic-gate ib_mad_hdr_t)) 1080Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Exclusive access to ibmf msg buf based on state", 1090Sstevel@tonic-gate _ibmf_msg)) 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate /* 1120Sstevel@tonic-gate * Defines for all CM state machine states, as defined in 1130Sstevel@tonic-gate * section 12.9.7. IBCM_REJ_SENT is a state not defined in 1140Sstevel@tonic-gate * the spec and is added for implementation purposes. 1150Sstevel@tonic-gate */ 1160Sstevel@tonic-gate typedef enum ibcm_conn_state_e { 1170Sstevel@tonic-gate /* Initial states */ 1180Sstevel@tonic-gate IBCM_STATE_IDLE = 0, 1190Sstevel@tonic-gate IBCM_STATE_LISTEN, 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate /* States during connection establishment */ 1220Sstevel@tonic-gate IBCM_STATE_REQ_SENT, 1230Sstevel@tonic-gate IBCM_STATE_REQ_RCVD, 1240Sstevel@tonic-gate IBCM_STATE_REP_SENT, 1250Sstevel@tonic-gate IBCM_STATE_REP_RCVD, 1260Sstevel@tonic-gate IBCM_STATE_REP_WAIT, 1270Sstevel@tonic-gate IBCM_STATE_MRA_SENT, 1280Sstevel@tonic-gate IBCM_STATE_MRA_REP_SENT, 1290Sstevel@tonic-gate IBCM_STATE_MRA_REP_RCVD, 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate /* States during connection establishment failures */ 1320Sstevel@tonic-gate IBCM_STATE_TIMED_OUT, 1330Sstevel@tonic-gate IBCM_STATE_ABORTED, 1340Sstevel@tonic-gate IBCM_STATE_REJ_SENT, 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate /* Established state */ 1370Sstevel@tonic-gate IBCM_STATE_TRANSIENT_ESTABLISHED, 1380Sstevel@tonic-gate IBCM_STATE_ESTABLISHED, 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate /* States during connection teardown */ 1410Sstevel@tonic-gate IBCM_STATE_TRANSIENT_DREQ_SENT, 1420Sstevel@tonic-gate IBCM_STATE_DREQ_SENT, 1430Sstevel@tonic-gate IBCM_STATE_DREQ_RCVD, 1440Sstevel@tonic-gate IBCM_STATE_DREP_RCVD, 1450Sstevel@tonic-gate IBCM_STATE_TIMEWAIT, 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate /* states for UD side of things */ 1480Sstevel@tonic-gate IBCM_STATE_SIDR_REQ_SENT, 1490Sstevel@tonic-gate IBCM_STATE_SIDR_REQ_RCVD, 1500Sstevel@tonic-gate IBCM_STATE_SIDR_REP_SENT, 1510Sstevel@tonic-gate IBCM_STATE_SIDR_REP_RCVD, 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate /* states common to RC and UD, during state resource deletion */ 1540Sstevel@tonic-gate IBCM_STATE_DELETE 1550Sstevel@tonic-gate } ibcm_conn_state_t; 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate /* Defines the AP states for LAP/APR */ 1580Sstevel@tonic-gate typedef enum ibcm_ap_state_e { 1590Sstevel@tonic-gate IBCM_AP_STATE_IDLE = 0x0, 1600Sstevel@tonic-gate IBCM_AP_STATE_LAP_SENT, 1610Sstevel@tonic-gate IBCM_AP_STATE_LAP_RCVD, 1620Sstevel@tonic-gate IBCM_AP_STATE_APR_RCVD, 1630Sstevel@tonic-gate IBCM_AP_STATE_MRA_LAP_RCVD, 1640Sstevel@tonic-gate IBCM_AP_STATE_MRA_LAP_SENT, 1650Sstevel@tonic-gate IBCM_AP_STATE_TIMED_OUT 1660Sstevel@tonic-gate } ibcm_ap_state_t; 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate /* 1690Sstevel@tonic-gate * Defines for the CM event types/MAD attribute IDs 1700Sstevel@tonic-gate */ 1710Sstevel@tonic-gate typedef enum ibcm_event_type_e { 1720Sstevel@tonic-gate IBCM_INCOMING_REQ = 0x0, 1730Sstevel@tonic-gate IBCM_INCOMING_MRA = 0x1, 1740Sstevel@tonic-gate IBCM_INCOMING_REJ = 0x2, 1750Sstevel@tonic-gate IBCM_INCOMING_REP = 0x3, 1760Sstevel@tonic-gate IBCM_INCOMING_RTU = 0x4, 1770Sstevel@tonic-gate IBCM_INCOMING_DREQ = 0x5, 1780Sstevel@tonic-gate IBCM_INCOMING_DREP = 0x6, 1790Sstevel@tonic-gate IBCM_INCOMING_SIDR_REQ = 0x7, 1800Sstevel@tonic-gate IBCM_INCOMING_SIDR_REP = 0x8, 1810Sstevel@tonic-gate IBCM_INCOMING_LAP = 0x9, 1820Sstevel@tonic-gate IBCM_INCOMING_APR = 0xA, 1830Sstevel@tonic-gate IBCM_OUTGOING_REQ = 0xB, /* REQ Sent on active CM side */ 1840Sstevel@tonic-gate IBCM_INCOMING_REQ_STALE = 0xC, /* lookup by remote HCA and */ 1850Sstevel@tonic-gate /* remote comid */ 1860Sstevel@tonic-gate IBCM_INCOMING_REP_STALE = 0xD, /* lookup by passive HCA and QPN */ 1870Sstevel@tonic-gate IBCM_INCOMING_REJ_RCOMID = 0xE /* lookup by remote com id */ 1880Sstevel@tonic-gate } ibcm_event_type_t; 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate /* 1910Sstevel@tonic-gate * IBMF calls back into CM on only the first 11 events defined in 1920Sstevel@tonic-gate * ibcm_event_type_t. CM has pre-defined functions for these 11 events 1930Sstevel@tonic-gate * 1940Sstevel@tonic-gate */ 1950Sstevel@tonic-gate #define IBCM_MAX_EVENTS 11 1960Sstevel@tonic-gate 1970Sstevel@tonic-gate /* 1980Sstevel@tonic-gate * CM message attribute IDs begin at this "base ID". The first 11 event types 1990Sstevel@tonic-gate * in ibcm_event_type_t are CM protocol messages that are posted to IBMF by 2000Sstevel@tonic-gate * adding the "base_id" to the respective event type value. By subtracting 2010Sstevel@tonic-gate * the "base_id" in IBMF callback in CM MAD, the message type is gotten back 2020Sstevel@tonic-gate */ 2030Sstevel@tonic-gate #define IBCM_ATTR_BASE_ID 0x10 2040Sstevel@tonic-gate 2050Sstevel@tonic-gate #define IBCM_MAX_RETRY_CNT 15 2060Sstevel@tonic-gate #define IBCM_ATTRID_FIELD_SIZE 4 2070Sstevel@tonic-gate #define IBCM_TRANID_PRIV_FIELD_SIZE 28 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate #define IBCM_RNR_RETRY_CNT_MASK 0x7 /* 3 bits */ 2100Sstevel@tonic-gate #define IBCM_MAX_RNR_RETRY_CNT 7 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate #define IBCM_INITIAL_COMID 1 2130Sstevel@tonic-gate #define IBCM_INITIAL_REQID 1 2140Sstevel@tonic-gate #define IBCM_INITIAL_SID 1 2150Sstevel@tonic-gate 2160Sstevel@tonic-gate /* 2170Sstevel@tonic-gate * Maximum number of com ids / req ids that can be active at any given time 2180Sstevel@tonic-gate * MUST ENSURE THAT (INITIAL ID + MAX IDS -1), for any of the IDs does not 2190Sstevel@tonic-gate * exceed the max 32 bit 2200Sstevel@tonic-gate */ 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate /* An hca can have max of 2^24 -2 RC connections */ 2230Sstevel@tonic-gate #define IBCM_MAX_COMIDS (0x01000000 - 2) 2240Sstevel@tonic-gate #define IBCM_MAX_REQIDS 0xFFFFFFFF 2250Sstevel@tonic-gate #define IBCM_MAX_LOCAL_SIDS 0xFFFFFFFF 2264703Shiremath #define IBCM_MAX_IP_SIDS 0xFFFF 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate typedef uint32_t ib_com_id_t; /* CM Communication ID */ 2290Sstevel@tonic-gate 2300Sstevel@tonic-gate /* 2310Sstevel@tonic-gate * Defines the CM Mode of operation for a connection 2320Sstevel@tonic-gate */ 2330Sstevel@tonic-gate typedef enum ibcm_mode_e { 2340Sstevel@tonic-gate IBCM_ACTIVE_MODE = 1, /* Active side CM */ 2350Sstevel@tonic-gate IBCM_PASSIVE_MODE = 2 /* Passive side CM */ 2360Sstevel@tonic-gate } ibcm_mode_t; 2370Sstevel@tonic-gate 2380Sstevel@tonic-gate 2390Sstevel@tonic-gate /* different IBCM return values */ 2400Sstevel@tonic-gate typedef enum ibcm_status_e { 2410Sstevel@tonic-gate IBCM_SUCCESS = 0, /* good status */ 2420Sstevel@tonic-gate IBCM_LOOKUP_EXISTS, /* statep lookup found existing entry */ 2430Sstevel@tonic-gate IBCM_LOOKUP_NEW, /* lookup created new statep entry */ 2440Sstevel@tonic-gate IBCM_LOOKUP_FAIL, /* lookup found no statep entry */ 2450Sstevel@tonic-gate IBCM_SEND_REJ, /* CM QP state change sent REJ msg */ 2460Sstevel@tonic-gate IBCM_SEND_REP, /* CM QP state change sent REP msg */ 2470Sstevel@tonic-gate IBCM_SEND_RTU, /* CM QP state change sent RTU msg */ 2480Sstevel@tonic-gate IBCM_SEND_APR, /* CM to send APR MAD as response */ 2490Sstevel@tonic-gate IBCM_SEND_SIDR_REP, /* client's UD handler returned this */ 2500Sstevel@tonic-gate IBCM_DEFER, /* client's handler returned this */ 2510Sstevel@tonic-gate IBCM_FAILURE /* generic IBCM failure */ 2520Sstevel@tonic-gate } ibcm_status_t; 2530Sstevel@tonic-gate 2540Sstevel@tonic-gate /* 2550Sstevel@tonic-gate * Struct definition for addressing information that CM maintains for 2560Sstevel@tonic-gate * each of the incoming MADs 2570Sstevel@tonic-gate */ 2580Sstevel@tonic-gate typedef struct ibcm_mad_addr { 2590Sstevel@tonic-gate ibmf_global_addr_info_t grh_hdr; /* GRH related fields of MAD */ 2600Sstevel@tonic-gate ibmf_addr_info_t rcvd_addr; /* Outgoing/Incoming MAD addr */ 2610Sstevel@tonic-gate ibmf_handle_t ibmf_hdl; /* IBMF handle */ 2620Sstevel@tonic-gate boolean_t grh_exists; /* TRUE if grh exists */ 2630Sstevel@tonic-gate uint8_t port_num; 2640Sstevel@tonic-gate struct ibcm_qp_list_s *cm_qp_entry; /* IBMF hdl on which MAD rcvd */ 2650Sstevel@tonic-gate /* or on which MAD shall be */ 2660Sstevel@tonic-gate /* sent out */ 2670Sstevel@tonic-gate } ibcm_mad_addr_t; 2680Sstevel@tonic-gate 2690Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_mad_addr)) 2700Sstevel@tonic-gate 2710Sstevel@tonic-gate #define IBCM_MAD_SIZE 0x100 /* size of MAD */ 2720Sstevel@tonic-gate #define IBCM_MAD_HDR_SIZE sizeof (ib_mad_hdr_t) /* size of MAD HDR */ 2730Sstevel@tonic-gate #define IBCM_MSG_SIZE IBCM_MAD_SIZE-IBCM_MAD_HDR_SIZE 2740Sstevel@tonic-gate 2750Sstevel@tonic-gate typedef enum ibcm_abort_flag_e { 2760Sstevel@tonic-gate IBCM_ABORT_INIT = 0, /* no abort flag is set */ 2770Sstevel@tonic-gate IBCM_ABORT_CLIENT = 1, /* client requested connection abort */ 2780Sstevel@tonic-gate IBCM_ABORT_REJ = 2 /* REJ received with timeout reason */ 2790Sstevel@tonic-gate } ibcm_abort_flag_t; 2800Sstevel@tonic-gate 2810Sstevel@tonic-gate typedef enum ibcm_isync_e { 2820Sstevel@tonic-gate IBCM_BLOCK = 0, /* Block cm operation */ 2830Sstevel@tonic-gate IBCM_UNBLOCK = 1, /* Unblock cm operation */ 2840Sstevel@tonic-gate IBCM_FAIL = 2 /* fail cm operation */ 2850Sstevel@tonic-gate } ibcm_isync_t; 2860Sstevel@tonic-gate 2870Sstevel@tonic-gate /* 2880Sstevel@tonic-gate * Define a connection state structure, used by the IBTF CM 2890Sstevel@tonic-gate * to maintain state about connected QPs. 2900Sstevel@tonic-gate * 2910Sstevel@tonic-gate * mode : CM connection mode active/passive 2920Sstevel@tonic-gate * state : CM connection state 2930Sstevel@tonic-gate * ap_state : CM AP Internal state to manage LAP/APR state machine 2940Sstevel@tonic-gate * state_mutex : lock for this structure 2950Sstevel@tonic-gate * channel : Channel associated with this RC state structure 2960Sstevel@tonic-gate * ref_cnt : Number of active threads that may reference this 2970Sstevel@tonic-gate * state structure 2980Sstevel@tonic-gate * svcid : Service ID 2990Sstevel@tonic-gate * cm_handler : Client handler callback address 3000Sstevel@tonic-gate * stored_reply_addr : Address for replying using the stored mad 3010Sstevel@tonic-gate * hcap : A pointer to the HCA's entry 3020Sstevel@tonic-gate * stored_msg : Stores the response REP/REJ/RTU MAD 3030Sstevel@tonic-gate * mra_msg : Stores the response MRA MAD 3040Sstevel@tonic-gate * dreq_msg : Stores the DREQ MAD 3050Sstevel@tonic-gate * drep_msg : Stores the DREP MAD 3060Sstevel@tonic-gate * lapr_msg : Stores the LAP/APR MAD 3070Sstevel@tonic-gate * detect duplicate LAP messages 3080Sstevel@tonic-gate * local_comid : Local communication id 3090Sstevel@tonic-gate * local_hca_guid : Local HCA GUID 3100Sstevel@tonic-gate * local_qpn : Local QPN 3110Sstevel@tonic-gate * 3120Sstevel@tonic-gate * remote_comid : Remote communication id 3130Sstevel@tonic-gate * remote_hca_guid : Remote HCA GUID 3140Sstevel@tonic-gate * remote_qpn : Remote QPN 3150Sstevel@tonic-gate * 3160Sstevel@tonic-gate * timerid : Timer id for the timeout either for re-sending the 3170Sstevel@tonic-gate * stored mad or deleting the stored mad 3180Sstevel@tonic-gate * Ex: A REJ/RTU response for an incoming REP 3190Sstevel@tonic-gate * A REP response to an incoming REQ 3200Sstevel@tonic-gate * An outgoing REQ on active connection side 3210Sstevel@tonic-gate * timer_value : Time for any of the above timers in HZ 3220Sstevel@tonic-gate * pkt_life_time : pkt life time from source to destination 3230Sstevel@tonic-gate * remote_ack_delay : Remote hca's ack delay in clock_t 3240Sstevel@tonic-gate * rc_alt_pkt_lt : Life time for new ALT path specified in LAP 3250Sstevel@tonic-gate * stale_clock : clock used to detect stale vs duplicate REQs 3260Sstevel@tonic-gate * timer_stored_state : state of connection for timeout() validation 3270Sstevel@tonic-gate * timer_stored_ap_state: CM ap_state for timeout validation 3280Sstevel@tonic-gate * remaining_retry_count: Remaining count for retries ie., posting stored MADs 3290Sstevel@tonic-gate * max_cm_retries : Max retry count for sending a REQ/REP/DREQ 3300Sstevel@tonic-gate * delete_mra_msg : Set to TRUE for deletion, if MRA re-send in progress 3310Sstevel@tonic-gate * resend_mad : B_TRUE, if REQ/REP/RTU/REJ MAD re-send is in progress 3320Sstevel@tonic-gate * resend_mra_mad : B_TRUE, if a MRA mad re-sens is in progress 3330Sstevel@tonic-gate * cep_retry_cnt : Retry count for CEP. 3340Sstevel@tonic-gate * stale : B_TRUE, if connection has become stale 3350Sstevel@tonic-gate * blocking_done : B_TRUE, if cv_signal been issued to block_client_cv 3360Sstevel@tonic-gate * clnt_hdl : Clnt_hdl passed in ibt_open_channel 3370Sstevel@tonic-gate * return_data : RC return args, valid for blocking 3380Sstevel@tonic-gate * ibt_open_channel 3390Sstevel@tonic-gate * drep_priv_data; : The pointer to client specified outgoing private 3400Sstevel@tonic-gate * data, from close channel API call 3410Sstevel@tonic-gate * drep_priv_data_len : The length of DREP private data that client would 3420Sstevel@tonic-gate * like to be returned from close channel API call 3430Sstevel@tonic-gate * delete_state_data : B_TRUE, if CM decides to delete state data, but 3440Sstevel@tonic-gate * there is some thread that could access state data 3450Sstevel@tonic-gate * 3460Sstevel@tonic-gate * avl_active_link : For inserting this state-data into active AVL tree 3470Sstevel@tonic-gate * avl_passive_link : For inserting this state-data into passive AVL tree 3480Sstevel@tonic-gate * Note : All timer values that are of type "clock_t" below are in usecs 3490Sstevel@tonic-gate */ 3500Sstevel@tonic-gate typedef struct ibcm_state_data_s { 3510Sstevel@tonic-gate /* for AVL tree */ 3520Sstevel@tonic-gate avl_node_t avl_active_link; 3530Sstevel@tonic-gate avl_node_t avl_passive_link; 3540Sstevel@tonic-gate avl_node_t avl_passive_comid_link; 3550Sstevel@tonic-gate 3560Sstevel@tonic-gate /* remote stuff */ 3570Sstevel@tonic-gate ib_guid_t remote_hca_guid; 3580Sstevel@tonic-gate ib_com_id_t remote_comid; 3590Sstevel@tonic-gate ib_qpn_t remote_qpn; 3600Sstevel@tonic-gate 3610Sstevel@tonic-gate /* local stuff */ 3620Sstevel@tonic-gate ib_com_id_t local_comid; 3630Sstevel@tonic-gate ib_qpn_t local_qpn; 3640Sstevel@tonic-gate ib_guid_t local_hca_guid; 3650Sstevel@tonic-gate 3660Sstevel@tonic-gate ibcm_mode_t mode; 3670Sstevel@tonic-gate ibcm_conn_state_t state; 3680Sstevel@tonic-gate ibcm_ap_state_t ap_state; 3690Sstevel@tonic-gate kmutex_t state_mutex; 3700Sstevel@tonic-gate ibt_channel_hdl_t channel; /* save a copy */ 3710Sstevel@tonic-gate 3720Sstevel@tonic-gate /* ref_cnt so others cannot delete a statep that may be referenced */ 3730Sstevel@tonic-gate int ref_cnt; 3740Sstevel@tonic-gate 3750Sstevel@tonic-gate ib_svc_id_t svcid; 3760Sstevel@tonic-gate ibt_cm_handler_t cm_handler; 3770Sstevel@tonic-gate 3780Sstevel@tonic-gate ibcm_mad_addr_t stored_reply_addr; 3790Sstevel@tonic-gate 3800Sstevel@tonic-gate struct ibcm_hca_info_s *hcap; 3810Sstevel@tonic-gate 3820Sstevel@tonic-gate ibmf_msg_t *stored_msg; 3830Sstevel@tonic-gate ibmf_msg_t *mra_msg; 3840Sstevel@tonic-gate ibmf_msg_t *dreq_msg; 3850Sstevel@tonic-gate ibmf_msg_t *drep_msg; 3860Sstevel@tonic-gate ibmf_msg_t *lapr_msg; 3870Sstevel@tonic-gate 3880Sstevel@tonic-gate void *defer_cm_msg; 3890Sstevel@tonic-gate 3900Sstevel@tonic-gate /* timeout related stuff */ 3910Sstevel@tonic-gate timeout_id_t timerid; 3920Sstevel@tonic-gate clock_t timer_value; 3930Sstevel@tonic-gate clock_t pkt_life_time; 3940Sstevel@tonic-gate clock_t remote_ack_delay; 3950Sstevel@tonic-gate clock_t rc_alt_pkt_lt; 3960Sstevel@tonic-gate 3970Sstevel@tonic-gate hrtime_t stale_clock; 3981093Shiremath hrtime_t post_time; 3991093Shiremath hrtime_t mra_time; 4000Sstevel@tonic-gate 4010Sstevel@tonic-gate ibcm_conn_state_t timer_stored_state; 4020Sstevel@tonic-gate ibcm_ap_state_t timer_stored_ap_state; 4030Sstevel@tonic-gate uint8_t remaining_retry_cnt; 4040Sstevel@tonic-gate uint8_t max_cm_retries; 4051093Shiremath uint8_t cm_retries; 4060Sstevel@tonic-gate 407557Shiremath uint8_t drep_in_progress; 408557Shiremath 4090Sstevel@tonic-gate /* some cep stuff, stored here temporarily during connection est */ 4100Sstevel@tonic-gate uint8_t cep_retry_cnt:3; 4110Sstevel@tonic-gate ibt_srate_t local_srate; 4120Sstevel@tonic-gate ibt_srate_t local_alt_srate; 4130Sstevel@tonic-gate ib_pkey_t pkey; 4140Sstevel@tonic-gate uint8_t prim_port; 4150Sstevel@tonic-gate uint8_t alt_port; 4160Sstevel@tonic-gate uint32_t starting_psn; 4170Sstevel@tonic-gate ib_path_bits_t prim_src_path_bits; 4180Sstevel@tonic-gate ib_path_bits_t alt_src_path_bits; 4190Sstevel@tonic-gate 4200Sstevel@tonic-gate boolean_t delete_mra_msg; 4210Sstevel@tonic-gate boolean_t stale; 4220Sstevel@tonic-gate boolean_t delete_state_data; 42311369SPramod.Gunjikar@Sun.COM boolean_t is_this_ofuv_chan; 4240Sstevel@tonic-gate 4250Sstevel@tonic-gate boolean_t open_done; 4260Sstevel@tonic-gate boolean_t close_done; 4270Sstevel@tonic-gate boolean_t ap_done; 4280Sstevel@tonic-gate 4290Sstevel@tonic-gate uint8_t send_mad_flags; 4300Sstevel@tonic-gate uint8_t close_flow; 4311093Shiremath uint8_t open_flow; 4320Sstevel@tonic-gate ibcm_abort_flag_t abort_flag; 4330Sstevel@tonic-gate 4340Sstevel@tonic-gate struct ibcm_state_data_s *timeout_next; 4350Sstevel@tonic-gate 4360Sstevel@tonic-gate ibcm_conn_state_t timedout_state; 4370Sstevel@tonic-gate 4380Sstevel@tonic-gate ibcm_isync_t cep_in_rts; 4390Sstevel@tonic-gate ibcm_isync_t clnt_proceed; 4400Sstevel@tonic-gate ibcm_isync_t close_nocb_state; 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate /* Clients' information */ 4430Sstevel@tonic-gate void *state_cm_private; 4440Sstevel@tonic-gate 4450Sstevel@tonic-gate /* pointer to service info */ 4460Sstevel@tonic-gate struct ibcm_svc_info_s *state_svc_infop; 4470Sstevel@tonic-gate 4480Sstevel@tonic-gate kcondvar_t block_client_cv; 4490Sstevel@tonic-gate kcondvar_t block_mad_cv; 4500Sstevel@tonic-gate 4510Sstevel@tonic-gate /* Data for recycle function */ 4520Sstevel@tonic-gate struct ibcm_taskq_recycle_arg_s *recycle_arg; 4530Sstevel@tonic-gate 4540Sstevel@tonic-gate /* Return data pointers in various cm api calls */ 4550Sstevel@tonic-gate ibt_rc_returns_t *open_return_data; 4560Sstevel@tonic-gate ibt_ap_returns_t *ap_return_data; 4573241Shiremath uint8_t *close_ret_priv_data; 4583241Shiremath ibt_priv_data_len_t *close_ret_priv_data_len; 4590Sstevel@tonic-gate uint8_t *close_ret_status; 4600Sstevel@tonic-gate 4611093Shiremath /* for queuing of open_rc_channel requests */ 4621093Shiremath struct ibcm_state_data_s *open_link; 4633241Shiremath /* for queuing of non-blocking close_rc_channel requests */ 4643241Shiremath struct ibcm_state_data_s *close_link; 4651093Shiremath 4660Sstevel@tonic-gate struct ibcm_conn_trace_s *conn_trace; 4670Sstevel@tonic-gate 4689913SShantkumar.Hiremath@Sun.COM /* For ibt_ofuvcm_get_req_data() */ 4699913SShantkumar.Hiremath@Sun.COM void *req_msgp; 4709913SShantkumar.Hiremath@Sun.COM 47111369SPramod.Gunjikar@Sun.COM /* Stored RNR retry count from incoming REQ or REP */ 47211369SPramod.Gunjikar@Sun.COM ibt_rnr_retry_cnt_t local_qp_rnr_cnt; 47311369SPramod.Gunjikar@Sun.COM 4740Sstevel@tonic-gate } ibcm_state_data_t; 4750Sstevel@tonic-gate 4760Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ibcm_state_data_s::state_mutex, 4770Sstevel@tonic-gate ibcm_state_data_s::{state ref_cnt timer_stored_state timer_value 4780Sstevel@tonic-gate timer_stored_ap_state remaining_retry_cnt clnt_proceed cep_in_rts 4790Sstevel@tonic-gate close_nocb_state block_client_cv block_mad_cv timedout_state cm_handler 4800Sstevel@tonic-gate abort_flag mra_msg})) 4810Sstevel@tonic-gate 4820Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_state_data_s::{mode channel svcid hcap 4830Sstevel@tonic-gate local_comid local_hca_guid local_qpn remote_comid remote_hca_guid 4840Sstevel@tonic-gate remote_qpn pkt_life_time remote_ack_delay rc_alt_pkt_lt stored_reply_addr 485401Shiremath max_cm_retries cep_retry_cnt local_srate local_alt_srate pkey 4860Sstevel@tonic-gate prim_port alt_port starting_psn state_svc_infop avl_active_link 4870Sstevel@tonic-gate avl_passive_link avl_passive_comid_link defer_cm_msg recycle_arg 4880Sstevel@tonic-gate conn_trace})) 4890Sstevel@tonic-gate 4900Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Serailized access by block_client_cv", 4913241Shiremath ibcm_state_data_s::{open_return_data ap_return_data close_ret_priv_data 4923241Shiremath close_ret_priv_data_len close_ret_status})) 4930Sstevel@tonic-gate 4940Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ibcm_state_data_s::{timedout_state 495*12965SWilliam.Taylor@Oracle.COM cm_handler mra_msg abort_flag local_qp_rnr_cnt})) 4960Sstevel@tonic-gate 4970Sstevel@tonic-gate /* 4980Sstevel@tonic-gate * Definitions for send mad flags. Respective bits in send_mad_flags or 4990Sstevel@tonic-gate * ud_send_mad_flags are set to 1, during MAD transmission, and reset in 5000Sstevel@tonic-gate * ibmf send completion callback or on completion of a blocking ibmf mad post. 5010Sstevel@tonic-gate */ 5020Sstevel@tonic-gate #define IBCM_REP_POST_BUSY 1 /* REP post in progress */ 5030Sstevel@tonic-gate #define IBCM_REJ_POST_BUSY 2 /* REJ post in progress */ 5040Sstevel@tonic-gate #define IBCM_RTU_POST_BUSY 4 /* RTU post in progress */ 5050Sstevel@tonic-gate #define IBCM_MRA_POST_BUSY 8 /* MRA post in progress */ 5060Sstevel@tonic-gate #define IBCM_DREP_POST_BUSY 16 /* DREQ post in progress */ 5070Sstevel@tonic-gate #define IBCM_SREP_POST_BUSY 32 /* SIDR REP post in progress */ 5080Sstevel@tonic-gate 5090Sstevel@tonic-gate /* MADs that are retransmitted only because of a timeout */ 5100Sstevel@tonic-gate #define IBCM_REQ_POST_BUSY 64 /* REQ post in progress */ 5110Sstevel@tonic-gate 5120Sstevel@tonic-gate 5130Sstevel@tonic-gate /* Incr/Decr ref_cnt by 1 */ 5140Sstevel@tonic-gate #define IBCM_REF_CNT_INCR(s) (s->ref_cnt++) 5150Sstevel@tonic-gate #define IBCM_REF_CNT_DECR(s) \ 5160Sstevel@tonic-gate if ((--(s->ref_cnt) == 0) && (s->delete_state_data == B_TRUE)) { \ 5170Sstevel@tonic-gate ibcm_add_tlist(s);\ 5180Sstevel@tonic-gate } \ 5190Sstevel@tonic-gate ASSERT(s->ref_cnt >= 0); 5200Sstevel@tonic-gate 5210Sstevel@tonic-gate /* 5220Sstevel@tonic-gate * This macro checks if ch_qp/ch_eec handles are both not set for a channel 5230Sstevel@tonic-gate */ 5240Sstevel@tonic-gate #define IBCM_INVALID_CHANNEL(chan) (chan == NULL) 5250Sstevel@tonic-gate 5260Sstevel@tonic-gate /* 5270Sstevel@tonic-gate * The next macros are used to get/set the statep from the QP 5280Sstevel@tonic-gate * handles, using the CM private data. These call into IBTL. 5290Sstevel@tonic-gate * The WAIT and RELEASE macros deal with related issues that 5300Sstevel@tonic-gate * require use of the same lock within IBTL. 5310Sstevel@tonic-gate */ 5320Sstevel@tonic-gate #define IBCM_GET_CHAN_PRIVATE(ch, s) \ 5330Sstevel@tonic-gate if ((ch) != NULL) { \ 5340Sstevel@tonic-gate s = ibtl_cm_get_chan_private(ch); \ 5350Sstevel@tonic-gate } else \ 5360Sstevel@tonic-gate s = NULL; 5370Sstevel@tonic-gate 5380Sstevel@tonic-gate #define IBCM_SET_CHAN_PRIVATE(ch, s) \ 5390Sstevel@tonic-gate if ((ch) != NULL) { \ 5400Sstevel@tonic-gate ibtl_cm_set_chan_private(ch, (void *)(s)); \ 5410Sstevel@tonic-gate } 5420Sstevel@tonic-gate 5430Sstevel@tonic-gate #define IBCM_RELEASE_CHAN_PRIVATE(ch) \ 5440Sstevel@tonic-gate if ((ch) != NULL) { \ 5450Sstevel@tonic-gate ibtl_cm_release_chan_private(ch); \ 5460Sstevel@tonic-gate } 5470Sstevel@tonic-gate 5480Sstevel@tonic-gate #define IBCM_WAIT_CHAN_PRIVATE(ch) \ 5490Sstevel@tonic-gate ibtl_cm_wait_chan_private(ch); 5500Sstevel@tonic-gate 5510Sstevel@tonic-gate /* In future, if we intend to change it to realtime_timeout, it's easy */ 5520Sstevel@tonic-gate #define IBCM_TIMEOUT(arg1, arg2) timeout(ibcm_timeout_cb, arg1,\ 5530Sstevel@tonic-gate drv_usectohz(arg2)) 5540Sstevel@tonic-gate #define IBCM_UD_TIMEOUT(arg1, arg2) timeout(ibcm_sidr_timeout_cb, arg1,\ 5550Sstevel@tonic-gate drv_usectohz(arg2)) 5560Sstevel@tonic-gate 5571093Shiremath extern void ibcm_open_enqueue(ibcm_state_data_t *statep); 5581093Shiremath extern void ibcm_open_done(ibcm_state_data_t *statep); 5593241Shiremath extern void ibcm_close_enqueue(ibcm_state_data_t *statep); 5601093Shiremath extern void ibcm_close_done(ibcm_state_data_t *statep, int send_done); 5611093Shiremath extern void ibcm_close_enter(void); 5621093Shiremath extern void ibcm_close_exit(void); 5631093Shiremath extern void ibcm_lapr_enter(void); 5641093Shiremath extern void ibcm_lapr_exit(void); 5651093Shiremath extern void ibcm_check_for_opens(void); 5663241Shiremath extern void ibcm_check_for_async_close(void); 5673241Shiremath extern void ibcm_close_start(ibcm_state_data_t *statep); 5681093Shiremath extern void ibcm_run_tlist_thread(void); 5691093Shiremath 5700Sstevel@tonic-gate /* 5710Sstevel@tonic-gate * Structures & defines for SIDR 5720Sstevel@tonic-gate */ 5730Sstevel@tonic-gate 5740Sstevel@tonic-gate /* 5750Sstevel@tonic-gate * Define a connection state structure, used for SIDR REQ and REP 5760Sstevel@tonic-gate * (ibcm_ud_state_data_t - struct for SIDR connection) 5770Sstevel@tonic-gate * 5780Sstevel@tonic-gate * ud_state: CM connection state (See ibcm_conn_state_t) 5790Sstevel@tonic-gate * ud_req_id: Request ID 5800Sstevel@tonic-gate * ud_svcid: Service ID 5810Sstevel@tonic-gate * ud_state_mutex: CM connection state 5820Sstevel@tonic-gate * 5830Sstevel@tonic-gate * ud_max_cm_retries: Max retry count for sending a SIDR REQ 5840Sstevel@tonic-gate * ud_ref_cnt: State ref count for not deleting accidentally 5850Sstevel@tonic-gate * ud_remaining_retry_count: Remaining count for retries ie., posting 5860Sstevel@tonic-gate * stored MADs 5870Sstevel@tonic-gate * ud_cm_handler: Server's handler callback address 5880Sstevel@tonic-gate * 5890Sstevel@tonic-gate * ud_nextp: CM link for IBTF list 5900Sstevel@tonic-gate * ud_hcap: A pointer to the HCA's entry 5910Sstevel@tonic-gate * 5920Sstevel@tonic-gate * ud_timerid: Timer id for the timeout either for re-sending the 5930Sstevel@tonic-gate * stored mad or deleting the stored mad 5940Sstevel@tonic-gate * Ex: A SIDR REP response for an incoming SIDR REQ 5950Sstevel@tonic-gate * An outgoing SIDR REQ on active connection side 5960Sstevel@tonic-gate * ud_timer_value: Time for any of the above timers in HZ 5970Sstevel@tonic-gate * ud_pkt_life_time: pkt life time from source to destination 5980Sstevel@tonic-gate * ud_stored_reply_addr: Address for replying using the stored mad 5990Sstevel@tonic-gate * 6000Sstevel@tonic-gate * ud_sidr_req_lid: SIDR REQ sender's port LID 6010Sstevel@tonic-gate * ud_sidr_req_gid: SIDR REQ sender's port GID 6020Sstevel@tonic-gate * ud_grh_exists: TRUE if GRH exists in the incoming SIDR REQ 6030Sstevel@tonic-gate * 6040Sstevel@tonic-gate * ud_passive_qpn: QPN allocated by server for a SIDR REQ 6050Sstevel@tonic-gate * ud_passive_qpn_qkey: QPN's QKEY allocated by server 6060Sstevel@tonic-gate * 6070Sstevel@tonic-gate * ud_block_client_cv: CV condition variable on which ibt_ud_get_dqpn() waits, 6080Sstevel@tonic-gate * if called in blocking mode. 6090Sstevel@tonic-gate * ud_return_data: UD return args, valid for blocking ibt_ud_get_dqpn 6100Sstevel@tonic-gate * ud_timer_stored_state: State stored for timeout handling 6110Sstevel@tonic-gate * ud_blocking_done : Tells if cv_wait is needed or not. To handle the 6120Sstevel@tonic-gate * case where a cv_signal is received prior to its 6130Sstevel@tonic-gate * cv_wait(). 6140Sstevel@tonic-gate * Note : All timer values that are of type "clock_t" below are in usec 6150Sstevel@tonic-gate */ 6160Sstevel@tonic-gate typedef struct ibcm_ud_state_data_s { 6170Sstevel@tonic-gate kmutex_t ud_state_mutex; 6180Sstevel@tonic-gate ibcm_conn_state_t ud_state; 6190Sstevel@tonic-gate ibcm_mode_t ud_mode; 6200Sstevel@tonic-gate 6210Sstevel@tonic-gate int ud_ref_cnt; 6220Sstevel@tonic-gate 6230Sstevel@tonic-gate uint32_t ud_req_id; 6240Sstevel@tonic-gate ib_svc_id_t ud_svc_id; 6250Sstevel@tonic-gate 6260Sstevel@tonic-gate uint8_t ud_max_cm_retries; 6270Sstevel@tonic-gate uint8_t ud_remaining_retry_cnt; 6280Sstevel@tonic-gate ibt_cm_ud_handler_t ud_cm_handler; 6290Sstevel@tonic-gate 6300Sstevel@tonic-gate struct ibcm_ud_state_data_s *ud_nextp; 6310Sstevel@tonic-gate struct ibcm_hca_info_s *ud_hcap; 6320Sstevel@tonic-gate 6330Sstevel@tonic-gate /* timeout related stuff */ 6340Sstevel@tonic-gate timeout_id_t ud_timerid; 6350Sstevel@tonic-gate clock_t ud_timer_value; 6360Sstevel@tonic-gate clock_t ud_pkt_life_time; 6370Sstevel@tonic-gate ibcm_mad_addr_t ud_stored_reply_addr; 6380Sstevel@tonic-gate ibmf_msg_t *ud_stored_msg; 6390Sstevel@tonic-gate 6400Sstevel@tonic-gate 6410Sstevel@tonic-gate /* SIDR REQ side related */ 6420Sstevel@tonic-gate ib_lid_t ud_sidr_req_lid; 6430Sstevel@tonic-gate ib_gid_t ud_sidr_req_gid; 6440Sstevel@tonic-gate boolean_t ud_grh_exists; 6450Sstevel@tonic-gate 6460Sstevel@tonic-gate /* Stored values on server/SIDR REP side for re-transmits */ 6470Sstevel@tonic-gate ib_qpn_t ud_passive_qpn; 6480Sstevel@tonic-gate ib_qkey_t ud_passive_qp_qkey; 6490Sstevel@tonic-gate 6500Sstevel@tonic-gate /* Clients' information */ 6510Sstevel@tonic-gate void *ud_state_cm_private; 6520Sstevel@tonic-gate 6530Sstevel@tonic-gate struct ibcm_ud_state_data_s *ud_timeout_next; 6540Sstevel@tonic-gate boolean_t ud_delete_state_data; 6550Sstevel@tonic-gate boolean_t ud_blocking_done; 6560Sstevel@tonic-gate 6570Sstevel@tonic-gate uint8_t ud_send_mad_flags; 6580Sstevel@tonic-gate 6590Sstevel@tonic-gate ibcm_isync_t ud_clnt_proceed; 6600Sstevel@tonic-gate 6610Sstevel@tonic-gate /* The following fields are not used by server side connection */ 6620Sstevel@tonic-gate kcondvar_t ud_block_client_cv; 6630Sstevel@tonic-gate ibt_ud_returns_t *ud_return_data; 6640Sstevel@tonic-gate ibcm_conn_state_t ud_timer_stored_state; 6650Sstevel@tonic-gate } ibcm_ud_state_data_t; 6660Sstevel@tonic-gate 6670Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ibcm_ud_state_data_s::ud_state_mutex, 6680Sstevel@tonic-gate ibcm_ud_state_data_s::{ud_state ud_ref_cnt ud_timerid 6690Sstevel@tonic-gate ud_delete_state_data ud_blocking_done ud_send_mad_flags ud_clnt_proceed 6700Sstevel@tonic-gate ud_timer_stored_state ud_send_mad_flags ud_clnt_proceed 6710Sstevel@tonic-gate ud_block_client_cv ud_timer_value ud_remaining_retry_cnt})) 6720Sstevel@tonic-gate 6730Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_ud_state_data_s::{ud_mode ud_req_id ud_svc_id 6740Sstevel@tonic-gate ud_max_cm_retries ud_pkt_life_time ud_stored_reply_addr ud_stored_msg 6750Sstevel@tonic-gate ud_sidr_req_lid ud_sidr_req_gid ud_grh_exists ud_passive_qpn 6760Sstevel@tonic-gate ud_passive_qp_qkey ud_state_cm_private ud_stored_reply_addr ud_stored_msg})) 6770Sstevel@tonic-gate 6780Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Serailized access by ud_block_client_cv", 6790Sstevel@tonic-gate ibcm_ud_state_data_s::{ud_return_data})) 6800Sstevel@tonic-gate 6810Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ibcm_ud_state_data_s::{ud_cm_handler})) 6820Sstevel@tonic-gate 6830Sstevel@tonic-gate /* 6840Sstevel@tonic-gate * Structure used to specify the SIDR search parameters 6850Sstevel@tonic-gate */ 6860Sstevel@tonic-gate typedef struct ibcm_sidr_srch_s { 6870Sstevel@tonic-gate ib_lid_t srch_lid; 6880Sstevel@tonic-gate ib_gid_t srch_gid; 6890Sstevel@tonic-gate boolean_t srch_grh_exists; 6900Sstevel@tonic-gate uint32_t srch_req_id; 6910Sstevel@tonic-gate ibcm_mode_t srch_mode; 6920Sstevel@tonic-gate } ibcm_sidr_srch_t; 6930Sstevel@tonic-gate 6940Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_sidr_srch_s)) 6950Sstevel@tonic-gate 6960Sstevel@tonic-gate /* 6970Sstevel@tonic-gate * Incr/Decr ud_ref_cnt by 1 6980Sstevel@tonic-gate */ 6990Sstevel@tonic-gate #define IBCM_UD_REF_CNT_INCR(s) ((s)->ud_ref_cnt++) 7000Sstevel@tonic-gate #define IBCM_UD_REF_CNT_DECR(s) \ 7010Sstevel@tonic-gate if ((--(s->ud_ref_cnt) == 0) && (s->ud_delete_state_data == B_TRUE)) { \ 7020Sstevel@tonic-gate ibcm_add_ud_tlist(s);\ 7030Sstevel@tonic-gate } \ 7040Sstevel@tonic-gate ASSERT(s->ud_ref_cnt >= 0); 7050Sstevel@tonic-gate 7060Sstevel@tonic-gate /* 7070Sstevel@tonic-gate * Structure to store the Service Registration and Service Bind entries. 7080Sstevel@tonic-gate * 7090Sstevel@tonic-gate * Well known service id's are unique on a given HCA, but can be registered 7100Sstevel@tonic-gate * only at some GID's. Hence can be multiple GID's per Service ID. For each 7110Sstevel@tonic-gate * such GID and PKEY combination registered, there will be an ibcm_svc_info_t 7120Sstevel@tonic-gate * entry in the CM global service list. 7130Sstevel@tonic-gate * 7140Sstevel@tonic-gate * Annex A of the spec constrains that there shall be one service provider per 7150Sstevel@tonic-gate * service id, which implies same svc_rc_handler for all such entries 7160Sstevel@tonic-gate * There can be multiple transport types (svc_tran_type) per Service ID. For 7170Sstevel@tonic-gate * each such transport type, there will be an ibcm_svc_info_t entry in the 7180Sstevel@tonic-gate * CM global service list and cm handler can be different 7190Sstevel@tonic-gate * 7200Sstevel@tonic-gate * For locally allocated service id's (maintained by OS), there can be only 7210Sstevel@tonic-gate * one GID, where the service can be registered 7220Sstevel@tonic-gate * 7230Sstevel@tonic-gate * svc_id: Service ID 7240Sstevel@tonic-gate * svc_num_sids: Number (Range) of service-ids supported 7250Sstevel@tonic-gate * svc_flags: Service flags specified at registration time 7260Sstevel@tonic-gate * svc_link: Global AVL tree of ibcm_svc_info_t structs 7270Sstevel@tonic-gate * svc_rc_handler: Server handler for RC (only one is valid at a time) 7280Sstevel@tonic-gate * svc_ud_handler: Server handler for UD (only one is valid at a time) 7290Sstevel@tonic-gate * svc_ref_cnt: Reference count 7300Sstevel@tonic-gate * svc_to_delete: If 1, then the entry is marked to be deleted 7310Sstevel@tonic-gate * 7320Sstevel@tonic-gate * sbind_gid: GID 7330Sstevel@tonic-gate * sbind_pkey: P_Key 7340Sstevel@tonic-gate * sbind_lease: Service Lease 7350Sstevel@tonic-gate * sbind_name: Service Name 7360Sstevel@tonic-gate */ 7370Sstevel@tonic-gate typedef struct ibcm_svc_info_s { 7380Sstevel@tonic-gate avl_node_t svc_link; 7390Sstevel@tonic-gate struct ibcm_svc_bind_s *svc_bind_list; 7400Sstevel@tonic-gate ibt_cm_handler_t svc_rc_handler; 7410Sstevel@tonic-gate ibt_cm_ud_handler_t svc_ud_handler; 7420Sstevel@tonic-gate int svc_ref_cnt; 7430Sstevel@tonic-gate int svc_to_delete; 7440Sstevel@tonic-gate ib_svc_id_t svc_id; 7450Sstevel@tonic-gate int svc_num_sids; 7460Sstevel@tonic-gate ibt_service_flags_t svc_flags; 7470Sstevel@tonic-gate } ibcm_svc_info_t; 7480Sstevel@tonic-gate 7490Sstevel@tonic-gate typedef struct ibcm_svc_bind_s { 7500Sstevel@tonic-gate struct ibcm_svc_bind_s *sbind_link; 7510Sstevel@tonic-gate void *sbind_cm_private; 7520Sstevel@tonic-gate ib_gid_t sbind_gid; 7530Sstevel@tonic-gate ib_guid_t sbind_hcaguid; 7540Sstevel@tonic-gate uint64_t sbind_key[2]; 7550Sstevel@tonic-gate /* sbind_data is assumed to be 8-byte aligned */ 7560Sstevel@tonic-gate uint8_t sbind_data[IB_SVC_DATA_LEN]; /* ServiceData */ 7570Sstevel@tonic-gate uint32_t sbind_lease; 7580Sstevel@tonic-gate ib_pkey_t sbind_pkey; 7590Sstevel@tonic-gate uint8_t sbind_port; 7600Sstevel@tonic-gate uint8_t sbind_rewrite_state; 7610Sstevel@tonic-gate char sbind_name[IB_SVC_NAME_LEN]; 7620Sstevel@tonic-gate } ibcm_svc_bind_t; 7630Sstevel@tonic-gate 7640Sstevel@tonic-gate /* 7650Sstevel@tonic-gate * Service records may be lost by the SM/SA (reboot, change in who 7660Sstevel@tonic-gate * is the master, etc.). When any of the above occurs, a PORT_UP 7670Sstevel@tonic-gate * async event is supposed to occur, at which point we mark all of 7680Sstevel@tonic-gate * our service record information as stale (REWRITE_NEEDED), and 7690Sstevel@tonic-gate * subsequently make the necessary sa_update calls to get the 7700Sstevel@tonic-gate * SM/SA in sync with all the service records we previously wrote. 7710Sstevel@tonic-gate * 7720Sstevel@tonic-gate * Values for sbind_rewrite_state follow. This field is protected by 7730Sstevel@tonic-gate * ibcm_svc_info_lock. ibt_unbind_service has to wait until a service 7740Sstevel@tonic-gate * binding is either idle or needed, sleeping on ibcm_svc_info_cv if 7750Sstevel@tonic-gate * busy (rewrite in progress). 7760Sstevel@tonic-gate */ 7770Sstevel@tonic-gate #define IBCM_REWRITE_IDLE 0 7780Sstevel@tonic-gate #define IBCM_REWRITE_NEEDED 1 7790Sstevel@tonic-gate #define IBCM_REWRITE_BUSY 2 7800Sstevel@tonic-gate 7810Sstevel@tonic-gate typedef struct ibcm_port_up_s { 7820Sstevel@tonic-gate ib_guid_t pup_hca_guid; 7830Sstevel@tonic-gate uint8_t pup_port; 7840Sstevel@tonic-gate } ibcm_port_up_t; 7850Sstevel@tonic-gate 7860Sstevel@tonic-gate /* arg is a pointer to ibcm_port_up_t */ 7870Sstevel@tonic-gate extern void ibcm_service_record_rewrite_task(void *); 7880Sstevel@tonic-gate 7890Sstevel@tonic-gate #define IBCM_SVC_INCR(svcinfop) (svcinfop)->svc_ref_cnt++ 7900Sstevel@tonic-gate #define IBCM_SVC_DECR(svcinfop) \ 7910Sstevel@tonic-gate if (--((svcinfop)->svc_ref_cnt) == 0 && \ 7920Sstevel@tonic-gate (svcinfop)->svc_to_delete) \ 7930Sstevel@tonic-gate cv_broadcast(&ibcm_svc_info_cv); \ 7940Sstevel@tonic-gate ASSERT(svcinfop->svc_ref_cnt >= 0); 7950Sstevel@tonic-gate 7960Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_svc_info_s::{svc_rc_handler svc_ud_handler svc_id 7970Sstevel@tonic-gate svc_num_sids svc_flags})) 7980Sstevel@tonic-gate 7990Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_svc_bind_s::{sbind_cm_private sbind_gid sbind_hcaguid 8000Sstevel@tonic-gate sbind_key sbind_data sbind_lease sbind_pkey sbind_port sbind_name})) 8010Sstevel@tonic-gate 8020Sstevel@tonic-gate /* for avl tree search */ 8030Sstevel@tonic-gate typedef struct ibcm_svc_lookup_s { 8040Sstevel@tonic-gate ib_svc_id_t sid; 8050Sstevel@tonic-gate int num_sids; 8060Sstevel@tonic-gate } ibcm_svc_lookup_t; 8070Sstevel@tonic-gate 8080Sstevel@tonic-gate typedef struct ibcm_ar_ref_s { 8090Sstevel@tonic-gate struct ibcm_ar_ref_s *ar_ref_link; 8100Sstevel@tonic-gate ibt_clnt_hdl_t ar_ibt_hdl; 8110Sstevel@tonic-gate } ibcm_ar_ref_t; 8120Sstevel@tonic-gate 8130Sstevel@tonic-gate typedef struct ibcm_ar_s { 8140Sstevel@tonic-gate ibt_ar_t ar; 8150Sstevel@tonic-gate int ar_flags; /* 1 = INITING, 2 = FAILED */ 8160Sstevel@tonic-gate int ar_waiters; /* # of waiters */ 8170Sstevel@tonic-gate kcondvar_t ar_cv; 8180Sstevel@tonic-gate uint8_t ar_port; 8190Sstevel@tonic-gate uint8_t ar_rewrite_state; /* see sbind_rewrite_state */ 8200Sstevel@tonic-gate ibcm_ar_ref_t *ar_ibt_hdl_list; 8210Sstevel@tonic-gate struct ibcm_ar_s *ar_link; 8220Sstevel@tonic-gate sa_service_record_t *ar_srv_recp; 8230Sstevel@tonic-gate ibmf_saa_handle_t ar_saa_handle; 8240Sstevel@tonic-gate struct ibcm_hca_info_s *ar_hcap; 8250Sstevel@tonic-gate } ibcm_ar_t; 8260Sstevel@tonic-gate 8270Sstevel@tonic-gate /* ar_flags */ 8280Sstevel@tonic-gate #define IBCM_AR_SUCCESS 0 8290Sstevel@tonic-gate #define IBCM_AR_FAILED 1 8300Sstevel@tonic-gate #define IBCM_AR_INITING 2 8310Sstevel@tonic-gate 8320Sstevel@tonic-gate 8330Sstevel@tonic-gate /* 8340Sstevel@tonic-gate * These flags are used for adding (if an entry does not exist) or 8350Sstevel@tonic-gate * for just looking one up 8360Sstevel@tonic-gate */ 8370Sstevel@tonic-gate typedef enum ibcm_lookup_flag_e { 8380Sstevel@tonic-gate IBCM_FLAG_LOOKUP = 0, /* just lookup */ 8390Sstevel@tonic-gate IBCM_FLAG_ADD = 1, /* just add */ 8400Sstevel@tonic-gate IBCM_FLAG_LOOKUP_AND_ADD = 2 /* lookup first. add if */ 8410Sstevel@tonic-gate /* lookup failed */ 8420Sstevel@tonic-gate } ibcm_lookup_flag_t; 8430Sstevel@tonic-gate 8440Sstevel@tonic-gate typedef enum ibcm_finit_state_e { 8450Sstevel@tonic-gate IBCM_FINIT_INIT, /* CM's init is not yet completed */ 8460Sstevel@tonic-gate IBCM_FINIT_IDLE, /* CM not in either init or fini */ 8470Sstevel@tonic-gate IBCM_FINIT_BUSY, /* CM busy either in init or fini */ 8480Sstevel@tonic-gate IBCM_FINIT_FAIL, /* Init failed */ 8490Sstevel@tonic-gate IBCM_FINIT_SUCCESS /* Fini has succeeded */ 8500Sstevel@tonic-gate } ibcm_finit_state_t; 8510Sstevel@tonic-gate 8520Sstevel@tonic-gate /* 8530Sstevel@tonic-gate * Identifies HCA's state. Used in the definition of ibcm_hca_info_t 8540Sstevel@tonic-gate * If HCA is in ACTIVE state only does CM allow any MAD processing. 8550Sstevel@tonic-gate */ 8560Sstevel@tonic-gate typedef enum ibcm_hca_state_e { 8570Sstevel@tonic-gate IBCM_HCA_INIT, 8580Sstevel@tonic-gate IBCM_HCA_ACTIVE, 8590Sstevel@tonic-gate IBCM_HCA_NOT_ACTIVE 8600Sstevel@tonic-gate } ibcm_hca_state_t; 8610Sstevel@tonic-gate 8620Sstevel@tonic-gate /* QP information per pkey, stored in port information */ 8630Sstevel@tonic-gate typedef struct ibcm_qp_list_s { 8640Sstevel@tonic-gate ib_pkey_t qp_pkey; 8650Sstevel@tonic-gate ibmf_qp_handle_t qp_cm; 8660Sstevel@tonic-gate uint32_t qp_ref_cnt; 8670Sstevel@tonic-gate struct ibcm_port_info_s *qp_port; 8680Sstevel@tonic-gate struct ibcm_qp_list_s *qp_next; 8690Sstevel@tonic-gate } ibcm_qp_list_t; 8700Sstevel@tonic-gate 8710Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_qp_list_s::{qp_pkey qp_cm qp_port qp_next})) 8720Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ibcm_qp_list_s)) 8730Sstevel@tonic-gate 8740Sstevel@tonic-gate /* 8750Sstevel@tonic-gate * port information per HCA 8760Sstevel@tonic-gate * port_ibmf_hdl - contains IBMF handle for that port if valid 8770Sstevel@tonic-gate * otherwise is NULL 8780Sstevel@tonic-gate * port_ibmf_saa_hdl - contains SA Access handle for that port if valid 8790Sstevel@tonic-gate * otherwise is NULL 8800Sstevel@tonic-gate */ 8810Sstevel@tonic-gate typedef struct ibcm_port_info_s { 8820Sstevel@tonic-gate ibmf_handle_t port_ibmf_hdl; 8830Sstevel@tonic-gate ibmf_saa_handle_t port_ibmf_saa_hdl; 8840Sstevel@tonic-gate ib_gid_t port_sgid0; 8850Sstevel@tonic-gate uint8_t port_event_status; 8860Sstevel@tonic-gate uint8_t port_saa_open_in_progress; 8870Sstevel@tonic-gate uint8_t port_num; 8880Sstevel@tonic-gate ibmf_register_info_t port_ibmf_reg; 8890Sstevel@tonic-gate ibmf_impl_caps_t port_ibmf_caps; 8900Sstevel@tonic-gate ibcm_qp_list_t port_qp1; 8910Sstevel@tonic-gate ibcm_qp_list_t *port_qplist; 8920Sstevel@tonic-gate struct ibcm_hca_info_s *port_hcap; 8930Sstevel@tonic-gate } ibcm_port_info_t; 8940Sstevel@tonic-gate 8950Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_port_info_s::{port_num port_ibmf_caps port_qp1 8960Sstevel@tonic-gate port_hcap})) 8970Sstevel@tonic-gate 8980Sstevel@tonic-gate /* Value to indicate to exit the timeout list processing thread */ 8990Sstevel@tonic-gate #define IBCM_TIMEOUT_THREAD_EXIT 01 9000Sstevel@tonic-gate 9010Sstevel@tonic-gate /* 9020Sstevel@tonic-gate * IBCM code relies on AVL routines already in kernel for faster lookups. 9030Sstevel@tonic-gate * AVL was chosen over mod hashing mechanism based on the its internal 9040Sstevel@tonic-gate * limitations in the kernel (no support for over 100,000 keys). 9050Sstevel@tonic-gate * 9060Sstevel@tonic-gate * IBCM uses two AVL trees on the passive side and one on active side per HCA. 9070Sstevel@tonic-gate * The two trees are need on the passive side because the tree lookup criteria 9080Sstevel@tonic-gate * changes based on the type of message being processed. On passive side it is 9090Sstevel@tonic-gate * based on remote_qpn and remote_hca_guid for only incoming REQ message and for 9100Sstevel@tonic-gate * for all other messages the search criteria is based upon remote_comid. 9110Sstevel@tonic-gate * On active side the lookup criteria remains static based upon local_comid. 9120Sstevel@tonic-gate * 9130Sstevel@tonic-gate * AVL tree insertions are done by grabbing the writer lock (hca_state_rwlock) 9140Sstevel@tonic-gate * and lookups are done by grabbing the reader lock. 9150Sstevel@tonic-gate */ 9160Sstevel@tonic-gate 9170Sstevel@tonic-gate /* 9180Sstevel@tonic-gate * CM's per HCA data structure. 9190Sstevel@tonic-gate * 9200Sstevel@tonic-gate * One such entry is added/removed on hca attach/detach notifications to CM 9210Sstevel@tonic-gate * respectively. 9220Sstevel@tonic-gate * 9230Sstevel@tonic-gate * Comids are used for all connections. Req ids are used for SIDR REQ and 9240Sstevel@tonic-gate * SIDR REP messages. These are simple counters that wrap around INT_MAX. 9250Sstevel@tonic-gate * NOTE: The starting value for comid, per HCA, is 2. 9260Sstevel@tonic-gate * 9270Sstevel@tonic-gate * hca_state: HCA's current state (ibcm_hca_state_t) - whether 9280Sstevel@tonic-gate * IBT_HCA_ACTIVE, IBT_HCA_NOT_ACTIVE, 9290Sstevel@tonic-gate * hca_guid: Active HCA guid 9300Sstevel@tonic-gate * hca_caps: HCA capability mask 9310Sstevel@tonic-gate * hca_ack_delay: HCA ack delay 9320Sstevel@tonic-gate * hca_max_rdma_rd Max RDMA in Reads 9330Sstevel@tonic-gate * hca_max_rdma_dpt Max RDMA out Reads 9340Sstevel@tonic-gate * hca_active_tree: This tree is used for lookups on Active/Passive side 9350Sstevel@tonic-gate * CM based on communication id ONLY. 9360Sstevel@tonic-gate * hca_passive_tree: This tree is used to lookup/create ibcm_state_data_t on 9370Sstevel@tonic-gate * Passive Side CM based on remote_qpn and remote_hca_guid. 9380Sstevel@tonic-gate * hca_passive_comid_tree: 9390Sstevel@tonic-gate * This tree is used to lookup/create ibcm_state_data_t on 9400Sstevel@tonic-gate * Passive Side CM based on remote_comid and 9410Sstevel@tonic-gate * remote_hca_guid. 9420Sstevel@tonic-gate * hca_state_rwlock: reader/writer Lock for the hca entry 9430Sstevel@tonic-gate * for hca_active_tree 9440Sstevel@tonic-gate * for hca_passive_tree 9450Sstevel@tonic-gate * for hca_next_comid 9460Sstevel@tonic-gate * hca_sidr_list: List for UD side 9470Sstevel@tonic-gate * hca_sidr_list_lock: List lock for UD side 9480Sstevel@tonic-gate * for hca_sidr_list 9490Sstevel@tonic-gate * for hca_next_reqid 9500Sstevel@tonic-gate * hca_next_reqid: Next active ReqId 9510Sstevel@tonic-gate * hca_next_comid: Next active ComID 9520Sstevel@tonic-gate * hca_next: Pointer to the next HCA 9530Sstevel@tonic-gate * hca_svc_cnt: A count of services registered on this hca 9540Sstevel@tonic-gate * hca_acc_cnt: A count of active references to this ibcm_hca_info_t 9550Sstevel@tonic-gate * hca_res_cnt: A count of client's active resources on this hca 9560Sstevel@tonic-gate * hca_num_ports: Number of ports that this HCA has 9570Sstevel@tonic-gate * hca_port_info: Per port information (IBMA/SA access handles etc.) 9580Sstevel@tonic-gate * 9590Sstevel@tonic-gate * Note : The global mutex ibcm_global_hca_mutex declared in CM is used for 9600Sstevel@tonic-gate * accesses to the following fields : 9610Sstevel@tonic-gate * hca_acc_cnt, hca_res_cnt, hca_svc_cnt, hca_state 9620Sstevel@tonic-gate */ 9630Sstevel@tonic-gate typedef struct ibcm_hca_info_s { 9640Sstevel@tonic-gate ibcm_hca_state_t hca_state; /* Is HCA attached? */ 9650Sstevel@tonic-gate ib_guid_t hca_guid; /* HCA's guid value */ 9660Sstevel@tonic-gate ibt_hca_flags_t hca_caps; /* HCA capabilities */ 9673241Shiremath uint32_t hca_vendor_id:24; 9683241Shiremath uint16_t hca_device_id; 9690Sstevel@tonic-gate ib_time_t hca_ack_delay; /* HCA ack delay */ 9700Sstevel@tonic-gate uint8_t hca_max_rdma_in_qp; /* Max RDMA in Reads */ 9710Sstevel@tonic-gate uint8_t hca_max_rdma_out_qp; /* Max RDMA out Reads */ 9720Sstevel@tonic-gate vmem_t *hca_comid_arena; /* arena for com ids */ 9730Sstevel@tonic-gate vmem_t *hca_reqid_arena; /* arena for req ids */ 9740Sstevel@tonic-gate avl_tree_t hca_active_tree; /* active node tree */ 9750Sstevel@tonic-gate avl_tree_t hca_passive_tree; /* passive node tree */ 9760Sstevel@tonic-gate avl_tree_t hca_passive_comid_tree; /* passive comid tree */ 9770Sstevel@tonic-gate krwlock_t hca_state_rwlock; /* per HCA lock */ 9780Sstevel@tonic-gate ibcm_ud_state_data_t *hca_sidr_list; /* SIDR state list */ 9790Sstevel@tonic-gate krwlock_t hca_sidr_list_lock; 9800Sstevel@tonic-gate 9810Sstevel@tonic-gate struct ibcm_hca_info_s *hca_next; /* Next HCA entry */ 9820Sstevel@tonic-gate 9830Sstevel@tonic-gate int hca_svc_cnt; /* # of */ 9840Sstevel@tonic-gate /* services allocated */ 9850Sstevel@tonic-gate int hca_acc_cnt; /* active references */ 9860Sstevel@tonic-gate int hca_res_cnt; /* total resources */ 9870Sstevel@tonic-gate uint8_t hca_num_ports; /* #ports on this HCA */ 9880Sstevel@tonic-gate ibcm_port_info_t hca_port_info[1]; /* Per portinfo array */ 9890Sstevel@tonic-gate } ibcm_hca_info_t; 9900Sstevel@tonic-gate 9910Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ibcm_hca_info_s::hca_state_rwlock, 9920Sstevel@tonic-gate ibcm_hca_info_s::{hca_active_tree hca_passive_tree hca_passive_comid_tree})) 9930Sstevel@tonic-gate 9940Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("hca_sidr_list_lock protects hca_sidr_list", 9950Sstevel@tonic-gate ibcm_hca_info_s::{hca_sidr_list})) 9960Sstevel@tonic-gate 9970Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_hca_info_s::{hca_guid hca_caps hca_ack_delay 9980Sstevel@tonic-gate hca_max_rdma_in_qp hca_max_rdma_out_qp hca_comid_arena hca_reqid_arena 9990Sstevel@tonic-gate hca_passive_tree hca_active_tree hca_passive_comid_tree hca_num_ports })) 10000Sstevel@tonic-gate 10013241Shiremath /* Are we on Tavor HCA */ 10023241Shiremath #define IBCM_IS_HCA_TAVOR(hcap) \ 10033241Shiremath (((hcap)->hca_device_id == 0x5a44) && ((hcap)->hca_vendor_id == 0x15b3)) 10040Sstevel@tonic-gate 10050Sstevel@tonic-gate /* 10060Sstevel@tonic-gate * called to ensure that HCA is in "attached" state and is willing to 10070Sstevel@tonic-gate * process connections etc. 10080Sstevel@tonic-gate */ 10090Sstevel@tonic-gate #define IBCM_ACCESS_HCA_OK(s) ((s)->hca_state == IBCM_HCA_ACTIVE) 10100Sstevel@tonic-gate 10110Sstevel@tonic-gate /* 10120Sstevel@tonic-gate * Passive AVL tree lookup info (for hca_passive_tree) 10130Sstevel@tonic-gate * CM needs this structure as passive tree lookups are based on 10140Sstevel@tonic-gate * QPN and HCA GUID. 10150Sstevel@tonic-gate */ 10160Sstevel@tonic-gate typedef struct ibcm_passive_node_info_s { 10170Sstevel@tonic-gate ib_qpn_t info_qpn; 10180Sstevel@tonic-gate ib_guid_t info_hca_guid; 10190Sstevel@tonic-gate } ibcm_passive_node_info_t; 10200Sstevel@tonic-gate 10210Sstevel@tonic-gate /* 10220Sstevel@tonic-gate * Passive Com ID AVL tree lookup info (for hca_passive_comid_tree) 10230Sstevel@tonic-gate * CM needs this structure as passive comid tree lookups are based on 10240Sstevel@tonic-gate * Remote Com ID and Remote HCA GUID. 10250Sstevel@tonic-gate */ 10260Sstevel@tonic-gate typedef struct ibcm_passive_comid_node_info_s { 10270Sstevel@tonic-gate ib_com_id_t info_comid; 10280Sstevel@tonic-gate ib_guid_t info_hca_guid; 10290Sstevel@tonic-gate } ibcm_passive_comid_node_info_t; 10300Sstevel@tonic-gate 10310Sstevel@tonic-gate /* CM proceed task args structure definition */ 10320Sstevel@tonic-gate typedef struct ibcm_proceed_targs_s { 10330Sstevel@tonic-gate ibt_cm_event_type_t event; 10340Sstevel@tonic-gate ibt_cm_status_t status; 10350Sstevel@tonic-gate union tst_t { 10360Sstevel@tonic-gate struct rc_s { 10370Sstevel@tonic-gate ibcm_state_data_t *statep; 10380Sstevel@tonic-gate ibt_cm_proceed_reply_t rc_cm_event_data; 10390Sstevel@tonic-gate } rc; 10400Sstevel@tonic-gate struct ud_s { 10410Sstevel@tonic-gate ibcm_ud_state_data_t *ud_statep; 10420Sstevel@tonic-gate ib_qpn_t ud_qpn; 10430Sstevel@tonic-gate ib_qkey_t ud_qkey; 10440Sstevel@tonic-gate ibt_redirect_info_t ud_redirect_info; 10450Sstevel@tonic-gate } ud; 10460Sstevel@tonic-gate } tst; 10470Sstevel@tonic-gate ibt_priv_data_len_t priv_data_len; 10480Sstevel@tonic-gate /* keep priv_data as the last field */ 10490Sstevel@tonic-gate uint8_t priv_data[IBT_MAX_PRIV_DATA_SZ]; 10500Sstevel@tonic-gate } ibcm_proceed_targs_t; 10510Sstevel@tonic-gate 10520Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_proceed_targs_s)) 10530Sstevel@tonic-gate 10540Sstevel@tonic-gate 10550Sstevel@tonic-gate /* 10560Sstevel@tonic-gate * function prototypes for AVL tree compares 10570Sstevel@tonic-gate */ 10580Sstevel@tonic-gate int ibcm_active_node_compare(const void *, const void *); 10590Sstevel@tonic-gate int ibcm_passive_node_compare(const void *, const void *); 10600Sstevel@tonic-gate int ibcm_passive_comid_node_compare(const void *, const void *); 10610Sstevel@tonic-gate 10620Sstevel@tonic-gate /* 10630Sstevel@tonic-gate * function prototypes to allocate IBMF/SA_ACCESS handles 10640Sstevel@tonic-gate */ 10650Sstevel@tonic-gate ibt_status_t ibcm_hca_reinit_port(ibcm_hca_info_t *hca_p, 10660Sstevel@tonic-gate uint8_t port_index); 10670Sstevel@tonic-gate 10680Sstevel@tonic-gate /* function prototypes to Manage CM's IBMF QP's */ 10690Sstevel@tonic-gate 10700Sstevel@tonic-gate ibcm_qp_list_t *ibcm_find_qp(ibcm_hca_info_t *hcap, int port_no, 10710Sstevel@tonic-gate ib_pkey_t pkey); 10720Sstevel@tonic-gate 10730Sstevel@tonic-gate void ibcm_release_qp(ibcm_qp_list_t *cm_qp_entry); 10740Sstevel@tonic-gate 10750Sstevel@tonic-gate ibcm_status_t ibcm_free_qp(ibcm_qp_list_t *cm_qp_entry); 10760Sstevel@tonic-gate 10770Sstevel@tonic-gate ibcm_status_t ibcm_free_allqps(ibcm_hca_info_t *hcap, int port_no); 10780Sstevel@tonic-gate 10790Sstevel@tonic-gate /* 10800Sstevel@tonic-gate * function prototypes to allocate and free outgoing CM messages 10810Sstevel@tonic-gate */ 10820Sstevel@tonic-gate ibt_status_t 10830Sstevel@tonic-gate ibcm_alloc_out_msg(ibmf_handle_t ibmf_handle, ibmf_msg_t **ibmf_msgpp, 10840Sstevel@tonic-gate uint8_t method); 10850Sstevel@tonic-gate ibcm_status_t 10860Sstevel@tonic-gate ibcm_free_out_msg(ibmf_handle_t ibmf_handle, ibmf_msg_t **ibmf_msgpp); 10870Sstevel@tonic-gate 10880Sstevel@tonic-gate /* 10890Sstevel@tonic-gate * Definition for CM state transition processing function 10900Sstevel@tonic-gate */ 10910Sstevel@tonic-gate typedef void (*ibcm_state_handler_t)(ibcm_hca_info_t *hcap, 10920Sstevel@tonic-gate uint8_t *cm_input_mad, ibcm_mad_addr_t *cm_mad_addr); 10930Sstevel@tonic-gate 10940Sstevel@tonic-gate /* 10950Sstevel@tonic-gate * CM REQ Message structure 10960Sstevel@tonic-gate * 10970Sstevel@tonic-gate * Request for communication. 10980Sstevel@tonic-gate * 10990Sstevel@tonic-gate * Things of interest are:- 11000Sstevel@tonic-gate * ib_qpn_t cannot be used - it is typecast to uint32_t but is 24 bits 11010Sstevel@tonic-gate * ib_eecn_t cannot be used - it is typecast to uint32_t but is 24 bits 11020Sstevel@tonic-gate * 11030Sstevel@tonic-gate * (See Table 85 REQ Message Contents - chapter 12 in IB Spec v1.0a) 11040Sstevel@tonic-gate * 11050Sstevel@tonic-gate */ 11060Sstevel@tonic-gate typedef struct ibcm_req_msg_s { 11070Sstevel@tonic-gate ib_com_id_t req_local_comm_id; /* Local communication id */ 11080Sstevel@tonic-gate /* 32 bits */ 11090Sstevel@tonic-gate uint32_t req_rsvd1; /* Reserved1 - 32 bits */ 11100Sstevel@tonic-gate ib_svc_id_t req_svc_id; /* Service Id - 64 bits */ 11110Sstevel@tonic-gate ib_guid_t req_local_ca_guid; /* Local CA GUID - 64 bits */ 11120Sstevel@tonic-gate uint32_t req_rsvd1p; /* Reserved1+ - 32 bits */ 11130Sstevel@tonic-gate ib_qkey_t req_local_qkey; /* Local Q_KEY - 32 bits */ 11140Sstevel@tonic-gate uint32_t req_local_qpn_plus; /* QPN_24 RESP_RSRC_8 */ 11150Sstevel@tonic-gate /* local side QPN - 24 bits */ 11160Sstevel@tonic-gate /* Offered responder */ 11170Sstevel@tonic-gate /* resources - 8 bits */ 11180Sstevel@tonic-gate uint32_t req_local_eec_no_plus; /* LOCAL_EECN_24 INIT_DEPTH_8 */ 11190Sstevel@tonic-gate /* Local side EECN - 24 bits */ 11200Sstevel@tonic-gate /* Offered initiator */ 11210Sstevel@tonic-gate /* depth - 8 bits */ 11220Sstevel@tonic-gate uint32_t req_remote_eecn_plus; /* REM_EECN_24 TO_5 TT_2 EE_1 */ 11230Sstevel@tonic-gate /* Remote side EECN - 24 bits */ 11240Sstevel@tonic-gate /* Remote CM timeout - 5 bits */ 11250Sstevel@tonic-gate /* Transport srvtype - 2 bits */ 11260Sstevel@tonic-gate /* End-to-End flow - 1 bit */ 11270Sstevel@tonic-gate uint32_t req_starting_psn_plus; /* START_PSN_24 TO_5 RETRY_3 */ 11280Sstevel@tonic-gate /* Starting PSN - 24 bits */ 11290Sstevel@tonic-gate /* Local CM timeout - 5 bits */ 11300Sstevel@tonic-gate /* Retry count - 3 bits */ 11310Sstevel@tonic-gate ib_pkey_t req_part_key; /* Partition key - 16 bits */ 11320Sstevel@tonic-gate uint8_t req_mtu_plus; /* PATH_MTU_4 RDC_1 RNR_3 */ 11330Sstevel@tonic-gate /* Path Pkt MTU - 4 bits */ 11340Sstevel@tonic-gate /* Does RDC exist? - 1 bits */ 11350Sstevel@tonic-gate /* RNR retry count - 3 bits */ 11360Sstevel@tonic-gate uint8_t req_max_cm_retries_plus; /* MAX_CM_RET_4 SRQ_1 RSV_3 */ 11370Sstevel@tonic-gate /* Max CM retries - 4 bits */ 11380Sstevel@tonic-gate /* SRQ Exists - 1 bit */ 11390Sstevel@tonic-gate /* Reserved2 - 3 bits */ 11400Sstevel@tonic-gate ib_lid_t req_primary_l_port_lid; /* Primary local port LID */ 11410Sstevel@tonic-gate ib_lid_t req_primary_r_port_lid; /* Primary Remote port LID */ 11420Sstevel@tonic-gate ib_gid_t req_primary_l_port_gid; /* Primary local port GID */ 11430Sstevel@tonic-gate ib_gid_t req_primary_r_port_gid; /* Primary remote port GID */ 11440Sstevel@tonic-gate uint32_t req_primary_flow_label_plus; /* FLOW_20 RSV_4 SRATE_6 */ 11450Sstevel@tonic-gate /* Prim. flow label - 20 bits */ 11460Sstevel@tonic-gate /* Reserved3 - 6 bits */ 11470Sstevel@tonic-gate /* Primary rate - 6 bits */ 11480Sstevel@tonic-gate uint8_t req_primary_traffic_class; 11490Sstevel@tonic-gate /* Primary Traffic class */ 11500Sstevel@tonic-gate uint8_t req_primary_hop_limit; /* Prim Hop Limit */ 11510Sstevel@tonic-gate uint8_t req_primary_sl_plus; /* PRIMARY_SL_4 LOCAL_1 RSV_3 */ 11520Sstevel@tonic-gate /* Primary SL - 4 bits */ 11530Sstevel@tonic-gate /* Prim. subnet local - 1 bit */ 11540Sstevel@tonic-gate /* Reserved4 - 3 bits */ 11550Sstevel@tonic-gate uint8_t req_primary_localtime_plus; /* LOCAL_TO_5 RSV_3 */ 11560Sstevel@tonic-gate /* Primary local */ 11570Sstevel@tonic-gate /* timeout - 5 bits */ 11580Sstevel@tonic-gate /* Reserved5 - 3 bits */ 11590Sstevel@tonic-gate ib_lid_t req_alt_l_port_lid; /* Alt local port LID */ 11600Sstevel@tonic-gate ib_lid_t req_alt_r_port_lid; /* Alt Remote port LID */ 11610Sstevel@tonic-gate /* Note: req_alt_l_port_gid/req_alt_r_port_gid are not 8-byte aligned */ 11620Sstevel@tonic-gate uint8_t req_alt_l_port_gid[16]; /* Alt local port GID */ 11630Sstevel@tonic-gate uint8_t req_alt_r_port_gid[16]; /* Alt remote port GID */ 11640Sstevel@tonic-gate uint32_t req_alt_flow_label_plus; /* ALT_FLOW_20 RSV_6 ARATE_6 */ 11650Sstevel@tonic-gate /* Alt flow label - 20 bits */ 11660Sstevel@tonic-gate /* Reserved6 - 6 bits */ 11670Sstevel@tonic-gate /* Alternate rate - 6 bits */ 11680Sstevel@tonic-gate uint8_t req_alt_traffic_class; /* Alt traffic class */ 11690Sstevel@tonic-gate uint8_t req_alt_hop_limit; /* Alt hop limit */ 11700Sstevel@tonic-gate uint8_t req_alt_sl_plus; /* ALT_SL_4 A_LOCAL_1 RSV_3 */ 11710Sstevel@tonic-gate /* Alternate SL - 4 bits */ 11720Sstevel@tonic-gate /* Alt subnet local - 1 bit */ 11730Sstevel@tonic-gate /* Reserved7 - 3 bits */ 11740Sstevel@tonic-gate uint8_t req_alt_localtime_plus; /* ALT_LOCAL_ACK_TO_5 RSV_3 */ 11750Sstevel@tonic-gate /* Alt Local ACK */ 11760Sstevel@tonic-gate /* timeout - 5 bits */ 11770Sstevel@tonic-gate /* Reserved8 - 3 bits */ 11780Sstevel@tonic-gate uint8_t req_private_data[IBT_REQ_PRIV_DATA_SZ]; 11790Sstevel@tonic-gate /* Private data */ 11800Sstevel@tonic-gate } ibcm_req_msg_t; 11810Sstevel@tonic-gate 11820Sstevel@tonic-gate 11830Sstevel@tonic-gate /* 11840Sstevel@tonic-gate * The following set of defines are short-cuts to CEP_PATH or GRH info 11850Sstevel@tonic-gate */ 11860Sstevel@tonic-gate #define IBCM_PRIM_CEP_PATH(s) (s)->oc_path->pi_prim_cep_path 11870Sstevel@tonic-gate #define IBCM_PRIM_ADDS_VECT(s) (s)->oc_path->pi_prim_cep_path.cep_adds_vect 11880Sstevel@tonic-gate 11890Sstevel@tonic-gate #define IBCM_ALT_CEP_PATH(s) (s)->oc_path->pi_alt_cep_path 11900Sstevel@tonic-gate #define IBCM_ALT_ADDS_VECT(s) (s)->oc_path->pi_alt_cep_path.cep_adds_vect 11910Sstevel@tonic-gate 11920Sstevel@tonic-gate #define IBCM_UD_CEP_PATH(s) (s)->us_path_info->ai_cep_path 11930Sstevel@tonic-gate #define IBCM_UD_ADDS_VECT(s) (s)->us_path_info->ai_cep_path.cep_adds_vect 11940Sstevel@tonic-gate 11950Sstevel@tonic-gate /* 11960Sstevel@tonic-gate * The following set of defines are short-cuts to ibt_cm_event_t 11970Sstevel@tonic-gate */ 11980Sstevel@tonic-gate #define IBCM_EVT_REQ(e) (e).cm_event.req 11990Sstevel@tonic-gate #define IBCM_EVT_REP(e) (e).cm_event.rep 12000Sstevel@tonic-gate 12010Sstevel@tonic-gate /* 12020Sstevel@tonic-gate * The following set of defines are short-cuts to qp_attrs or qp_info 12030Sstevel@tonic-gate */ 12040Sstevel@tonic-gate #define IBCM_QP_RC(q) (q).qp_info.qp_transport.rc 12050Sstevel@tonic-gate #define IBCM_QP_UD(q) (q).qp_info.qp_transport.ud 12060Sstevel@tonic-gate #define IBCM_QP_UC(q) (q).qp_info.qp_transport.uc 12070Sstevel@tonic-gate 12080Sstevel@tonic-gate #define IBCM_QPINFO(q) (q).qp_transport 12090Sstevel@tonic-gate #define IBCM_QPINFO_RC(q) (q).qp_transport.rc 12100Sstevel@tonic-gate #define IBCM_QPINFO_RC_PATH(q) (q).qp_transport.rc.rc_path 12110Sstevel@tonic-gate #define IBCM_QPINFO_UC(q) (q).qp_transport.uc 12120Sstevel@tonic-gate #define IBCM_QPINFO_UC_PATH(q) (q).qp_transport.uc.uc_path 12130Sstevel@tonic-gate #define IBCM_QPINFO_UD(q) (q).qp_transport.ud 12140Sstevel@tonic-gate 12150Sstevel@tonic-gate 12160Sstevel@tonic-gate /* The following set of defines are short-cuts to RC and SIDR MAD HDRs */ 12170Sstevel@tonic-gate 12180Sstevel@tonic-gate #define IBCM_OUT_MADP(msgp) (msgp->im_msgbufs_send.im_bufs_mad_hdr) 12190Sstevel@tonic-gate #define IBCM_OUT_HDRP(msgp) ((ib_mad_hdr_t *)IBCM_OUT_MADP(msgp)) 12200Sstevel@tonic-gate #define IBCM_OUT_MSGP(msgp) (msgp->im_msgbufs_send.im_bufs_cl_data) 12210Sstevel@tonic-gate 12220Sstevel@tonic-gate #define IBCM_IN_MADP(msgp) (msgp->im_msgbufs_recv.im_bufs_mad_hdr) 12230Sstevel@tonic-gate #define IBCM_IN_HDRP(msgp) ((ib_mad_hdr_t *)IBCM_IN_MADP(msgp)) 12240Sstevel@tonic-gate #define IBCM_IN_MSGP(msgp) (msgp->im_msgbufs_recv.im_bufs_cl_data) 12250Sstevel@tonic-gate 12260Sstevel@tonic-gate #define IBCM_REJ_PRIV(msgp) &(((ibcm_rej_msg_t *) \ 12270Sstevel@tonic-gate IBCM_OUT_MSGP(statep->stored_msg))->rej_private_data[0]) 12280Sstevel@tonic-gate /* 12290Sstevel@tonic-gate * CM MRA Message structure 12300Sstevel@tonic-gate * 12310Sstevel@tonic-gate * Message Receipt Acknowledgement (MRA). 12320Sstevel@tonic-gate * 12330Sstevel@tonic-gate * NOTE: IB hosts and targets are required to be able to receive and 12340Sstevel@tonic-gate * act upon an MRA, but the ability to send an MRA is optional. 12350Sstevel@tonic-gate */ 12360Sstevel@tonic-gate typedef struct ibcm_mra_msg_s { 12370Sstevel@tonic-gate ib_com_id_t mra_local_comm_id; /* Local communication id */ 12380Sstevel@tonic-gate ib_com_id_t mra_remote_comm_id; /* Remote communication id */ 12390Sstevel@tonic-gate uint8_t mra_message_type_plus; /* Message Type - 2 bits */ 12400Sstevel@tonic-gate /* Reserved1 - 6 bits */ 12410Sstevel@tonic-gate uint8_t mra_service_timeout_plus; /* SVC_TO_5 RSV_3 */ 12420Sstevel@tonic-gate /* Service timeout - 5 bits */ 12430Sstevel@tonic-gate /* Reserved2 - 3 bits */ 12440Sstevel@tonic-gate uint8_t mra_private_data[IBT_MRA_PRIV_DATA_SZ]; 12450Sstevel@tonic-gate /* Private data */ 12460Sstevel@tonic-gate } ibcm_mra_msg_t; 12470Sstevel@tonic-gate 12480Sstevel@tonic-gate /* 12490Sstevel@tonic-gate * CM REJ Message structure 12500Sstevel@tonic-gate * REJ indicates that the sender will not continue through the communication 12510Sstevel@tonic-gate * establishment sequence and the reason why it will not. 12520Sstevel@tonic-gate * 12530Sstevel@tonic-gate * NOTE: See ibt_cm_reason_t in common/sys/ib/ib_cm.h for complete list 12540Sstevel@tonic-gate * of rejection reasons supported. 12550Sstevel@tonic-gate */ 12560Sstevel@tonic-gate typedef struct ibcm_rej_msg_s { 12570Sstevel@tonic-gate ib_com_id_t rej_local_comm_id; /* Local communication id */ 12580Sstevel@tonic-gate ib_com_id_t rej_remote_comm_id; /* Remote communication id */ 12590Sstevel@tonic-gate uint8_t rej_msg_type_plus; /* REJ_MSG_TYPE_2 RSV_6 */ 12600Sstevel@tonic-gate /* Msg being REJed - 2 bits */ 12610Sstevel@tonic-gate /* Reserved1 - 6 bits */ 12620Sstevel@tonic-gate uint8_t rej_reject_info_len_plus; /* REJ_INFO_LEN_7 RSV_1 */ 12630Sstevel@tonic-gate /* Rej. Info Length - 7 bits */ 12640Sstevel@tonic-gate /* Reserved2 - 1 bit */ 12650Sstevel@tonic-gate uint16_t rej_rejection_reason; /* Reject err code - 16 bits */ 12660Sstevel@tonic-gate uint8_t rej_addl_rej_info[IBT_CM_ADDL_REJ_LEN]; 12670Sstevel@tonic-gate /* Additional Reject Info */ 12680Sstevel@tonic-gate uint8_t rej_private_data[IBT_REJ_PRIV_DATA_SZ]; 12690Sstevel@tonic-gate /* Private data */ 12700Sstevel@tonic-gate } ibcm_rej_msg_t; 12710Sstevel@tonic-gate 12720Sstevel@tonic-gate /* 12730Sstevel@tonic-gate * CM REP Message structure 12740Sstevel@tonic-gate * 12750Sstevel@tonic-gate * REP is returned in response to REQ, indicating that the respondent 12760Sstevel@tonic-gate * accepts the Service-ID, proposed primary port, and any parameters 12770Sstevel@tonic-gate * specified in the PrivateData of the REQ. 12780Sstevel@tonic-gate */ 12790Sstevel@tonic-gate typedef struct ibcm_rep_msg_s { 12800Sstevel@tonic-gate ib_com_id_t rep_local_comm_id; /* Local communication id */ 12810Sstevel@tonic-gate ib_com_id_t rep_remote_comm_id; /* Remote communication id */ 12820Sstevel@tonic-gate ib_qkey_t rep_local_qkey; /* Local Q_KEY */ 12830Sstevel@tonic-gate uint32_t rep_local_qpn_plus; /* LOCAL_QPN_24 RSV_8 */ 12840Sstevel@tonic-gate /* Local side QPN - 24 bits */ 12850Sstevel@tonic-gate /* Reserved1 - 8 bits */ 12860Sstevel@tonic-gate uint32_t rep_local_eecn_plus; /* LOCAL_EECN_24 RSV_8 */ 12870Sstevel@tonic-gate /* Local side EECN - 24 bits */ 12880Sstevel@tonic-gate /* Reserved2 - 8 bits */ 12890Sstevel@tonic-gate uint32_t rep_starting_psn_plus; /* STARTING_PSN_24 RSV_8 */ 12900Sstevel@tonic-gate /* Starting PSN - 24 bits */ 12910Sstevel@tonic-gate /* Reserved3 - 8 bits */ 12920Sstevel@tonic-gate uint8_t rep_resp_resources; /* Responder resources 8 bits */ 12930Sstevel@tonic-gate uint8_t rep_initiator_depth; /* Initiator depth - 8 bits */ 12940Sstevel@tonic-gate uint8_t rep_target_delay_plus; /* TGT_ACK_DLY_5 FAIL_2 EE_1 */ 12950Sstevel@tonic-gate /* Target ACK delay - 5 bits */ 12960Sstevel@tonic-gate /* Failover accepted - 2 bits */ 12970Sstevel@tonic-gate /* End-to-End flow control - */ 12980Sstevel@tonic-gate /* 1 bit */ 12990Sstevel@tonic-gate uint8_t rep_rnr_retry_cnt_plus; /* RNR_COUNT_3 SRQ_1 RSV_4 */ 13000Sstevel@tonic-gate /* RNR retry count - 3 bits */ 13010Sstevel@tonic-gate /* SRQ Exists - 1 bit */ 13020Sstevel@tonic-gate /* Reserved4 - 4 bits */ 13030Sstevel@tonic-gate uint8_t rep_local_ca_guid[8]; /* Local CA GUID - 64 bits */ 13040Sstevel@tonic-gate uint8_t rep_private_data[IBT_REP_PRIV_DATA_SZ]; 13050Sstevel@tonic-gate /* Private data */ 13060Sstevel@tonic-gate } ibcm_rep_msg_t; 13070Sstevel@tonic-gate 13080Sstevel@tonic-gate 13090Sstevel@tonic-gate /* 13100Sstevel@tonic-gate * CM RTU Message structure 13110Sstevel@tonic-gate * 13120Sstevel@tonic-gate * RTU indicates that the connection is established, and that the 13130Sstevel@tonic-gate * recipient may begin transmitting. 13140Sstevel@tonic-gate */ 13150Sstevel@tonic-gate typedef struct ibcm_rtu_msg_s { 13160Sstevel@tonic-gate ib_com_id_t rtu_local_comm_id; /* Local communication id */ 13170Sstevel@tonic-gate ib_com_id_t rtu_remote_comm_id; /* Remote communication id */ 13180Sstevel@tonic-gate uint8_t rtu_private_data[IBT_RTU_PRIV_DATA_SZ]; 13190Sstevel@tonic-gate /* Private data */ 13200Sstevel@tonic-gate } ibcm_rtu_msg_t; 13210Sstevel@tonic-gate 13220Sstevel@tonic-gate 13230Sstevel@tonic-gate /* 13240Sstevel@tonic-gate * CM DREQ Message structure 13250Sstevel@tonic-gate * 13260Sstevel@tonic-gate * DREQ is sent to initiate the connection release sequence. 13270Sstevel@tonic-gate */ 13280Sstevel@tonic-gate typedef struct ibcm_dreq_msg_s { 13290Sstevel@tonic-gate ib_com_id_t dreq_local_comm_id; /* Local communication id */ 13300Sstevel@tonic-gate ib_com_id_t dreq_remote_comm_id; /* Remote communication id */ 13310Sstevel@tonic-gate uint32_t dreq_remote_qpn_eecn_plus; /* REM_EECN_24 RSV_8 */ 13320Sstevel@tonic-gate /* Remote QPN/EECN - 24 bits */ 13330Sstevel@tonic-gate /* reserved - 8 bits */ 13340Sstevel@tonic-gate uint8_t dreq_private_data[IBT_DREQ_PRIV_DATA_SZ]; 13350Sstevel@tonic-gate /* Private data */ 13360Sstevel@tonic-gate } ibcm_dreq_msg_t; 13370Sstevel@tonic-gate 13380Sstevel@tonic-gate 13390Sstevel@tonic-gate /* 13400Sstevel@tonic-gate * CM DREP Message structure 13410Sstevel@tonic-gate * 13420Sstevel@tonic-gate * DREP is sent in response to DREQ, and signifies that the sender has 13430Sstevel@tonic-gate * received DREQ. 13440Sstevel@tonic-gate */ 13450Sstevel@tonic-gate typedef struct ibcm_drep_msg_s { 13460Sstevel@tonic-gate ib_com_id_t drep_local_comm_id; /* Local communication id */ 13470Sstevel@tonic-gate ib_com_id_t drep_remote_comm_id; /* Remote communication id */ 13480Sstevel@tonic-gate uint8_t drep_private_data[IBT_DREP_PRIV_DATA_SZ]; 13490Sstevel@tonic-gate /* Private Data */ 13500Sstevel@tonic-gate } ibcm_drep_msg_t; 13510Sstevel@tonic-gate 13520Sstevel@tonic-gate 13530Sstevel@tonic-gate /* 13540Sstevel@tonic-gate * CM LAP Message structure 13550Sstevel@tonic-gate * 13560Sstevel@tonic-gate * NOTE: LAP and APR messages are optional. These are needed if CM 13570Sstevel@tonic-gate * accepts REQ messages and agrees to perform Automatic Path Migration. 13580Sstevel@tonic-gate * 13590Sstevel@tonic-gate * This message is used to change the alternate path information for a 13600Sstevel@tonic-gate * specific connection. 13610Sstevel@tonic-gate */ 13620Sstevel@tonic-gate typedef struct ibcm_lap_msg_s { 13630Sstevel@tonic-gate ib_com_id_t lap_local_comm_id; /* Local communication id */ 13640Sstevel@tonic-gate ib_com_id_t lap_remote_comm_id; /* Remote communication id */ 13650Sstevel@tonic-gate uint32_t lap_rsvd1; /* Reserved - 32 bits */ 13660Sstevel@tonic-gate uint32_t lap_remote_qpn_eecn_plus; /* REM_EECN_24 TO_5 RSV_3 */ 13670Sstevel@tonic-gate /* Remote QPN/EECN - 24 bits */ 13680Sstevel@tonic-gate /* Remote CM response */ 13690Sstevel@tonic-gate /* timeout - 5 bits */ 13700Sstevel@tonic-gate /* Reserved1 - 3 bits */ 13710Sstevel@tonic-gate uint32_t lap_rsvd2; /* Reserved2 - 32 bits */ 13720Sstevel@tonic-gate ib_lid_t lap_alt_l_port_lid; /* Alt local port LID */ 13730Sstevel@tonic-gate ib_lid_t lap_alt_r_port_lid; /* Alt Remote port LID */ 13740Sstevel@tonic-gate ib_gid_t lap_alt_l_port_gid; /* Alt local port GID */ 13750Sstevel@tonic-gate ib_gid_t lap_alt_r_port_gid; /* Alt remote port GID */ 13760Sstevel@tonic-gate uint32_t lap_alt_flow_label_plus; /* ALT_FLOW_20 RSV_4 TCL_8 */ 13770Sstevel@tonic-gate /* Alt flow label - 20 bits */ 13780Sstevel@tonic-gate /* Reserved3 - 4 bits */ 13790Sstevel@tonic-gate /* Alt traffic class - 8 bits */ 13800Sstevel@tonic-gate uint8_t lap_alt_hop_limit; /* Alt hop limit */ 13810Sstevel@tonic-gate uint8_t lap_alt_srate_plus; /* Reserved4 - 2 bits */ 13820Sstevel@tonic-gate /* Alt. static rate - 6 bits */ 13830Sstevel@tonic-gate uint8_t lap_alt_sl_plus; /* ALT_SL_4 A_LOCAL_1 RSV_3 */ 13840Sstevel@tonic-gate /* Alternate SL - 4 bits */ 13850Sstevel@tonic-gate /* Alt subnet local - 1 bit */ 13860Sstevel@tonic-gate /* Reserved5 - 3 bits */ 13870Sstevel@tonic-gate uint8_t lap_alt_local_acktime_plus; /* ALT_TO_5 RSV_3 */ 13880Sstevel@tonic-gate /* Alt Local ACK */ 13890Sstevel@tonic-gate /* timeout - 5 bits */ 13900Sstevel@tonic-gate /* Reserved6 - 3 bits */ 13910Sstevel@tonic-gate uint8_t lap_private_data[IBT_LAP_PRIV_DATA_SZ]; 13920Sstevel@tonic-gate /* Private data */ 13930Sstevel@tonic-gate } ibcm_lap_msg_t; 13940Sstevel@tonic-gate 13950Sstevel@tonic-gate 13960Sstevel@tonic-gate /* 13970Sstevel@tonic-gate * CM APR Message structure 13980Sstevel@tonic-gate * 13990Sstevel@tonic-gate * APR is sent in response to a LAP request. MRA may be sent to allow 14000Sstevel@tonic-gate * processing of the LAP. 14010Sstevel@tonic-gate */ 14020Sstevel@tonic-gate typedef struct ibcm_apr_msg_s { 14030Sstevel@tonic-gate ib_com_id_t apr_local_comm_id; /* Local communication id */ 14040Sstevel@tonic-gate ib_com_id_t apr_remote_comm_id; /* Remote communication id */ 14050Sstevel@tonic-gate uint8_t apr_addl_info_len; /* Add'l Info Len - 8 bits */ 14060Sstevel@tonic-gate uint8_t apr_ap_status; /* AP status - 8 bits */ 14070Sstevel@tonic-gate uint16_t apr_rsvd1; /* Reserved1 - 16 bits */ 14080Sstevel@tonic-gate uint8_t apr_addl_info[IBT_CM_APR_ADDL_LEN]; 14090Sstevel@tonic-gate /* Additional Information */ 14100Sstevel@tonic-gate uint8_t apr_private_data[IBT_APR_PRIV_DATA_SZ]; 14110Sstevel@tonic-gate /* Private data */ 14120Sstevel@tonic-gate } ibcm_apr_msg_t; 14130Sstevel@tonic-gate 14140Sstevel@tonic-gate 14150Sstevel@tonic-gate /* 14160Sstevel@tonic-gate * CM SIDR_REQ Message structure 14170Sstevel@tonic-gate * 14180Sstevel@tonic-gate * NOTE: SIDR_REQ and SIDR_REP messages are conditionally required. 14190Sstevel@tonic-gate * These are needed if non-management services are provided on the Channel 14200Sstevel@tonic-gate * Adapter other than fixed QPNs. Management services include those 14210Sstevel@tonic-gate * provided thru Subnet Manager Packets or thru General Management Packets. 14220Sstevel@tonic-gate * 14230Sstevel@tonic-gate * SIDR_REQ requests that the recipient return the information necessary 14240Sstevel@tonic-gate * to communicate via UD messages with the entity specified by 14250Sstevel@tonic-gate * SIDR_REQ:ServiceID 14260Sstevel@tonic-gate */ 14270Sstevel@tonic-gate typedef struct ibcm_sidr_req_msg_s { 14280Sstevel@tonic-gate uint32_t sidr_req_request_id; /* Request id */ 14290Sstevel@tonic-gate ib_pkey_t sidr_req_pkey; /* P_Key */ 14300Sstevel@tonic-gate uint8_t sidr_req_reserved[2]; /* Reserved */ 14310Sstevel@tonic-gate ib_svc_id_t sidr_req_service_id; /* Service Id */ 14320Sstevel@tonic-gate uint8_t sidr_req_private_data[IBT_SIDR_REQ_PRIV_DATA_SZ]; 14330Sstevel@tonic-gate /* Private Data */ 14340Sstevel@tonic-gate } ibcm_sidr_req_msg_t; 14350Sstevel@tonic-gate 14360Sstevel@tonic-gate 14370Sstevel@tonic-gate /* 14380Sstevel@tonic-gate * CM SIDR_REP Message structure 14390Sstevel@tonic-gate * 14400Sstevel@tonic-gate * SIDR_REP returns the information necessary to communicate via UD 14410Sstevel@tonic-gate * messages with the entity specified by SIDR_REQ:ServiceID 14420Sstevel@tonic-gate */ 14430Sstevel@tonic-gate typedef struct ibcm_sidr_rep_msg_s { 14440Sstevel@tonic-gate uint32_t sidr_rep_request_id; /* Request id */ 14450Sstevel@tonic-gate uint8_t sidr_rep_rep_status; /* Status */ 14460Sstevel@tonic-gate uint8_t sidr_rep_add_info_len; /* Length of Add Info */ 14470Sstevel@tonic-gate uint8_t sidr_rep_reserved1[2]; /* Reserved */ 14480Sstevel@tonic-gate uint32_t sidr_rep_qpn_plus; /* QPN_24 RSV_8 */ 14490Sstevel@tonic-gate /* since the 64-bit SID is not aligned, treat it as a byte array */ 14500Sstevel@tonic-gate uint8_t sidr_rep_service_id[8]; /* Service Id */ 14510Sstevel@tonic-gate ib_qkey_t sidr_rep_qkey; /* Q_KEY */ 14520Sstevel@tonic-gate uint8_t sidr_rep_class_port_info[IBT_CM_SIDR_CP_LEN]; 14530Sstevel@tonic-gate /* Class Port Info */ 14540Sstevel@tonic-gate /* aka., add'l info */ 14550Sstevel@tonic-gate uint8_t sidr_rep_private_data[IBT_SIDR_REP_PRIV_DATA_SZ]; 14560Sstevel@tonic-gate /* Private data */ 14570Sstevel@tonic-gate } ibcm_sidr_rep_msg_t; 14580Sstevel@tonic-gate 14590Sstevel@tonic-gate typedef struct ibcm_classportinfo_msg_s { 14600Sstevel@tonic-gate uint8_t BaseVersion; /* ver. of MAD base format */ 14610Sstevel@tonic-gate uint8_t ClassVersion; /* ver. of MAD class format */ 14620Sstevel@tonic-gate uint16_t CapabilityMask; /* capabilities of this class */ 14630Sstevel@tonic-gate uint32_t RespTimeValue_plus; /* reserved : 27 bits */ 14640Sstevel@tonic-gate /* resptime value : 5 bits */ 14650Sstevel@tonic-gate uint64_t RedirectGID_hi; /* dest gid of redirect msgs */ 14660Sstevel@tonic-gate uint64_t RedirectGID_lo; /* dest gid of redirect msgs */ 14670Sstevel@tonic-gate uint32_t RedirectTC_plus; /* traffic class: 8 bits */ 14680Sstevel@tonic-gate /* SL: 4 bits */ 14690Sstevel@tonic-gate /* Flow label: 20 bits */ 14700Sstevel@tonic-gate ib_lid_t RedirectLID; /* dlid for class services */ 14710Sstevel@tonic-gate ib_pkey_t RedirectP_Key; /* p_key for class services */ 14720Sstevel@tonic-gate uint32_t RedirectQP_plus; /* Reserved: 8 bits */ 14730Sstevel@tonic-gate /* QPN: 24 bits */ 14740Sstevel@tonic-gate ib_qkey_t RedirectQ_Key; /* q_key for class services */ 14750Sstevel@tonic-gate uint64_t TrapGID_hi; /* dest gid of trap msgs */ 14760Sstevel@tonic-gate uint64_t TrapGID_lo; /* dest gid of trap msgs */ 14770Sstevel@tonic-gate uint32_t TrapTC_plus; /* Trap traffic class, etc., */ 14780Sstevel@tonic-gate ib_lid_t TrapLID; /* dlid for traps */ 14790Sstevel@tonic-gate ib_pkey_t TrapP_Key; /* p_key for traps */ 14800Sstevel@tonic-gate uint32_t TrapHL_plus; /* Trap hop limit,etc., */ 14810Sstevel@tonic-gate ib_qkey_t TrapQ_Key; /* q_key for traps */ 14820Sstevel@tonic-gate } ibcm_classportinfo_msg_t; 14830Sstevel@tonic-gate 14840Sstevel@tonic-gate /* All msgs are readonly on receiving side */ 14850Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_req_msg_s)) 14860Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_rep_msg_s)) 14870Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_mra_msg_s)) 14880Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_rej_msg_s)) 14890Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_lap_msg_s)) 14900Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_apr_msg_s)) 14910Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_sidr_req_msg_s)) 14920Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_sidr_rep_msg_s)) 14930Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_rtu_msg_s)) 14940Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_dreq_msg_s)) 14950Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_drep_msg_s)) 14960Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_classportinfo_msg_s)) 14970Sstevel@tonic-gate 14980Sstevel@tonic-gate /* Prototype definitions for CM implementation functions */ 14990Sstevel@tonic-gate 15000Sstevel@tonic-gate /* 15010Sstevel@tonic-gate * The callback from IBMF to CM. This routines calls one of the CM 15020Sstevel@tonic-gate * state processing functions depending upon mesg/attribute id 15030Sstevel@tonic-gate * 15040Sstevel@tonic-gate * ibmf_handle : IBMF handle on which CM MAD was received 15050Sstevel@tonic-gate * pktp : MAD packet 15060Sstevel@tonic-gate * args : IBMF receive mad callback arg 15070Sstevel@tonic-gate */ 15080Sstevel@tonic-gate void ibcm_recv_cb(ibmf_handle_t ibmf_handle, ibmf_msg_t *msgp, void *args); 15090Sstevel@tonic-gate 15100Sstevel@tonic-gate /* 15110Sstevel@tonic-gate * Prototypes for CM state transition handling functions 15120Sstevel@tonic-gate */ 15130Sstevel@tonic-gate 15140Sstevel@tonic-gate /* 15150Sstevel@tonic-gate * The following are the CM state processing functions called on an 15160Sstevel@tonic-gate * incoming REQ/REP/RTU/MRA/REJ/DREQ/DREP on active/passive sides 15170Sstevel@tonic-gate * (Also handled are SIDR_REP and SIDR_REQ) 15180Sstevel@tonic-gate * The brief description of these functions 15190Sstevel@tonic-gate * Search based on CM message fields in CM's HCA entry. 15200Sstevel@tonic-gate * Create/Delete state structures based on incoming message 15210Sstevel@tonic-gate * Handle duplicate messages and state transitions 15220Sstevel@tonic-gate * Set and Cancel timeouts 15230Sstevel@tonic-gate * Handle stale connections 15240Sstevel@tonic-gate * Change CM connection state 15250Sstevel@tonic-gate * Call CM CEP state transition functions to update CEP state 15260Sstevel@tonic-gate * and set CEP attributes 15270Sstevel@tonic-gate * 15280Sstevel@tonic-gate * INPUTS: 15290Sstevel@tonic-gate * hcap: - IBMF callback argument 15300Sstevel@tonic-gate * cm_input_mad: - ibmf message pointer of incoming MAD 15310Sstevel@tonic-gate * cm_mad_addr - CM MAD address 15320Sstevel@tonic-gate * 15330Sstevel@tonic-gate * The state transition processing is specified in different functions based 15340Sstevel@tonic-gate * on incoming message type rather than as one function because, the CM 15350Sstevel@tonic-gate * processing is different for each of them. 15360Sstevel@tonic-gate * 15370Sstevel@tonic-gate * A global call table is initialized with these function addresses 15380Sstevel@tonic-gate * (is defined in ibcm_impl.c), and invoked from ibcm_recv_cb 15390Sstevel@tonic-gate * (IBMF's recv callback to CM) based on mesg/attribute id. 15400Sstevel@tonic-gate */ 15410Sstevel@tonic-gate void ibcm_process_req_msg(ibcm_hca_info_t *hcap, uint8_t *cm_input_mad, 15420Sstevel@tonic-gate ibcm_mad_addr_t *cm_mad_addr); 15430Sstevel@tonic-gate void ibcm_process_rep_msg(ibcm_hca_info_t *hcap, uint8_t *cm_input_mad, 15440Sstevel@tonic-gate ibcm_mad_addr_t *cm_mad_addr); 15450Sstevel@tonic-gate void ibcm_process_rtu_msg(ibcm_hca_info_t *hcap, uint8_t *cm_input_mad, 15460Sstevel@tonic-gate ibcm_mad_addr_t *cm_mad_addr); 15470Sstevel@tonic-gate void ibcm_process_dreq_msg(ibcm_hca_info_t *hcap, uint8_t *cm_input_mad, 15480Sstevel@tonic-gate ibcm_mad_addr_t *cm_mad_addr); 15490Sstevel@tonic-gate void ibcm_process_drep_msg(ibcm_hca_info_t *hcap, uint8_t *cm_input_mad, 15500Sstevel@tonic-gate ibcm_mad_addr_t *cm_mad_addr); 15510Sstevel@tonic-gate void ibcm_process_rej_msg(ibcm_hca_info_t *hcap, uint8_t *cm_input_mad, 15520Sstevel@tonic-gate ibcm_mad_addr_t *cm_mad_addr); 15530Sstevel@tonic-gate void ibcm_process_mra_msg(ibcm_hca_info_t *hcap, uint8_t *cm_input_mad, 15540Sstevel@tonic-gate ibcm_mad_addr_t *cm_mad_addr); 15550Sstevel@tonic-gate void ibcm_process_apr_msg(ibcm_hca_info_t *hcap, uint8_t *cm_input_mad, 15560Sstevel@tonic-gate ibcm_mad_addr_t *cm_mad_addr); 15570Sstevel@tonic-gate void ibcm_process_lap_msg(ibcm_hca_info_t *hcap, uint8_t *cm_input_mad, 15580Sstevel@tonic-gate ibcm_mad_addr_t *cm_mad_addr); 15590Sstevel@tonic-gate void ibcm_process_sidr_req_msg(ibcm_hca_info_t *hcap, 15600Sstevel@tonic-gate uint8_t *cm_input_mad, ibcm_mad_addr_t *cm_mad_addr); 15610Sstevel@tonic-gate void ibcm_process_sidr_rep_msg(ibcm_hca_info_t *hcap, 15620Sstevel@tonic-gate uint8_t *cm_input_mad, ibcm_mad_addr_t *cm_mad_addr); 15630Sstevel@tonic-gate 15640Sstevel@tonic-gate typedef enum ibcm_proceed_error_e { 15650Sstevel@tonic-gate IBCM_PROCEED_INVALID_NONE = 0, 15660Sstevel@tonic-gate IBCM_PROCEED_INVALID_EVENT, 15670Sstevel@tonic-gate IBCM_PROCEED_INVALID_EVENT_STATE, 15680Sstevel@tonic-gate IBCM_PROCEED_INVALID_PRIV_SZ, 15690Sstevel@tonic-gate IBCM_PROCEED_INVALID_LAP 15700Sstevel@tonic-gate } ibcm_proceed_error_t; 15710Sstevel@tonic-gate 15720Sstevel@tonic-gate /* Encapsulates the information that client returns back from CM callback */ 15730Sstevel@tonic-gate typedef struct ibcm_clnt_reply_info_s { 15740Sstevel@tonic-gate ibt_cm_proceed_reply_t *reply_event; 15750Sstevel@tonic-gate void *priv_data; 15760Sstevel@tonic-gate ibt_priv_data_len_t priv_data_len; 15770Sstevel@tonic-gate } ibcm_clnt_reply_info_t; 15780Sstevel@tonic-gate 15790Sstevel@tonic-gate /* Encapsulates the information that UD client returns back from CM callback */ 15800Sstevel@tonic-gate typedef struct ibcm_ud_clnt_reply_info_s { 15810Sstevel@tonic-gate ib_qpn_t ud_qpn; 15820Sstevel@tonic-gate ib_qkey_t ud_qkey; 15830Sstevel@tonic-gate ibt_redirect_info_t *redirect_infop; 15840Sstevel@tonic-gate void *priv_data; 15850Sstevel@tonic-gate ibt_priv_data_len_t priv_data_len; 15860Sstevel@tonic-gate } ibcm_ud_clnt_reply_info_t; 15870Sstevel@tonic-gate 15880Sstevel@tonic-gate /* 15890Sstevel@tonic-gate * Prototypes for CM CEP state transition handling functions. These are 15900Sstevel@tonic-gate * called from CM connection state transition handling functions. 15910Sstevel@tonic-gate * 15920Sstevel@tonic-gate * The brief description of these functions : 15930Sstevel@tonic-gate * Validate CEP related attributes in the messages 15940Sstevel@tonic-gate * Change CEP state 15950Sstevel@tonic-gate * Set CEP attributes (modify CEP) 15960Sstevel@tonic-gate * Call client/server callback handlers 15970Sstevel@tonic-gate * Fill up the response MADs 15980Sstevel@tonic-gate * 15990Sstevel@tonic-gate * The arguments are : 16000Sstevel@tonic-gate * statep: Connection state structure 16010Sstevel@tonic-gate * cm_req/rep/rtu/rej msg : Received CM message 16020Sstevel@tonic-gate * cm_output_mad : The response CM MAD with some of the fields filled in 16030Sstevel@tonic-gate * The cm output mad is allocated by CM state transition 16040Sstevel@tonic-gate * functions and has generic MAD header 16050Sstevel@tonic-gate * Certain fields like com id, etc., are filled by CM 16060Sstevel@tonic-gate * connection state transition functions that are above 16070Sstevel@tonic-gate */ 16080Sstevel@tonic-gate 16090Sstevel@tonic-gate /* QP state transition function called for an incoming REQ on passive side */ 16100Sstevel@tonic-gate ibcm_status_t ibcm_cep_state_req(ibcm_state_data_t *statep, 16110Sstevel@tonic-gate ibcm_req_msg_t *cm_req_msg, ibt_cm_reason_t *reason, 16120Sstevel@tonic-gate uint8_t *arej_info_len); 16130Sstevel@tonic-gate 16140Sstevel@tonic-gate /* Processes QP state machine based on return values from cm handler */ 16150Sstevel@tonic-gate ibcm_status_t ibcm_process_cep_req_cm_hdlr(ibcm_state_data_t *statep, 16160Sstevel@tonic-gate ibt_cm_status_t cb_status, 16170Sstevel@tonic-gate ibcm_clnt_reply_info_t *clnt_info, 16180Sstevel@tonic-gate ibt_cm_reason_t *reject_reason, uint8_t *arej_len, 16190Sstevel@tonic-gate ibcm_req_msg_t *cm_req_msgp); 16200Sstevel@tonic-gate 16210Sstevel@tonic-gate /* Processes CM state machine based on return values from ibcm_cep_state_req */ 16220Sstevel@tonic-gate void ibcm_handle_cep_req_response(ibcm_state_data_t *statep, 16230Sstevel@tonic-gate ibcm_status_t response, ibt_cm_reason_t reject_reason, 16240Sstevel@tonic-gate uint8_t arej_info_len); 16250Sstevel@tonic-gate 16260Sstevel@tonic-gate /* QP state transition function called for an incoming REP on active side */ 16270Sstevel@tonic-gate ibcm_status_t ibcm_cep_state_rep(ibcm_state_data_t *statep, 16280Sstevel@tonic-gate ibcm_rep_msg_t *cm_rep_msg, ibt_cm_reason_t *reason, 16290Sstevel@tonic-gate uint8_t *arej_info_len); 16300Sstevel@tonic-gate 16310Sstevel@tonic-gate /* Processes QP state machine based on return values from cm handler */ 16320Sstevel@tonic-gate ibcm_status_t ibcm_process_cep_rep_cm_hdlr(ibcm_state_data_t *statep, 16330Sstevel@tonic-gate ibt_cm_status_t cb_status, 16340Sstevel@tonic-gate ibcm_clnt_reply_info_t *clnt_info, 16350Sstevel@tonic-gate ibt_cm_reason_t *reject_reason, uint8_t *arej_len, 16360Sstevel@tonic-gate ibcm_rep_msg_t *cm_rep_msgp); 16370Sstevel@tonic-gate 16380Sstevel@tonic-gate /* Processes CM state machine based on return values from ibcm_cep_state_rep */ 16390Sstevel@tonic-gate void ibcm_handle_cep_rep_response(ibcm_state_data_t *statep, 16400Sstevel@tonic-gate ibcm_status_t response, ibt_cm_reason_t reject_reason, 16410Sstevel@tonic-gate uint8_t arej_info_len, ibcm_rep_msg_t *rep_msgp); 16420Sstevel@tonic-gate 16430Sstevel@tonic-gate /* QP state transition function called for an incoming RTU on passive side */ 16440Sstevel@tonic-gate void ibcm_cep_state_rtu(ibcm_state_data_t *statep, 16450Sstevel@tonic-gate ibcm_rtu_msg_t *cm_rtu_msg); 16460Sstevel@tonic-gate 16470Sstevel@tonic-gate /* QP state transition func called for an incoming REJ on active/passive side */ 16480Sstevel@tonic-gate void ibcm_cep_state_rej(ibcm_state_data_t *statep, 16490Sstevel@tonic-gate ibcm_rej_msg_t *cm_rej_msg, ibcm_conn_state_t rej_state); 16500Sstevel@tonic-gate 16510Sstevel@tonic-gate /* QP state transition func for an incoming REJ on active side in est state */ 16520Sstevel@tonic-gate void ibcm_cep_state_rej_est(ibcm_state_data_t *statep); 16530Sstevel@tonic-gate 16540Sstevel@tonic-gate /* 16550Sstevel@tonic-gate * QP state transition function called for an outgoing RTU on active side, 16560Sstevel@tonic-gate * after setting CEP to RTS state active/passive side 16570Sstevel@tonic-gate */ 16580Sstevel@tonic-gate void ibcm_cep_send_rtu(ibcm_state_data_t *statep); 16590Sstevel@tonic-gate 16600Sstevel@tonic-gate 16610Sstevel@tonic-gate /* QP state transition function called for an incoming LAP */ 16620Sstevel@tonic-gate ibcm_status_t ibcm_cep_state_lap(ibcm_state_data_t *statep, 16630Sstevel@tonic-gate ibcm_lap_msg_t *lap_msg, ibcm_apr_msg_t *apr_msg); 16640Sstevel@tonic-gate 16650Sstevel@tonic-gate /* Processes QP state machine based on return value from cm handler for LAP */ 16660Sstevel@tonic-gate void ibcm_process_cep_lap_cm_hdlr(ibcm_state_data_t *statep, 16670Sstevel@tonic-gate ibt_cm_status_t cb_status, 16680Sstevel@tonic-gate ibcm_clnt_reply_info_t *clnt_info, 16690Sstevel@tonic-gate ibcm_lap_msg_t *lap_msg, ibcm_apr_msg_t *apr_msg); 16700Sstevel@tonic-gate 16710Sstevel@tonic-gate void ibcm_post_apr_mad(ibcm_state_data_t *statep); 16720Sstevel@tonic-gate 16730Sstevel@tonic-gate void ibcm_cep_state_apr(ibcm_state_data_t *statep, 16740Sstevel@tonic-gate ibcm_lap_msg_t *lap_msg, ibcm_apr_msg_t *apr_msg); 16750Sstevel@tonic-gate 16760Sstevel@tonic-gate /* Processes CM state machine based on return value from cm handler */ 16770Sstevel@tonic-gate void ibcm_handle_cep_dreq_response(ibcm_state_data_t *statep, 16780Sstevel@tonic-gate void *priv_data, ibt_priv_data_len_t priv_data_len); 16790Sstevel@tonic-gate 16800Sstevel@tonic-gate /* Processes CM UD state machine based on return values from cm handler */ 16810Sstevel@tonic-gate void ibcm_process_sidr_req_cm_hdlr(ibcm_ud_state_data_t *ud_statep, 16820Sstevel@tonic-gate ibt_cm_status_t cb_status, 16830Sstevel@tonic-gate ibcm_ud_clnt_reply_info_t *ud_clnt_info, 16840Sstevel@tonic-gate ibt_sidr_status_t *sidr_status, 16850Sstevel@tonic-gate ibcm_sidr_rep_msg_t *sidr_repp); 16860Sstevel@tonic-gate 16870Sstevel@tonic-gate void ibcm_proceed_via_taskq(void *targs); 16880Sstevel@tonic-gate void ibcm_ud_proceed_via_taskq(void *targs); 16890Sstevel@tonic-gate 16900Sstevel@tonic-gate /* 16910Sstevel@tonic-gate * Builds the reply MAD address based on "incoming mad addr" that is 16920Sstevel@tonic-gate * supplied to it as an arg. 16930Sstevel@tonic-gate * Swaps the source and destination lids in ibmf_addr_info_t 16940Sstevel@tonic-gate * Swaps the source and destination gids in ib_grh_t 16950Sstevel@tonic-gate * 16960Sstevel@tonic-gate * INPUTS: 16970Sstevel@tonic-gate * incoming_cm_mad_addr - Address information in the incoming MAD 16980Sstevel@tonic-gate * reply_cm_mad_addr - Derived address for the reply MAD 16990Sstevel@tonic-gate * The reply MAD address is derived based 17000Sstevel@tonic-gate * address information of incoming CM MAD 17010Sstevel@tonic-gate */ 17020Sstevel@tonic-gate void ibcm_build_reply_mad_addr(ibcm_mad_addr_t *incoming_cm_mad_addr, 17030Sstevel@tonic-gate ibcm_mad_addr_t *reply_cm_mad_addr); 17040Sstevel@tonic-gate 17050Sstevel@tonic-gate /* Posts RC CM MAD using IBMF */ 17060Sstevel@tonic-gate void ibcm_post_rc_mad(ibcm_state_data_t *statep, ibmf_msg_t *msgp, 17070Sstevel@tonic-gate ibmf_msg_cb_t post_cb, void *args); 17080Sstevel@tonic-gate 17090Sstevel@tonic-gate /* Posts UD CM MAD using IBMF */ 17100Sstevel@tonic-gate void ibcm_post_ud_mad(ibcm_ud_state_data_t *ud_statep, ibmf_msg_t *msgp, 17110Sstevel@tonic-gate ibmf_msg_cb_t ud_post_cb, void *args); 17120Sstevel@tonic-gate 17130Sstevel@tonic-gate /* Posts CM MAD using IBMF */ 17140Sstevel@tonic-gate ibt_status_t ibcm_post_mad(ibmf_msg_t *msgp, ibcm_mad_addr_t *cm_mad_addr, 17150Sstevel@tonic-gate ibmf_msg_cb_t post_cb, void *args); 17160Sstevel@tonic-gate 17170Sstevel@tonic-gate /* Post REJ MAD */ 17180Sstevel@tonic-gate void ibcm_post_rej_mad(ibcm_state_data_t *statep, ibt_cm_reason_t reason, 17190Sstevel@tonic-gate int who, void *addl_rej_info, uint8_t arej_info_len); 17200Sstevel@tonic-gate 17210Sstevel@tonic-gate /* Post REP MAD */ 17220Sstevel@tonic-gate void ibcm_post_rep_mad(ibcm_state_data_t *statep); 17230Sstevel@tonic-gate 17240Sstevel@tonic-gate /* Post RTU MAD */ 17250Sstevel@tonic-gate ibcm_status_t ibcm_post_rtu_mad(ibcm_state_data_t *statep); 17260Sstevel@tonic-gate 17270Sstevel@tonic-gate /* Post DREQ MAD */ 17280Sstevel@tonic-gate void ibcm_post_dreq_mad(void *statep); 17290Sstevel@tonic-gate 17300Sstevel@tonic-gate /* Post LAP MAD */ 17310Sstevel@tonic-gate void ibcm_post_lap_mad(ibcm_state_data_t *statep); 17320Sstevel@tonic-gate 17330Sstevel@tonic-gate 17340Sstevel@tonic-gate /* 17350Sstevel@tonic-gate * Posts CM SIDR MAD using IBMF in blocking mode 17360Sstevel@tonic-gate * 17370Sstevel@tonic-gate * INPUTS: 17380Sstevel@tonic-gate * ud_statep: UD statep which is posting the mad 17390Sstevel@tonic-gate * cm_mad_addr: Address information for the MAD to be posted 17400Sstevel@tonic-gate * status: SIDR status 17410Sstevel@tonic-gate */ 17420Sstevel@tonic-gate void ibcm_post_sidr_rep_mad(ibcm_ud_state_data_t *ud_statep, 17430Sstevel@tonic-gate ibt_sidr_status_t status); 17440Sstevel@tonic-gate 17450Sstevel@tonic-gate /* prototypes to resend RC mad and UD MAD */ 17460Sstevel@tonic-gate void ibcm_resend_rep_mad(ibcm_state_data_t *statep); 17470Sstevel@tonic-gate void ibcm_resend_rtu_mad(ibcm_state_data_t *statep); 17480Sstevel@tonic-gate void ibcm_resend_rej_mad(ibcm_state_data_t *statep); 17490Sstevel@tonic-gate void ibcm_resend_mra_mad(ibcm_state_data_t *statep); 17500Sstevel@tonic-gate void ibcm_resend_srep_mad(ibcm_ud_state_data_t *statep); 17510Sstevel@tonic-gate 17520Sstevel@tonic-gate 17530Sstevel@tonic-gate /* Helper function used in connection abort processing */ 17540Sstevel@tonic-gate void ibcm_process_abort(ibcm_state_data_t *statep); 17550Sstevel@tonic-gate 17560Sstevel@tonic-gate /* 17570Sstevel@tonic-gate * Prototypes for CM functions that lookup for a connection state structure 17580Sstevel@tonic-gate */ 17590Sstevel@tonic-gate 17600Sstevel@tonic-gate /* 17610Sstevel@tonic-gate * ibcm_lookup_msg: 17620Sstevel@tonic-gate * 17630Sstevel@tonic-gate * Retrieves an existing state structure or creates a new one if none found. 17640Sstevel@tonic-gate * This function is used during passive side of connection establishment for 17650Sstevel@tonic-gate * INCOMING REQ/REJ/RTU/MRA 17660Sstevel@tonic-gate * This function is used during active side of connection establishment for 17670Sstevel@tonic-gate * INCOMING REP/REJ/MRA 17680Sstevel@tonic-gate * This function is used during active side of connection establishment for 17690Sstevel@tonic-gate * an outgoing REQ. 17700Sstevel@tonic-gate * 17710Sstevel@tonic-gate * NOTE: IBCM_LOOKP_FAIL is only returned if a new entry wasn't created and 17720Sstevel@tonic-gate * a match wasn't found. 17730Sstevel@tonic-gate * 17740Sstevel@tonic-gate * Arguments are:- 17750Sstevel@tonic-gate * ibcm_event_type_t - what type of message 17760Sstevel@tonic-gate * incoming REQ, REP, REJ, MRA, RTU, DREQ, DREP 17770Sstevel@tonic-gate * local_comid - ONLY *NOT* valid for incoming REQ. 17780Sstevel@tonic-gate * needed for others 17790Sstevel@tonic-gate * remote_qpn - Remote CM's QP number 17800Sstevel@tonic-gate * remote_hca_guid - ONLY VALID FOR incoming REQ. 17810Sstevel@tonic-gate * Ignored for others 17820Sstevel@tonic-gate * hcap - HCA entry table pointer 17830Sstevel@tonic-gate * statep - "return"ed state pointer 17840Sstevel@tonic-gate * 17850Sstevel@tonic-gate * Return Values: 17860Sstevel@tonic-gate * IBCM_LOOKUP_NEW - new statep allocated 17870Sstevel@tonic-gate * IBCM_LOOKUP_EXISTS - found an existing entry 17880Sstevel@tonic-gate * IBCM_LOOKUP_FAIL - failed to find an entry 17890Sstevel@tonic-gate * IBCM_MEMORY_FAILURE - failed to get memory 17900Sstevel@tonic-gate * iff flags != IBT_CHAN_BLOCKING 17910Sstevel@tonic-gate */ 17920Sstevel@tonic-gate ibcm_status_t ibcm_lookup_msg(ibcm_event_type_t event_type, 17930Sstevel@tonic-gate ib_com_id_t local_comid, ib_qpn_t remote_qpn, 17940Sstevel@tonic-gate ib_guid_t remote_hca_guid, ibcm_hca_info_t *hcap, 17950Sstevel@tonic-gate ibcm_state_data_t **statep); 17960Sstevel@tonic-gate 17970Sstevel@tonic-gate 17980Sstevel@tonic-gate /* 17990Sstevel@tonic-gate * Routines for CM SIDR state structure list manipulation 18000Sstevel@tonic-gate * Wherever possible, the list routines of ibtl are used 18010Sstevel@tonic-gate * for list manipulation 18020Sstevel@tonic-gate */ 18030Sstevel@tonic-gate 18040Sstevel@tonic-gate /* 18050Sstevel@tonic-gate * Finds an entry based on lid, gid and grh exists fields 18060Sstevel@tonic-gate * lid: LID of incoming SIDR REQ 18070Sstevel@tonic-gate * gid: GID of incoming SIDR REQ 18080Sstevel@tonic-gate * grh_exists: TRUE if GRH exists in the incoming SIDR REQ 18090Sstevel@tonic-gate * hcap: CM State HCA entry ptr to search for SIDR state structure 18100Sstevel@tonic-gate * statep: Returns a valid state structure, if one exists based 18110Sstevel@tonic-gate * on lid, gid and grh_exists fields 18120Sstevel@tonic-gate * flag: whether to just look OR to look and add if it doesn't exist. 18130Sstevel@tonic-gate */ 18140Sstevel@tonic-gate ibcm_status_t ibcm_find_sidr_entry(ibcm_sidr_srch_t *srch_param, 18150Sstevel@tonic-gate ibcm_hca_info_t *hcap, 18160Sstevel@tonic-gate ibcm_ud_state_data_t **statep, 18170Sstevel@tonic-gate ibcm_lookup_flag_t flag); 18180Sstevel@tonic-gate 18190Sstevel@tonic-gate ibcm_ud_state_data_t *ibcm_add_sidr_entry(ibcm_sidr_srch_t *srch_param, 18200Sstevel@tonic-gate ibcm_hca_info_t *hcap); 18210Sstevel@tonic-gate 18220Sstevel@tonic-gate /* 18230Sstevel@tonic-gate * Deletes a given state structure, from both hca state and passive trees 18240Sstevel@tonic-gate * If ref cnt is zero, deallocates all buffers and memory of state data 18250Sstevel@tonic-gate */ 18260Sstevel@tonic-gate void ibcm_delete_state_data(ibcm_state_data_t *statep); 18270Sstevel@tonic-gate 18280Sstevel@tonic-gate /* 18290Sstevel@tonic-gate * Deallocates all the buffers and memory of state data. 18300Sstevel@tonic-gate * This function must be called, only when ref_cnt is zero. 18310Sstevel@tonic-gate */ 18320Sstevel@tonic-gate void ibcm_dealloc_state_data(ibcm_state_data_t *statep); 18330Sstevel@tonic-gate 18340Sstevel@tonic-gate /* 18350Sstevel@tonic-gate * Deletes a given UD state structure, from SIDR list. 18360Sstevel@tonic-gate * The routine acquires and releases the SIDR list lock. 18370Sstevel@tonic-gate */ 18380Sstevel@tonic-gate void ibcm_delete_ud_state_data(ibcm_ud_state_data_t *statep); 18390Sstevel@tonic-gate void ibcm_dealloc_ud_state_data(ibcm_ud_state_data_t *statep); 18400Sstevel@tonic-gate 18410Sstevel@tonic-gate /* 18420Sstevel@tonic-gate * Service ID entry create and lookup functions 18430Sstevel@tonic-gate */ 18440Sstevel@tonic-gate 18450Sstevel@tonic-gate /* 18460Sstevel@tonic-gate * Adds/looks-up an ibcm_svc_info_t entry in the CM's global table. 18470Sstevel@tonic-gate * This global table is defined in ibcm_impl.c. 18480Sstevel@tonic-gate * 18490Sstevel@tonic-gate * svc_info_list_lock must be held for RW_READER by caller of 18500Sstevel@tonic-gate * ibcm_find_svc_entry(). 18510Sstevel@tonic-gate * 18520Sstevel@tonic-gate * Arguments are:- 18530Sstevel@tonic-gate * sid - service id 18540Sstevel@tonic-gate * num_sids - Number (Range) of service-ids 18550Sstevel@tonic-gate * 18560Sstevel@tonic-gate * Return values: 18570Sstevel@tonic-gate * Pointer to ibcm_svc_info_t on success, otherwise NULL. 18580Sstevel@tonic-gate */ 18590Sstevel@tonic-gate int ibcm_svc_compare(const void *p1, const void *p2); 18600Sstevel@tonic-gate ibcm_svc_info_t *ibcm_create_svc_entry(ib_svc_id_t sid, int num_sids); 18610Sstevel@tonic-gate ibcm_svc_info_t *ibcm_find_svc_entry(ib_svc_id_t sid); 18620Sstevel@tonic-gate 18630Sstevel@tonic-gate /* 18640Sstevel@tonic-gate * The following are the function prototypes for various id initialization, 18650Sstevel@tonic-gate * allocation, free and destroy operations. The cm id allocations are based 18660Sstevel@tonic-gate * on vmem operations 18670Sstevel@tonic-gate * The service id's are maintained globally per host 18680Sstevel@tonic-gate * The com id and req id's are maintained per hca 18690Sstevel@tonic-gate * To maintain compatibility with intel, service ids are allocated on a 32 bit 18700Sstevel@tonic-gate * range, though spec has 64 bit range for service id's 18710Sstevel@tonic-gate */ 18720Sstevel@tonic-gate ibcm_status_t ibcm_init_ids(); 18730Sstevel@tonic-gate void ibcm_fini_ids(); 18740Sstevel@tonic-gate 18750Sstevel@tonic-gate ibcm_status_t ibcm_init_hca_ids(ibcm_hca_info_t *hcap); 18760Sstevel@tonic-gate void ibcm_fini_hca_ids(ibcm_hca_info_t *hcap); 18770Sstevel@tonic-gate 18780Sstevel@tonic-gate ibcm_status_t ibcm_alloc_comid(ibcm_hca_info_t *hcap, ib_com_id_t *comid); 18790Sstevel@tonic-gate void ibcm_free_comid(ibcm_hca_info_t *hcap, ib_com_id_t comid); 18800Sstevel@tonic-gate 18810Sstevel@tonic-gate ibcm_status_t ibcm_alloc_reqid(ibcm_hca_info_t *hcap, uint32_t *reqid); 18820Sstevel@tonic-gate void ibcm_free_reqid(ibcm_hca_info_t *hcap, uint32_t reqid); 18830Sstevel@tonic-gate 18840Sstevel@tonic-gate ib_svc_id_t ibcm_alloc_local_sids(int num_sids); 18850Sstevel@tonic-gate void ibcm_free_local_sids(ib_svc_id_t service_id, int num_sids); 18860Sstevel@tonic-gate 18874703Shiremath ib_svc_id_t ibcm_alloc_ip_sid(); 18884703Shiremath void ibcm_free_ip_sid(ib_svc_id_t sid); 18894703Shiremath 18900Sstevel@tonic-gate uint64_t ibcm_generate_tranid(uint8_t event, uint32_t id, 18910Sstevel@tonic-gate uint32_t cm_tran_priv); 18920Sstevel@tonic-gate 18930Sstevel@tonic-gate void ibcm_decode_tranid(uint64_t tran_id, uint32_t *cm_tran_priv); 18940Sstevel@tonic-gate 18950Sstevel@tonic-gate ibcm_status_t ibcm_ar_init(void); 18960Sstevel@tonic-gate ibcm_status_t ibcm_ar_fini(void); 18970Sstevel@tonic-gate 18987919SBill.Taylor@Sun.COM /* IP Addressing API debugging */ 18997919SBill.Taylor@Sun.COM extern int ibcm_printip; /* set to 1 to enable IBTF DPRINTFs */ 19007919SBill.Taylor@Sun.COM extern void ibcm_ip_print(char *label, ibt_ip_addr_t *ipa); 19017919SBill.Taylor@Sun.COM 19027919SBill.Taylor@Sun.COM #define IBCM_PRINT_IP(LABEL, IP_ADDR) \ 19037919SBill.Taylor@Sun.COM if (ibcm_printip) { \ 19047919SBill.Taylor@Sun.COM ibcm_ip_print(LABEL, IP_ADDR); \ 19057919SBill.Taylor@Sun.COM } 19060Sstevel@tonic-gate /* 19070Sstevel@tonic-gate * These functions are called to do timeout processing from CM connection 19080Sstevel@tonic-gate * state transitions. (Also for SIDR REQ and SIDR REP processing) 19090Sstevel@tonic-gate * 19100Sstevel@tonic-gate * Brief description : 19110Sstevel@tonic-gate * If retry count is below max retry value, then post the stored response 19120Sstevel@tonic-gate * MAD using IBMF in blocking mode, adjusts remaining retry counters. 19130Sstevel@tonic-gate * If retry counter reaches max value, then retry failure handling is 19140Sstevel@tonic-gate * done here 19150Sstevel@tonic-gate * 19160Sstevel@tonic-gate * CM will ensure that the state data structure of the associated 19170Sstevel@tonic-gate * timeout is valid when this timeout function is called. 19180Sstevel@tonic-gate * (See timer_stored_state in ibcm_state_data_t and 19190Sstevel@tonic-gate * ud_timer_stored_state in ibcm_ud_state_data_t) 19200Sstevel@tonic-gate */ 19210Sstevel@tonic-gate void ibcm_timeout_cb(void *arg); 19220Sstevel@tonic-gate void ibcm_sidr_timeout_cb(void *arg); 19230Sstevel@tonic-gate 19240Sstevel@tonic-gate /* 19250Sstevel@tonic-gate * function prototypes for IBMF send completion callbacks on non-blocking 19260Sstevel@tonic-gate * MAD posts 19270Sstevel@tonic-gate */ 19280Sstevel@tonic-gate void ibcm_post_req_complete(ibmf_handle_t ibmf_handle, ibmf_msg_t *msgp, 19290Sstevel@tonic-gate void *args); 19300Sstevel@tonic-gate void ibcm_post_rep_wait_complete(ibmf_handle_t ibmf_handle, ibmf_msg_t *msgp, 19310Sstevel@tonic-gate void *args); /* MRA Rcvd on active side */ 19320Sstevel@tonic-gate void ibcm_post_rep_complete(ibmf_handle_t ibmf_handle, ibmf_msg_t *msgp, 19330Sstevel@tonic-gate void *args); 19340Sstevel@tonic-gate void ibcm_resend_post_rep_complete(ibmf_handle_t ibmf_handle, 19350Sstevel@tonic-gate ibmf_msg_t *msgp, void *args); 19360Sstevel@tonic-gate void ibcm_post_mra_rep_complete(ibmf_handle_t ibmf_handle, ibmf_msg_t *msgp, 19370Sstevel@tonic-gate void *args); /* MRA Rcvd on passive side */ 19380Sstevel@tonic-gate void ibcm_post_rej_complete(ibmf_handle_t ibmf_handle, ibmf_msg_t *msgp, 19390Sstevel@tonic-gate void *args); 19400Sstevel@tonic-gate void ibcm_post_dreq_complete(ibmf_handle_t ibmf_handle, ibmf_msg_t *msgp, 19410Sstevel@tonic-gate void *args); 19420Sstevel@tonic-gate void ibcm_post_drep_complete(ibmf_handle_t ibmf_handle, ibmf_msg_t *msgp, 19430Sstevel@tonic-gate void *args); 19440Sstevel@tonic-gate void ibcm_post_lap_complete(ibmf_handle_t ibmf_handle, ibmf_msg_t *msgp, 19450Sstevel@tonic-gate void *args); 19460Sstevel@tonic-gate void ibcm_post_apr_complete(ibmf_handle_t ibmf_handle, ibmf_msg_t *msgp, 19470Sstevel@tonic-gate void *args); 19480Sstevel@tonic-gate void ibcm_post_stored_apr_complete(ibmf_handle_t ibmf_handle, 19490Sstevel@tonic-gate ibmf_msg_t *msgp, void *args); 19500Sstevel@tonic-gate void ibcm_post_mra_lap_complete(ibmf_handle_t ibmf_handle, ibmf_msg_t *msgp, 19510Sstevel@tonic-gate void *args); /* MRA Rcvd for LAP on active side */ 19520Sstevel@tonic-gate void ibcm_post_mra_complete(ibmf_handle_t ibmf_handle, ibmf_msg_t *msgp, 19530Sstevel@tonic-gate void *args); /* for MRA sender */ 19540Sstevel@tonic-gate void ibcm_post_rtu_complete(ibmf_handle_t ibmf_handle, ibmf_msg_t *msgp, 19550Sstevel@tonic-gate void *args); 19560Sstevel@tonic-gate 19570Sstevel@tonic-gate void ibcm_post_sidr_req_complete(ibmf_handle_t ibmf_handle, 19580Sstevel@tonic-gate ibmf_msg_t *msgp, void *args); 19590Sstevel@tonic-gate 19600Sstevel@tonic-gate /* 19610Sstevel@tonic-gate * ibcm_find_hca_entry: 19620Sstevel@tonic-gate * Given a HCA's GUID find out ibcm_hca_info_t entry for that HCA 19630Sstevel@tonic-gate * This entry can be then used to access AVL tree/SIDR list etc. 19640Sstevel@tonic-gate * 19650Sstevel@tonic-gate * NOTE: This entry is not removed from the "ibcm_hca_listp". 19660Sstevel@tonic-gate * And this function is called with ibcm_hca_list_mutex mutex held. 19670Sstevel@tonic-gate * 19680Sstevel@tonic-gate * INPUTS: 19690Sstevel@tonic-gate * hca_guid - HCA's guid 19700Sstevel@tonic-gate * 19710Sstevel@tonic-gate * RETURN VALUE: 19720Sstevel@tonic-gate * hcap - if a match is found, else NULL 19730Sstevel@tonic-gate */ 19740Sstevel@tonic-gate ibcm_hca_info_t *ibcm_find_hca_entry(ib_guid_t hca_guid); 19750Sstevel@tonic-gate ibcm_hca_info_t *ibcm_find_hcap_entry(ib_guid_t hca_guid); 19760Sstevel@tonic-gate void ibcm_delete_hca_entry(ibcm_hca_info_t *hcap); 19770Sstevel@tonic-gate 19780Sstevel@tonic-gate /* Routines that manage the hca's temporary access count */ 19790Sstevel@tonic-gate ibcm_status_t ibcm_inc_hca_acc_cnt(ibcm_hca_info_t *hca); 19800Sstevel@tonic-gate void ibcm_dec_hca_acc_cnt(ibcm_hca_info_t *hca); 19810Sstevel@tonic-gate 19820Sstevel@tonic-gate /* Routines that manage the hca's resource count */ 19830Sstevel@tonic-gate void ibcm_inc_hca_res_cnt(ibcm_hca_info_t *hca); 19840Sstevel@tonic-gate void ibcm_dec_hca_res_cnt(ibcm_hca_info_t *hca); 19850Sstevel@tonic-gate 19860Sstevel@tonic-gate /* Routines that manage the hca's service count */ 19870Sstevel@tonic-gate void ibcm_inc_hca_svc_cnt(ibcm_hca_info_t *hca); 19880Sstevel@tonic-gate void ibcm_dec_hca_svc_cnt(ibcm_hca_info_t *hca); 19890Sstevel@tonic-gate 19900Sstevel@tonic-gate /* Routine to fetch the saa_handle */ 19910Sstevel@tonic-gate ibmf_saa_handle_t ibcm_get_saa_handle(ibcm_hca_info_t *hcap, uint8_t port); 19920Sstevel@tonic-gate 19930Sstevel@tonic-gate /* Allow some flow control of RC connection initiations */ 19941093Shiremath void ibcm_flow_inc(void); 19951093Shiremath void ibcm_flow_dec(hrtime_t delta, char *mad_type); 19960Sstevel@tonic-gate 19970Sstevel@tonic-gate /* Allow some flow control of SA requests */ 19980Sstevel@tonic-gate void ibcm_sa_access_enter(void); 19990Sstevel@tonic-gate void ibcm_sa_access_exit(void); 20000Sstevel@tonic-gate 20010Sstevel@tonic-gate /* 20020Sstevel@tonic-gate * ibcm_cep_to_error_state: 20030Sstevel@tonic-gate * Helper function to transition a CEP to ERROR state 20040Sstevel@tonic-gate * 20050Sstevel@tonic-gate * NOTE: This function checks if ch_qp is valid or ch_eec and calls 20060Sstevel@tonic-gate * into IBTL to transition the CEP. 20070Sstevel@tonic-gate * 20080Sstevel@tonic-gate * INPUTS: 20090Sstevel@tonic-gate * statep - Connection state pointer 20100Sstevel@tonic-gate * 20110Sstevel@tonic-gate * RETURN VALUE: 20120Sstevel@tonic-gate * IBT_SUCCESS - if CEP transition succeeded; else error 20130Sstevel@tonic-gate */ 20140Sstevel@tonic-gate ibt_status_t ibcm_cep_to_error_state(ibcm_state_data_t *statep); 20150Sstevel@tonic-gate 20160Sstevel@tonic-gate /* 20170Sstevel@tonic-gate * Processes the pending stateps in a linked list. The operations are to 20180Sstevel@tonic-gate * invoke a cm handler or delete statep 20190Sstevel@tonic-gate * When the above operations are required on statep from a timeout handler, 20200Sstevel@tonic-gate * they are linked for later processing by an independent thread 20210Sstevel@tonic-gate */ 20220Sstevel@tonic-gate void ibcm_process_tlist(); 20230Sstevel@tonic-gate /* Links RC stateps to an RC timeout processing list */ 20240Sstevel@tonic-gate void ibcm_add_tlist(ibcm_state_data_t *statep); 20250Sstevel@tonic-gate 20260Sstevel@tonic-gate /* Links SIDR/UD stateps to an SIDR/UD timeout processing list */ 20270Sstevel@tonic-gate void ibcm_add_ud_tlist(ibcm_ud_state_data_t *ud_statep); 20280Sstevel@tonic-gate 20290Sstevel@tonic-gate /* 20300Sstevel@tonic-gate * This call either aborts a pending or completes a in-progress LAP/APR 20310Sstevel@tonic-gate * operation 20320Sstevel@tonic-gate */ 20330Sstevel@tonic-gate void ibcm_sync_lapr_idle(ibcm_state_data_t *statep); 20340Sstevel@tonic-gate 20350Sstevel@tonic-gate void ibcm_process_rc_recycle(void *recycle_arg); 20360Sstevel@tonic-gate 20370Sstevel@tonic-gate /* 20380Sstevel@tonic-gate * Helper function to handle endianess in case of Service Data. 20390Sstevel@tonic-gate * Used by ibt_bind_service() and ibt_get_paths(). 20400Sstevel@tonic-gate */ 20410Sstevel@tonic-gate void ibcm_swizzle_from_srv(ibt_srv_data_t *sb_data, uint8_t *service_bytes); 20420Sstevel@tonic-gate void ibcm_swizzle_to_srv(uint8_t *service_bytes, ibt_srv_data_t *sb_data); 20430Sstevel@tonic-gate 20440Sstevel@tonic-gate /* Misc ibcm global variables */ 20450Sstevel@tonic-gate extern char cmlog[]; 20460Sstevel@tonic-gate extern ibt_clnt_hdl_t ibcm_ibt_handle; 20470Sstevel@tonic-gate extern taskq_t *ibcm_taskq; 20480Sstevel@tonic-gate extern ibcm_state_handler_t ibcm_sm_funcs_tbl[]; 20490Sstevel@tonic-gate extern uint8_t ibcm_timeout_list_flags; 20500Sstevel@tonic-gate extern ibcm_classportinfo_msg_t ibcm_clpinfo; 20510Sstevel@tonic-gate 20520Sstevel@tonic-gate /* Global lists */ 20530Sstevel@tonic-gate extern avl_tree_t ibcm_svc_avl_tree; /* global service id tree */ 20540Sstevel@tonic-gate extern ibcm_state_data_t *ibcm_timeout_list_hdr, *ibcm_timeout_list_tail; 20550Sstevel@tonic-gate extern ibcm_ud_state_data_t *ibcm_ud_timeout_list_hdr, 20560Sstevel@tonic-gate *ibcm_ud_timeout_list_tail; 20570Sstevel@tonic-gate /* Default global retry counts */ 20589913SShantkumar.Hiremath@Sun.COM extern uint8_t ibcm_max_retries; 20590Sstevel@tonic-gate extern uint32_t ibcm_max_sa_retries; 20600Sstevel@tonic-gate extern int ibcm_sa_timeout_delay; /* in ticks */ 20610Sstevel@tonic-gate 20620Sstevel@tonic-gate /* Various default global timers */ 20630Sstevel@tonic-gate extern ibt_rnr_nak_time_t ibcm_default_rnr_nak_time; 20640Sstevel@tonic-gate 20650Sstevel@tonic-gate extern clock_t ibcm_local_processing_time; /* usecs */ 20660Sstevel@tonic-gate extern clock_t ibcm_remote_response_time; 20670Sstevel@tonic-gate extern ib_time_t ibcm_max_sidr_rep_proctime; 20680Sstevel@tonic-gate extern ib_time_t ibcm_max_sidr_rep_store_time; 20690Sstevel@tonic-gate extern uint32_t ibcm_adj_btime; 20700Sstevel@tonic-gate extern uint32_t ibcm_sw_delay; 20710Sstevel@tonic-gate 20720Sstevel@tonic-gate extern ib_time_t ibcm_max_ib_pkt_lt; 20730Sstevel@tonic-gate extern ib_time_t ibcm_max_ib_mad_pkt_lt; 20740Sstevel@tonic-gate 20750Sstevel@tonic-gate /* Global locks */ 20760Sstevel@tonic-gate extern kmutex_t ibcm_svc_info_lock; 20779913SShantkumar.Hiremath@Sun.COM extern kmutex_t ibcm_mcglist_lock; 20780Sstevel@tonic-gate extern kmutex_t ibcm_global_hca_lock; 20790Sstevel@tonic-gate extern kmutex_t ibcm_qp_list_lock; 20800Sstevel@tonic-gate extern kmutex_t ibcm_timeout_list_lock; 20810Sstevel@tonic-gate extern kmutex_t ibcm_recv_mutex; 20820Sstevel@tonic-gate 20830Sstevel@tonic-gate /* Global cond variables */ 20840Sstevel@tonic-gate extern kcondvar_t ibcm_global_hca_cv; 20850Sstevel@tonic-gate extern kcondvar_t ibcm_svc_info_cv; 20860Sstevel@tonic-gate extern kcondvar_t ibcm_timeout_list_cv; 20870Sstevel@tonic-gate extern kcondvar_t ibcm_timeout_thread_done_cv; 20880Sstevel@tonic-gate 20890Sstevel@tonic-gate _NOTE(LOCK_ORDER(ibcm_state_data_s::state_mutex ibcm_timeout_list_lock)) 20900Sstevel@tonic-gate _NOTE(LOCK_ORDER(ibcm_ud_state_data_s::ud_state_mutex ibcm_timeout_list_lock)) 20910Sstevel@tonic-gate _NOTE(LOCK_ORDER(ibcm_hca_info_s::hca_state_rwlock 20920Sstevel@tonic-gate ibcm_state_data_s::state_mutex)) 20930Sstevel@tonic-gate _NOTE(LOCK_ORDER(ibcm_hca_info_s::hca_sidr_list_lock 20940Sstevel@tonic-gate ibcm_ud_state_data_s::ud_state_mutex)) 20950Sstevel@tonic-gate 20960Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ibcm_local_processing_time ibcm_remote_response_time 20970Sstevel@tonic-gate ibcm_max_sidr_rep_proctime ibcm_max_sidr_rep_store_time ibcm_adj_btime 20980Sstevel@tonic-gate ibcm_sw_delay ibcm_max_retries ibcm_max_sa_retries)) 20990Sstevel@tonic-gate 21000Sstevel@tonic-gate /* 21010Sstevel@tonic-gate * miscellaneous defines for retries, times etc. 21020Sstevel@tonic-gate */ 21031093Shiremath #define IBCM_MAX_RETRIES 11 /* Max CM retries for a msg */ 21041093Shiremath #define IBCM_LOCAL_RESPONSE_TIME 300000 /* Local CM processing time */ 21050Sstevel@tonic-gate /* in usecs */ 21061093Shiremath #define IBCM_REMOTE_RESPONSE_TIME 300000 /* Remote CM response time */ 21070Sstevel@tonic-gate /* in usecs */ 21080Sstevel@tonic-gate #define IBCM_MAX_SIDR_PROCESS_TIME 16 /* Time to process SIDR REP */ 21090Sstevel@tonic-gate #define IBCM_MAX_SIDR_PKT_LIFE_TIME 9 /* Approx pkt lt for UD srver */ 21100Sstevel@tonic-gate 21115752Shiremath #define IBCM_MAX_IB_PKT_LT 20 /* 4 second */ 21120Sstevel@tonic-gate #define IBCM_MAX_IB_MAD_PKT_LT 18 /* 1 second */ 21130Sstevel@tonic-gate 21140Sstevel@tonic-gate #define IBCM_MAX_SA_RETRIES 0 /* Max CM retry for SA update */ 21150Sstevel@tonic-gate 21160Sstevel@tonic-gate /* versions for CM MADs */ 21170Sstevel@tonic-gate #define IBCM_MAD_BASE_VERSION 1 21180Sstevel@tonic-gate #define IBCM_MAD_CLASS_VERSION 2 21190Sstevel@tonic-gate 21200Sstevel@tonic-gate /* for Class_Port_Info stuff - see section 16.7.3.1 in Vol1 IB Spec */ 21210Sstevel@tonic-gate #define IBCM_CPINFO_CAP_RC 0x0200 /* RC is supported */ 21220Sstevel@tonic-gate #define IBCM_CPINFO_CAP_RD 0x0400 /* RD is supported */ 21230Sstevel@tonic-gate #define IBCM_CPINFO_CAP_RAW 0x0800 /* Raw Datagrams supported */ 21240Sstevel@tonic-gate #define IBCM_CPINFO_CAP_UC 0x1000 /* UC supported */ 21250Sstevel@tonic-gate #define IBCM_CPINFO_CAP_SIDR 0x2000 /* SIDR supported */ 21260Sstevel@tonic-gate 21274703Shiremath #define IBCM_V4_PART_OF_V6(v6) v6.s6_addr32[3] 21284703Shiremath /* RDMA CM IP Service's Private Data Format. */ 21294703Shiremath #ifdef _BIG_ENDIAN 21304703Shiremath typedef struct ibcm_ip_pvtdata_s { 21314703Shiremath uint8_t ip_MajV:4, 21324703Shiremath ip_MinV:4; 21334703Shiremath uint8_t ip_ipv:4, 21344703Shiremath ip_rsvd:4; /* 0-3: rsvd, 4-7: ipv */ 21354703Shiremath uint16_t ip_srcport; /* Source Port */ 21364703Shiremath in6_addr_t ip_srcip; /* Source IP address. */ 21374703Shiremath in6_addr_t ip_dstip; /* Remote IP address. */ 21384703Shiremath #define ip_srcv4 IBCM_V4_PART_OF_V6(ip_srcip) 21394703Shiremath #define ip_dstv4 IBCM_V4_PART_OF_V6(ip_dstip) 21404703Shiremath #define ip_srcv6 ip_srcip 21414703Shiremath #define ip_dstv6 ip_dstip 21424703Shiremath } ibcm_ip_pvtdata_t; 21434703Shiremath #else 21444703Shiremath typedef struct ibcm_ip_pvtdata_s { 21454703Shiremath uint8_t ip_MinV:4, 21464703Shiremath ip_MajV:4; 21474703Shiremath uint8_t ip_rsvd:4, 21484703Shiremath ip_ipv:4; /* 0-3: rsvd, 4-7: ipv */ 21494703Shiremath uint16_t ip_srcport; /* Source Port */ 21504703Shiremath in6_addr_t ip_srcip; /* Source IP address. */ 21514703Shiremath in6_addr_t ip_dstip; /* Remote IP address. */ 21524703Shiremath #define ip_srcv4 IBCM_V4_PART_OF_V6(ip_srcip) 21534703Shiremath #define ip_dstv4 IBCM_V4_PART_OF_V6(ip_dstip) 21544703Shiremath #define ip_srcv6 ip_srcip 21554703Shiremath #define ip_dstv6 ip_dstip 21564703Shiremath } ibcm_ip_pvtdata_t; 21574703Shiremath #endif 21584703Shiremath 21590Sstevel@tonic-gate /* 21600Sstevel@tonic-gate * for debug purposes 21610Sstevel@tonic-gate */ 21620Sstevel@tonic-gate #ifdef DEBUG 21630Sstevel@tonic-gate extern int ibcm_test_mode; 21640Sstevel@tonic-gate 21650Sstevel@tonic-gate void ibcm_query_qp(ibmf_handle_t ibmf_hdl, ibmf_qp_handle_t ibmf_qp); 21660Sstevel@tonic-gate void ibcm_dump_raw_message(uchar_t *); 21670Sstevel@tonic-gate void ibcm_dump_srvrec(sa_service_record_t *); 21680Sstevel@tonic-gate void ibcm_dump_pathrec(sa_path_record_t *); 21690Sstevel@tonic-gate void ibcm_dump_noderec(sa_node_record_t *); 21700Sstevel@tonic-gate 21710Sstevel@tonic-gate void ibcm_query_classport_info(ibt_channel_hdl_t channel); 21720Sstevel@tonic-gate 21730Sstevel@tonic-gate #define IBCM_DUMP_RAW_MSG ibcm_dump_raw_message 21740Sstevel@tonic-gate #define IBCM_DUMP_SERVICE_REC ibcm_dump_srvrec 21750Sstevel@tonic-gate #define IBCM_DUMP_PATH_REC ibcm_dump_pathrec 21760Sstevel@tonic-gate #define IBCM_DUMP_NODE_REC ibcm_dump_noderec 21770Sstevel@tonic-gate #else 21780Sstevel@tonic-gate #define IBCM_DUMP_RAW_MSG 0 && 21790Sstevel@tonic-gate #define IBCM_DUMP_SERVICE_REC 0 && 21800Sstevel@tonic-gate #define IBCM_DUMP_PATH_REC 0 && 21810Sstevel@tonic-gate #define IBCM_DUMP_NODE_REC 0 && 21820Sstevel@tonic-gate #endif 21830Sstevel@tonic-gate 21840Sstevel@tonic-gate ibt_status_t ibcm_ibmf_analyze_error(int ibmf_status); 21850Sstevel@tonic-gate 21860Sstevel@tonic-gate ibt_status_t ibcm_contact_sa_access(ibmf_saa_handle_t saa_handle, 21870Sstevel@tonic-gate ibmf_saa_access_args_t *access_args, size_t *length, void **results_p); 21880Sstevel@tonic-gate 21899891SRajkumar.Sivaprakasam@Sun.COM ibt_status_t ibcm_ibtl_node_info(ib_guid_t, uint8_t, ib_lid_t, 21909891SRajkumar.Sivaprakasam@Sun.COM ibt_node_info_t *node_info); 21919891SRajkumar.Sivaprakasam@Sun.COM 2192557Shiremath void ibcm_path_cache_init(void); 2193557Shiremath void ibcm_path_cache_fini(void); 2194557Shiremath void ibcm_path_cache_purge(void); 2195557Shiremath 21960Sstevel@tonic-gate #ifdef __cplusplus 21970Sstevel@tonic-gate } 21980Sstevel@tonic-gate #endif 21990Sstevel@tonic-gate 22000Sstevel@tonic-gate 22010Sstevel@tonic-gate #endif /* _SYS_IB_MGT_IBCM_IBCM_IMPL_H */ 2202