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>
8 * Joachim Fenkes <fenkes@de.ibm.com>
10 * Copyright (c) 2005 IBM Corporation
12 * All rights reserved.
14 * This source code is distributed under a dual license of GPL v2.0 and OpenIB
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions are met:
22 * Redistributions of source code must retain the above copyright notice, this
23 * list of conditions and the following disclaimer.
25 * Redistributions in binary form must reproduce the above copyright notice,
26 * this list of conditions and the following disclaimer in the documentation
27 * and/or other materials
28 * provided with the distribution.
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
34 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
37 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
38 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 * POSSIBILITY OF SUCH DAMAGE.
43 #ifndef __EHCA_CLASSES_H__
44 #define __EHCA_CLASSES_H__
56 #include <linux/wait.h>
58 #include <rdma/ib_verbs.h>
59 #include <rdma/ib_user_verbs.h>
62 #include "ehca_classes_pSeries.h"
64 #include "ipz_pt_fn.h"
68 #define EHCA_EQE_CACHE_SIZE 20
70 struct ehca_eqe_cache_entry {
77 struct ipz_queue ipz_queue;
78 struct ipz_eq_handle ipz_eq_handle;
79 struct work_struct work;
80 struct h_galpas galpas;
84 struct tasklet_struct interrupt_task;
86 spinlock_t irq_spinlock;
87 struct ehca_eqe_cache_entry eqe_cache[EHCA_EQE_CACHE_SIZE];
91 struct ib_cq *ibcq_aqp1;
92 struct ib_qp *ibqp_aqp1;
94 enum ib_port_state port_state;
98 struct ib_device ib_device;
99 struct ibmebus_dev *ibmebus_dev;
102 struct list_head shca_list;
103 struct ipz_adapter_handle ipz_hca_handle;
104 struct ehca_sport sport[2];
107 struct ehca_mr *maxmr;
109 struct h_galpas galpas;
110 struct mutex modify_mutex;
121 enum ehca_ext_qp_type {
131 struct ib_srq ib_srq;
134 enum ehca_ext_qp_type ext_type;
135 struct ipz_queue ipz_squeue;
136 struct ipz_queue ipz_rqueue;
137 struct h_galpas galpas;
141 spinlock_t spinlock_s;
142 spinlock_t spinlock_r;
143 u32 sq_max_inline_data_size;
144 struct ipz_qp_handle ipz_qp_handle;
146 struct ib_qp_init_attr init_attr;
147 struct ehca_cq *send_cq;
148 struct ehca_cq *recv_cq;
149 unsigned int sqerr_purgeflag;
150 struct hlist_node list_entries;
151 /* mmap counter for resources mapped into user space */
157 #define IS_SRQ(qp) (qp->ext_type == EQPT_SRQ)
158 #define HAS_SQ(qp) (qp->ext_type != EQPT_SRQ)
159 #define HAS_RQ(qp) (qp->ext_type != EQPT_SRQBASE)
161 /* must be power of 2 */
162 #define QP_HASHTAB_LEN 8
166 struct ipz_queue ipz_queue;
167 struct h_galpas galpas;
172 struct ipz_cq_handle ipz_cq_handle;
175 struct hlist_head qp_hashtab[QP_HASHTAB_LEN];
176 struct list_head entry;
177 u32 nr_callbacks; /* #events assigned to cpu by scaling code */
178 u32 nr_events; /* #events seen */
179 wait_queue_head_t wait_completion;
180 spinlock_t task_lock;
182 /* mmap counter for resources mapped into user space */
188 EHCA_MR_FLAG_FMR = 0x80000000, /* FMR, created with ehca_alloc_fmr */
189 EHCA_MR_FLAG_MAXMR = 0x40000000, /* max-MR */
194 struct ib_mr ib_mr; /* must always be first in ehca_mr */
195 struct ib_fmr ib_fmr; /* must always be first in ehca_mr */
197 struct ib_umem *umem;
200 enum ehca_mr_flag flags;
201 u32 num_pages; /* number of MR pages */
202 u32 num_4k; /* number of 4k "page" portions to form MR */
203 int acl; /* ACL (stored here for usage in reregister) */
204 u64 *start; /* virtual start address (stored here for */
205 /* usage in reregister) */
206 u64 size; /* size (stored here for usage in reregister) */
207 u32 fmr_page_size; /* page size for FMR */
208 u32 fmr_max_pages; /* max pages for FMR */
209 u32 fmr_max_maps; /* max outstanding maps for FMR */
210 u32 fmr_map_cnt; /* map counter for FMR */
211 /* fw specific data */
212 struct ipz_mrmw_handle ipz_mr_handle; /* MR handle for h-calls */
213 struct h_galpas galpas;
214 /* data for userspace bridge */
220 struct ib_mw ib_mw; /* gen2 mw, must always be first in ehca_mw */
223 u8 never_bound; /* indication MW was never bound */
224 struct ipz_mrmw_handle ipz_mw_handle; /* MW handle for h-calls */
225 struct h_galpas galpas;
228 enum ehca_mr_pgi_type {
229 EHCA_MR_PGI_PHYS = 1, /* type of ehca_reg_phys_mr,
230 * ehca_rereg_phys_mr,
231 * ehca_reg_internal_maxmr */
232 EHCA_MR_PGI_USER = 2, /* type of ehca_reg_user_mr */
233 EHCA_MR_PGI_FMR = 3 /* type of ehca_map_phys_fmr */
236 struct ehca_mr_pginfo {
237 enum ehca_mr_pgi_type type;
240 u64 num_4k; /* number of 4k "page" portions */
241 u64 page_4k_cnt; /* counter for 4k "page" portions */
242 u64 next_4k; /* next 4k "page" portion in buffer/chunk/listelem */
244 /* type EHCA_MR_PGI_PHYS section */
246 struct ib_phys_buf *phys_buf_array;
249 /* type EHCA_MR_PGI_USER section */
250 struct ib_umem *region;
251 struct ib_umem_chunk *next_chunk;
254 /* type EHCA_MR_PGI_FMR section */
257 /* next_4k also used within EHCA_MR_PGI_FMR */
260 /* output parameters for MR/FMR hipz calls */
261 struct ehca_mr_hipzout_parms {
262 struct ipz_mrmw_handle handle;
270 /* output parameters for MW hipz calls */
271 struct ehca_mw_hipzout_parms {
272 struct ipz_mrmw_handle handle;
278 struct ehca_ud_av av;
281 struct ehca_ucontext {
282 struct ib_ucontext ib_ucontext;
285 int ehca_init_pd_cache(void);
286 void ehca_cleanup_pd_cache(void);
287 int ehca_init_cq_cache(void);
288 void ehca_cleanup_cq_cache(void);
289 int ehca_init_qp_cache(void);
290 void ehca_cleanup_qp_cache(void);
291 int ehca_init_av_cache(void);
292 void ehca_cleanup_av_cache(void);
293 int ehca_init_mrmw_cache(void);
294 void ehca_cleanup_mrmw_cache(void);
296 extern spinlock_t ehca_qp_idr_lock;
297 extern spinlock_t ehca_cq_idr_lock;
298 extern spinlock_t hcall_lock;
299 extern struct idr ehca_qp_idr;
300 extern struct idr ehca_cq_idr;
302 extern int ehca_static_rate;
303 extern int ehca_port_act_time;
304 extern int ehca_use_hp_mr;
305 extern int ehca_scaling_code;
307 struct ipzu_queue_resp {
308 u32 qe_size; /* queue entry size */
310 u32 queue_length; /* queue length allocated in bytes */
313 u32 dummy; /* padding for 8 byte alignment */
316 struct ehca_create_cq_resp {
319 struct ipzu_queue_resp ipz_queue;
322 struct ehca_create_qp_resp {
328 /* qp_num assigned by ehca: sqp0/1 may have got different numbers */
330 u32 dummy; /* padding for 8 byte alignment */
331 struct ipzu_queue_resp ipz_squeue;
332 struct ipzu_queue_resp ipz_rqueue;
335 struct ehca_alloc_cq_parms {
337 u32 act_nr_of_entries;
339 struct ipz_eq_handle eq_handle;
342 enum ehca_service_type {
349 enum ehca_ll_comp_flags {
350 LLQP_SEND_COMP = 0x20,
351 LLQP_RECV_COMP = 0x40,
352 LLQP_COMP_MASK = 0x60,
355 struct ehca_alloc_qp_parms {
356 /* input parameters */
357 enum ehca_service_type servicetype;
359 enum ehca_ext_qp_type ext_type;
360 enum ehca_ll_comp_flags ll_comp_flags;
362 int max_send_wr, max_recv_wr;
363 int max_send_sge, max_recv_sge;
367 struct ipz_eq_handle eq_handle;
369 struct ipz_cq_handle send_cq_handle, recv_cq_handle;
371 u32 srq_qpn, srq_token, srq_limit;
373 /* output parameters */
375 struct ipz_qp_handle qp_handle;
376 struct h_galpas galpas;
378 u16 act_nr_send_wqes;
379 u16 act_nr_recv_wqes;
387 int ehca_cq_assign_qp(struct ehca_cq *cq, struct ehca_qp *qp);
388 int ehca_cq_unassign_qp(struct ehca_cq *cq, unsigned int qp_num);
389 struct ehca_qp* ehca_cq_get_qp(struct ehca_cq *cq, int qp_num);