xref: /onnv-gate/usr/src/uts/common/sys/sunmdi.h (revision 2402:8f4d719c99e8)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51909Scm136836  * Common Development and Distribution License (the "License").
61909Scm136836  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
221909Scm136836  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_SUNMDI_H
270Sstevel@tonic-gate #define	_SYS_SUNMDI_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate /*
320Sstevel@tonic-gate  * Multiplexed I/O global include
330Sstevel@tonic-gate  */
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #include <sys/note.h>
360Sstevel@tonic-gate #include <sys/esunddi.h>
370Sstevel@tonic-gate #include <sys/sunddi.h>
380Sstevel@tonic-gate #include <sys/ddipropdefs.h>
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #ifdef	__cplusplus
410Sstevel@tonic-gate extern "C" {
420Sstevel@tonic-gate #endif
430Sstevel@tonic-gate 
440Sstevel@tonic-gate /*
450Sstevel@tonic-gate  * Most MDI functions return success or failure
460Sstevel@tonic-gate  */
470Sstevel@tonic-gate #define	MDI_SUCCESS		0	/* Call Success */
480Sstevel@tonic-gate #define	MDI_FAILURE		-1	/* Unspecified Error */
490Sstevel@tonic-gate #define	MDI_NOMEM		-2	/* No resources available */
500Sstevel@tonic-gate #define	MDI_ACCEPT		-3	/* Request accepted */
510Sstevel@tonic-gate #define	MDI_BUSY		-4	/* Busy */
520Sstevel@tonic-gate #define	MDI_NOPATH		-5	/* No more paths are available */
530Sstevel@tonic-gate #define	MDI_EINVAL		-6	/* Invalid parameter */
540Sstevel@tonic-gate #define	MDI_NOT_SUPPORTED	-8	/* Device not supported */
550Sstevel@tonic-gate #define	MDI_DEVI_ONLINING	-9	/* Devi is onlining */
560Sstevel@tonic-gate 
570Sstevel@tonic-gate /*
580Sstevel@tonic-gate  * handle to mdi_pathinfo node
590Sstevel@tonic-gate  */
600Sstevel@tonic-gate typedef struct x_mdi_pathinfo *mdi_pathinfo_t;
610Sstevel@tonic-gate 
620Sstevel@tonic-gate /*
630Sstevel@tonic-gate  * Path info node state definitions
640Sstevel@tonic-gate  */
650Sstevel@tonic-gate typedef enum {
660Sstevel@tonic-gate 	MDI_PATHINFO_STATE_INIT,
670Sstevel@tonic-gate 	MDI_PATHINFO_STATE_ONLINE,
680Sstevel@tonic-gate 	MDI_PATHINFO_STATE_STANDBY,
690Sstevel@tonic-gate 	MDI_PATHINFO_STATE_FAULT,
700Sstevel@tonic-gate 	MDI_PATHINFO_STATE_OFFLINE
710Sstevel@tonic-gate } mdi_pathinfo_state_t;
720Sstevel@tonic-gate 
730Sstevel@tonic-gate /*
740Sstevel@tonic-gate  * MDI vHCI class definitions
750Sstevel@tonic-gate  */
760Sstevel@tonic-gate #define	MDI_HCI_CLASS_SCSI	"scsi_vhci"
770Sstevel@tonic-gate #define	MDI_HCI_CLASS_IB	"ib"
780Sstevel@tonic-gate 
790Sstevel@tonic-gate #ifdef _KERNEL
800Sstevel@tonic-gate 
810Sstevel@tonic-gate /*
820Sstevel@tonic-gate  * mpxio component definitions:  Every registered component of the
830Sstevel@tonic-gate  * mpxio system has a "mpxio-component" property attached to it.
840Sstevel@tonic-gate  * Identify its function
850Sstevel@tonic-gate  */
860Sstevel@tonic-gate #define	MDI_COMPONENT_NONE	0
870Sstevel@tonic-gate #define	MDI_COMPONENT_VHCI	0x1
880Sstevel@tonic-gate #define	MDI_COMPONENT_PHCI	0x2
890Sstevel@tonic-gate #define	MDI_COMPONENT_CLIENT	0x4
900Sstevel@tonic-gate 
910Sstevel@tonic-gate /*
920Sstevel@tonic-gate  * mdi_pathinfo node state utility definitions
930Sstevel@tonic-gate  */
940Sstevel@tonic-gate #define	MDI_PATHINFO_STATE_TRANSIENT			0x00010000
950Sstevel@tonic-gate #define	MDI_PATHINFO_STATE_USER_DISABLE			0x00100000
960Sstevel@tonic-gate #define	MDI_PATHINFO_STATE_DRV_DISABLE			0x00200000
970Sstevel@tonic-gate #define	MDI_PATHINFO_STATE_DRV_DISABLE_TRANSIENT	0x00400000
980Sstevel@tonic-gate #define	MDI_PATHINFO_STATE_MASK				0x0000FFFF
990Sstevel@tonic-gate #define	MDI_PATHINFO_EXT_STATE_MASK			0xFFF00000
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate #define	USER_DISABLE			1
1020Sstevel@tonic-gate #define	DRIVER_DISABLE			2
1030Sstevel@tonic-gate #define	DRIVER_DISABLE_TRANSIENT	3
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate /*
1070Sstevel@tonic-gate  * Most MDI functions return success or failure
1080Sstevel@tonic-gate  */
1090Sstevel@tonic-gate #define	MDI_SUCCESS		0	/* Call Success			*/
1100Sstevel@tonic-gate #define	MDI_FAILURE		-1	/* Unspecified Error		*/
1110Sstevel@tonic-gate #define	MDI_NOMEM		-2	/* No resources available	*/
1120Sstevel@tonic-gate #define	MDI_ACCEPT		-3	/* Request accepted		*/
1130Sstevel@tonic-gate #define	MDI_BUSY		-4	/* Busy				*/
1140Sstevel@tonic-gate #define	MDI_NOPATH		-5	/* No more paths are available	*/
1150Sstevel@tonic-gate #define	MDI_EINVAL		-6	/* Invalid parameter		*/
1160Sstevel@tonic-gate #define	MDI_NOT_SUPPORTED	-8	/* Device not supported		*/
1170Sstevel@tonic-gate #define	MDI_DEVI_ONLINING	-9	/* Devi is onlining		*/
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate /*
1200Sstevel@tonic-gate  * MDI operation vector structure definition
1210Sstevel@tonic-gate  */
1220Sstevel@tonic-gate #define	MDI_OPS_REV_1			1
1230Sstevel@tonic-gate #define	MDI_OPS_REV			MDI_OPS_REV_1
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate #define	MDI_VHCI(dip)	(DEVI(dip)->devi_mdi_component & MDI_COMPONENT_VHCI)
1260Sstevel@tonic-gate #define	MDI_PHCI(dip)	(DEVI(dip)->devi_mdi_component & MDI_COMPONENT_PHCI)
1270Sstevel@tonic-gate #define	MDI_CLIENT(dip)	(DEVI(dip)->devi_mdi_component & MDI_COMPONENT_CLIENT)
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate /*
1300Sstevel@tonic-gate  * MDI device hotplug notification
1310Sstevel@tonic-gate  */
1320Sstevel@tonic-gate int mdi_devi_online(dev_info_t *, uint_t);
1330Sstevel@tonic-gate int mdi_devi_offline(dev_info_t *, uint_t);
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate /*
1362155Scth  * MDI devinfo locking functions.
1372155Scth  */
1382155Scth void mdi_devi_enter(dev_info_t *, int *);
1392155Scth void mdi_devi_exit_phci(dev_info_t *, int);
1402155Scth void mdi_devi_enter_phci(dev_info_t *, int *);
1412155Scth void mdi_devi_exit(dev_info_t *, int);
1422155Scth 
1432155Scth /*
1442155Scth  * MDI device support functions.
1452155Scth  */
1462155Scth dev_info_t *mdi_devi_get_vdip(dev_info_t *);
1472155Scth int mdi_devi_pdip_entered(dev_info_t *);
1482155Scth 
1492155Scth /*
1500Sstevel@tonic-gate  * MDI component device instance attach/detach notification
1510Sstevel@tonic-gate  */
1520Sstevel@tonic-gate int mdi_pre_attach(dev_info_t *, ddi_attach_cmd_t);
1530Sstevel@tonic-gate void mdi_post_attach(dev_info_t *, ddi_attach_cmd_t, int);
1540Sstevel@tonic-gate int mdi_pre_detach(dev_info_t *, ddi_detach_cmd_t);
1550Sstevel@tonic-gate void mdi_post_detach(dev_info_t *, ddi_detach_cmd_t, int);
1560Sstevel@tonic-gate 
1570Sstevel@tonic-gate /*
1580Sstevel@tonic-gate  * mdi_pathinfo management functions.
1590Sstevel@tonic-gate  *
1600Sstevel@tonic-gate  * Find, allocate and Free functions.
1610Sstevel@tonic-gate  */
1620Sstevel@tonic-gate mdi_pathinfo_t *mdi_pi_find(dev_info_t *, char *, char *);
1630Sstevel@tonic-gate int mdi_pi_alloc(dev_info_t *, char *, char *, char *, int, mdi_pathinfo_t **);
1640Sstevel@tonic-gate int mdi_pi_alloc_compatible(dev_info_t *, char *, char *, char *,
1650Sstevel@tonic-gate 	char **, int, int, mdi_pathinfo_t **);
1660Sstevel@tonic-gate int mdi_pi_free(mdi_pathinfo_t *, int);
1670Sstevel@tonic-gate 
1682155Scth void mdi_hold_path(mdi_pathinfo_t *);
1692155Scth void mdi_rele_path(mdi_pathinfo_t *);
1702155Scth 
1710Sstevel@tonic-gate /*
1720Sstevel@tonic-gate  * mdi_pathinfo node state change functions.
1730Sstevel@tonic-gate  */
1740Sstevel@tonic-gate int mdi_pi_online(mdi_pathinfo_t *, int);
1750Sstevel@tonic-gate int mdi_pi_standby(mdi_pathinfo_t *, int);
1760Sstevel@tonic-gate int mdi_pi_fault(mdi_pathinfo_t *, int);
1770Sstevel@tonic-gate int mdi_pi_offline(mdi_pathinfo_t *, int);
1781909Scm136836 /*
1791909Scm136836  * NOTE: the next 2 interfaces will be removed once the NWS files are
1801909Scm136836  * changed to use the new mdi_{enable,disable}_path interfaces
1811909Scm136836  */
1820Sstevel@tonic-gate int mdi_pi_disable(dev_info_t *, dev_info_t *, int);
1830Sstevel@tonic-gate int mdi_pi_enable(dev_info_t *, dev_info_t *, int);
1841909Scm136836 int mdi_pi_disable_path(mdi_pathinfo_t *, int);
1851909Scm136836 int mdi_pi_enable_path(mdi_pathinfo_t *, int);
1860Sstevel@tonic-gate 
1870Sstevel@tonic-gate /*
1880Sstevel@tonic-gate  * MPxIO-PM stuff
1890Sstevel@tonic-gate  */
1900Sstevel@tonic-gate typedef enum {
1910Sstevel@tonic-gate 	MDI_PM_PRE_CONFIG = 0,
1920Sstevel@tonic-gate 	MDI_PM_POST_CONFIG,
1930Sstevel@tonic-gate 	MDI_PM_PRE_UNCONFIG,
1940Sstevel@tonic-gate 	MDI_PM_POST_UNCONFIG,
1950Sstevel@tonic-gate 	MDI_PM_HOLD_POWER,
1960Sstevel@tonic-gate 	MDI_PM_RELE_POWER
1970Sstevel@tonic-gate } mdi_pm_op_t;
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate int
2000Sstevel@tonic-gate mdi_bus_power(dev_info_t *, void *, pm_bus_power_op_t, void *, void *);
2010Sstevel@tonic-gate 
2020Sstevel@tonic-gate int
2030Sstevel@tonic-gate mdi_power(dev_info_t *, mdi_pm_op_t, void *, char *, int);
2040Sstevel@tonic-gate 
2050Sstevel@tonic-gate /*
2060Sstevel@tonic-gate  * mdi_pathinfo node walker function.
2070Sstevel@tonic-gate  */
2080Sstevel@tonic-gate int mdi_component_is_vhci(dev_info_t *, const char **);
2090Sstevel@tonic-gate int mdi_component_is_phci(dev_info_t *, const char **);
2100Sstevel@tonic-gate int mdi_component_is_client(dev_info_t *, const char **);
2110Sstevel@tonic-gate mdi_pathinfo_t *mdi_get_next_phci_path(dev_info_t *, mdi_pathinfo_t *);
2120Sstevel@tonic-gate mdi_pathinfo_t *mdi_get_next_client_path(dev_info_t *, mdi_pathinfo_t *);
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate /*
2150Sstevel@tonic-gate  * mdi_pathinfo node member functions
2160Sstevel@tonic-gate  */
2170Sstevel@tonic-gate void mdi_pi_lock(mdi_pathinfo_t *);
2180Sstevel@tonic-gate void mdi_pi_unlock(mdi_pathinfo_t *);
2190Sstevel@tonic-gate dev_info_t *mdi_pi_get_client(mdi_pathinfo_t *);
2200Sstevel@tonic-gate dev_info_t *mdi_pi_get_phci(mdi_pathinfo_t *);
2210Sstevel@tonic-gate char *mdi_pi_get_addr(mdi_pathinfo_t *);
2220Sstevel@tonic-gate mdi_pathinfo_state_t mdi_pi_get_state(mdi_pathinfo_t *);
2230Sstevel@tonic-gate 
2240Sstevel@tonic-gate /*
2250Sstevel@tonic-gate  * mdi_pathinfo Property handling functions
2260Sstevel@tonic-gate  */
2270Sstevel@tonic-gate int mdi_prop_remove(mdi_pathinfo_t *, char *);
2280Sstevel@tonic-gate int mdi_prop_update_byte_array(mdi_pathinfo_t *, char *, uchar_t *, uint_t);
2290Sstevel@tonic-gate int mdi_prop_update_int(mdi_pathinfo_t *, char *, int);
2300Sstevel@tonic-gate int mdi_prop_update_int64(mdi_pathinfo_t *, char *, int64_t);
2310Sstevel@tonic-gate int mdi_prop_update_int_array(mdi_pathinfo_t *, char *, int *, uint_t);
2320Sstevel@tonic-gate int mdi_prop_update_string(mdi_pathinfo_t *, char *, char *);
2330Sstevel@tonic-gate int mdi_prop_update_string_array(mdi_pathinfo_t *, char *, char **, uint_t);
2340Sstevel@tonic-gate nvpair_t *mdi_pi_get_next_prop(mdi_pathinfo_t *, nvpair_t *);
2350Sstevel@tonic-gate 
2360Sstevel@tonic-gate int mdi_prop_lookup_byte_array(mdi_pathinfo_t *, char *, uchar_t **, uint_t *);
2370Sstevel@tonic-gate int mdi_prop_lookup_int(mdi_pathinfo_t *, char *, int *);
2380Sstevel@tonic-gate int mdi_prop_lookup_int64(mdi_pathinfo_t *, char *, int64_t *);
2390Sstevel@tonic-gate int mdi_prop_lookup_int_array(mdi_pathinfo_t *, char *, int **, uint_t *);
2400Sstevel@tonic-gate int mdi_prop_lookup_string(mdi_pathinfo_t *, char *, char **);
2410Sstevel@tonic-gate int mdi_prop_lookup_string_array(mdi_pathinfo_t *, char *, char ***, uint_t *);
2420Sstevel@tonic-gate int mdi_prop_free(void *);
2430Sstevel@tonic-gate 
2440Sstevel@tonic-gate /*
2450Sstevel@tonic-gate  * pHCI driver instance registration/unregistration
2460Sstevel@tonic-gate  *
2470Sstevel@tonic-gate  * mdi_phci_register() is called by a pHCI drivers to register itself as a
2480Sstevel@tonic-gate  * transport provider for a specific 'class' (see mdi_vhci_register() above);
2490Sstevel@tonic-gate  * it should be called from attach(9e).
2500Sstevel@tonic-gate  *
2510Sstevel@tonic-gate  * mdi_phci_unregister() is called from detach(9e) to unregister a pHCI
2520Sstevel@tonic-gate  * instance from the framework.
2530Sstevel@tonic-gate  */
2540Sstevel@tonic-gate int		mdi_phci_register(char *, dev_info_t *, int);
2550Sstevel@tonic-gate int		mdi_phci_unregister(dev_info_t *, int);
2560Sstevel@tonic-gate 
2570Sstevel@tonic-gate /* get set phci private data */
2580Sstevel@tonic-gate caddr_t mdi_pi_get_phci_private(mdi_pathinfo_t *);
2590Sstevel@tonic-gate void mdi_pi_set_phci_private(mdi_pathinfo_t *, caddr_t);
2600Sstevel@tonic-gate 
2610Sstevel@tonic-gate int mdi_vhci_bus_config(dev_info_t *, uint_t, ddi_bus_config_op_t, void *,
262878Sramat     dev_info_t **, char *);
2630Sstevel@tonic-gate 
264893Srs135747 /*
265893Srs135747  * mdi_vhci node walker function
266893Srs135747  */
267893Srs135747 void mdi_walk_vhcis(int (*f)(dev_info_t *, void *), void *arg);
268893Srs135747 
269893Srs135747 /*
270893Srs135747  * mdi_phci node walker function
271893Srs135747  */
272893Srs135747 void mdi_vhci_walk_phcis(dev_info_t *, int (*f)(dev_info_t *, void *),
273893Srs135747     void *arg);
274893Srs135747 
275893Srs135747 /*
276893Srs135747  * mdi_client node walker function
277893Srs135747  */
278893Srs135747 void mdi_vhci_walk_clients(dev_info_t *, int (*f)(dev_info_t *, void *),
279893Srs135747     void *arg);
280893Srs135747 
281*2402Spramodbg /*
282*2402Spramodbg  * MDI PHCI driver list helper functions
283*2402Spramodbg  */
284*2402Spramodbg char **mdi_get_phci_driver_list(char *vhci_class, int	*ndrivers);
285*2402Spramodbg void mdi_free_phci_driver_list(char **driver_list, int ndrivers);
286*2402Spramodbg 
2870Sstevel@tonic-gate #endif /* _KERNEL */
2880Sstevel@tonic-gate 
2890Sstevel@tonic-gate #ifdef	__cplusplus
2900Sstevel@tonic-gate }
2910Sstevel@tonic-gate #endif
2920Sstevel@tonic-gate 
2930Sstevel@tonic-gate #endif	/* _SYS_SUNMDI_H */
294