2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 2N/A * These are routines that are used by both the bay.so topo enumerator and the 2N/A * Compare two strings. 2N/A /* remove any trailing blank spaces */ 2N/A /* stop at the first non-blank */ 2N/A * Callback for devtree walk. 2N/A * Look for SAS HBA nodes. 2N/A /* make sure it's SAS direct attached */ 2N/A /* This is a SAS HBA node */ 2N/A /* look to see if we already captured it's parent */ 2N/A /* check for 'ddi-vhci-class' */ 2N/A /* make sure it's SAS direct attached */ 2N/A /* This is a SAS HBA node */ 2N/A * Create the configuration file path/name. Attempt to create in this order: 2N/A * 1. ../<product>-<chassis-sn>,bay_labels 2N/A * 2. ../<product>,bay_labels 2N/A * 3. ../<platform>,bay_labels 2N/A /* get platform name */ 2N/A /* ../<product>-<product-sn>,bay_labels */ 2N/A /* ../<product>,bay_labels */ 2N/A /* ../<platform>,bay_labels */ 2N/A * Get integer property. 2N/A /* look for pathinfo property */ 2N/A /* look for devinfo property */ 2N/A /* property not found */ 2N/A * Get the phy from the "attached-port-pm" property which is 2N/A * stored as a bit mask (1 << phy-num) string. 2N/A * If there is no phy mask property look for 'phy-num' property which 2N/A * is the PHY (potentially deprecated at some point). SATA mpt drives 2N/A * PHY is the target value. 2N/A /* first look for (SAS) 'attached-port-pm' */ 2N/A /* look at the child devinfo node */ 2N/A /* next look for (SAS) 'phy-num' */ 2N/A /* look at the child devinfo node */ 2N/A /* must be a SATA drive, first look for 'sata-phy' */ 2N/A /* lastly for SATA drive, look for 'target' */ 2N/A * Get string property. 2N/A /* look for pathinfo property */ 2N/A /* look for devinfo property */ 2N/A /* property not found */ 2N/A * All iport devi nodes should have the 'initiator-port' property. Look for 2N/A * a matching 'attached-port' property. But that's not always the case so we 2N/A * use node1 and node2 notation. 2N/A /* look for devi 'initiator-port' (or equivalent) */ 2N/A * look for either a child devinfo or a pathinfo node that 2N/A * contains a 'attached-port' (or equivalent) property to match. 2N/A /* make sure it's not smp */ 2N/A /* make sure it's not smp */ 2N/A * For HBAs "other" than ones that support iport: 2N/A * - first check that it's not attached to an expander 2N/A * - then see if it's direct attached 2N/A * Unfortunately some HBA drivers don't differentiate between direct 2N/A * attached and expander attached storage via properties. Need to 2N/A * determine if this HBA is connected to an expander. 2N/A /* count devinfo child nodes */ 2N/A /* count devinfo children */ 2N/A /* count pathinfo nodes */ 2N/A /* count pathinfo nodes */ 2N/A /* check for 'sd' or 'disk' devinfo nodes */ 2N/A /* final check for 'sd' or 'disk' pathinfo nodes */ 2N/A * Different SAS HBA driver (children) report they're direct attached 2N/A * differently. MPxIO also determines how to decide if this is sas direct. 2N/A * For HBAs that support iport, each will contain the '*-port' properties which 2N/A * determine direct attached. 2N/A * For HBAs that don't support iport, the direct attached hba will have a 2N/A * "disk"/"sd" devinfo child or pathinfo node. 2N/A * mpt_sas/scu : iport 'initiator-port' ==> device 'attached-port' 2N/A * pmcs : iport 'attached-port' ==> device 'target-port' 2N/A /* look for child iport node */ 2N/A /* 'initiator-port' == 'attached-port' */ 2N/A /* 'attached-port' == 'target-port' */ 2N/A /* no iport; check other indicators */ 2N/A * Callback for topo walk looking for hba label by matching the devfs path 2N/A * passed in with the 'dev' property of the topo node. 2N/A /* see if we're as PCIe function node */ 2N/A /* look for dev (TOPO_IO_DEV) path in (TOPO_PGROUP_IO) property */ 2N/A /* check for matching paths */ 2N/A /* path matches, get the label */ 2N/A /* copy the label */