Debian Codegraph @

infiniband-diags/scripts/ibstatus

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 # Usage ibstatus [devname[:port]]
4
5 infiniband_base="/sys/class/infinibandscip-shell filesystem . . `/sys/class/infiniband`."
6 def_ibdev="mthca0"
7
8 usagescip-shell shell shell-project 0.0.0 usage().() {
9 prog=`basenamescip-shell system . . basename. $0`
10 echoscip-shell system . . echo. "Usage: " $prog " [-h] [devname[:portnum]]"
11 echoscip-shell system . . echo. " -h: this help screen"
12 echoscip-shell system . . echo. " Examples:"
13 echoscip-shell system . . echo. " $prog mthca1 # shows status of all ports of 'mthca1'"
14 echoscip-shell system . . echo. " $prog mthca0:2 # shows status port number 2 of 'mthca0'"
15 echoscip-shell system . . echo. " $prog # default: shows status of all '$def_ibdev' ports"
16 exit 255
17 }
18
19 fatalscip-shell shell shell-project 0.0.0 fatal().() {
20 echoscip-shell system . . echo. "Fatal error: " $*
21 exit 255
22 }
23
24
25 port_statusscip-shell shell shell-project 0.0.0 port_status().() {
26 port_dir="$infiniband_base/$1/ports/$2"
27 echoscip-shell system . . echo. "Infiniband device '$1' port $2 status:"
28 echoscip-shell system . . echo. " default gid: " `[scip-shell system . . `[`. -r $port_dir/gids/0 ] && catscip-shell system . . cat. $port_dir/gids/0 || echoscip-shell system . . echo. unknown`
29 echoscip-shell system . . echo. " base lid: " `[scip-shell system . . `[`. -r $port_dir/lid ] && catscip-shell system . . cat. $port_dir/lid || echoscip-shell system . . echo. unknown`
30 echoscip-shell system . . echo. " sm lid: " `[scip-shell system . . `[`. -r $port_dir/sm_lid ] && catscip-shell system . . cat. $port_dir/sm_lid || echoscip-shell system . . echo. unknown`
31 echoscip-shell system . . echo. " state: " `[scip-shell system . . `[`. -r $port_dir/state ] && catscip-shell system . . cat. $port_dir/state || echoscip-shell system . . echo. unknown`
32 echoscip-shell system . . echo. " phys state: " `[scip-shell system . . `[`. -r $port_dir/phys_state ] && catscip-shell system . . cat. $port_dir/phys_state || echoscip-shell system . . echo. unknown`
33 echoscip-shell system . . echo. " rate: " `[scip-shell system . . `[`. -r $port_dir/rate ] && catscip-shell system . . cat. $port_dir/rate || echoscip-shell system . . echo. unknown`
34 echoscip-shell system . . echo. " link_layer: " `[scip-shell system . . `[`. -r $port_dir/link_layer ] && catscip-shell system . . cat. $port_dir/link_layer || echoscip-shell system . . echo. IB`
35 echoscip-shell system . . echo.
36 }
37
38 ib_statusscip-shell shell shell-project 0.0.0 ib_status().() {
39 ports_dir="$infiniband_base/$1/ports"
40
41 if ! [scip-shell system . . `[`. -d "$ports_dir" ]; then
42 fatalscip-shell shell shell-project 0.0.0 fatal(). "device '$1': sys files not found ($ports_dir)"
43 fi
44
45 if [scip-shell system . . `[`. "$2" = "+" ]; then
46 ports=`(cd "$infiniband_base/$1/ports" 2>/dev/nullscip-shell filesystem . . `/dev/null`. || fatalscip-shell shell shell-project 0.0.0 fatal(). No devices; echoscip-shell system . . echo. *)`
47 else
48 ports=$2
49 fi
50
51 for i in $ports; do
52 port_statusscip-shell shell shell-project 0.0.0 port_status(). $1 $i
53 done
54 }
55
56 if [scip-shell system . . `[`. "$1" = "-h" ]; then
57 usagescip-shell shell shell-project 0.0.0 usage().
58 fi
59
60 if [scip-shell system . . `[`. -z "$1" ]; then
61 cd $infiniband_base 2>/dev/nullscip-shell filesystem . . `/dev/null`. || fatalscip-shell shell shell-project 0.0.0 fatal(). No devices
62 for dev in *; do
63 ib_statusscip-shell shell shell-project 0.0.0 ib_status(). $dev "+";
64 done
65 exit 0
66 fi
67
68 while [scip-shell system . . `[`. "$1" ]; do
69 dev=`echoscip-shell system . . echo. $1 | sedscip-shell system . . sed. 's/:.*$//'`
70 port=`echoscip-shell system . . echo. $1 | sedscip-shell system . . sed. 's/^.*://'`
71
72 if [scip-shell system . . `[`. "$port" = "$dev" ]; then
73 port="+"
74 fi
75
76 ib_statusscip-shell shell shell-project 0.0.0 ib_status(). $dev $port
77 shift
78 done