xref: /titanic_50/usr/src/uts/common/sys/ib/mgt/ibdma/ibdma_impl.h (revision 1bdd6c0e3710e91cb1f31aa78de33cb638494480)
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 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 #ifndef _IBDMA_IMPL_H
27 #define	_IBDMA_IMPL_H
28 
29 /*
30  * ibdma_impl.h
31  *
32  * Device Management Agent private prototypes and structures.
33  */
34 
35 #ifdef __cpluplus
36 extern "C" {
37 #endif
38 
39 #include <sys/ib/ibtl/ibvti.h>		/* IB verrbs interfaces */
40 #include <sys/ib/mgt/ib_dm_attr.h>	/* IB DM defines/structures */
41 #include <sys/ib/mgt/ib_mad.h>		/* IB MAD defines/structures */
42 
43 enum  {
44 	IBDMA_MAD_SIZE		= 256,
45 	IBDMA_DM_MAD_HDR_SIZE	= 40,
46 	IBDMA_DM_RESP_TIME	= 20,
47 	IBDMA_MAX_IOC		= 16
48 };
49 
50 /*
51  * Implementation of handle returned to consumer.
52  */
53 typedef struct ibdma_hdl_impl_s {
54 	list_node_t		ih_node;
55 	ib_guid_t		ih_iou_guid;
56 	uint8_t			ih_ioc_ndx;
57 } ibdma_hdl_impl_t;
58 
59 /*
60  * Each I/O Controller slot for the I/O Unit.
61  */
62 typedef struct ibdma_ioc_s {
63 	uint8_t				ii_inuse;
64 	/*
65 	 * Just to map handle back to slot number and hca
66 	 */
67 	int				ii_slot;
68 	struct ibdma_hca_s		*ii_hcap;
69 
70 	/*
71 	 * Profile provided by the I/O Controller, must be stored
72 	 * in network order.  Note that the profile indicates the
73 	 * number of service entries pointed to by ii_srvcs.
74 	 */
75 	ib_dm_ioc_ctrl_profile_t	ii_profile;
76 	ib_dm_srv_t			*ii_srvcs;
77 } ibdma_ioc_t;
78 
79 /*
80  * The ibdma_hca_t structure is only used internally by the
81  * IB DM Agent.  It is created when the associated HCA is
82  * opened as part of initialization or as a result of a
83  * notification via IBTF.  It is destroyed when the HCA
84  * is closed as part of fini processing or as a result of
85  * a notification via IBTF.  The structure is not directly
86  * accessed by IBMF call-backs or the consumer API.
87  */
88 typedef struct ibdma_port_s {
89 	ibmf_handle_t		ip_ibmf_hdl;
90 	ibmf_register_info_t	ip_ibmf_reg;
91 	ibmf_impl_caps_t	ip_ibmf_caps;
92 	struct ibdma_hca_s	*ip_hcap;
93 } ibdma_port_t;
94 
95 typedef struct ibdma_hca_s {
96 	list_node_t		ih_node;
97 	ibt_hca_hdl_t		ih_ibt_hdl;
98 
99 	/*
100 	 * Consumer handles associated with I/O Controllers
101 	 * that have registered with this I/O Unit.
102 	 */
103 	list_t			ih_hdl_list;
104 
105 	/*
106 	 * The I/O Unit that is presented to the IB Fabric.
107 	 * It is stored in network order.
108 	 */
109 	krwlock_t		ih_iou_rwlock;
110 	ib_guid_t		ih_iou_guid;
111 	ib_dm_io_unitinfo_t	ih_iou;
112 	ibdma_ioc_t		ih_ioc[IBDMA_MAX_IOC];
113 	uint8_t			ih_nports;
114 	ibdma_port_t		ih_port[1];
115 } ibdma_hca_t;
116 
117 
118 /*
119  * The IBDMA module state information created and initialized
120  * at _init() and freed at _fini().
121  */
122 typedef struct ibdma_mod_state_s {
123 	ibt_clnt_hdl_t		ms_ibt_hdl;
124 
125 	/*
126 	 * The HCA list lock is used protect the HCA list and
127 	 * is held during consumer routines (in place of a
128 	 * reference count) to ensure the HCA exists for the
129 	 * duration of it's use in the routine.
130 	 */
131 	kmutex_t		ms_hca_list_lock;
132 	list_t			ms_hca_list;
133 	uint_t			ms_num_hcas;
134 
135 } ibdma_mod_state_t;
136 
137 
138 /*
139  * Client API internal helpers
140  */
141 typedef enum ibdma_ioc_state_e {
142 	IBDMA_IOC_NOT_INSTALLED = 0,
143 	IBDMA_IOC_PRESENT = 1,
144 	IBDMA_IOC_DOES_NOT_EXIST = 255,
145 	IBDMA_HDL_MAGIC = 0x00931000
146 } ibdma_ioc_state_t;
147 
148 static void
149 ibdma_set_ioc_state(ibdma_hca_t *hca, int slot, ibdma_ioc_state_t state);
150 static ibdma_ioc_state_t ibdma_get_ioc_state(ibdma_hca_t *hca, int slot);
151 
152 #endif /* _IBDMA_IMPL_H */
153