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