ib_verbs.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * Broadcom NetXtreme-E RoCE driver.
  3. *
  4. * Copyright (c) 2016 - 2017, Broadcom. All rights reserved. The term
  5. * Broadcom refers to Broadcom Limited and/or its subsidiaries.
  6. *
  7. * This software is available to you under a choice of one of two
  8. * licenses. You may choose to be licensed under the terms of the GNU
  9. * General Public License (GPL) Version 2, available from the file
  10. * COPYING in the main directory of this source tree, or the
  11. * BSD license below:
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions
  15. * are met:
  16. *
  17. * 1. Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. * 2. Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in
  21. * the documentation and/or other materials provided with the
  22. * distribution.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  26. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  27. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
  28. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  30. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  31. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  32. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  33. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  34. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. * Description: IB Verbs interpreter (header)
  37. */
  38. #ifndef __BNXT_RE_IB_VERBS_H__
  39. #define __BNXT_RE_IB_VERBS_H__
  40. struct bnxt_re_gid_ctx {
  41. u32 idx;
  42. u32 refcnt;
  43. };
  44. struct bnxt_re_pd {
  45. struct bnxt_re_dev *rdev;
  46. struct ib_pd ib_pd;
  47. struct bnxt_qplib_pd qplib_pd;
  48. struct bnxt_qplib_dpi dpi;
  49. };
  50. struct bnxt_re_ah {
  51. struct bnxt_re_dev *rdev;
  52. struct ib_ah ib_ah;
  53. struct bnxt_qplib_ah qplib_ah;
  54. };
  55. struct bnxt_re_qp {
  56. struct list_head list;
  57. struct bnxt_re_dev *rdev;
  58. struct ib_qp ib_qp;
  59. spinlock_t sq_lock; /* protect sq */
  60. struct bnxt_qplib_qp qplib_qp;
  61. struct ib_umem *sumem;
  62. struct ib_umem *rumem;
  63. /* QP1 */
  64. u32 send_psn;
  65. struct ib_ud_header qp1_hdr;
  66. };
  67. struct bnxt_re_cq {
  68. struct bnxt_re_dev *rdev;
  69. spinlock_t cq_lock; /* protect cq */
  70. u16 cq_count;
  71. u16 cq_period;
  72. struct ib_cq ib_cq;
  73. struct bnxt_qplib_cq qplib_cq;
  74. struct bnxt_qplib_cqe *cql;
  75. #define MAX_CQL_PER_POLL 1024
  76. u32 max_cql;
  77. struct ib_umem *umem;
  78. };
  79. struct bnxt_re_mr {
  80. struct bnxt_re_dev *rdev;
  81. struct ib_mr ib_mr;
  82. struct ib_umem *ib_umem;
  83. struct bnxt_qplib_mrw qplib_mr;
  84. u32 npages;
  85. u64 *pages;
  86. struct bnxt_qplib_frpl qplib_frpl;
  87. };
  88. struct bnxt_re_frpl {
  89. struct bnxt_re_dev *rdev;
  90. struct bnxt_qplib_frpl qplib_frpl;
  91. u64 *page_list;
  92. };
  93. struct bnxt_re_fmr {
  94. struct bnxt_re_dev *rdev;
  95. struct ib_fmr ib_fmr;
  96. struct bnxt_qplib_mrw qplib_fmr;
  97. };
  98. struct bnxt_re_mw {
  99. struct bnxt_re_dev *rdev;
  100. struct ib_mw ib_mw;
  101. struct bnxt_qplib_mrw qplib_mw;
  102. };
  103. struct bnxt_re_ucontext {
  104. struct bnxt_re_dev *rdev;
  105. struct ib_ucontext ib_uctx;
  106. struct bnxt_qplib_dpi *dpi;
  107. void *shpg;
  108. spinlock_t sh_lock; /* protect shpg */
  109. };
  110. struct net_device *bnxt_re_get_netdev(struct ib_device *ibdev, u8 port_num);
  111. int bnxt_re_query_device(struct ib_device *ibdev,
  112. struct ib_device_attr *ib_attr,
  113. struct ib_udata *udata);
  114. int bnxt_re_modify_device(struct ib_device *ibdev,
  115. int device_modify_mask,
  116. struct ib_device_modify *device_modify);
  117. int bnxt_re_query_port(struct ib_device *ibdev, u8 port_num,
  118. struct ib_port_attr *port_attr);
  119. int bnxt_re_modify_port(struct ib_device *ibdev, u8 port_num,
  120. int port_modify_mask,
  121. struct ib_port_modify *port_modify);
  122. int bnxt_re_get_port_immutable(struct ib_device *ibdev, u8 port_num,
  123. struct ib_port_immutable *immutable);
  124. int bnxt_re_query_pkey(struct ib_device *ibdev, u8 port_num,
  125. u16 index, u16 *pkey);
  126. int bnxt_re_del_gid(struct ib_device *ibdev, u8 port_num,
  127. unsigned int index, void **context);
  128. int bnxt_re_add_gid(struct ib_device *ibdev, u8 port_num,
  129. unsigned int index, const union ib_gid *gid,
  130. const struct ib_gid_attr *attr, void **context);
  131. int bnxt_re_query_gid(struct ib_device *ibdev, u8 port_num,
  132. int index, union ib_gid *gid);
  133. enum rdma_link_layer bnxt_re_get_link_layer(struct ib_device *ibdev,
  134. u8 port_num);
  135. struct ib_pd *bnxt_re_alloc_pd(struct ib_device *ibdev,
  136. struct ib_ucontext *context,
  137. struct ib_udata *udata);
  138. int bnxt_re_dealloc_pd(struct ib_pd *pd);
  139. struct ib_ah *bnxt_re_create_ah(struct ib_pd *pd,
  140. struct rdma_ah_attr *ah_attr,
  141. struct ib_udata *udata);
  142. int bnxt_re_modify_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr);
  143. int bnxt_re_query_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr);
  144. int bnxt_re_destroy_ah(struct ib_ah *ah);
  145. struct ib_qp *bnxt_re_create_qp(struct ib_pd *pd,
  146. struct ib_qp_init_attr *qp_init_attr,
  147. struct ib_udata *udata);
  148. int bnxt_re_modify_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
  149. int qp_attr_mask, struct ib_udata *udata);
  150. int bnxt_re_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
  151. int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr);
  152. int bnxt_re_destroy_qp(struct ib_qp *qp);
  153. int bnxt_re_post_send(struct ib_qp *qp, struct ib_send_wr *send_wr,
  154. struct ib_send_wr **bad_send_wr);
  155. int bnxt_re_post_recv(struct ib_qp *qp, struct ib_recv_wr *recv_wr,
  156. struct ib_recv_wr **bad_recv_wr);
  157. struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev,
  158. const struct ib_cq_init_attr *attr,
  159. struct ib_ucontext *context,
  160. struct ib_udata *udata);
  161. int bnxt_re_destroy_cq(struct ib_cq *cq);
  162. int bnxt_re_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc);
  163. int bnxt_re_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
  164. struct ib_mr *bnxt_re_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
  165. int bnxt_re_map_mr_sg(struct ib_mr *ib_mr, struct scatterlist *sg, int sg_nents,
  166. unsigned int *sg_offset);
  167. struct ib_mr *bnxt_re_alloc_mr(struct ib_pd *ib_pd, enum ib_mr_type mr_type,
  168. u32 max_num_sg);
  169. int bnxt_re_dereg_mr(struct ib_mr *mr);
  170. struct ib_fmr *bnxt_re_alloc_fmr(struct ib_pd *pd, int mr_access_flags,
  171. struct ib_fmr_attr *fmr_attr);
  172. int bnxt_re_map_phys_fmr(struct ib_fmr *fmr, u64 *page_list, int list_len,
  173. u64 iova);
  174. int bnxt_re_unmap_fmr(struct list_head *fmr_list);
  175. int bnxt_re_dealloc_fmr(struct ib_fmr *fmr);
  176. struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
  177. u64 virt_addr, int mr_access_flags,
  178. struct ib_udata *udata);
  179. struct ib_ucontext *bnxt_re_alloc_ucontext(struct ib_device *ibdev,
  180. struct ib_udata *udata);
  181. int bnxt_re_dealloc_ucontext(struct ib_ucontext *context);
  182. int bnxt_re_mmap(struct ib_ucontext *context, struct vm_area_struct *vma);
  183. #endif /* __BNXT_RE_IB_VERBS_H__ */