dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / ibd_upgrade / ibd_upgrade.sh
blob23be8cdc02f7429c04d1afaae28f30716bc154b2
1 #!/sbin/sh
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
20 # CDDL HEADER END
23 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
27 PATH=/sbin:/bin
28 ORIGIFS="${IFS}"
29 USAGE="Usage: ibd_upgrade [-v]"
30 DRVCONF=/kernel/drv/ibp.conf.old
33 # split device path into path components
35 split_path_components()
37 hca_path=
38 node_name=
39 port=
40 pkey=
41 service=
42 partition_name=
44 hca_path="/dev/`dirname $device_path`"
45 bname=`basename $device_path`
46 IFS=":"
47 set -- $bname
48 node_at_addr=$1
49 partition_name=$2
50 IFS="@"
51 set -- $node_at_addr
52 node_name=$1
53 IFS=","
54 set -- $2
55 port=$1
56 pkey=0x$2
57 service=$3
59 IFS="${ORIGIFS}"
62 do_cmd()
64 if [ $verbose -eq 1 ]; then
65 echo "$1"
70 process_rc_mode()
72 device=$1
75 # Get the instance number of ibd
76 # Device name format would be ibd#,
78 IFS="d"
79 set -- ${device}
80 IFS="${ORIGIFS}"
82 if [ "$1" != "ib" ]; then
83 return
86 inst=$2
88 IFS=","
89 set -- ${enable_rc}
90 IFS="${ORIGIFS}"
92 if [ ${inst} -lt $# ]; then
93 (( inst = $inst + 1 ))
94 eval "linkmode=\$${inst}"
95 else
96 linkmode=0
99 if [ "$linkmode" = "0" ]; then
100 do_cmd "dladm set-linkprop -p linkmode=ud ${device}"
104 verbose=0
105 while getopts v c
107 case $c in
108 v) verbose=1;;
109 \?) echo "$USAGE" 1>&2
110 exit 2;;
111 esac
112 done
114 enable_rc=
115 if [ -f ${DRVCONF} ]; then
116 enable_rc=`egrep "^[ ]*enable_rc[ ]*=" ${DRVCONF} | sed -e "s/[ ]*//g" -e "s/enable_rc=//" -e "s/;$//" 2>/dev/null`
120 # Loop through all ibd devices based on the old model (i.e., one ibd instance
121 # per partition; consequently device names have non zero pkey)
122 # and create data links with the same names as in the old model under the
123 # new model.
125 ls -l /dev/ibd* 2> /dev/null \
126 | while read x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 device_path
128 split_path_components
130 if [ "$node_name" != "ibport" -o "$service" != "ipib" \
131 -o "$pkey" = "0x0" -o "$pkey" = "0x" ]; then
132 continue
135 # verify that the hca path exists
136 cd $hca_path 2> /dev/null
137 if [ $? -ne 0 ]; then
138 continue
141 fn=`echo ibport@${port},0,ipib:ibp*[0-9]`
142 if [ -c "$fn" ]; then
143 IFS=":"
144 set -- $fn
145 IFS="${ORIGIFS}"
147 do_cmd "dladm delete-phys $partition_name" 2>/dev/null
148 if [ $? -ne 0 ]; then
149 do_cmd "ibd_delete_link $partition_name"
151 do_cmd "dladm create-part -f -l $2 -P $pkey $partition_name"
153 if [ "$enable_rc" != "" ]; then
154 process_rc_mode $partition_name
157 done
159 exit 0