2
# the next line restarts using tclsh \
6
set Usage "Usage: $argv0 -t topo-file"
9
Convert Topo File into OpenSM Subnet file
10
-------------------------------------------
16
The utility reads in a topology file and generate an OpenSM
17
subnet.lst file (in local dir) to match the specified topology.
18
It 'invents' guids and lids sequentially.
20
TODO: Randomize missmatches ...
23
###########################################################################
25
# return the string representing the given port in the subnet.lst
26
proc getPortStr {port} {
28
set portFormat "{ CA%s Ports:%02x SystemGUID:%s NodeGUID:%s PortGUID:%s VenID:000002C9 DevID:%s Rev:000000A1 {%s} LID:%04x PN:%02x }"
29
set node [IBPort_p_node_get $port]
30
set sysName [IBSystem_name_get [IBNode_p_system_get $node]]
31
if {[IBNode_type_get $node] == $IB_SW_NODE} {
32
# we assume all switches are IS3
34
set desc "$sysName MT47396 Infiniscale-III Mellanox Technologies"
36
# we assume all CAs are Tavors:
38
set desc "$sysName MT23108 Infinihost-II Mellanox Technologies"
40
return [format $portFormat \
42
[IBNode_numPorts_get $node] \
43
[string range [IBNode_guid_get $node] 2 end] \
44
[string range [IBNode_guid_get $node] 2 end] \
45
[string range [IBPort_guid_get $port] 2 end] \
48
[IBPort_base_lid_get $port] \
49
[IBPort_num_get $port] \
53
# return the string of the link in subnet.lst format
54
proc getLinkStr {port1 port2} {
55
set linkFormat "%s %s PHY=%s LOG=%s SPD=%s"
56
set p1 [getPortStr $port1]
57
set p2 [getPortStr $port2]
58
set width [IBPort_width_get $port1]
59
set speed [IBPort_speed_get $port1]
60
return [format $linkFormat $p1 $p2 $width "ACT" $speed]
64
###########################################################################
70
package require getopt
72
while { [ set err [ getopt $argv "t:" opt arg ]] } {
73
if { $err < 0 } then {
78
h {puts $Help; exit 0}
81
puts "-E- Unsupported option:$opt"
90
set left_args [ lrange $argv $optind end ]
91
if {[llength $left_args]} {
92
puts "-E- extra parameter(s) used : $left_args"
97
if {[catch {set of [open subnet.lst w]} e]} {
102
set fabric [new_IBFabric ]
103
if {[IBFabric_parseTopology $fabric $topoFile]} {
104
puts "-E- Fail to parse topo:$topoFile"
108
# we track the number of allocated guids and lids
112
# go node by node and assign guids and lids,
113
foreach nodeDef [IBFabric_NodeByName_get $fabric ] {
114
set node [lindex $nodeDef 1]
116
# make sure the node has a guid and lid
117
set guid [IBNode_guid_get $node]
120
IBNode_guid_set $node [format "0x0002c900%08x" $curGuid]
124
foreach port [IBNode_Ports_get $node] {
125
# assign port base lid and guid:
126
IBPort_guid_set $port [format "0x0002c900%08x" $curGuid]
127
IBPort_base_lid_set $port $curLid
129
# non switches require new lid and new guid to each port:
130
if {[IBNode_type_get $node] != $IB_SW_NODE} {
136
# we have assigned at least one guid and lid ...
137
if {[IBNode_type_get $node] == $IB_SW_NODE} {
143
# second iteration we are ready for output
145
# go node by node and assign guids and lids,
146
foreach nodeDef [IBFabric_NodeByName_get $fabric ] {
147
set node [lindex $nodeDef 1]
149
foreach port [IBNode_Ports_get $node] {
150
set remPort [IBPort_p_remotePort_get $port]
152
# only interested in links
153
if {$remPort != ""} {
154
puts $of [getLinkStr $port $remPort]