1330502Shselasky/*-
2330502Shselasky * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3330502Shselasky *
4330502Shselasky * Copyright (c) 2018, Mellanox Technologies, Ltd.  All rights reserved.
5330502Shselasky *
6330502Shselasky * Redistribution and use in source and binary forms, with or without
7330502Shselasky * modification, are permitted provided that the following conditions
8330502Shselasky * are met:
9330502Shselasky * 1. Redistributions of source code must retain the above copyright
10330502Shselasky *    notice, this list of conditions and the following disclaimer.
11330502Shselasky * 2. Redistributions in binary form must reproduce the above copyright
12330502Shselasky *    notice, this list of conditions and the following disclaimer in the
13330502Shselasky *    documentation and/or other materials provided with the distribution.
14330502Shselasky *
15330502Shselasky * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
16330502Shselasky * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17330502Shselasky * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18330502Shselasky * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
19330502Shselasky * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20330502Shselasky * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21330502Shselasky * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22330502Shselasky * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23330502Shselasky * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24330502Shselasky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25330502Shselasky * SUCH DAMAGE.
26330502Shselasky *
27330502Shselasky * $FreeBSD: stable/11/sys/ofed/include/rdma/ib_verbs_compat.h 331769 2018-03-30 18:06:29Z hselasky $
28330502Shselasky */
29330502Shselasky
30330502Shselasky#if !defined(IB_VERBS_COMPAT_H)
31330502Shselasky#define	IB_VERBS_COMPAT_H
32330502Shselasky
33330502Shselasky#include <rdma/ib_verbs.h>
34330502Shselasky
35330502Shselaskyenum ib_device_attr_comp_mask {
36330502Shselasky	IB_DEVICE_ATTR_WITH_TIMESTAMP_MASK = 1ULL << 1,
37330502Shselasky	IB_DEVICE_ATTR_WITH_HCA_CORE_CLOCK = 1ULL << 2
38330502Shselasky};
39330502Shselasky
40330502Shselaskystruct ib_protocol_stats {
41330502Shselasky	/* TBD... */
42330502Shselasky};
43330502Shselasky
44330502Shselaskystruct iw_protocol_stats {
45330502Shselasky	u64	ipInReceives;
46330502Shselasky	u64	ipInHdrErrors;
47330502Shselasky	u64	ipInTooBigErrors;
48330502Shselasky	u64	ipInNoRoutes;
49330502Shselasky	u64	ipInAddrErrors;
50330502Shselasky	u64	ipInUnknownProtos;
51330502Shselasky	u64	ipInTruncatedPkts;
52330502Shselasky	u64	ipInDiscards;
53330502Shselasky	u64	ipInDelivers;
54330502Shselasky	u64	ipOutForwDatagrams;
55330502Shselasky	u64	ipOutRequests;
56330502Shselasky	u64	ipOutDiscards;
57330502Shselasky	u64	ipOutNoRoutes;
58330502Shselasky	u64	ipReasmTimeout;
59330502Shselasky	u64	ipReasmReqds;
60330502Shselasky	u64	ipReasmOKs;
61330502Shselasky	u64	ipReasmFails;
62330502Shselasky	u64	ipFragOKs;
63330502Shselasky	u64	ipFragFails;
64330502Shselasky	u64	ipFragCreates;
65330502Shselasky	u64	ipInMcastPkts;
66330502Shselasky	u64	ipOutMcastPkts;
67330502Shselasky	u64	ipInBcastPkts;
68330502Shselasky	u64	ipOutBcastPkts;
69330502Shselasky
70330502Shselasky	u64	tcpRtoAlgorithm;
71330502Shselasky	u64	tcpRtoMin;
72330502Shselasky	u64	tcpRtoMax;
73330502Shselasky	u64	tcpMaxConn;
74330502Shselasky	u64	tcpActiveOpens;
75330502Shselasky	u64	tcpPassiveOpens;
76330502Shselasky	u64	tcpAttemptFails;
77330502Shselasky	u64	tcpEstabResets;
78330502Shselasky	u64	tcpCurrEstab;
79330502Shselasky	u64	tcpInSegs;
80330502Shselasky	u64	tcpOutSegs;
81330502Shselasky	u64	tcpRetransSegs;
82330502Shselasky	u64	tcpInErrs;
83330502Shselasky	u64	tcpOutRsts;
84330502Shselasky};
85330502Shselasky
86330502Shselaskyunion rdma_protocol_stats {
87330502Shselasky	struct ib_protocol_stats ib;
88330502Shselasky	struct iw_protocol_stats iw;
89330502Shselasky};
90330502Shselasky
91330502Shselaskyenum ib_mr_create_flags {
92330502Shselasky	IB_MR_SIGNATURE_EN = 1,
93330502Shselasky};
94330502Shselasky
95330502Shselaskystruct ib_mr_init_attr {
96330502Shselasky	int	max_reg_descriptors;
97330502Shselasky	u32	flags;
98330502Shselasky};
99330502Shselasky
100330502Shselaskyenum ib_qpg_type {
101330502Shselasky	IB_QPG_NONE = 0,
102330502Shselasky	IB_QPG_PARENT = (1 << 0),
103330502Shselasky	IB_QPG_CHILD_RX = (1 << 1),
104330502Shselasky	IB_QPG_CHILD_TX = (1 << 2)
105330502Shselasky};
106330502Shselasky
107330502Shselaskystruct ib_qpg_init_attrib {
108330502Shselasky	u32	tss_child_count;
109330502Shselasky	u32	rss_child_count;
110330502Shselasky};
111330502Shselasky
112330502Shselaskyenum {
113330502Shselasky	IB_DCT_CREATE_FLAG_RCV_INLINE = 1 << 0,
114330502Shselasky	IB_DCT_CREATE_FLAGS_MASK = IB_DCT_CREATE_FLAG_RCV_INLINE,
115330502Shselasky};
116330502Shselasky
117330502Shselaskystruct ib_dct_init_attr {
118330502Shselasky	struct ib_pd *pd;
119330502Shselasky	struct ib_cq *cq;
120330502Shselasky	struct ib_srq *srq;
121330502Shselasky	u64	dc_key;
122330502Shselasky	u8	port;
123330502Shselasky	u32	access_flags;
124330502Shselasky	u8	min_rnr_timer;
125330502Shselasky	u8	tclass;
126330502Shselasky	u32	flow_label;
127330502Shselasky	enum ib_mtu mtu;
128330502Shselasky	u8	pkey_index;
129330502Shselasky	u8	gid_index;
130330502Shselasky	u8	hop_limit;
131330502Shselasky	u32	create_flags;
132330502Shselasky};
133330502Shselasky
134330502Shselaskystruct ib_dct_attr {
135330502Shselasky	u64	dc_key;
136330502Shselasky	u8	port;
137330502Shselasky	u32	access_flags;
138330502Shselasky	u8	min_rnr_timer;
139330502Shselasky	u8	tclass;
140330502Shselasky	u32	flow_label;
141330502Shselasky	enum ib_mtu mtu;
142330502Shselasky	u8	pkey_index;
143330502Shselasky	u8	gid_index;
144330502Shselasky	u8	hop_limit;
145330502Shselasky	u32	key_violations;
146330502Shselasky	u8	state;
147330502Shselasky};
148330502Shselasky
149330502Shselaskystruct ib_fast_reg_page_list {
150330502Shselasky	struct ib_device *device;
151330502Shselasky	u64    *page_list;
152330502Shselasky	unsigned int max_page_list_len;
153330502Shselasky};
154330502Shselasky
155330502Shselaskystruct ib_mw_bind_info {
156330502Shselasky	struct ib_mr *mr;
157330502Shselasky	u64	addr;
158330502Shselasky	u64	length;
159330502Shselasky	int	mw_access_flags;
160330502Shselasky};
161330502Shselasky
162330502Shselaskystruct ib_mr_attr {
163330502Shselasky	struct ib_pd *pd;
164330502Shselasky	u64	device_virt_addr;
165330502Shselasky	u64	size;
166330502Shselasky	int	mr_access_flags;
167330502Shselasky	u32	lkey;
168330502Shselasky	u32	rkey;
169330502Shselasky};
170330502Shselasky
171330502Shselaskystruct ib_mw_bind {
172330502Shselasky	u64	wr_id;
173330502Shselasky	int	send_flags;
174330502Shselasky	struct ib_mw_bind_info bind_info;
175330502Shselasky};
176330502Shselasky
177330502Shselaskyenum ib_cq_attr_mask {
178330502Shselasky	IB_CQ_MODERATION = (1 << 0),
179330502Shselasky	IB_CQ_CAP_FLAGS = (1 << 1)
180330502Shselasky};
181330502Shselasky
182330502Shselaskyenum ib_cq_cap_flags {
183330502Shselasky	IB_CQ_IGNORE_OVERRUN = (1 << 0)
184330502Shselasky};
185330502Shselasky
186330502Shselaskystruct ib_cq_attr {
187330502Shselasky	struct {
188330502Shselasky		u16	cq_count;
189330502Shselasky		u16	cq_period;
190330502Shselasky	}	moderation;
191330502Shselasky	u32	cq_cap_flags;
192330502Shselasky};
193330502Shselasky
194330502Shselaskystruct ib_dct {
195330502Shselasky	struct ib_device *device;
196330502Shselasky	struct ib_uobject *uobject;
197330502Shselasky	struct ib_pd *pd;
198330502Shselasky	struct ib_cq *cq;
199330502Shselasky	struct ib_srq *srq;
200330502Shselasky	u32	dct_num;
201330502Shselasky};
202330502Shselasky
203330502Shselaskyenum verbs_values_mask {
204330502Shselasky	IBV_VALUES_HW_CLOCK = 1 << 0
205330502Shselasky};
206330502Shselasky
207330502Shselaskystruct ib_device_values {
208330502Shselasky	int	values_mask;
209330502Shselasky	uint64_t hwclock;
210330502Shselasky};
211330502Shselasky
212330502Shselasky#define	IB_WR_FAST_REG_MR -2		/* not implemented */
213330502Shselasky
214330502Shselaskystruct ib_send_wr_compat {
215330502Shselasky	union {
216330502Shselasky		/*
217330502Shselasky		 * NOTE: The following structure must be kept in sync
218330502Shselasky		 * with "struct ib_send_wr":
219330502Shselasky		 */
220330502Shselasky		struct {
221330502Shselasky			struct ib_send_wr_compat *next;
222330502Shselasky			union {
223330502Shselasky				u64	wr_id;
224330502Shselasky				struct ib_cqe *wr_cqe;
225330502Shselasky			};
226330502Shselasky			struct ib_sge *sg_list;
227330502Shselasky			int	num_sge;
228330502Shselasky			enum ib_wr_opcode opcode;
229330502Shselasky			int	send_flags;
230330502Shselasky			union {
231330502Shselasky				__be32	imm_data;
232330502Shselasky				u32	invalidate_rkey;
233330502Shselasky			}	ex;
234330502Shselasky		};
235330502Shselasky		union {
236330502Shselasky			struct ib_rdma_wr rdma;
237330502Shselasky			struct ib_atomic_wr atomic;
238330502Shselasky			struct ib_ud_wr ud;
239330502Shselasky			struct ib_sig_handover_wr sig_handover;
240330502Shselasky			struct {
241330502Shselasky				struct ib_send_wr wr;
242330502Shselasky				u64	iova_start;
243330502Shselasky				struct ib_fast_reg_page_list *page_list;
244330502Shselasky				unsigned int page_shift;
245330502Shselasky				unsigned int page_list_len;
246330502Shselasky				u32	length;
247330502Shselasky				int	access_flags;
248330502Shselasky				u32	rkey;
249330502Shselasky			}	fast_reg;
250330502Shselasky			struct {
251330502Shselasky				struct ib_send_wr wr;
252330502Shselasky				int	npages;
253330502Shselasky				int	access_flags;
254330502Shselasky				u32	mkey;
255330502Shselasky				struct ib_pd *pd;
256330502Shselasky				u64	virt_addr;
257330502Shselasky				u64	length;
258330502Shselasky				int	page_shift;
259330502Shselasky			}	umr;
260330502Shselasky			struct {
261330502Shselasky				struct ib_send_wr wr;
262330502Shselasky				struct ib_mw *mw;
263330502Shselasky				/* The new rkey for the memory window. */
264330502Shselasky				u32	rkey;
265330502Shselasky				struct ib_mw_bind_info bind_info;
266330502Shselasky			}	bind_mw;
267330502Shselasky		}	wr;
268330502Shselasky	};
269330502Shselasky	u32	xrc_remote_srq_num;	/* XRC TGT QPs only */
270330502Shselasky};
271330502Shselasky
272330502Shselaskystatic inline int
273330502Shselaskyib_post_send_compat(struct ib_qp *qp,
274330502Shselasky    struct ib_send_wr_compat *send_wr,
275330502Shselasky    struct ib_send_wr_compat **bad_send_wr)
276330502Shselasky{
277330502Shselasky	return (ib_post_send(qp, (struct ib_send_wr *)send_wr,
278330502Shselasky	    (struct ib_send_wr **)bad_send_wr));
279330502Shselasky}
280330502Shselasky
281330502Shselasky#undef ib_post_send
282330502Shselasky#define	ib_post_send(...) \
283330502Shselasky	ib_post_send_compat(__VA_ARGS__)
284330502Shselasky
285330502Shselasky#define	ib_send_wr \
286330502Shselasky	ib_send_wr_compat
287330502Shselasky
288330502Shselaskystatic inline int
289330502Shselaskyib_query_device_compat(struct ib_device *device,
290330502Shselasky    struct ib_device_attr *device_attr)
291330502Shselasky{
292330502Shselasky	*device_attr = device->attrs;
293330502Shselasky	return (0);
294330502Shselasky}
295330502Shselasky
296330502Shselasky#undef ib_query_device
297330502Shselasky#define	ib_query_device(...) \
298330502Shselasky	ib_query_device_compat(__VA_ARGS__)
299330502Shselasky
300330502Shselaskystatic inline int
301330502Shselaskyib_query_gid_compat(struct ib_device *device,
302330502Shselasky    u8 port_num, int index, union ib_gid *gid)
303330502Shselasky{
304330502Shselasky	return (ib_query_gid(device, port_num, index, gid, NULL));
305330502Shselasky}
306330502Shselasky
307330502Shselasky#undef ib_query_gid
308330502Shselasky#define	ib_query_gid(...) \
309330502Shselasky	ib_query_gid_compat(__VA_ARGS__)
310330502Shselasky
311330502Shselaskystatic inline int
312330502Shselaskyib_find_gid_compat(struct ib_device *device, union ib_gid *gid,
313330502Shselasky    u8 * port_num, u16 * index)
314330502Shselasky{
315330502Shselasky	return (ib_find_gid(device, gid, IB_GID_TYPE_IB, NULL, port_num, index));
316330502Shselasky}
317330502Shselasky
318330502Shselasky#undef ib_find_gid
319330502Shselasky#define	ib_find_gid(...) \
320330502Shselasky	ib_find_gid_compat(__VA_ARGS__)
321330502Shselasky
322330502Shselaskystatic inline struct ib_pd *
323330502Shselaskyib_alloc_pd_compat(struct ib_device *device)
324330502Shselasky{
325330502Shselasky	return (ib_alloc_pd(device, 0));
326330502Shselasky}
327330502Shselasky
328330502Shselasky#undef ib_alloc_pd
329330502Shselasky#define	ib_alloc_pd(...) \
330330502Shselasky	ib_alloc_pd_compat(__VA_ARGS__)
331330502Shselasky
332330502Shselaskystatic inline struct ib_cq *
333330502Shselaskyib_create_cq_compat(struct ib_device *device,
334330502Shselasky    ib_comp_handler comp_handler,
335330502Shselasky    void (*event_handler) (struct ib_event *, void *),
336330502Shselasky    void *cq_context, int cqe, int comp_vector)
337330502Shselasky{
338330502Shselasky	const struct ib_cq_init_attr cq_attr = {.cqe = cqe,.comp_vector = comp_vector};
339330502Shselasky
340330502Shselasky	return (ib_create_cq(device, comp_handler, event_handler, cq_context, &cq_attr));
341330502Shselasky}
342330502Shselasky
343330502Shselasky#undef ib_create_cq
344330502Shselasky#define	ib_create_cq(...) \
345330502Shselasky	ib_create_cq_compat(__VA_ARGS__)
346330502Shselasky
347330502Shselaskystatic inline int
348330502Shselaskyib_modify_cq_compat(struct ib_cq *cq,
349330502Shselasky    struct ib_cq_attr *cq_attr,
350330502Shselasky    int cq_attr_mask)
351330502Shselasky{
352330502Shselasky	if (cq_attr_mask & IB_CQ_MODERATION) {
353330502Shselasky		return (ib_modify_cq(cq, cq_attr->moderation.cq_count,
354330502Shselasky		    cq_attr->moderation.cq_period));
355330502Shselasky	} else {
356330502Shselasky		return (0);
357330502Shselasky	}
358330502Shselasky}
359330502Shselasky
360330502Shselasky#undef ib_modify_cq
361330502Shselasky#define	ib_modify_cq(...) \
362330502Shselasky	ib_modify_cq_compat(__VA_ARGS__)
363330502Shselasky
364330502Shselaskystatic inline struct ib_mr *
365330502Shselaskyib_get_dma_mr(struct ib_pd *pd, int mr_access_flags)
366330502Shselasky{
367330794Shselasky	struct ib_mr *mr;
368331010Shselasky	int err;
369330794Shselasky
370331010Shselasky	err = ib_check_mr_access(mr_access_flags);
371331010Shselasky	if (err)
372331010Shselasky		return ERR_PTR(err);
373331010Shselasky
374331010Shselasky	if (!pd->device->get_dma_mr)
375331010Shselasky		return ERR_PTR(-ENOSYS);
376331010Shselasky
377330794Shselasky	mr = pd->device->get_dma_mr(pd, mr_access_flags);
378330794Shselasky	if (IS_ERR(mr))
379330794Shselasky		return ERR_CAST(mr);
380330794Shselasky
381330794Shselasky	mr->device = pd->device;
382330794Shselasky	mr->pd = pd;
383330794Shselasky	mr->uobject = NULL;
384330794Shselasky	mr->need_inval = false;
385330794Shselasky	atomic_inc(&pd->usecnt);
386330794Shselasky
387330794Shselasky	return (mr);
388330502Shselasky}
389330502Shselasky
390330502Shselaskystatic inline struct ib_mr *
391330502Shselaskyib_reg_phys_mr(struct ib_pd *pd,
392330502Shselasky    struct ib_phys_buf *phys_buf_array,
393330502Shselasky    int num_phys_buf,
394330502Shselasky    int mr_access_flags,
395330502Shselasky    u64 * iova_start)
396330502Shselasky{
397331009Shselasky	struct ib_mr *mr;
398331009Shselasky	int err;
399331009Shselasky
400331009Shselasky	err = ib_check_mr_access(mr_access_flags);
401331009Shselasky	if (err)
402331009Shselasky		return ERR_PTR(err);
403331009Shselasky
404331009Shselasky	if (!pd->device->reg_phys_mr)
405331009Shselasky		return ERR_PTR(-ENOSYS);
406331009Shselasky
407331009Shselasky	mr = pd->device->reg_phys_mr(pd, phys_buf_array, num_phys_buf,
408331009Shselasky				     mr_access_flags, iova_start);
409331009Shselasky	if (IS_ERR(mr))
410331009Shselasky		return ERR_CAST(mr);
411331009Shselasky
412331009Shselasky	mr->device = pd->device;
413331009Shselasky	mr->pd = pd;
414331009Shselasky	mr->uobject = NULL;
415331009Shselasky	atomic_inc(&pd->usecnt);
416331009Shselasky
417331009Shselasky	return (mr);
418330502Shselasky}
419330502Shselasky
420330502Shselaskystatic inline int
421330502Shselaskyib_rereg_phys_mr(struct ib_mr *mr,
422330502Shselasky    int mr_rereg_mask,
423330502Shselasky    struct ib_pd *pd,
424330502Shselasky    struct ib_phys_buf *phys_buf_array,
425330502Shselasky    int num_phys_buf,
426330502Shselasky    int mr_access_flags,
427330502Shselasky    u64 * iova_start)
428330502Shselasky{
429330502Shselasky	return (-EOPNOTSUPP);
430330502Shselasky}
431330502Shselasky
432330502Shselaskystatic inline int
433330502Shselaskyib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr)
434330502Shselasky{
435330502Shselasky	return (-EOPNOTSUPP);
436330502Shselasky}
437330502Shselasky
438330502Shselaskystatic inline struct ib_mr *
439330502Shselaskyib_create_mr(struct ib_pd *pd,
440330502Shselasky    struct ib_mr_init_attr *mr_init_attr)
441330502Shselasky{
442330502Shselasky	return (ERR_PTR(-ENOSYS));
443330502Shselasky}
444330502Shselasky
445330502Shselaskystatic inline int
446330502Shselaskyib_destroy_mr(struct ib_mr *mr)
447330502Shselasky{
448330502Shselasky	return (-EOPNOTSUPP);
449330502Shselasky}
450330502Shselasky
451330502Shselaskystatic inline struct ib_mr *
452330502Shselaskyib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len)
453330502Shselasky{
454330502Shselasky	return (ERR_PTR(-ENOSYS));
455330502Shselasky}
456330502Shselasky
457330502Shselaskystatic inline struct ib_fast_reg_page_list *
458330502Shselaskyib_alloc_fast_reg_page_list(struct ib_device *device, int page_list_len)
459330502Shselasky{
460330502Shselasky	return (ERR_PTR(-ENOSYS));
461330502Shselasky}
462330502Shselasky
463330502Shselaskystatic inline void
464330502Shselaskyib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list)
465330502Shselasky{
466330502Shselasky
467330502Shselasky}
468330502Shselasky
469330502Shselaskystatic inline struct ib_mw *
470330502Shselaskyib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type)
471330502Shselasky{
472330502Shselasky	struct ib_mw *mw;
473330502Shselasky
474330502Shselasky	if (!pd->device->alloc_mw)
475330502Shselasky		return ERR_PTR(-ENOSYS);
476330502Shselasky
477330502Shselasky	mw = pd->device->alloc_mw(pd, type, NULL);
478330502Shselasky	if (!IS_ERR(mw)) {
479330502Shselasky		mw->device = pd->device;
480330502Shselasky		mw->pd = pd;
481330502Shselasky		mw->uobject = NULL;
482330502Shselasky		mw->type = type;
483330502Shselasky		atomic_inc(&pd->usecnt);
484330502Shselasky	}
485330502Shselasky	return (mw);
486330502Shselasky}
487330502Shselasky
488330502Shselaskystatic inline int
489330502Shselaskyib_bind_mw(struct ib_qp *qp,
490330502Shselasky    struct ib_mw *mw,
491330502Shselasky    struct ib_mw_bind *mw_bind)
492330502Shselasky{
493330502Shselasky	return (-EOPNOTSUPP);
494330502Shselasky}
495330502Shselasky
496330502Shselaskystatic inline int
497330502Shselaskyib_dealloc_mw(struct ib_mw *mw)
498330502Shselasky{
499330502Shselasky	struct ib_pd *pd;
500330502Shselasky	int ret;
501330502Shselasky
502330502Shselasky	pd = mw->pd;
503330502Shselasky	ret = mw->device->dealloc_mw(mw);
504330502Shselasky	if (!ret)
505330502Shselasky		atomic_dec(&pd->usecnt);
506330502Shselasky	return (ret);
507330502Shselasky}
508330502Shselasky
509330502Shselaskystatic inline struct ib_dct *
510330502Shselaskyib_create_dct(struct ib_pd *pd, struct ib_dct_init_attr *attr,
511330502Shselasky    struct ib_udata *udata)
512330502Shselasky{
513330502Shselasky	return (ERR_PTR(-ENOSYS));
514330502Shselasky}
515330502Shselasky
516330502Shselaskystatic inline int
517330502Shselaskyib_destroy_dct(struct ib_dct *dct)
518330502Shselasky{
519330502Shselasky	return (-EOPNOTSUPP);
520330502Shselasky}
521330502Shselasky
522330502Shselaskystatic inline int
523330502Shselaskyib_query_dct(struct ib_dct *dct, struct ib_dct_attr *attr)
524330502Shselasky{
525330502Shselasky	return (-EOPNOTSUPP);
526330502Shselasky}
527330502Shselasky
528330502Shselaskystatic inline int
529330502Shselaskyib_query_values(struct ib_device *device,
530330502Shselasky    int q_values, struct ib_device_values *values)
531330502Shselasky{
532330502Shselasky	return (-EOPNOTSUPP);
533330502Shselasky}
534330502Shselasky
535330502Shselaskystatic inline void
536330502Shselaskyib_active_speed_enum_to_rate(u8 active_speed,
537330502Shselasky    int *rate,
538330502Shselasky    char **speed)
539330502Shselasky{
540330502Shselasky	switch (active_speed) {
541330502Shselasky	case IB_SPEED_DDR:
542330502Shselasky		*speed = " DDR";
543330502Shselasky		*rate = 50;
544330502Shselasky		break;
545330502Shselasky	case IB_SPEED_QDR:
546330502Shselasky		*speed = " QDR";
547330502Shselasky		*rate = 100;
548330502Shselasky		break;
549330502Shselasky	case IB_SPEED_FDR10:
550330502Shselasky		*speed = " FDR10";
551330502Shselasky		*rate = 100;
552330502Shselasky		break;
553330502Shselasky	case IB_SPEED_FDR:
554330502Shselasky		*speed = " FDR";
555330502Shselasky		*rate = 140;
556330502Shselasky		break;
557330502Shselasky	case IB_SPEED_EDR:
558330502Shselasky		*speed = " EDR";
559330502Shselasky		*rate = 250;
560330502Shselasky		break;
561330502Shselasky	case IB_SPEED_SDR:
562330502Shselasky	default:			/* default to SDR for invalid rates */
563330502Shselasky		*rate = 25;
564330502Shselasky		break;
565330502Shselasky	}
566330502Shselasky}
567330502Shselasky
568330502Shselasky#include <rdma/rdma_cm.h>
569330502Shselasky
570330502Shselaskystatic inline struct rdma_cm_id *
571330502Shselaskyrdma_create_id_compat(rdma_cm_event_handler event_handler,
572330502Shselasky    void *context, enum rdma_port_space ps,
573330502Shselasky    enum ib_qp_type qp_type)
574330502Shselasky{
575330502Shselasky	return (rdma_create_id(&init_net, event_handler, context, ps, qp_type));
576330502Shselasky}
577330502Shselasky
578330502Shselasky#undef rdma_create_id
579330502Shselasky#define	rdma_create_id(...) \
580330502Shselasky	rdma_create_id_compat(__VA_ARGS__)
581330502Shselasky
582330502Shselasky#endif					/* IB_VERBS_COMPAT_H */
583