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 */
siw_copy_sgl(struct ib_sge * sge,struct siw_sge * siw_sge,int num_sge)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, u32 port,
40 struct ib_port_attr *attr);
41 int siw_get_port_immutable(struct ib_device *base_dev, u32 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, u32 port,
48 struct ib_port_attr *attr);
49 int siw_query_gid(struct ib_device *base_dev, u32 port, int idx,
50 union ib_gid *gid);
51 int siw_alloc_pd(struct ib_pd *base_pd, struct ib_udata *udata);
52 int siw_dealloc_pd(struct ib_pd *base_pd, struct ib_udata *udata);
53 int siw_create_qp(struct ib_qp *qp, struct ib_qp_init_attr *attr,
54 struct ib_udata *udata);
55 int siw_query_qp(struct ib_qp *base_qp, struct ib_qp_attr *qp_attr,
56 int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr);
57 int siw_verbs_modify_qp(struct ib_qp *base_qp, struct ib_qp_attr *attr,
58 int attr_mask, struct ib_udata *udata);
59 int siw_destroy_qp(struct ib_qp *base_qp, struct ib_udata *udata);
60 int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr,
61 const struct ib_send_wr **bad_wr);
62 int siw_post_receive(struct ib_qp *base_qp, const struct ib_recv_wr *wr,
63 const struct ib_recv_wr **bad_wr);
64 int siw_destroy_cq(struct ib_cq *base_cq, struct ib_udata *udata);
65 int siw_poll_cq(struct ib_cq *base_cq, int num_entries, struct ib_wc *wc);
66 int siw_req_notify_cq(struct ib_cq *base_cq, enum ib_cq_notify_flags flags);
67 struct ib_mr *siw_reg_user_mr(struct ib_pd *base_pd, u64 start, u64 len,
68 u64 rnic_va, int rights, struct ib_udata *udata);
69 struct ib_mr *siw_alloc_mr(struct ib_pd *base_pd, enum ib_mr_type mr_type,
70 u32 max_sge);
71 struct ib_mr *siw_get_dma_mr(struct ib_pd *base_pd, int rights);
72 int siw_map_mr_sg(struct ib_mr *base_mr, struct scatterlist *sl, int num_sle,
73 unsigned int *sg_off);
74 int siw_dereg_mr(struct ib_mr *base_mr, struct ib_udata *udata);
75 int siw_create_srq(struct ib_srq *base_srq, struct ib_srq_init_attr *attr,
76 struct ib_udata *udata);
77 int siw_modify_srq(struct ib_srq *base_srq, struct ib_srq_attr *attr,
78 enum ib_srq_attr_mask mask, struct ib_udata *udata);
79 int siw_query_srq(struct ib_srq *base_srq, struct ib_srq_attr *attr);
80 int siw_destroy_srq(struct ib_srq *base_srq, struct ib_udata *udata);
81 int siw_post_srq_recv(struct ib_srq *base_srq, const struct ib_recv_wr *wr,
82 const struct ib_recv_wr **bad_wr);
83 int siw_mmap(struct ib_ucontext *ctx, struct vm_area_struct *vma);
84 void siw_mmap_free(struct rdma_user_mmap_entry *rdma_entry);
85 void siw_qp_event(struct siw_qp *qp, enum ib_event_type type);
86 void siw_cq_event(struct siw_cq *cq, enum ib_event_type type);
87 void siw_srq_event(struct siw_srq *srq, enum ib_event_type type);
88 void siw_port_event(struct siw_device *dev, u32 port, enum ib_event_type type);
89
90 #endif
91