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> |
| 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 | |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 45 | |
| 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> |
| 56 | |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 57 | #include <rdma/ib_verbs.h> |
| 58 | #include <rdma/ib_user_verbs.h> |
| 59 | |
Hoang-Nam Nguyen | 78d8d5f | 2007-02-15 17:06:33 +0100 | [diff] [blame] | 60 | #ifdef CONFIG_PPC64 |
| 61 | #include "ehca_classes_pSeries.h" |
| 62 | #endif |
| 63 | #include "ipz_pt_fn.h" |
| 64 | #include "ehca_qes.h" |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 65 | #include "ehca_irq.h" |
| 66 | |
Hoang-Nam Nguyen | 78d8d5f | 2007-02-15 17:06:33 +0100 | [diff] [blame] | 67 | #define EHCA_EQE_CACHE_SIZE 20 |
| 68 | |
| 69 | struct ehca_eqe_cache_entry { |
| 70 | struct ehca_eqe *eqe; |
| 71 | struct ehca_cq *cq; |
| 72 | }; |
| 73 | |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 74 | struct ehca_eq { |
| 75 | u32 length; |
| 76 | struct ipz_queue ipz_queue; |
| 77 | struct ipz_eq_handle ipz_eq_handle; |
| 78 | struct work_struct work; |
| 79 | struct h_galpas galpas; |
| 80 | int is_initialized; |
| 81 | struct ehca_pfeq pf; |
| 82 | spinlock_t spinlock; |
| 83 | struct tasklet_struct interrupt_task; |
| 84 | u32 ist; |
Hoang-Nam Nguyen | 78d8d5f | 2007-02-15 17:06:33 +0100 | [diff] [blame] | 85 | spinlock_t irq_spinlock; |
| 86 | struct ehca_eqe_cache_entry eqe_cache[EHCA_EQE_CACHE_SIZE]; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | struct ehca_sport { |
| 90 | struct ib_cq *ibcq_aqp1; |
| 91 | struct ib_qp *ibqp_aqp1; |
| 92 | enum ib_rate rate; |
| 93 | enum ib_port_state port_state; |
| 94 | }; |
| 95 | |
| 96 | struct ehca_shca { |
| 97 | struct ib_device ib_device; |
| 98 | struct ibmebus_dev *ibmebus_dev; |
| 99 | u8 num_ports; |
| 100 | int hw_level; |
| 101 | struct list_head shca_list; |
| 102 | struct ipz_adapter_handle ipz_hca_handle; |
| 103 | struct ehca_sport sport[2]; |
| 104 | struct ehca_eq eq; |
| 105 | struct ehca_eq neq; |
| 106 | struct ehca_mr *maxmr; |
| 107 | struct ehca_pd *pd; |
| 108 | struct h_galpas galpas; |
Joachim Fenkes | c4ed790 | 2007-04-24 17:44:31 +0200 | [diff] [blame] | 109 | struct mutex modify_mutex; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | struct ehca_pd { |
| 113 | struct ib_pd ib_pd; |
| 114 | struct ipz_pd fw_pd; |
| 115 | u32 ownpid; |
| 116 | }; |
| 117 | |
| 118 | struct ehca_qp { |
| 119 | struct ib_qp ib_qp; |
| 120 | u32 qp_type; |
| 121 | struct ipz_queue ipz_squeue; |
| 122 | struct ipz_queue ipz_rqueue; |
| 123 | struct h_galpas galpas; |
| 124 | u32 qkey; |
| 125 | u32 real_qp_num; |
| 126 | u32 token; |
| 127 | spinlock_t spinlock_s; |
| 128 | spinlock_t spinlock_r; |
| 129 | u32 sq_max_inline_data_size; |
| 130 | struct ipz_qp_handle ipz_qp_handle; |
| 131 | struct ehca_pfqp pf; |
| 132 | struct ib_qp_init_attr init_attr; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 133 | struct ehca_cq *send_cq; |
| 134 | struct ehca_cq *recv_cq; |
| 135 | unsigned int sqerr_purgeflag; |
| 136 | struct hlist_node list_entries; |
Hoang-Nam Nguyen | 4c34bdf | 2007-01-24 00:13:35 +0100 | [diff] [blame] | 137 | /* mmap counter for resources mapped into user space */ |
| 138 | u32 mm_count_squeue; |
| 139 | u32 mm_count_rqueue; |
| 140 | u32 mm_count_galpa; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 141 | }; |
| 142 | |
| 143 | /* must be power of 2 */ |
| 144 | #define QP_HASHTAB_LEN 8 |
| 145 | |
| 146 | struct ehca_cq { |
| 147 | struct ib_cq ib_cq; |
| 148 | struct ipz_queue ipz_queue; |
| 149 | struct h_galpas galpas; |
| 150 | spinlock_t spinlock; |
| 151 | u32 cq_number; |
| 152 | u32 token; |
| 153 | u32 nr_of_entries; |
| 154 | struct ipz_cq_handle ipz_cq_handle; |
| 155 | struct ehca_pfcq pf; |
| 156 | spinlock_t cb_lock; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 157 | struct hlist_head qp_hashtab[QP_HASHTAB_LEN]; |
| 158 | struct list_head entry; |
Hoang-Nam Nguyen | 3172679 | 2007-02-28 18:01:02 +0100 | [diff] [blame] | 159 | u32 nr_callbacks; /* #events assigned to cpu by scaling code */ |
| 160 | u32 nr_events; /* #events seen */ |
| 161 | wait_queue_head_t wait_completion; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 162 | spinlock_t task_lock; |
| 163 | u32 ownpid; |
Hoang-Nam Nguyen | 4c34bdf | 2007-01-24 00:13:35 +0100 | [diff] [blame] | 164 | /* mmap counter for resources mapped into user space */ |
| 165 | u32 mm_count_queue; |
| 166 | u32 mm_count_galpa; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 167 | }; |
| 168 | |
| 169 | enum ehca_mr_flag { |
| 170 | EHCA_MR_FLAG_FMR = 0x80000000, /* FMR, created with ehca_alloc_fmr */ |
| 171 | EHCA_MR_FLAG_MAXMR = 0x40000000, /* max-MR */ |
| 172 | }; |
| 173 | |
| 174 | struct ehca_mr { |
| 175 | union { |
| 176 | struct ib_mr ib_mr; /* must always be first in ehca_mr */ |
| 177 | struct ib_fmr ib_fmr; /* must always be first in ehca_mr */ |
| 178 | } ib; |
| 179 | spinlock_t mrlock; |
| 180 | |
| 181 | enum ehca_mr_flag flags; |
| 182 | u32 num_pages; /* number of MR pages */ |
| 183 | u32 num_4k; /* number of 4k "page" portions to form MR */ |
| 184 | int acl; /* ACL (stored here for usage in reregister) */ |
| 185 | u64 *start; /* virtual start address (stored here for */ |
| 186 | /* usage in reregister) */ |
| 187 | u64 size; /* size (stored here for usage in reregister) */ |
| 188 | u32 fmr_page_size; /* page size for FMR */ |
| 189 | u32 fmr_max_pages; /* max pages for FMR */ |
| 190 | u32 fmr_max_maps; /* max outstanding maps for FMR */ |
| 191 | u32 fmr_map_cnt; /* map counter for FMR */ |
| 192 | /* fw specific data */ |
| 193 | struct ipz_mrmw_handle ipz_mr_handle; /* MR handle for h-calls */ |
| 194 | struct h_galpas galpas; |
| 195 | /* data for userspace bridge */ |
| 196 | u32 nr_of_pages; |
| 197 | void *pagearray; |
| 198 | }; |
| 199 | |
| 200 | struct ehca_mw { |
| 201 | struct ib_mw ib_mw; /* gen2 mw, must always be first in ehca_mw */ |
| 202 | spinlock_t mwlock; |
| 203 | |
| 204 | u8 never_bound; /* indication MW was never bound */ |
| 205 | struct ipz_mrmw_handle ipz_mw_handle; /* MW handle for h-calls */ |
| 206 | struct h_galpas galpas; |
| 207 | }; |
| 208 | |
| 209 | enum ehca_mr_pgi_type { |
| 210 | EHCA_MR_PGI_PHYS = 1, /* type of ehca_reg_phys_mr, |
| 211 | * ehca_rereg_phys_mr, |
| 212 | * ehca_reg_internal_maxmr */ |
| 213 | EHCA_MR_PGI_USER = 2, /* type of ehca_reg_user_mr */ |
| 214 | EHCA_MR_PGI_FMR = 3 /* type of ehca_map_phys_fmr */ |
| 215 | }; |
| 216 | |
| 217 | struct ehca_mr_pginfo { |
| 218 | enum ehca_mr_pgi_type type; |
| 219 | u64 num_pages; |
| 220 | u64 page_cnt; |
| 221 | u64 num_4k; /* number of 4k "page" portions */ |
| 222 | u64 page_4k_cnt; /* counter for 4k "page" portions */ |
| 223 | u64 next_4k; /* next 4k "page" portion in buffer/chunk/listelem */ |
| 224 | |
| 225 | /* type EHCA_MR_PGI_PHYS section */ |
| 226 | int num_phys_buf; |
| 227 | struct ib_phys_buf *phys_buf_array; |
| 228 | u64 next_buf; |
| 229 | |
| 230 | /* type EHCA_MR_PGI_USER section */ |
| 231 | struct ib_umem *region; |
| 232 | struct ib_umem_chunk *next_chunk; |
| 233 | u64 next_nmap; |
| 234 | |
| 235 | /* type EHCA_MR_PGI_FMR section */ |
| 236 | u64 *page_list; |
| 237 | u64 next_listelem; |
| 238 | /* next_4k also used within EHCA_MR_PGI_FMR */ |
| 239 | }; |
| 240 | |
| 241 | /* output parameters for MR/FMR hipz calls */ |
| 242 | struct ehca_mr_hipzout_parms { |
| 243 | struct ipz_mrmw_handle handle; |
| 244 | u32 lkey; |
| 245 | u32 rkey; |
| 246 | u64 len; |
| 247 | u64 vaddr; |
| 248 | u32 acl; |
| 249 | }; |
| 250 | |
| 251 | /* output parameters for MW hipz calls */ |
| 252 | struct ehca_mw_hipzout_parms { |
| 253 | struct ipz_mrmw_handle handle; |
| 254 | u32 rkey; |
| 255 | }; |
| 256 | |
| 257 | struct ehca_av { |
| 258 | struct ib_ah ib_ah; |
| 259 | struct ehca_ud_av av; |
| 260 | }; |
| 261 | |
| 262 | struct ehca_ucontext { |
| 263 | struct ib_ucontext ib_ucontext; |
| 264 | }; |
| 265 | |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 266 | int ehca_init_pd_cache(void); |
| 267 | void ehca_cleanup_pd_cache(void); |
| 268 | int ehca_init_cq_cache(void); |
| 269 | void ehca_cleanup_cq_cache(void); |
| 270 | int ehca_init_qp_cache(void); |
| 271 | void ehca_cleanup_qp_cache(void); |
| 272 | int ehca_init_av_cache(void); |
| 273 | void ehca_cleanup_av_cache(void); |
| 274 | int ehca_init_mrmw_cache(void); |
| 275 | void ehca_cleanup_mrmw_cache(void); |
| 276 | |
| 277 | extern spinlock_t ehca_qp_idr_lock; |
| 278 | extern spinlock_t ehca_cq_idr_lock; |
| 279 | extern struct idr ehca_qp_idr; |
| 280 | extern struct idr ehca_cq_idr; |
| 281 | |
| 282 | extern int ehca_static_rate; |
| 283 | extern int ehca_port_act_time; |
| 284 | extern int ehca_use_hp_mr; |
Hoang-Nam Nguyen | 4fd3006 | 2007-02-15 17:08:33 +0100 | [diff] [blame] | 285 | extern int ehca_scaling_code; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 286 | |
| 287 | struct ipzu_queue_resp { |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 288 | u32 qe_size; /* queue entry size */ |
| 289 | u32 act_nr_of_sg; |
| 290 | u32 queue_length; /* queue length allocated in bytes */ |
| 291 | u32 pagesize; |
| 292 | u32 toggle_state; |
| 293 | u32 dummy; /* padding for 8 byte alignment */ |
| 294 | }; |
| 295 | |
| 296 | struct ehca_create_cq_resp { |
| 297 | u32 cq_number; |
| 298 | u32 token; |
| 299 | struct ipzu_queue_resp ipz_queue; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 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; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 312 | }; |
| 313 | |
| 314 | struct ehca_alloc_cq_parms { |
| 315 | u32 nr_cqe; |
| 316 | u32 act_nr_of_entries; |
| 317 | u32 act_pages; |
| 318 | struct ipz_eq_handle eq_handle; |
| 319 | }; |
| 320 | |
| 321 | struct ehca_alloc_qp_parms { |
| 322 | int servicetype; |
| 323 | int sigtype; |
| 324 | int daqp_ctrl; |
| 325 | int max_send_sge; |
| 326 | int max_recv_sge; |
| 327 | int ud_av_l_key_ctl; |
| 328 | |
| 329 | u16 act_nr_send_wqes; |
| 330 | u16 act_nr_recv_wqes; |
| 331 | u8 act_nr_recv_sges; |
| 332 | u8 act_nr_send_sges; |
| 333 | |
| 334 | u32 nr_rq_pages; |
| 335 | u32 nr_sq_pages; |
| 336 | |
| 337 | struct ipz_eq_handle ipz_eq_handle; |
| 338 | struct ipz_pd pd; |
| 339 | }; |
| 340 | |
| 341 | int ehca_cq_assign_qp(struct ehca_cq *cq, struct ehca_qp *qp); |
| 342 | int ehca_cq_unassign_qp(struct ehca_cq *cq, unsigned int qp_num); |
| 343 | struct ehca_qp* ehca_cq_get_qp(struct ehca_cq *cq, int qp_num); |
| 344 | |
| 345 | #endif |