1#!/bin/ksh
2#
3# This file and its contents are supplied under the terms of the
4# Common Development and Distribution License ("CDDL"), version 1.0.
5# You may only use this file in accordance with the terms of version
6# 1.0 of the CDDL.
7#
8# A full copy of the text of the CDDL should have accompanied this
9# source.  A copy of the CDDL is also available via the Internet at
10# http://www.illumos.org/license/CDDL.
11#
12
13#
14# Copyright (c) 2018, Joyent, Inc.
15#
16
17#
18# Generate the topology map for an expanderless system with 24 bays. HBAs are
19# in slots 2, 4, and 6. Additionally, there are two rear-facing SATA drive
20# bays, connected to the SATA headers on the motherboard.
21#
22
23function do_sas_node
24{
25  cat <<EOF
26    <node instance='${1}'>
27    <facility name='fail' type='indicator' provider='fac_prov_mptsas' >
28      <propgroup name='facility' version='1' name-stability='Private'
29        data-stability='Private' >
30        <propval name='type' type='uint32' value='0' />
31        <propmethod name='mptsas_led_mode' version='0' propname='mode'
32          proptype='uint32' mutable='1'>
33        </propmethod>
34      </propgroup>
35    </facility>
36    <facility name='ident' type='indicator' provider='fac_prov_mptsas' >
37      <propgroup name='facility' version='1' name-stability='Private'
38        data-stability='Private' >
39        <propval name='type' type='uint32' value='1' />
40        <propmethod name='mptsas_led_mode' version='0' propname='mode'
41          proptype='uint32' mutable='1'>
42        </propmethod>
43      </propgroup>
44    </facility>
45    <facility name='ok2rm' type='indicator' provider='fac_prov_mptsas' >
46      <propgroup name='facility' version='1' name-stability='Private'
47        data-stability='Private' >
48        <propval name='type' type='uint32' value='2' />
49        <propmethod name='mptsas_led_mode' version='0' propname='mode'
50          proptype='uint32' mutable='1'>
51        </propmethod>
52      </propgroup>
53    </facility>
54      <propgroup name='protocol' version='1' name-stability='Private'
55        data-stability='Private'>
56        <propval name='label' type='string' value='${2}' />
57      </propgroup>
58      <propgroup name='binding' version='1' name-stability='Private'
59        data-stability='Private'>
60        <propval name='driver' type='string' value='mpt_sas' />
61        <propval name='devctl' type='string' value='${3}' />
62        <propval name='enclosure' type='uint32' value='${4}' />
63        <propval name='slot' type='uint32' value='${5}' />
64      </propgroup>
65    </node>
66EOF
67}
68
69function do_sata_node
70{
71	bay=$1
72	bay_inst=$2
73	#
74	# There are six SATA headers on the motherboard, which represent
75	# targets 0-5.  The two rear-facing SATA bays are connected to the two
76	# headers associated with targets 4 and 5.
77	#
78	(( target = bay + 4 ))
79	hpath="/pci@0,0/pci15d9,981@11,5"
80	tpath="/disk@${target},0"
81	devctl="/devices/pci@0,0/pci15d9,981@11,5:devctl"
82  cat <<EOF
83    <node instance='$bay_inst'>
84      <facility name='fail' type='indicator' provider='fac_prov_ahci' >
85        <propgroup name='facility' version='1' name-stability='Private'
86          data-stability='Private' >
87          <propval name='type' type='uint32' value='0' />
88          <propmethod name='ahci_led_mode' version='0' propname='mode'
89            proptype='uint32' mutable='1'>
90          </propmethod>
91        </propgroup>
92      </facility>
93      <facility name='ident' type='indicator' provider='fac_prov_ahci' >
94        <propgroup name='facility' version='1' name-stability='Private'
95          data-stability='Private' >
96          <propval name='type' type='uint32' value='1' />
97          <propmethod name='ahci_led_mode' version='0' propname='mode'
98            proptype='uint32' mutable='1'>
99          </propmethod>
100        </propgroup>
101      </facility>
102
103      <propgroup name='protocol' version='1' name-stability='Private'
104        data-stability='Private'>
105        <propval name='label' type='string' value='Rear Disk $bay' />
106      </propgroup>
107      <propgroup name='io' version='1' name-stability='Private'
108        data-stability='Private'>
109        <propval name='ap-path' type='string' value='/devices${hpath}:$target' />
110      </propgroup>
111      <propgroup name='binding' version='1' name-stability='Private'
112        data-stability='Private'>
113        <propval name='occupant-path' type='string'
114          value='$hpath$tpath' />
115        <propval name='devctl' type='string'
116          value='$devctl' />
117        <propval name='port' type='uint32' value='$target' />
118      </propgroup>
119    </node>
120EOF
121}
122
123
124cat <<EOF
125<topology name='disk' scheme='hc'>
126  <range name='bay' min='0' max='25'>
127EOF
128
129enclosure=1
130bay=0
131slot=0
132devctl0='/devices/pci@7d,0/pci8086,2030@0/pci15d9,808@0:devctl'
133while (( slot <= 7 )); do
134  do_sas_node $bay "Front Disk $bay" "$devctl0" $enclosure $slot
135  (( bay = bay + 1 ))
136  (( slot = slot + 1 ))
137done
138
139slot=0
140devctl0='/devices/pci@cd,0/pci8086,2030@0/pci15d9,808@0:devctl'
141while (( slot <= 7 )); do
142  do_sas_node $bay "Front Disk $bay" "$devctl0" $enclosure $slot
143  (( bay = bay + 1 ))
144  (( slot = slot + 1 ))
145done
146
147slot=0
148devctl0='/devices/pci@56,0/pci8086,2030@0/pci15d9,808@0:devctl'
149while (( slot <= 7 )); do
150  do_sas_node $bay "Front Disk $bay" "$devctl0" $enclosure $slot
151  (( bay = bay + 1 ))
152  (( slot = slot + 1 ))
153done
154
155do_sata_node 0 24
156do_sata_node 1 25
157
158cat <<EOF
159    <dependents grouping='children'>
160      <range name='disk' min='0' max='0'>
161        <enum-method name='disk' version='1' />
162      </range>
163    </dependents>
164   </range>
165</topology>
166EOF
167