ehca_classes.h 8.7 KB

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