ehca_classes.h revision a6a12947fbf4a1782535468d756b0d44babf9760
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 * Joachim Fenkes <fenkes@de.ibm.com> 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 46 47struct ehca_module; 48struct ehca_qp; 49struct ehca_cq; 50struct ehca_eq; 51struct ehca_mr; 52struct ehca_mw; 53struct ehca_pd; 54struct ehca_av; 55 56#include <linux/wait.h> 57 58#include <rdma/ib_verbs.h> 59#include <rdma/ib_user_verbs.h> 60 61#ifdef CONFIG_PPC64 62#include "ehca_classes_pSeries.h" 63#endif 64#include "ipz_pt_fn.h" 65#include "ehca_qes.h" 66#include "ehca_irq.h" 67 68#define EHCA_EQE_CACHE_SIZE 20 69 70struct ehca_eqe_cache_entry { 71 struct ehca_eqe *eqe; 72 struct ehca_cq *cq; 73}; 74 75struct ehca_eq { 76 u32 length; 77 struct ipz_queue ipz_queue; 78 struct ipz_eq_handle ipz_eq_handle; 79 struct work_struct work; 80 struct h_galpas galpas; 81 int is_initialized; 82 struct ehca_pfeq pf; 83 spinlock_t spinlock; 84 struct tasklet_struct interrupt_task; 85 u32 ist; 86 spinlock_t irq_spinlock; 87 struct ehca_eqe_cache_entry eqe_cache[EHCA_EQE_CACHE_SIZE]; 88}; 89 90struct ehca_sport { 91 struct ib_cq *ibcq_aqp1; 92 struct ib_qp *ibqp_aqp1; 93 enum ib_rate rate; 94 enum ib_port_state port_state; 95}; 96 97struct ehca_shca { 98 struct ib_device ib_device; 99 struct ibmebus_dev *ibmebus_dev; 100 u8 num_ports; 101 int hw_level; 102 struct list_head shca_list; 103 struct ipz_adapter_handle ipz_hca_handle; 104 struct ehca_sport sport[2]; 105 struct ehca_eq eq; 106 struct ehca_eq neq; 107 struct ehca_mr *maxmr; 108 struct ehca_pd *pd; 109 struct h_galpas galpas; 110 struct mutex modify_mutex; 111 u64 hca_cap; 112 int max_mtu; 113}; 114 115struct ehca_pd { 116 struct ib_pd ib_pd; 117 struct ipz_pd fw_pd; 118 u32 ownpid; 119}; 120 121enum ehca_ext_qp_type { 122 EQPT_NORMAL = 0, 123 EQPT_LLQP = 1, 124 EQPT_SRQBASE = 2, 125 EQPT_SRQ = 3, 126}; 127 128struct ehca_qp { 129 union { 130 struct ib_qp ib_qp; 131 struct ib_srq ib_srq; 132 }; 133 u32 qp_type; 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; 138 u32 qkey; 139 u32 real_qp_num; 140 u32 token; 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; 145 struct ehca_pfqp pf; 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 */ 152 u32 mm_count_squeue; 153 u32 mm_count_rqueue; 154 u32 mm_count_galpa; 155}; 156 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) 160 161/* must be power of 2 */ 162#define QP_HASHTAB_LEN 8 163 164struct ehca_cq { 165 struct ib_cq ib_cq; 166 struct ipz_queue ipz_queue; 167 struct h_galpas galpas; 168 spinlock_t spinlock; 169 u32 cq_number; 170 u32 token; 171 u32 nr_of_entries; 172 struct ipz_cq_handle ipz_cq_handle; 173 struct ehca_pfcq pf; 174 spinlock_t cb_lock; 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; 181 u32 ownpid; 182 /* mmap counter for resources mapped into user space */ 183 u32 mm_count_queue; 184 u32 mm_count_galpa; 185}; 186 187enum ehca_mr_flag { 188 EHCA_MR_FLAG_FMR = 0x80000000, /* FMR, created with ehca_alloc_fmr */ 189 EHCA_MR_FLAG_MAXMR = 0x40000000, /* max-MR */ 190}; 191 192struct ehca_mr { 193 union { 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 */ 196 } ib; 197 struct ib_umem *umem; 198 spinlock_t mrlock; 199 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 */ 215 u32 nr_of_pages; 216 void *pagearray; 217}; 218 219struct ehca_mw { 220 struct ib_mw ib_mw; /* gen2 mw, must always be first in ehca_mw */ 221 spinlock_t mwlock; 222 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; 226}; 227 228enum 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 */ 234}; 235 236struct ehca_mr_pginfo { 237 enum ehca_mr_pgi_type type; 238 u64 num_pages; 239 u64 page_cnt; 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 */ 243 244 /* type EHCA_MR_PGI_PHYS section */ 245 int num_phys_buf; 246 struct ib_phys_buf *phys_buf_array; 247 u64 next_buf; 248 249 /* type EHCA_MR_PGI_USER section */ 250 struct ib_umem *region; 251 struct ib_umem_chunk *next_chunk; 252 u64 next_nmap; 253 254 /* type EHCA_MR_PGI_FMR section */ 255 u64 *page_list; 256 u64 next_listelem; 257 /* next_4k also used within EHCA_MR_PGI_FMR */ 258}; 259 260/* output parameters for MR/FMR hipz calls */ 261struct ehca_mr_hipzout_parms { 262 struct ipz_mrmw_handle handle; 263 u32 lkey; 264 u32 rkey; 265 u64 len; 266 u64 vaddr; 267 u32 acl; 268}; 269 270/* output parameters for MW hipz calls */ 271struct ehca_mw_hipzout_parms { 272 struct ipz_mrmw_handle handle; 273 u32 rkey; 274}; 275 276struct ehca_av { 277 struct ib_ah ib_ah; 278 struct ehca_ud_av av; 279}; 280 281struct ehca_ucontext { 282 struct ib_ucontext ib_ucontext; 283}; 284 285int ehca_init_pd_cache(void); 286void ehca_cleanup_pd_cache(void); 287int ehca_init_cq_cache(void); 288void ehca_cleanup_cq_cache(void); 289int ehca_init_qp_cache(void); 290void ehca_cleanup_qp_cache(void); 291int ehca_init_av_cache(void); 292void ehca_cleanup_av_cache(void); 293int ehca_init_mrmw_cache(void); 294void ehca_cleanup_mrmw_cache(void); 295 296extern spinlock_t ehca_qp_idr_lock; 297extern spinlock_t ehca_cq_idr_lock; 298extern spinlock_t hcall_lock; 299extern struct idr ehca_qp_idr; 300extern struct idr ehca_cq_idr; 301 302extern int ehca_static_rate; 303extern int ehca_port_act_time; 304extern int ehca_use_hp_mr; 305extern int ehca_scaling_code; 306 307struct ipzu_queue_resp { 308 u32 qe_size; /* queue entry size */ 309 u32 act_nr_of_sg; 310 u32 queue_length; /* queue length allocated in bytes */ 311 u32 pagesize; 312 u32 toggle_state; 313 u32 dummy; /* padding for 8 byte alignment */ 314}; 315 316struct ehca_create_cq_resp { 317 u32 cq_number; 318 u32 token; 319 struct ipzu_queue_resp ipz_queue; 320}; 321 322struct ehca_create_qp_resp { 323 u32 qp_num; 324 u32 token; 325 u32 qp_type; 326 u32 ext_type; 327 u32 qkey; 328 /* qp_num assigned by ehca: sqp0/1 may have got different numbers */ 329 u32 real_qp_num; 330 u32 dummy; /* padding for 8 byte alignment */ 331 struct ipzu_queue_resp ipz_squeue; 332 struct ipzu_queue_resp ipz_rqueue; 333}; 334 335struct ehca_alloc_cq_parms { 336 u32 nr_cqe; 337 u32 act_nr_of_entries; 338 u32 act_pages; 339 struct ipz_eq_handle eq_handle; 340}; 341 342enum ehca_service_type { 343 ST_RC = 0, 344 ST_UC = 1, 345 ST_RD = 2, 346 ST_UD = 3, 347}; 348 349enum ehca_ll_comp_flags { 350 LLQP_SEND_COMP = 0x20, 351 LLQP_RECV_COMP = 0x40, 352 LLQP_COMP_MASK = 0x60, 353}; 354 355struct ehca_alloc_qp_parms { 356/* input parameters */ 357 enum ehca_service_type servicetype; 358 int sigtype; 359 enum ehca_ext_qp_type ext_type; 360 enum ehca_ll_comp_flags ll_comp_flags; 361 362 int max_send_wr, max_recv_wr; 363 int max_send_sge, max_recv_sge; 364 int ud_av_l_key_ctl; 365 366 u32 token; 367 struct ipz_eq_handle eq_handle; 368 struct ipz_pd pd; 369 struct ipz_cq_handle send_cq_handle, recv_cq_handle; 370 371 u32 srq_qpn, srq_token, srq_limit; 372 373/* output parameters */ 374 u32 real_qp_num; 375 struct ipz_qp_handle qp_handle; 376 struct h_galpas galpas; 377 378 u16 act_nr_send_wqes; 379 u16 act_nr_recv_wqes; 380 u8 act_nr_recv_sges; 381 u8 act_nr_send_sges; 382 383 u32 nr_rq_pages; 384 u32 nr_sq_pages; 385}; 386 387int ehca_cq_assign_qp(struct ehca_cq *cq, struct ehca_qp *qp); 388int ehca_cq_unassign_qp(struct ehca_cq *cq, unsigned int qp_num); 389struct ehca_qp* ehca_cq_get_qp(struct ehca_cq *cq, int qp_num); 390 391#endif 392