2 * IBM eServer eHCA Infiniband device driver for Linux on POWER
4 * Struct definition for eHCA internal structures
6 * Authors: Heiko J Schick <schickhj@de.ibm.com>
7 * Christoph Raisch <raisch@de.ibm.com>
9 * Copyright (c) 2005 IBM Corporation
11 * All rights reserved.
13 * This source code is distributed under a dual license of GPL v2.0 and OpenIB
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are met:
21 * Redistributions of source code must retain the above copyright notice, this
22 * list of conditions and the following disclaimer.
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.
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.
42 #ifndef __EHCA_CLASSES_H__
43 #define __EHCA_CLASSES_H__
45 #include "ehca_classes.h"
46 #include "ipz_pt_fn.h"
58 #include "ehca_classes_pSeries.h"
61 #include <rdma/ib_verbs.h>
62 #include <rdma/ib_user_verbs.h>
68 struct ipz_queue ipz_queue;
69 struct ipz_eq_handle ipz_eq_handle;
70 struct work_struct work;
71 struct h_galpas galpas;
75 struct tasklet_struct interrupt_task;
80 struct ib_cq *ibcq_aqp1;
81 struct ib_qp *ibqp_aqp1;
83 enum ib_port_state port_state;
87 struct ib_device ib_device;
88 struct ibmebus_dev *ibmebus_dev;
91 struct list_head shca_list;
92 struct ipz_adapter_handle ipz_hca_handle;
93 struct ehca_sport sport[2];
96 struct ehca_mr *maxmr;
98 struct h_galpas galpas;
110 struct ipz_queue ipz_squeue;
111 struct ipz_queue ipz_rqueue;
112 struct h_galpas galpas;
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;
121 struct ib_qp_init_attr init_attr;
122 struct ehca_cq *send_cq;
123 struct ehca_cq *recv_cq;
124 unsigned int sqerr_purgeflag;
125 struct hlist_node list_entries;
126 /* mmap counter for resources mapped into user space */
132 /* must be power of 2 */
133 #define QP_HASHTAB_LEN 8
137 struct ipz_queue ipz_queue;
138 struct h_galpas galpas;
143 struct ipz_cq_handle ipz_cq_handle;
146 struct hlist_head qp_hashtab[QP_HASHTAB_LEN];
147 struct list_head entry;
149 spinlock_t task_lock;
151 /* mmap counter for resources mapped into user space */
157 EHCA_MR_FLAG_FMR = 0x80000000, /* FMR, created with ehca_alloc_fmr */
158 EHCA_MR_FLAG_MAXMR = 0x40000000, /* max-MR */
163 struct ib_mr ib_mr; /* must always be first in ehca_mr */
164 struct ib_fmr ib_fmr; /* must always be first in ehca_mr */
168 enum ehca_mr_flag flags;
169 u32 num_pages; /* number of MR pages */
170 u32 num_4k; /* number of 4k "page" portions to form MR */
171 int acl; /* ACL (stored here for usage in reregister) */
172 u64 *start; /* virtual start address (stored here for */
173 /* usage in reregister) */
174 u64 size; /* size (stored here for usage in reregister) */
175 u32 fmr_page_size; /* page size for FMR */
176 u32 fmr_max_pages; /* max pages for FMR */
177 u32 fmr_max_maps; /* max outstanding maps for FMR */
178 u32 fmr_map_cnt; /* map counter for FMR */
179 /* fw specific data */
180 struct ipz_mrmw_handle ipz_mr_handle; /* MR handle for h-calls */
181 struct h_galpas galpas;
182 /* data for userspace bridge */
188 struct ib_mw ib_mw; /* gen2 mw, must always be first in ehca_mw */
191 u8 never_bound; /* indication MW was never bound */
192 struct ipz_mrmw_handle ipz_mw_handle; /* MW handle for h-calls */
193 struct h_galpas galpas;
196 enum ehca_mr_pgi_type {
197 EHCA_MR_PGI_PHYS = 1, /* type of ehca_reg_phys_mr,
198 * ehca_rereg_phys_mr,
199 * ehca_reg_internal_maxmr */
200 EHCA_MR_PGI_USER = 2, /* type of ehca_reg_user_mr */
201 EHCA_MR_PGI_FMR = 3 /* type of ehca_map_phys_fmr */
204 struct ehca_mr_pginfo {
205 enum ehca_mr_pgi_type type;
208 u64 num_4k; /* number of 4k "page" portions */
209 u64 page_4k_cnt; /* counter for 4k "page" portions */
210 u64 next_4k; /* next 4k "page" portion in buffer/chunk/listelem */
212 /* type EHCA_MR_PGI_PHYS section */
214 struct ib_phys_buf *phys_buf_array;
217 /* type EHCA_MR_PGI_USER section */
218 struct ib_umem *region;
219 struct ib_umem_chunk *next_chunk;
222 /* type EHCA_MR_PGI_FMR section */
225 /* next_4k also used within EHCA_MR_PGI_FMR */
228 /* output parameters for MR/FMR hipz calls */
229 struct ehca_mr_hipzout_parms {
230 struct ipz_mrmw_handle handle;
238 /* output parameters for MW hipz calls */
239 struct ehca_mw_hipzout_parms {
240 struct ipz_mrmw_handle handle;
246 struct ehca_ud_av av;
249 struct ehca_ucontext {
250 struct ib_ucontext ib_ucontext;
253 int ehca_init_pd_cache(void);
254 void ehca_cleanup_pd_cache(void);
255 int ehca_init_cq_cache(void);
256 void ehca_cleanup_cq_cache(void);
257 int ehca_init_qp_cache(void);
258 void ehca_cleanup_qp_cache(void);
259 int ehca_init_av_cache(void);
260 void ehca_cleanup_av_cache(void);
261 int ehca_init_mrmw_cache(void);
262 void ehca_cleanup_mrmw_cache(void);
264 extern spinlock_t ehca_qp_idr_lock;
265 extern spinlock_t ehca_cq_idr_lock;
266 extern struct idr ehca_qp_idr;
267 extern struct idr ehca_cq_idr;
269 extern int ehca_static_rate;
270 extern int ehca_port_act_time;
271 extern int ehca_use_hp_mr;
273 struct ipzu_queue_resp {
274 u32 qe_size; /* queue entry size */
276 u32 queue_length; /* queue length allocated in bytes */
279 u32 dummy; /* padding for 8 byte alignment */
282 struct ehca_create_cq_resp {
285 struct ipzu_queue_resp ipz_queue;
288 struct ehca_create_qp_resp {
293 /* qp_num assigned by ehca: sqp0/1 may have got different numbers */
295 u32 dummy; /* padding for 8 byte alignment */
296 struct ipzu_queue_resp ipz_squeue;
297 struct ipzu_queue_resp ipz_rqueue;
300 struct ehca_alloc_cq_parms {
302 u32 act_nr_of_entries;
304 struct ipz_eq_handle eq_handle;
307 struct ehca_alloc_qp_parms {
315 u16 act_nr_send_wqes;
316 u16 act_nr_recv_wqes;
323 struct ipz_eq_handle ipz_eq_handle;
327 int ehca_cq_assign_qp(struct ehca_cq *cq, struct ehca_qp *qp);
328 int ehca_cq_unassign_qp(struct ehca_cq *cq, unsigned int qp_num);
329 struct ehca_qp* ehca_cq_get_qp(struct ehca_cq *cq, int qp_num);