diff options
Diffstat (limited to 'drivers/infiniband/hw/ehca/ehca_classes.h')
-rw-r--r-- | drivers/infiniband/hw/ehca/ehca_classes.h | 346 |
1 files changed, 346 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/ehca/ehca_classes.h b/drivers/infiniband/hw/ehca/ehca_classes.h new file mode 100644 index 000000000000..1c722032319c --- /dev/null +++ b/drivers/infiniband/hw/ehca/ehca_classes.h | |||
@@ -0,0 +1,346 @@ | |||
1 | /* | ||
2 | * IBM eServer eHCA Infiniband device driver for Linux on POWER | ||
3 | * | ||
4 | * Struct definition for eHCA internal structures | ||
5 | * | ||
6 | * Authors: Heiko J Schick <schickhj@de.ibm.com> | ||
7 | * Christoph Raisch <raisch@de.ibm.com> | ||
8 | * | ||
9 | * Copyright (c) 2005 IBM Corporation | ||
10 | * | ||
11 | * All rights reserved. | ||
12 | * | ||
13 | * This source code is distributed under a dual license of GPL v2.0 and OpenIB | ||
14 | * BSD. | ||
15 | * | ||
16 | * OpenIB BSD License | ||
17 | * | ||
18 | * Redistribution and use in source and binary forms, with or without | ||
19 | * modification, are permitted provided that the following conditions are met: | ||
20 | * | ||
21 | * Redistributions of source code must retain the above copyright notice, this | ||
22 | * list of conditions and the following disclaimer. | ||
23 | * | ||
24 | * Redistributions in binary form must reproduce the above copyright notice, | ||
25 | * this list of conditions and the following disclaimer in the documentation | ||
26 | * and/or other materials | ||
27 | * provided with the distribution. | ||
28 | * | ||
29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
30 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
33 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
34 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
35 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
36 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||
37 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
38 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
39 | * POSSIBILITY OF SUCH DAMAGE. | ||
40 | */ | ||
41 | |||
42 | #ifndef __EHCA_CLASSES_H__ | ||
43 | #define __EHCA_CLASSES_H__ | ||
44 | |||
45 | #include "ehca_classes.h" | ||
46 | #include "ipz_pt_fn.h" | ||
47 | |||
48 | struct ehca_module; | ||
49 | struct ehca_qp; | ||
50 | struct ehca_cq; | ||
51 | struct ehca_eq; | ||
52 | struct ehca_mr; | ||
53 | struct ehca_mw; | ||
54 | struct ehca_pd; | ||
55 | struct ehca_av; | ||
56 | |||
57 | #ifdef CONFIG_PPC64 | ||
58 | #include "ehca_classes_pSeries.h" | ||
59 | #endif | ||
60 | |||
61 | #include <rdma/ib_verbs.h> | ||
62 | #include <rdma/ib_user_verbs.h> | ||
63 | |||
64 | #include "ehca_irq.h" | ||
65 | |||
66 | struct ehca_eq { | ||
67 | u32 length; | ||
68 | struct ipz_queue ipz_queue; | ||
69 | struct ipz_eq_handle ipz_eq_handle; | ||
70 | struct work_struct work; | ||
71 | struct h_galpas galpas; | ||
72 | int is_initialized; | ||
73 | struct ehca_pfeq pf; | ||
74 | spinlock_t spinlock; | ||
75 | struct tasklet_struct interrupt_task; | ||
76 | u32 ist; | ||
77 | }; | ||
78 | |||
79 | struct ehca_sport { | ||
80 | struct ib_cq *ibcq_aqp1; | ||
81 | struct ib_qp *ibqp_aqp1; | ||
82 | enum ib_rate rate; | ||
83 | enum ib_port_state port_state; | ||
84 | }; | ||
85 | |||
86 | struct ehca_shca { | ||
87 | struct ib_device ib_device; | ||
88 | struct ibmebus_dev *ibmebus_dev; | ||
89 | u8 num_ports; | ||
90 | int hw_level; | ||
91 | struct list_head shca_list; | ||
92 | struct ipz_adapter_handle ipz_hca_handle; | ||
93 | struct ehca_sport sport[2]; | ||
94 | struct ehca_eq eq; | ||
95 | struct ehca_eq neq; | ||
96 | struct ehca_mr *maxmr; | ||
97 | struct ehca_pd *pd; | ||
98 | struct h_galpas galpas; | ||
99 | }; | ||
100 | |||
101 | struct ehca_pd { | ||
102 | struct ib_pd ib_pd; | ||
103 | struct ipz_pd fw_pd; | ||
104 | u32 ownpid; | ||
105 | }; | ||
106 | |||
107 | struct ehca_qp { | ||
108 | struct ib_qp ib_qp; | ||
109 | u32 qp_type; | ||
110 | struct ipz_queue ipz_squeue; | ||
111 | struct ipz_queue ipz_rqueue; | ||
112 | struct h_galpas galpas; | ||
113 | u32 qkey; | ||
114 | u32 real_qp_num; | ||
115 | u32 token; | ||
116 | spinlock_t spinlock_s; | ||
117 | spinlock_t spinlock_r; | ||
118 | u32 sq_max_inline_data_size; | ||
119 | struct ipz_qp_handle ipz_qp_handle; | ||
120 | struct ehca_pfqp pf; | ||
121 | struct ib_qp_init_attr init_attr; | ||
122 | u64 uspace_squeue; | ||
123 | u64 uspace_rqueue; | ||
124 | u64 uspace_fwh; | ||
125 | struct ehca_cq *send_cq; | ||
126 | struct ehca_cq *recv_cq; | ||
127 | unsigned int sqerr_purgeflag; | ||
128 | struct hlist_node list_entries; | ||
129 | }; | ||
130 | |||
131 | /* must be power of 2 */ | ||
132 | #define QP_HASHTAB_LEN 8 | ||
133 | |||
134 | struct ehca_cq { | ||
135 | struct ib_cq ib_cq; | ||
136 | struct ipz_queue ipz_queue; | ||
137 | struct h_galpas galpas; | ||
138 | spinlock_t spinlock; | ||
139 | u32 cq_number; | ||
140 | u32 token; | ||
141 | u32 nr_of_entries; | ||
142 | struct ipz_cq_handle ipz_cq_handle; | ||
143 | struct ehca_pfcq pf; | ||
144 | spinlock_t cb_lock; | ||
145 | u64 uspace_queue; | ||
146 | u64 uspace_fwh; | ||
147 | struct hlist_head qp_hashtab[QP_HASHTAB_LEN]; | ||
148 | struct list_head entry; | ||
149 | u32 nr_callbacks; | ||
150 | spinlock_t task_lock; | ||
151 | u32 ownpid; | ||
152 | }; | ||
153 | |||
154 | enum ehca_mr_flag { | ||
155 | EHCA_MR_FLAG_FMR = 0x80000000, /* FMR, created with ehca_alloc_fmr */ | ||
156 | EHCA_MR_FLAG_MAXMR = 0x40000000, /* max-MR */ | ||
157 | }; | ||
158 | |||
159 | struct ehca_mr { | ||
160 | union { | ||
161 | struct ib_mr ib_mr; /* must always be first in ehca_mr */ | ||
162 | struct ib_fmr ib_fmr; /* must always be first in ehca_mr */ | ||
163 | } ib; | ||
164 | spinlock_t mrlock; | ||
165 | |||
166 | enum ehca_mr_flag flags; | ||
167 | u32 num_pages; /* number of MR pages */ | ||
168 | u32 num_4k; /* number of 4k "page" portions to form MR */ | ||
169 | int acl; /* ACL (stored here for usage in reregister) */ | ||
170 | u64 *start; /* virtual start address (stored here for */ | ||
171 | /* usage in reregister) */ | ||
172 | u64 size; /* size (stored here for usage in reregister) */ | ||
173 | u32 fmr_page_size; /* page size for FMR */ | ||
174 | u32 fmr_max_pages; /* max pages for FMR */ | ||
175 | u32 fmr_max_maps; /* max outstanding maps for FMR */ | ||
176 | u32 fmr_map_cnt; /* map counter for FMR */ | ||
177 | /* fw specific data */ | ||
178 | struct ipz_mrmw_handle ipz_mr_handle; /* MR handle for h-calls */ | ||
179 | struct h_galpas galpas; | ||
180 | /* data for userspace bridge */ | ||
181 | u32 nr_of_pages; | ||
182 | void *pagearray; | ||
183 | }; | ||
184 | |||
185 | struct ehca_mw { | ||
186 | struct ib_mw ib_mw; /* gen2 mw, must always be first in ehca_mw */ | ||
187 | spinlock_t mwlock; | ||
188 | |||
189 | u8 never_bound; /* indication MW was never bound */ | ||
190 | struct ipz_mrmw_handle ipz_mw_handle; /* MW handle for h-calls */ | ||
191 | struct h_galpas galpas; | ||
192 | }; | ||
193 | |||
194 | enum ehca_mr_pgi_type { | ||
195 | EHCA_MR_PGI_PHYS = 1, /* type of ehca_reg_phys_mr, | ||
196 | * ehca_rereg_phys_mr, | ||
197 | * ehca_reg_internal_maxmr */ | ||
198 | EHCA_MR_PGI_USER = 2, /* type of ehca_reg_user_mr */ | ||
199 | EHCA_MR_PGI_FMR = 3 /* type of ehca_map_phys_fmr */ | ||
200 | }; | ||
201 | |||
202 | struct ehca_mr_pginfo { | ||
203 | enum ehca_mr_pgi_type type; | ||
204 | u64 num_pages; | ||
205 | u64 page_cnt; | ||
206 | u64 num_4k; /* number of 4k "page" portions */ | ||
207 | u64 page_4k_cnt; /* counter for 4k "page" portions */ | ||
208 | u64 next_4k; /* next 4k "page" portion in buffer/chunk/listelem */ | ||
209 | |||
210 | /* type EHCA_MR_PGI_PHYS section */ | ||
211 | int num_phys_buf; | ||
212 | struct ib_phys_buf *phys_buf_array; | ||
213 | u64 next_buf; | ||
214 | |||
215 | /* type EHCA_MR_PGI_USER section */ | ||
216 | struct ib_umem *region; | ||
217 | struct ib_umem_chunk *next_chunk; | ||
218 | u64 next_nmap; | ||
219 | |||
220 | /* type EHCA_MR_PGI_FMR section */ | ||
221 | u64 *page_list; | ||
222 | u64 next_listelem; | ||
223 | /* next_4k also used within EHCA_MR_PGI_FMR */ | ||
224 | }; | ||
225 | |||
226 | /* output parameters for MR/FMR hipz calls */ | ||
227 | struct ehca_mr_hipzout_parms { | ||
228 | struct ipz_mrmw_handle handle; | ||
229 | u32 lkey; | ||
230 | u32 rkey; | ||
231 | u64 len; | ||
232 | u64 vaddr; | ||
233 | u32 acl; | ||
234 | }; | ||
235 | |||
236 | /* output parameters for MW hipz calls */ | ||
237 | struct ehca_mw_hipzout_parms { | ||
238 | struct ipz_mrmw_handle handle; | ||
239 | u32 rkey; | ||
240 | }; | ||
241 | |||
242 | struct ehca_av { | ||
243 | struct ib_ah ib_ah; | ||
244 | struct ehca_ud_av av; | ||
245 | }; | ||
246 | |||
247 | struct ehca_ucontext { | ||
248 | struct ib_ucontext ib_ucontext; | ||
249 | }; | ||
250 | |||
251 | struct ehca_module *ehca_module_new(void); | ||
252 | |||
253 | int ehca_module_delete(struct ehca_module *me); | ||
254 | |||
255 | int ehca_eq_ctor(struct ehca_eq *eq); | ||
256 | |||
257 | int ehca_eq_dtor(struct ehca_eq *eq); | ||
258 | |||
259 | struct ehca_shca *ehca_shca_new(void); | ||
260 | |||
261 | int ehca_shca_delete(struct ehca_shca *me); | ||
262 | |||
263 | struct ehca_sport *ehca_sport_new(struct ehca_shca *anchor); | ||
264 | |||
265 | int ehca_init_pd_cache(void); | ||
266 | void ehca_cleanup_pd_cache(void); | ||
267 | int ehca_init_cq_cache(void); | ||
268 | void ehca_cleanup_cq_cache(void); | ||
269 | int ehca_init_qp_cache(void); | ||
270 | void ehca_cleanup_qp_cache(void); | ||
271 | int ehca_init_av_cache(void); | ||
272 | void ehca_cleanup_av_cache(void); | ||
273 | int ehca_init_mrmw_cache(void); | ||
274 | void ehca_cleanup_mrmw_cache(void); | ||
275 | |||
276 | extern spinlock_t ehca_qp_idr_lock; | ||
277 | extern spinlock_t ehca_cq_idr_lock; | ||
278 | extern struct idr ehca_qp_idr; | ||
279 | extern struct idr ehca_cq_idr; | ||
280 | |||
281 | extern int ehca_static_rate; | ||
282 | extern int ehca_port_act_time; | ||
283 | extern int ehca_use_hp_mr; | ||
284 | |||
285 | struct ipzu_queue_resp { | ||
286 | u64 queue; /* points to first queue entry */ | ||
287 | u32 qe_size; /* queue entry size */ | ||
288 | u32 act_nr_of_sg; | ||
289 | u32 queue_length; /* queue length allocated in bytes */ | ||
290 | u32 pagesize; | ||
291 | u32 toggle_state; | ||
292 | u32 dummy; /* padding for 8 byte alignment */ | ||
293 | }; | ||
294 | |||
295 | struct ehca_create_cq_resp { | ||
296 | u32 cq_number; | ||
297 | u32 token; | ||
298 | struct ipzu_queue_resp ipz_queue; | ||
299 | struct h_galpas galpas; | ||
300 | }; | ||
301 | |||
302 | struct ehca_create_qp_resp { | ||
303 | u32 qp_num; | ||
304 | u32 token; | ||
305 | u32 qp_type; | ||
306 | u32 qkey; | ||
307 | /* qp_num assigned by ehca: sqp0/1 may have got different numbers */ | ||
308 | u32 real_qp_num; | ||
309 | u32 dummy; /* padding for 8 byte alignment */ | ||
310 | struct ipzu_queue_resp ipz_squeue; | ||
311 | struct ipzu_queue_resp ipz_rqueue; | ||
312 | struct h_galpas galpas; | ||
313 | }; | ||
314 | |||
315 | struct ehca_alloc_cq_parms { | ||
316 | u32 nr_cqe; | ||
317 | u32 act_nr_of_entries; | ||
318 | u32 act_pages; | ||
319 | struct ipz_eq_handle eq_handle; | ||
320 | }; | ||
321 | |||
322 | struct ehca_alloc_qp_parms { | ||
323 | int servicetype; | ||
324 | int sigtype; | ||
325 | int daqp_ctrl; | ||
326 | int max_send_sge; | ||
327 | int max_recv_sge; | ||
328 | int ud_av_l_key_ctl; | ||
329 | |||
330 | u16 act_nr_send_wqes; | ||
331 | u16 act_nr_recv_wqes; | ||
332 | u8 act_nr_recv_sges; | ||
333 | u8 act_nr_send_sges; | ||
334 | |||
335 | u32 nr_rq_pages; | ||
336 | u32 nr_sq_pages; | ||
337 | |||
338 | struct ipz_eq_handle ipz_eq_handle; | ||
339 | struct ipz_pd pd; | ||
340 | }; | ||
341 | |||
342 | int ehca_cq_assign_qp(struct ehca_cq *cq, struct ehca_qp *qp); | ||
343 | int ehca_cq_unassign_qp(struct ehca_cq *cq, unsigned int qp_num); | ||
344 | struct ehca_qp* ehca_cq_get_qp(struct ehca_cq *cq, int qp_num); | ||
345 | |||
346 | #endif | ||