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__
55 #include <linux/wait.h>
56 #include <linux/mutex.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];
90 struct ehca_sma_attr {
91 u16 lid, lmc, sm_sl, sm_lid;
92 u16 pkey_tbl_len, pkeys[16];
96 struct ib_cq *ibcq_aqp1;
97 struct ib_qp *ibqp_aqp1;
98 enum ib_port_state port_state;
99 struct ehca_sma_attr saved_attr;
102 #define HCA_CAP_MR_PGSIZE_4K 0x80000000
103 #define HCA_CAP_MR_PGSIZE_64K 0x40000000
104 #define HCA_CAP_MR_PGSIZE_1M 0x20000000
105 #define HCA_CAP_MR_PGSIZE_16M 0x10000000
108 struct ib_device ib_device;
109 struct of_device *ofdev;
112 struct list_head shca_list;
113 struct ipz_adapter_handle ipz_hca_handle;
114 struct ehca_sport sport[2];
117 struct ehca_mr *maxmr;
119 struct h_galpas galpas;
120 struct mutex modify_mutex;
122 /* MR pgsize: bit 0-3 means 4K, 64K, 1M, 16M respectively */
123 u32 hca_cap_mr_pgsize;
131 /* small queue mgmt */
133 struct list_head free[2];
134 struct list_head full[2];
137 enum ehca_ext_qp_type {
147 struct ib_srq ib_srq;
150 enum ehca_ext_qp_type ext_type;
151 struct ipz_queue ipz_squeue;
152 struct ipz_queue ipz_rqueue;
153 struct h_galpas galpas;
157 spinlock_t spinlock_s;
158 spinlock_t spinlock_r;
159 u32 sq_max_inline_data_size;
160 struct ipz_qp_handle ipz_qp_handle;
162 struct ib_qp_init_attr init_attr;
163 struct ehca_cq *send_cq;
164 struct ehca_cq *recv_cq;
165 unsigned int sqerr_purgeflag;
166 struct hlist_node list_entries;
167 /* mmap counter for resources mapped into user space */
173 #define IS_SRQ(qp) (qp->ext_type == EQPT_SRQ)
174 #define HAS_SQ(qp) (qp->ext_type != EQPT_SRQ)
175 #define HAS_RQ(qp) (qp->ext_type != EQPT_SRQBASE)
177 /* must be power of 2 */
178 #define QP_HASHTAB_LEN 8
182 struct ipz_queue ipz_queue;
183 struct h_galpas galpas;
188 struct ipz_cq_handle ipz_cq_handle;
191 struct hlist_head qp_hashtab[QP_HASHTAB_LEN];
192 struct list_head entry;
193 u32 nr_callbacks; /* #events assigned to cpu by scaling code */
194 atomic_t nr_events; /* #events seen */
195 wait_queue_head_t wait_completion;
196 spinlock_t task_lock;
198 /* mmap counter for resources mapped into user space */
204 EHCA_MR_FLAG_FMR = 0x80000000, /* FMR, created with ehca_alloc_fmr */
205 EHCA_MR_FLAG_MAXMR = 0x40000000, /* max-MR */
210 struct ib_mr ib_mr; /* must always be first in ehca_mr */
211 struct ib_fmr ib_fmr; /* must always be first in ehca_mr */
213 struct ib_umem *umem;
216 enum ehca_mr_flag flags;
217 u32 num_kpages; /* number of kernel pages */
218 u32 num_hwpages; /* number of hw pages to form MR */
219 u64 hwpage_size; /* hw page size used for this MR */
220 int acl; /* ACL (stored here for usage in reregister) */
221 u64 *start; /* virtual start address (stored here for */
222 /* usage in reregister) */
223 u64 size; /* size (stored here for usage in reregister) */
224 u32 fmr_page_size; /* page size for FMR */
225 u32 fmr_max_pages; /* max pages for FMR */
226 u32 fmr_max_maps; /* max outstanding maps for FMR */
227 u32 fmr_map_cnt; /* map counter for FMR */
228 /* fw specific data */
229 struct ipz_mrmw_handle ipz_mr_handle; /* MR handle for h-calls */
230 struct h_galpas galpas;
234 struct ib_mw ib_mw; /* gen2 mw, must always be first in ehca_mw */
237 u8 never_bound; /* indication MW was never bound */
238 struct ipz_mrmw_handle ipz_mw_handle; /* MW handle for h-calls */
239 struct h_galpas galpas;
242 enum ehca_mr_pgi_type {
243 EHCA_MR_PGI_PHYS = 1, /* type of ehca_reg_phys_mr,
244 * ehca_rereg_phys_mr,
245 * ehca_reg_internal_maxmr */
246 EHCA_MR_PGI_USER = 2, /* type of ehca_reg_user_mr */
247 EHCA_MR_PGI_FMR = 3 /* type of ehca_map_phys_fmr */
250 struct ehca_mr_pginfo {
251 enum ehca_mr_pgi_type type;
254 u64 hwpage_size; /* hw page size used for this MR */
255 u64 num_hwpages; /* number of hw pages */
256 u64 hwpage_cnt; /* counter for hw pages */
257 u64 next_hwpage; /* next hw page in buffer/chunk/listelem */
260 struct { /* type EHCA_MR_PGI_PHYS section */
262 struct ib_phys_buf *phys_buf_array;
265 struct { /* type EHCA_MR_PGI_USER section */
266 struct ib_umem *region;
267 struct ib_umem_chunk *next_chunk;
270 struct { /* type EHCA_MR_PGI_FMR section */
278 /* output parameters for MR/FMR hipz calls */
279 struct ehca_mr_hipzout_parms {
280 struct ipz_mrmw_handle handle;
288 /* output parameters for MW hipz calls */
289 struct ehca_mw_hipzout_parms {
290 struct ipz_mrmw_handle handle;
296 struct ehca_ud_av av;
299 struct ehca_ucontext {
300 struct ib_ucontext ib_ucontext;
303 int ehca_init_pd_cache(void);
304 void ehca_cleanup_pd_cache(void);
305 int ehca_init_cq_cache(void);
306 void ehca_cleanup_cq_cache(void);
307 int ehca_init_qp_cache(void);
308 void ehca_cleanup_qp_cache(void);
309 int ehca_init_av_cache(void);
310 void ehca_cleanup_av_cache(void);
311 int ehca_init_mrmw_cache(void);
312 void ehca_cleanup_mrmw_cache(void);
313 int ehca_init_small_qp_cache(void);
314 void ehca_cleanup_small_qp_cache(void);
316 extern rwlock_t ehca_qp_idr_lock;
317 extern rwlock_t ehca_cq_idr_lock;
318 extern struct idr ehca_qp_idr;
319 extern struct idr ehca_cq_idr;
321 extern int ehca_static_rate;
322 extern int ehca_port_act_time;
323 extern int ehca_use_hp_mr;
324 extern int ehca_scaling_code;
325 extern int ehca_lock_hcalls;
327 struct ipzu_queue_resp {
328 u32 qe_size; /* queue entry size */
330 u32 queue_length; /* queue length allocated in bytes */
333 u32 offset; /* save offset within a page for small_qp */
336 struct ehca_create_cq_resp {
339 struct ipzu_queue_resp ipz_queue;
344 struct ehca_create_qp_resp {
350 /* qp_num assigned by ehca: sqp0/1 may have got different numbers */
354 struct ipzu_queue_resp ipz_squeue;
355 struct ipzu_queue_resp ipz_rqueue;
358 struct ehca_alloc_cq_parms {
360 u32 act_nr_of_entries;
362 struct ipz_eq_handle eq_handle;
365 enum ehca_service_type {
372 enum ehca_ll_comp_flags {
373 LLQP_SEND_COMP = 0x20,
374 LLQP_RECV_COMP = 0x40,
375 LLQP_COMP_MASK = 0x60,
378 struct ehca_alloc_queue_parms {
379 /* input parameters */
385 /* output parameters */
388 u32 queue_size; /* bytes for small queues, pages otherwise */
391 struct ehca_alloc_qp_parms {
392 struct ehca_alloc_queue_parms squeue;
393 struct ehca_alloc_queue_parms rqueue;
395 /* input parameters */
396 enum ehca_service_type servicetype;
399 enum ehca_ext_qp_type ext_type;
400 enum ehca_ll_comp_flags ll_comp_flags;
404 struct ipz_eq_handle eq_handle;
406 struct ipz_cq_handle send_cq_handle, recv_cq_handle;
408 u32 srq_qpn, srq_token, srq_limit;
410 /* output parameters */
412 struct ipz_qp_handle qp_handle;
413 struct h_galpas galpas;
416 int ehca_cq_assign_qp(struct ehca_cq *cq, struct ehca_qp *qp);
417 int ehca_cq_unassign_qp(struct ehca_cq *cq, unsigned int qp_num);
418 struct ehca_qp *ehca_cq_get_qp(struct ehca_cq *cq, int qp_num);