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*9167SRandall.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 /* 900Sstevel@tonic-gate * mdi_pathinfo node state utility definitions 910Sstevel@tonic-gate */ 920Sstevel@tonic-gate #define MDI_PATHINFO_STATE_TRANSIENT 0x00010000 930Sstevel@tonic-gate #define MDI_PATHINFO_STATE_USER_DISABLE 0x00100000 940Sstevel@tonic-gate #define MDI_PATHINFO_STATE_DRV_DISABLE 0x00200000 950Sstevel@tonic-gate #define MDI_PATHINFO_STATE_DRV_DISABLE_TRANSIENT 0x00400000 960Sstevel@tonic-gate #define MDI_PATHINFO_STATE_MASK 0x0000FFFF 970Sstevel@tonic-gate #define MDI_PATHINFO_EXT_STATE_MASK 0xFFF00000 980Sstevel@tonic-gate 990Sstevel@tonic-gate #define USER_DISABLE 1 1000Sstevel@tonic-gate #define DRIVER_DISABLE 2 1010Sstevel@tonic-gate #define DRIVER_DISABLE_TRANSIENT 3 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate /* 1050Sstevel@tonic-gate * Most MDI functions return success or failure 1060Sstevel@tonic-gate */ 1070Sstevel@tonic-gate #define MDI_SUCCESS 0 /* Call Success */ 1080Sstevel@tonic-gate #define MDI_FAILURE -1 /* Unspecified Error */ 1090Sstevel@tonic-gate #define MDI_NOMEM -2 /* No resources available */ 1100Sstevel@tonic-gate #define MDI_ACCEPT -3 /* Request accepted */ 1110Sstevel@tonic-gate #define MDI_BUSY -4 /* Busy */ 1120Sstevel@tonic-gate #define MDI_NOPATH -5 /* No more paths are available */ 1130Sstevel@tonic-gate #define MDI_EINVAL -6 /* Invalid parameter */ 1140Sstevel@tonic-gate #define MDI_NOT_SUPPORTED -8 /* Device not supported */ 1150Sstevel@tonic-gate #define MDI_DEVI_ONLINING -9 /* Devi is onlining */ 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate /* 1180Sstevel@tonic-gate * MDI operation vector structure definition 1190Sstevel@tonic-gate */ 1200Sstevel@tonic-gate #define MDI_OPS_REV_1 1 1210Sstevel@tonic-gate #define MDI_OPS_REV MDI_OPS_REV_1 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate #define MDI_VHCI(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_VHCI) 1240Sstevel@tonic-gate #define MDI_PHCI(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_PHCI) 1250Sstevel@tonic-gate #define MDI_CLIENT(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_CLIENT) 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate /* 1280Sstevel@tonic-gate * MDI device hotplug notification 1290Sstevel@tonic-gate */ 1300Sstevel@tonic-gate int mdi_devi_online(dev_info_t *, uint_t); 1310Sstevel@tonic-gate int mdi_devi_offline(dev_info_t *, uint_t); 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate /* 1344845Svikram * MDI path retire interfaces 1354845Svikram */ 1364845Svikram void mdi_phci_mark_retiring(dev_info_t *dip, char **cons_array); 1374845Svikram void mdi_phci_retire_notify(dev_info_t *dip, int *constraint); 1384845Svikram void mdi_phci_retire_finalize(dev_info_t *dip, int phci_only); 1394845Svikram void mdi_phci_unretire(dev_info_t *dip); 1404845Svikram 1414845Svikram /* 1422155Scth * MDI devinfo locking functions. 1432155Scth */ 1442155Scth void mdi_devi_enter(dev_info_t *, int *); 145*9167SRandall.Ralphs@Sun.COM int mdi_devi_tryenter(dev_info_t *, int *); 1462155Scth void mdi_devi_exit_phci(dev_info_t *, int); 1472155Scth void mdi_devi_enter_phci(dev_info_t *, int *); 1482155Scth void mdi_devi_exit(dev_info_t *, int); 1492155Scth 1502155Scth /* 1512155Scth * MDI device support functions. 1522155Scth */ 1532155Scth dev_info_t *mdi_devi_get_vdip(dev_info_t *); 1542155Scth int mdi_devi_pdip_entered(dev_info_t *); 1552155Scth 1562155Scth /* 1570Sstevel@tonic-gate * MDI component device instance attach/detach notification 1580Sstevel@tonic-gate */ 1590Sstevel@tonic-gate int mdi_pre_attach(dev_info_t *, ddi_attach_cmd_t); 1600Sstevel@tonic-gate void mdi_post_attach(dev_info_t *, ddi_attach_cmd_t, int); 1610Sstevel@tonic-gate int mdi_pre_detach(dev_info_t *, ddi_detach_cmd_t); 1620Sstevel@tonic-gate void mdi_post_detach(dev_info_t *, ddi_detach_cmd_t, int); 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate /* 1650Sstevel@tonic-gate * mdi_pathinfo management functions. 1660Sstevel@tonic-gate * 1670Sstevel@tonic-gate * Find, allocate and Free functions. 1680Sstevel@tonic-gate */ 1690Sstevel@tonic-gate mdi_pathinfo_t *mdi_pi_find(dev_info_t *, char *, char *); 1700Sstevel@tonic-gate int mdi_pi_alloc(dev_info_t *, char *, char *, char *, int, mdi_pathinfo_t **); 1710Sstevel@tonic-gate int mdi_pi_alloc_compatible(dev_info_t *, char *, char *, char *, 1720Sstevel@tonic-gate char **, int, int, mdi_pathinfo_t **); 1730Sstevel@tonic-gate int mdi_pi_free(mdi_pathinfo_t *, int); 1740Sstevel@tonic-gate 1752155Scth void mdi_hold_path(mdi_pathinfo_t *); 1762155Scth void mdi_rele_path(mdi_pathinfo_t *); 1772155Scth 1780Sstevel@tonic-gate /* 1790Sstevel@tonic-gate * mdi_pathinfo node state change functions. 1800Sstevel@tonic-gate */ 1810Sstevel@tonic-gate int mdi_pi_online(mdi_pathinfo_t *, int); 1820Sstevel@tonic-gate int mdi_pi_standby(mdi_pathinfo_t *, int); 1830Sstevel@tonic-gate int mdi_pi_fault(mdi_pathinfo_t *, int); 1840Sstevel@tonic-gate int mdi_pi_offline(mdi_pathinfo_t *, int); 1851909Scm136836 /* 1861909Scm136836 * NOTE: the next 2 interfaces will be removed once the NWS files are 1871909Scm136836 * changed to use the new mdi_{enable,disable}_path interfaces 1881909Scm136836 */ 1890Sstevel@tonic-gate int mdi_pi_disable(dev_info_t *, dev_info_t *, int); 1900Sstevel@tonic-gate int mdi_pi_enable(dev_info_t *, dev_info_t *, int); 1911909Scm136836 int mdi_pi_disable_path(mdi_pathinfo_t *, int); 1921909Scm136836 int mdi_pi_enable_path(mdi_pathinfo_t *, int); 1930Sstevel@tonic-gate 1940Sstevel@tonic-gate /* 1950Sstevel@tonic-gate * MPxIO-PM stuff 1960Sstevel@tonic-gate */ 1970Sstevel@tonic-gate typedef enum { 1980Sstevel@tonic-gate MDI_PM_PRE_CONFIG = 0, 1990Sstevel@tonic-gate MDI_PM_POST_CONFIG, 2000Sstevel@tonic-gate MDI_PM_PRE_UNCONFIG, 2010Sstevel@tonic-gate MDI_PM_POST_UNCONFIG, 2020Sstevel@tonic-gate MDI_PM_HOLD_POWER, 2030Sstevel@tonic-gate MDI_PM_RELE_POWER 2040Sstevel@tonic-gate } mdi_pm_op_t; 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate int 2070Sstevel@tonic-gate mdi_bus_power(dev_info_t *, void *, pm_bus_power_op_t, void *, void *); 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate int 2100Sstevel@tonic-gate mdi_power(dev_info_t *, mdi_pm_op_t, void *, char *, int); 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate /* 2130Sstevel@tonic-gate * mdi_pathinfo node walker function. 2140Sstevel@tonic-gate */ 2150Sstevel@tonic-gate int mdi_component_is_vhci(dev_info_t *, const char **); 2160Sstevel@tonic-gate int mdi_component_is_phci(dev_info_t *, const char **); 2170Sstevel@tonic-gate int mdi_component_is_client(dev_info_t *, const char **); 2180Sstevel@tonic-gate mdi_pathinfo_t *mdi_get_next_phci_path(dev_info_t *, mdi_pathinfo_t *); 2190Sstevel@tonic-gate mdi_pathinfo_t *mdi_get_next_client_path(dev_info_t *, mdi_pathinfo_t *); 2200Sstevel@tonic-gate 2210Sstevel@tonic-gate /* 2220Sstevel@tonic-gate * mdi_pathinfo node member functions 2230Sstevel@tonic-gate */ 2240Sstevel@tonic-gate void mdi_pi_lock(mdi_pathinfo_t *); 2250Sstevel@tonic-gate void mdi_pi_unlock(mdi_pathinfo_t *); 2260Sstevel@tonic-gate dev_info_t *mdi_pi_get_client(mdi_pathinfo_t *); 2270Sstevel@tonic-gate dev_info_t *mdi_pi_get_phci(mdi_pathinfo_t *); 228*9167SRandall.Ralphs@Sun.COM char *mdi_pi_get_node_name(mdi_pathinfo_t *); 2290Sstevel@tonic-gate char *mdi_pi_get_addr(mdi_pathinfo_t *); 2300Sstevel@tonic-gate mdi_pathinfo_state_t mdi_pi_get_state(mdi_pathinfo_t *); 2316640Scth int mdi_pi_get_path_instance(mdi_pathinfo_t *); 2326640Scth char *mdi_pi_pathname_by_instance(int path_instance); 2336640Scth char *mdi_pi_pathname(mdi_pathinfo_t *); 2347413SJaven.Wu@Sun.COM char *mdi_pi_pathname_obp(mdi_pathinfo_t *, char *); 2357413SJaven.Wu@Sun.COM int mdi_pi_pathname_obp_set(mdi_pathinfo_t *, char *); 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate /* 2380Sstevel@tonic-gate * mdi_pathinfo Property handling functions 2390Sstevel@tonic-gate */ 2400Sstevel@tonic-gate int mdi_prop_remove(mdi_pathinfo_t *, char *); 2410Sstevel@tonic-gate int mdi_prop_update_byte_array(mdi_pathinfo_t *, char *, uchar_t *, uint_t); 2420Sstevel@tonic-gate int mdi_prop_update_int(mdi_pathinfo_t *, char *, int); 2430Sstevel@tonic-gate int mdi_prop_update_int64(mdi_pathinfo_t *, char *, int64_t); 2440Sstevel@tonic-gate int mdi_prop_update_int_array(mdi_pathinfo_t *, char *, int *, uint_t); 2450Sstevel@tonic-gate int mdi_prop_update_string(mdi_pathinfo_t *, char *, char *); 2460Sstevel@tonic-gate int mdi_prop_update_string_array(mdi_pathinfo_t *, char *, char **, uint_t); 2470Sstevel@tonic-gate nvpair_t *mdi_pi_get_next_prop(mdi_pathinfo_t *, nvpair_t *); 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate int mdi_prop_lookup_byte_array(mdi_pathinfo_t *, char *, uchar_t **, uint_t *); 2500Sstevel@tonic-gate int mdi_prop_lookup_int(mdi_pathinfo_t *, char *, int *); 2510Sstevel@tonic-gate int mdi_prop_lookup_int64(mdi_pathinfo_t *, char *, int64_t *); 2520Sstevel@tonic-gate int mdi_prop_lookup_int_array(mdi_pathinfo_t *, char *, int **, uint_t *); 2530Sstevel@tonic-gate int mdi_prop_lookup_string(mdi_pathinfo_t *, char *, char **); 2540Sstevel@tonic-gate int mdi_prop_lookup_string_array(mdi_pathinfo_t *, char *, char ***, uint_t *); 2550Sstevel@tonic-gate int mdi_prop_free(void *); 2560Sstevel@tonic-gate 2570Sstevel@tonic-gate /* 2580Sstevel@tonic-gate * pHCI driver instance registration/unregistration 2590Sstevel@tonic-gate * 2600Sstevel@tonic-gate * mdi_phci_register() is called by a pHCI drivers to register itself as a 2610Sstevel@tonic-gate * transport provider for a specific 'class' (see mdi_vhci_register() above); 2620Sstevel@tonic-gate * it should be called from attach(9e). 2630Sstevel@tonic-gate * 2640Sstevel@tonic-gate * mdi_phci_unregister() is called from detach(9e) to unregister a pHCI 2650Sstevel@tonic-gate * instance from the framework. 2660Sstevel@tonic-gate */ 2670Sstevel@tonic-gate int mdi_phci_register(char *, dev_info_t *, int); 2680Sstevel@tonic-gate int mdi_phci_unregister(dev_info_t *, int); 2690Sstevel@tonic-gate 2700Sstevel@tonic-gate /* get set phci private data */ 2710Sstevel@tonic-gate caddr_t mdi_pi_get_phci_private(mdi_pathinfo_t *); 2720Sstevel@tonic-gate void mdi_pi_set_phci_private(mdi_pathinfo_t *, caddr_t); 2730Sstevel@tonic-gate 2740Sstevel@tonic-gate int mdi_vhci_bus_config(dev_info_t *, uint_t, ddi_bus_config_op_t, void *, 275878Sramat dev_info_t **, char *); 2760Sstevel@tonic-gate 277893Srs135747 /* 278893Srs135747 * mdi_vhci node walker function 279893Srs135747 */ 280893Srs135747 void mdi_walk_vhcis(int (*f)(dev_info_t *, void *), void *arg); 281893Srs135747 282893Srs135747 /* 283893Srs135747 * mdi_phci node walker function 284893Srs135747 */ 285893Srs135747 void mdi_vhci_walk_phcis(dev_info_t *, int (*f)(dev_info_t *, void *), 286893Srs135747 void *arg); 287893Srs135747 288893Srs135747 /* 289893Srs135747 * mdi_client node walker function 290893Srs135747 */ 291893Srs135747 void mdi_vhci_walk_clients(dev_info_t *, int (*f)(dev_info_t *, void *), 292893Srs135747 void *arg); 293893Srs135747 2942402Spramodbg /* 2952402Spramodbg * MDI PHCI driver list helper functions 2962402Spramodbg */ 2972402Spramodbg char **mdi_get_phci_driver_list(char *vhci_class, int *ndrivers); 2982402Spramodbg void mdi_free_phci_driver_list(char **driver_list, int ndrivers); 2992402Spramodbg 3000Sstevel@tonic-gate #endif /* _KERNEL */ 3010Sstevel@tonic-gate 3020Sstevel@tonic-gate #ifdef __cplusplus 3030Sstevel@tonic-gate } 3040Sstevel@tonic-gate #endif 3050Sstevel@tonic-gate 3060Sstevel@tonic-gate #endif /* _SYS_SUNMDI_H */ 307