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*6640Scth * Copyright 2008 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 /* 1364845Svikram * MDI path retire interfaces 1374845Svikram */ 1384845Svikram void mdi_phci_mark_retiring(dev_info_t *dip, char **cons_array); 1394845Svikram void mdi_phci_retire_notify(dev_info_t *dip, int *constraint); 1404845Svikram void mdi_phci_retire_finalize(dev_info_t *dip, int phci_only); 1414845Svikram void mdi_phci_unretire(dev_info_t *dip); 1424845Svikram 1434845Svikram /* 1442155Scth * MDI devinfo locking functions. 1452155Scth */ 1462155Scth void mdi_devi_enter(dev_info_t *, int *); 1472155Scth void mdi_devi_exit_phci(dev_info_t *, int); 1482155Scth void mdi_devi_enter_phci(dev_info_t *, int *); 1492155Scth void mdi_devi_exit(dev_info_t *, int); 1502155Scth 1512155Scth /* 1522155Scth * MDI device support functions. 1532155Scth */ 1542155Scth dev_info_t *mdi_devi_get_vdip(dev_info_t *); 1552155Scth int mdi_devi_pdip_entered(dev_info_t *); 1562155Scth 1572155Scth /* 1580Sstevel@tonic-gate * MDI component device instance attach/detach notification 1590Sstevel@tonic-gate */ 1600Sstevel@tonic-gate int mdi_pre_attach(dev_info_t *, ddi_attach_cmd_t); 1610Sstevel@tonic-gate void mdi_post_attach(dev_info_t *, ddi_attach_cmd_t, int); 1620Sstevel@tonic-gate int mdi_pre_detach(dev_info_t *, ddi_detach_cmd_t); 1630Sstevel@tonic-gate void mdi_post_detach(dev_info_t *, ddi_detach_cmd_t, int); 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate /* 1660Sstevel@tonic-gate * mdi_pathinfo management functions. 1670Sstevel@tonic-gate * 1680Sstevel@tonic-gate * Find, allocate and Free functions. 1690Sstevel@tonic-gate */ 1700Sstevel@tonic-gate mdi_pathinfo_t *mdi_pi_find(dev_info_t *, char *, char *); 1710Sstevel@tonic-gate int mdi_pi_alloc(dev_info_t *, char *, char *, char *, int, mdi_pathinfo_t **); 1720Sstevel@tonic-gate int mdi_pi_alloc_compatible(dev_info_t *, char *, char *, char *, 1730Sstevel@tonic-gate char **, int, int, mdi_pathinfo_t **); 1740Sstevel@tonic-gate int mdi_pi_free(mdi_pathinfo_t *, int); 1750Sstevel@tonic-gate 1762155Scth void mdi_hold_path(mdi_pathinfo_t *); 1772155Scth void mdi_rele_path(mdi_pathinfo_t *); 1782155Scth 1790Sstevel@tonic-gate /* 1800Sstevel@tonic-gate * mdi_pathinfo node state change functions. 1810Sstevel@tonic-gate */ 1820Sstevel@tonic-gate int mdi_pi_online(mdi_pathinfo_t *, int); 1830Sstevel@tonic-gate int mdi_pi_standby(mdi_pathinfo_t *, int); 1840Sstevel@tonic-gate int mdi_pi_fault(mdi_pathinfo_t *, int); 1850Sstevel@tonic-gate int mdi_pi_offline(mdi_pathinfo_t *, int); 1861909Scm136836 /* 1871909Scm136836 * NOTE: the next 2 interfaces will be removed once the NWS files are 1881909Scm136836 * changed to use the new mdi_{enable,disable}_path interfaces 1891909Scm136836 */ 1900Sstevel@tonic-gate int mdi_pi_disable(dev_info_t *, dev_info_t *, int); 1910Sstevel@tonic-gate int mdi_pi_enable(dev_info_t *, dev_info_t *, int); 1921909Scm136836 int mdi_pi_disable_path(mdi_pathinfo_t *, int); 1931909Scm136836 int mdi_pi_enable_path(mdi_pathinfo_t *, int); 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate /* 1960Sstevel@tonic-gate * MPxIO-PM stuff 1970Sstevel@tonic-gate */ 1980Sstevel@tonic-gate typedef enum { 1990Sstevel@tonic-gate MDI_PM_PRE_CONFIG = 0, 2000Sstevel@tonic-gate MDI_PM_POST_CONFIG, 2010Sstevel@tonic-gate MDI_PM_PRE_UNCONFIG, 2020Sstevel@tonic-gate MDI_PM_POST_UNCONFIG, 2030Sstevel@tonic-gate MDI_PM_HOLD_POWER, 2040Sstevel@tonic-gate MDI_PM_RELE_POWER 2050Sstevel@tonic-gate } mdi_pm_op_t; 2060Sstevel@tonic-gate 2070Sstevel@tonic-gate int 2080Sstevel@tonic-gate mdi_bus_power(dev_info_t *, void *, pm_bus_power_op_t, void *, void *); 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate int 2110Sstevel@tonic-gate mdi_power(dev_info_t *, mdi_pm_op_t, void *, char *, int); 2120Sstevel@tonic-gate 2130Sstevel@tonic-gate /* 2140Sstevel@tonic-gate * mdi_pathinfo node walker function. 2150Sstevel@tonic-gate */ 2160Sstevel@tonic-gate int mdi_component_is_vhci(dev_info_t *, const char **); 2170Sstevel@tonic-gate int mdi_component_is_phci(dev_info_t *, const char **); 2180Sstevel@tonic-gate int mdi_component_is_client(dev_info_t *, const char **); 2190Sstevel@tonic-gate mdi_pathinfo_t *mdi_get_next_phci_path(dev_info_t *, mdi_pathinfo_t *); 2200Sstevel@tonic-gate mdi_pathinfo_t *mdi_get_next_client_path(dev_info_t *, mdi_pathinfo_t *); 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate /* 2230Sstevel@tonic-gate * mdi_pathinfo node member functions 2240Sstevel@tonic-gate */ 2250Sstevel@tonic-gate void mdi_pi_lock(mdi_pathinfo_t *); 2260Sstevel@tonic-gate void mdi_pi_unlock(mdi_pathinfo_t *); 2270Sstevel@tonic-gate dev_info_t *mdi_pi_get_client(mdi_pathinfo_t *); 2280Sstevel@tonic-gate dev_info_t *mdi_pi_get_phci(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 *); 231*6640Scth int mdi_pi_get_path_instance(mdi_pathinfo_t *); 232*6640Scth char *mdi_pi_pathname_by_instance(int path_instance); 233*6640Scth char *mdi_pi_pathname(mdi_pathinfo_t *); 2340Sstevel@tonic-gate 2350Sstevel@tonic-gate /* 2360Sstevel@tonic-gate * mdi_pathinfo Property handling functions 2370Sstevel@tonic-gate */ 2380Sstevel@tonic-gate int mdi_prop_remove(mdi_pathinfo_t *, char *); 2390Sstevel@tonic-gate int mdi_prop_update_byte_array(mdi_pathinfo_t *, char *, uchar_t *, uint_t); 2400Sstevel@tonic-gate int mdi_prop_update_int(mdi_pathinfo_t *, char *, int); 2410Sstevel@tonic-gate int mdi_prop_update_int64(mdi_pathinfo_t *, char *, int64_t); 2420Sstevel@tonic-gate int mdi_prop_update_int_array(mdi_pathinfo_t *, char *, int *, uint_t); 2430Sstevel@tonic-gate int mdi_prop_update_string(mdi_pathinfo_t *, char *, char *); 2440Sstevel@tonic-gate int mdi_prop_update_string_array(mdi_pathinfo_t *, char *, char **, uint_t); 2450Sstevel@tonic-gate nvpair_t *mdi_pi_get_next_prop(mdi_pathinfo_t *, nvpair_t *); 2460Sstevel@tonic-gate 2470Sstevel@tonic-gate int mdi_prop_lookup_byte_array(mdi_pathinfo_t *, char *, uchar_t **, uint_t *); 2480Sstevel@tonic-gate int mdi_prop_lookup_int(mdi_pathinfo_t *, char *, int *); 2490Sstevel@tonic-gate int mdi_prop_lookup_int64(mdi_pathinfo_t *, char *, int64_t *); 2500Sstevel@tonic-gate int mdi_prop_lookup_int_array(mdi_pathinfo_t *, char *, int **, uint_t *); 2510Sstevel@tonic-gate int mdi_prop_lookup_string(mdi_pathinfo_t *, char *, char **); 2520Sstevel@tonic-gate int mdi_prop_lookup_string_array(mdi_pathinfo_t *, char *, char ***, uint_t *); 2530Sstevel@tonic-gate int mdi_prop_free(void *); 2540Sstevel@tonic-gate 2550Sstevel@tonic-gate /* 2560Sstevel@tonic-gate * pHCI driver instance registration/unregistration 2570Sstevel@tonic-gate * 2580Sstevel@tonic-gate * mdi_phci_register() is called by a pHCI drivers to register itself as a 2590Sstevel@tonic-gate * transport provider for a specific 'class' (see mdi_vhci_register() above); 2600Sstevel@tonic-gate * it should be called from attach(9e). 2610Sstevel@tonic-gate * 2620Sstevel@tonic-gate * mdi_phci_unregister() is called from detach(9e) to unregister a pHCI 2630Sstevel@tonic-gate * instance from the framework. 2640Sstevel@tonic-gate */ 2650Sstevel@tonic-gate int mdi_phci_register(char *, dev_info_t *, int); 2660Sstevel@tonic-gate int mdi_phci_unregister(dev_info_t *, int); 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate /* get set phci private data */ 2690Sstevel@tonic-gate caddr_t mdi_pi_get_phci_private(mdi_pathinfo_t *); 2700Sstevel@tonic-gate void mdi_pi_set_phci_private(mdi_pathinfo_t *, caddr_t); 2710Sstevel@tonic-gate 2720Sstevel@tonic-gate int mdi_vhci_bus_config(dev_info_t *, uint_t, ddi_bus_config_op_t, void *, 273878Sramat dev_info_t **, char *); 2740Sstevel@tonic-gate 275893Srs135747 /* 276893Srs135747 * mdi_vhci node walker function 277893Srs135747 */ 278893Srs135747 void mdi_walk_vhcis(int (*f)(dev_info_t *, void *), void *arg); 279893Srs135747 280893Srs135747 /* 281893Srs135747 * mdi_phci node walker function 282893Srs135747 */ 283893Srs135747 void mdi_vhci_walk_phcis(dev_info_t *, int (*f)(dev_info_t *, void *), 284893Srs135747 void *arg); 285893Srs135747 286893Srs135747 /* 287893Srs135747 * mdi_client node walker function 288893Srs135747 */ 289893Srs135747 void mdi_vhci_walk_clients(dev_info_t *, int (*f)(dev_info_t *, void *), 290893Srs135747 void *arg); 291893Srs135747 2922402Spramodbg /* 2932402Spramodbg * MDI PHCI driver list helper functions 2942402Spramodbg */ 2952402Spramodbg char **mdi_get_phci_driver_list(char *vhci_class, int *ndrivers); 2962402Spramodbg void mdi_free_phci_driver_list(char **driver_list, int ndrivers); 2972402Spramodbg 2980Sstevel@tonic-gate #endif /* _KERNEL */ 2990Sstevel@tonic-gate 3000Sstevel@tonic-gate #ifdef __cplusplus 3010Sstevel@tonic-gate } 3020Sstevel@tonic-gate #endif 3030Sstevel@tonic-gate 3040Sstevel@tonic-gate #endif /* _SYS_SUNMDI_H */ 305