xref: /freebsd/sys/dev/qlnx/qlnxr/qlnxr_verbs.h (revision cfd6422a5217410fbd66f7a7a8a64d9d85e61229)
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 struct ib_srq *qlnxr_create_srq(struct ib_pd *,
44 			struct ib_srq_init_attr *,
45 			struct ib_udata *);
46 
47 extern int qlnxr_destroy_srq(struct ib_srq *);
48 
49 extern int qlnxr_modify_srq(struct ib_srq *,
50 			struct ib_srq_attr *,
51 			enum ib_srq_attr_mask,
52 			struct ib_udata *);
53 
54 extern int qlnxr_query_srq(struct ib_srq *,
55 			struct ib_srq_attr *);
56 
57 extern int qlnxr_post_srq_recv(struct ib_srq *,
58 			struct ib_recv_wr *,
59 			struct ib_recv_wr **bad_recv_wr);
60 
61 #if __FreeBSD_version < 1102000
62 extern int qlnxr_query_device(struct ib_device *, struct ib_device_attr *);
63 #else
64 extern int qlnxr_query_device(struct ib_device *, struct ib_device_attr *,
65 		struct ib_udata *);
66 extern int qlnxr_get_port_immutable(struct ib_device *ibdev, u8 port_num,
67 		struct ib_port_immutable *immutable);
68 #endif
69 
70 extern int qlnxr_query_port(struct ib_device *,
71 			u8 port,
72 			struct ib_port_attr *props);
73 
74 extern int qlnxr_modify_port(struct ib_device *,
75 			u8 port,
76 			int mask,
77 			struct ib_port_modify *props);
78 
79 extern enum rdma_link_layer qlnxr_link_layer(struct ib_device *device,
80 			uint8_t port_num);
81 
82 struct ib_pd *qlnxr_alloc_pd(struct ib_device *,
83 			struct ib_ucontext *,
84 			struct ib_udata *);
85 
86 extern int qlnxr_dealloc_pd(struct ib_pd *pd);
87 
88 #if __FreeBSD_version >= 1102000
89 extern struct ib_cq *qlnxr_create_cq(struct ib_device *ibdev,
90 			const struct ib_cq_init_attr *attr,
91 			struct ib_ucontext *ib_ctx,
92 			struct ib_udata *udata);
93 #else
94 #if __FreeBSD_version >= 1100000
95 extern struct ib_cq *qlnxr_create_cq(struct ib_device *ibdev,
96 			struct ib_cq_init_attr *attr,
97 			struct ib_ucontext *ib_ctx,
98 			struct ib_udata *udata);
99 #else
100 extern struct ib_cq *qlnxr_create_cq(struct ib_device *ibdev,
101 			int cqe,
102 			int comp_vector,
103 			struct ib_ucontext *ib_ctx,
104 			struct ib_udata *udata);
105 #endif
106 #endif /* #if __FreeBSD_version >= 1102000 */
107 
108 extern int qlnxr_destroy_cq(struct ib_cq *);
109 
110 extern int qlnxr_resize_cq(struct ib_cq *,
111 			int cqe,
112 			struct ib_udata *);
113 
114 extern int qlnxr_poll_cq(struct ib_cq *,
115 			int num_entries,
116 			struct ib_wc *wc);
117 
118 extern struct ib_qp *qlnxr_create_qp(struct ib_pd *,
119 		       struct ib_qp_init_attr *attrs,
120 		       struct ib_udata *);
121 
122 extern int qlnxr_modify_qp(struct ib_qp *,
123 			struct ib_qp_attr *attr,
124 			int attr_mask,
125 			struct ib_udata *udata);
126 
127 extern int qlnxr_query_qp(struct ib_qp *,
128 			struct ib_qp_attr *qp_attr,
129 			int qp_attr_mask,
130 			struct ib_qp_init_attr *);
131 
132 extern int qlnxr_destroy_qp(struct ib_qp *);
133 
134 extern int qlnxr_query_pkey(struct ib_device *,
135 			u8 port,
136 			u16 index,
137 			u16 *pkey);
138 
139 #if __FreeBSD_version >= 1102000
140 extern struct ib_ah *qlnxr_create_ah(struct ib_pd *ibpd,
141 			struct ib_ah_attr *attr, struct ib_udata *udata);
142 #else
143 extern struct ib_ah *qlnxr_create_ah(struct ib_pd *ibpd,
144 			struct ib_ah_attr *attr);
145 #endif /* #if __FreeBSD_version >= 1102000 */
146 
147 extern int qlnxr_destroy_ah(struct ib_ah *ibah);
148 
149 extern int qlnxr_query_ah(struct ib_ah *ibah,
150 			struct ib_ah_attr *attr);
151 
152 extern int qlnxr_modify_ah(struct ib_ah *ibah,
153 			struct ib_ah_attr *attr);
154 
155 #if __FreeBSD_version >= 1102000
156 extern int qlnxr_process_mad(struct ib_device *ibdev,
157 			int process_mad_flags,
158 			u8 port_num,
159 			const struct ib_wc *in_wc,
160 			const struct ib_grh *in_grh,
161 			const struct ib_mad_hdr *mad_hdr,
162 			size_t in_mad_size,
163 			struct ib_mad_hdr *out_mad,
164 			size_t *out_mad_size,
165 			u16 *out_mad_pkey_index);
166 #else
167 extern int qlnxr_process_mad(struct ib_device *ibdev,
168 			int process_mad_flags,
169 			u8 port_num,
170 			struct ib_wc *in_wc,
171 			struct ib_grh *in_grh,
172 			struct ib_mad *in_mad,
173 			struct ib_mad *out_mad);
174 #endif /* #if __FreeBSD_version >= 1102000 */
175 
176 extern int qlnxr_post_send(struct ib_qp *,
177 			struct ib_send_wr *,
178 			struct ib_send_wr **bad_wr);
179 
180 extern int qlnxr_post_recv(struct ib_qp *,
181 			struct ib_recv_wr *,
182 			struct ib_recv_wr **bad_wr);
183 
184 extern int qlnxr_arm_cq(struct ib_cq *,
185 			enum ib_cq_notify_flags flags);
186 
187 extern struct ib_mr *qlnxr_get_dma_mr(struct ib_pd *,
188 			int acc);
189 
190 #if __FreeBSD_version < 1102000
191 extern struct ib_mr *qlnxr_reg_kernel_mr(struct ib_pd *,
192 			struct ib_phys_buf *buffer_list,
193 			int num_phys_buf,
194 			int acc,
195 			u64 *iova_start);
196 #endif /* #if __FreeBSD_version < 1102000 */
197 
198 extern int qlnxr_dereg_mr(struct ib_mr *);
199 
200 #if __FreeBSD_version >= 1102000
201 extern struct ib_mr *qlnxr_reg_user_mr(struct ib_pd *,
202 			u64 start,
203 			u64 length,
204 			u64 virt,
205 			int acc,
206 			struct ib_udata *);
207 #else
208 extern struct ib_mr *qlnxr_reg_user_mr(struct ib_pd *,
209 			u64 start,
210 			u64 length,
211 			u64 virt,
212 			int acc,
213 			struct ib_udata *,
214 			int mr_id);
215 #endif /* #if __FreeBSD_version >= 1102000 */
216 
217 #if __FreeBSD_version >= 1102000
218 
219 extern struct ib_mr *qlnxr_alloc_mr(struct ib_pd *pd,
220 			enum ib_mr_type mr_type, u32 max_num_sg);
221 extern int qlnxr_map_mr_sg(struct ib_mr *mr, struct scatterlist *sg,
222 			int sg_nents, unsigned int *sg_offset);
223 #else
224 
225 extern struct ib_mr *qlnxr_alloc_frmr(struct ib_pd *pd,
226 			int max_page_list_len);
227 
228 extern struct ib_fast_reg_page_list *qlnxr_alloc_frmr_page_list(
229 			struct ib_device *ibdev,
230 			int page_list_len);
231 
232 extern void qlnxr_free_frmr_page_list(struct ib_fast_reg_page_list *page_list);
233 
234 #endif /* #if  __FreeBSD_version >= 1102000 */
235 
236 extern struct ib_ucontext *qlnxr_alloc_ucontext(struct ib_device *ibdev,
237                 struct ib_udata *udata);
238 
239 extern int qlnxr_dealloc_ucontext(struct ib_ucontext *ibctx);
240 
241 extern int qlnxr_mmap(struct ib_ucontext *, struct vm_area_struct *vma);
242 
243 extern int qlnxr_iw_connect(struct iw_cm_id *cm_id,
244 		    struct iw_cm_conn_param *conn_param);
245 
246 extern int qlnxr_iw_create_listen(struct iw_cm_id *cm_id, int backlog);
247 
248 void qlnxr_iw_destroy_listen(struct iw_cm_id *cm_id);
249 
250 extern int qlnxr_iw_accept(struct iw_cm_id *cm_id,
251 		      struct iw_cm_conn_param *conn_param);
252 
253 extern int qlnxr_iw_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len);
254 
255 extern void qlnxr_iw_qp_add_ref(struct ib_qp *qp);
256 
257 extern void qlnxr_iw_qp_rem_ref(struct ib_qp *qp);
258 
259 extern struct ib_qp *qlnxr_iw_get_qp(struct ib_device *dev, int qpn);
260 
261 #endif /* #ifndef __QLNXR_VERBS_H__ */
262