| 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 | |
| 7 | #ifndef RXE_LOC_H |
| 8 | #define RXE_LOC_H |
| 9 | |
| 10 | /* rxe_av.c */ |
| 11 | void rxe_init_av(struct rdma_ah_attr *attr, struct rxe_av *av); |
| 12 | int rxe_av_chk_attr(struct rxe_qp *qp, struct rdma_ah_attr *attr); |
| 13 | int rxe_ah_chk_attr(struct rxe_ah *ah, struct rdma_ah_attr *attr); |
| 14 | void rxe_av_from_attr(u8 port_num, struct rxe_av *av, |
| 15 | struct rdma_ah_attr *attr); |
| 16 | void rxe_av_to_attr(struct rxe_av *av, struct rdma_ah_attr *attr); |
| 17 | void rxe_av_fill_ip_info(struct rxe_av *av, struct rdma_ah_attr *attr); |
| 18 | struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt, struct rxe_ah **ahp); |
| 19 | |
| 20 | /* rxe_cq.c */ |
| 21 | int rxe_cq_chk_attr(struct rxe_dev *rxe, struct rxe_cq *cq, |
| 22 | int cqe, int comp_vector); |
| 23 | |
| 24 | int rxe_cq_from_init(struct rxe_dev *rxe, struct rxe_cq *cq, int cqe, |
| 25 | int comp_vector, struct ib_udata *udata, |
| 26 | struct rxe_create_cq_resp __user *uresp); |
| 27 | |
| 28 | int rxe_cq_resize_queue(struct rxe_cq *cq, int new_cqe, |
| 29 | struct rxe_resize_cq_resp __user *uresp, |
| 30 | struct ib_udata *udata); |
| 31 | |
| 32 | int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited); |
| 33 | |
| 34 | void rxe_cq_cleanup(struct rxe_pool_elem *elem); |
| 35 | |
| 36 | /* rxe_mcast.c */ |
| 37 | struct rxe_mcg *rxe_lookup_mcg(struct rxe_dev *rxe, union ib_gid *mgid); |
| 38 | int rxe_attach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid); |
| 39 | int rxe_detach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid); |
| 40 | void rxe_cleanup_mcg(struct kref *kref); |
| 41 | |
| 42 | /* rxe_mmap.c */ |
| 43 | struct rxe_mmap_info { |
| 44 | struct list_head pending_mmaps; |
| 45 | struct ib_ucontext *context; |
| 46 | struct kref ref; |
| 47 | void *obj; |
| 48 | |
| 49 | struct mminfo info; |
| 50 | }; |
| 51 | |
| 52 | void rxe_mmap_release(struct kref *ref); |
| 53 | |
| 54 | struct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *dev, u32 size, |
| 55 | struct ib_udata *udata, void *obj); |
| 56 | |
| 57 | int rxe_mmap(struct ib_ucontext *context, struct vm_area_struct *vma); |
| 58 | |
| 59 | /* rxe_mr.c */ |
| 60 | u8 rxe_get_next_key(u32 last_key); |
| 61 | void rxe_mr_init(int access, struct rxe_mr *mr); |
| 62 | void rxe_mr_init_dma(int access, struct rxe_mr *mr); |
| 63 | int rxe_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, |
| 64 | int access, struct rxe_mr *mr); |
| 65 | int rxe_mr_init_fast(int max_pages, struct rxe_mr *mr); |
| 66 | int rxe_flush_pmem_iova(struct rxe_mr *mr, u64 iova, unsigned int length); |
| 67 | int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, |
| 68 | unsigned int length, enum rxe_mr_copy_dir dir); |
| 69 | int copy_data(struct rxe_pd *pd, int access, struct rxe_dma_info *dma, |
| 70 | void *addr, int length, enum rxe_mr_copy_dir dir); |
| 71 | int rxe_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, |
| 72 | int sg_nents, unsigned int *sg_offset); |
| 73 | enum resp_states rxe_mr_do_atomic_op(struct rxe_mr *mr, u64 iova, int opcode, |
| 74 | u64 compare, u64 swap_add, u64 *orig_val); |
| 75 | enum resp_states rxe_mr_do_atomic_write(struct rxe_mr *mr, u64 iova, u64 value); |
| 76 | struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, |
| 77 | enum rxe_mr_lookup_type type); |
| 78 | int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length); |
| 79 | int advance_dma_data(struct rxe_dma_info *dma, unsigned int length); |
| 80 | int rxe_invalidate_mr(struct rxe_qp *qp, u32 key); |
| 81 | int rxe_reg_fast_mr(struct rxe_qp *qp, struct rxe_send_wqe *wqe); |
| 82 | void rxe_mr_cleanup(struct rxe_pool_elem *elem); |
| 83 | |
| 84 | /* defined in rxe_mr.c; used in rxe_mr.c and rxe_odp.c */ |
| 85 | extern spinlock_t atomic_ops_lock; |
| 86 | |
| 87 | /* rxe_mw.c */ |
| 88 | int rxe_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata); |
| 89 | int rxe_dealloc_mw(struct ib_mw *ibmw); |
| 90 | int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe); |
| 91 | int rxe_invalidate_mw(struct rxe_qp *qp, u32 rkey); |
| 92 | struct rxe_mw *rxe_lookup_mw(struct rxe_qp *qp, int access, u32 rkey); |
| 93 | void rxe_mw_cleanup(struct rxe_pool_elem *elem); |
| 94 | |
| 95 | /* rxe_net.c */ |
| 96 | struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av, |
| 97 | int paylen, struct rxe_pkt_info *pkt); |
| 98 | int rxe_prepare(struct rxe_av *av, struct rxe_pkt_info *pkt, |
| 99 | struct sk_buff *skb); |
| 100 | int rxe_xmit_packet(struct rxe_qp *qp, struct rxe_pkt_info *pkt, |
| 101 | struct sk_buff *skb); |
| 102 | const char *rxe_parent_name(struct rxe_dev *rxe, unsigned int port_num); |
| 103 | |
| 104 | /* rxe_qp.c */ |
| 105 | int rxe_qp_chk_init(struct rxe_dev *rxe, struct ib_qp_init_attr *init); |
| 106 | int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd, |
| 107 | struct ib_qp_init_attr *init, |
| 108 | struct rxe_create_qp_resp __user *uresp, |
| 109 | struct ib_pd *ibpd, struct ib_udata *udata); |
| 110 | int rxe_qp_to_init(struct rxe_qp *qp, struct ib_qp_init_attr *init); |
| 111 | int rxe_qp_chk_attr(struct rxe_dev *rxe, struct rxe_qp *qp, |
| 112 | struct ib_qp_attr *attr, int mask); |
| 113 | int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, |
| 114 | int mask, struct ib_udata *udata); |
| 115 | int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask); |
| 116 | void rxe_qp_error(struct rxe_qp *qp); |
| 117 | int rxe_qp_chk_destroy(struct rxe_qp *qp); |
| 118 | void rxe_qp_cleanup(struct rxe_pool_elem *elem); |
| 119 | |
| 120 | static inline int qp_num(struct rxe_qp *qp) |
| 121 | { |
| 122 | return qp->ibqp.qp_num; |
| 123 | } |
| 124 | |
| 125 | static inline enum ib_qp_type qp_type(struct rxe_qp *qp) |
| 126 | { |
| 127 | return qp->ibqp.qp_type; |
| 128 | } |
| 129 | |
| 130 | static inline enum ib_qp_state qp_state(struct rxe_qp *qp) |
| 131 | { |
| 132 | return qp->attr.qp_state; |
| 133 | } |
| 134 | |
| 135 | static inline int qp_mtu(struct rxe_qp *qp) |
| 136 | { |
| 137 | if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC) |
| 138 | return qp->attr.path_mtu; |
| 139 | else |
| 140 | return IB_MTU_4096; |
| 141 | } |
| 142 | |
| 143 | static inline bool is_odp_mr(struct rxe_mr *mr) |
| 144 | { |
| 145 | return IS_ENABLED(CONFIG_INFINIBAND_ON_DEMAND_PAGING) && mr->umem && |
| 146 | mr->umem->is_odp; |
| 147 | } |
| 148 | |
| 149 | void free_rd_atomic_resource(struct resp_res *res); |
| 150 | |
| 151 | static inline void rxe_advance_resp_resource(struct rxe_qp *qp) |
| 152 | { |
| 153 | qp->resp.res_head++; |
| 154 | if (unlikely(qp->resp.res_head == qp->attr.max_dest_rd_atomic)) |
| 155 | qp->resp.res_head = 0; |
| 156 | } |
| 157 | |
| 158 | void retransmit_timer(struct timer_list *t); |
| 159 | void rnr_nak_timer(struct timer_list *t); |
| 160 | |
| 161 | /* rxe_srq.c */ |
| 162 | int rxe_srq_chk_init(struct rxe_dev *rxe, struct ib_srq_init_attr *init); |
| 163 | int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq, |
| 164 | struct ib_srq_init_attr *init, struct ib_udata *udata, |
| 165 | struct rxe_create_srq_resp __user *uresp); |
| 166 | int rxe_srq_chk_attr(struct rxe_dev *rxe, struct rxe_srq *srq, |
| 167 | struct ib_srq_attr *attr, enum ib_srq_attr_mask mask); |
| 168 | int rxe_srq_from_attr(struct rxe_dev *rxe, struct rxe_srq *srq, |
| 169 | struct ib_srq_attr *attr, enum ib_srq_attr_mask mask, |
| 170 | struct rxe_modify_srq_cmd *ucmd, struct ib_udata *udata); |
| 171 | void rxe_srq_cleanup(struct rxe_pool_elem *elem); |
| 172 | |
| 173 | void rxe_dealloc(struct ib_device *ib_dev); |
| 174 | |
| 175 | int rxe_completer(struct rxe_qp *qp); |
| 176 | int rxe_requester(struct rxe_qp *qp); |
| 177 | int rxe_sender(struct rxe_qp *qp); |
| 178 | int rxe_receiver(struct rxe_qp *qp); |
| 179 | |
| 180 | /* rxe_icrc.c */ |
| 181 | int rxe_icrc_check(struct sk_buff *skb, struct rxe_pkt_info *pkt); |
| 182 | void rxe_icrc_generate(struct sk_buff *skb, struct rxe_pkt_info *pkt); |
| 183 | |
| 184 | void rxe_resp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb); |
| 185 | |
| 186 | void rxe_comp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb); |
| 187 | |
| 188 | static inline unsigned int wr_opcode_mask(int opcode, struct rxe_qp *qp) |
| 189 | { |
| 190 | return rxe_wr_opcode_info[opcode].mask[qp->ibqp.qp_type]; |
| 191 | } |
| 192 | |
| 193 | /* rxe_odp.c */ |
| 194 | extern const struct mmu_interval_notifier_ops rxe_mn_ops; |
| 195 | |
| 196 | #if defined CONFIG_INFINIBAND_ON_DEMAND_PAGING |
| 197 | int rxe_odp_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, |
| 198 | u64 iova, int access_flags, struct rxe_mr *mr); |
| 199 | int rxe_odp_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length, |
| 200 | enum rxe_mr_copy_dir dir); |
| 201 | enum resp_states rxe_odp_atomic_op(struct rxe_mr *mr, u64 iova, int opcode, |
| 202 | u64 compare, u64 swap_add, u64 *orig_val); |
| 203 | int rxe_odp_flush_pmem_iova(struct rxe_mr *mr, u64 iova, |
| 204 | unsigned int length); |
| 205 | enum resp_states rxe_odp_do_atomic_write(struct rxe_mr *mr, u64 iova, u64 value); |
| 206 | #else /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */ |
| 207 | static inline int |
| 208 | rxe_odp_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, u64 iova, |
| 209 | int access_flags, struct rxe_mr *mr) |
| 210 | { |
| 211 | return -EOPNOTSUPP; |
| 212 | } |
| 213 | static inline int rxe_odp_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, |
| 214 | int length, enum rxe_mr_copy_dir dir) |
| 215 | { |
| 216 | return -EOPNOTSUPP; |
| 217 | } |
| 218 | static inline enum resp_states |
| 219 | rxe_odp_atomic_op(struct rxe_mr *mr, u64 iova, int opcode, |
| 220 | u64 compare, u64 swap_add, u64 *orig_val) |
| 221 | { |
| 222 | return RESPST_ERR_UNSUPPORTED_OPCODE; |
| 223 | } |
| 224 | static inline int rxe_odp_flush_pmem_iova(struct rxe_mr *mr, u64 iova, |
| 225 | unsigned int length) |
| 226 | { |
| 227 | return -EOPNOTSUPP; |
| 228 | } |
| 229 | static inline enum resp_states rxe_odp_do_atomic_write(struct rxe_mr *mr, |
| 230 | u64 iova, u64 value) |
| 231 | { |
| 232 | return RESPST_ERR_UNSUPPORTED_OPCODE; |
| 233 | } |
| 234 | #endif /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */ |
| 235 | |
| 236 | #endif /* RXE_LOC_H */ |
| 237 | |