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