[IBAL] Change CEP DREP API
[mirror/winof/.git] / core / al / al_cm_cep.h
1 /*\r
2  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
3  * Portions Copyright (c) 2008 Microsoft 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 #pragma once\r
35 \r
36 #ifndef _AL_CM_CEP_H_\r
37 #define _AL_CM_CEP_H_\r
38 \r
39 \r
40 #include <iba/ib_al.h>\r
41 #include "al_common.h"\r
42 \r
43 \r
44 #define CEP_EVENT_TIMEOUT       0x80000000\r
45 #define CEP_EVENT_RECV          0x40000000\r
46 #define CEP_EVENT_REQ           0x00000001\r
47 #define CEP_EVENT_REP           0x00000002\r
48 #define CEP_EVENT_RTU           0x00000004\r
49 #define CEP_EVENT_DREQ          0x00000008\r
50 #define CEP_EVENT_DREP          0x00000010\r
51 #define CEP_EVENT_MRA           0x00000020\r
52 #define CEP_EVENT_REJ           0x00000040\r
53 #define CEP_EVENT_LAP           0x00000080\r
54 #define CEP_EVENT_APR           0x00000100\r
55 #define CEP_EVENT_SIDR          0x00800000\r
56 \r
57 \r
58 #define AL_INVALID_CID          0xFFFFFFFF\r
59 #define AL_RESERVED_CID         0\r
60 \r
61 \r
62 typedef void\r
63 (*al_pfn_cep_cb_t)(\r
64         IN              const   ib_al_handle_t                          h_al,\r
65         IN              const   net32_t                                         cid );\r
66 /* PARAMETERS\r
67 *       h_al\r
68 *               [in] Handle to the AL instance to pass into the al_cep_poll call.\r
69 *\r
70 *       cid\r
71 *               [in] CID of the CEP on which the event occurred.  The CID should\r
72 *               be passed into the al_cep_poll call.\r
73 *\r
74 * RETURN VALUES:\r
75 *       This function does not return a value.\r
76 *\r
77 * NOTES\r
78 *       The callback is invoked at DISPATCH_LEVEL.\r
79 *\r
80 *       Recipients of the callback are expected to call al_cep_poll to retrieve\r
81 *       event specific details until al_cep_poll returns IB_NOT_DONE.  This may\r
82 *       be done in a different thread context.\r
83 *********/\r
84 \r
85 \r
86 ib_api_status_t\r
87 create_cep_mgr(\r
88         IN                              al_obj_t* const                         p_parent_obj );\r
89 \r
90 \r
91 void\r
92 al_cep_cleanup_al(\r
93         IN              const   ib_al_handle_t                          h_al );\r
94 \r
95 \r
96 ib_api_status_t\r
97 al_create_cep(\r
98         IN                              ib_al_handle_t                          h_al,\r
99         IN                              al_pfn_cep_cb_t                         pfn_cb,\r
100         IN                              void*                                           context,\r
101         IN                              ib_pfn_destroy_cb_t                     pfn_destroy_cb OPTIONAL,\r
102         IN      OUT                     net32_t* const                          p_cid );\r
103 /*\r
104 * NOTES\r
105 *       This function may be invoked at DISPATCH_LEVEL\r
106 *\r
107 * The pfn_cb parameter may be NULL in the kernel if using IRPs for\r
108 * event notification.\r
109 *********/\r
110 \r
111 /* Destruction is asynchronous. */\r
112 void\r
113 al_destroy_cep(\r
114         IN                              ib_al_handle_t                          h_al,\r
115         IN      OUT                     net32_t* const                          p_cid,\r
116         IN                              boolean_t                                       reusable );\r
117 /*\r
118 *********/\r
119 \r
120 ib_api_status_t\r
121 al_cep_listen(\r
122         IN                              ib_al_handle_t                          h_al,\r
123         IN                              net32_t                                         cid,\r
124         IN                              ib_cep_listen_t* const          p_listen_info );\r
125 \r
126 \r
127 ib_api_status_t\r
128 al_cep_pre_req(\r
129         IN                              ib_al_handle_t                          h_al,\r
130         IN                              net32_t                                         cid,\r
131         IN              const   ib_cm_req_t* const                      p_cm_req,\r
132                 OUT                     ib_qp_mod_t* const                      p_init );\r
133 \r
134 \r
135 ib_api_status_t\r
136 al_cep_send_req(\r
137         IN                              ib_al_handle_t                          h_al,\r
138         IN                              net32_t                                         cid );\r
139 \r
140 \r
141 ib_api_status_t\r
142 al_cep_pre_rep(\r
143         IN                              ib_al_handle_t                          h_al,\r
144         IN                              net32_t                                         cid,\r
145         IN                              void*                                           context,\r
146         IN                              ib_pfn_destroy_cb_t                     pfn_destroy_cb OPTIONAL,\r
147         IN              const   ib_cm_rep_t* const                      p_cm_rep,\r
148         IN      OUT                     net32_t* const                          p_cid,\r
149                 OUT                     ib_qp_mod_t* const                      p_init );\r
150 \r
151 ib_api_status_t\r
152 al_cep_pre_rep_ex(\r
153         IN                              ib_al_handle_t                          h_al,\r
154         IN                              net32_t                                         cid,\r
155         IN                              al_pfn_cep_cb_t                         pfn_cb,\r
156         IN                              void*                                           context,\r
157         IN                              ib_pfn_destroy_cb_t                     pfn_destroy_cb OPTIONAL,\r
158         IN              const   ib_cm_rep_t* const                      p_cm_rep,\r
159         IN      OUT                     net32_t* const                          p_cid,\r
160                 OUT                     ib_qp_mod_t* const                      p_init );\r
161 \r
162 ib_api_status_t\r
163 al_cep_send_rep(\r
164         IN                              ib_al_handle_t                          h_al,\r
165         IN                              net32_t                                         cid );\r
166 \r
167 \r
168 ib_api_status_t\r
169 al_cep_get_rtr_attr(\r
170         IN                              ib_al_handle_t                          h_al,\r
171         IN                              net32_t                                         cid,\r
172                 OUT                     ib_qp_mod_t* const                      p_rtr );\r
173 \r
174 \r
175 ib_api_status_t\r
176 al_cep_get_rts_attr(\r
177         IN                              ib_al_handle_t                          h_al,\r
178         IN                              net32_t                                         cid,\r
179                 OUT                     ib_qp_mod_t* const                      p_rts );\r
180 \r
181 \r
182 ib_api_status_t\r
183 al_cep_rtu(\r
184         IN                              ib_al_handle_t                          h_al,\r
185         IN                              net32_t                                         cid,\r
186         IN              const   uint8_t*                                        p_pdata OPTIONAL,\r
187         IN                              uint8_t                                         pdata_len );\r
188 \r
189 \r
190 ib_api_status_t\r
191 al_cep_rej(\r
192         IN                              ib_al_handle_t                          h_al,\r
193         IN                              net32_t                                         cid,\r
194         IN                              ib_rej_status_t                         rej_status,\r
195         IN              const   uint8_t* const                          p_ari,\r
196         IN                              uint8_t                                         ari_len,\r
197         IN              const   uint8_t* const                          p_pdata,\r
198         IN                              uint8_t                                         pdata_len );\r
199 \r
200 \r
201 ib_api_status_t\r
202 al_cep_mra(\r
203         IN                              ib_al_handle_t                          h_al,\r
204         IN                              net32_t                                         cid,\r
205         IN              const   ib_cm_mra_t* const                      p_cm_mra );\r
206 \r
207 \r
208 ib_api_status_t\r
209 al_cep_lap(\r
210         IN                              ib_al_handle_t                          h_al,\r
211         IN                              net32_t                                         cid,\r
212         IN              const   ib_cm_lap_t* const                      p_cm_lap );\r
213 \r
214 \r
215 ib_api_status_t\r
216 al_cep_pre_apr(\r
217         IN                              ib_al_handle_t                          h_al,\r
218         IN                              net32_t                                         cid,\r
219         IN              const   ib_cm_apr_t* const                      p_cm_apr,\r
220                 OUT                     ib_qp_mod_t* const                      p_apr );\r
221 \r
222 \r
223 ib_api_status_t\r
224 al_cep_send_apr(\r
225         IN                              ib_al_handle_t                          h_al,\r
226         IN                              net32_t                                         cid );\r
227 \r
228 \r
229 ib_api_status_t\r
230 al_cep_dreq(\r
231         IN                              ib_al_handle_t                          h_al,\r
232         IN                              net32_t                                         cid,\r
233         IN              const   uint8_t* const                          p_pdata OPTIONAL,\r
234         IN              const   uint8_t                                         pdata_len );\r
235 \r
236 \r
237 ib_api_status_t\r
238 al_cep_drep(\r
239         IN                              ib_al_handle_t                          h_al,\r
240         IN                              net32_t                                         cid,\r
241         IN              const   uint8_t* const                          p_pdata OPTIONAL,\r
242         IN              const   uint8_t                                         pdata_len );\r
243 \r
244 \r
245 ib_api_status_t\r
246 al_cep_get_timewait(\r
247         IN                              ib_al_handle_t                          h_al,\r
248         IN                              net32_t                                         cid,\r
249                 OUT                     uint64_t* const                         p_timewait_us );\r
250 \r
251 \r
252 ib_api_status_t\r
253 al_cep_migrate(\r
254         IN                              ib_al_handle_t                          h_al,\r
255         IN                              net32_t                                         cid );\r
256 \r
257 \r
258 ib_api_status_t\r
259 al_cep_established(\r
260         IN                              ib_al_handle_t                          h_al,\r
261         IN                              net32_t                                         cid );\r
262 \r
263 \r
264 ib_api_status_t\r
265 al_cep_poll(\r
266         IN                              ib_al_handle_t                          h_al,\r
267         IN                              net32_t                                         cid,\r
268                 OUT                     void**                                          p_context,\r
269                 OUT                     net32_t* const                          p_new_cid,\r
270                 OUT                     ib_mad_element_t** const        pp_mad );\r
271 \r
272 \r
273 #ifdef CL_KERNEL\r
274 \r
275 NTSTATUS\r
276 al_cep_queue_irp(\r
277         IN                              ib_al_handle_t                          h_al,\r
278         IN                              net32_t                                         cid,\r
279         IN                              IRP* const                                      p_irp );\r
280 \r
281 NTSTATUS\r
282 al_cep_get_cid(\r
283         IN              ib_al_handle_t                                          h_al,\r
284         IN              net32_t                 const                           cid,\r
285         IN              PIRP                                                            h_ioctl\r
286         );\r
287 \r
288 NTSTATUS\r
289 al_cep_get_pdata(\r
290         IN                              ib_al_handle_t                          h_al,\r
291         IN                              net32_t                                         cid,\r
292         OUT         uint8_t                     *p_init_depth,\r
293         OUT         uint8_t                     *p_resp_res,\r
294         IN      OUT                     uint8_t                                         *p_psize,\r
295                 OUT                     uint8_t*                                        pdata );\r
296 \r
297 #endif /* CL_KERNEL */\r
298 \r
299 \r
300 /****s* Access Layer/al_cep_sreq_t\r
301 * NAME\r
302 *       al_cep_sreq_t\r
303 *\r
304 * DESCRIPTION\r
305 *       Connection request information used to establish a new connection.\r
306 *\r
307 * SYNOPSIS\r
308 */\r
309 typedef struct _al_cep_sreq\r
310 {\r
311         ib_net64_t                                      svc_id;\r
312 \r
313         ib_path_rec_t*                          p_path;\r
314 \r
315         const uint8_t*                          p_pdata;\r
316         uint8_t                                         pdata_len;\r
317 \r
318         uint8_t                                         max_cm_retries;\r
319         ib_net16_t                                      pkey;\r
320         uint32_t                                        timeout_ms;\r
321 \r
322 }       al_cep_sreq_t;\r
323 /*\r
324 * FIELDS\r
325 *       svc_id\r
326 *               The ID of the remote service to which the SIDR request is\r
327 *               being made.\r
328 *\r
329 *       p_path\r
330 *               Path information over which to send the request.\r
331 *\r
332 *       p_pdata\r
333 *               Optional user-defined private data sent as part of the SIDR request.\r
334 *\r
335 *       pdata_len\r
336 *               Defines the size of the user-defined private data.\r
337 *\r
338 *       max_cm_retries\r
339 *               The maximum number of times that either CM should\r
340 *               resend a SIDR message.\r
341 *\r
342 *       timeout_ms\r
343 *               Timeout value in milli-seconds for the SIDR REQ to expire.  The CM will\r
344 *               add twice packet lifetime to this value to determine the actual timeout\r
345 *               value used.\r
346 *\r
347 *       pkey\r
348 *               pkey to be used as part of the request.\r
349 *\r
350 * SEE ALSO\r
351 *       al_cep_sreq\r
352 *****/\r
353 \r
354 ib_api_status_t\r
355 al_cep_sreq(\r
356         IN                              ib_al_handle_t                          h_al,\r
357         IN                              net32_t                                         cid,\r
358         IN              const   al_cep_sreq_t* const            p_sreq );\r
359 \r
360 \r
361 /****s* Access Layer/al_cep_srep_t\r
362 * NAME\r
363 *       al_cep_srep_t\r
364 *\r
365 * DESCRIPTION\r
366 *       SIDR reply information.\r
367 *\r
368 * SYNOPSIS\r
369 */\r
370 typedef struct _al_cep_srep\r
371 {\r
372         net32_t                                         qp_num;\r
373         net32_t                                         qkey;\r
374 \r
375         const uint8_t*                          p_pdata;\r
376         const void*                                     p_info;\r
377 \r
378         uint8_t                                         pdata_len;\r
379         uint8_t                                         info_len;\r
380 \r
381         ib_sidr_status_t                        status;\r
382 \r
383 }       al_cep_srep_t;\r
384 /*\r
385 * FIELDS\r
386 *       qp_num\r
387 *               The number of the queue pair on which the requested service\r
388 *               is supported.\r
389 *\r
390 *       qp_key\r
391 *               The QKEY of the returned queue pair.\r
392 *\r
393 *       p_pdata\r
394 *               Optional user-defined private data sent as part of the SIDR reply.\r
395 *\r
396 *       p_info\r
397 *               Optional "additonal information" sent as part of the SIDR reply.\r
398 *\r
399 *       pdata_len\r
400 *               Size of the user-defined private data.\r
401 *\r
402 *       info_len\r
403 *               Size of the "additional information".\r
404 *\r
405 *       status\r
406 *               sidr status value returned back to a previously received REQ.\r
407 *\r
408 * SEE ALSO\r
409 *       al_cep_srep\r
410 *****/\r
411 \r
412 ib_api_status_t\r
413 al_cep_srep(\r
414         IN                              ib_al_handle_t                          h_al,\r
415         IN                              net32_t                                         cid,\r
416         IN              const   al_cep_srep_t* const            p_sreq );\r
417 \r
418 \r
419 \r
420 \r
421 /*\r
422  * Return the local ACK timeout value based on the given packet lifetime\r
423  * and target ACK delay.  Both input values are assumed to be in the form\r
424  * 4.096 x 2 ^ input.\r
425  */\r
426 #define MAX_LOCAL_ACK_TIMEOUT           0x1F            /* limited to 5 bits */\r
427 \r
428 inline uint8_t\r
429 calc_lcl_ack_timeout(\r
430         IN              const   uint8_t                                         round_trip_time,\r
431         IN              const   uint8_t                                         target_ack_delay )\r
432 {\r
433         uint64_t        timeout;\r
434         uint8_t         local_ack_timeout;\r
435 \r
436         if( !target_ack_delay )\r
437         {\r
438                 if( round_trip_time > MAX_LOCAL_ACK_TIMEOUT )\r
439                         return MAX_LOCAL_ACK_TIMEOUT;\r
440                 else\r
441                         return round_trip_time;\r
442         }\r
443 \r
444         /*\r
445          * Since both input and the output values are in the same form, we\r
446          * can ignore the 4.096 portion by dividing it out.\r
447          */\r
448 \r
449         /* The input parameter is the round trip time. */\r
450         timeout = (uint64_t)1 << round_trip_time;\r
451 \r
452         /* Add in the target ack delay. */\r
453         if( target_ack_delay )\r
454                 timeout += (uint64_t)1 << target_ack_delay;\r
455 \r
456         /* Calculate the local ACK timeout. */\r
457         local_ack_timeout = 1;\r
458         while( (1ui64 << local_ack_timeout) <= timeout )\r
459         {\r
460                 local_ack_timeout++;\r
461 \r
462                 /* Only 5-bits are valid. */\r
463                 if( local_ack_timeout > MAX_LOCAL_ACK_TIMEOUT )\r
464                         return MAX_LOCAL_ACK_TIMEOUT;\r
465         }\r
466 \r
467         return local_ack_timeout;\r
468 }\r
469 \r
470 #endif  /* _AL_CM_CEP_H_ */\r