File: mkSimNodeDir

package info (click to toggle)
ibutils 1.2-OFED-1.4.2-1.3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 23,616 kB
  • sloc: cpp: 153,349; ansic: 77,237; tcl: 13,447; sh: 11,852; makefile: 494; yacc: 333; lex: 169; awk: 53
file content (129 lines) | stat: -rwxr-xr-x 2,966 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash

usage="$0 -n node-name [-g sim-guids-file]"
function help () {
cat <<EOF
$usage

This utility build the /proc like file tree for the given node
based on the guids dump file produced by the simulator.

Options:
-n node-name = the node name to create the files for.
-g sim-guids-file = dump file to use. default is ./ibmgtsim.guids.txt

LIMITATIONS:
Only HCAs are supported.
Single HCA per guid.

EOF
exit 0
}

guids_file=ibmgtsim.guids.txt

while getopts ":n:gh" options; do
  case $options in
    n ) node_name=$OPTARG;;
    g ) guids_file=$OPTARG;;
    h ) help;;
    \? ) echo $usage
         exit 1;;
    * ) echo $usage
        exit 1;;
  esac
done

if test -z $node_name; then
    echo "You must specify a node name using the -n option."
    exit 1
fi

# find the node by name in the guids file:
nodeGuid=`awk '/NODE *'$node_name'\/U1/{print $3}' $guids_file`
if test -z $nodeGuid; then
    echo "Fail to find node:$node_name in $guids_file"
    exit 1
fi
port1Guid=`awk '/PORT *'$node_name'\/P1/{print $3}' $guids_file`
port2Guid=`awk '/PORT *'$node_name'\/P2/{print $3}' $guids_file`

ng=`echo $nodeGuid | sed -e 's/0x//' -e 's/\(....\)\(....\)\(....\)\(....\)/\1:\2:\3:\4/'`
pg1=`echo $port1Guid | sed -e 's/0x//' -e 's/\(....\)\(....\)\(....\)\(....\)/\1:\2:\3:\4/'`
pg2=`echo $port2Guid | sed -e 's/0x//' -e 's/\(....\)\(....\)\(....\)\(....\)/\1:\2:\3:\4/'`

echo "$node_name GUIDS: Node=$ng Port1=$pg1 Port2=$pg2"

# Create the node dir
mkdir -p $node_name/ca1

# Node Info
cat <<EOF > $node_name/ca1/info
name:          InfiniHost0
provider:      tavor
node GUID:     $ng
ports:         2
vendor ID:     0x2c9
device ID:     0x5a44
HW revision:   0xa1
FW revision:   0x300020002
EOF

# Port1
mkdir -p $node_name/ca1/port1

# port info
cat <<EOF > $node_name/ca1/port1/info
state:         INIT
LID:           0x0000
LMC:           0x0000
SM LID:        0x0001
SM SL:         0x0000
Capabilities:  IsTrapSupported
               IsAutomaticMigrationSupported
               IsSLMappingSupported
               IsLEDInfoSupported
               IsSystemImageGUIDSupported
               IsVendorClassSupported
               IsCapabilityMaskNoticeSupported
EOF

# pkey
cat <<EOF > $node_name/ca1/port1/pkey_table
[  0] ffff
EOF

# gids
cat <<EOF > $node_name/ca1/port1/gid_table
[  0] fe80:0000:0000:0000:$pg1
EOF

# Port2
mkdir -p $node_name/ca1/port2

# port info
cat <<EOF > $node_name/ca1/port2/info
state:         INIT
LID:           0x0000
LMC:           0x0000
SM LID:        0x0001
SM SL:         0x0000
Capabilities:  IsTrapSupported
               IsAutomaticMigrationSupported
               IsSLMappingSupported
               IsLEDInfoSupported
               IsSystemImageGUIDSupported
               IsVendorClassSupported
               IsCapabilityMaskNoticeSupported
EOF

# pkey
cat <<EOF > $node_name/ca1/port2/pkey_table
[  0] ffff
EOF

# gids
cat <<EOF > $node_name/ca1/port2/gid_table
[  0] fe80:0000:0000:0000:$pg2
EOF