xref: /linux/drivers/infiniband/sw/rxe/rxe_loc.h (revision 67f57892f9b2c93a3a020109d2285232fbde8b81)
163fa15dbSBob Pearson /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
28700e3e7SMoni Shoua /*
38700e3e7SMoni Shoua  * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
48700e3e7SMoni Shoua  * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
58700e3e7SMoni Shoua  */
68700e3e7SMoni Shoua 
78700e3e7SMoni Shoua #ifndef RXE_LOC_H
88700e3e7SMoni Shoua #define RXE_LOC_H
98700e3e7SMoni Shoua 
108700e3e7SMoni Shoua /* rxe_av.c */
11fa407188SKamal Heib void rxe_init_av(struct rdma_ah_attr *attr, struct rxe_av *av);
1225fd735aSBob Pearson int rxe_av_chk_attr(struct rxe_qp *qp, struct rdma_ah_attr *attr);
1325fd735aSBob Pearson int rxe_ah_chk_attr(struct rxe_ah *ah, struct rdma_ah_attr *attr);
14ca3d9feeSZhu Yanjun void rxe_av_from_attr(u8 port_num, struct rxe_av *av,
151a241db1SZhu Yanjun 		     struct rdma_ah_attr *attr);
16a402dc44SZhu Yanjun void rxe_av_to_attr(struct rxe_av *av, struct rdma_ah_attr *attr);
1747ec3866SParav Pandit void rxe_av_fill_ip_info(struct rxe_av *av, struct rdma_ah_attr *attr);
1863221acbSBob Pearson struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt, struct rxe_ah **ahp);
198700e3e7SMoni Shoua 
208700e3e7SMoni Shoua /* rxe_cq.c */
218700e3e7SMoni Shoua int rxe_cq_chk_attr(struct rxe_dev *rxe, struct rxe_cq *cq,
22b92ec0feSJason Gunthorpe 		    int cqe, int comp_vector);
238700e3e7SMoni Shoua 
248700e3e7SMoni Shoua int rxe_cq_from_init(struct rxe_dev *rxe, struct rxe_cq *cq, int cqe,
25ff23dfa1SShamir Rabinovitch 		     int comp_vector, struct ib_udata *udata,
260c43ab37SJason Gunthorpe 		     struct rxe_create_cq_resp __user *uresp);
278700e3e7SMoni Shoua 
280c43ab37SJason Gunthorpe int rxe_cq_resize_queue(struct rxe_cq *cq, int new_cqe,
29ff23dfa1SShamir Rabinovitch 			struct rxe_resize_cq_resp __user *uresp,
30ff23dfa1SShamir Rabinovitch 			struct ib_udata *udata);
318700e3e7SMoni Shoua 
328700e3e7SMoni Shoua int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited);
338700e3e7SMoni Shoua 
34b2a41678SBob Pearson void rxe_cq_cleanup(struct rxe_pool_elem *elem);
358700e3e7SMoni Shoua 
368700e3e7SMoni Shoua /* rxe_mcast.c */
378a0a5fe0SBob Pearson struct rxe_mcg *rxe_lookup_mcg(struct rxe_dev *rxe, union ib_gid *mgid);
38758c7f1eSBob Pearson int rxe_attach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid);
39758c7f1eSBob Pearson int rxe_detach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid);
403810c1a1SBob Pearson void rxe_cleanup_mcg(struct kref *kref);
418700e3e7SMoni Shoua 
428700e3e7SMoni Shoua /* rxe_mmap.c */
438700e3e7SMoni Shoua struct rxe_mmap_info {
448700e3e7SMoni Shoua 	struct list_head	pending_mmaps;
458700e3e7SMoni Shoua 	struct ib_ucontext	*context;
468700e3e7SMoni Shoua 	struct kref		ref;
478700e3e7SMoni Shoua 	void			*obj;
488700e3e7SMoni Shoua 
498700e3e7SMoni Shoua 	struct mminfo info;
508700e3e7SMoni Shoua };
518700e3e7SMoni Shoua 
528700e3e7SMoni Shoua void rxe_mmap_release(struct kref *ref);
538700e3e7SMoni Shoua 
54ff23dfa1SShamir Rabinovitch struct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *dev, u32 size,
55ff23dfa1SShamir Rabinovitch 					   struct ib_udata *udata, void *obj);
568700e3e7SMoni Shoua 
578700e3e7SMoni Shoua int rxe_mmap(struct ib_ucontext *context, struct vm_area_struct *vma);
588700e3e7SMoni Shoua 
598700e3e7SMoni Shoua /* rxe_mr.c */
60beec0239SBob Pearson u8 rxe_get_next_key(u32 last_key);
6158651bbbSBob Pearson void rxe_mr_init_dma(int access, struct rxe_mr *mr);
62aafe4cc5SGuoqing Jiang int rxe_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length,
63cd5b010fSLang Cheng 		     int access, struct rxe_mr *mr);
6458651bbbSBob Pearson int rxe_mr_init_fast(int max_pages, struct rxe_mr *mr);
65592627ccSBob Pearson int rxe_flush_pmem_iova(struct rxe_mr *mr, u64 iova, unsigned int length);
66592627ccSBob Pearson int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr,
67592627ccSBob Pearson 		unsigned int length, enum rxe_mr_copy_dir dir);
681117f26eSBob Pearson int copy_data(struct rxe_pd *pd, int access, struct rxe_dma_info *dma,
691117f26eSBob Pearson 	      void *addr, int length, enum rxe_mr_copy_dir dir);
70db4729a5SBob Pearson int rxe_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
71db4729a5SBob Pearson 		  int sg_nents, unsigned int *sg_offset);
72f04d5b3dSBob Pearson int rxe_mr_do_atomic_op(struct rxe_mr *mr, u64 iova, int opcode,
73f04d5b3dSBob Pearson 			u64 compare, u64 swap_add, u64 *orig_val);
74d8bdb0ebSBob Pearson int rxe_mr_do_atomic_write(struct rxe_mr *mr, u64 iova, u64 value);
75364e282cSBob Pearson struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key,
763902b429SBob Pearson 			 enum rxe_mr_lookup_type type);
77364e282cSBob Pearson int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length);
788700e3e7SMoni Shoua int advance_dma_data(struct rxe_dma_info *dma, unsigned int length);
79174e7b13SMd Haris Iqbal int rxe_invalidate_mr(struct rxe_qp *qp, u32 key);
8000134533SBob Pearson int rxe_reg_fast_mr(struct rxe_qp *qp, struct rxe_send_wqe *wqe);
81b2a41678SBob Pearson void rxe_mr_cleanup(struct rxe_pool_elem *elem);
828700e3e7SMoni Shoua 
83beec0239SBob Pearson /* rxe_mw.c */
84beec0239SBob Pearson int rxe_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata);
85beec0239SBob Pearson int rxe_dealloc_mw(struct ib_mw *ibmw);
8632a577b4SBob Pearson int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe);
873902b429SBob Pearson int rxe_invalidate_mw(struct rxe_qp *qp, u32 rkey);
88cdd0b856SBob Pearson struct rxe_mw *rxe_lookup_mw(struct rxe_qp *qp, int access, u32 rkey);
89b2a41678SBob Pearson void rxe_mw_cleanup(struct rxe_pool_elem *elem);
90beec0239SBob Pearson 
91839f5ac0SBart Van Assche /* rxe_net.c */
92839f5ac0SBart Van Assche struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av,
93839f5ac0SBart Van Assche 				int paylen, struct rxe_pkt_info *pkt);
9463221acbSBob Pearson int rxe_prepare(struct rxe_av *av, struct rxe_pkt_info *pkt,
9563221acbSBob Pearson 		struct sk_buff *skb);
9636fbb03dSBob Pearson int rxe_xmit_packet(struct rxe_qp *qp, struct rxe_pkt_info *pkt,
9736fbb03dSBob Pearson 		    struct sk_buff *skb);
98839f5ac0SBart Van Assche const char *rxe_parent_name(struct rxe_dev *rxe, unsigned int port_num);
99839f5ac0SBart Van Assche 
1008700e3e7SMoni Shoua /* rxe_qp.c */
1018700e3e7SMoni Shoua int rxe_qp_chk_init(struct rxe_dev *rxe, struct ib_qp_init_attr *init);
1028700e3e7SMoni Shoua int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd,
1030c43ab37SJason Gunthorpe 		     struct ib_qp_init_attr *init,
1040c43ab37SJason Gunthorpe 		     struct rxe_create_qp_resp __user *uresp,
105e00b64f7SShamir Rabinovitch 		     struct ib_pd *ibpd, struct ib_udata *udata);
1068700e3e7SMoni Shoua int rxe_qp_to_init(struct rxe_qp *qp, struct ib_qp_init_attr *init);
1078700e3e7SMoni Shoua int rxe_qp_chk_attr(struct rxe_dev *rxe, struct rxe_qp *qp,
1088700e3e7SMoni Shoua 		    struct ib_qp_attr *attr, int mask);
1098700e3e7SMoni Shoua int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr,
1108700e3e7SMoni Shoua 		     int mask, struct ib_udata *udata);
1118700e3e7SMoni Shoua int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask);
1128700e3e7SMoni Shoua void rxe_qp_error(struct rxe_qp *qp);
113f9f48460SBob Pearson int rxe_qp_chk_destroy(struct rxe_qp *qp);
11402827b67SBob Pearson void rxe_qp_cleanup(struct rxe_pool_elem *elem);
1158700e3e7SMoni Shoua 
1168700e3e7SMoni Shoua static inline int qp_num(struct rxe_qp *qp)
1178700e3e7SMoni Shoua {
1188700e3e7SMoni Shoua 	return qp->ibqp.qp_num;
1198700e3e7SMoni Shoua }
1208700e3e7SMoni Shoua 
1218700e3e7SMoni Shoua static inline enum ib_qp_type qp_type(struct rxe_qp *qp)
1228700e3e7SMoni Shoua {
1238700e3e7SMoni Shoua 	return qp->ibqp.qp_type;
1248700e3e7SMoni Shoua }
1258700e3e7SMoni Shoua 
1268700e3e7SMoni Shoua static inline enum ib_qp_state qp_state(struct rxe_qp *qp)
1278700e3e7SMoni Shoua {
1288700e3e7SMoni Shoua 	return qp->attr.qp_state;
1298700e3e7SMoni Shoua }
1308700e3e7SMoni Shoua 
1318700e3e7SMoni Shoua static inline int qp_mtu(struct rxe_qp *qp)
1328700e3e7SMoni Shoua {
1338700e3e7SMoni Shoua 	if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC)
1348700e3e7SMoni Shoua 		return qp->attr.path_mtu;
1358700e3e7SMoni Shoua 	else
1360797e6f1SNathan Chancellor 		return IB_MTU_4096;
1378700e3e7SMoni Shoua }
1388700e3e7SMoni Shoua 
13968691badSXiao Yang void free_rd_atomic_resource(struct resp_res *res);
1408700e3e7SMoni Shoua 
1418700e3e7SMoni Shoua static inline void rxe_advance_resp_resource(struct rxe_qp *qp)
1428700e3e7SMoni Shoua {
1438700e3e7SMoni Shoua 	qp->resp.res_head++;
144b6bbee0dSParav Pandit 	if (unlikely(qp->resp.res_head == qp->attr.max_dest_rd_atomic))
1458700e3e7SMoni Shoua 		qp->resp.res_head = 0;
1468700e3e7SMoni Shoua }
1478700e3e7SMoni Shoua 
1483bfbea74SKees Cook void retransmit_timer(struct timer_list *t);
1493bfbea74SKees Cook void rnr_nak_timer(struct timer_list *t);
1508700e3e7SMoni Shoua 
1518700e3e7SMoni Shoua /* rxe_srq.c */
1520b1fbfb9SBob Pearson int rxe_srq_chk_init(struct rxe_dev *rxe, struct ib_srq_init_attr *init);
1538700e3e7SMoni Shoua int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq,
154ff23dfa1SShamir Rabinovitch 		      struct ib_srq_init_attr *init, struct ib_udata *udata,
1550c43ab37SJason Gunthorpe 		      struct rxe_create_srq_resp __user *uresp);
1560b1fbfb9SBob Pearson int rxe_srq_chk_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
1570b1fbfb9SBob Pearson 		     struct ib_srq_attr *attr, enum ib_srq_attr_mask mask);
1588700e3e7SMoni Shoua int rxe_srq_from_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
1598700e3e7SMoni Shoua 		      struct ib_srq_attr *attr, enum ib_srq_attr_mask mask,
160ff23dfa1SShamir Rabinovitch 		      struct rxe_modify_srq_cmd *ucmd, struct ib_udata *udata);
161b2a41678SBob Pearson void rxe_srq_cleanup(struct rxe_pool_elem *elem);
1628700e3e7SMoni Shoua 
163c367074bSJason Gunthorpe void rxe_dealloc(struct ib_device *ib_dev);
1648700e3e7SMoni Shoua 
1653946fc2aSBob Pearson int rxe_completer(struct rxe_qp *qp);
1663946fc2aSBob Pearson int rxe_requester(struct rxe_qp *qp);
16767f57892SBob Pearson int rxe_sender(struct rxe_qp *qp);
16867f57892SBob Pearson int rxe_receiver(struct rxe_qp *qp);
1698700e3e7SMoni Shoua 
170fe87fb17SBob Pearson /* rxe_icrc.c */
171add2b3b8SBob Pearson int rxe_icrc_init(struct rxe_dev *rxe);
172fe87fb17SBob Pearson int rxe_icrc_check(struct sk_buff *skb, struct rxe_pkt_info *pkt);
1731117f26eSBob Pearson void rxe_icrc_generate(struct sk_buff *skb, struct rxe_pkt_info *pkt);
1748700e3e7SMoni Shoua 
1759802c335SZhu Yanjun void rxe_resp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb);
1768700e3e7SMoni Shoua 
1779802c335SZhu Yanjun void rxe_comp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb);
1788700e3e7SMoni Shoua 
179c498e82eSKamal Heib static inline unsigned int wr_opcode_mask(int opcode, struct rxe_qp *qp)
1808700e3e7SMoni Shoua {
1818700e3e7SMoni Shoua 	return rxe_wr_opcode_info[opcode].mask[qp->ibqp.qp_type];
1828700e3e7SMoni Shoua }
1838700e3e7SMoni Shoua 
1848700e3e7SMoni Shoua #endif /* RXE_LOC_H */
185