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