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, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A * Routines used by the bay,so topo enumerator. 2N/A * Create "target-port-l0ids" property. 2N/A char *f =
"create_l0ids";
2N/A /* look at the child */ 2N/A "%s: failed to get \'target-port\'\n", f);
2N/A * Return the minor attachment point node. 2N/A * return the child node which matches the phy. 2N/A * Create the attachment point path. 2N/A /* ap_path = "/devices" + minor node path */ 2N/A * Return the generated generic slot label. 2N/A * The caller is responsible to free memory. 2N/A char *f =
"generic_label";
2N/A /* grab the topo pci label */ 2N/A /* get the generic name from the class code */ 2N/A /* no generic name, use node name */ 2N/A /* create the label */ 2N/A * Return TRUE if chassis label is an 'internal' chassis. 2N/A * Generate the occupant path. 2N/A /* 'target-port' prop */ 2N/A /* leading 'w' is not always consistent */ 2N/A /* oc_path = devfs path + "/disk@w' + 'target-port' + "," + 'lun' */ 2N/A * Get the devid property from the disk node matching the path passed in. 2N/A char *f =
"get_devid";
2N/A /* find the child matching the phy and grab the devid prop */ 2N/A char *f =
"get_generic";
2N/A /* look for boot flag */ 2N/A /* not set of not true */ 2N/A * Get the total number of possible direct attached PHYs (bays). It's either 2N/A * the 'num-phys-hba' or 'num-phys' integer property of the HBA di_node. 2N/A /* first look for 'num-phys' */ 2N/A /* next look for 'num-phys-hba' */ 2N/A * Get the chassis name (held in FM_FMRI_AUTH_V1_CHASSIS_NM) and chassis S/N 2N/A * (FM_FMRI_AUTH_V1_CHASSIS_SN) from the authority fmri. 2N/A /* everyone has either a chassis or a mother(board) */ 2N/A "No chassis or motherboard node.\n");
2N/A /* get auth list from topo node */ 2N/A /* get chassis name */ 2N/A /* chassis serial number */ 2N/A * Callback for mod walk routine; calls the shared routine to find the 2N/A * Get the pci slot label. 2N/A * The caller is responsible for freeing memory. 2N/A char *f =
"get_pcilabel";
2N/A "%s: topo_walk_init() failed for (%s)\n",
2N/A "%s: topo_walk_step() failed for (%s)\n",
2N/A * Get the slot id by parsing the pci label for the slot, or return 0 if 2N/A * it's an on-board device (label == "MB"). 2N/A /* on-board - slot id is 0 by pcie spec */ 2N/A /* extract the slot id from the label */ 2N/A /* convert to an int */ 2N/A /* 'PCIe 0' is really slot id 1 */ 2N/A * Parse a line of the bay config file to extract data. 2N/A /* skip lines starting with '#' */ 2N/A /* parse the line e.g. */ 2N/A /* Sans Digital TR4X:pmcs:0:JBOD 0:812BDA443-184:5:BAY2 */ 2N/A /* check the hba driver name and instance */ 2N/A /* not what we're looking for */ 2N/A /* cut off the last newline */ 2N/A "chassis label(%s) chassis S/N(%s) phy(%d) bay label(%s)\n",
2N/A /* fill in the bay struct */ 2N/A * Read the config file and fill in the bays array. Return the number of 2N/A * structs (bays) filled in. 2N/A /* open the config file and read how many bays for this hba */ 2N/A "read_config: failed to open config file (%s)\n", f);
2N/A * config file format: 2N/A * "product:driver name:instance:product name:product s/n:PHY:label" 2N/A * "%s:%s:%d:%s:%d:%s" 2N/A * Sort the hba_nodes[] array relative to their slot id. If the slot id is 2N/A * not obtainable; sort in the order seen. 2N/A * Return: 0 - successfully sorted 2N/A * -1 - failed to sort (usually due to lack of PCIe slotid) 2N/A /* fill in the sorting struct */ 2N/A * Get the pci slot id from the HBA pcibus topo label. 2N/A * The pcibus enum has already done all the twizzle 2N/A /* get ya sort on */ 2N/A /* refill hba_nodes now in relative order */