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