Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ehca_classes.h
Go to the documentation of this file.
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 <[email protected]>
7  * Christoph Raisch <[email protected]>
8  * Joachim Fenkes <[email protected]>
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 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 
55 #include <linux/wait.h>
56 #include <linux/mutex.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 #define EHCA_MAX_NUM_QUEUES 0xffff
70 
72  struct ehca_eqe *eqe;
73  struct ehca_cq *cq;
74 };
75 
76 struct ehca_eq {
80  struct work_struct work;
81  struct h_galpas galpas;
83  struct ehca_pfeq pf;
89 };
90 
91 struct ehca_sma_attr {
94 };
95 
96 struct ehca_sport {
97  struct ib_cq *ibcq_aqp1;
98  struct ib_qp *ibqp_sqp[2];
99  /* lock to serialze modify_qp() calls for sqp in normal
100  * and irq path (when event PORT_ACTIVE is received first time)
101  */
106 };
107 
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
112 
113 struct ehca_shca {
117  int hw_level;
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;
128  /* MR pgsize: bit 0-3 means 4K, 64K, 1M, 16M respectively */
130  int max_mtu;
135 };
136 
137 struct ehca_pd {
138  struct ib_pd ib_pd;
139  struct ipz_pd fw_pd;
140  /* small queue mgmt */
141  struct mutex lock;
142  struct list_head free[2];
143  struct list_head full[2];
144 };
145 
150  EQPT_SRQ = 3,
151 };
152 
153 /* struct to cache modify_qp()'s parms for GSI/SMI qp */
155  int mask;
156  struct ib_qp_attr attr;
157 };
158 
159 #define EHCA_MOD_QP_PARM_MAX 4
160 
161 #define QMAP_IDX_MASK 0xFFFFULL
162 
163 /* struct for tracking if cqes have been reported to the application */
168 };
169 
172  unsigned int entries;
173  unsigned int tail;
174  unsigned int left_to_poll;
175  unsigned int next_wqe_idx; /* Idx to first wqe to be flushed */
176 };
177 
178 /* function to calculate the next index for the qmap */
179 static inline unsigned int next_index(unsigned int cur_index, unsigned int limit)
180 {
181  unsigned int temp = cur_index + 1;
182  return (temp == limit) ? 0 : temp;
183 }
184 
185 struct ehca_qp {
186  union {
187  struct ib_qp ib_qp;
188  struct ib_srq ib_srq;
189  };
197  struct h_galpas galpas;
205  struct ehca_pfqp pf;
207  struct ehca_cq *send_cq;
208  struct ehca_cq *recv_cq;
209  unsigned int sqerr_purgeflag;
211  /* array to cache modify_qp()'s parms for GSI/SMI qp */
214  /* mmap counter for resources mapped into user space */
218  /* unsolicited ack circumvention */
223  atomic_t nr_events; /* events seen */
228 };
229 
230 #define IS_SRQ(qp) (qp->ext_type == EQPT_SRQ)
231 #define HAS_SQ(qp) (qp->ext_type != EQPT_SRQ)
232 #define HAS_RQ(qp) (qp->ext_type != EQPT_SRQBASE)
233 
234 /* must be power of 2 */
235 #define QP_HASHTAB_LEN 8
236 
237 struct ehca_cq {
238  struct ib_cq ib_cq;
240  struct h_galpas galpas;
246  struct ehca_pfcq pf;
249  struct list_head entry;
250  u32 nr_callbacks; /* #events assigned to cpu by scaling code */
251  atomic_t nr_events; /* #events seen */
254  /* mmap counter for resources mapped into user space */
259 };
260 
262  EHCA_MR_FLAG_FMR = 0x80000000, /* FMR, created with ehca_alloc_fmr */
263  EHCA_MR_FLAG_MAXMR = 0x40000000, /* max-MR */
264 };
265 
266 struct ehca_mr {
267  union {
268  struct ib_mr ib_mr; /* must always be first in ehca_mr */
269  struct ib_fmr ib_fmr; /* must always be first in ehca_mr */
270  } ib;
271  struct ib_umem *umem;
273 
275  u32 num_kpages; /* number of kernel pages */
276  u32 num_hwpages; /* number of hw pages to form MR */
277  u64 hwpage_size; /* hw page size used for this MR */
278  int acl; /* ACL (stored here for usage in reregister) */
279  u64 *start; /* virtual start address (stored here for */
280  /* usage in reregister) */
281  u64 size; /* size (stored here for usage in reregister) */
282  u32 fmr_page_size; /* page size for FMR */
283  u32 fmr_max_pages; /* max pages for FMR */
284  u32 fmr_max_maps; /* max outstanding maps for FMR */
285  u32 fmr_map_cnt; /* map counter for FMR */
286  /* fw specific data */
287  struct ipz_mrmw_handle ipz_mr_handle; /* MR handle for h-calls */
288  struct h_galpas galpas;
289 };
290 
291 struct ehca_mw {
292  struct ib_mw ib_mw; /* gen2 mw, must always be first in ehca_mw */
294 
295  u8 never_bound; /* indication MW was never bound */
296  struct ipz_mrmw_handle ipz_mw_handle; /* MW handle for h-calls */
297  struct h_galpas galpas;
298 };
299 
301  EHCA_MR_PGI_PHYS = 1, /* type of ehca_reg_phys_mr,
302  * ehca_rereg_phys_mr,
303  * ehca_reg_internal_maxmr */
304  EHCA_MR_PGI_USER = 2, /* type of ehca_reg_user_mr */
305  EHCA_MR_PGI_FMR = 3 /* type of ehca_map_phys_fmr */
306 };
307 
312  u64 hwpage_size; /* hw page size used for this MR */
313  u64 num_hwpages; /* number of hw pages */
314  u64 hwpage_cnt; /* counter for hw pages */
315  u64 next_hwpage; /* next hw page in buffer/chunk/listelem */
316 
317  union {
318  struct { /* type EHCA_MR_PGI_PHYS section */
322  } phy;
323  struct { /* type EHCA_MR_PGI_USER section */
324  struct ib_umem *region;
327  } usr;
328  struct { /* type EHCA_MR_PGI_FMR section */
332  } fmr;
333  } u;
334 };
335 
336 /* output parameters for MR/FMR hipz calls */
344 };
345 
346 /* output parameters for MW hipz calls */
350 };
351 
352 struct ehca_av {
353  struct ib_ah ib_ah;
354  struct ehca_ud_av av;
355 };
356 
359 };
360 
361 int ehca_init_pd_cache(void);
362 void ehca_cleanup_pd_cache(void);
363 int ehca_init_cq_cache(void);
364 void ehca_cleanup_cq_cache(void);
365 int ehca_init_qp_cache(void);
366 void ehca_cleanup_qp_cache(void);
367 int ehca_init_av_cache(void);
368 void ehca_cleanup_av_cache(void);
369 int ehca_init_mrmw_cache(void);
370 void ehca_cleanup_mrmw_cache(void);
371 int ehca_init_small_qp_cache(void);
372 void ehca_cleanup_small_qp_cache(void);
373 
376 extern struct idr ehca_qp_idr;
377 extern struct idr ehca_cq_idr;
379 
380 extern int ehca_static_rate;
381 extern int ehca_port_act_time;
382 extern bool ehca_use_hp_mr;
383 extern bool ehca_scaling_code;
384 extern int ehca_lock_hcalls;
385 extern int ehca_nr_ports;
386 extern int ehca_max_cq;
387 extern int ehca_max_qp;
388 
390  u32 qe_size; /* queue entry size */
392  u32 queue_length; /* queue length allocated in bytes */
395  u32 offset; /* save offset within a page for small_qp */
396 };
397 
404 };
405 
412  /* qp_num assigned by ehca: sqp0/1 may have got different numbers */
418 };
419 
425 };
426 
428  ST_RC = 0,
429  ST_UC = 1,
430  ST_RD = 2,
431  ST_UD = 3,
432 };
433 
438 };
439 
441  /* input parameters */
442  int max_wr;
443  int max_sge;
445  int is_small;
446 
447  /* output parameters */
450  u32 queue_size; /* bytes for small queues, pages otherwise */
451 };
452 
456 
457  /* input parameters */
460  int sigtype;
464 
467  struct ipz_pd pd;
468  struct ipz_cq_handle send_cq_handle, recv_cq_handle;
469 
471 
472  /* output parameters */
475  struct h_galpas galpas;
476 };
477 
478 int ehca_cq_assign_qp(struct ehca_cq *cq, struct ehca_qp *qp);
479 int ehca_cq_unassign_qp(struct ehca_cq *cq, unsigned int qp_num);
480 struct ehca_qp *ehca_cq_get_qp(struct ehca_cq *cq, int qp_num);
481 
482 #endif