Sun-Fire-X4540-hc-topology.xmlgen revision 825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77
#!/usr/local/bin/perl
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#pragma ident "%Z%%M% %I% %E% SMI"
#
use Getopt::Std;
# X4540: platform specific begin
my $sys_supported = { "name" => "Sun-Fire-X4540",
"prop_name" => "sfx4500",
"num_bays" => "48",
"bay_label" => "HD_ID_"};
# X4540: platform specific end
$IFILE = "filehandle";
$OFILE = "filehandle";
sub Usage()
{
print STDERR "Usage: xml-gen -p <platform> " .
"-i <input_xml_file> -o <output_xml_file>\n";
}
# Define properties associated with LED manipulation.
# We have three LEDs per disk: Present (PRSNT), OK-to-remove (OK2RM), and fault.
# We track the following states (absent present configured unconfigured) via
# the PRSNT/OK2RM LEDs (FAULT LED is maintained separately).
sub calc_sfx_prop
{
my $name = shift;
my $bay = shift;
my $sid = shift;
my @names = (
"+PRSNT", "-PRSNT",
"+OK2RM", "-OK2RM",
"+FAULT", "-FAULT");
my @masks = (
"amask=0x0001", "dmask=0x0001",
"amask=0x0008", "dmask=0x0008",
"amask=0x0002", "dmask=0x0002");
my @states = (
"absent>present", "present>configured",
"configured>unconfigured", "unconfigured>configured",
"unconfigured>absent", "configured>absent",
"present>absent", "absent>configured");
my @actions = (
"+PRSNT&amp;+OK2RM", "+PRSNT&amp;-OK2RM",
"+OK2RM", "-OK2RM",
"-OK2RM&amp;-PRSNT", "-OK2RM&amp;-PRSNT",
"-OK2RM&amp;-PRSNT", "-OK2RM&amp;+PRSNT");
printf OFILE "\n";
printf OFILE
" <propgroup name='%s-properties' version='1' " .
"name-stability='Private' data-stability='Private' >\n", $name;
printf OFILE
" <propval name='fru-update-action' type='string' " .
"value='ipmi:fru gid=3 hdd=%d' />\n", $bay;
for ($i = 0; $i < 6; $i++) {
printf OFILE
" <propval name='indicator-name-%d' type='string' " .
"value='%s' />\n", $i, $names[$i];
printf OFILE
" <propval name='indicator-action-%d' " .
"type='string' value='ipmi:state sid=%d %s' />\n",
$i, $sid, $masks[$i];
}
for ($i = 0; $i < 8; $i++) {
printf OFILE
" <propval name='indicator-rule-states-%d' " .
"type='string' value='%s' />\n", $i, $states[$i];
printf OFILE
" <propval name='indicator-rule-actions-%d' " .
"type='string' value='%s' />\n", $i, $actions[$i];
}
printf OFILE
" </propgroup>\n\n";
}
sub calc_nodes
{
# X4540: platform specific begin
my @pci0=(0, 0, 0, 0x3c, 0x3c, 0x3c);
my @pci1=(0x377, 0x375, 0x376, 0x377, 0x375, 0x376);
my @pci2=(0xa, 0xb, 0xf, 0xa, 0xb, 0xf);
# X4540: platform specific end
for ($bay = 0; $bay < $sys_supported->{"num_bays"}; $bay++) {
# X4540: platform specific begin
$sid = 90 + $bay;
$target = $bay % 8;
$controller = $bay / 8;
# set hba path, target path, bay path, and attachment point
$hpath = sprintf("/pci\@%x,0/pci10de,%x\@%x/pci1000,1000\@0",
$pci0[$controller], $pci1[$controller], $pci2[$controller]);
$tpath = sprintf("/sd\@%x,0", $target);
$apoint = sprintf(":scsi::dsk/c%dt%dd0",
$controller + 1, $target);
# X4540: platform specific end
printf OFILE "\n <node instance='%d'>\n\n", $bay;
printf OFILE
" <propgroup name='protocol' version='1' " .
"name-stability='Private' data-stability='Private' >\n";
printf OFILE
" <propval name='label' type='string' " .
"value='%s%d' />\n",
$sys_supported->{"bay_label"}, $bay;
printf OFILE
" </propgroup>\n";
printf OFILE
" <propgroup name='io' version='1' " .
"name-stability='Private' data-stability='Private' >\n";
printf OFILE
" <propval name='ap-path' type='string' " .
"value='/devices%s%s' />\n", $hpath, $apoint;
printf OFILE
" </propgroup>\n";
# platform specific LED support
calc_sfx_prop($sys_supported->{"prop_name"}, $bay, $sid);
printf OFILE
" <propgroup name='binding' version='1' " .
"name-stability='Private' data-stability='Private' >\n";
printf OFILE
" <propval name='occupant-path' type='string' " .
"value='%s%s' />\n", $hpath, $tpath;
printf OFILE
" </propgroup>\n";
printf OFILE "\n </node>\n\n";
}
}
$ok = getopts("p:i:o:h", \%options);
if ($options{'h'}) {
Usage();
exit (1);
}
$platform = $options{'p'};
$input_file = $options{'i'};
$output_file = $options{'o'};
if (!$platform || !$input_file || !$output_file) {
Usage();
exit (1);
}
open(IFILE, "< $input_file") || die("$input_file cannot be opened.");
open(OFILE, "> $output_file") || die("$output_file cannot be opened.");
my $in_chassis_range = 0;
while ($line = <IFILE>) {
chomp($line);
if ($line =~ /range\s+name\s?=\s?\Wchassis\W/) {
$in_chassis_range = 1;
}
print OFILE "$line\n";
if ($in_chassis_range && ($line =~ /<dependents/)) {
last;
}
}
print OFILE " <!--xml-gen internal storage-->\n";
printf OFILE " <range name='bay' min='0' max='%d'>\n",
$sys_supported->{"num_bays"}-1;
#
# Statically define locate indicator
#
print OFILE " <facility name='locate' type='indicator' ".
"provider='fac_prov_ipmi' >\n";
print OFILE " <propgroup name='facility' version='1' ".
"name-stability='Private' data-stability='Private' >\n";
print OFILE " <propval name='type' type='uint32' value='1' />\n";
print OFILE " <propmethod name='ipmi_entity' version='0' ".
"propname='entity_ref' proptype='string' >\n";
print OFILE " <argval name='format' type='string' ".
"value='hdd%d.ok2rm.led' />\n";
print OFILE " <argval name='offset' type='uint32' ".
"value='0' />\n";
print OFILE " <argval name='nparams' type='uint32' ".
"value='1' />\n";
print OFILE " </propmethod>\n";
print OFILE " <propmethod name='thumper_locate_mode' ".
"version='0'\n";
print OFILE " propname='mode' proptype='uint32' ".
"mutable='1' >\n";
print OFILE " </propmethod>\n";
print OFILE " </propgroup>\n";
print OFILE " </facility>\n";
#
# Statically define ok2rm indicator
#
print OFILE " <facility name='ok2rm' type='indicator' ".
"provider='fac_prov_ipmi' >\n";
print OFILE " <propgroup name='facility' version='1' ".
"name-stability='Private' data-stability='Private' >\n";
print OFILE " <propval name='type' type='uint32' value='2' />\n";
print OFILE " <propmethod name='ipmi_entity' version='0' ".
"propname='entity_ref' proptype='string' >\n";
print OFILE " <argval name='format' type='string' ".
"value='hdd%d.state' />\n";
print OFILE " <argval name='offset' type='uint32' ".
"value='0' />\n";
print OFILE " <argval name='nparams' type='uint32' ".
"value='1' />\n";
print OFILE " </propmethod>\n";
print OFILE " <propmethod name='thumper_indicator_mode' ".
"version='0'\n";
print OFILE " propname='mode' proptype='uint32' ".
"mutable='1' >\n";
print OFILE " </propmethod>\n";
print OFILE " </propgroup>\n";
print OFILE " </facility>\n";
#
# Statically define service indicator
#
print OFILE " <facility name='service' type='indicator' ".
"provider='fac_prov_ipmi' >\n";
print OFILE " <propgroup name='facility' version='1' ".
"name-stability='Private' data-stability='Private' >\n";
print OFILE " <propval name='type' type='uint32' value='0' />\n";
print OFILE " <propmethod name='ipmi_entity' version='0' ".
"propname='entity_ref' proptype='string' >\n";
print OFILE " <argval name='format' type='string' ".
"value='hdd%d.state' />\n";
print OFILE " <argval name='offset' type='uint32' ".
"value='0' />\n";
print OFILE " <argval name='nparams' type='uint32' ".
"value='1' />\n";
print OFILE " </propmethod>\n";
print OFILE " <propmethod name='thumper_indicator_mode' ".
"version='0' propname='mode' proptype='uint32' mutable='1' >\n";
print OFILE " </propmethod>\n";
print OFILE " </propgroup>\n";
print OFILE " </facility>\n";
#
# Statically define present indicator
#
print OFILE " <facility name='present' type='indicator' ".
"provider='fac_prov_ipmi' >\n";
print OFILE " <propgroup name='facility' version='1' ".
"name-stability='Private' data-stability='Private' >\n";
print OFILE " <propval name='type' type='uint32' value='3' />\n";
print OFILE " <propmethod name='ipmi_entity' version='0' ".
"propname='entity_ref' proptype='string' >\n";
print OFILE " <argval name='format' type='string' ".
"value='hdd%d.state' />\n";
print OFILE " <argval name='offset' type='uint32' ".
"value='0' />\n";
print OFILE " <argval name='nparams' type='uint32' ".
"value='1' />\n";
print OFILE " </propmethod>\n";
print OFILE " <propmethod name='thumper_indicator_mode' ".
"version='0' propname='mode' proptype='uint32' mutable='1' >\n";
print OFILE " </propmethod>\n";
print OFILE " </propgroup>\n";
print OFILE " </facility>\n";
calc_nodes(0);
printf OFILE " <dependents grouping='children'>\n";
printf OFILE " <range name='disk' min='0' max='0'>\n";
printf OFILE " <enum-method name='disk' version='1' />\n";
printf OFILE " </range>\n";
printf OFILE " </dependents>\n\n";
printf OFILE " </range>\n";
while ($line = <IFILE>) {
print OFILE $line;
}
close OFILE;
close IFILE;