From c9dc4439ecd94217f5dc2c17d4663b7bea67797b Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Thu, 5 Apr 2018 09:39:56 -0400 Subject: [PATCH 1/2] Add postscript to enable CAPI mode for mlnxofed --- xCAT/postscripts/enablecapi | 92 +++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 xCAT/postscripts/enablecapi diff --git a/xCAT/postscripts/enablecapi b/xCAT/postscripts/enablecapi new file mode 100644 index 000000000..e99e6fe6c --- /dev/null +++ b/xCAT/postscripts/enablecapi @@ -0,0 +1,92 @@ +#!/bin/bash + +if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then + str_dir_name=`dirname $0` + . $str_dir_name/xcatlib.sh +fi + +#--------------------------------------------------------------------------- +#=head1 enablecapi +#=head2 enable CAPI and tunnel Atomics for compute nodes +# at least MOFED 4.3.1 has to be installed and only support on ConnectX5 +# +# updatenode enablecapi +# +#--------------------------------------------------------------------------- + +#check if mlnx ofed installed +if [ ! -x /usr/bin/ofed_info ]; then + logger -t xcat -p local4.err "MOFED is not installed" + echo "MOFED is not installed on the system" + exit -1 +fi + +#mofed version at least 4.3-1 +version=`/usr/bin/ofed_info -n` +majorversion=`echo $version | cut -d- -f1` +minorversion=`echo $version | cut -d- -f2` +if (( $(echo "$majorversion < 4.3" |bc -l) )); then + logger -t xcat -p local4.err "Current MOFED version is $version and needs to be at least 4.3-1" + echo "Current MOFED version is $version and needs to be at least 4.3-1" + exit -1 +fi +if (( $(echo "$majorversion == 4.3" |bc -l) )); then + minor=`echo $minorversion | cut -d. -f1` + if (( $(echo "$minor < 1") )); then + logger -t xcat -p local4.err "MOFED version needs to be at least 4.3-1" + echo "Current MOFED version is $version and needs to be at least 4.3-1" + exit -1 + fi +fi + +#check if mst is existed +if [ ! -x /usr/bin/mst ]; then + logger -t xcat -p local4.err "mst command is not available" + echo "mst command is not available" + exit -1 +fi + +service mst restart >/dev/null 2>&1 +if [ "$?" != "0" ] ;then + logger -t xcat -p local4.err "[Error] failed to start mst." + echo "[Error] failed to start mst." + exit -1 +fi + + +#check if mlxconfig is existed +if [ ! -x /usr/bin/mlxconfig ]; then + logger -t xcat -p local4.err "mlxconfig command is not available" + echo "mlxconfig command is not available" + exit -1 +fi + +reboot_flag=0 + +for x in `ls /dev/mst/mt*` +do + mlxconfig -y -d $x q | grep 'ConnectX5' >/dev/null 2>&1 + if [ $? == 0 ]; then + mlxconfig -y -d $x set ADVANCED_PCI_SETTINGS=true >/dev/null 2>&1 + mlxconfig -y -d $x set IBM_CAPI_EN=true >/dev/null 2>&1 + mlxconfig -y -d $x set IBM_TUNNELED_ATOMIC_EN=true >/dev/null 2>&1 + mlxconfig -y -d $x set IBM_AS_NOTIFY_EN=true >/dev/null 2>&1 + echo "Apply new Configuration for $x:" + mlxconfig -y -d $x q | grep 'IBM' + reboot_flag=1 + fi +done + +if [[ $reboot_flag == 0 ]]; then + echo "Didn't find ConnectX5 Devices, will not apply the new configuration" +fi + +if [[ $reboot_flag == 1 ]]; then + echo "******************************************************" + echo " New configuration applied" + echo " Please reboot system to load new configurations" + echo "******************************************************" +fi + +exit 0 + From 4240fd54c96e8d3b2c3c8a5be9a45641e2705935 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Thu, 5 Apr 2018 10:42:51 -0400 Subject: [PATCH 2/2] modify from review --- xCAT/postscripts/enablecapi | 59 ++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/xCAT/postscripts/enablecapi b/xCAT/postscripts/enablecapi index e99e6fe6c..628e8f19a 100644 --- a/xCAT/postscripts/enablecapi +++ b/xCAT/postscripts/enablecapi @@ -14,51 +14,46 @@ fi # #--------------------------------------------------------------------------- -#check if mlnx ofed installed -if [ ! -x /usr/bin/ofed_info ]; then - logger -t xcat -p local4.err "MOFED is not installed" - echo "MOFED is not installed on the system" - exit -1 -fi +function logerr { + echo "$@" + logger -t xcat -p local4.err $@ +} + + +#check if mlnx ofed commands are installed +COMMANDS="ofed_info mst mlxconfig" +for CMD in ${COMMANDS}; do + RC=`command -v ${CMD} >> /dev/nul 2>&1; echo $?` + if [[ ${RC} != 0 ]]; then + ERRMSG="Command: ${CMD} is not found, unable to run the scripts" + logerr $ERRMSG + exit 1 + fi +done #mofed version at least 4.3-1 version=`/usr/bin/ofed_info -n` majorversion=`echo $version | cut -d- -f1` minorversion=`echo $version | cut -d- -f2` if (( $(echo "$majorversion < 4.3" |bc -l) )); then - logger -t xcat -p local4.err "Current MOFED version is $version and needs to be at least 4.3-1" - echo "Current MOFED version is $version and needs to be at least 4.3-1" - exit -1 + ERRMSG="Current MOFED version is $version and needs to be at least 4.3-1" + logerr $ERRMSG + exit 1 fi if (( $(echo "$majorversion == 4.3" |bc -l) )); then minor=`echo $minorversion | cut -d. -f1` if (( $(echo "$minor < 1") )); then - logger -t xcat -p local4.err "MOFED version needs to be at least 4.3-1" - echo "Current MOFED version is $version and needs to be at least 4.3-1" - exit -1 + ERRMSG="Current MOFED version is $version and needs to be at least 4.3-1" + logerr $ERRMSG + exit 1 fi fi -#check if mst is existed -if [ ! -x /usr/bin/mst ]; then - logger -t xcat -p local4.err "mst command is not available" - echo "mst command is not available" - exit -1 -fi - service mst restart >/dev/null 2>&1 if [ "$?" != "0" ] ;then - logger -t xcat -p local4.err "[Error] failed to start mst." - echo "[Error] failed to start mst." - exit -1 -fi - - -#check if mlxconfig is existed -if [ ! -x /usr/bin/mlxconfig ]; then - logger -t xcat -p local4.err "mlxconfig command is not available" - echo "mlxconfig command is not available" - exit -1 + ERRMSG "[Error] failed to start mst." + logerr $ERRMSG + exit 1 fi reboot_flag=0 @@ -79,9 +74,7 @@ done if [[ $reboot_flag == 0 ]]; then echo "Didn't find ConnectX5 Devices, will not apply the new configuration" -fi - -if [[ $reboot_flag == 1 ]]; then +else echo "******************************************************" echo " New configuration applied" echo " Please reboot system to load new configurations"