@@ -48,11 +48,13 @@ usage ()
4848{
4949 echo " Usage: $0 [options]"
5050 echo " Options:"
51+ echo " -a, --activate <0|1> Activate the upgrade."
5152 echo " -b, --bfb <bfb_file> BFB image file to use."
5253 echo " -c, --config <config_file> Optional configuration file."
5354 echo " -f, --rootfs <rootfs_file> Optional rootfs file."
5455 echo " -h, --help Show help message."
5556 echo " -k, --keep-log Do not clear the log after reading during bfb install."
57+ echo " -l, --lfwp Enable LFWP upgrade."
5658 echo " -m, --remote-mode <mode> Remote mode to use (scp, nc, ncpipe)."
5759 echo " -p, --pldm <pldm_file> PLDM image for runtime upgrade."
5860 echo " -r, --rshim <device> Rshim device, format [<ip>:<port>:]rshim<N>."
@@ -624,6 +626,8 @@ num_bfb=0
624626num_rshim=0
625627max_bfb=1
626628max_rshim=1
629+ lfwp=0
630+ activate=
627631
628632rshim_node= # rshim device identifier, e.g. rshim0
629633ip= # IP address for remote host
@@ -637,18 +641,20 @@ pcie_bd="" # PCIE Bus-Device
637641pf0_bound=0 # PF0 is bound prior to the script run
638642pf1_bound=0 # PF1 is bound prior to the script run
639643
640- options=` getopt -n bfb-install -o b:c:f:hkm :p:r:Ruv \
641- -l bfb:,config:,rootfs:,help,keep-log,remote-mode:,reverse-nc,rshim:,pldm:,runtime,verbose \
644+ options=` getopt -n bfb-install -o a: b:c:f:hklm :p:r:Ruv \
645+ -l activate:, bfb:,config:,rootfs:,help,keep-log,lfwp ,remote-mode:,reverse-nc,rshim:,pldm:,runtime,verbose \
642646 -- " $@ " `
643647if [ $? != 0 ]; then echo " Command line error" >&2 ; exit 1; fi
644648eval set -- $options
645649while [ " $1 " != -- ]; do
646650 case $1 in
651+ --activate|-a) shift ; activate=$1 ;;
647652 --bfb|-b) shift ; bfb=$( readlink -f $1 ) num_bfb=$(( num_bfb + 1 )) ;;
648653 --config|-c) shift ; cfg=$1 ;;
649654 --rootfs|-f) shift ; rootfs=$1 ;;
650655 --help|-h) usage; exit 0 ;;
651656 --keep-log|-k) clear_on_read=0 ;;
657+ --lfwp|-l) lfwp=1; runtime=1 ;;
652658 --pldm|-p) shift ; pldm=$( readlink -f $1 ) ;;
653659 --remote-mode|-m) shift ; remote_mode=$1 ;;
654660 --rshim|-r) shift ; rshim=$1 num_rshim=$(( num_rshim + 1 )) ;;
@@ -663,7 +669,10 @@ done
663669
664670# Parameter checks
665671
666- if [ -z " ${bfb} " -a -z " ${pldm} " ]; then
672+ # Default activate to the lfwp value.
673+ activate=${activate:- $lfwp }
674+
675+ if [ -z " ${bfb} " -a -z " ${pldm} " -a ${activate} -eq 0 ]; then
667676 echo " Error: Need to provide either bfb or pldm file."
668677 usage >&2
669678 exit 1
@@ -876,12 +885,7 @@ if [ -n "${pldm}" ]; then
876885
877886 pldm=" "
878887 bfb=" ${TMP_DIR} /pldm/pldm.bfb"
879- elif [ ${runtime} -eq 1 ]; then
880- if [ ! -e " ${bfb} " ]; then
881- echo " Error: ${bfb} not found."
882- exit 1
883- fi
884-
888+ elif [ ${runtime} -eq 1 -a -e " ${bfb} " ]; then
885889 # Convert bundle BFB to flat BFB if needed.
886890 # This conversion is only supported on PCIe host.
887891 is_bundle=$( mlx-mkbfb -d " ${bfb} " | grep " In-memory filesystem" )
@@ -913,8 +917,8 @@ elif [ ${runtime} -eq 1 ]; then
913917 fi
914918fi
915919
916- # Check again if bfb file exists
917- if [ ! -e " ${bfb} " ]; then
920+ # Check again if bfb file exists (if not activate-only).
921+ if [ ! -e " ${bfb} " -a ${activate} -eq 0 ]; then
918922 echo " Error: ${bfb} not found."
919923 exit 1
920924fi
@@ -1013,16 +1017,44 @@ if [ ${nic_mode} -eq 1 -a -n "${pcie_bd}" -a ${runtime} -eq 0 ]; then
10131017 done
10141018fi
10151019
1016- # Reactivate NIC_FW
1017- if which flint & > /dev/null ; then
1018- if [ -n " ${pcie_bd} " -a ${runtime} -eq 1 ] ; then
1020+ # Reactivate NIC_FW if runtime but not LFWP.
1021+ if [ ${lfwp} -eq 0 -a -n " ${pcie_bd} " -a ${runtime} -eq 1 ] ; then
1022+ if which flint & > /dev/null ; then
10191023 # Suppress errors if already activated.
10201024 flint -d ${pcie_bd} .0 ir >& /dev/null
1025+ else
1026+ echo " Flint not found. Skip NIC_FW reactivation."
10211027 fi
1022- else
1023- echo " Flint not found. Skip NIC_FW reactivation."
10241028fi
10251029
1026- push_boot_stream
1030+ # Push BFB and wait for result.
1031+ if [ -e " ${bfb} " ]; then
1032+ push_boot_stream
1033+ wait_for_update_to_finish
1034+ fi
1035+
1036+ # LFWP activation on PCIe host.
1037+ if [ ${lfwp} -eq 1 -a ${activate} -eq 1 ]; then
1038+ if [ -z " ${pcie_bd} " ]; then
1039+ echo " ERROR: Failed to activate LFWP, PCIe device not found."
1040+ exit 1
1041+ fi
1042+
1043+ if ! which mlxfwreset & > /dev/null; then
1044+ echo " ERROR: Failed to activate LFWP, mlxfwreset not found."
1045+ exit 1
1046+ fi
10271047
1028- wait_for_update_to_finish
1048+ # Best-effort to check and apply L0 reset.
1049+ if (mlxfwreset -d ${pcie_bd} .0 q | grep live-Patch | grep -qw " \-Supported" ); then
1050+ echo " Live Patch NIC Firmware reset is supported."
1051+ msg=$( mlxfwreset -d ${pcie_bd} .0 -y -l 0 r 2>&1 )
1052+ if [ $? -ne 0 ]; then
1053+ echo " ERROR: Live Patch NIC Firmware reset failed. $msg "
1054+ else
1055+ echo " Live Patch NIC Firmware reset done"
1056+ fi
1057+ else
1058+ echo " Live Patch NIC Firmware reset not supported."
1059+ fi
1060+ fi
0 commit comments