1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _SYS_SUNMDI_H 28*0Sstevel@tonic-gate #define _SYS_SUNMDI_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate /* 33*0Sstevel@tonic-gate * Multiplexed I/O global include 34*0Sstevel@tonic-gate */ 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #include <sys/note.h> 37*0Sstevel@tonic-gate #include <sys/esunddi.h> 38*0Sstevel@tonic-gate #include <sys/sunddi.h> 39*0Sstevel@tonic-gate #include <sys/ddipropdefs.h> 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate #ifdef __cplusplus 42*0Sstevel@tonic-gate extern "C" { 43*0Sstevel@tonic-gate #endif 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate /* 46*0Sstevel@tonic-gate * Most MDI functions return success or failure 47*0Sstevel@tonic-gate */ 48*0Sstevel@tonic-gate #define MDI_SUCCESS 0 /* Call Success */ 49*0Sstevel@tonic-gate #define MDI_FAILURE -1 /* Unspecified Error */ 50*0Sstevel@tonic-gate #define MDI_NOMEM -2 /* No resources available */ 51*0Sstevel@tonic-gate #define MDI_ACCEPT -3 /* Request accepted */ 52*0Sstevel@tonic-gate #define MDI_BUSY -4 /* Busy */ 53*0Sstevel@tonic-gate #define MDI_NOPATH -5 /* No more paths are available */ 54*0Sstevel@tonic-gate #define MDI_EINVAL -6 /* Invalid parameter */ 55*0Sstevel@tonic-gate #define MDI_NOT_SUPPORTED -8 /* Device not supported */ 56*0Sstevel@tonic-gate #define MDI_DEVI_ONLINING -9 /* Devi is onlining */ 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate /* 59*0Sstevel@tonic-gate * handle to mdi_pathinfo node 60*0Sstevel@tonic-gate */ 61*0Sstevel@tonic-gate typedef struct x_mdi_pathinfo *mdi_pathinfo_t; 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate /* 64*0Sstevel@tonic-gate * Path info node state definitions 65*0Sstevel@tonic-gate */ 66*0Sstevel@tonic-gate typedef enum { 67*0Sstevel@tonic-gate MDI_PATHINFO_STATE_INIT, 68*0Sstevel@tonic-gate MDI_PATHINFO_STATE_ONLINE, 69*0Sstevel@tonic-gate MDI_PATHINFO_STATE_STANDBY, 70*0Sstevel@tonic-gate MDI_PATHINFO_STATE_FAULT, 71*0Sstevel@tonic-gate MDI_PATHINFO_STATE_OFFLINE 72*0Sstevel@tonic-gate } mdi_pathinfo_state_t; 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate /* 75*0Sstevel@tonic-gate * MDI vHCI class definitions 76*0Sstevel@tonic-gate */ 77*0Sstevel@tonic-gate #define MDI_HCI_CLASS_SCSI "scsi_vhci" 78*0Sstevel@tonic-gate #define MDI_HCI_CLASS_IB "ib" 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate #ifdef _KERNEL 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate /* 83*0Sstevel@tonic-gate * mpxio component definitions: Every registered component of the 84*0Sstevel@tonic-gate * mpxio system has a "mpxio-component" property attached to it. 85*0Sstevel@tonic-gate * Identify its function 86*0Sstevel@tonic-gate */ 87*0Sstevel@tonic-gate #define MDI_COMPONENT_NONE 0 88*0Sstevel@tonic-gate #define MDI_COMPONENT_VHCI 0x1 89*0Sstevel@tonic-gate #define MDI_COMPONENT_PHCI 0x2 90*0Sstevel@tonic-gate #define MDI_COMPONENT_CLIENT 0x4 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate /* 93*0Sstevel@tonic-gate * mdi_pathinfo node state utility definitions 94*0Sstevel@tonic-gate */ 95*0Sstevel@tonic-gate #define MDI_PATHINFO_STATE_TRANSIENT 0x00010000 96*0Sstevel@tonic-gate #define MDI_PATHINFO_STATE_USER_DISABLE 0x00100000 97*0Sstevel@tonic-gate #define MDI_PATHINFO_STATE_DRV_DISABLE 0x00200000 98*0Sstevel@tonic-gate #define MDI_PATHINFO_STATE_DRV_DISABLE_TRANSIENT 0x00400000 99*0Sstevel@tonic-gate #define MDI_PATHINFO_STATE_MASK 0x0000FFFF 100*0Sstevel@tonic-gate #define MDI_PATHINFO_EXT_STATE_MASK 0xFFF00000 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate #define USER_DISABLE 1 103*0Sstevel@tonic-gate #define DRIVER_DISABLE 2 104*0Sstevel@tonic-gate #define DRIVER_DISABLE_TRANSIENT 3 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate 107*0Sstevel@tonic-gate /* 108*0Sstevel@tonic-gate * Most MDI functions return success or failure 109*0Sstevel@tonic-gate */ 110*0Sstevel@tonic-gate #define MDI_SUCCESS 0 /* Call Success */ 111*0Sstevel@tonic-gate #define MDI_FAILURE -1 /* Unspecified Error */ 112*0Sstevel@tonic-gate #define MDI_NOMEM -2 /* No resources available */ 113*0Sstevel@tonic-gate #define MDI_ACCEPT -3 /* Request accepted */ 114*0Sstevel@tonic-gate #define MDI_BUSY -4 /* Busy */ 115*0Sstevel@tonic-gate #define MDI_NOPATH -5 /* No more paths are available */ 116*0Sstevel@tonic-gate #define MDI_EINVAL -6 /* Invalid parameter */ 117*0Sstevel@tonic-gate #define MDI_NOT_SUPPORTED -8 /* Device not supported */ 118*0Sstevel@tonic-gate #define MDI_DEVI_ONLINING -9 /* Devi is onlining */ 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate /* 121*0Sstevel@tonic-gate * MDI operation vector structure definition 122*0Sstevel@tonic-gate */ 123*0Sstevel@tonic-gate #define MDI_OPS_REV_1 1 124*0Sstevel@tonic-gate #define MDI_OPS_REV MDI_OPS_REV_1 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate #define MDI_VHCI(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_VHCI) 127*0Sstevel@tonic-gate #define MDI_PHCI(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_PHCI) 128*0Sstevel@tonic-gate #define MDI_CLIENT(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_CLIENT) 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gate /* 131*0Sstevel@tonic-gate * MDI device hotplug notification 132*0Sstevel@tonic-gate */ 133*0Sstevel@tonic-gate int mdi_devi_online(dev_info_t *, uint_t); 134*0Sstevel@tonic-gate int mdi_devi_offline(dev_info_t *, uint_t); 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate /* 137*0Sstevel@tonic-gate * MDI component device instance attach/detach notification 138*0Sstevel@tonic-gate */ 139*0Sstevel@tonic-gate int mdi_pre_attach(dev_info_t *, ddi_attach_cmd_t); 140*0Sstevel@tonic-gate void mdi_post_attach(dev_info_t *, ddi_attach_cmd_t, int); 141*0Sstevel@tonic-gate int mdi_pre_detach(dev_info_t *, ddi_detach_cmd_t); 142*0Sstevel@tonic-gate void mdi_post_detach(dev_info_t *, ddi_detach_cmd_t, int); 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate int mdi_devi_config_one(dev_info_t *, char *, dev_info_t **, int, clock_t); 145*0Sstevel@tonic-gate 146*0Sstevel@tonic-gate /* 147*0Sstevel@tonic-gate * mdi_pathinfo management functions. 148*0Sstevel@tonic-gate * 149*0Sstevel@tonic-gate * Find, allocate and Free functions. 150*0Sstevel@tonic-gate */ 151*0Sstevel@tonic-gate mdi_pathinfo_t *mdi_pi_find(dev_info_t *, char *, char *); 152*0Sstevel@tonic-gate int mdi_pi_alloc(dev_info_t *, char *, char *, char *, int, mdi_pathinfo_t **); 153*0Sstevel@tonic-gate int mdi_pi_alloc_compatible(dev_info_t *, char *, char *, char *, 154*0Sstevel@tonic-gate char **, int, int, mdi_pathinfo_t **); 155*0Sstevel@tonic-gate int mdi_pi_free(mdi_pathinfo_t *, int); 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate /* 158*0Sstevel@tonic-gate * mdi_pathinfo node state change functions. 159*0Sstevel@tonic-gate */ 160*0Sstevel@tonic-gate int mdi_pi_online(mdi_pathinfo_t *, int); 161*0Sstevel@tonic-gate int mdi_pi_standby(mdi_pathinfo_t *, int); 162*0Sstevel@tonic-gate int mdi_pi_fault(mdi_pathinfo_t *, int); 163*0Sstevel@tonic-gate int mdi_pi_offline(mdi_pathinfo_t *, int); 164*0Sstevel@tonic-gate int mdi_pi_disable(dev_info_t *, dev_info_t *, int); 165*0Sstevel@tonic-gate int mdi_pi_enable(dev_info_t *, dev_info_t *, int); 166*0Sstevel@tonic-gate 167*0Sstevel@tonic-gate /* 168*0Sstevel@tonic-gate * MPxIO-PM stuff 169*0Sstevel@tonic-gate */ 170*0Sstevel@tonic-gate typedef enum { 171*0Sstevel@tonic-gate MDI_PM_PRE_CONFIG = 0, 172*0Sstevel@tonic-gate MDI_PM_POST_CONFIG, 173*0Sstevel@tonic-gate MDI_PM_PRE_UNCONFIG, 174*0Sstevel@tonic-gate MDI_PM_POST_UNCONFIG, 175*0Sstevel@tonic-gate MDI_PM_HOLD_POWER, 176*0Sstevel@tonic-gate MDI_PM_RELE_POWER 177*0Sstevel@tonic-gate } mdi_pm_op_t; 178*0Sstevel@tonic-gate 179*0Sstevel@tonic-gate int 180*0Sstevel@tonic-gate mdi_bus_power(dev_info_t *, void *, pm_bus_power_op_t, void *, void *); 181*0Sstevel@tonic-gate 182*0Sstevel@tonic-gate int 183*0Sstevel@tonic-gate mdi_power(dev_info_t *, mdi_pm_op_t, void *, char *, int); 184*0Sstevel@tonic-gate 185*0Sstevel@tonic-gate /* 186*0Sstevel@tonic-gate * mdi_pathinfo node walker function. 187*0Sstevel@tonic-gate */ 188*0Sstevel@tonic-gate int mdi_component_is_vhci(dev_info_t *, const char **); 189*0Sstevel@tonic-gate int mdi_component_is_phci(dev_info_t *, const char **); 190*0Sstevel@tonic-gate int mdi_component_is_client(dev_info_t *, const char **); 191*0Sstevel@tonic-gate mdi_pathinfo_t *mdi_get_next_phci_path(dev_info_t *, mdi_pathinfo_t *); 192*0Sstevel@tonic-gate mdi_pathinfo_t *mdi_get_next_client_path(dev_info_t *, mdi_pathinfo_t *); 193*0Sstevel@tonic-gate 194*0Sstevel@tonic-gate /* 195*0Sstevel@tonic-gate * mdi_pathinfo node member functions 196*0Sstevel@tonic-gate */ 197*0Sstevel@tonic-gate void mdi_pi_lock(mdi_pathinfo_t *); 198*0Sstevel@tonic-gate void mdi_pi_unlock(mdi_pathinfo_t *); 199*0Sstevel@tonic-gate dev_info_t *mdi_pi_get_client(mdi_pathinfo_t *); 200*0Sstevel@tonic-gate dev_info_t *mdi_pi_get_phci(mdi_pathinfo_t *); 201*0Sstevel@tonic-gate char *mdi_pi_get_addr(mdi_pathinfo_t *); 202*0Sstevel@tonic-gate mdi_pathinfo_state_t mdi_pi_get_state(mdi_pathinfo_t *); 203*0Sstevel@tonic-gate 204*0Sstevel@tonic-gate /* 205*0Sstevel@tonic-gate * mdi_pathinfo Property handling functions 206*0Sstevel@tonic-gate */ 207*0Sstevel@tonic-gate int mdi_prop_remove(mdi_pathinfo_t *, char *); 208*0Sstevel@tonic-gate int mdi_prop_update_byte_array(mdi_pathinfo_t *, char *, uchar_t *, uint_t); 209*0Sstevel@tonic-gate int mdi_prop_update_int(mdi_pathinfo_t *, char *, int); 210*0Sstevel@tonic-gate int mdi_prop_update_int64(mdi_pathinfo_t *, char *, int64_t); 211*0Sstevel@tonic-gate int mdi_prop_update_int_array(mdi_pathinfo_t *, char *, int *, uint_t); 212*0Sstevel@tonic-gate int mdi_prop_update_string(mdi_pathinfo_t *, char *, char *); 213*0Sstevel@tonic-gate int mdi_prop_update_string_array(mdi_pathinfo_t *, char *, char **, uint_t); 214*0Sstevel@tonic-gate nvpair_t *mdi_pi_get_next_prop(mdi_pathinfo_t *, nvpair_t *); 215*0Sstevel@tonic-gate 216*0Sstevel@tonic-gate int mdi_prop_lookup_byte_array(mdi_pathinfo_t *, char *, uchar_t **, uint_t *); 217*0Sstevel@tonic-gate int mdi_prop_lookup_int(mdi_pathinfo_t *, char *, int *); 218*0Sstevel@tonic-gate int mdi_prop_lookup_int64(mdi_pathinfo_t *, char *, int64_t *); 219*0Sstevel@tonic-gate int mdi_prop_lookup_int_array(mdi_pathinfo_t *, char *, int **, uint_t *); 220*0Sstevel@tonic-gate int mdi_prop_lookup_string(mdi_pathinfo_t *, char *, char **); 221*0Sstevel@tonic-gate int mdi_prop_lookup_string_array(mdi_pathinfo_t *, char *, char ***, uint_t *); 222*0Sstevel@tonic-gate int mdi_prop_free(void *); 223*0Sstevel@tonic-gate 224*0Sstevel@tonic-gate /* 225*0Sstevel@tonic-gate * pHCI driver instance registration/unregistration 226*0Sstevel@tonic-gate * 227*0Sstevel@tonic-gate * mdi_phci_register() is called by a pHCI drivers to register itself as a 228*0Sstevel@tonic-gate * transport provider for a specific 'class' (see mdi_vhci_register() above); 229*0Sstevel@tonic-gate * it should be called from attach(9e). 230*0Sstevel@tonic-gate * 231*0Sstevel@tonic-gate * mdi_phci_unregister() is called from detach(9e) to unregister a pHCI 232*0Sstevel@tonic-gate * instance from the framework. 233*0Sstevel@tonic-gate */ 234*0Sstevel@tonic-gate int mdi_phci_register(char *, dev_info_t *, int); 235*0Sstevel@tonic-gate int mdi_phci_unregister(dev_info_t *, int); 236*0Sstevel@tonic-gate 237*0Sstevel@tonic-gate /* get set phci private data */ 238*0Sstevel@tonic-gate caddr_t mdi_pi_get_phci_private(mdi_pathinfo_t *); 239*0Sstevel@tonic-gate void mdi_pi_set_phci_private(mdi_pathinfo_t *, caddr_t); 240*0Sstevel@tonic-gate 241*0Sstevel@tonic-gate int mdi_vhci_bus_config(dev_info_t *, uint_t, ddi_bus_config_op_t, void *, 242*0Sstevel@tonic-gate dev_info_t **); 243*0Sstevel@tonic-gate 244*0Sstevel@tonic-gate #endif /* _KERNEL */ 245*0Sstevel@tonic-gate 246*0Sstevel@tonic-gate #ifdef __cplusplus 247*0Sstevel@tonic-gate } 248*0Sstevel@tonic-gate #endif 249*0Sstevel@tonic-gate 250*0Sstevel@tonic-gate #endif /* _SYS_SUNMDI_H */ 251