1843d17d4SRob Johnston#!/bin/ksh
2843d17d4SRob Johnston#
3843d17d4SRob Johnston# This file and its contents are supplied under the terms of the
4843d17d4SRob Johnston# Common Development and Distribution License ("CDDL"), version 1.0.
5843d17d4SRob Johnston# You may only use this file in accordance with the terms of version
6843d17d4SRob Johnston# 1.0 of the CDDL.
7843d17d4SRob Johnston#
8843d17d4SRob Johnston# A full copy of the text of the CDDL should have accompanied this
9843d17d4SRob Johnston# source.  A copy of the CDDL is also available via the Internet at
10843d17d4SRob Johnston# http://www.illumos.org/license/CDDL.
11843d17d4SRob Johnston#
12843d17d4SRob Johnston
13843d17d4SRob Johnston#
14843d17d4SRob Johnston# Copyright (c) 2018, Joyent, Inc.
15843d17d4SRob Johnston#
16843d17d4SRob Johnston
17843d17d4SRob Johnston#
18843d17d4SRob Johnston# Generate the topology map for an expanderless system with 24 bays. HBAs are
19843d17d4SRob Johnston# in slots 2, 4, and 6. Additionally, there are two rear-facing SATA drive
20843d17d4SRob Johnston# bays, connected to the SATA headers on the motherboard.
21843d17d4SRob Johnston#
22843d17d4SRob Johnston
23843d17d4SRob Johnstonfunction do_sas_node
24843d17d4SRob Johnston{
25843d17d4SRob Johnston  cat <<EOF
26843d17d4SRob Johnston    <node instance='${1}'>
27843d17d4SRob Johnston    <facility name='fail' type='indicator' provider='fac_prov_mptsas' >
28843d17d4SRob Johnston      <propgroup name='facility' version='1' name-stability='Private'
29843d17d4SRob Johnston        data-stability='Private' >
30843d17d4SRob Johnston        <propval name='type' type='uint32' value='0' />
31843d17d4SRob Johnston        <propmethod name='mptsas_led_mode' version='0' propname='mode'
32843d17d4SRob Johnston          proptype='uint32' mutable='1'>
33843d17d4SRob Johnston        </propmethod>
34843d17d4SRob Johnston      </propgroup>
35843d17d4SRob Johnston    </facility>
36843d17d4SRob Johnston    <facility name='ident' type='indicator' provider='fac_prov_mptsas' >
37843d17d4SRob Johnston      <propgroup name='facility' version='1' name-stability='Private'
38843d17d4SRob Johnston        data-stability='Private' >
39843d17d4SRob Johnston        <propval name='type' type='uint32' value='1' />
40843d17d4SRob Johnston        <propmethod name='mptsas_led_mode' version='0' propname='mode'
41843d17d4SRob Johnston          proptype='uint32' mutable='1'>
42843d17d4SRob Johnston        </propmethod>
43843d17d4SRob Johnston      </propgroup>
44843d17d4SRob Johnston    </facility>
45843d17d4SRob Johnston    <facility name='ok2rm' type='indicator' provider='fac_prov_mptsas' >
46843d17d4SRob Johnston      <propgroup name='facility' version='1' name-stability='Private'
47843d17d4SRob Johnston        data-stability='Private' >
48843d17d4SRob Johnston        <propval name='type' type='uint32' value='2' />
49843d17d4SRob Johnston        <propmethod name='mptsas_led_mode' version='0' propname='mode'
50843d17d4SRob Johnston          proptype='uint32' mutable='1'>
51843d17d4SRob Johnston        </propmethod>
52843d17d4SRob Johnston      </propgroup>
53843d17d4SRob Johnston    </facility>
54843d17d4SRob Johnston      <propgroup name='protocol' version='1' name-stability='Private'
55843d17d4SRob Johnston        data-stability='Private'>
56843d17d4SRob Johnston        <propval name='label' type='string' value='${2}' />
57843d17d4SRob Johnston      </propgroup>
58843d17d4SRob Johnston      <propgroup name='binding' version='1' name-stability='Private'
59843d17d4SRob Johnston        data-stability='Private'>
60843d17d4SRob Johnston        <propval name='driver' type='string' value='mpt_sas' />
61843d17d4SRob Johnston        <propval name='devctl' type='string' value='${3}' />
62843d17d4SRob Johnston        <propval name='enclosure' type='uint32' value='${4}' />
63843d17d4SRob Johnston        <propval name='slot' type='uint32' value='${5}' />
64843d17d4SRob Johnston      </propgroup>
65843d17d4SRob Johnston    </node>
66843d17d4SRob JohnstonEOF
67843d17d4SRob Johnston}
68843d17d4SRob Johnston
69843d17d4SRob Johnstonfunction do_sata_node
70843d17d4SRob Johnston{
71843d17d4SRob Johnston	bay=$1
72843d17d4SRob Johnston	bay_inst=$2
73843d17d4SRob Johnston	#
74843d17d4SRob Johnston	# There are six SATA headers on the motherboard, which represent
75843d17d4SRob Johnston	# targets 0-5.  The two rear-facing SATA bays are connected to the two
76843d17d4SRob Johnston	# headers associated with targets 4 and 5.
77843d17d4SRob Johnston	#
78843d17d4SRob Johnston	(( target = bay + 4 ))
79843d17d4SRob Johnston	hpath="/pci@0,0/pci15d9,981@11,5"
80843d17d4SRob Johnston	tpath="/disk@${target},0"
81*e2f631f9SJordan Paige Hendricks	devctl="/devices/pci@0,0/pci15d9,981@11,5:devctl"
82843d17d4SRob Johnston  cat <<EOF
83843d17d4SRob Johnston    <node instance='$bay_inst'>
84*e2f631f9SJordan Paige Hendricks      <facility name='fail' type='indicator' provider='fac_prov_ahci' >
85*e2f631f9SJordan Paige Hendricks        <propgroup name='facility' version='1' name-stability='Private'
86*e2f631f9SJordan Paige Hendricks          data-stability='Private' >
87*e2f631f9SJordan Paige Hendricks          <propval name='type' type='uint32' value='0' />
88*e2f631f9SJordan Paige Hendricks          <propmethod name='ahci_led_mode' version='0' propname='mode'
89*e2f631f9SJordan Paige Hendricks            proptype='uint32' mutable='1'>
90*e2f631f9SJordan Paige Hendricks          </propmethod>
91*e2f631f9SJordan Paige Hendricks        </propgroup>
92*e2f631f9SJordan Paige Hendricks      </facility>
93*e2f631f9SJordan Paige Hendricks      <facility name='ident' type='indicator' provider='fac_prov_ahci' >
94*e2f631f9SJordan Paige Hendricks        <propgroup name='facility' version='1' name-stability='Private'
95*e2f631f9SJordan Paige Hendricks          data-stability='Private' >
96*e2f631f9SJordan Paige Hendricks          <propval name='type' type='uint32' value='1' />
97*e2f631f9SJordan Paige Hendricks          <propmethod name='ahci_led_mode' version='0' propname='mode'
98*e2f631f9SJordan Paige Hendricks            proptype='uint32' mutable='1'>
99*e2f631f9SJordan Paige Hendricks          </propmethod>
100*e2f631f9SJordan Paige Hendricks        </propgroup>
101*e2f631f9SJordan Paige Hendricks      </facility>
102*e2f631f9SJordan Paige Hendricks
103843d17d4SRob Johnston      <propgroup name='protocol' version='1' name-stability='Private'
104843d17d4SRob Johnston        data-stability='Private'>
105843d17d4SRob Johnston        <propval name='label' type='string' value='Rear Disk $bay' />
106843d17d4SRob Johnston      </propgroup>
107843d17d4SRob Johnston      <propgroup name='io' version='1' name-stability='Private'
108843d17d4SRob Johnston        data-stability='Private'>
109843d17d4SRob Johnston        <propval name='ap-path' type='string' value='/devices${hpath}:$target' />
110843d17d4SRob Johnston      </propgroup>
111843d17d4SRob Johnston      <propgroup name='binding' version='1' name-stability='Private'
112843d17d4SRob Johnston        data-stability='Private'>
113843d17d4SRob Johnston        <propval name='occupant-path' type='string'
114843d17d4SRob Johnston          value='$hpath$tpath' />
115*e2f631f9SJordan Paige Hendricks        <propval name='devctl' type='string'
116*e2f631f9SJordan Paige Hendricks          value='$devctl' />
117*e2f631f9SJordan Paige Hendricks        <propval name='port' type='uint32' value='$target' />
118843d17d4SRob Johnston      </propgroup>
119843d17d4SRob Johnston    </node>
120843d17d4SRob JohnstonEOF
121843d17d4SRob Johnston}
122843d17d4SRob Johnston
123843d17d4SRob Johnston
124843d17d4SRob Johnstoncat <<EOF
125843d17d4SRob Johnston<topology name='disk' scheme='hc'>
126843d17d4SRob Johnston  <range name='bay' min='0' max='25'>
127843d17d4SRob JohnstonEOF
128843d17d4SRob Johnston
129843d17d4SRob Johnstonenclosure=1
130843d17d4SRob Johnstonbay=0
131843d17d4SRob Johnstonslot=0
132843d17d4SRob Johnstondevctl0='/devices/pci@7d,0/pci8086,2030@0/pci15d9,808@0:devctl'
133843d17d4SRob Johnstonwhile (( slot <= 7 )); do
134843d17d4SRob Johnston  do_sas_node $bay "Front Disk $bay" "$devctl0" $enclosure $slot
135843d17d4SRob Johnston  (( bay = bay + 1 ))
136843d17d4SRob Johnston  (( slot = slot + 1 ))
137843d17d4SRob Johnstondone
138843d17d4SRob Johnston
139843d17d4SRob Johnstonslot=0
140843d17d4SRob Johnstondevctl0='/devices/pci@cd,0/pci8086,2030@0/pci15d9,808@0:devctl'
141843d17d4SRob Johnstonwhile (( slot <= 7 )); do
142843d17d4SRob Johnston  do_sas_node $bay "Front Disk $bay" "$devctl0" $enclosure $slot
143843d17d4SRob Johnston  (( bay = bay + 1 ))
144843d17d4SRob Johnston  (( slot = slot + 1 ))
145843d17d4SRob Johnstondone
146843d17d4SRob Johnston
147843d17d4SRob Johnstonslot=0
148843d17d4SRob Johnstondevctl0='/devices/pci@56,0/pci8086,2030@0/pci15d9,808@0:devctl'
149843d17d4SRob Johnstonwhile (( slot <= 7 )); do
150843d17d4SRob Johnston  do_sas_node $bay "Front Disk $bay" "$devctl0" $enclosure $slot
151843d17d4SRob Johnston  (( bay = bay + 1 ))
152843d17d4SRob Johnston  (( slot = slot + 1 ))
153843d17d4SRob Johnstondone
154843d17d4SRob Johnston
155843d17d4SRob Johnstondo_sata_node 0 24
156843d17d4SRob Johnstondo_sata_node 1 25
157843d17d4SRob Johnston
158843d17d4SRob Johnstoncat <<EOF
159843d17d4SRob Johnston    <dependents grouping='children'>
160843d17d4SRob Johnston      <range name='disk' min='0' max='0'>
161843d17d4SRob Johnston        <enum-method name='disk' version='1' />
162843d17d4SRob Johnston      </range>
163843d17d4SRob Johnston    </dependents>
164843d17d4SRob Johnston   </range>
165843d17d4SRob Johnston</topology>
166843d17d4SRob JohnstonEOF
167