ehca_classes.h 8.5 KB

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