mlx5_ib.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. /*
  2. * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #ifndef MLX5_IB_H
  33. #define MLX5_IB_H
  34. #include <linux/kernel.h>
  35. #include <linux/sched.h>
  36. #include <rdma/ib_verbs.h>
  37. #include <rdma/ib_smi.h>
  38. #include <linux/mlx5/driver.h>
  39. #include <linux/mlx5/cq.h>
  40. #include <linux/mlx5/qp.h>
  41. #include <linux/mlx5/srq.h>
  42. #include <linux/types.h>
  43. #define mlx5_ib_dbg(dev, format, arg...) \
  44. pr_debug("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \
  45. __LINE__, current->pid, ##arg)
  46. #define mlx5_ib_err(dev, format, arg...) \
  47. pr_err("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \
  48. __LINE__, current->pid, ##arg)
  49. #define mlx5_ib_warn(dev, format, arg...) \
  50. pr_warn("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \
  51. __LINE__, current->pid, ##arg)
  52. enum {
  53. MLX5_IB_MMAP_CMD_SHIFT = 8,
  54. MLX5_IB_MMAP_CMD_MASK = 0xff,
  55. };
  56. enum mlx5_ib_mmap_cmd {
  57. MLX5_IB_MMAP_REGULAR_PAGE = 0,
  58. MLX5_IB_MMAP_GET_CONTIGUOUS_PAGES = 1, /* always last */
  59. };
  60. enum {
  61. MLX5_RES_SCAT_DATA32_CQE = 0x1,
  62. MLX5_RES_SCAT_DATA64_CQE = 0x2,
  63. MLX5_REQ_SCAT_DATA32_CQE = 0x11,
  64. MLX5_REQ_SCAT_DATA64_CQE = 0x22,
  65. };
  66. enum mlx5_ib_latency_class {
  67. MLX5_IB_LATENCY_CLASS_LOW,
  68. MLX5_IB_LATENCY_CLASS_MEDIUM,
  69. MLX5_IB_LATENCY_CLASS_HIGH,
  70. MLX5_IB_LATENCY_CLASS_FAST_PATH
  71. };
  72. enum mlx5_ib_mad_ifc_flags {
  73. MLX5_MAD_IFC_IGNORE_MKEY = 1,
  74. MLX5_MAD_IFC_IGNORE_BKEY = 2,
  75. MLX5_MAD_IFC_NET_VIEW = 4,
  76. };
  77. struct mlx5_ib_ucontext {
  78. struct ib_ucontext ibucontext;
  79. struct list_head db_page_list;
  80. /* protect doorbell record alloc/free
  81. */
  82. struct mutex db_page_mutex;
  83. struct mlx5_uuar_info uuari;
  84. };
  85. static inline struct mlx5_ib_ucontext *to_mucontext(struct ib_ucontext *ibucontext)
  86. {
  87. return container_of(ibucontext, struct mlx5_ib_ucontext, ibucontext);
  88. }
  89. struct mlx5_ib_pd {
  90. struct ib_pd ibpd;
  91. u32 pdn;
  92. u32 pa_lkey;
  93. };
  94. /* Use macros here so that don't have to duplicate
  95. * enum ib_send_flags and enum ib_qp_type for low-level driver
  96. */
  97. #define MLX5_IB_SEND_UMR_UNREG IB_SEND_RESERVED_START
  98. #define MLX5_IB_QPT_REG_UMR IB_QPT_RESERVED1
  99. #define MLX5_IB_WR_UMR IB_WR_RESERVED1
  100. struct wr_list {
  101. u16 opcode;
  102. u16 next;
  103. };
  104. struct mlx5_ib_wq {
  105. u64 *wrid;
  106. u32 *wr_data;
  107. struct wr_list *w_list;
  108. unsigned *wqe_head;
  109. u16 unsig_count;
  110. /* serialize post to the work queue
  111. */
  112. spinlock_t lock;
  113. int wqe_cnt;
  114. int max_post;
  115. int max_gs;
  116. int offset;
  117. int wqe_shift;
  118. unsigned head;
  119. unsigned tail;
  120. u16 cur_post;
  121. u16 last_poll;
  122. void *qend;
  123. };
  124. enum {
  125. MLX5_QP_USER,
  126. MLX5_QP_KERNEL,
  127. MLX5_QP_EMPTY
  128. };
  129. struct mlx5_ib_qp {
  130. struct ib_qp ibqp;
  131. struct mlx5_core_qp mqp;
  132. struct mlx5_buf buf;
  133. struct mlx5_db db;
  134. struct mlx5_ib_wq rq;
  135. u32 doorbell_qpn;
  136. u8 sq_signal_bits;
  137. u8 fm_cache;
  138. int sq_max_wqes_per_wr;
  139. int sq_spare_wqes;
  140. struct mlx5_ib_wq sq;
  141. struct ib_umem *umem;
  142. int buf_size;
  143. /* serialize qp state modifications
  144. */
  145. struct mutex mutex;
  146. u16 xrcdn;
  147. u32 flags;
  148. u8 port;
  149. u8 alt_port;
  150. u8 atomic_rd_en;
  151. u8 resp_depth;
  152. u8 state;
  153. int mlx_type;
  154. int wq_sig;
  155. int scat_cqe;
  156. int max_inline_data;
  157. struct mlx5_bf *bf;
  158. int has_rq;
  159. /* only for user space QPs. For kernel
  160. * we have it from the bf object
  161. */
  162. int uuarn;
  163. int create_type;
  164. u32 pa_lkey;
  165. /* Store signature errors */
  166. bool signature_en;
  167. };
  168. struct mlx5_ib_cq_buf {
  169. struct mlx5_buf buf;
  170. struct ib_umem *umem;
  171. int cqe_size;
  172. int nent;
  173. };
  174. enum mlx5_ib_qp_flags {
  175. MLX5_IB_QP_BLOCK_MULTICAST_LOOPBACK = 1 << 0,
  176. MLX5_IB_QP_SIGNATURE_HANDLING = 1 << 1,
  177. };
  178. struct mlx5_shared_mr_info {
  179. int mr_id;
  180. struct ib_umem *umem;
  181. };
  182. struct mlx5_ib_cq {
  183. struct ib_cq ibcq;
  184. struct mlx5_core_cq mcq;
  185. struct mlx5_ib_cq_buf buf;
  186. struct mlx5_db db;
  187. /* serialize access to the CQ
  188. */
  189. spinlock_t lock;
  190. /* protect resize cq
  191. */
  192. struct mutex resize_mutex;
  193. struct mlx5_ib_cq_buf *resize_buf;
  194. struct ib_umem *resize_umem;
  195. int cqe_size;
  196. };
  197. struct mlx5_ib_srq {
  198. struct ib_srq ibsrq;
  199. struct mlx5_core_srq msrq;
  200. struct mlx5_buf buf;
  201. struct mlx5_db db;
  202. u64 *wrid;
  203. /* protect SRQ hanlding
  204. */
  205. spinlock_t lock;
  206. int head;
  207. int tail;
  208. u16 wqe_ctr;
  209. struct ib_umem *umem;
  210. /* serialize arming a SRQ
  211. */
  212. struct mutex mutex;
  213. int wq_sig;
  214. };
  215. struct mlx5_ib_xrcd {
  216. struct ib_xrcd ibxrcd;
  217. u32 xrcdn;
  218. };
  219. struct mlx5_ib_mr {
  220. struct ib_mr ibmr;
  221. struct mlx5_core_mr mmr;
  222. struct ib_umem *umem;
  223. struct mlx5_shared_mr_info *smr_info;
  224. struct list_head list;
  225. int order;
  226. int umred;
  227. __be64 *pas;
  228. dma_addr_t dma;
  229. int npages;
  230. struct mlx5_ib_dev *dev;
  231. struct mlx5_create_mkey_mbox_out out;
  232. struct mlx5_core_sig_ctx *sig;
  233. };
  234. struct mlx5_ib_fast_reg_page_list {
  235. struct ib_fast_reg_page_list ibfrpl;
  236. __be64 *mapped_page_list;
  237. dma_addr_t map;
  238. };
  239. struct mlx5_ib_umr_context {
  240. enum ib_wc_status status;
  241. struct completion done;
  242. };
  243. static inline void mlx5_ib_init_umr_context(struct mlx5_ib_umr_context *context)
  244. {
  245. context->status = -1;
  246. init_completion(&context->done);
  247. }
  248. struct umr_common {
  249. struct ib_pd *pd;
  250. struct ib_cq *cq;
  251. struct ib_qp *qp;
  252. struct ib_mr *mr;
  253. /* control access to UMR QP
  254. */
  255. struct semaphore sem;
  256. };
  257. enum {
  258. MLX5_FMR_INVALID,
  259. MLX5_FMR_VALID,
  260. MLX5_FMR_BUSY,
  261. };
  262. struct mlx5_ib_fmr {
  263. struct ib_fmr ibfmr;
  264. struct mlx5_core_mr mr;
  265. int access_flags;
  266. int state;
  267. /* protect fmr state
  268. */
  269. spinlock_t lock;
  270. u64 wrid;
  271. struct ib_send_wr wr[2];
  272. u8 page_shift;
  273. struct ib_fast_reg_page_list page_list;
  274. };
  275. struct mlx5_cache_ent {
  276. struct list_head head;
  277. /* sync access to the cahce entry
  278. */
  279. spinlock_t lock;
  280. struct dentry *dir;
  281. char name[4];
  282. u32 order;
  283. u32 size;
  284. u32 cur;
  285. u32 miss;
  286. u32 limit;
  287. struct dentry *fsize;
  288. struct dentry *fcur;
  289. struct dentry *fmiss;
  290. struct dentry *flimit;
  291. struct mlx5_ib_dev *dev;
  292. struct work_struct work;
  293. struct delayed_work dwork;
  294. int pending;
  295. };
  296. struct mlx5_mr_cache {
  297. struct workqueue_struct *wq;
  298. struct mlx5_cache_ent ent[MAX_MR_CACHE_ENTRIES];
  299. int stopped;
  300. struct dentry *root;
  301. unsigned long last_add;
  302. };
  303. struct mlx5_ib_resources {
  304. struct ib_cq *c0;
  305. struct ib_xrcd *x0;
  306. struct ib_xrcd *x1;
  307. struct ib_pd *p0;
  308. struct ib_srq *s0;
  309. };
  310. struct mlx5_ib_dev {
  311. struct ib_device ib_dev;
  312. struct mlx5_core_dev mdev;
  313. MLX5_DECLARE_DOORBELL_LOCK(uar_lock);
  314. struct list_head eqs_list;
  315. int num_ports;
  316. int num_comp_vectors;
  317. /* serialize update of capability mask
  318. */
  319. struct mutex cap_mask_mutex;
  320. bool ib_active;
  321. struct umr_common umrc;
  322. /* sync used page count stats
  323. */
  324. spinlock_t mr_lock;
  325. struct mlx5_ib_resources devr;
  326. struct mlx5_mr_cache cache;
  327. struct timer_list delay_timer;
  328. int fill_delay;
  329. };
  330. static inline struct mlx5_ib_cq *to_mibcq(struct mlx5_core_cq *mcq)
  331. {
  332. return container_of(mcq, struct mlx5_ib_cq, mcq);
  333. }
  334. static inline struct mlx5_ib_xrcd *to_mxrcd(struct ib_xrcd *ibxrcd)
  335. {
  336. return container_of(ibxrcd, struct mlx5_ib_xrcd, ibxrcd);
  337. }
  338. static inline struct mlx5_ib_dev *to_mdev(struct ib_device *ibdev)
  339. {
  340. return container_of(ibdev, struct mlx5_ib_dev, ib_dev);
  341. }
  342. static inline struct mlx5_ib_fmr *to_mfmr(struct ib_fmr *ibfmr)
  343. {
  344. return container_of(ibfmr, struct mlx5_ib_fmr, ibfmr);
  345. }
  346. static inline struct mlx5_ib_cq *to_mcq(struct ib_cq *ibcq)
  347. {
  348. return container_of(ibcq, struct mlx5_ib_cq, ibcq);
  349. }
  350. static inline struct mlx5_ib_qp *to_mibqp(struct mlx5_core_qp *mqp)
  351. {
  352. return container_of(mqp, struct mlx5_ib_qp, mqp);
  353. }
  354. static inline struct mlx5_ib_mr *to_mibmr(struct mlx5_core_mr *mmr)
  355. {
  356. return container_of(mmr, struct mlx5_ib_mr, mmr);
  357. }
  358. static inline struct mlx5_ib_pd *to_mpd(struct ib_pd *ibpd)
  359. {
  360. return container_of(ibpd, struct mlx5_ib_pd, ibpd);
  361. }
  362. static inline struct mlx5_ib_srq *to_msrq(struct ib_srq *ibsrq)
  363. {
  364. return container_of(ibsrq, struct mlx5_ib_srq, ibsrq);
  365. }
  366. static inline struct mlx5_ib_qp *to_mqp(struct ib_qp *ibqp)
  367. {
  368. return container_of(ibqp, struct mlx5_ib_qp, ibqp);
  369. }
  370. static inline struct mlx5_ib_srq *to_mibsrq(struct mlx5_core_srq *msrq)
  371. {
  372. return container_of(msrq, struct mlx5_ib_srq, msrq);
  373. }
  374. static inline struct mlx5_ib_mr *to_mmr(struct ib_mr *ibmr)
  375. {
  376. return container_of(ibmr, struct mlx5_ib_mr, ibmr);
  377. }
  378. static inline struct mlx5_ib_fast_reg_page_list *to_mfrpl(struct ib_fast_reg_page_list *ibfrpl)
  379. {
  380. return container_of(ibfrpl, struct mlx5_ib_fast_reg_page_list, ibfrpl);
  381. }
  382. struct mlx5_ib_ah {
  383. struct ib_ah ibah;
  384. struct mlx5_av av;
  385. };
  386. static inline struct mlx5_ib_ah *to_mah(struct ib_ah *ibah)
  387. {
  388. return container_of(ibah, struct mlx5_ib_ah, ibah);
  389. }
  390. static inline struct mlx5_ib_dev *mlx5_core2ibdev(struct mlx5_core_dev *dev)
  391. {
  392. return container_of(dev, struct mlx5_ib_dev, mdev);
  393. }
  394. static inline struct mlx5_ib_dev *mlx5_pci2ibdev(struct pci_dev *pdev)
  395. {
  396. return mlx5_core2ibdev(pci2mlx5_core_dev(pdev));
  397. }
  398. int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, unsigned long virt,
  399. struct mlx5_db *db);
  400. void mlx5_ib_db_unmap_user(struct mlx5_ib_ucontext *context, struct mlx5_db *db);
  401. void __mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq);
  402. void mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq);
  403. void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index);
  404. int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey,
  405. int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
  406. void *in_mad, void *response_mad);
  407. struct ib_ah *create_ib_ah(struct ib_ah_attr *ah_attr,
  408. struct mlx5_ib_ah *ah);
  409. struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
  410. int mlx5_ib_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr);
  411. int mlx5_ib_destroy_ah(struct ib_ah *ah);
  412. struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
  413. struct ib_srq_init_attr *init_attr,
  414. struct ib_udata *udata);
  415. int mlx5_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
  416. enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
  417. int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr);
  418. int mlx5_ib_destroy_srq(struct ib_srq *srq);
  419. int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
  420. struct ib_recv_wr **bad_wr);
  421. struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd,
  422. struct ib_qp_init_attr *init_attr,
  423. struct ib_udata *udata);
  424. int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
  425. int attr_mask, struct ib_udata *udata);
  426. int mlx5_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask,
  427. struct ib_qp_init_attr *qp_init_attr);
  428. int mlx5_ib_destroy_qp(struct ib_qp *qp);
  429. int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
  430. struct ib_send_wr **bad_wr);
  431. int mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
  432. struct ib_recv_wr **bad_wr);
  433. void *mlx5_get_send_wqe(struct mlx5_ib_qp *qp, int n);
  434. struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, int entries,
  435. int vector, struct ib_ucontext *context,
  436. struct ib_udata *udata);
  437. int mlx5_ib_destroy_cq(struct ib_cq *cq);
  438. int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
  439. int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
  440. int mlx5_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
  441. int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata);
  442. struct ib_mr *mlx5_ib_get_dma_mr(struct ib_pd *pd, int acc);
  443. struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
  444. u64 virt_addr, int access_flags,
  445. struct ib_udata *udata);
  446. int mlx5_ib_dereg_mr(struct ib_mr *ibmr);
  447. int mlx5_ib_destroy_mr(struct ib_mr *ibmr);
  448. struct ib_mr *mlx5_ib_create_mr(struct ib_pd *pd,
  449. struct ib_mr_init_attr *mr_init_attr);
  450. struct ib_mr *mlx5_ib_alloc_fast_reg_mr(struct ib_pd *pd,
  451. int max_page_list_len);
  452. struct ib_fast_reg_page_list *mlx5_ib_alloc_fast_reg_page_list(struct ib_device *ibdev,
  453. int page_list_len);
  454. void mlx5_ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list);
  455. struct ib_fmr *mlx5_ib_fmr_alloc(struct ib_pd *pd, int acc,
  456. struct ib_fmr_attr *fmr_attr);
  457. int mlx5_ib_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
  458. int npages, u64 iova);
  459. int mlx5_ib_unmap_fmr(struct list_head *fmr_list);
  460. int mlx5_ib_fmr_dealloc(struct ib_fmr *ibfmr);
  461. int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
  462. struct ib_wc *in_wc, struct ib_grh *in_grh,
  463. struct ib_mad *in_mad, struct ib_mad *out_mad);
  464. struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev,
  465. struct ib_ucontext *context,
  466. struct ib_udata *udata);
  467. int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd);
  468. int mlx5_vector2eqn(struct mlx5_ib_dev *dev, int vector, int *eqn, int *irqn);
  469. int mlx5_ib_get_buf_offset(u64 addr, int page_shift, u32 *offset);
  470. int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, u8 port);
  471. int mlx5_ib_query_port(struct ib_device *ibdev, u8 port,
  472. struct ib_port_attr *props);
  473. int mlx5_ib_init_fmr(struct mlx5_ib_dev *dev);
  474. void mlx5_ib_cleanup_fmr(struct mlx5_ib_dev *dev);
  475. void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
  476. int *ncont, int *order);
  477. void mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
  478. int page_shift, __be64 *pas, int umr);
  479. void mlx5_ib_copy_pas(u64 *old, u64 *new, int step, int num);
  480. int mlx5_ib_get_cqe_size(struct mlx5_ib_dev *dev, struct ib_cq *ibcq);
  481. int mlx5_mr_cache_init(struct mlx5_ib_dev *dev);
  482. int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev);
  483. int mlx5_mr_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift);
  484. void mlx5_umr_cq_handler(struct ib_cq *cq, void *cq_context);
  485. int mlx5_ib_check_mr_status(struct ib_mr *ibmr, u32 check_mask,
  486. struct ib_mr_status *mr_status);
  487. static inline void init_query_mad(struct ib_smp *mad)
  488. {
  489. mad->base_version = 1;
  490. mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
  491. mad->class_version = 1;
  492. mad->method = IB_MGMT_METHOD_GET;
  493. }
  494. static inline u8 convert_access(int acc)
  495. {
  496. return (acc & IB_ACCESS_REMOTE_ATOMIC ? MLX5_PERM_ATOMIC : 0) |
  497. (acc & IB_ACCESS_REMOTE_WRITE ? MLX5_PERM_REMOTE_WRITE : 0) |
  498. (acc & IB_ACCESS_REMOTE_READ ? MLX5_PERM_REMOTE_READ : 0) |
  499. (acc & IB_ACCESS_LOCAL_WRITE ? MLX5_PERM_LOCAL_WRITE : 0) |
  500. MLX5_PERM_LOCAL_READ;
  501. }
  502. #endif /* MLX5_IB_H */