#!/sbin/sh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # # setvar PATH = "/sbin:/bin" setvar ORIGIFS = "${IFS}" setvar USAGE = ""Usage: ibd_upgrade [-v]"" setvar DRVCONF = '/kernel/drv/ibp.conf.old' # # split device path into path components # proc split_path_components { setvar hca_path = '' setvar node_name = '' setvar port = '' setvar pkey = '' setvar service = '' setvar partition_name = '' setvar hca_path = ""/dev/$(dirname $device_path)"" setvar bname = $(basename $device_path) setvar IFS = "":"" set -- $bname setvar node_at_addr = "$1" setvar partition_name = "$2" setvar IFS = ""@"" set -- $node_at_addr setvar node_name = "$1" setvar IFS = "","" set -- $2 setvar port = "$1" setvar pkey = "0x$2" setvar service = "$3" setvar IFS = "${ORIGIFS}" } proc do_cmd { if test $verbose -eq 1 { echo $1 } $1 } proc process_rc_mode { setvar device = "$1" # # Get the instance number of ibd # Device name format would be ibd#, # setvar IFS = ""d"" set -- ${device} setvar IFS = "${ORIGIFS}" if test $1 != "ib" { return } setvar inst = "$2" setvar IFS = "","" set -- ${enable_rc} setvar IFS = "${ORIGIFS}" if test ${inst} -lt $Argc { (( inst = $inst + 1 )) eval "linkmode=\$${inst}" } else { setvar linkmode = '0' } if test $linkmode = "0" { do_cmd "dladm set-linkprop -p linkmode=ud ${device}" } } setvar verbose = '0' while getopts v c { match $c { with v setvar verbose = '1' with \? echo $USAGE 1>&2 exit 2 } } setvar enable_rc = '' if test -f ${DRVCONF} { setvar enable_rc = $(egrep "^[ ]*enable_rc[ ]*=" ${DRVCONF} | sed -e "s/[ ]*//g" -e "s/enable_rc=//" -e "s/;$//" ) } # # Loop through all ibd devices based on the old model (i.e., one ibd instance # per partition; consequently device names have non zero pkey) # and create data links with the same names as in the old model under the # new model. # ls -l /dev/ibd* 2> /dev/null \ | while read x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 device_path { split_path_components if test $node_name != "ibport" -o $service != "ipib" \ -o $pkey = "0x0" -o $pkey = "0x" { continue } # verify that the hca path exists cd $hca_path 2> /dev/null if test $Status -ne 0 { continue } setvar fn = $(echo ibport@${port},0,ipib:ibp*[0-9]) if test -c $fn { setvar IFS = "":"" set -- $fn setvar IFS = "${ORIGIFS}" do_cmd "dladm delete-phys $partition_name" 2>/dev/null if test $Status -ne 0 { do_cmd "ibd_delete_link $partition_name" } do_cmd "dladm create-part -f -l $2 -P $pkey $partition_name" if test $enable_rc != "" { process_rc_mode $partition_name } } } exit 0