[DAPL2] sync with WinOF 2.1 branch
[mirror/winof/.git] / inc / kernel / iba / ib_cm_ifc.h
1 /*\r
2  * Copyright (c) 2008 Intel Corporation.  All rights reserved.\r
3  *\r
4  * This software is available to you under the OpenIB.org BSD license\r
5  * below:\r
6  *\r
7  *     Redistribution and use in source and binary forms, with or\r
8  *     without modification, are permitted provided that the following\r
9  *     conditions are met:\r
10  *\r
11  *      - Redistributions of source code must retain the above\r
12  *        copyright notice, this list of conditions and the following\r
13  *        disclaimer.\r
14  *\r
15  *      - Redistributions in binary form must reproduce the above\r
16  *        copyright notice, this list of conditions and the following\r
17  *        disclaimer in the documentation and/or other materials\r
18  *        provided with the distribution.\r
19  *\r
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
23  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
24  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
25  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
26  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
27  * SOFTWARE.\r
28  */\r
29 \r
30 #ifndef _ib_cm_ifc_h_\r
31 #define _ib_cm_ifc_h_\r
32 \r
33 #include <initguid.h>\r
34 #include <iba/ib_al_ifc.h>\r
35 #include <iba/ib_types.h>\r
36 #include <iba/ib_al.h>\r
37 \r
38 struct _iba_cm_event;\r
39 \r
40 typedef struct _iba_cm_id\r
41 {\r
42         void            *context;\r
43         NTSTATUS        (*callback)(struct _iba_cm_id *p_id, struct _iba_cm_event *p_event);\r
44         net32_t         cid;\r
45 \r
46 }       iba_cm_id;\r
47 \r
48 typedef struct _iba_cm_req\r
49 {\r
50         ib_net64_t                                      service_id;\r
51 \r
52         ib_path_rec_t                           *p_primary_path;\r
53         ib_path_rec_t                           *p_alt_path;\r
54 \r
55         net32_t                                         qpn;\r
56         ib_qp_type_t                            qp_type;\r
57         net32_t                                         starting_psn;\r
58 \r
59         void                                            *p_pdata;\r
60         uint8_t                                         pdata_len;\r
61 \r
62         uint8_t                                         max_cm_retries;\r
63         uint8_t                                         resp_res;\r
64         uint8_t                                         init_depth;\r
65         uint8_t                                         remote_resp_timeout;\r
66         uint8_t                                         flow_ctrl;\r
67         uint8_t                                         local_resp_timeout;\r
68         uint8_t                                         rnr_retry_cnt;\r
69         uint8_t                                         retry_cnt;\r
70         uint8_t                                         srq;\r
71 \r
72 }       iba_cm_req;\r
73 \r
74 typedef struct _iba_cm_req_event\r
75 {\r
76         iba_cm_req                                      req;\r
77         net64_t                                         local_ca_guid;\r
78         net64_t                                         remote_ca_guid;\r
79         uint16_t                                        pkey_index;\r
80         uint8_t                                         port_num;\r
81 \r
82 }       iba_cm_req_event;\r
83 \r
84 typedef struct _iba_cm_rep\r
85 {\r
86         net32_t                                         qpn;\r
87         net32_t                                         starting_psn;\r
88 \r
89         void                                            *p_pdata;\r
90         uint8_t                                         pdata_len;\r
91 \r
92         ib_cm_failover_t                        failover_accepted;\r
93         uint8_t                                         resp_res;\r
94         uint8_t                                         init_depth;\r
95         uint8_t                                         flow_ctrl;\r
96         uint8_t                                         rnr_retry_cnt;\r
97         uint8_t                                         srq;\r
98 \r
99 }       iba_cm_rep;\r
100 \r
101 typedef struct _iba_cm_rep_event\r
102 {\r
103         iba_cm_rep                                      rep;\r
104         net64_t                                         ca_guid;\r
105         uint8_t                                         target_ack_delay;\r
106 \r
107 }       iba_cm_rep_event;\r
108 \r
109 typedef struct _iba_cm_pdata\r
110 {\r
111         void                                            *p_pdata;\r
112         uint8_t                                         pdata_len;\r
113 \r
114 }       iba_cm_pdata;\r
115 typedef iba_cm_pdata                    iba_cm_rtu_event;\r
116 typedef iba_cm_pdata                    iba_cm_dreq_event;\r
117 typedef iba_cm_pdata                    iba_cm_drep_event;\r
118 \r
119 typedef struct _iba_cm_rej_event\r
120 {\r
121         void                                            *ari;\r
122         void                                            *p_pdata;\r
123         ib_rej_status_t                         reason;\r
124         uint8_t                                         ari_length;\r
125         uint8_t                                         pdata_len;\r
126         \r
127 }       iba_cm_rej_event;\r
128 \r
129 typedef struct _iba_cm_mra_event\r
130 {\r
131         void                                            *p_pdata;\r
132         uint8_t                                         pdata_len;\r
133         uint8_t                                         service_timeout;\r
134 \r
135 }       iba_cm_mra_event;\r
136 \r
137 typedef struct _iba_cm_lap\r
138 {\r
139         ib_path_rec_t                           *p_alt_path;\r
140         void                                            *p_pdata;\r
141         uint8_t                                         pdata_len;\r
142         uint8_t                                         remote_resp_timeout;\r
143 \r
144 }       iba_cm_lap;\r
145 typedef iba_cm_lap iba_cm_lap_event;\r
146 \r
147 typedef struct _iba_cm_apr\r
148 {\r
149         void                                            *p_pdata;\r
150         ib_apr_info_t                           *p_info;\r
151         uint8_t                                         pdata_len;\r
152         uint8_t                                         info_length;\r
153         ib_apr_status_t                         status;\r
154 \r
155 }       iba_cm_apr;\r
156 typedef iba_cm_apr iba_cm_apr_event;\r
157 \r
158 typedef struct _iba_cm_sidr_req\r
159 {\r
160         ib_net64_t                                      service_id;\r
161         ib_path_rec_t                           *p_path;\r
162         void                                            *p_pdata;\r
163         uint8_t                                         pdata_len;\r
164         uint8_t                                         max_cm_retries;\r
165         uint32_t                                        timeout;\r
166 \r
167 }       iba_cm_sidr_req;\r
168 \r
169 typedef struct _iba_cm_sidr_req_event\r
170 {\r
171         iba_cm_sidr_req                         sidr_req;\r
172         net64_t                                         ca_guid;\r
173         uint16_t                                        pkey_index;\r
174         uint8_t                                         port_num;\r
175 \r
176 }       iba_cm_sidr_req_event;\r
177 \r
178 typedef struct _iba_cm_sidr_rep\r
179 {\r
180         net32_t                                         qpn;\r
181         net32_t                                         qkey;\r
182         void                                            *p_pdata;\r
183         void                                            *p_info;\r
184         uint8_t                                         pdata_len;\r
185         uint8_t                                         info_len;\r
186         ib_sidr_status_t                        status;\r
187 \r
188 }       iba_cm_sidr_rep;\r
189 typedef iba_cm_sidr_rep iba_cm_sidr_rep_event;\r
190 \r
191 typedef enum _iba_cm_event_type\r
192 {\r
193         iba_cm_req_error,\r
194         iba_cm_req_received,\r
195         iba_cm_rep_error,\r
196         iba_cm_rep_received,\r
197         iba_cm_rtu_received,\r
198         iba_cm_dreq_error,\r
199         iba_cm_dreq_received,\r
200         iba_cm_drep_received,\r
201         iba_cm_rej_received,\r
202         iba_cm_mra_received,\r
203         iba_cm_lap_error,\r
204         iba_cm_lap_received,\r
205         iba_cm_apr_received,\r
206         iba_cm_sidr_req_error,\r
207         iba_cm_sidr_req_received,\r
208         iba_cm_sidr_rep_received\r
209 \r
210 }       iba_cm_event_type;\r
211 \r
212 typedef struct _iba_cm_event\r
213 {\r
214         iba_cm_event_type                       type;\r
215         union\r
216         {\r
217                 iba_cm_req_event                req;\r
218                 iba_cm_rep_event                rep;\r
219                 iba_cm_rtu_event                rtu;\r
220                 iba_cm_dreq_event               dreq;\r
221                 iba_cm_drep_event               drep;\r
222                 iba_cm_rej_event                rej;\r
223                 iba_cm_mra_event                mra;\r
224                 iba_cm_lap_event                lap;\r
225                 iba_cm_apr_event                apr;\r
226                 iba_cm_sidr_req_event   sidr_req;\r
227                 iba_cm_sidr_rep_event   sidr_rep;\r
228 \r
229         }       data;\r
230 \r
231 }       iba_cm_event;\r
232 \r
233 typedef struct _iba_cm_interface\r
234 {\r
235         NTSTATUS                (*create_id)(NTSTATUS (*callback)(iba_cm_id *p_id,\r
236                                                                                                           iba_cm_event *p_event),\r
237                                                                  void *context, iba_cm_id **pp_id);\r
238         void                    (*destroy_id)(iba_cm_id *p_id);\r
239 \r
240         NTSTATUS                (*listen)(iba_cm_id *p_id, net64_t service_id, void *p_compare_buf,\r
241                                                           uint8_t compare_len, uint8_t compare_offset);\r
242 \r
243         NTSTATUS                (*send_req)(iba_cm_id *p_id, iba_cm_req *p_req);\r
244         NTSTATUS                (*send_rep)(iba_cm_id *p_id, iba_cm_rep *p_rep);\r
245         NTSTATUS                (*send_rtu)(iba_cm_id *p_id, void *p_pdata, uint8_t pdata_len);\r
246 \r
247         NTSTATUS                (*send_dreq)(iba_cm_id *p_id, void *p_pdata, uint8_t pdata_len);\r
248         NTSTATUS                (*send_drep)(iba_cm_id *p_id, void *p_pdata, uint8_t pdata_len);\r
249 \r
250         NTSTATUS                (*send_rej)(iba_cm_id *p_id, ib_rej_status_t status,\r
251                                                                 void *p_ari, uint8_t ari_len,\r
252                                                                 void *p_pdata, uint8_t pdata_len);\r
253         NTSTATUS                (*send_mra)(iba_cm_id *p_id, uint8_t service_timeout,\r
254                                                                 void *p_pdata, uint8_t pdata_len);\r
255 \r
256         NTSTATUS                (*send_lap)(iba_cm_id *p_id, iba_cm_lap *p_lap);\r
257         NTSTATUS                (*send_apr)(iba_cm_id *p_id, iba_cm_apr *p_apr);\r
258 \r
259         NTSTATUS                (*send_sidr_req)(iba_cm_id *p_id, iba_cm_sidr_req *p_req);\r
260         NTSTATUS                (*send_sidr_rep)(iba_cm_id *p_id, iba_cm_sidr_rep *p_rep);\r
261 \r
262         NTSTATUS                (*get_qp_attr)(iba_cm_id *p_id, ib_qp_state_t state,\r
263                                                                    ib_qp_mod_t *p_attr);\r
264 \r
265         NTSTATUS                (*migrate)(iba_cm_id *p_id);\r
266         NTSTATUS                (*established)(iba_cm_id *p_id);\r
267 \r
268 }       iba_cm_interface;\r
269 \r
270 static inline USHORT IbaCmVersion(UINT8 Major, UINT8 Minor)\r
271 {\r
272         return ((USHORT) Major << 8) | ((USHORT) Minor);\r
273 }\r
274 \r
275 static inline UINT8 IbaCmVersionMajor(USHORT Version)\r
276 {\r
277         return (UINT8) (Version >> 8);\r
278 }\r
279 \r
280 static inline UINT8 IbaCmVersionMinor(USHORT Version)\r
281 {\r
282         return (UINT8) Version;\r
283 }\r
284 \r
285 // {EACC1466-BB2D-4478-B5BE-40EDF7EE08AB}\r
286 DEFINE_GUID(GUID_INFINIBAND_INTERFACE_CM, 0xeacc1466, 0xbb2d, 0x4478,\r
287                         0xb5, 0xbe, 0x40, 0xed, 0xf7, 0xee, 0x8, 0xab);\r
288 \r
289 typedef struct _INFINIBAND_INTERFACE_CM\r
290 {\r
291         INTERFACE                       InterfaceHeader;\r
292         iba_cm_interface        CM;\r
293 \r
294 }       INFINIBAND_INTERFACE_CM;\r
295 \r
296 #endif // _ib_cm_ifc_h_