rxe_loc.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
  2. /*
  3. * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
  4. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
  5. */
  6. #ifndef RXE_LOC_H
  7. #define RXE_LOC_H
  8. /* rxe_av.c */
  9. void rxe_init_av(struct rdma_ah_attr *attr, struct rxe_av *av);
  10. int rxe_av_chk_attr(struct rxe_dev *rxe, struct rdma_ah_attr *attr);
  11. void rxe_av_from_attr(u8 port_num, struct rxe_av *av,
  12. struct rdma_ah_attr *attr);
  13. void rxe_av_to_attr(struct rxe_av *av, struct rdma_ah_attr *attr);
  14. void rxe_av_fill_ip_info(struct rxe_av *av, struct rdma_ah_attr *attr);
  15. struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt, struct rxe_ah **ahp);
  16. /* rxe_cq.c */
  17. int rxe_cq_chk_attr(struct rxe_dev *rxe, struct rxe_cq *cq,
  18. int cqe, int comp_vector);
  19. int rxe_cq_from_init(struct rxe_dev *rxe, struct rxe_cq *cq, int cqe,
  20. int comp_vector, struct ib_udata *udata,
  21. struct rxe_create_cq_resp __user *uresp);
  22. int rxe_cq_resize_queue(struct rxe_cq *cq, int new_cqe,
  23. struct rxe_resize_cq_resp __user *uresp,
  24. struct ib_udata *udata);
  25. int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited);
  26. void rxe_cq_disable(struct rxe_cq *cq);
  27. void rxe_cq_cleanup(struct rxe_pool_elem *elem);
  28. /* rxe_mcast.c */
  29. struct rxe_mcg *rxe_lookup_mcg(struct rxe_dev *rxe, union ib_gid *mgid);
  30. int rxe_attach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid);
  31. int rxe_detach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid);
  32. void rxe_cleanup_mcg(struct kref *kref);
  33. /* rxe_mmap.c */
  34. struct rxe_mmap_info {
  35. struct list_head pending_mmaps;
  36. struct ib_ucontext *context;
  37. struct kref ref;
  38. void *obj;
  39. struct mminfo info;
  40. };
  41. void rxe_mmap_release(struct kref *ref);
  42. struct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *dev, u32 size,
  43. struct ib_udata *udata, void *obj);
  44. int rxe_mmap(struct ib_ucontext *context, struct vm_area_struct *vma);
  45. /* rxe_mr.c */
  46. u8 rxe_get_next_key(u32 last_key);
  47. void rxe_mr_init_dma(int access, struct rxe_mr *mr);
  48. int rxe_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, u64 iova,
  49. int access, struct rxe_mr *mr);
  50. int rxe_mr_init_fast(int max_pages, struct rxe_mr *mr);
  51. int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length,
  52. enum rxe_mr_copy_dir dir);
  53. int copy_data(struct rxe_pd *pd, int access, struct rxe_dma_info *dma,
  54. void *addr, int length, enum rxe_mr_copy_dir dir);
  55. void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length);
  56. struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key,
  57. enum rxe_mr_lookup_type type);
  58. int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length);
  59. int advance_dma_data(struct rxe_dma_info *dma, unsigned int length);
  60. int rxe_invalidate_mr(struct rxe_qp *qp, u32 key);
  61. int rxe_reg_fast_mr(struct rxe_qp *qp, struct rxe_send_wqe *wqe);
  62. int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
  63. void rxe_mr_cleanup(struct rxe_pool_elem *elem);
  64. /* rxe_mw.c */
  65. int rxe_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata);
  66. int rxe_dealloc_mw(struct ib_mw *ibmw);
  67. int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe);
  68. int rxe_invalidate_mw(struct rxe_qp *qp, u32 rkey);
  69. struct rxe_mw *rxe_lookup_mw(struct rxe_qp *qp, int access, u32 rkey);
  70. void rxe_mw_cleanup(struct rxe_pool_elem *elem);
  71. /* rxe_net.c */
  72. struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av,
  73. int paylen, struct rxe_pkt_info *pkt);
  74. int rxe_prepare(struct rxe_av *av, struct rxe_pkt_info *pkt,
  75. struct sk_buff *skb);
  76. int rxe_xmit_packet(struct rxe_qp *qp, struct rxe_pkt_info *pkt,
  77. struct sk_buff *skb);
  78. const char *rxe_parent_name(struct rxe_dev *rxe, unsigned int port_num);
  79. /* rxe_qp.c */
  80. int rxe_qp_chk_init(struct rxe_dev *rxe, struct ib_qp_init_attr *init);
  81. int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd,
  82. struct ib_qp_init_attr *init,
  83. struct rxe_create_qp_resp __user *uresp,
  84. struct ib_pd *ibpd, struct ib_udata *udata);
  85. int rxe_qp_to_init(struct rxe_qp *qp, struct ib_qp_init_attr *init);
  86. int rxe_qp_chk_attr(struct rxe_dev *rxe, struct rxe_qp *qp,
  87. struct ib_qp_attr *attr, int mask);
  88. int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr,
  89. int mask, struct ib_udata *udata);
  90. int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask);
  91. void rxe_qp_error(struct rxe_qp *qp);
  92. int rxe_qp_chk_destroy(struct rxe_qp *qp);
  93. void rxe_qp_cleanup(struct rxe_pool_elem *elem);
  94. static inline int qp_num(struct rxe_qp *qp)
  95. {
  96. return qp->ibqp.qp_num;
  97. }
  98. static inline enum ib_qp_type qp_type(struct rxe_qp *qp)
  99. {
  100. return qp->ibqp.qp_type;
  101. }
  102. static inline enum ib_qp_state qp_state(struct rxe_qp *qp)
  103. {
  104. return qp->attr.qp_state;
  105. }
  106. static inline int qp_mtu(struct rxe_qp *qp)
  107. {
  108. if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC)
  109. return qp->attr.path_mtu;
  110. else
  111. return IB_MTU_4096;
  112. }
  113. static inline int rcv_wqe_size(int max_sge)
  114. {
  115. return sizeof(struct rxe_recv_wqe) +
  116. max_sge * sizeof(struct ib_sge);
  117. }
  118. void free_rd_atomic_resource(struct resp_res *res);
  119. static inline void rxe_advance_resp_resource(struct rxe_qp *qp)
  120. {
  121. qp->resp.res_head++;
  122. if (unlikely(qp->resp.res_head == qp->attr.max_dest_rd_atomic))
  123. qp->resp.res_head = 0;
  124. }
  125. void retransmit_timer(struct timer_list *t);
  126. void rnr_nak_timer(struct timer_list *t);
  127. /* rxe_srq.c */
  128. int rxe_srq_chk_init(struct rxe_dev *rxe, struct ib_srq_init_attr *init);
  129. int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq,
  130. struct ib_srq_init_attr *init, struct ib_udata *udata,
  131. struct rxe_create_srq_resp __user *uresp);
  132. int rxe_srq_chk_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
  133. struct ib_srq_attr *attr, enum ib_srq_attr_mask mask);
  134. int rxe_srq_from_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
  135. struct ib_srq_attr *attr, enum ib_srq_attr_mask mask,
  136. struct rxe_modify_srq_cmd *ucmd, struct ib_udata *udata);
  137. void rxe_srq_cleanup(struct rxe_pool_elem *elem);
  138. void rxe_dealloc(struct ib_device *ib_dev);
  139. int rxe_completer(void *arg);
  140. int rxe_requester(void *arg);
  141. int rxe_responder(void *arg);
  142. /* rxe_icrc.c */
  143. int rxe_icrc_init(struct rxe_dev *rxe);
  144. int rxe_icrc_check(struct sk_buff *skb, struct rxe_pkt_info *pkt);
  145. void rxe_icrc_generate(struct sk_buff *skb, struct rxe_pkt_info *pkt);
  146. void rxe_resp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb);
  147. void rxe_comp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb);
  148. static inline unsigned int wr_opcode_mask(int opcode, struct rxe_qp *qp)
  149. {
  150. return rxe_wr_opcode_info[opcode].mask[qp->ibqp.qp_type];
  151. }
  152. #endif /* RXE_LOC_H */