1*9684SSusan.Gleeson@Sun.COM /* 2*9684SSusan.Gleeson@Sun.COM * CDDL HEADER START 3*9684SSusan.Gleeson@Sun.COM * 4*9684SSusan.Gleeson@Sun.COM * The contents of this file are subject to the terms of the 5*9684SSusan.Gleeson@Sun.COM * Common Development and Distribution License (the "License"). 6*9684SSusan.Gleeson@Sun.COM * You may not use this file except in compliance with the License. 7*9684SSusan.Gleeson@Sun.COM * 8*9684SSusan.Gleeson@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*9684SSusan.Gleeson@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*9684SSusan.Gleeson@Sun.COM * See the License for the specific language governing permissions 11*9684SSusan.Gleeson@Sun.COM * and limitations under the License. 12*9684SSusan.Gleeson@Sun.COM * 13*9684SSusan.Gleeson@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*9684SSusan.Gleeson@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*9684SSusan.Gleeson@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*9684SSusan.Gleeson@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*9684SSusan.Gleeson@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*9684SSusan.Gleeson@Sun.COM * 19*9684SSusan.Gleeson@Sun.COM * CDDL HEADER END 20*9684SSusan.Gleeson@Sun.COM */ 21*9684SSusan.Gleeson@Sun.COM 22*9684SSusan.Gleeson@Sun.COM /* 23*9684SSusan.Gleeson@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24*9684SSusan.Gleeson@Sun.COM * Use is subject to license terms. 25*9684SSusan.Gleeson@Sun.COM */ 26*9684SSusan.Gleeson@Sun.COM #ifndef _IBDMA_IMPL_H 27*9684SSusan.Gleeson@Sun.COM #define _IBDMA_IMPL_H 28*9684SSusan.Gleeson@Sun.COM 29*9684SSusan.Gleeson@Sun.COM /* 30*9684SSusan.Gleeson@Sun.COM * ibdma_impl.h 31*9684SSusan.Gleeson@Sun.COM * 32*9684SSusan.Gleeson@Sun.COM * Device Management Agent private prototypes and structures. 33*9684SSusan.Gleeson@Sun.COM */ 34*9684SSusan.Gleeson@Sun.COM 35*9684SSusan.Gleeson@Sun.COM #ifdef __cpluplus 36*9684SSusan.Gleeson@Sun.COM extern "C" { 37*9684SSusan.Gleeson@Sun.COM #endif 38*9684SSusan.Gleeson@Sun.COM 39*9684SSusan.Gleeson@Sun.COM #include <sys/ib/ibtl/ibvti.h> /* IB verrbs interfaces */ 40*9684SSusan.Gleeson@Sun.COM #include <sys/ib/mgt/ib_dm_attr.h> /* IB DM defines/structures */ 41*9684SSusan.Gleeson@Sun.COM #include <sys/ib/mgt/ib_mad.h> /* IB MAD defines/structures */ 42*9684SSusan.Gleeson@Sun.COM 43*9684SSusan.Gleeson@Sun.COM enum { 44*9684SSusan.Gleeson@Sun.COM IBDMA_MAD_SIZE = 256, 45*9684SSusan.Gleeson@Sun.COM IBDMA_DM_MAD_HDR_SIZE = 40, 46*9684SSusan.Gleeson@Sun.COM IBDMA_DM_RESP_TIME = 20, 47*9684SSusan.Gleeson@Sun.COM IBDMA_MAX_IOC = 16 48*9684SSusan.Gleeson@Sun.COM }; 49*9684SSusan.Gleeson@Sun.COM 50*9684SSusan.Gleeson@Sun.COM /* 51*9684SSusan.Gleeson@Sun.COM * Implementation of handle returned to consumer. 52*9684SSusan.Gleeson@Sun.COM */ 53*9684SSusan.Gleeson@Sun.COM typedef struct ibdma_hdl_impl_s { 54*9684SSusan.Gleeson@Sun.COM list_node_t ih_node; 55*9684SSusan.Gleeson@Sun.COM ib_guid_t ih_iou_guid; 56*9684SSusan.Gleeson@Sun.COM uint8_t ih_ioc_ndx; 57*9684SSusan.Gleeson@Sun.COM } ibdma_hdl_impl_t; 58*9684SSusan.Gleeson@Sun.COM 59*9684SSusan.Gleeson@Sun.COM /* 60*9684SSusan.Gleeson@Sun.COM * Each I/O Controller slot for the I/O Unit. 61*9684SSusan.Gleeson@Sun.COM */ 62*9684SSusan.Gleeson@Sun.COM typedef struct ibdma_ioc_s { 63*9684SSusan.Gleeson@Sun.COM uint8_t ii_inuse; 64*9684SSusan.Gleeson@Sun.COM /* 65*9684SSusan.Gleeson@Sun.COM * Just to map handle back to slot number and hca 66*9684SSusan.Gleeson@Sun.COM */ 67*9684SSusan.Gleeson@Sun.COM int ii_slot; 68*9684SSusan.Gleeson@Sun.COM struct ibdma_hca_s *ii_hcap; 69*9684SSusan.Gleeson@Sun.COM 70*9684SSusan.Gleeson@Sun.COM /* 71*9684SSusan.Gleeson@Sun.COM * Profile provided by the I/O Controller, must be stored 72*9684SSusan.Gleeson@Sun.COM * in network order. Note that the profile indicates the 73*9684SSusan.Gleeson@Sun.COM * number of service entries pointed to by ii_srvcs. 74*9684SSusan.Gleeson@Sun.COM */ 75*9684SSusan.Gleeson@Sun.COM ib_dm_ioc_ctrl_profile_t ii_profile; 76*9684SSusan.Gleeson@Sun.COM ib_dm_srv_t *ii_srvcs; 77*9684SSusan.Gleeson@Sun.COM } ibdma_ioc_t; 78*9684SSusan.Gleeson@Sun.COM 79*9684SSusan.Gleeson@Sun.COM /* 80*9684SSusan.Gleeson@Sun.COM * The ibdma_hca_t structure is only used internally by the 81*9684SSusan.Gleeson@Sun.COM * IB DM Agent. It is created when the associated HCA is 82*9684SSusan.Gleeson@Sun.COM * opened as part of initialization or as a result of a 83*9684SSusan.Gleeson@Sun.COM * notification via IBTF. It is destroyed when the HCA 84*9684SSusan.Gleeson@Sun.COM * is closed as part of fini processing or as a result of 85*9684SSusan.Gleeson@Sun.COM * a notification via IBTF. The structure is not directly 86*9684SSusan.Gleeson@Sun.COM * accessed by IBMF call-backs or the consumer API. 87*9684SSusan.Gleeson@Sun.COM */ 88*9684SSusan.Gleeson@Sun.COM typedef struct ibdma_port_s { 89*9684SSusan.Gleeson@Sun.COM ibmf_handle_t ip_ibmf_hdl; 90*9684SSusan.Gleeson@Sun.COM ibmf_register_info_t ip_ibmf_reg; 91*9684SSusan.Gleeson@Sun.COM ibmf_impl_caps_t ip_ibmf_caps; 92*9684SSusan.Gleeson@Sun.COM struct ibdma_hca_s *ip_hcap; 93*9684SSusan.Gleeson@Sun.COM } ibdma_port_t; 94*9684SSusan.Gleeson@Sun.COM 95*9684SSusan.Gleeson@Sun.COM typedef struct ibdma_hca_s { 96*9684SSusan.Gleeson@Sun.COM list_node_t ih_node; 97*9684SSusan.Gleeson@Sun.COM ibt_hca_hdl_t ih_ibt_hdl; 98*9684SSusan.Gleeson@Sun.COM 99*9684SSusan.Gleeson@Sun.COM /* 100*9684SSusan.Gleeson@Sun.COM * Consumer handles associated with I/O Controllers 101*9684SSusan.Gleeson@Sun.COM * that have registered with this I/O Unit. 102*9684SSusan.Gleeson@Sun.COM */ 103*9684SSusan.Gleeson@Sun.COM list_t ih_hdl_list; 104*9684SSusan.Gleeson@Sun.COM 105*9684SSusan.Gleeson@Sun.COM /* 106*9684SSusan.Gleeson@Sun.COM * The I/O Unit that is presented to the IB Fabric. 107*9684SSusan.Gleeson@Sun.COM * It is stored in network order. 108*9684SSusan.Gleeson@Sun.COM */ 109*9684SSusan.Gleeson@Sun.COM krwlock_t ih_iou_rwlock; 110*9684SSusan.Gleeson@Sun.COM ib_guid_t ih_iou_guid; 111*9684SSusan.Gleeson@Sun.COM ib_dm_io_unitinfo_t ih_iou; 112*9684SSusan.Gleeson@Sun.COM ibdma_ioc_t ih_ioc[IBDMA_MAX_IOC]; 113*9684SSusan.Gleeson@Sun.COM uint8_t ih_nports; 114*9684SSusan.Gleeson@Sun.COM ibdma_port_t ih_port[1]; 115*9684SSusan.Gleeson@Sun.COM } ibdma_hca_t; 116*9684SSusan.Gleeson@Sun.COM 117*9684SSusan.Gleeson@Sun.COM 118*9684SSusan.Gleeson@Sun.COM /* 119*9684SSusan.Gleeson@Sun.COM * The IBDMA module state information created and initialized 120*9684SSusan.Gleeson@Sun.COM * at _init() and freed at _fini(). 121*9684SSusan.Gleeson@Sun.COM */ 122*9684SSusan.Gleeson@Sun.COM typedef struct ibdma_mod_state_s { 123*9684SSusan.Gleeson@Sun.COM ibt_clnt_hdl_t ms_ibt_hdl; 124*9684SSusan.Gleeson@Sun.COM 125*9684SSusan.Gleeson@Sun.COM /* 126*9684SSusan.Gleeson@Sun.COM * The HCA list lock is used protect the HCA list and 127*9684SSusan.Gleeson@Sun.COM * is held during consumer routines (in place of a 128*9684SSusan.Gleeson@Sun.COM * reference count) to ensure the HCA exists for the 129*9684SSusan.Gleeson@Sun.COM * duration of it's use in the routine. 130*9684SSusan.Gleeson@Sun.COM */ 131*9684SSusan.Gleeson@Sun.COM kmutex_t ms_hca_list_lock; 132*9684SSusan.Gleeson@Sun.COM list_t ms_hca_list; 133*9684SSusan.Gleeson@Sun.COM uint_t ms_num_hcas; 134*9684SSusan.Gleeson@Sun.COM 135*9684SSusan.Gleeson@Sun.COM } ibdma_mod_state_t; 136*9684SSusan.Gleeson@Sun.COM 137*9684SSusan.Gleeson@Sun.COM 138*9684SSusan.Gleeson@Sun.COM /* 139*9684SSusan.Gleeson@Sun.COM * Client API internal helpers 140*9684SSusan.Gleeson@Sun.COM */ 141*9684SSusan.Gleeson@Sun.COM typedef enum ibdma_ioc_state_e { 142*9684SSusan.Gleeson@Sun.COM IBDMA_IOC_NOT_INSTALLED = 0, 143*9684SSusan.Gleeson@Sun.COM IBDMA_IOC_PRESENT = 1, 144*9684SSusan.Gleeson@Sun.COM IBDMA_IOC_DOES_NOT_EXIST = 255, 145*9684SSusan.Gleeson@Sun.COM IBDMA_HDL_MAGIC = 0x00931000 146*9684SSusan.Gleeson@Sun.COM } ibdma_ioc_state_t; 147*9684SSusan.Gleeson@Sun.COM 148*9684SSusan.Gleeson@Sun.COM static void 149*9684SSusan.Gleeson@Sun.COM ibdma_set_ioc_state(ibdma_hca_t *hca, int slot, ibdma_ioc_state_t state); 150*9684SSusan.Gleeson@Sun.COM static ibdma_ioc_state_t ibdma_get_ioc_state(ibdma_hca_t *hca, int slot); 151*9684SSusan.Gleeson@Sun.COM 152*9684SSusan.Gleeson@Sun.COM #endif /* _IBDMA_IMPL_H */ 153