git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@588 ad392aa1-c5ef-ae45-8dd8-e69d62...
[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  * Attribute cache for port info saved to expedite local MAD processing.\r
71  * Note that the cache accounts for the worst case GID and PKEY table size\r
72  * but is allocated from paged pool, so it's nothing to worry about.\r
73  */\r
74 \r
75 typedef struct _guid_block\r
76 {\r
77         boolean_t                               valid;\r
78         ib_guid_info_t                  tbl;\r
79 \r
80 }       guid_block_t;\r
81 \r
82 \r
83 typedef struct _pkey_block\r
84 {\r
85         boolean_t                               valid;\r
86         ib_pkey_table_info_t    tbl;\r
87 \r
88 }       pkey_block_t;\r
89 \r
90 typedef struct _sl_vl_cache\r
91 {\r
92         boolean_t                               valid;\r
93         ib_slvl_table_t                 tbl;\r
94 \r
95 }       sl_vl_cache_t;\r
96 \r
97 typedef struct _vl_arb_block\r
98 {\r
99         boolean_t                               valid;\r
100         ib_vl_arb_table_t               tbl;\r
101 \r
102 }       vl_arb_block_t;\r
103 \r
104 typedef struct _attr_cache\r
105 {\r
106         guid_block_t            guid_block[32];\r
107         pkey_block_t            pkey_tbl[2048];\r
108         sl_vl_cache_t           sl_vl;\r
109         vl_arb_block_t  vl_arb[4];\r
110 \r
111 }       spl_qp_cache_t;\r
112 \r
113 \r
114 /* Per port special QP service */\r
115 typedef struct _spl_qp_svc\r
116 {\r
117         al_obj_t                                                obj;            /* Child of spl_qp_agent_t */\r
118         cl_map_item_t                           map_item;       /* Item on SMI/GSI list */\r
119 \r
120         net64_t                                         port_guid;\r
121         uint8_t                                         port_num;\r
122         ib_net16_t                                      base_lid;\r
123         uint8_t                                         lmc;\r
124         \r
125         ib_net16_t                                      sm_lid;\r
126         uint8_t                                         sm_sl;\r
127         ib_net64_t                                      m_key;\r
128 \r
129         spl_qp_cache_t                          cache;\r
130         cl_spinlock_t                                   cache_lock;\r
131         boolean_t                                       cache_en;\r
132         \r
133         al_mad_disp_handle_t                    h_mad_disp;\r
134         ib_cq_handle_t                          h_send_cq;\r
135         ib_cq_handle_t                          h_recv_cq;\r
136         ib_qp_handle_t                          h_qp;\r
137 \r
138 #if defined( CL_USE_MUTEX )\r
139         boolean_t                                       send_async_queued;\r
140         cl_async_proc_item_t            send_async_cb;\r
141         boolean_t                                       recv_async_queued;\r
142         cl_async_proc_item_t            recv_async_cb;\r
143 #endif\r
144 \r
145         spl_qp_svc_state_t                      state;\r
146         atomic32_t                                      in_use_cnt;\r
147         cl_async_proc_item_t            reset_async;\r
148 \r
149         uint32_t                                        max_qp_depth;\r
150         al_mad_wr_t*                            local_mad_wr;\r
151         cl_qlist_t                                      send_queue;\r
152         cl_qlist_t                                      recv_queue;\r
153         cl_async_proc_item_t            send_async;\r
154 \r
155         ib_qp_handle_t                          h_qp_alias;\r
156         ib_pool_key_t                           pool_key;\r
157         ib_mad_svc_handle_t                     h_mad_svc;\r
158 \r
159 }       spl_qp_svc_t;\r
160 \r
161 \r
162 typedef enum _mad_route\r
163 {\r
164         ROUTE_DISPATCHER = 0,\r
165         ROUTE_REMOTE,\r
166         ROUTE_LOCAL,\r
167         ROUTE_LOOPBACK,\r
168         ROUTE_DISCARD\r
169 \r
170 }       mad_route_t;\r
171 \r
172 \r
173 static inline boolean_t\r
174 is_dispatcher(\r
175         IN              const   mad_route_t                                     route )\r
176 {\r
177         return( route == ROUTE_DISPATCHER );\r
178 }\r
179 \r
180 \r
181 static inline boolean_t\r
182 is_remote(\r
183         IN              const   mad_route_t                                     route )\r
184 {\r
185         return( route == ROUTE_REMOTE );\r
186 }\r
187 \r
188 \r
189 static inline boolean_t\r
190 is_discard(\r
191         IN              const   mad_route_t                                     route )\r
192 {\r
193         return( route == ROUTE_DISCARD );\r
194 }\r
195 \r
196 \r
197 static inline boolean_t\r
198 is_loopback(\r
199         IN              const   mad_route_t                                     route )\r
200 {\r
201         return( route == ROUTE_LOOPBACK );\r
202 }\r
203 \r
204 \r
205 static inline boolean_t\r
206 is_local(\r
207         IN              const   mad_route_t                                     route )\r
208 {\r
209         /*\r
210          * Loopback implies a locally routed MAD.  Discarded MADs are always\r
211          * handled locally to maintain proper order of work completions.\r
212          */\r
213         return( ( route == ROUTE_LOCAL ) ||\r
214                 is_loopback( route ) || is_discard( route ) );\r
215 }\r
216 \r
217 \r
218 ib_api_status_t\r
219 create_spl_qp_mgr(\r
220         IN                              al_obj_t*       const                   p_parent_obj );\r
221 \r
222 \r
223 ib_api_status_t\r
224 acquire_smi_disp(\r
225         IN              const   ib_net64_t                                      port_guid,\r
226                 OUT                     al_mad_disp_handle_t* const     ph_mad_disp );\r
227 \r
228 \r
229 ib_api_status_t\r
230 acquire_gsi_disp(\r
231         IN              const   ib_net64_t                                      port_guid,\r
232                 OUT                     al_mad_disp_handle_t* const     ph_mad_disp );\r
233 \r
234 \r
235 ib_api_status_t\r
236 spl_qp_svc_send(\r
237         IN              const   ib_qp_handle_t                          h_qp,\r
238         IN                              ib_send_wr_t* const                     p_send_wr );\r
239 \r
240 \r
241 void\r
242 force_smi_poll(\r
243         void );\r
244 \r
245 \r
246 #endif\r