1*9e39c5baSBill Taylor /* 2*9e39c5baSBill Taylor * CDDL HEADER START 3*9e39c5baSBill Taylor * 4*9e39c5baSBill Taylor * The contents of this file are subject to the terms of the 5*9e39c5baSBill Taylor * Common Development and Distribution License (the "License"). 6*9e39c5baSBill Taylor * You may not use this file except in compliance with the License. 7*9e39c5baSBill Taylor * 8*9e39c5baSBill Taylor * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*9e39c5baSBill Taylor * or http://www.opensolaris.org/os/licensing. 10*9e39c5baSBill Taylor * See the License for the specific language governing permissions 11*9e39c5baSBill Taylor * and limitations under the License. 12*9e39c5baSBill Taylor * 13*9e39c5baSBill Taylor * When distributing Covered Code, include this CDDL HEADER in each 14*9e39c5baSBill Taylor * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*9e39c5baSBill Taylor * If applicable, add the following below this CDDL HEADER, with the 16*9e39c5baSBill Taylor * fields enclosed by brackets "[]" replaced with your own identifying 17*9e39c5baSBill Taylor * information: Portions Copyright [yyyy] [name of copyright owner] 18*9e39c5baSBill Taylor * 19*9e39c5baSBill Taylor * CDDL HEADER END 20*9e39c5baSBill Taylor */ 21*9e39c5baSBill Taylor 22*9e39c5baSBill Taylor /* 23*9e39c5baSBill Taylor * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*9e39c5baSBill Taylor * Use is subject to license terms. 25*9e39c5baSBill Taylor */ 26*9e39c5baSBill Taylor 27*9e39c5baSBill Taylor #ifndef _SYS_IB_ADAPTERS_TAVOR_AGENTS_H 28*9e39c5baSBill Taylor #define _SYS_IB_ADAPTERS_TAVOR_AGENTS_H 29*9e39c5baSBill Taylor 30*9e39c5baSBill Taylor /* 31*9e39c5baSBill Taylor * tavor_agents.h 32*9e39c5baSBill Taylor * Contains all of the prototypes, #defines, and structures necessary 33*9e39c5baSBill Taylor * for all of the Tavor Infiniband Management Agent (SMA, PMA, BMA) 34*9e39c5baSBill Taylor * routines 35*9e39c5baSBill Taylor * Specifically it contains the various flags, structures used for tracking 36*9e39c5baSBill Taylor * the Tavor agents, and prototypes for initialization and teardown 37*9e39c5baSBill Taylor * functions. 38*9e39c5baSBill Taylor */ 39*9e39c5baSBill Taylor 40*9e39c5baSBill Taylor #include <sys/types.h> 41*9e39c5baSBill Taylor #include <sys/conf.h> 42*9e39c5baSBill Taylor #include <sys/ddi.h> 43*9e39c5baSBill Taylor #include <sys/sunddi.h> 44*9e39c5baSBill Taylor 45*9e39c5baSBill Taylor #include <sys/ib/mgt/ibmf/ibmf.h> 46*9e39c5baSBill Taylor 47*9e39c5baSBill Taylor #ifdef __cplusplus 48*9e39c5baSBill Taylor extern "C" { 49*9e39c5baSBill Taylor #endif 50*9e39c5baSBill Taylor 51*9e39c5baSBill Taylor /* 52*9e39c5baSBill Taylor * The following defines specify the default number of (SW-assisted) agents 53*9e39c5baSBill Taylor * per port. It is broken down by QP number. QP0 will have only the one 54*9e39c5baSBill Taylor * agent, the SMA. QP1 should have two agents, the PMA and BMA, but for now 55*9e39c5baSBill Taylor * the Tavor firmware doesn't support a BMA. So we do not register it with 56*9e39c5baSBill Taylor * the IBMF. 57*9e39c5baSBill Taylor */ 58*9e39c5baSBill Taylor #define TAVOR_NUM_QP0_AGENTS_PER_PORT 1 59*9e39c5baSBill Taylor #define TAVOR_NUM_QP1_AGENTS_PER_PORT 1 60*9e39c5baSBill Taylor 61*9e39c5baSBill Taylor /* Number of threads for the agent handling task queue */ 62*9e39c5baSBill Taylor #define TAVOR_TASKQ_NTHREADS 1 63*9e39c5baSBill Taylor 64*9e39c5baSBill Taylor /* Maximum number of tasks on task queue */ 65*9e39c5baSBill Taylor #define TAVOR_TASKQ_MAX_TASKS 4 66*9e39c5baSBill Taylor 67*9e39c5baSBill Taylor /* 68*9e39c5baSBill Taylor * The following defines the name for the task queue. Note: this string 69*9e39c5baSBill Taylor * will later be combined with the Tavor driver instance number to create 70*9e39c5baSBill Taylor * a unique name for the task queue 71*9e39c5baSBill Taylor */ 72*9e39c5baSBill Taylor #define TAVOR_TASKQ_NAME "tavor_taskq" 73*9e39c5baSBill Taylor 74*9e39c5baSBill Taylor /* 75*9e39c5baSBill Taylor * The following macros are used when handling directed route MADs. They tell 76*9e39c5baSBill Taylor * the driver whether a given MAD is a directed route MAD, can extract the 77*9e39c5baSBill Taylor * "hop pointer" and "hop count" fields, and can even set the "direction" bit 78*9e39c5baSBill Taylor * in the MAD and (if necessary) update the "hop pointer". 79*9e39c5baSBill Taylor * More details on how these macros are used can be found in the 80*9e39c5baSBill Taylor * tavor_agents.c source file. 81*9e39c5baSBill Taylor */ 82*9e39c5baSBill Taylor #define TAVOR_MAD_IS_DR(madhdrp) \ 83*9e39c5baSBill Taylor (((sm_dr_mad_hdr_t *)(madhdrp))->MgmtClass == 0x81) 84*9e39c5baSBill Taylor #define TAVOR_DRMAD_GET_HOPCOUNT(madhdrp) \ 85*9e39c5baSBill Taylor (((sm_dr_mad_hdr_t *)(madhdrp))->HopCount) 86*9e39c5baSBill Taylor #define TAVOR_DRMAD_GET_HOPPOINTER(madhdrp) \ 87*9e39c5baSBill Taylor (((sm_dr_mad_hdr_t *)(madhdrp))->HopPointer) 88*9e39c5baSBill Taylor #define TAVOR_DRMAD_SET_HOPPOINTER(madhdrp, hp) \ 89*9e39c5baSBill Taylor (((sm_dr_mad_hdr_t *)(madhdrp))->HopPointer = (hp)) 90*9e39c5baSBill Taylor #ifdef _LITTLE_ENDIAN 91*9e39c5baSBill Taylor #define TAVOR_DRMAD_SET_DIRECTION(madhdrp) \ 92*9e39c5baSBill Taylor (((sm_dr_mad_hdr_t *)(madhdrp))->D_Status |= 0x0080) 93*9e39c5baSBill Taylor #else 94*9e39c5baSBill Taylor #define TAVOR_DRMAD_SET_DIRECTION(madhdrp) \ 95*9e39c5baSBill Taylor (((sm_dr_mad_hdr_t *)(madhdrp))->D_Status |= 0x8000) 96*9e39c5baSBill Taylor #endif 97*9e39c5baSBill Taylor 98*9e39c5baSBill Taylor /* 99*9e39c5baSBill Taylor * The following macro is used to determine whether a received MAD is 100*9e39c5baSBill Taylor * one of the special "Tavor Trap" MADs. If it is, then some special 101*9e39c5baSBill Taylor * processing (described in tavor_agents.c) is necessary. 102*9e39c5baSBill Taylor */ 103*9e39c5baSBill Taylor #define TAVOR_IS_SPECIAL_TRAP_MAD(msgp) \ 104*9e39c5baSBill Taylor ((((msgp)->im_msgbufs_recv.im_bufs_mad_hdr->R_Method & \ 105*9e39c5baSBill Taylor MAD_METHOD_MASK) == MAD_METHOD_TRAP) && \ 106*9e39c5baSBill Taylor ((msgp)->im_local_addr.ia_remote_lid == 0)) 107*9e39c5baSBill Taylor 108*9e39c5baSBill Taylor /* 109*9e39c5baSBill Taylor * The following macro is used to determine whether a received MAD is 110*9e39c5baSBill Taylor * a "TrapRepress" MAD. If it is, then no response MAD should be sent 111*9e39c5baSBill Taylor * (described in tavor_agents.c). 112*9e39c5baSBill Taylor */ 113*9e39c5baSBill Taylor #define TAVOR_IS_TRAP_REPRESS_MAD(msgp) \ 114*9e39c5baSBill Taylor ((((msgp)->im_msgbufs_recv.im_bufs_mad_hdr->R_Method & \ 115*9e39c5baSBill Taylor MAD_METHOD_MASK) == MAD_METHOD_TRAP_REPRESS)) 116*9e39c5baSBill Taylor 117*9e39c5baSBill Taylor /* 118*9e39c5baSBill Taylor * The following define specified the offset for the start of "Return Path" 119*9e39c5baSBill Taylor * in a directed route MAD. Note: this is the offset from the start of the 120*9e39c5baSBill Taylor * MAD data area (in bytes). 121*9e39c5baSBill Taylor */ 122*9e39c5baSBill Taylor #define TAVOR_DRMAD_RETURN_PATH_OFFSET 0x80 123*9e39c5baSBill Taylor 124*9e39c5baSBill Taylor /* 125*9e39c5baSBill Taylor * The tavor_agent_list_s structure is used in the Tavor IB Management Agent 126*9e39c5baSBill Taylor * routines to keep track of the number (and type) of each register agent. 127*9e39c5baSBill Taylor * The primary purpose of tracking this information (port number, management 128*9e39c5baSBill Taylor * class, and IBMF handle) is to be able to later deregister all the agents 129*9e39c5baSBill Taylor * which are registered at attach() time. Note: a pointer to this structure 130*9e39c5baSBill Taylor * is returned to the driver (by the IBMF) every time the agent callback 131*9e39c5baSBill Taylor * routine is called. This is why the structure contains a backpointer to 132*9e39c5baSBill Taylor * the Tavor softstate. 133*9e39c5baSBill Taylor */ 134*9e39c5baSBill Taylor struct tavor_agent_list_s { 135*9e39c5baSBill Taylor tavor_state_t *agl_state; 136*9e39c5baSBill Taylor uint_t agl_port; 137*9e39c5baSBill Taylor ibmf_client_type_t agl_mgmtclass; 138*9e39c5baSBill Taylor ibmf_handle_t agl_ibmfhdl; 139*9e39c5baSBill Taylor }; 140*9e39c5baSBill Taylor 141*9e39c5baSBill Taylor /* 142*9e39c5baSBill Taylor * The tavor_agent_handler_arg_t structure is used in the Tavor IB Management 143*9e39c5baSBill Taylor * Agent routines to pass request information through the task queue. Each 144*9e39c5baSBill Taylor * time a request is received (by the Tavor agent request callback), one 145*9e39c5baSBill Taylor * of these structures is allocated and filled with the relevant information 146*9e39c5baSBill Taylor * for the request. It is then dispatched to the task queue (with a pointer 147*9e39c5baSBill Taylor * to the structure passed as an argument). From there it is later pulled 148*9e39c5baSBill Taylor * apart and the individual fields of the structure used to handle the 149*9e39c5baSBill Taylor * request. 150*9e39c5baSBill Taylor */ 151*9e39c5baSBill Taylor typedef struct tavor_agent_handler_arg_s { 152*9e39c5baSBill Taylor ibmf_handle_t ahd_ibmfhdl; 153*9e39c5baSBill Taylor ibmf_msg_t *ahd_ibmfmsg; 154*9e39c5baSBill Taylor tavor_agent_list_t *ahd_agentlist; 155*9e39c5baSBill Taylor } tavor_agent_handler_arg_t; 156*9e39c5baSBill Taylor 157*9e39c5baSBill Taylor int tavor_agent_handlers_init(tavor_state_t *state); 158*9e39c5baSBill Taylor int tavor_agent_handlers_fini(tavor_state_t *state); 159*9e39c5baSBill Taylor 160*9e39c5baSBill Taylor #ifdef __cplusplus 161*9e39c5baSBill Taylor } 162*9e39c5baSBill Taylor #endif 163*9e39c5baSBill Taylor 164*9e39c5baSBill Taylor #endif /* _SYS_IB_ADAPTERS_TAVOR_AGENTS_H */ 165