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 /* 229167SRandall.Ralphs@Sun.COM * Copyright 2009 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 /* 300Sstevel@tonic-gate * Multiplexed I/O global include 310Sstevel@tonic-gate */ 320Sstevel@tonic-gate 330Sstevel@tonic-gate #include <sys/note.h> 340Sstevel@tonic-gate #include <sys/esunddi.h> 350Sstevel@tonic-gate #include <sys/sunddi.h> 360Sstevel@tonic-gate #include <sys/ddipropdefs.h> 370Sstevel@tonic-gate 380Sstevel@tonic-gate #ifdef __cplusplus 390Sstevel@tonic-gate extern "C" { 400Sstevel@tonic-gate #endif 410Sstevel@tonic-gate 420Sstevel@tonic-gate /* 430Sstevel@tonic-gate * Most MDI functions return success or failure 440Sstevel@tonic-gate */ 450Sstevel@tonic-gate #define MDI_SUCCESS 0 /* Call Success */ 460Sstevel@tonic-gate #define MDI_FAILURE -1 /* Unspecified Error */ 470Sstevel@tonic-gate #define MDI_NOMEM -2 /* No resources available */ 480Sstevel@tonic-gate #define MDI_ACCEPT -3 /* Request accepted */ 490Sstevel@tonic-gate #define MDI_BUSY -4 /* Busy */ 500Sstevel@tonic-gate #define MDI_NOPATH -5 /* No more paths are available */ 510Sstevel@tonic-gate #define MDI_EINVAL -6 /* Invalid parameter */ 520Sstevel@tonic-gate #define MDI_NOT_SUPPORTED -8 /* Device not supported */ 530Sstevel@tonic-gate #define MDI_DEVI_ONLINING -9 /* Devi is onlining */ 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* 560Sstevel@tonic-gate * handle to mdi_pathinfo node 570Sstevel@tonic-gate */ 580Sstevel@tonic-gate typedef struct x_mdi_pathinfo *mdi_pathinfo_t; 590Sstevel@tonic-gate 600Sstevel@tonic-gate /* 610Sstevel@tonic-gate * Path info node state definitions 620Sstevel@tonic-gate */ 630Sstevel@tonic-gate typedef enum { 640Sstevel@tonic-gate MDI_PATHINFO_STATE_INIT, 650Sstevel@tonic-gate MDI_PATHINFO_STATE_ONLINE, 660Sstevel@tonic-gate MDI_PATHINFO_STATE_STANDBY, 670Sstevel@tonic-gate MDI_PATHINFO_STATE_FAULT, 680Sstevel@tonic-gate MDI_PATHINFO_STATE_OFFLINE 690Sstevel@tonic-gate } mdi_pathinfo_state_t; 700Sstevel@tonic-gate 710Sstevel@tonic-gate /* 720Sstevel@tonic-gate * MDI vHCI class definitions 730Sstevel@tonic-gate */ 740Sstevel@tonic-gate #define MDI_HCI_CLASS_SCSI "scsi_vhci" 750Sstevel@tonic-gate #define MDI_HCI_CLASS_IB "ib" 760Sstevel@tonic-gate 770Sstevel@tonic-gate #ifdef _KERNEL 780Sstevel@tonic-gate 790Sstevel@tonic-gate /* 800Sstevel@tonic-gate * mpxio component definitions: Every registered component of the 810Sstevel@tonic-gate * mpxio system has a "mpxio-component" property attached to it. 820Sstevel@tonic-gate * Identify its function 830Sstevel@tonic-gate */ 840Sstevel@tonic-gate #define MDI_COMPONENT_NONE 0 850Sstevel@tonic-gate #define MDI_COMPONENT_VHCI 0x1 860Sstevel@tonic-gate #define MDI_COMPONENT_PHCI 0x2 870Sstevel@tonic-gate #define MDI_COMPONENT_CLIENT 0x4 880Sstevel@tonic-gate 890Sstevel@tonic-gate /* 90*10696SDavid.Hollister@Sun.COM * mdi_pathinfo node state utility definitions (bits in mdi_pathinfo_state_t) 91*10696SDavid.Hollister@Sun.COM * 92*10696SDavid.Hollister@Sun.COM * NOTE: having mdi_pathinfo_state_t contain both state and flags is error 93*10696SDavid.Hollister@Sun.COM * prone. For new flags, please consider using MDI_PATHINFO_FLAG_ (and 94*10696SDavid.Hollister@Sun.COM * moving existing EXT_STATE_MASK flags over would be good too). 950Sstevel@tonic-gate */ 960Sstevel@tonic-gate #define MDI_PATHINFO_STATE_TRANSIENT 0x00010000 970Sstevel@tonic-gate #define MDI_PATHINFO_STATE_USER_DISABLE 0x00100000 980Sstevel@tonic-gate #define MDI_PATHINFO_STATE_DRV_DISABLE 0x00200000 990Sstevel@tonic-gate #define MDI_PATHINFO_STATE_DRV_DISABLE_TRANSIENT 0x00400000 1000Sstevel@tonic-gate #define MDI_PATHINFO_STATE_MASK 0x0000FFFF 1010Sstevel@tonic-gate #define MDI_PATHINFO_EXT_STATE_MASK 0xFFF00000 1020Sstevel@tonic-gate 103*10696SDavid.Hollister@Sun.COM /* 104*10696SDavid.Hollister@Sun.COM * mdi_pathinfo flags definitions 105*10696SDavid.Hollister@Sun.COM */ 106*10696SDavid.Hollister@Sun.COM #define MDI_PATHINFO_FLAGS_HIDDEN 0x00000001 107*10696SDavid.Hollister@Sun.COM #define MDI_PATHINFO_FLAGS_DEVICE_REMOVED 0x00000002 108*10696SDavid.Hollister@Sun.COM 1090Sstevel@tonic-gate #define USER_DISABLE 1 1100Sstevel@tonic-gate #define DRIVER_DISABLE 2 1110Sstevel@tonic-gate #define DRIVER_DISABLE_TRANSIENT 3 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate /* 1150Sstevel@tonic-gate * Most MDI functions return success or failure 1160Sstevel@tonic-gate */ 1170Sstevel@tonic-gate #define MDI_SUCCESS 0 /* Call Success */ 1180Sstevel@tonic-gate #define MDI_FAILURE -1 /* Unspecified Error */ 1190Sstevel@tonic-gate #define MDI_NOMEM -2 /* No resources available */ 1200Sstevel@tonic-gate #define MDI_ACCEPT -3 /* Request accepted */ 1210Sstevel@tonic-gate #define MDI_BUSY -4 /* Busy */ 1220Sstevel@tonic-gate #define MDI_NOPATH -5 /* No more paths are available */ 1230Sstevel@tonic-gate #define MDI_EINVAL -6 /* Invalid parameter */ 1240Sstevel@tonic-gate #define MDI_NOT_SUPPORTED -8 /* Device not supported */ 1250Sstevel@tonic-gate #define MDI_DEVI_ONLINING -9 /* Devi is onlining */ 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate /* 1280Sstevel@tonic-gate * MDI operation vector structure definition 1290Sstevel@tonic-gate */ 1300Sstevel@tonic-gate #define MDI_OPS_REV_1 1 1310Sstevel@tonic-gate #define MDI_OPS_REV MDI_OPS_REV_1 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate #define MDI_VHCI(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_VHCI) 1340Sstevel@tonic-gate #define MDI_PHCI(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_PHCI) 1350Sstevel@tonic-gate #define MDI_CLIENT(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_CLIENT) 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate /* 1380Sstevel@tonic-gate * MDI device hotplug notification 1390Sstevel@tonic-gate */ 1400Sstevel@tonic-gate int mdi_devi_online(dev_info_t *, uint_t); 1410Sstevel@tonic-gate int mdi_devi_offline(dev_info_t *, uint_t); 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate /* 1444845Svikram * MDI path retire interfaces 1454845Svikram */ 1464845Svikram void mdi_phci_mark_retiring(dev_info_t *dip, char **cons_array); 1474845Svikram void mdi_phci_retire_notify(dev_info_t *dip, int *constraint); 1484845Svikram void mdi_phci_retire_finalize(dev_info_t *dip, int phci_only); 1494845Svikram void mdi_phci_unretire(dev_info_t *dip); 1504845Svikram 1514845Svikram /* 1522155Scth * MDI devinfo locking functions. 1532155Scth */ 1542155Scth void mdi_devi_enter(dev_info_t *, int *); 1559167SRandall.Ralphs@Sun.COM int mdi_devi_tryenter(dev_info_t *, int *); 1562155Scth void mdi_devi_exit_phci(dev_info_t *, int); 1572155Scth void mdi_devi_enter_phci(dev_info_t *, int *); 1582155Scth void mdi_devi_exit(dev_info_t *, int); 1592155Scth 1602155Scth /* 1612155Scth * MDI device support functions. 1622155Scth */ 1632155Scth dev_info_t *mdi_devi_get_vdip(dev_info_t *); 1642155Scth int mdi_devi_pdip_entered(dev_info_t *); 1652155Scth 1662155Scth /* 1670Sstevel@tonic-gate * MDI component device instance attach/detach notification 1680Sstevel@tonic-gate */ 1690Sstevel@tonic-gate int mdi_pre_attach(dev_info_t *, ddi_attach_cmd_t); 1700Sstevel@tonic-gate void mdi_post_attach(dev_info_t *, ddi_attach_cmd_t, int); 1710Sstevel@tonic-gate int mdi_pre_detach(dev_info_t *, ddi_detach_cmd_t); 1720Sstevel@tonic-gate void mdi_post_detach(dev_info_t *, ddi_detach_cmd_t, int); 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate /* 1750Sstevel@tonic-gate * mdi_pathinfo management functions. 1760Sstevel@tonic-gate * 1770Sstevel@tonic-gate * Find, allocate and Free functions. 1780Sstevel@tonic-gate */ 1790Sstevel@tonic-gate mdi_pathinfo_t *mdi_pi_find(dev_info_t *, char *, char *); 1800Sstevel@tonic-gate int mdi_pi_alloc(dev_info_t *, char *, char *, char *, int, mdi_pathinfo_t **); 1810Sstevel@tonic-gate int mdi_pi_alloc_compatible(dev_info_t *, char *, char *, char *, 1820Sstevel@tonic-gate char **, int, int, mdi_pathinfo_t **); 1830Sstevel@tonic-gate int mdi_pi_free(mdi_pathinfo_t *, int); 1840Sstevel@tonic-gate 1852155Scth void mdi_hold_path(mdi_pathinfo_t *); 1862155Scth void mdi_rele_path(mdi_pathinfo_t *); 1872155Scth 1880Sstevel@tonic-gate /* 1890Sstevel@tonic-gate * mdi_pathinfo node state change functions. 1900Sstevel@tonic-gate */ 1910Sstevel@tonic-gate int mdi_pi_online(mdi_pathinfo_t *, int); 1920Sstevel@tonic-gate int mdi_pi_standby(mdi_pathinfo_t *, int); 1930Sstevel@tonic-gate int mdi_pi_fault(mdi_pathinfo_t *, int); 1940Sstevel@tonic-gate int mdi_pi_offline(mdi_pathinfo_t *, int); 1951909Scm136836 /* 1961909Scm136836 * NOTE: the next 2 interfaces will be removed once the NWS files are 1971909Scm136836 * changed to use the new mdi_{enable,disable}_path interfaces 1981909Scm136836 */ 1990Sstevel@tonic-gate int mdi_pi_disable(dev_info_t *, dev_info_t *, int); 2000Sstevel@tonic-gate int mdi_pi_enable(dev_info_t *, dev_info_t *, int); 2011909Scm136836 int mdi_pi_disable_path(mdi_pathinfo_t *, int); 2021909Scm136836 int mdi_pi_enable_path(mdi_pathinfo_t *, int); 2030Sstevel@tonic-gate 204*10696SDavid.Hollister@Sun.COM int mdi_pi_ishidden(mdi_pathinfo_t *); 205*10696SDavid.Hollister@Sun.COM 206*10696SDavid.Hollister@Sun.COM int mdi_pi_device_isremoved(mdi_pathinfo_t *); 207*10696SDavid.Hollister@Sun.COM int mdi_pi_device_remove(mdi_pathinfo_t *); 208*10696SDavid.Hollister@Sun.COM int mdi_pi_device_insert(mdi_pathinfo_t *); 209*10696SDavid.Hollister@Sun.COM 2100Sstevel@tonic-gate /* 2110Sstevel@tonic-gate * MPxIO-PM stuff 2120Sstevel@tonic-gate */ 2130Sstevel@tonic-gate typedef enum { 2140Sstevel@tonic-gate MDI_PM_PRE_CONFIG = 0, 2150Sstevel@tonic-gate MDI_PM_POST_CONFIG, 2160Sstevel@tonic-gate MDI_PM_PRE_UNCONFIG, 2170Sstevel@tonic-gate MDI_PM_POST_UNCONFIG, 2180Sstevel@tonic-gate MDI_PM_HOLD_POWER, 2190Sstevel@tonic-gate MDI_PM_RELE_POWER 2200Sstevel@tonic-gate } mdi_pm_op_t; 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate int 2230Sstevel@tonic-gate mdi_bus_power(dev_info_t *, void *, pm_bus_power_op_t, void *, void *); 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate int 2260Sstevel@tonic-gate mdi_power(dev_info_t *, mdi_pm_op_t, void *, char *, int); 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate /* 2290Sstevel@tonic-gate * mdi_pathinfo node walker function. 2300Sstevel@tonic-gate */ 2310Sstevel@tonic-gate int mdi_component_is_vhci(dev_info_t *, const char **); 2320Sstevel@tonic-gate int mdi_component_is_phci(dev_info_t *, const char **); 2330Sstevel@tonic-gate int mdi_component_is_client(dev_info_t *, const char **); 2340Sstevel@tonic-gate mdi_pathinfo_t *mdi_get_next_phci_path(dev_info_t *, mdi_pathinfo_t *); 2350Sstevel@tonic-gate mdi_pathinfo_t *mdi_get_next_client_path(dev_info_t *, mdi_pathinfo_t *); 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate /* 2380Sstevel@tonic-gate * mdi_pathinfo node member functions 2390Sstevel@tonic-gate */ 2400Sstevel@tonic-gate void mdi_pi_lock(mdi_pathinfo_t *); 2410Sstevel@tonic-gate void mdi_pi_unlock(mdi_pathinfo_t *); 2420Sstevel@tonic-gate dev_info_t *mdi_pi_get_client(mdi_pathinfo_t *); 2430Sstevel@tonic-gate dev_info_t *mdi_pi_get_phci(mdi_pathinfo_t *); 2449167SRandall.Ralphs@Sun.COM char *mdi_pi_get_node_name(mdi_pathinfo_t *); 2450Sstevel@tonic-gate char *mdi_pi_get_addr(mdi_pathinfo_t *); 2460Sstevel@tonic-gate mdi_pathinfo_state_t mdi_pi_get_state(mdi_pathinfo_t *); 247*10696SDavid.Hollister@Sun.COM uint_t mdi_pi_get_flags(mdi_pathinfo_t *); 2486640Scth int mdi_pi_get_path_instance(mdi_pathinfo_t *); 249*10696SDavid.Hollister@Sun.COM char *mdi_pi_pathname_by_instance(int); 2506640Scth char *mdi_pi_pathname(mdi_pathinfo_t *); 2517413SJaven.Wu@Sun.COM char *mdi_pi_pathname_obp(mdi_pathinfo_t *, char *); 2527413SJaven.Wu@Sun.COM int mdi_pi_pathname_obp_set(mdi_pathinfo_t *, char *); 253*10696SDavid.Hollister@Sun.COM char *mdi_pi_spathname_by_instance(int); 254*10696SDavid.Hollister@Sun.COM char *mdi_pi_spathname(mdi_pathinfo_t *); 2550Sstevel@tonic-gate 2560Sstevel@tonic-gate /* 2570Sstevel@tonic-gate * mdi_pathinfo Property handling functions 2580Sstevel@tonic-gate */ 2590Sstevel@tonic-gate int mdi_prop_remove(mdi_pathinfo_t *, char *); 2600Sstevel@tonic-gate int mdi_prop_update_byte_array(mdi_pathinfo_t *, char *, uchar_t *, uint_t); 2610Sstevel@tonic-gate int mdi_prop_update_int(mdi_pathinfo_t *, char *, int); 2620Sstevel@tonic-gate int mdi_prop_update_int64(mdi_pathinfo_t *, char *, int64_t); 2630Sstevel@tonic-gate int mdi_prop_update_int_array(mdi_pathinfo_t *, char *, int *, uint_t); 2640Sstevel@tonic-gate int mdi_prop_update_string(mdi_pathinfo_t *, char *, char *); 2650Sstevel@tonic-gate int mdi_prop_update_string_array(mdi_pathinfo_t *, char *, char **, uint_t); 2660Sstevel@tonic-gate nvpair_t *mdi_pi_get_next_prop(mdi_pathinfo_t *, nvpair_t *); 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate int mdi_prop_lookup_byte_array(mdi_pathinfo_t *, char *, uchar_t **, uint_t *); 2690Sstevel@tonic-gate int mdi_prop_lookup_int(mdi_pathinfo_t *, char *, int *); 2700Sstevel@tonic-gate int mdi_prop_lookup_int64(mdi_pathinfo_t *, char *, int64_t *); 2710Sstevel@tonic-gate int mdi_prop_lookup_int_array(mdi_pathinfo_t *, char *, int **, uint_t *); 2720Sstevel@tonic-gate int mdi_prop_lookup_string(mdi_pathinfo_t *, char *, char **); 2730Sstevel@tonic-gate int mdi_prop_lookup_string_array(mdi_pathinfo_t *, char *, char ***, uint_t *); 2740Sstevel@tonic-gate int mdi_prop_free(void *); 2750Sstevel@tonic-gate 2760Sstevel@tonic-gate /* 2770Sstevel@tonic-gate * pHCI driver instance registration/unregistration 2780Sstevel@tonic-gate * 2790Sstevel@tonic-gate * mdi_phci_register() is called by a pHCI drivers to register itself as a 2800Sstevel@tonic-gate * transport provider for a specific 'class' (see mdi_vhci_register() above); 2810Sstevel@tonic-gate * it should be called from attach(9e). 2820Sstevel@tonic-gate * 2830Sstevel@tonic-gate * mdi_phci_unregister() is called from detach(9e) to unregister a pHCI 2840Sstevel@tonic-gate * instance from the framework. 2850Sstevel@tonic-gate */ 2860Sstevel@tonic-gate int mdi_phci_register(char *, dev_info_t *, int); 2870Sstevel@tonic-gate int mdi_phci_unregister(dev_info_t *, int); 2880Sstevel@tonic-gate 2890Sstevel@tonic-gate /* get set phci private data */ 2900Sstevel@tonic-gate caddr_t mdi_pi_get_phci_private(mdi_pathinfo_t *); 2910Sstevel@tonic-gate void mdi_pi_set_phci_private(mdi_pathinfo_t *, caddr_t); 2920Sstevel@tonic-gate 2930Sstevel@tonic-gate int mdi_vhci_bus_config(dev_info_t *, uint_t, ddi_bus_config_op_t, void *, 294878Sramat dev_info_t **, char *); 2950Sstevel@tonic-gate 296893Srs135747 /* 297893Srs135747 * mdi_vhci node walker function 298893Srs135747 */ 299893Srs135747 void mdi_walk_vhcis(int (*f)(dev_info_t *, void *), void *arg); 300893Srs135747 301893Srs135747 /* 302893Srs135747 * mdi_phci node walker function 303893Srs135747 */ 304893Srs135747 void mdi_vhci_walk_phcis(dev_info_t *, int (*f)(dev_info_t *, void *), 305893Srs135747 void *arg); 306893Srs135747 307893Srs135747 /* 308893Srs135747 * mdi_client node walker function 309893Srs135747 */ 310893Srs135747 void mdi_vhci_walk_clients(dev_info_t *, int (*f)(dev_info_t *, void *), 311893Srs135747 void *arg); 312893Srs135747 3132402Spramodbg /* 3142402Spramodbg * MDI PHCI driver list helper functions 3152402Spramodbg */ 3162402Spramodbg char **mdi_get_phci_driver_list(char *vhci_class, int *ndrivers); 3172402Spramodbg void mdi_free_phci_driver_list(char **driver_list, int ndrivers); 3182402Spramodbg 3190Sstevel@tonic-gate #endif /* _KERNEL */ 3200Sstevel@tonic-gate 3210Sstevel@tonic-gate #ifdef __cplusplus 3220Sstevel@tonic-gate } 3230Sstevel@tonic-gate #endif 3240Sstevel@tonic-gate 3250Sstevel@tonic-gate #endif /* _SYS_SUNMDI_H */ 326