Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 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> |
Joachim Fenkes | a6a1294 | 2007-07-09 15:25:10 +0200 | [diff] [blame] | 8 | * Joachim Fenkes <fenkes@de.ibm.com> |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 9 | * |
| 10 | * Copyright (c) 2005 IBM Corporation |
| 11 | * |
| 12 | * All rights reserved. |
| 13 | * |
| 14 | * This source code is distributed under a dual license of GPL v2.0 and OpenIB |
| 15 | * BSD. |
| 16 | * |
| 17 | * OpenIB BSD License |
| 18 | * |
| 19 | * Redistribution and use in source and binary forms, with or without |
| 20 | * modification, are permitted provided that the following conditions are met: |
| 21 | * |
| 22 | * Redistributions of source code must retain the above copyright notice, this |
| 23 | * list of conditions and the following disclaimer. |
| 24 | * |
| 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. |
| 29 | * |
| 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. |
| 41 | */ |
| 42 | |
| 43 | #ifndef __EHCA_CLASSES_H__ |
| 44 | #define __EHCA_CLASSES_H__ |
| 45 | |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 46 | struct ehca_module; |
| 47 | struct ehca_qp; |
| 48 | struct ehca_cq; |
| 49 | struct ehca_eq; |
| 50 | struct ehca_mr; |
| 51 | struct ehca_mw; |
| 52 | struct ehca_pd; |
| 53 | struct ehca_av; |
| 54 | |
Hoang-Nam Nguyen | 3172679 | 2007-02-28 18:01:02 +0100 | [diff] [blame] | 55 | #include <linux/wait.h> |
Roland Dreier | 1fea391 | 2007-10-09 19:59:05 -0700 | [diff] [blame] | 56 | #include <linux/mutex.h> |
Hoang-Nam Nguyen | 3172679 | 2007-02-28 18:01:02 +0100 | [diff] [blame] | 57 | |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 58 | #include <rdma/ib_verbs.h> |
| 59 | #include <rdma/ib_user_verbs.h> |
| 60 | |
Hoang-Nam Nguyen | 78d8d5f | 2007-02-15 17:06:33 +0100 | [diff] [blame] | 61 | #ifdef CONFIG_PPC64 |
| 62 | #include "ehca_classes_pSeries.h" |
| 63 | #endif |
| 64 | #include "ipz_pt_fn.h" |
| 65 | #include "ehca_qes.h" |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 66 | #include "ehca_irq.h" |
| 67 | |
Hoang-Nam Nguyen | 78d8d5f | 2007-02-15 17:06:33 +0100 | [diff] [blame] | 68 | #define EHCA_EQE_CACHE_SIZE 20 |
Stefan Roscher | d227fa7 | 2008-04-29 13:46:53 -0700 | [diff] [blame] | 69 | #define EHCA_MAX_NUM_QUEUES 0xffff |
Hoang-Nam Nguyen | 78d8d5f | 2007-02-15 17:06:33 +0100 | [diff] [blame] | 70 | |
| 71 | struct ehca_eqe_cache_entry { |
| 72 | struct ehca_eqe *eqe; |
| 73 | struct ehca_cq *cq; |
| 74 | }; |
| 75 | |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 76 | struct ehca_eq { |
| 77 | u32 length; |
| 78 | struct ipz_queue ipz_queue; |
| 79 | struct ipz_eq_handle ipz_eq_handle; |
| 80 | struct work_struct work; |
| 81 | struct h_galpas galpas; |
| 82 | int is_initialized; |
| 83 | struct ehca_pfeq pf; |
| 84 | spinlock_t spinlock; |
| 85 | struct tasklet_struct interrupt_task; |
| 86 | u32 ist; |
Hoang-Nam Nguyen | 78d8d5f | 2007-02-15 17:06:33 +0100 | [diff] [blame] | 87 | spinlock_t irq_spinlock; |
| 88 | struct ehca_eqe_cache_entry eqe_cache[EHCA_EQE_CACHE_SIZE]; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
Joachim Fenkes | 8705ce5 | 2007-07-09 15:32:22 +0200 | [diff] [blame] | 91 | struct ehca_sma_attr { |
| 92 | u16 lid, lmc, sm_sl, sm_lid; |
| 93 | u16 pkey_tbl_len, pkeys[16]; |
| 94 | }; |
| 95 | |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 96 | struct ehca_sport { |
| 97 | struct ib_cq *ibcq_aqp1; |
Hoang-Nam Nguyen | b8b50e3 | 2008-01-17 15:04:32 +0100 | [diff] [blame] | 98 | struct ib_qp *ibqp_sqp[2]; |
Hoang-Nam Nguyen | bbdd267 | 2008-01-17 15:05:45 +0100 | [diff] [blame] | 99 | /* lock to serialze modify_qp() calls for sqp in normal |
| 100 | * and irq path (when event PORT_ACTIVE is received first time) |
| 101 | */ |
| 102 | spinlock_t mod_sqp_lock; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 103 | enum ib_port_state port_state; |
Joachim Fenkes | 8705ce5 | 2007-07-09 15:32:22 +0200 | [diff] [blame] | 104 | struct ehca_sma_attr saved_attr; |
Hoang-Nam Nguyen | 2b5e6b1 | 2008-01-25 21:18:27 +0100 | [diff] [blame] | 105 | u32 pma_qp_nr; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 106 | }; |
| 107 | |
Hoang-Nam Nguyen | 08c283a | 2007-09-13 18:14:58 +0200 | [diff] [blame] | 108 | #define HCA_CAP_MR_PGSIZE_4K 0x80000000 |
| 109 | #define HCA_CAP_MR_PGSIZE_64K 0x40000000 |
| 110 | #define HCA_CAP_MR_PGSIZE_1M 0x20000000 |
| 111 | #define HCA_CAP_MR_PGSIZE_16M 0x10000000 |
Hoang-Nam Nguyen | 5bb7d92 | 2007-07-20 16:01:51 +0200 | [diff] [blame] | 112 | |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 113 | struct ehca_shca { |
| 114 | struct ib_device ib_device; |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 115 | struct of_device *ofdev; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 116 | u8 num_ports; |
| 117 | int hw_level; |
| 118 | struct list_head shca_list; |
| 119 | struct ipz_adapter_handle ipz_hca_handle; |
| 120 | struct ehca_sport sport[2]; |
| 121 | struct ehca_eq eq; |
| 122 | struct ehca_eq neq; |
| 123 | struct ehca_mr *maxmr; |
| 124 | struct ehca_pd *pd; |
| 125 | struct h_galpas galpas; |
Joachim Fenkes | c4ed790 | 2007-04-24 17:44:31 +0200 | [diff] [blame] | 126 | struct mutex modify_mutex; |
Joachim Fenkes | 91f13aa | 2007-07-09 15:21:45 +0200 | [diff] [blame] | 127 | u64 hca_cap; |
Hoang-Nam Nguyen | 5bb7d92 | 2007-07-20 16:01:51 +0200 | [diff] [blame] | 128 | /* MR pgsize: bit 0-3 means 4K, 64K, 1M, 16M respectively */ |
| 129 | u32 hca_cap_mr_pgsize; |
Joachim Fenkes | 91f13aa | 2007-07-09 15:21:45 +0200 | [diff] [blame] | 130 | int max_mtu; |
Stefan Roscher | 19f4282 | 2008-10-22 15:52:31 -0700 | [diff] [blame^] | 131 | int max_num_qps; |
| 132 | int max_num_cqs; |
Stefan Roscher | d227fa7 | 2008-04-29 13:46:53 -0700 | [diff] [blame] | 133 | atomic_t num_cqs; |
| 134 | atomic_t num_qps; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | struct ehca_pd { |
| 138 | struct ib_pd ib_pd; |
| 139 | struct ipz_pd fw_pd; |
Stefan Roscher | e2f81da | 2007-07-20 16:04:17 +0200 | [diff] [blame] | 140 | /* small queue mgmt */ |
| 141 | struct mutex lock; |
| 142 | struct list_head free[2]; |
| 143 | struct list_head full[2]; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 144 | }; |
| 145 | |
Joachim Fenkes | a6a1294 | 2007-07-09 15:25:10 +0200 | [diff] [blame] | 146 | enum ehca_ext_qp_type { |
| 147 | EQPT_NORMAL = 0, |
| 148 | EQPT_LLQP = 1, |
| 149 | EQPT_SRQBASE = 2, |
| 150 | EQPT_SRQ = 3, |
| 151 | }; |
| 152 | |
Hoang-Nam Nguyen | bbdd267 | 2008-01-17 15:05:45 +0100 | [diff] [blame] | 153 | /* struct to cache modify_qp()'s parms for GSI/SMI qp */ |
| 154 | struct ehca_mod_qp_parm { |
| 155 | int mask; |
| 156 | struct ib_qp_attr attr; |
| 157 | }; |
| 158 | |
| 159 | #define EHCA_MOD_QP_PARM_MAX 4 |
| 160 | |
Alexander Schmidt | 6773f07 | 2008-08-12 15:46:30 +0200 | [diff] [blame] | 161 | #define QMAP_IDX_MASK 0xFFFFULL |
| 162 | |
| 163 | /* struct for tracking if cqes have been reported to the application */ |
| 164 | struct ehca_qmap_entry { |
| 165 | u16 app_wr_id; |
| 166 | u16 reported; |
| 167 | }; |
| 168 | |
Alexander Schmidt | b9012e0 | 2008-09-20 20:05:21 -0700 | [diff] [blame] | 169 | struct ehca_queue_map { |
| 170 | struct ehca_qmap_entry *map; |
| 171 | unsigned int entries; |
| 172 | unsigned int tail; |
| 173 | unsigned int left_to_poll; |
| 174 | }; |
| 175 | |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 176 | struct ehca_qp { |
Joachim Fenkes | a6a1294 | 2007-07-09 15:25:10 +0200 | [diff] [blame] | 177 | union { |
| 178 | struct ib_qp ib_qp; |
| 179 | struct ib_srq ib_srq; |
| 180 | }; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 181 | u32 qp_type; |
Joachim Fenkes | a6a1294 | 2007-07-09 15:25:10 +0200 | [diff] [blame] | 182 | enum ehca_ext_qp_type ext_type; |
Joachim Fenkes | 863fb09 | 2008-04-23 11:55:45 -0700 | [diff] [blame] | 183 | enum ib_qp_state state; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 184 | struct ipz_queue ipz_squeue; |
Alexander Schmidt | b9012e0 | 2008-09-20 20:05:21 -0700 | [diff] [blame] | 185 | struct ehca_queue_map sq_map; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 186 | struct ipz_queue ipz_rqueue; |
Alexander Schmidt | b9012e0 | 2008-09-20 20:05:21 -0700 | [diff] [blame] | 187 | struct ehca_queue_map rq_map; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 188 | struct h_galpas galpas; |
| 189 | u32 qkey; |
| 190 | u32 real_qp_num; |
| 191 | u32 token; |
| 192 | spinlock_t spinlock_s; |
| 193 | spinlock_t spinlock_r; |
| 194 | u32 sq_max_inline_data_size; |
| 195 | struct ipz_qp_handle ipz_qp_handle; |
| 196 | struct ehca_pfqp pf; |
| 197 | struct ib_qp_init_attr init_attr; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 198 | struct ehca_cq *send_cq; |
| 199 | struct ehca_cq *recv_cq; |
| 200 | unsigned int sqerr_purgeflag; |
| 201 | struct hlist_node list_entries; |
Hoang-Nam Nguyen | bbdd267 | 2008-01-17 15:05:45 +0100 | [diff] [blame] | 202 | /* array to cache modify_qp()'s parms for GSI/SMI qp */ |
| 203 | struct ehca_mod_qp_parm *mod_qp_parm; |
| 204 | int mod_qp_parm_idx; |
Hoang-Nam Nguyen | 4c34bdf | 2007-01-24 00:13:35 +0100 | [diff] [blame] | 205 | /* mmap counter for resources mapped into user space */ |
| 206 | u32 mm_count_squeue; |
| 207 | u32 mm_count_rqueue; |
| 208 | u32 mm_count_galpa; |
Joachim Fenkes | 2ec8e66 | 2008-01-17 15:07:24 +0100 | [diff] [blame] | 209 | /* unsolicited ack circumvention */ |
| 210 | int unsol_ack_circ; |
| 211 | int mtu_shift; |
| 212 | u32 message_count; |
| 213 | u32 packet_count; |
Stefan Roscher | 12137c5 | 2008-05-07 11:35:06 -0700 | [diff] [blame] | 214 | atomic_t nr_events; /* events seen */ |
| 215 | wait_queue_head_t wait_completion; |
Joachim Fenkes | 5b673b7 | 2008-07-22 14:18:07 -0700 | [diff] [blame] | 216 | int mig_armed; |
Alexander Schmidt | b9012e0 | 2008-09-20 20:05:21 -0700 | [diff] [blame] | 217 | struct list_head sq_err_node; |
| 218 | struct list_head rq_err_node; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 219 | }; |
| 220 | |
Joachim Fenkes | a6a1294 | 2007-07-09 15:25:10 +0200 | [diff] [blame] | 221 | #define IS_SRQ(qp) (qp->ext_type == EQPT_SRQ) |
| 222 | #define HAS_SQ(qp) (qp->ext_type != EQPT_SRQ) |
| 223 | #define HAS_RQ(qp) (qp->ext_type != EQPT_SRQBASE) |
| 224 | |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 225 | /* must be power of 2 */ |
| 226 | #define QP_HASHTAB_LEN 8 |
| 227 | |
| 228 | struct ehca_cq { |
| 229 | struct ib_cq ib_cq; |
| 230 | struct ipz_queue ipz_queue; |
| 231 | struct h_galpas galpas; |
| 232 | spinlock_t spinlock; |
| 233 | u32 cq_number; |
| 234 | u32 token; |
| 235 | u32 nr_of_entries; |
| 236 | struct ipz_cq_handle ipz_cq_handle; |
| 237 | struct ehca_pfcq pf; |
| 238 | spinlock_t cb_lock; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 239 | struct hlist_head qp_hashtab[QP_HASHTAB_LEN]; |
| 240 | struct list_head entry; |
Joachim Fenkes | 28db6be | 2007-07-09 15:30:39 +0200 | [diff] [blame] | 241 | u32 nr_callbacks; /* #events assigned to cpu by scaling code */ |
| 242 | atomic_t nr_events; /* #events seen */ |
Hoang-Nam Nguyen | 3172679 | 2007-02-28 18:01:02 +0100 | [diff] [blame] | 243 | wait_queue_head_t wait_completion; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 244 | spinlock_t task_lock; |
Hoang-Nam Nguyen | 4c34bdf | 2007-01-24 00:13:35 +0100 | [diff] [blame] | 245 | /* mmap counter for resources mapped into user space */ |
| 246 | u32 mm_count_queue; |
| 247 | u32 mm_count_galpa; |
Alexander Schmidt | b9012e0 | 2008-09-20 20:05:21 -0700 | [diff] [blame] | 248 | struct list_head sqp_err_list; |
| 249 | struct list_head rqp_err_list; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 250 | }; |
| 251 | |
| 252 | enum ehca_mr_flag { |
| 253 | EHCA_MR_FLAG_FMR = 0x80000000, /* FMR, created with ehca_alloc_fmr */ |
| 254 | EHCA_MR_FLAG_MAXMR = 0x40000000, /* max-MR */ |
| 255 | }; |
| 256 | |
| 257 | struct ehca_mr { |
| 258 | union { |
| 259 | struct ib_mr ib_mr; /* must always be first in ehca_mr */ |
| 260 | struct ib_fmr ib_fmr; /* must always be first in ehca_mr */ |
| 261 | } ib; |
Roland Dreier | f7c6a7b | 2007-03-04 16:15:11 -0800 | [diff] [blame] | 262 | struct ib_umem *umem; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 263 | spinlock_t mrlock; |
| 264 | |
| 265 | enum ehca_mr_flag flags; |
Hoang-Nam Nguyen | df17bfd | 2007-07-12 17:52:29 +0200 | [diff] [blame] | 266 | u32 num_kpages; /* number of kernel pages */ |
| 267 | u32 num_hwpages; /* number of hw pages to form MR */ |
Hoang-Nam Nguyen | 5bb7d92 | 2007-07-20 16:01:51 +0200 | [diff] [blame] | 268 | u64 hwpage_size; /* hw page size used for this MR */ |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 269 | int acl; /* ACL (stored here for usage in reregister) */ |
| 270 | u64 *start; /* virtual start address (stored here for */ |
Hoang-Nam Nguyen | 2b94397 | 2007-07-12 17:53:47 +0200 | [diff] [blame] | 271 | /* usage in reregister) */ |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 272 | u64 size; /* size (stored here for usage in reregister) */ |
| 273 | u32 fmr_page_size; /* page size for FMR */ |
| 274 | u32 fmr_max_pages; /* max pages for FMR */ |
| 275 | u32 fmr_max_maps; /* max outstanding maps for FMR */ |
| 276 | u32 fmr_map_cnt; /* map counter for FMR */ |
| 277 | /* fw specific data */ |
| 278 | struct ipz_mrmw_handle ipz_mr_handle; /* MR handle for h-calls */ |
| 279 | struct h_galpas galpas; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 280 | }; |
| 281 | |
| 282 | struct ehca_mw { |
| 283 | struct ib_mw ib_mw; /* gen2 mw, must always be first in ehca_mw */ |
| 284 | spinlock_t mwlock; |
| 285 | |
| 286 | u8 never_bound; /* indication MW was never bound */ |
| 287 | struct ipz_mrmw_handle ipz_mw_handle; /* MW handle for h-calls */ |
| 288 | struct h_galpas galpas; |
| 289 | }; |
| 290 | |
| 291 | enum ehca_mr_pgi_type { |
| 292 | EHCA_MR_PGI_PHYS = 1, /* type of ehca_reg_phys_mr, |
| 293 | * ehca_rereg_phys_mr, |
| 294 | * ehca_reg_internal_maxmr */ |
| 295 | EHCA_MR_PGI_USER = 2, /* type of ehca_reg_user_mr */ |
| 296 | EHCA_MR_PGI_FMR = 3 /* type of ehca_map_phys_fmr */ |
| 297 | }; |
| 298 | |
| 299 | struct ehca_mr_pginfo { |
| 300 | enum ehca_mr_pgi_type type; |
Hoang-Nam Nguyen | df17bfd | 2007-07-12 17:52:29 +0200 | [diff] [blame] | 301 | u64 num_kpages; |
| 302 | u64 kpage_cnt; |
Hoang-Nam Nguyen | 5bb7d92 | 2007-07-20 16:01:51 +0200 | [diff] [blame] | 303 | u64 hwpage_size; /* hw page size used for this MR */ |
Hoang-Nam Nguyen | df17bfd | 2007-07-12 17:52:29 +0200 | [diff] [blame] | 304 | u64 num_hwpages; /* number of hw pages */ |
| 305 | u64 hwpage_cnt; /* counter for hw pages */ |
| 306 | u64 next_hwpage; /* next hw page in buffer/chunk/listelem */ |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 307 | |
Hoang-Nam Nguyen | df17bfd | 2007-07-12 17:52:29 +0200 | [diff] [blame] | 308 | union { |
| 309 | struct { /* type EHCA_MR_PGI_PHYS section */ |
| 310 | int num_phys_buf; |
| 311 | struct ib_phys_buf *phys_buf_array; |
| 312 | u64 next_buf; |
| 313 | } phy; |
| 314 | struct { /* type EHCA_MR_PGI_USER section */ |
| 315 | struct ib_umem *region; |
| 316 | struct ib_umem_chunk *next_chunk; |
| 317 | u64 next_nmap; |
| 318 | } usr; |
| 319 | struct { /* type EHCA_MR_PGI_FMR section */ |
| 320 | u64 fmr_pgsize; |
| 321 | u64 *page_list; |
| 322 | u64 next_listelem; |
| 323 | } fmr; |
| 324 | } u; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 325 | }; |
| 326 | |
| 327 | /* output parameters for MR/FMR hipz calls */ |
| 328 | struct ehca_mr_hipzout_parms { |
| 329 | struct ipz_mrmw_handle handle; |
| 330 | u32 lkey; |
| 331 | u32 rkey; |
| 332 | u64 len; |
| 333 | u64 vaddr; |
| 334 | u32 acl; |
| 335 | }; |
| 336 | |
| 337 | /* output parameters for MW hipz calls */ |
| 338 | struct ehca_mw_hipzout_parms { |
| 339 | struct ipz_mrmw_handle handle; |
| 340 | u32 rkey; |
| 341 | }; |
| 342 | |
| 343 | struct ehca_av { |
| 344 | struct ib_ah ib_ah; |
| 345 | struct ehca_ud_av av; |
| 346 | }; |
| 347 | |
| 348 | struct ehca_ucontext { |
| 349 | struct ib_ucontext ib_ucontext; |
| 350 | }; |
| 351 | |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 352 | int ehca_init_pd_cache(void); |
| 353 | void ehca_cleanup_pd_cache(void); |
| 354 | int ehca_init_cq_cache(void); |
| 355 | void ehca_cleanup_cq_cache(void); |
| 356 | int ehca_init_qp_cache(void); |
| 357 | void ehca_cleanup_qp_cache(void); |
| 358 | int ehca_init_av_cache(void); |
| 359 | void ehca_cleanup_av_cache(void); |
| 360 | int ehca_init_mrmw_cache(void); |
| 361 | void ehca_cleanup_mrmw_cache(void); |
Stefan Roscher | e2f81da | 2007-07-20 16:04:17 +0200 | [diff] [blame] | 362 | int ehca_init_small_qp_cache(void); |
| 363 | void ehca_cleanup_small_qp_cache(void); |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 364 | |
Joachim Fenkes | 26ed687 | 2007-07-09 15:31:10 +0200 | [diff] [blame] | 365 | extern rwlock_t ehca_qp_idr_lock; |
| 366 | extern rwlock_t ehca_cq_idr_lock; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 367 | extern struct idr ehca_qp_idr; |
| 368 | extern struct idr ehca_cq_idr; |
| 369 | |
| 370 | extern int ehca_static_rate; |
| 371 | extern int ehca_port_act_time; |
| 372 | extern int ehca_use_hp_mr; |
Hoang-Nam Nguyen | 4fd3006 | 2007-02-15 17:08:33 +0100 | [diff] [blame] | 373 | extern int ehca_scaling_code; |
Joachim Fenkes | 3d758a4 | 2007-12-13 13:35:57 +0100 | [diff] [blame] | 374 | extern int ehca_lock_hcalls; |
Hoang-Nam Nguyen | bbdd267 | 2008-01-17 15:05:45 +0100 | [diff] [blame] | 375 | extern int ehca_nr_ports; |
Stefan Roscher | d227fa7 | 2008-04-29 13:46:53 -0700 | [diff] [blame] | 376 | extern int ehca_max_cq; |
| 377 | extern int ehca_max_qp; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 378 | |
| 379 | struct ipzu_queue_resp { |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 380 | u32 qe_size; /* queue entry size */ |
| 381 | u32 act_nr_of_sg; |
| 382 | u32 queue_length; /* queue length allocated in bytes */ |
| 383 | u32 pagesize; |
| 384 | u32 toggle_state; |
Stefan Roscher | e2f81da | 2007-07-20 16:04:17 +0200 | [diff] [blame] | 385 | u32 offset; /* save offset within a page for small_qp */ |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 386 | }; |
| 387 | |
| 388 | struct ehca_create_cq_resp { |
| 389 | u32 cq_number; |
| 390 | u32 token; |
| 391 | struct ipzu_queue_resp ipz_queue; |
Hoang-Nam Nguyen | e390d3b | 2007-09-11 15:31:06 +0200 | [diff] [blame] | 392 | u32 fw_handle_ofs; |
| 393 | u32 dummy; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 394 | }; |
| 395 | |
| 396 | struct ehca_create_qp_resp { |
| 397 | u32 qp_num; |
| 398 | u32 token; |
| 399 | u32 qp_type; |
Joachim Fenkes | a6a1294 | 2007-07-09 15:25:10 +0200 | [diff] [blame] | 400 | u32 ext_type; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 401 | u32 qkey; |
| 402 | /* qp_num assigned by ehca: sqp0/1 may have got different numbers */ |
| 403 | u32 real_qp_num; |
Hoang-Nam Nguyen | e390d3b | 2007-09-11 15:31:06 +0200 | [diff] [blame] | 404 | u32 fw_handle_ofs; |
Hoang-Nam Nguyen | a660722 | 2007-09-28 17:18:47 +0200 | [diff] [blame] | 405 | u32 dummy; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 406 | struct ipzu_queue_resp ipz_squeue; |
| 407 | struct ipzu_queue_resp ipz_rqueue; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 408 | }; |
| 409 | |
| 410 | struct ehca_alloc_cq_parms { |
| 411 | u32 nr_cqe; |
| 412 | u32 act_nr_of_entries; |
| 413 | u32 act_pages; |
| 414 | struct ipz_eq_handle eq_handle; |
| 415 | }; |
| 416 | |
Joachim Fenkes | 9a79fc0 | 2007-07-09 15:23:15 +0200 | [diff] [blame] | 417 | enum ehca_service_type { |
| 418 | ST_RC = 0, |
| 419 | ST_UC = 1, |
| 420 | ST_RD = 2, |
| 421 | ST_UD = 3, |
| 422 | }; |
| 423 | |
Joachim Fenkes | 9a79fc0 | 2007-07-09 15:23:15 +0200 | [diff] [blame] | 424 | enum ehca_ll_comp_flags { |
| 425 | LLQP_SEND_COMP = 0x20, |
| 426 | LLQP_RECV_COMP = 0x40, |
| 427 | LLQP_COMP_MASK = 0x60, |
| 428 | }; |
| 429 | |
Stefan Roscher | e2f81da | 2007-07-20 16:04:17 +0200 | [diff] [blame] | 430 | struct ehca_alloc_queue_parms { |
| 431 | /* input parameters */ |
| 432 | int max_wr; |
| 433 | int max_sge; |
| 434 | int page_size; |
| 435 | int is_small; |
| 436 | |
| 437 | /* output parameters */ |
| 438 | u16 act_nr_wqes; |
| 439 | u8 act_nr_sges; |
| 440 | u32 queue_size; /* bytes for small queues, pages otherwise */ |
| 441 | }; |
| 442 | |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 443 | struct ehca_alloc_qp_parms { |
Stefan Roscher | e2f81da | 2007-07-20 16:04:17 +0200 | [diff] [blame] | 444 | struct ehca_alloc_queue_parms squeue; |
| 445 | struct ehca_alloc_queue_parms rqueue; |
| 446 | |
| 447 | /* input parameters */ |
Joachim Fenkes | 9a79fc0 | 2007-07-09 15:23:15 +0200 | [diff] [blame] | 448 | enum ehca_service_type servicetype; |
Stefan Roscher | e2f81da | 2007-07-20 16:04:17 +0200 | [diff] [blame] | 449 | int qp_storage; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 450 | int sigtype; |
Joachim Fenkes | 9a79fc0 | 2007-07-09 15:23:15 +0200 | [diff] [blame] | 451 | enum ehca_ext_qp_type ext_type; |
| 452 | enum ehca_ll_comp_flags ll_comp_flags; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 453 | int ud_av_l_key_ctl; |
| 454 | |
Joachim Fenkes | 9a79fc0 | 2007-07-09 15:23:15 +0200 | [diff] [blame] | 455 | u32 token; |
| 456 | struct ipz_eq_handle eq_handle; |
| 457 | struct ipz_pd pd; |
| 458 | struct ipz_cq_handle send_cq_handle, recv_cq_handle; |
| 459 | |
| 460 | u32 srq_qpn, srq_token, srq_limit; |
| 461 | |
Stefan Roscher | e2f81da | 2007-07-20 16:04:17 +0200 | [diff] [blame] | 462 | /* output parameters */ |
Joachim Fenkes | 9a79fc0 | 2007-07-09 15:23:15 +0200 | [diff] [blame] | 463 | u32 real_qp_num; |
| 464 | struct ipz_qp_handle qp_handle; |
| 465 | struct h_galpas galpas; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 466 | }; |
| 467 | |
| 468 | int ehca_cq_assign_qp(struct ehca_cq *cq, struct ehca_qp *qp); |
| 469 | int ehca_cq_unassign_qp(struct ehca_cq *cq, unsigned int qp_num); |
Hoang-Nam Nguyen | 2b94397 | 2007-07-12 17:53:47 +0200 | [diff] [blame] | 470 | struct ehca_qp *ehca_cq_get_qp(struct ehca_cq *cq, int qp_num); |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 471 | |
| 472 | #endif |