xref: /titanic_50/usr/src/uts/common/sys/sunmdi.h (revision 049fa28a1fa444b1ffffe4e619e7e39fbd617462)
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  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_SUNMDI_H
27 #define	_SYS_SUNMDI_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * Multiplexed I/O global include
33  */
34 
35 #include <sys/note.h>
36 #include <sys/esunddi.h>
37 #include <sys/sunddi.h>
38 #include <sys/ddipropdefs.h>
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 /*
45  * Most MDI functions return success or failure
46  */
47 #define	MDI_SUCCESS		0	/* Call Success */
48 #define	MDI_FAILURE		-1	/* Unspecified Error */
49 #define	MDI_NOMEM		-2	/* No resources available */
50 #define	MDI_ACCEPT		-3	/* Request accepted */
51 #define	MDI_BUSY		-4	/* Busy */
52 #define	MDI_NOPATH		-5	/* No more paths are available */
53 #define	MDI_EINVAL		-6	/* Invalid parameter */
54 #define	MDI_NOT_SUPPORTED	-8	/* Device not supported */
55 #define	MDI_DEVI_ONLINING	-9	/* Devi is onlining */
56 
57 /*
58  * handle to mdi_pathinfo node
59  */
60 typedef struct x_mdi_pathinfo *mdi_pathinfo_t;
61 
62 /*
63  * Path info node state definitions
64  */
65 typedef enum {
66 	MDI_PATHINFO_STATE_INIT,
67 	MDI_PATHINFO_STATE_ONLINE,
68 	MDI_PATHINFO_STATE_STANDBY,
69 	MDI_PATHINFO_STATE_FAULT,
70 	MDI_PATHINFO_STATE_OFFLINE
71 } mdi_pathinfo_state_t;
72 
73 /*
74  * MDI vHCI class definitions
75  */
76 #define	MDI_HCI_CLASS_SCSI	"scsi_vhci"
77 #define	MDI_HCI_CLASS_IB	"ib"
78 
79 #ifdef _KERNEL
80 
81 /*
82  * mpxio component definitions:  Every registered component of the
83  * mpxio system has a "mpxio-component" property attached to it.
84  * Identify its function
85  */
86 #define	MDI_COMPONENT_NONE	0
87 #define	MDI_COMPONENT_VHCI	0x1
88 #define	MDI_COMPONENT_PHCI	0x2
89 #define	MDI_COMPONENT_CLIENT	0x4
90 
91 /*
92  * mdi_pathinfo node state utility definitions
93  */
94 #define	MDI_PATHINFO_STATE_TRANSIENT			0x00010000
95 #define	MDI_PATHINFO_STATE_USER_DISABLE			0x00100000
96 #define	MDI_PATHINFO_STATE_DRV_DISABLE			0x00200000
97 #define	MDI_PATHINFO_STATE_DRV_DISABLE_TRANSIENT	0x00400000
98 #define	MDI_PATHINFO_STATE_MASK				0x0000FFFF
99 #define	MDI_PATHINFO_EXT_STATE_MASK			0xFFF00000
100 
101 #define	USER_DISABLE			1
102 #define	DRIVER_DISABLE			2
103 #define	DRIVER_DISABLE_TRANSIENT	3
104 
105 
106 /*
107  * Most MDI functions return success or failure
108  */
109 #define	MDI_SUCCESS		0	/* Call Success			*/
110 #define	MDI_FAILURE		-1	/* Unspecified Error		*/
111 #define	MDI_NOMEM		-2	/* No resources available	*/
112 #define	MDI_ACCEPT		-3	/* Request accepted		*/
113 #define	MDI_BUSY		-4	/* Busy				*/
114 #define	MDI_NOPATH		-5	/* No more paths are available	*/
115 #define	MDI_EINVAL		-6	/* Invalid parameter		*/
116 #define	MDI_NOT_SUPPORTED	-8	/* Device not supported		*/
117 #define	MDI_DEVI_ONLINING	-9	/* Devi is onlining		*/
118 
119 /*
120  * MDI operation vector structure definition
121  */
122 #define	MDI_OPS_REV_1			1
123 #define	MDI_OPS_REV			MDI_OPS_REV_1
124 
125 #define	MDI_VHCI(dip)	(DEVI(dip)->devi_mdi_component & MDI_COMPONENT_VHCI)
126 #define	MDI_PHCI(dip)	(DEVI(dip)->devi_mdi_component & MDI_COMPONENT_PHCI)
127 #define	MDI_CLIENT(dip)	(DEVI(dip)->devi_mdi_component & MDI_COMPONENT_CLIENT)
128 
129 /*
130  * MDI device hotplug notification
131  */
132 int mdi_devi_online(dev_info_t *, uint_t);
133 int mdi_devi_offline(dev_info_t *, uint_t);
134 
135 /*
136  * MDI component device instance attach/detach notification
137  */
138 int mdi_pre_attach(dev_info_t *, ddi_attach_cmd_t);
139 void mdi_post_attach(dev_info_t *, ddi_attach_cmd_t, int);
140 int mdi_pre_detach(dev_info_t *, ddi_detach_cmd_t);
141 void mdi_post_detach(dev_info_t *, ddi_detach_cmd_t, int);
142 
143 int mdi_devi_config_one(dev_info_t *, char *, dev_info_t **, int, clock_t);
144 
145 /*
146  * mdi_pathinfo management functions.
147  *
148  * Find, allocate and Free functions.
149  */
150 mdi_pathinfo_t *mdi_pi_find(dev_info_t *, char *, char *);
151 int mdi_pi_alloc(dev_info_t *, char *, char *, char *, int, mdi_pathinfo_t **);
152 int mdi_pi_alloc_compatible(dev_info_t *, char *, char *, char *,
153 	char **, int, int, mdi_pathinfo_t **);
154 int mdi_pi_free(mdi_pathinfo_t *, int);
155 
156 /*
157  * mdi_pathinfo node state change functions.
158  */
159 int mdi_pi_online(mdi_pathinfo_t *, int);
160 int mdi_pi_standby(mdi_pathinfo_t *, int);
161 int mdi_pi_fault(mdi_pathinfo_t *, int);
162 int mdi_pi_offline(mdi_pathinfo_t *, int);
163 /*
164  * NOTE: the next 2 interfaces will be removed once the NWS files are
165  * changed to use the new mdi_{enable,disable}_path interfaces
166  */
167 int mdi_pi_disable(dev_info_t *, dev_info_t *, int);
168 int mdi_pi_enable(dev_info_t *, dev_info_t *, int);
169 int mdi_pi_disable_path(mdi_pathinfo_t *, int);
170 int mdi_pi_enable_path(mdi_pathinfo_t *, int);
171 
172 /*
173  * MPxIO-PM stuff
174  */
175 typedef enum {
176 	MDI_PM_PRE_CONFIG = 0,
177 	MDI_PM_POST_CONFIG,
178 	MDI_PM_PRE_UNCONFIG,
179 	MDI_PM_POST_UNCONFIG,
180 	MDI_PM_HOLD_POWER,
181 	MDI_PM_RELE_POWER
182 } mdi_pm_op_t;
183 
184 int
185 mdi_bus_power(dev_info_t *, void *, pm_bus_power_op_t, void *, void *);
186 
187 int
188 mdi_power(dev_info_t *, mdi_pm_op_t, void *, char *, int);
189 
190 /*
191  * mdi_pathinfo node walker function.
192  */
193 int mdi_component_is_vhci(dev_info_t *, const char **);
194 int mdi_component_is_phci(dev_info_t *, const char **);
195 int mdi_component_is_client(dev_info_t *, const char **);
196 mdi_pathinfo_t *mdi_get_next_phci_path(dev_info_t *, mdi_pathinfo_t *);
197 mdi_pathinfo_t *mdi_get_next_client_path(dev_info_t *, mdi_pathinfo_t *);
198 
199 /*
200  * mdi_pathinfo node member functions
201  */
202 void mdi_pi_lock(mdi_pathinfo_t *);
203 void mdi_pi_unlock(mdi_pathinfo_t *);
204 dev_info_t *mdi_pi_get_client(mdi_pathinfo_t *);
205 dev_info_t *mdi_pi_get_phci(mdi_pathinfo_t *);
206 char *mdi_pi_get_addr(mdi_pathinfo_t *);
207 mdi_pathinfo_state_t mdi_pi_get_state(mdi_pathinfo_t *);
208 
209 /*
210  * mdi_pathinfo Property handling functions
211  */
212 int mdi_prop_remove(mdi_pathinfo_t *, char *);
213 int mdi_prop_update_byte_array(mdi_pathinfo_t *, char *, uchar_t *, uint_t);
214 int mdi_prop_update_int(mdi_pathinfo_t *, char *, int);
215 int mdi_prop_update_int64(mdi_pathinfo_t *, char *, int64_t);
216 int mdi_prop_update_int_array(mdi_pathinfo_t *, char *, int *, uint_t);
217 int mdi_prop_update_string(mdi_pathinfo_t *, char *, char *);
218 int mdi_prop_update_string_array(mdi_pathinfo_t *, char *, char **, uint_t);
219 nvpair_t *mdi_pi_get_next_prop(mdi_pathinfo_t *, nvpair_t *);
220 
221 int mdi_prop_lookup_byte_array(mdi_pathinfo_t *, char *, uchar_t **, uint_t *);
222 int mdi_prop_lookup_int(mdi_pathinfo_t *, char *, int *);
223 int mdi_prop_lookup_int64(mdi_pathinfo_t *, char *, int64_t *);
224 int mdi_prop_lookup_int_array(mdi_pathinfo_t *, char *, int **, uint_t *);
225 int mdi_prop_lookup_string(mdi_pathinfo_t *, char *, char **);
226 int mdi_prop_lookup_string_array(mdi_pathinfo_t *, char *, char ***, uint_t *);
227 int mdi_prop_free(void *);
228 
229 /*
230  * pHCI driver instance registration/unregistration
231  *
232  * mdi_phci_register() is called by a pHCI drivers to register itself as a
233  * transport provider for a specific 'class' (see mdi_vhci_register() above);
234  * it should be called from attach(9e).
235  *
236  * mdi_phci_unregister() is called from detach(9e) to unregister a pHCI
237  * instance from the framework.
238  */
239 int		mdi_phci_register(char *, dev_info_t *, int);
240 int		mdi_phci_unregister(dev_info_t *, int);
241 
242 /* get set phci private data */
243 caddr_t mdi_pi_get_phci_private(mdi_pathinfo_t *);
244 void mdi_pi_set_phci_private(mdi_pathinfo_t *, caddr_t);
245 
246 int mdi_vhci_bus_config(dev_info_t *, uint_t, ddi_bus_config_op_t, void *,
247     dev_info_t **, char *);
248 
249 /*
250  * mdi_vhci node walker function
251  */
252 void mdi_walk_vhcis(int (*f)(dev_info_t *, void *), void *arg);
253 
254 /*
255  * mdi_phci node walker function
256  */
257 void mdi_vhci_walk_phcis(dev_info_t *, int (*f)(dev_info_t *, void *),
258     void *arg);
259 
260 /*
261  * mdi_client node walker function
262  */
263 void mdi_vhci_walk_clients(dev_info_t *, int (*f)(dev_info_t *, void *),
264     void *arg);
265 
266 #endif /* _KERNEL */
267 
268 #ifdef	__cplusplus
269 }
270 #endif
271 
272 #endif	/* _SYS_SUNMDI_H */
273