xref: /freebsd/sys/dev/qlnx/qlnxr/qlnxr_verbs.h (revision 77013d11e6483b970af25e13c9b892075742f7e5)
1 /*
2  * Copyright (c) 2018-2019 Cavium, Inc.
3  * All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions
7  *  are met:
8  *
9  *  1. Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  *  2. Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  *
15  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  *  POSSIBILITY OF SUCH DAMAGE.
26  *
27  * $FreeBSD$
28  */
29 
30 #ifndef __QLNXR_VERBS_H__
31 #define __QLNXR_VERBS_H__
32 
33 extern int qlnxr_iw_query_gid(struct ib_device *,
34 			uint8_t port,
35 			int index,
36 			union ib_gid *gid);
37 
38 extern int qlnxr_query_gid(struct ib_device *,
39 			u8 port,
40 			int index,
41 			union ib_gid *gid);
42 
43 extern int qlnxr_create_srq(struct ib_srq *ibsrq,
44 			struct ib_srq_init_attr *,
45 			struct ib_udata *);
46 
47 extern void qlnxr_destroy_srq(struct ib_srq *,
48 			struct ib_udata *);
49 
50 extern int qlnxr_modify_srq(struct ib_srq *,
51 			struct ib_srq_attr *,
52 			enum ib_srq_attr_mask,
53 			struct ib_udata *);
54 
55 extern int qlnxr_query_srq(struct ib_srq *,
56 			struct ib_srq_attr *);
57 
58 extern int qlnxr_post_srq_recv(struct ib_srq *,
59 			const struct ib_recv_wr *,
60 			const struct ib_recv_wr **bad_recv_wr);
61 
62 #if __FreeBSD_version < 1102000
63 extern int qlnxr_query_device(struct ib_device *, struct ib_device_attr *);
64 #else
65 extern int qlnxr_query_device(struct ib_device *, struct ib_device_attr *,
66 		struct ib_udata *);
67 extern int qlnxr_get_port_immutable(struct ib_device *ibdev, u8 port_num,
68 		struct ib_port_immutable *immutable);
69 #endif
70 
71 extern int qlnxr_query_port(struct ib_device *,
72 			u8 port,
73 			struct ib_port_attr *props);
74 
75 extern int qlnxr_modify_port(struct ib_device *,
76 			u8 port,
77 			int mask,
78 			struct ib_port_modify *props);
79 
80 extern enum rdma_link_layer qlnxr_link_layer(struct ib_device *device,
81 			uint8_t port_num);
82 
83 extern int qlnxr_alloc_pd(struct ib_pd *ibpd, struct ib_udata *);
84 
85 extern void qlnxr_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata);
86 
87 extern int qlnxr_create_cq(struct ib_cq *ibcq,
88 		   const struct ib_cq_init_attr *attr,
89 		   struct ib_udata *udata);
90 
91 extern void qlnxr_destroy_cq(struct ib_cq *, struct ib_udata *);
92 
93 extern int qlnxr_resize_cq(struct ib_cq *,
94 			int cqe,
95 			struct ib_udata *);
96 
97 extern int qlnxr_poll_cq(struct ib_cq *,
98 			int num_entries,
99 			struct ib_wc *wc);
100 
101 extern struct ib_qp *qlnxr_create_qp(struct ib_pd *,
102 		       struct ib_qp_init_attr *attrs,
103 		       struct ib_udata *);
104 
105 extern int qlnxr_modify_qp(struct ib_qp *,
106 			struct ib_qp_attr *attr,
107 			int attr_mask,
108 			struct ib_udata *udata);
109 
110 extern int qlnxr_query_qp(struct ib_qp *,
111 			struct ib_qp_attr *qp_attr,
112 			int qp_attr_mask,
113 			struct ib_qp_init_attr *);
114 
115 extern int qlnxr_destroy_qp(struct ib_qp *, struct ib_udata *);
116 
117 extern int qlnxr_query_pkey(struct ib_device *,
118 			u8 port,
119 			u16 index,
120 			u16 *pkey);
121 
122 extern int qlnxr_create_ah(struct ib_ah *ibah,
123 			struct ib_ah_attr *attr, u32 flags,
124 			struct ib_udata *udata);
125 extern void qlnxr_destroy_ah(struct ib_ah *ibah, u32 flags);
126 
127 extern int qlnxr_query_ah(struct ib_ah *ibah,
128 			struct ib_ah_attr *attr);
129 
130 extern int qlnxr_modify_ah(struct ib_ah *ibah,
131 			struct ib_ah_attr *attr);
132 
133 #if __FreeBSD_version >= 1102000
134 extern int qlnxr_process_mad(struct ib_device *ibdev,
135 			int process_mad_flags,
136 			u8 port_num,
137 			const struct ib_wc *in_wc,
138 			const struct ib_grh *in_grh,
139 			const struct ib_mad_hdr *mad_hdr,
140 			size_t in_mad_size,
141 			struct ib_mad_hdr *out_mad,
142 			size_t *out_mad_size,
143 			u16 *out_mad_pkey_index);
144 #else
145 extern int qlnxr_process_mad(struct ib_device *ibdev,
146 			int process_mad_flags,
147 			u8 port_num,
148 			struct ib_wc *in_wc,
149 			struct ib_grh *in_grh,
150 			struct ib_mad *in_mad,
151 			struct ib_mad *out_mad);
152 #endif /* #if __FreeBSD_version >= 1102000 */
153 
154 extern int qlnxr_post_send(struct ib_qp *,
155 			const struct ib_send_wr *,
156 			const struct ib_send_wr **bad_wr);
157 
158 extern int qlnxr_post_recv(struct ib_qp *,
159 			const struct ib_recv_wr *,
160 			const struct ib_recv_wr **bad_wr);
161 
162 extern int qlnxr_arm_cq(struct ib_cq *,
163 			enum ib_cq_notify_flags flags);
164 
165 extern struct ib_mr *qlnxr_get_dma_mr(struct ib_pd *,
166 			int acc);
167 
168 #if __FreeBSD_version < 1102000
169 extern struct ib_mr *qlnxr_reg_kernel_mr(struct ib_pd *,
170 			struct ib_phys_buf *buffer_list,
171 			int num_phys_buf,
172 			int acc,
173 			u64 *iova_start);
174 #endif /* #if __FreeBSD_version < 1102000 */
175 
176 extern int qlnxr_dereg_mr(struct ib_mr *, struct ib_udata *);
177 
178 #if __FreeBSD_version >= 1102000
179 extern struct ib_mr *qlnxr_reg_user_mr(struct ib_pd *,
180 			u64 start,
181 			u64 length,
182 			u64 virt,
183 			int acc,
184 			struct ib_udata *);
185 #else
186 extern struct ib_mr *qlnxr_reg_user_mr(struct ib_pd *,
187 			u64 start,
188 			u64 length,
189 			u64 virt,
190 			int acc,
191 			struct ib_udata *,
192 			int mr_id);
193 #endif /* #if __FreeBSD_version >= 1102000 */
194 
195 #if __FreeBSD_version >= 1102000
196 
197 extern struct ib_mr *qlnxr_alloc_mr(struct ib_pd *pd,
198 			enum ib_mr_type mr_type, u32 max_num_sg,
199 			struct ib_udata *udata);
200 
201 extern int qlnxr_map_mr_sg(struct ib_mr *mr, struct scatterlist *sg,
202 			int sg_nents, unsigned int *sg_offset);
203 #else
204 
205 extern struct ib_mr *qlnxr_alloc_frmr(struct ib_pd *pd,
206 			int max_page_list_len);
207 
208 extern struct ib_fast_reg_page_list *qlnxr_alloc_frmr_page_list(
209 			struct ib_device *ibdev,
210 			int page_list_len);
211 
212 extern void qlnxr_free_frmr_page_list(struct ib_fast_reg_page_list *page_list);
213 
214 #endif /* #if  __FreeBSD_version >= 1102000 */
215 
216 extern int qlnxr_alloc_ucontext(struct ib_ucontext *uctx,
217 				struct ib_udata *udata);
218 
219 extern void qlnxr_dealloc_ucontext(struct ib_ucontext *ibctx);
220 
221 extern int qlnxr_mmap(struct ib_ucontext *, struct vm_area_struct *vma);
222 
223 extern int qlnxr_iw_connect(struct iw_cm_id *cm_id,
224 		    struct iw_cm_conn_param *conn_param);
225 
226 extern int qlnxr_iw_create_listen(struct iw_cm_id *cm_id, int backlog);
227 
228 void qlnxr_iw_destroy_listen(struct iw_cm_id *cm_id);
229 
230 extern int qlnxr_iw_accept(struct iw_cm_id *cm_id,
231 		      struct iw_cm_conn_param *conn_param);
232 
233 extern int qlnxr_iw_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len);
234 
235 extern void qlnxr_iw_qp_add_ref(struct ib_qp *qp);
236 
237 extern void qlnxr_iw_qp_rem_ref(struct ib_qp *qp);
238 
239 extern struct ib_qp *qlnxr_iw_get_qp(struct ib_device *dev, int qpn);
240 
241 #endif /* #ifndef __QLNXR_VERBS_H__ */
242