xref: /titanic_50/usr/src/uts/common/sys/sunmdi.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_SUNMDI_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_SUNMDI_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate /*
33*7c478bd9Sstevel@tonic-gate  * Multiplexed I/O global include
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #include <sys/note.h>
37*7c478bd9Sstevel@tonic-gate #include <sys/esunddi.h>
38*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
39*7c478bd9Sstevel@tonic-gate #include <sys/ddipropdefs.h>
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
42*7c478bd9Sstevel@tonic-gate extern "C" {
43*7c478bd9Sstevel@tonic-gate #endif
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate /*
46*7c478bd9Sstevel@tonic-gate  * Most MDI functions return success or failure
47*7c478bd9Sstevel@tonic-gate  */
48*7c478bd9Sstevel@tonic-gate #define	MDI_SUCCESS		0	/* Call Success */
49*7c478bd9Sstevel@tonic-gate #define	MDI_FAILURE		-1	/* Unspecified Error */
50*7c478bd9Sstevel@tonic-gate #define	MDI_NOMEM		-2	/* No resources available */
51*7c478bd9Sstevel@tonic-gate #define	MDI_ACCEPT		-3	/* Request accepted */
52*7c478bd9Sstevel@tonic-gate #define	MDI_BUSY		-4	/* Busy */
53*7c478bd9Sstevel@tonic-gate #define	MDI_NOPATH		-5	/* No more paths are available */
54*7c478bd9Sstevel@tonic-gate #define	MDI_EINVAL		-6	/* Invalid parameter */
55*7c478bd9Sstevel@tonic-gate #define	MDI_NOT_SUPPORTED	-8	/* Device not supported */
56*7c478bd9Sstevel@tonic-gate #define	MDI_DEVI_ONLINING	-9	/* Devi is onlining */
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate /*
59*7c478bd9Sstevel@tonic-gate  * handle to mdi_pathinfo node
60*7c478bd9Sstevel@tonic-gate  */
61*7c478bd9Sstevel@tonic-gate typedef struct x_mdi_pathinfo *mdi_pathinfo_t;
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate /*
64*7c478bd9Sstevel@tonic-gate  * Path info node state definitions
65*7c478bd9Sstevel@tonic-gate  */
66*7c478bd9Sstevel@tonic-gate typedef enum {
67*7c478bd9Sstevel@tonic-gate 	MDI_PATHINFO_STATE_INIT,
68*7c478bd9Sstevel@tonic-gate 	MDI_PATHINFO_STATE_ONLINE,
69*7c478bd9Sstevel@tonic-gate 	MDI_PATHINFO_STATE_STANDBY,
70*7c478bd9Sstevel@tonic-gate 	MDI_PATHINFO_STATE_FAULT,
71*7c478bd9Sstevel@tonic-gate 	MDI_PATHINFO_STATE_OFFLINE
72*7c478bd9Sstevel@tonic-gate } mdi_pathinfo_state_t;
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate /*
75*7c478bd9Sstevel@tonic-gate  * MDI vHCI class definitions
76*7c478bd9Sstevel@tonic-gate  */
77*7c478bd9Sstevel@tonic-gate #define	MDI_HCI_CLASS_SCSI	"scsi_vhci"
78*7c478bd9Sstevel@tonic-gate #define	MDI_HCI_CLASS_IB	"ib"
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate /*
83*7c478bd9Sstevel@tonic-gate  * mpxio component definitions:  Every registered component of the
84*7c478bd9Sstevel@tonic-gate  * mpxio system has a "mpxio-component" property attached to it.
85*7c478bd9Sstevel@tonic-gate  * Identify its function
86*7c478bd9Sstevel@tonic-gate  */
87*7c478bd9Sstevel@tonic-gate #define	MDI_COMPONENT_NONE	0
88*7c478bd9Sstevel@tonic-gate #define	MDI_COMPONENT_VHCI	0x1
89*7c478bd9Sstevel@tonic-gate #define	MDI_COMPONENT_PHCI	0x2
90*7c478bd9Sstevel@tonic-gate #define	MDI_COMPONENT_CLIENT	0x4
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate /*
93*7c478bd9Sstevel@tonic-gate  * mdi_pathinfo node state utility definitions
94*7c478bd9Sstevel@tonic-gate  */
95*7c478bd9Sstevel@tonic-gate #define	MDI_PATHINFO_STATE_TRANSIENT			0x00010000
96*7c478bd9Sstevel@tonic-gate #define	MDI_PATHINFO_STATE_USER_DISABLE			0x00100000
97*7c478bd9Sstevel@tonic-gate #define	MDI_PATHINFO_STATE_DRV_DISABLE			0x00200000
98*7c478bd9Sstevel@tonic-gate #define	MDI_PATHINFO_STATE_DRV_DISABLE_TRANSIENT	0x00400000
99*7c478bd9Sstevel@tonic-gate #define	MDI_PATHINFO_STATE_MASK				0x0000FFFF
100*7c478bd9Sstevel@tonic-gate #define	MDI_PATHINFO_EXT_STATE_MASK			0xFFF00000
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate #define	USER_DISABLE			1
103*7c478bd9Sstevel@tonic-gate #define	DRIVER_DISABLE			2
104*7c478bd9Sstevel@tonic-gate #define	DRIVER_DISABLE_TRANSIENT	3
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate /*
108*7c478bd9Sstevel@tonic-gate  * Most MDI functions return success or failure
109*7c478bd9Sstevel@tonic-gate  */
110*7c478bd9Sstevel@tonic-gate #define	MDI_SUCCESS		0	/* Call Success			*/
111*7c478bd9Sstevel@tonic-gate #define	MDI_FAILURE		-1	/* Unspecified Error		*/
112*7c478bd9Sstevel@tonic-gate #define	MDI_NOMEM		-2	/* No resources available	*/
113*7c478bd9Sstevel@tonic-gate #define	MDI_ACCEPT		-3	/* Request accepted		*/
114*7c478bd9Sstevel@tonic-gate #define	MDI_BUSY		-4	/* Busy				*/
115*7c478bd9Sstevel@tonic-gate #define	MDI_NOPATH		-5	/* No more paths are available	*/
116*7c478bd9Sstevel@tonic-gate #define	MDI_EINVAL		-6	/* Invalid parameter		*/
117*7c478bd9Sstevel@tonic-gate #define	MDI_NOT_SUPPORTED	-8	/* Device not supported		*/
118*7c478bd9Sstevel@tonic-gate #define	MDI_DEVI_ONLINING	-9	/* Devi is onlining		*/
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate /*
121*7c478bd9Sstevel@tonic-gate  * MDI operation vector structure definition
122*7c478bd9Sstevel@tonic-gate  */
123*7c478bd9Sstevel@tonic-gate #define	MDI_OPS_REV_1			1
124*7c478bd9Sstevel@tonic-gate #define	MDI_OPS_REV			MDI_OPS_REV_1
125*7c478bd9Sstevel@tonic-gate 
126*7c478bd9Sstevel@tonic-gate #define	MDI_VHCI(dip)	(DEVI(dip)->devi_mdi_component & MDI_COMPONENT_VHCI)
127*7c478bd9Sstevel@tonic-gate #define	MDI_PHCI(dip)	(DEVI(dip)->devi_mdi_component & MDI_COMPONENT_PHCI)
128*7c478bd9Sstevel@tonic-gate #define	MDI_CLIENT(dip)	(DEVI(dip)->devi_mdi_component & MDI_COMPONENT_CLIENT)
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate /*
131*7c478bd9Sstevel@tonic-gate  * MDI device hotplug notification
132*7c478bd9Sstevel@tonic-gate  */
133*7c478bd9Sstevel@tonic-gate int mdi_devi_online(dev_info_t *, uint_t);
134*7c478bd9Sstevel@tonic-gate int mdi_devi_offline(dev_info_t *, uint_t);
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate /*
137*7c478bd9Sstevel@tonic-gate  * MDI component device instance attach/detach notification
138*7c478bd9Sstevel@tonic-gate  */
139*7c478bd9Sstevel@tonic-gate int mdi_pre_attach(dev_info_t *, ddi_attach_cmd_t);
140*7c478bd9Sstevel@tonic-gate void mdi_post_attach(dev_info_t *, ddi_attach_cmd_t, int);
141*7c478bd9Sstevel@tonic-gate int mdi_pre_detach(dev_info_t *, ddi_detach_cmd_t);
142*7c478bd9Sstevel@tonic-gate void mdi_post_detach(dev_info_t *, ddi_detach_cmd_t, int);
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate int mdi_devi_config_one(dev_info_t *, char *, dev_info_t **, int, clock_t);
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate /*
147*7c478bd9Sstevel@tonic-gate  * mdi_pathinfo management functions.
148*7c478bd9Sstevel@tonic-gate  *
149*7c478bd9Sstevel@tonic-gate  * Find, allocate and Free functions.
150*7c478bd9Sstevel@tonic-gate  */
151*7c478bd9Sstevel@tonic-gate mdi_pathinfo_t *mdi_pi_find(dev_info_t *, char *, char *);
152*7c478bd9Sstevel@tonic-gate int mdi_pi_alloc(dev_info_t *, char *, char *, char *, int, mdi_pathinfo_t **);
153*7c478bd9Sstevel@tonic-gate int mdi_pi_alloc_compatible(dev_info_t *, char *, char *, char *,
154*7c478bd9Sstevel@tonic-gate 	char **, int, int, mdi_pathinfo_t **);
155*7c478bd9Sstevel@tonic-gate int mdi_pi_free(mdi_pathinfo_t *, int);
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate /*
158*7c478bd9Sstevel@tonic-gate  * mdi_pathinfo node state change functions.
159*7c478bd9Sstevel@tonic-gate  */
160*7c478bd9Sstevel@tonic-gate int mdi_pi_online(mdi_pathinfo_t *, int);
161*7c478bd9Sstevel@tonic-gate int mdi_pi_standby(mdi_pathinfo_t *, int);
162*7c478bd9Sstevel@tonic-gate int mdi_pi_fault(mdi_pathinfo_t *, int);
163*7c478bd9Sstevel@tonic-gate int mdi_pi_offline(mdi_pathinfo_t *, int);
164*7c478bd9Sstevel@tonic-gate int mdi_pi_disable(dev_info_t *, dev_info_t *, int);
165*7c478bd9Sstevel@tonic-gate int mdi_pi_enable(dev_info_t *, dev_info_t *, int);
166*7c478bd9Sstevel@tonic-gate 
167*7c478bd9Sstevel@tonic-gate /*
168*7c478bd9Sstevel@tonic-gate  * MPxIO-PM stuff
169*7c478bd9Sstevel@tonic-gate  */
170*7c478bd9Sstevel@tonic-gate typedef enum {
171*7c478bd9Sstevel@tonic-gate 	MDI_PM_PRE_CONFIG = 0,
172*7c478bd9Sstevel@tonic-gate 	MDI_PM_POST_CONFIG,
173*7c478bd9Sstevel@tonic-gate 	MDI_PM_PRE_UNCONFIG,
174*7c478bd9Sstevel@tonic-gate 	MDI_PM_POST_UNCONFIG,
175*7c478bd9Sstevel@tonic-gate 	MDI_PM_HOLD_POWER,
176*7c478bd9Sstevel@tonic-gate 	MDI_PM_RELE_POWER
177*7c478bd9Sstevel@tonic-gate } mdi_pm_op_t;
178*7c478bd9Sstevel@tonic-gate 
179*7c478bd9Sstevel@tonic-gate int
180*7c478bd9Sstevel@tonic-gate mdi_bus_power(dev_info_t *, void *, pm_bus_power_op_t, void *, void *);
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate int
183*7c478bd9Sstevel@tonic-gate mdi_power(dev_info_t *, mdi_pm_op_t, void *, char *, int);
184*7c478bd9Sstevel@tonic-gate 
185*7c478bd9Sstevel@tonic-gate /*
186*7c478bd9Sstevel@tonic-gate  * mdi_pathinfo node walker function.
187*7c478bd9Sstevel@tonic-gate  */
188*7c478bd9Sstevel@tonic-gate int mdi_component_is_vhci(dev_info_t *, const char **);
189*7c478bd9Sstevel@tonic-gate int mdi_component_is_phci(dev_info_t *, const char **);
190*7c478bd9Sstevel@tonic-gate int mdi_component_is_client(dev_info_t *, const char **);
191*7c478bd9Sstevel@tonic-gate mdi_pathinfo_t *mdi_get_next_phci_path(dev_info_t *, mdi_pathinfo_t *);
192*7c478bd9Sstevel@tonic-gate mdi_pathinfo_t *mdi_get_next_client_path(dev_info_t *, mdi_pathinfo_t *);
193*7c478bd9Sstevel@tonic-gate 
194*7c478bd9Sstevel@tonic-gate /*
195*7c478bd9Sstevel@tonic-gate  * mdi_pathinfo node member functions
196*7c478bd9Sstevel@tonic-gate  */
197*7c478bd9Sstevel@tonic-gate void mdi_pi_lock(mdi_pathinfo_t *);
198*7c478bd9Sstevel@tonic-gate void mdi_pi_unlock(mdi_pathinfo_t *);
199*7c478bd9Sstevel@tonic-gate dev_info_t *mdi_pi_get_client(mdi_pathinfo_t *);
200*7c478bd9Sstevel@tonic-gate dev_info_t *mdi_pi_get_phci(mdi_pathinfo_t *);
201*7c478bd9Sstevel@tonic-gate char *mdi_pi_get_addr(mdi_pathinfo_t *);
202*7c478bd9Sstevel@tonic-gate mdi_pathinfo_state_t mdi_pi_get_state(mdi_pathinfo_t *);
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate /*
205*7c478bd9Sstevel@tonic-gate  * mdi_pathinfo Property handling functions
206*7c478bd9Sstevel@tonic-gate  */
207*7c478bd9Sstevel@tonic-gate int mdi_prop_remove(mdi_pathinfo_t *, char *);
208*7c478bd9Sstevel@tonic-gate int mdi_prop_update_byte_array(mdi_pathinfo_t *, char *, uchar_t *, uint_t);
209*7c478bd9Sstevel@tonic-gate int mdi_prop_update_int(mdi_pathinfo_t *, char *, int);
210*7c478bd9Sstevel@tonic-gate int mdi_prop_update_int64(mdi_pathinfo_t *, char *, int64_t);
211*7c478bd9Sstevel@tonic-gate int mdi_prop_update_int_array(mdi_pathinfo_t *, char *, int *, uint_t);
212*7c478bd9Sstevel@tonic-gate int mdi_prop_update_string(mdi_pathinfo_t *, char *, char *);
213*7c478bd9Sstevel@tonic-gate int mdi_prop_update_string_array(mdi_pathinfo_t *, char *, char **, uint_t);
214*7c478bd9Sstevel@tonic-gate nvpair_t *mdi_pi_get_next_prop(mdi_pathinfo_t *, nvpair_t *);
215*7c478bd9Sstevel@tonic-gate 
216*7c478bd9Sstevel@tonic-gate int mdi_prop_lookup_byte_array(mdi_pathinfo_t *, char *, uchar_t **, uint_t *);
217*7c478bd9Sstevel@tonic-gate int mdi_prop_lookup_int(mdi_pathinfo_t *, char *, int *);
218*7c478bd9Sstevel@tonic-gate int mdi_prop_lookup_int64(mdi_pathinfo_t *, char *, int64_t *);
219*7c478bd9Sstevel@tonic-gate int mdi_prop_lookup_int_array(mdi_pathinfo_t *, char *, int **, uint_t *);
220*7c478bd9Sstevel@tonic-gate int mdi_prop_lookup_string(mdi_pathinfo_t *, char *, char **);
221*7c478bd9Sstevel@tonic-gate int mdi_prop_lookup_string_array(mdi_pathinfo_t *, char *, char ***, uint_t *);
222*7c478bd9Sstevel@tonic-gate int mdi_prop_free(void *);
223*7c478bd9Sstevel@tonic-gate 
224*7c478bd9Sstevel@tonic-gate /*
225*7c478bd9Sstevel@tonic-gate  * pHCI driver instance registration/unregistration
226*7c478bd9Sstevel@tonic-gate  *
227*7c478bd9Sstevel@tonic-gate  * mdi_phci_register() is called by a pHCI drivers to register itself as a
228*7c478bd9Sstevel@tonic-gate  * transport provider for a specific 'class' (see mdi_vhci_register() above);
229*7c478bd9Sstevel@tonic-gate  * it should be called from attach(9e).
230*7c478bd9Sstevel@tonic-gate  *
231*7c478bd9Sstevel@tonic-gate  * mdi_phci_unregister() is called from detach(9e) to unregister a pHCI
232*7c478bd9Sstevel@tonic-gate  * instance from the framework.
233*7c478bd9Sstevel@tonic-gate  */
234*7c478bd9Sstevel@tonic-gate int		mdi_phci_register(char *, dev_info_t *, int);
235*7c478bd9Sstevel@tonic-gate int		mdi_phci_unregister(dev_info_t *, int);
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate /* get set phci private data */
238*7c478bd9Sstevel@tonic-gate caddr_t mdi_pi_get_phci_private(mdi_pathinfo_t *);
239*7c478bd9Sstevel@tonic-gate void mdi_pi_set_phci_private(mdi_pathinfo_t *, caddr_t);
240*7c478bd9Sstevel@tonic-gate 
241*7c478bd9Sstevel@tonic-gate int mdi_vhci_bus_config(dev_info_t *, uint_t, ddi_bus_config_op_t, void *,
242*7c478bd9Sstevel@tonic-gate     dev_info_t **);
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
245*7c478bd9Sstevel@tonic-gate 
246*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
247*7c478bd9Sstevel@tonic-gate }
248*7c478bd9Sstevel@tonic-gate #endif
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_SUNMDI_H */
251