99 lines
2.8 KiB
Bash
Executable File
99 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Copyright 2016 Mellanox Technologies, Ltd
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
# implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
# Set defaults
|
|
MAX_VFS=$MAX_NUM_VFS
|
|
LOG_FILE=/var/log/mlnx_fw_update.log
|
|
OFED_DEBS_DIR=/opt/ofed/MLNX_OFED/DEBS/
|
|
|
|
if [ -z $FORCE_LINK_TYPE ]; then
|
|
FORCE_LINK_TYPE=false
|
|
fi
|
|
|
|
if [ -z $LINK_TYPE ]; then
|
|
LINK_TYPE=1
|
|
fi
|
|
|
|
# Install required packages
|
|
dpkg -i ${OFED_DEBS_DIR}/kernel-mft-dkms*.deb
|
|
dpkg -i ${OFED_DEBS_DIR}/mstflint*.deb
|
|
dpkg -i ${OFED_DEBS_DIR}/mft*.deb
|
|
|
|
# Validate that not OEM
|
|
BUS_ID=`lspci | grep -m 1 Mellanox | cut -d' ' -f1`
|
|
if [ -z $BUS_ID ]; then
|
|
echo "Didn't find bus, skipping firmware upgrade" >> $LOG_FILE
|
|
exit 0
|
|
fi
|
|
|
|
mstflint -d ${BUS_ID} q | grep -i PSID | grep MT_
|
|
if [ $? -ne 0 ]; then
|
|
echo "Not Mellanox Card or a NIC access problem. skipping firmware upgrade." >> $LOG_FILE
|
|
else # Not OEM
|
|
echo "Starting FW upgrade" >> $LOG_FILE
|
|
/opt/ofed/MLNX_OFED/mlnxofedinstall --fw-update-only >> $LOG_FILE
|
|
fi
|
|
|
|
# Set ConnectX-4 FW
|
|
if which mst; then
|
|
echo "Enabling SR-IOV in FW" >> $LOG_FILE
|
|
mst start >> $LOG_FILE
|
|
dev=`mst status | grep 411 | awk '{print $1}'`
|
|
mlxconfig -d $dev q |grep -q SRIOV_EN
|
|
if [ $? -ne 0 ]; then
|
|
echo "Problem accessing FW configurations, skipping FW configurations." >> $LOG_FILE
|
|
exit 0
|
|
fi
|
|
|
|
reset_fw=false
|
|
|
|
# Verify link type (if forced)
|
|
if $FORCE_LINK_TYPE; then
|
|
mlxconfig -d $dev q | grep LINK_TYPE_P1 | awk '{print $2}' | \
|
|
grep $LINK_TYPE &> /dev/null
|
|
if [ $? -ne 0 ]; then
|
|
echo "Setting Link type as $LINK_TYPE in FW" >> $LOG_FILE
|
|
mlxconfig -d $dev -y set LINK_TYPE_P1=$LINK_TYPE \
|
|
LINK_TYPE_P2=$LINK_TYPE >> $LOG_FILE
|
|
reset_fw=true
|
|
fi
|
|
fi
|
|
|
|
# Verify MAX VFs num
|
|
mlxconfig -d $dev q | grep NUM_OF_VFS | grep $MAX_VFS &> /dev/null
|
|
if [ $? -ne 0 ]; then
|
|
echo "Setting max VFs to $MAX_VFS in FW" >> $LOG_FILE
|
|
mlxconfig -d $dev -y set SRIOV_EN=1 NUM_OF_VFS=$MAX_VFS \
|
|
VF_LOG_BAR_SIZE=1 NUM_VF_MSIX=4 >> $LOG_FILE
|
|
reset_fw=true
|
|
fi
|
|
|
|
# Reset ConnectX-4 FW
|
|
if $reset_fw; then
|
|
echo "Reset FW on MLNX Card" >> $LOG_FILE
|
|
mlxfwreset --device $dev -y reset >> $LOG_FILE
|
|
for i in $(ibdev2netdev |grep mlx5 |grep -i down |awk '{print $5}')
|
|
do
|
|
ifconfig $i up;
|
|
done
|
|
fi
|
|
|
|
else
|
|
echo "Skipping ConenctX-4 configurations in FW since no MST found" >> $LOG_FILE
|
|
fi
|
|
|
|
exit 0
|