xref: /linux/drivers/infiniband/sw/siw/siw_verbs.h (revision ee88f4ebe57523889fc437bc42f95d9ab89bdd9f)
1 /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
2 
3 /* Authors: Bernard Metzler <bmt@zurich.ibm.com> */
4 /* Copyright (c) 2008-2019, IBM Corporation */
5 
6 #ifndef _SIW_VERBS_H
7 #define _SIW_VERBS_H
8 
9 #include <linux/errno.h>
10 
11 #include <rdma/iw_cm.h>
12 #include <rdma/ib_verbs.h>
13 #include <rdma/ib_user_verbs.h>
14 
15 #include "siw.h"
16 #include "siw_cm.h"
17 
18 /*
19  * siw_copy_sgl()
20  *
21  * Copy SGL from RDMA core representation to local
22  * representation.
23  */
24 static inline void siw_copy_sgl(struct ib_sge *sge, struct siw_sge *siw_sge,
25 				int num_sge)
26 {
27 	while (num_sge--) {
28 		siw_sge->laddr = sge->addr;
29 		siw_sge->length = sge->length;
30 		siw_sge->lkey = sge->lkey;
31 
32 		siw_sge++;
33 		sge++;
34 	}
35 }
36 
37 int siw_alloc_ucontext(struct ib_ucontext *base_ctx, struct ib_udata *udata);
38 void siw_dealloc_ucontext(struct ib_ucontext *base_ctx);
39 int siw_query_port(struct ib_device *base_dev, u8 port,
40 		   struct ib_port_attr *attr);
41 int siw_get_port_immutable(struct ib_device *base_dev, u8 port,
42 			   struct ib_port_immutable *port_immutable);
43 int siw_query_device(struct ib_device *base_dev, struct ib_device_attr *attr,
44 		     struct ib_udata *udata);
45 int siw_create_cq(struct ib_cq *base_cq, const struct ib_cq_init_attr *attr,
46 		  struct ib_udata *udata);
47 int siw_query_port(struct ib_device *base_dev, u8 port,
48 		   struct ib_port_attr *attr);
49 int siw_query_pkey(struct ib_device *base_dev, u8 port, u16 idx, u16 *pkey);
50 int siw_query_gid(struct ib_device *base_dev, u8 port, int idx,
51 		  union ib_gid *gid);
52 int siw_alloc_pd(struct ib_pd *base_pd, struct ib_udata *udata);
53 void siw_dealloc_pd(struct ib_pd *base_pd, struct ib_udata *udata);
54 struct ib_qp *siw_create_qp(struct ib_pd *base_pd,
55 			    struct ib_qp_init_attr *attr,
56 			    struct ib_udata *udata);
57 int siw_query_qp(struct ib_qp *base_qp, struct ib_qp_attr *qp_attr,
58 		 int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr);
59 int siw_verbs_modify_qp(struct ib_qp *base_qp, struct ib_qp_attr *attr,
60 			int attr_mask, struct ib_udata *udata);
61 int siw_destroy_qp(struct ib_qp *base_qp, struct ib_udata *udata);
62 int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr,
63 		  const struct ib_send_wr **bad_wr);
64 int siw_post_receive(struct ib_qp *base_qp, const struct ib_recv_wr *wr,
65 		     const struct ib_recv_wr **bad_wr);
66 void siw_destroy_cq(struct ib_cq *base_cq, struct ib_udata *udata);
67 int siw_poll_cq(struct ib_cq *base_cq, int num_entries, struct ib_wc *wc);
68 int siw_req_notify_cq(struct ib_cq *base_cq, enum ib_cq_notify_flags flags);
69 struct ib_mr *siw_reg_user_mr(struct ib_pd *base_pd, u64 start, u64 len,
70 			      u64 rnic_va, int rights, struct ib_udata *udata);
71 struct ib_mr *siw_alloc_mr(struct ib_pd *base_pd, enum ib_mr_type mr_type,
72 			   u32 max_sge, struct ib_udata *udata);
73 struct ib_mr *siw_get_dma_mr(struct ib_pd *base_pd, int rights);
74 int siw_map_mr_sg(struct ib_mr *base_mr, struct scatterlist *sl, int num_sle,
75 		  unsigned int *sg_off);
76 int siw_dereg_mr(struct ib_mr *base_mr, struct ib_udata *udata);
77 int siw_create_srq(struct ib_srq *base_srq, struct ib_srq_init_attr *attr,
78 		   struct ib_udata *udata);
79 int siw_modify_srq(struct ib_srq *base_srq, struct ib_srq_attr *attr,
80 		   enum ib_srq_attr_mask mask, struct ib_udata *udata);
81 int siw_query_srq(struct ib_srq *base_srq, struct ib_srq_attr *attr);
82 void siw_destroy_srq(struct ib_srq *base_srq, struct ib_udata *udata);
83 int siw_post_srq_recv(struct ib_srq *base_srq, const struct ib_recv_wr *wr,
84 		      const struct ib_recv_wr **bad_wr);
85 int siw_mmap(struct ib_ucontext *ctx, struct vm_area_struct *vma);
86 void siw_mmap_free(struct rdma_user_mmap_entry *rdma_entry);
87 void siw_qp_event(struct siw_qp *qp, enum ib_event_type type);
88 void siw_cq_event(struct siw_cq *cq, enum ib_event_type type);
89 void siw_srq_event(struct siw_srq *srq, enum ib_event_type type);
90 void siw_port_event(struct siw_device *dev, u8 port, enum ib_event_type type);
91 
92 #endif
93