xref: /titanic_51/usr/src/uts/common/sys/ib/clients/of/sol_ofs/sol_kverb_impl.h (revision c0dd49bdd68c0d758a67d56f07826f3b45cfc664)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_KVERB_IMPL_H
27 #define	_SYS_IB_CLIENTS_OF_SOL_OFS_SOL_KVERB_IMPL_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/ib/ibtl/ibvti.h>
34 
35 /*
36  * If there is yet an active async event, hdl is not freed. However,
37  * if the device state is IB_DEV_CLOSE, the device is about to be closed
38  * so that the event should be discarded.
39  */
40 #define	FIRE_QP_EVENT(clnt, hdl, ib_event, qpp, type)			\
41 		rw_enter(&clnt->lock, RW_READER);			\
42 		if (qpp && qpp->event_handler &&			\
43 		    qpp->device->reg_state == IB_DEV_OPEN) {		\
44 			ib_event.device = qpp->device;			\
45 			ib_event.event = type;				\
46 			ib_event.element.qp = qpp;			\
47 			qpp->event_handler(&ib_event, qpp->qp_context);	\
48 		}							\
49 		rw_exit(&clnt->lock)
50 
51 #define	FIRE_CQ_EVENT(clnt, hdl, ib_event, cqp, type)			\
52 		rw_enter(&clnt->lock, RW_READER);			\
53 		if (cqp && cqp->event_handler &&			\
54 		    cqp->device->reg_state == IB_DEV_OPEN) {		\
55 			ib_event.device = cqp->device;			\
56 			ib_event.event = type;				\
57 			ib_event.element.cq = cqp;			\
58 			cqp->event_handler(&ib_event, cqp->cq_context);	\
59 		}							\
60 		rw_exit(&clnt->lock)
61 
62 #define	IBTF2OF_PGSZ(hca_page_sz)	((hca_page_sz) << 10)
63 #define	OF2IBTF_STATE(s)		((enum ibt_cep_state_e)(s))
64 #define	OF2IBTF_SRATE(r)		((enum ibt_srate_e)(r))
65 #define	OF2IBTF_PATH_MIG_STATE(s)	((ibt_cep_cmstate_t)((s)+1))
66 #define	OF2IBTF_PATH_MTU(m)		((ib_mtu_t)(m))
67 
68 typedef unsigned int gfp_t;
69 
70 typedef struct sol_ofs_client_s {
71 	ib_client_t		*ib_client;
72 	ibt_clnt_modinfo_t	ibt_client;
73 	ibt_clnt_hdl_t		ibt_hdl;
74 	uint_t			hca_num;
75 	uint_t			hca_open_num;
76 	llist_head_t		device_list;
77 	llist_head_t		client_list;
78 	krwlock_t		lock;
79 	enum {
80 				IB_OFS_CLNT_UNINITIALIZED,
81 				IB_OFS_CLNT_INITIALIZED
82 	} state;
83 } ofs_client_t;
84 
85 #ifdef	__cplusplus
86 }
87 #endif
88 
89 #endif	/* _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_KVERB_IMPL_H */
90