162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. 462306a36Sopenharmony_ci * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#ifndef RXE_LOC_H 862306a36Sopenharmony_ci#define RXE_LOC_H 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci/* rxe_av.c */ 1162306a36Sopenharmony_civoid rxe_init_av(struct rdma_ah_attr *attr, struct rxe_av *av); 1262306a36Sopenharmony_ciint rxe_av_chk_attr(struct rxe_qp *qp, struct rdma_ah_attr *attr); 1362306a36Sopenharmony_ciint rxe_ah_chk_attr(struct rxe_ah *ah, struct rdma_ah_attr *attr); 1462306a36Sopenharmony_civoid rxe_av_from_attr(u8 port_num, struct rxe_av *av, 1562306a36Sopenharmony_ci struct rdma_ah_attr *attr); 1662306a36Sopenharmony_civoid rxe_av_to_attr(struct rxe_av *av, struct rdma_ah_attr *attr); 1762306a36Sopenharmony_civoid rxe_av_fill_ip_info(struct rxe_av *av, struct rdma_ah_attr *attr); 1862306a36Sopenharmony_cistruct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt, struct rxe_ah **ahp); 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci/* rxe_cq.c */ 2162306a36Sopenharmony_ciint rxe_cq_chk_attr(struct rxe_dev *rxe, struct rxe_cq *cq, 2262306a36Sopenharmony_ci int cqe, int comp_vector); 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ciint rxe_cq_from_init(struct rxe_dev *rxe, struct rxe_cq *cq, int cqe, 2562306a36Sopenharmony_ci int comp_vector, struct ib_udata *udata, 2662306a36Sopenharmony_ci struct rxe_create_cq_resp __user *uresp); 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ciint rxe_cq_resize_queue(struct rxe_cq *cq, int new_cqe, 2962306a36Sopenharmony_ci struct rxe_resize_cq_resp __user *uresp, 3062306a36Sopenharmony_ci struct ib_udata *udata); 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ciint rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited); 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_civoid rxe_cq_cleanup(struct rxe_pool_elem *elem); 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci/* rxe_mcast.c */ 3762306a36Sopenharmony_cistruct rxe_mcg *rxe_lookup_mcg(struct rxe_dev *rxe, union ib_gid *mgid); 3862306a36Sopenharmony_ciint rxe_attach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid); 3962306a36Sopenharmony_ciint rxe_detach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid); 4062306a36Sopenharmony_civoid rxe_cleanup_mcg(struct kref *kref); 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/* rxe_mmap.c */ 4362306a36Sopenharmony_cistruct rxe_mmap_info { 4462306a36Sopenharmony_ci struct list_head pending_mmaps; 4562306a36Sopenharmony_ci struct ib_ucontext *context; 4662306a36Sopenharmony_ci struct kref ref; 4762306a36Sopenharmony_ci void *obj; 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci struct mminfo info; 5062306a36Sopenharmony_ci}; 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_civoid rxe_mmap_release(struct kref *ref); 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_cistruct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *dev, u32 size, 5562306a36Sopenharmony_ci struct ib_udata *udata, void *obj); 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ciint rxe_mmap(struct ib_ucontext *context, struct vm_area_struct *vma); 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci/* rxe_mr.c */ 6062306a36Sopenharmony_ciu8 rxe_get_next_key(u32 last_key); 6162306a36Sopenharmony_civoid rxe_mr_init_dma(int access, struct rxe_mr *mr); 6262306a36Sopenharmony_ciint rxe_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, u64 iova, 6362306a36Sopenharmony_ci int access, struct rxe_mr *mr); 6462306a36Sopenharmony_ciint rxe_mr_init_fast(int max_pages, struct rxe_mr *mr); 6562306a36Sopenharmony_ciint rxe_flush_pmem_iova(struct rxe_mr *mr, u64 iova, unsigned int length); 6662306a36Sopenharmony_ciint rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, 6762306a36Sopenharmony_ci unsigned int length, enum rxe_mr_copy_dir dir); 6862306a36Sopenharmony_ciint copy_data(struct rxe_pd *pd, int access, struct rxe_dma_info *dma, 6962306a36Sopenharmony_ci void *addr, int length, enum rxe_mr_copy_dir dir); 7062306a36Sopenharmony_ciint rxe_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, 7162306a36Sopenharmony_ci int sg_nents, unsigned int *sg_offset); 7262306a36Sopenharmony_ciint rxe_mr_do_atomic_op(struct rxe_mr *mr, u64 iova, int opcode, 7362306a36Sopenharmony_ci u64 compare, u64 swap_add, u64 *orig_val); 7462306a36Sopenharmony_ciint rxe_mr_do_atomic_write(struct rxe_mr *mr, u64 iova, u64 value); 7562306a36Sopenharmony_cistruct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, 7662306a36Sopenharmony_ci enum rxe_mr_lookup_type type); 7762306a36Sopenharmony_ciint mr_check_range(struct rxe_mr *mr, u64 iova, size_t length); 7862306a36Sopenharmony_ciint advance_dma_data(struct rxe_dma_info *dma, unsigned int length); 7962306a36Sopenharmony_ciint rxe_invalidate_mr(struct rxe_qp *qp, u32 key); 8062306a36Sopenharmony_ciint rxe_reg_fast_mr(struct rxe_qp *qp, struct rxe_send_wqe *wqe); 8162306a36Sopenharmony_civoid rxe_mr_cleanup(struct rxe_pool_elem *elem); 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci/* rxe_mw.c */ 8462306a36Sopenharmony_ciint rxe_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata); 8562306a36Sopenharmony_ciint rxe_dealloc_mw(struct ib_mw *ibmw); 8662306a36Sopenharmony_ciint rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe); 8762306a36Sopenharmony_ciint rxe_invalidate_mw(struct rxe_qp *qp, u32 rkey); 8862306a36Sopenharmony_cistruct rxe_mw *rxe_lookup_mw(struct rxe_qp *qp, int access, u32 rkey); 8962306a36Sopenharmony_civoid rxe_mw_cleanup(struct rxe_pool_elem *elem); 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci/* rxe_net.c */ 9262306a36Sopenharmony_cistruct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av, 9362306a36Sopenharmony_ci int paylen, struct rxe_pkt_info *pkt); 9462306a36Sopenharmony_ciint rxe_prepare(struct rxe_av *av, struct rxe_pkt_info *pkt, 9562306a36Sopenharmony_ci struct sk_buff *skb); 9662306a36Sopenharmony_ciint rxe_xmit_packet(struct rxe_qp *qp, struct rxe_pkt_info *pkt, 9762306a36Sopenharmony_ci struct sk_buff *skb); 9862306a36Sopenharmony_ciconst char *rxe_parent_name(struct rxe_dev *rxe, unsigned int port_num); 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci/* rxe_qp.c */ 10162306a36Sopenharmony_ciint rxe_qp_chk_init(struct rxe_dev *rxe, struct ib_qp_init_attr *init); 10262306a36Sopenharmony_ciint rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd, 10362306a36Sopenharmony_ci struct ib_qp_init_attr *init, 10462306a36Sopenharmony_ci struct rxe_create_qp_resp __user *uresp, 10562306a36Sopenharmony_ci struct ib_pd *ibpd, struct ib_udata *udata); 10662306a36Sopenharmony_ciint rxe_qp_to_init(struct rxe_qp *qp, struct ib_qp_init_attr *init); 10762306a36Sopenharmony_ciint rxe_qp_chk_attr(struct rxe_dev *rxe, struct rxe_qp *qp, 10862306a36Sopenharmony_ci struct ib_qp_attr *attr, int mask); 10962306a36Sopenharmony_ciint rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, 11062306a36Sopenharmony_ci int mask, struct ib_udata *udata); 11162306a36Sopenharmony_ciint rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask); 11262306a36Sopenharmony_civoid rxe_qp_error(struct rxe_qp *qp); 11362306a36Sopenharmony_ciint rxe_qp_chk_destroy(struct rxe_qp *qp); 11462306a36Sopenharmony_civoid rxe_qp_cleanup(struct rxe_pool_elem *elem); 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_cistatic inline int qp_num(struct rxe_qp *qp) 11762306a36Sopenharmony_ci{ 11862306a36Sopenharmony_ci return qp->ibqp.qp_num; 11962306a36Sopenharmony_ci} 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_cistatic inline enum ib_qp_type qp_type(struct rxe_qp *qp) 12262306a36Sopenharmony_ci{ 12362306a36Sopenharmony_ci return qp->ibqp.qp_type; 12462306a36Sopenharmony_ci} 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_cistatic inline enum ib_qp_state qp_state(struct rxe_qp *qp) 12762306a36Sopenharmony_ci{ 12862306a36Sopenharmony_ci return qp->attr.qp_state; 12962306a36Sopenharmony_ci} 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_cistatic inline int qp_mtu(struct rxe_qp *qp) 13262306a36Sopenharmony_ci{ 13362306a36Sopenharmony_ci if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC) 13462306a36Sopenharmony_ci return qp->attr.path_mtu; 13562306a36Sopenharmony_ci else 13662306a36Sopenharmony_ci return IB_MTU_4096; 13762306a36Sopenharmony_ci} 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_civoid free_rd_atomic_resource(struct resp_res *res); 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_cistatic inline void rxe_advance_resp_resource(struct rxe_qp *qp) 14262306a36Sopenharmony_ci{ 14362306a36Sopenharmony_ci qp->resp.res_head++; 14462306a36Sopenharmony_ci if (unlikely(qp->resp.res_head == qp->attr.max_dest_rd_atomic)) 14562306a36Sopenharmony_ci qp->resp.res_head = 0; 14662306a36Sopenharmony_ci} 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_civoid retransmit_timer(struct timer_list *t); 14962306a36Sopenharmony_civoid rnr_nak_timer(struct timer_list *t); 15062306a36Sopenharmony_ci 15162306a36Sopenharmony_ci/* rxe_srq.c */ 15262306a36Sopenharmony_ciint rxe_srq_chk_init(struct rxe_dev *rxe, struct ib_srq_init_attr *init); 15362306a36Sopenharmony_ciint rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq, 15462306a36Sopenharmony_ci struct ib_srq_init_attr *init, struct ib_udata *udata, 15562306a36Sopenharmony_ci struct rxe_create_srq_resp __user *uresp); 15662306a36Sopenharmony_ciint rxe_srq_chk_attr(struct rxe_dev *rxe, struct rxe_srq *srq, 15762306a36Sopenharmony_ci struct ib_srq_attr *attr, enum ib_srq_attr_mask mask); 15862306a36Sopenharmony_ciint rxe_srq_from_attr(struct rxe_dev *rxe, struct rxe_srq *srq, 15962306a36Sopenharmony_ci struct ib_srq_attr *attr, enum ib_srq_attr_mask mask, 16062306a36Sopenharmony_ci struct rxe_modify_srq_cmd *ucmd, struct ib_udata *udata); 16162306a36Sopenharmony_civoid rxe_srq_cleanup(struct rxe_pool_elem *elem); 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_civoid rxe_dealloc(struct ib_device *ib_dev); 16462306a36Sopenharmony_ci 16562306a36Sopenharmony_ciint rxe_completer(struct rxe_qp *qp); 16662306a36Sopenharmony_ciint rxe_requester(struct rxe_qp *qp); 16762306a36Sopenharmony_ciint rxe_responder(struct rxe_qp *qp); 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci/* rxe_icrc.c */ 17062306a36Sopenharmony_ciint rxe_icrc_init(struct rxe_dev *rxe); 17162306a36Sopenharmony_ciint rxe_icrc_check(struct sk_buff *skb, struct rxe_pkt_info *pkt); 17262306a36Sopenharmony_civoid rxe_icrc_generate(struct sk_buff *skb, struct rxe_pkt_info *pkt); 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_civoid rxe_resp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb); 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_civoid rxe_comp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb); 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_cistatic inline unsigned int wr_opcode_mask(int opcode, struct rxe_qp *qp) 17962306a36Sopenharmony_ci{ 18062306a36Sopenharmony_ci return rxe_wr_opcode_info[opcode].mask[qp->ibqp.qp_type]; 18162306a36Sopenharmony_ci} 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ci#endif /* RXE_LOC_H */ 184