17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _SYS_SUNMDI_H 287c478bd9Sstevel@tonic-gate #define _SYS_SUNMDI_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate /* 337c478bd9Sstevel@tonic-gate * Multiplexed I/O global include 347c478bd9Sstevel@tonic-gate */ 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #include <sys/note.h> 377c478bd9Sstevel@tonic-gate #include <sys/esunddi.h> 387c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 397c478bd9Sstevel@tonic-gate #include <sys/ddipropdefs.h> 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #ifdef __cplusplus 427c478bd9Sstevel@tonic-gate extern "C" { 437c478bd9Sstevel@tonic-gate #endif 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* 467c478bd9Sstevel@tonic-gate * Most MDI functions return success or failure 477c478bd9Sstevel@tonic-gate */ 487c478bd9Sstevel@tonic-gate #define MDI_SUCCESS 0 /* Call Success */ 497c478bd9Sstevel@tonic-gate #define MDI_FAILURE -1 /* Unspecified Error */ 507c478bd9Sstevel@tonic-gate #define MDI_NOMEM -2 /* No resources available */ 517c478bd9Sstevel@tonic-gate #define MDI_ACCEPT -3 /* Request accepted */ 527c478bd9Sstevel@tonic-gate #define MDI_BUSY -4 /* Busy */ 537c478bd9Sstevel@tonic-gate #define MDI_NOPATH -5 /* No more paths are available */ 547c478bd9Sstevel@tonic-gate #define MDI_EINVAL -6 /* Invalid parameter */ 557c478bd9Sstevel@tonic-gate #define MDI_NOT_SUPPORTED -8 /* Device not supported */ 567c478bd9Sstevel@tonic-gate #define MDI_DEVI_ONLINING -9 /* Devi is onlining */ 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* 597c478bd9Sstevel@tonic-gate * handle to mdi_pathinfo node 607c478bd9Sstevel@tonic-gate */ 617c478bd9Sstevel@tonic-gate typedef struct x_mdi_pathinfo *mdi_pathinfo_t; 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate /* 647c478bd9Sstevel@tonic-gate * Path info node state definitions 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate typedef enum { 677c478bd9Sstevel@tonic-gate MDI_PATHINFO_STATE_INIT, 687c478bd9Sstevel@tonic-gate MDI_PATHINFO_STATE_ONLINE, 697c478bd9Sstevel@tonic-gate MDI_PATHINFO_STATE_STANDBY, 707c478bd9Sstevel@tonic-gate MDI_PATHINFO_STATE_FAULT, 717c478bd9Sstevel@tonic-gate MDI_PATHINFO_STATE_OFFLINE 727c478bd9Sstevel@tonic-gate } mdi_pathinfo_state_t; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* 757c478bd9Sstevel@tonic-gate * MDI vHCI class definitions 767c478bd9Sstevel@tonic-gate */ 777c478bd9Sstevel@tonic-gate #define MDI_HCI_CLASS_SCSI "scsi_vhci" 787c478bd9Sstevel@tonic-gate #define MDI_HCI_CLASS_IB "ib" 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate #ifdef _KERNEL 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* 837c478bd9Sstevel@tonic-gate * mpxio component definitions: Every registered component of the 847c478bd9Sstevel@tonic-gate * mpxio system has a "mpxio-component" property attached to it. 857c478bd9Sstevel@tonic-gate * Identify its function 867c478bd9Sstevel@tonic-gate */ 877c478bd9Sstevel@tonic-gate #define MDI_COMPONENT_NONE 0 887c478bd9Sstevel@tonic-gate #define MDI_COMPONENT_VHCI 0x1 897c478bd9Sstevel@tonic-gate #define MDI_COMPONENT_PHCI 0x2 907c478bd9Sstevel@tonic-gate #define MDI_COMPONENT_CLIENT 0x4 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* 937c478bd9Sstevel@tonic-gate * mdi_pathinfo node state utility definitions 947c478bd9Sstevel@tonic-gate */ 957c478bd9Sstevel@tonic-gate #define MDI_PATHINFO_STATE_TRANSIENT 0x00010000 967c478bd9Sstevel@tonic-gate #define MDI_PATHINFO_STATE_USER_DISABLE 0x00100000 977c478bd9Sstevel@tonic-gate #define MDI_PATHINFO_STATE_DRV_DISABLE 0x00200000 987c478bd9Sstevel@tonic-gate #define MDI_PATHINFO_STATE_DRV_DISABLE_TRANSIENT 0x00400000 997c478bd9Sstevel@tonic-gate #define MDI_PATHINFO_STATE_MASK 0x0000FFFF 1007c478bd9Sstevel@tonic-gate #define MDI_PATHINFO_EXT_STATE_MASK 0xFFF00000 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate #define USER_DISABLE 1 1037c478bd9Sstevel@tonic-gate #define DRIVER_DISABLE 2 1047c478bd9Sstevel@tonic-gate #define DRIVER_DISABLE_TRANSIENT 3 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* 1087c478bd9Sstevel@tonic-gate * Most MDI functions return success or failure 1097c478bd9Sstevel@tonic-gate */ 1107c478bd9Sstevel@tonic-gate #define MDI_SUCCESS 0 /* Call Success */ 1117c478bd9Sstevel@tonic-gate #define MDI_FAILURE -1 /* Unspecified Error */ 1127c478bd9Sstevel@tonic-gate #define MDI_NOMEM -2 /* No resources available */ 1137c478bd9Sstevel@tonic-gate #define MDI_ACCEPT -3 /* Request accepted */ 1147c478bd9Sstevel@tonic-gate #define MDI_BUSY -4 /* Busy */ 1157c478bd9Sstevel@tonic-gate #define MDI_NOPATH -5 /* No more paths are available */ 1167c478bd9Sstevel@tonic-gate #define MDI_EINVAL -6 /* Invalid parameter */ 1177c478bd9Sstevel@tonic-gate #define MDI_NOT_SUPPORTED -8 /* Device not supported */ 1187c478bd9Sstevel@tonic-gate #define MDI_DEVI_ONLINING -9 /* Devi is onlining */ 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate /* 1217c478bd9Sstevel@tonic-gate * MDI operation vector structure definition 1227c478bd9Sstevel@tonic-gate */ 1237c478bd9Sstevel@tonic-gate #define MDI_OPS_REV_1 1 1247c478bd9Sstevel@tonic-gate #define MDI_OPS_REV MDI_OPS_REV_1 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate #define MDI_VHCI(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_VHCI) 1277c478bd9Sstevel@tonic-gate #define MDI_PHCI(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_PHCI) 1287c478bd9Sstevel@tonic-gate #define MDI_CLIENT(dip) (DEVI(dip)->devi_mdi_component & MDI_COMPONENT_CLIENT) 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate /* 1317c478bd9Sstevel@tonic-gate * MDI device hotplug notification 1327c478bd9Sstevel@tonic-gate */ 1337c478bd9Sstevel@tonic-gate int mdi_devi_online(dev_info_t *, uint_t); 1347c478bd9Sstevel@tonic-gate int mdi_devi_offline(dev_info_t *, uint_t); 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate /* 1377c478bd9Sstevel@tonic-gate * MDI component device instance attach/detach notification 1387c478bd9Sstevel@tonic-gate */ 1397c478bd9Sstevel@tonic-gate int mdi_pre_attach(dev_info_t *, ddi_attach_cmd_t); 1407c478bd9Sstevel@tonic-gate void mdi_post_attach(dev_info_t *, ddi_attach_cmd_t, int); 1417c478bd9Sstevel@tonic-gate int mdi_pre_detach(dev_info_t *, ddi_detach_cmd_t); 1427c478bd9Sstevel@tonic-gate void mdi_post_detach(dev_info_t *, ddi_detach_cmd_t, int); 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate int mdi_devi_config_one(dev_info_t *, char *, dev_info_t **, int, clock_t); 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate /* 1477c478bd9Sstevel@tonic-gate * mdi_pathinfo management functions. 1487c478bd9Sstevel@tonic-gate * 1497c478bd9Sstevel@tonic-gate * Find, allocate and Free functions. 1507c478bd9Sstevel@tonic-gate */ 1517c478bd9Sstevel@tonic-gate mdi_pathinfo_t *mdi_pi_find(dev_info_t *, char *, char *); 1527c478bd9Sstevel@tonic-gate int mdi_pi_alloc(dev_info_t *, char *, char *, char *, int, mdi_pathinfo_t **); 1537c478bd9Sstevel@tonic-gate int mdi_pi_alloc_compatible(dev_info_t *, char *, char *, char *, 1547c478bd9Sstevel@tonic-gate char **, int, int, mdi_pathinfo_t **); 1557c478bd9Sstevel@tonic-gate int mdi_pi_free(mdi_pathinfo_t *, int); 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate /* 1587c478bd9Sstevel@tonic-gate * mdi_pathinfo node state change functions. 1597c478bd9Sstevel@tonic-gate */ 1607c478bd9Sstevel@tonic-gate int mdi_pi_online(mdi_pathinfo_t *, int); 1617c478bd9Sstevel@tonic-gate int mdi_pi_standby(mdi_pathinfo_t *, int); 1627c478bd9Sstevel@tonic-gate int mdi_pi_fault(mdi_pathinfo_t *, int); 1637c478bd9Sstevel@tonic-gate int mdi_pi_offline(mdi_pathinfo_t *, int); 1647c478bd9Sstevel@tonic-gate int mdi_pi_disable(dev_info_t *, dev_info_t *, int); 1657c478bd9Sstevel@tonic-gate int mdi_pi_enable(dev_info_t *, dev_info_t *, int); 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate /* 1687c478bd9Sstevel@tonic-gate * MPxIO-PM stuff 1697c478bd9Sstevel@tonic-gate */ 1707c478bd9Sstevel@tonic-gate typedef enum { 1717c478bd9Sstevel@tonic-gate MDI_PM_PRE_CONFIG = 0, 1727c478bd9Sstevel@tonic-gate MDI_PM_POST_CONFIG, 1737c478bd9Sstevel@tonic-gate MDI_PM_PRE_UNCONFIG, 1747c478bd9Sstevel@tonic-gate MDI_PM_POST_UNCONFIG, 1757c478bd9Sstevel@tonic-gate MDI_PM_HOLD_POWER, 1767c478bd9Sstevel@tonic-gate MDI_PM_RELE_POWER 1777c478bd9Sstevel@tonic-gate } mdi_pm_op_t; 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate int 1807c478bd9Sstevel@tonic-gate mdi_bus_power(dev_info_t *, void *, pm_bus_power_op_t, void *, void *); 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate int 1837c478bd9Sstevel@tonic-gate mdi_power(dev_info_t *, mdi_pm_op_t, void *, char *, int); 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate /* 1867c478bd9Sstevel@tonic-gate * mdi_pathinfo node walker function. 1877c478bd9Sstevel@tonic-gate */ 1887c478bd9Sstevel@tonic-gate int mdi_component_is_vhci(dev_info_t *, const char **); 1897c478bd9Sstevel@tonic-gate int mdi_component_is_phci(dev_info_t *, const char **); 1907c478bd9Sstevel@tonic-gate int mdi_component_is_client(dev_info_t *, const char **); 1917c478bd9Sstevel@tonic-gate mdi_pathinfo_t *mdi_get_next_phci_path(dev_info_t *, mdi_pathinfo_t *); 1927c478bd9Sstevel@tonic-gate mdi_pathinfo_t *mdi_get_next_client_path(dev_info_t *, mdi_pathinfo_t *); 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate /* 1957c478bd9Sstevel@tonic-gate * mdi_pathinfo node member functions 1967c478bd9Sstevel@tonic-gate */ 1977c478bd9Sstevel@tonic-gate void mdi_pi_lock(mdi_pathinfo_t *); 1987c478bd9Sstevel@tonic-gate void mdi_pi_unlock(mdi_pathinfo_t *); 1997c478bd9Sstevel@tonic-gate dev_info_t *mdi_pi_get_client(mdi_pathinfo_t *); 2007c478bd9Sstevel@tonic-gate dev_info_t *mdi_pi_get_phci(mdi_pathinfo_t *); 2017c478bd9Sstevel@tonic-gate char *mdi_pi_get_addr(mdi_pathinfo_t *); 2027c478bd9Sstevel@tonic-gate mdi_pathinfo_state_t mdi_pi_get_state(mdi_pathinfo_t *); 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate /* 2057c478bd9Sstevel@tonic-gate * mdi_pathinfo Property handling functions 2067c478bd9Sstevel@tonic-gate */ 2077c478bd9Sstevel@tonic-gate int mdi_prop_remove(mdi_pathinfo_t *, char *); 2087c478bd9Sstevel@tonic-gate int mdi_prop_update_byte_array(mdi_pathinfo_t *, char *, uchar_t *, uint_t); 2097c478bd9Sstevel@tonic-gate int mdi_prop_update_int(mdi_pathinfo_t *, char *, int); 2107c478bd9Sstevel@tonic-gate int mdi_prop_update_int64(mdi_pathinfo_t *, char *, int64_t); 2117c478bd9Sstevel@tonic-gate int mdi_prop_update_int_array(mdi_pathinfo_t *, char *, int *, uint_t); 2127c478bd9Sstevel@tonic-gate int mdi_prop_update_string(mdi_pathinfo_t *, char *, char *); 2137c478bd9Sstevel@tonic-gate int mdi_prop_update_string_array(mdi_pathinfo_t *, char *, char **, uint_t); 2147c478bd9Sstevel@tonic-gate nvpair_t *mdi_pi_get_next_prop(mdi_pathinfo_t *, nvpair_t *); 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate int mdi_prop_lookup_byte_array(mdi_pathinfo_t *, char *, uchar_t **, uint_t *); 2177c478bd9Sstevel@tonic-gate int mdi_prop_lookup_int(mdi_pathinfo_t *, char *, int *); 2187c478bd9Sstevel@tonic-gate int mdi_prop_lookup_int64(mdi_pathinfo_t *, char *, int64_t *); 2197c478bd9Sstevel@tonic-gate int mdi_prop_lookup_int_array(mdi_pathinfo_t *, char *, int **, uint_t *); 2207c478bd9Sstevel@tonic-gate int mdi_prop_lookup_string(mdi_pathinfo_t *, char *, char **); 2217c478bd9Sstevel@tonic-gate int mdi_prop_lookup_string_array(mdi_pathinfo_t *, char *, char ***, uint_t *); 2227c478bd9Sstevel@tonic-gate int mdi_prop_free(void *); 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate /* 2257c478bd9Sstevel@tonic-gate * pHCI driver instance registration/unregistration 2267c478bd9Sstevel@tonic-gate * 2277c478bd9Sstevel@tonic-gate * mdi_phci_register() is called by a pHCI drivers to register itself as a 2287c478bd9Sstevel@tonic-gate * transport provider for a specific 'class' (see mdi_vhci_register() above); 2297c478bd9Sstevel@tonic-gate * it should be called from attach(9e). 2307c478bd9Sstevel@tonic-gate * 2317c478bd9Sstevel@tonic-gate * mdi_phci_unregister() is called from detach(9e) to unregister a pHCI 2327c478bd9Sstevel@tonic-gate * instance from the framework. 2337c478bd9Sstevel@tonic-gate */ 2347c478bd9Sstevel@tonic-gate int mdi_phci_register(char *, dev_info_t *, int); 2357c478bd9Sstevel@tonic-gate int mdi_phci_unregister(dev_info_t *, int); 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate /* get set phci private data */ 2387c478bd9Sstevel@tonic-gate caddr_t mdi_pi_get_phci_private(mdi_pathinfo_t *); 2397c478bd9Sstevel@tonic-gate void mdi_pi_set_phci_private(mdi_pathinfo_t *, caddr_t); 2407c478bd9Sstevel@tonic-gate 2417c478bd9Sstevel@tonic-gate int mdi_vhci_bus_config(dev_info_t *, uint_t, ddi_bus_config_op_t, void *, 242*3c34adc5Sramat dev_info_t **, char *); 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 2457c478bd9Sstevel@tonic-gate 2467c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2477c478bd9Sstevel@tonic-gate } 2487c478bd9Sstevel@tonic-gate #endif 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate #endif /* _SYS_SUNMDI_H */ 251