[MTHCA\MT23108\IBAL] change to support TRAP and TRAP_REPRESS
[mirror/winof/.git] / core / al / kernel / al_smi.h
1 /*\r
2  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
3  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. \r
4  *\r
5  * This software is available to you under the OpenIB.org BSD license\r
6  * below:\r
7  *\r
8  *     Redistribution and use in source and binary forms, with or\r
9  *     without modification, are permitted provided that the following\r
10  *     conditions are met:\r
11  *\r
12  *      - Redistributions of source code must retain the above\r
13  *        copyright notice, this list of conditions and the following\r
14  *        disclaimer.\r
15  *\r
16  *      - Redistributions in binary form must reproduce the above\r
17  *        copyright notice, this list of conditions and the following\r
18  *        disclaimer in the documentation and/or other materials\r
19  *        provided with the distribution.\r
20  *\r
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
24  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
25  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
26  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
27  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
28  * SOFTWARE.\r
29  *\r
30  * $Id$\r
31  */\r
32 \r
33 \r
34 #if !defined( __AL_SMI_H__ )\r
35 #define __AL_SMI_H__\r
36 \r
37 \r
38 #include <iba/ib_types.h>\r
39 #include <complib/cl_qmap.h>\r
40 #include "al_common.h"\r
41 #include "al_mad.h"\r
42 \r
43 \r
44 /* Global special QP manager */\r
45 typedef struct _spl_qp_mgr\r
46 {\r
47         al_obj_t                                        obj;            /* Child of gp_al_mgr */\r
48         ib_pnp_handle_t                         h_qp0_pnp;      /* Handle for QP0 port PnP events */\r
49         ib_pnp_handle_t                         h_qp1_pnp;      /* Handle for QP1 port PnP events */\r
50 \r
51         cl_timer_t                                      poll_timer;     /* Timer for polling HW SMIs */\r
52 \r
53         cl_qmap_t                                       smi_map;        /* List of SMI services */\r
54         cl_qmap_t                                       gsi_map;        /* List of GSI services */\r
55 \r
56 }       spl_qp_mgr_t;\r
57 \r
58 \r
59 \r
60 typedef enum _spl_qp_svc_state\r
61 {\r
62         SPL_QP_INIT = 0,\r
63         SPL_QP_ACTIVE,\r
64         SPL_QP_ERROR,\r
65         SPL_QP_DESTROYING\r
66 \r
67 }       spl_qp_svc_state_t;\r
68 \r
69 \r
70 \r
71 /* Per port special QP service */\r
72 typedef struct _spl_qp_svc\r
73 {\r
74         al_obj_t                                        obj;            /* Child of spl_qp_agent_t */\r
75         cl_map_item_t                           map_item;       /* Item on SMI/GSI list */\r
76 \r
77         net64_t                                         port_guid;\r
78         uint8_t                                         port_num;\r
79         ib_net16_t                                      base_lid;\r
80         uint8_t                                         lmc;\r
81 \r
82         ib_net16_t                                      sm_lid;\r
83         uint8_t                                         sm_sl;\r
84 \r
85         al_mad_disp_handle_t            h_mad_disp;\r
86         ib_cq_handle_t                          h_send_cq;\r
87         ib_cq_handle_t                          h_recv_cq;\r
88         ib_qp_handle_t                          h_qp;\r
89 \r
90 #if defined( CL_USE_MUTEX )\r
91         boolean_t                                       send_async_queued;\r
92         cl_async_proc_item_t            send_async_cb;\r
93         boolean_t                                       recv_async_queued;\r
94         cl_async_proc_item_t            recv_async_cb;\r
95 #endif\r
96 \r
97         spl_qp_svc_state_t                      state;\r
98         atomic32_t                                      in_use_cnt;\r
99         cl_async_proc_item_t            reset_async;\r
100 \r
101         uint32_t                                        max_qp_depth;\r
102         al_mad_wr_t*                            local_mad_wr;\r
103         cl_qlist_t                                      send_queue;\r
104         cl_qlist_t                                      recv_queue;\r
105         cl_async_proc_item_t            send_async;\r
106 \r
107         ib_qp_handle_t                          h_qp_alias;\r
108         ib_pool_key_t                           pool_key;\r
109         ib_mad_svc_handle_t                     h_mad_svc;\r
110 \r
111 }       spl_qp_svc_t;\r
112 \r
113 \r
114 typedef enum _mad_route\r
115 {\r
116         ROUTE_DISPATCHER = 0,\r
117         ROUTE_REMOTE,\r
118         ROUTE_LOCAL,\r
119         ROUTE_LOOPBACK,\r
120         ROUTE_DISCARD\r
121 \r
122 }       mad_route_t;\r
123 \r
124 \r
125 static inline boolean_t\r
126 is_dispatcher(\r
127         IN              const   mad_route_t                                     route )\r
128 {\r
129         return( route == ROUTE_DISPATCHER );\r
130 }\r
131 \r
132 \r
133 static inline boolean_t\r
134 is_remote(\r
135         IN              const   mad_route_t                                     route )\r
136 {\r
137         return( route == ROUTE_REMOTE );\r
138 }\r
139 \r
140 \r
141 static inline boolean_t\r
142 is_discard(\r
143         IN              const   mad_route_t                                     route )\r
144 {\r
145         return( route == ROUTE_DISCARD );\r
146 }\r
147 \r
148 \r
149 static inline boolean_t\r
150 is_loopback(\r
151         IN              const   mad_route_t                                     route )\r
152 {\r
153         return( route == ROUTE_LOOPBACK );\r
154 }\r
155 \r
156 \r
157 static inline boolean_t\r
158 is_local(\r
159         IN              const   mad_route_t                                     route )\r
160 {\r
161         /*\r
162          * Loopback implies a locally routed MAD.  Discarded MADs are always\r
163          * handled locally to maintain proper order of work completions.\r
164          */\r
165         return( ( route == ROUTE_LOCAL ) ||\r
166                 is_loopback( route ) || is_discard( route ) );\r
167 }\r
168 \r
169 \r
170 ib_api_status_t\r
171 create_spl_qp_mgr(\r
172         IN                              al_obj_t*       const                   p_parent_obj );\r
173 \r
174 \r
175 ib_api_status_t\r
176 acquire_smi_disp(\r
177         IN              const   ib_net64_t                                      port_guid,\r
178                 OUT                     al_mad_disp_handle_t* const     ph_mad_disp );\r
179 \r
180 \r
181 ib_api_status_t\r
182 acquire_gsi_disp(\r
183         IN              const   ib_net64_t                                      port_guid,\r
184                 OUT                     al_mad_disp_handle_t* const     ph_mad_disp );\r
185 \r
186 \r
187 ib_api_status_t\r
188 spl_qp_svc_send(\r
189         IN              const   ib_qp_handle_t                          h_qp,\r
190         IN                              ib_send_wr_t* const                     p_send_wr );\r
191 \r
192 \r
193 void\r
194 force_smi_poll(\r
195         void );\r
196 \r
197 \r
198 #endif\r