#!/usr/sbin/sh # # Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. # . /lib/svc/share/smf_include.sh . /lib/svc/share/fs_include.sh # # The IB Unified Driver (UD) project changed the device tree underneath # the IB HCA node. The job of this ibud post upgrade script is to replace # obsolete lines in /etc/path_to_inst with their replacement lines (example # shown below). This script is run only once, as it will remove the old paths # from /etc/path_to_inst which is the condition needed for this script to run. # # Here is an example of the old/legacy paths: # # "/pci8086,3410@9/pci15b3,673c@0" 0 "hermon" # "/pci8086,3410@9/pci15b3,673c@0/ibport@1,0,ipib" 0 "ibp" # "/pci8086,3410@9/pci15b3,673c@0/ibport@2,0,ipib" 1 "ibp" # # which is replaced by the new paths: # # "/pci8086,3410@9/pci15b3,673c@0" 0 "mcxnex" # "/pci8086,3410@9/pci15b3,673c@0/hermon@0" 0 "hermon" # "/pci8086,3410@9/pci15b3,673c@0/hermon@0/ibport@1,0,ipib" 0 "ibp" # "/pci8086,3410@9/pci15b3,673c@0/hermon@0/ibport@2,0,ipib" 1 "ibp" # # The important feature of this script is to maintain the instance numbers # within /etc/path_to_inst so that other consumers of device driver instances, # e.g., dladm, retain their validity during this one-time upgrade from the # old "hermon" driver to the new "mcxnex/hermon" layered drivers. # EOIB_PATHS=/etc/ibud_eoib_paths PATHTOINST=/etc/path_to_inst CP=/usr/bin/cp RM=/usr/bin/rm EGREP=/usr/bin/egrep CAT=/usr/bin/cat NAWK=/usr/bin/nawk update_pathtoinst_entries() { echo "Doing one-time conversion of /etc/path_to_inst for InfiniBand." # # Determine lowest mcxnex_inst for our use. There could have been # instances in earlier releases on i386 for Mellanox ethernet cards # that have "vendor ID, device id" of "pciex15b3,6750". # mcxnex_inst=0 while read path instance driver; do if [ "$driver" = '"mcxnex"' ]; then path_no_quote=`echo $path | sed s/^\"// | sed s/\"$//` $CAT $PATHTOINST | $EGREP $path_no_quote | \ $EGREP '"mcxe"'> /dev/null if [ $? -eq 0 ]; then if [ $instance -ge $mcxnex_inst ]; then mcxnex_inst=`expr $instance + 1` fi fi fi done < $PATHTOINST # Now we have lowest "mcxnex_inst" for our use. # Start with no eoib paths, and add them in if and when detected. > $EOIB_PATHS # # Find all new ConnectX (mcxnex) entries, and destroy them. # Find all old/legacy ConnectX (hermon) entries, and convert them. # while read line; do echo $line | read path instance driver if [ "$driver" = '"mcxnex"' ]; then # # Discard it unless it is pciex15b3,6750 (which was # previously supported by mcxnex ethernet on i386). # path_no_quote=`echo $path | sed s/^\"// | sed s/\"$//` $CAT $PATHTOINST | $EGREP $path_no_quote | \ $EGREP '"mcxe"'> /dev/null if [ $? -eq 0 ]; then echo "$line" fi elif [ "$driver" = '"hermon"' ]; then # Discard it unless it is old/legacy (see above). echo $path | $EGREP "/hermon@" > /dev/null if [ $? -ne 0 ]; then # Remember hermon instance for use with ibport hermon_inst=$instance hermon_addr=$mcxnex_inst # Append valid EOIB paths to tmp file $EGREP eoib.*hermon$hermon_inst $PATHTOINST >> \ $EOIB_PATHS # # Create new mcxnex line, and increment # mcxnex instance number for the next device. # echo $path $mcxnex_inst '"mcxnex"' mcxnex_inst=`expr $mcxnex_inst + 1` # Create new hermon line echo `echo $path | sed "s/\"//g" | \ sed "s/.*/\"&\/hermon@$hermon_addr\"/"` \ $hermon_inst '"hermon"' fi else # # Legacy "ibport" paths do not have the substring # "hermon@" in them, only the new "ibport" paths # have this. # echo $path | $EGREP ibport | grep -v "hermon@" > \ /dev/null if [ $? -eq 0 ]; then # Discard any new lines, and covert old lines. echo $path | $EGREP "/hermon" > /dev/null if [ $? -ne 0 ]; then # Replace old with new ibport path. echo \"`echo $path | sed "s/\"//g" | \ sed "s/ibport/hermon@$hermon_addr\/ibport"/`\" \ $instance $driver fi else # # The path is something else, so just pass it # forward. This includes all comment lines. # echo "$line" fi fi done < $PATHTOINST > $PATHTOINST.pass1 # Remove EOIB paths, then append the valid new ones. $EGREP -v "eoib@hermon" $PATHTOINST.pass1 > $PATHTOINST.pass2 $CAT $PATHTOINST.pass2 $EOIB_PATHS > $PATHTOINST.pass3 $CP $PATHTOINST $PATHTOINST.old /usr/bin/mv $PATHTOINST.pass3 $PATHTOINST # Clean up. $RM $PATHTOINST.pass? $EOIB_PATHS } system_reboot() { # The following "reboot" logic has been copied from the fs-usr script. MSGSUCCESS="Rebooting to complete upgrade of InfiniBand configuration." /usr/sbin/bootadm update-archive -f if [ $? != 0 ]; then cecho "" cecho "WARNING: Automatic update of the boot archive failed." cecho "Update the boot archive using 'bootadm update-archive'" cecho "command and then reboot the system from the same device" cecho "that was previously booted." cecho "" exit $SMF_EXIT_ERR_FATAL fi if [ `uname -p` = "i386" ]; then /usr/sbin/reboot -f dryrun if [ $? = 0 ]; then cecho "" cecho $MSGSUCCESS cecho "" bootcmd=`/usr/sbin/eeprom bootcmd | \ /usr/bin/sed -e 's#bootcmd=##g'` /usr/sbin/reboot -f -- "$bootcmd" exit $SMF_EXIT_OK fi boot_prop=`/usr/sbin/svccfg -s svc:/system/boot-config:default listprop config/auto-reboot-safe | \ /usr/bin/nawk '{ print $3}'` if [ "$boot_prop" != "true" ]; then cecho "" cecho "WARNING: Reboot required." cecho "" cecho "The InfiniBand configuration was updated as part of the" cecho "upgrade. In order to complete the upgrade, please reboot" cecho "the system from the same device that was previously booted." cecho "" exit $SMF_EXIT_ERR_FATAL else cecho "" cecho $MSGSUCCESS cecho "" /usr/sbin/reboot -p exit $SMF_EXIT_OK fi fi cecho "" cecho $MSGSUCCESS cecho "" /usr/sbin/reboot -p exit $SMF_EXIT_OK } ibud_post_upgrade_main() { # Remove hca dev links; correct ones are recreated. $RM -f /dev/infiniband/hca/* # # Check to see if there is a need for an upgrade from legacy driver # (hermon) to unified driver (mcxnex/hermon). The condition is that # there exist paths for the hermon driver that do not have the # "hermon@" substring. # $EGREP -v 'hermon@' $PATHTOINST | $EGREP '"hermon"' >/dev/null if [ $? -ne 0 ]; then # No legacy "hermon", so no need to do anything, just exit. exit $SMF_EXIT_OK fi # # We're doing the "one time" device path conversion, and rebooting. # update_pathtoinst_entries system_reboot exit $SMF_EXIT_OK } # # Main script. # ibud_post_upgrade_main