Move FW burn to discovery stage

With removing reboot task, upgrading bootstrap packages
and adding SR-IOV capabilities to it

Change-Id: I41222f5c4548d092a7626d85b03a64365de225e9
This commit is contained in:
Aviram Bar-Haim 2016-04-11 14:24:48 +03:00 committed by Rawan Herzallah
parent 42c47329fc
commit 64f0c86510
7 changed files with 220 additions and 22 deletions

View File

@ -1,4 +1,30 @@
#!/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.
OFED_DEBS_DIR=/opt/ofed/MLNX_OFED/DEBS
# Set mlnx scripts to run on boot
sed -i '1a\$(init_mlnx.sh > \/dev\/null 2>\&1) \&\n' /etc/rc.local
if [ ! -z $1 ]; then
sed -i '1a\export FORCE_LINK_TYPE=true' /etc/rc.local
sed -i "1a\export LINK_TYPE=$1" /etc/rc.local
fi
# Install required packages
dpkg -i ${OFED_DEBS_DIR}/mlnx-ofed-kernel-utils*.deb
dpkg -i ${OFED_DEBS_DIR}/mlnx-ofed-kernel-dkms*.deb
exit 0

View File

@ -0,0 +1,19 @@
#!/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.
/opt/mellanox_init.sh 2
exit 0

View File

@ -0,0 +1,19 @@
#!/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.
/opt/mellanox_init.sh 1
exit 0

View File

@ -121,6 +121,9 @@ function update(){
\rm /etc/modprobe.d/ml*_core.conf
\rm /etc/modprobe.d/ib_ipoib.conf
# Ensure FW updated
mlnx_fw_upgrade
# Ensure eth_ipoib module
if ! lsmod | grep -wq eth_ipoib
then

View File

@ -0,0 +1,97 @@
#!/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=31
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
dpkg -i /opt/ofed/MLNX_OFED/DEBS/mlnx-fw-updater*.deb >> $LOG_FILE
fi
# Set ConnectX-4 FW
if which mst; then
echo "Enabling SR-IOV in FW" >> $LOG_FILE
mst start >> $LOG_FILE
mlxconfig -d /dev/mst/mt4115_pciconf0 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/mst/mt4115_pciconf0 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/mst/mt4115_pciconf0 -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/mst/mt4115_pciconf0 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/mst/mt4115_pciconf0 -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/mst/mt4115_pciconf0 -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

View File

@ -48,7 +48,6 @@ function download {
fi
}
function get_packages() {
file_type=$1
old_packages=$2
@ -59,26 +58,11 @@ function get_packages() {
done
}
old_rpms="${PLUGIN_DIR}/repositories/centos/Packages/*.rpm"
rpm_files="cirros-testvm-mellanox-0.3.2-1.mira3.x86_64.rpm
cirros-testvm-mellanox-ib-0.3.2-7.el6.x86_64.rpm
eswitchd-0.11-5.el6.x86_64.rpm
mlnx-dnsmasq-2014.2.2-1.noarch.rpm
mlnx-ofed-fuel-2.3-2.0.8.el6.x86_64.rpm
redhat-rpm-config-9.0.3-42.el6.centos.noarch.rpm"
#get_packages "rpm" "$old_rpms" "$rpm_files" # CentOS is not supported in 7.0
old_debs="${PLUGIN_DIR}/repositories/ubuntu/*.deb"
deb_files="cirros-testvm-mellanox_0.3.2-ubuntu3_amd64.deb
cirros-testvm-mellanox-ib_0.3.2-9_amd64.deb
eswitchd_1.0.0-18_amd64.deb
mlnx-ofed-fuel_3.2-2.0.0.0_amd64.deb
mlnx-ofed-kernel-dkms_3.1-OFED.3.1.1.0.3.1.g9032737_all.deb
mlnx-ofed-kernel-utils_3.1-OFED.3.1.1.0.3.1.g9032737_amd64.deb
lldpd_0.9.1-0_amd64.deb
python-networking-mlnx_7.0.0-1_all.deb"
get_packages "deb" "$old_debs" "$deb_files"
bootstrap_dir="${PLUGIN_DIR}/bootstrap/"
bootstrap_files="initrd_mlnx_mos*"
get_packages "bootstrap" "$bootstrap_dir/$bootstrap_files" "$bootstrap_files"

View File

@ -1,4 +1,18 @@
#!/usr/bin/env python
# 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.
import yaml
import os
@ -6,15 +20,40 @@ import time
import subprocess
import sys
# Verify input
if len(sys.argv) > 1 and (sys.argv[1] == 'eth' or sys.argv[1] == 'ib' or \
sys.argv[1] == 'default_link_type' ):
if 'default_link_type' in sys.argv[1]:
link_type = 'eth'
else:
link_type = "_%s" % sys.argv[1]
elif len(sys.argv) == 1:
link_type = ""
else:
basename = os.path.basename(sys.argv[0])
print "Wrong usage."
print "Usage: %s <link_type>" % basename
print " Valid link type: eth,ib"
print " option 1: %s" % basename
print " option 2: %s eth" % basename
print " option 3: %s ib" % basename
print " option 4: %s default_link_type" % basename
exit(1)
# Set variables
plugin = subprocess.Popen("echo /var/www/nailgun/plugins/mellanox-plugin-*/ " +
"| tr '/' '\n' | grep mellanox-plugin | tr -d '\n' ",
"| tr '/' '\n' | grep mellanox-plugin | tr -d '\n' ",
shell=True, stdout=subprocess.PIPE).stdout.read()
plugin_uri = "http://127.0.0.1:8080/plugins/%s/repositories/ubuntu/" % plugin
current_time = time.strftime("%d_%m_%y_%H_%M")
# Set fuel-bootstrap yaml and build image
with open("/etc/fuel-bootstrap-cli/fuel_bootstrap_cli.yaml", 'r') as stream:
fuel_bootstrap_config = yaml.load(stream)
override = False
repos_names = [repo['name'] for repo in fuel_bootstrap_config['repos']]
# Verify Mellanox repo
if 'mlnx' not in repos_names:
fuel_bootstrap_config['repos'].append({'priority': 1100,
'name': 'mlnx',
@ -22,14 +61,25 @@ with open("/etc/fuel-bootstrap-cli/fuel_bootstrap_cli.yaml", 'r') as stream:
'section': None,
'type': 'deb',
'uri': plugin_uri})
override = True
# Verify SR-IOV capabilities
if 'intel_iommu=on' not in fuel_bootstrap_config['extend_kopts']:
fuel_bootstrap_config['extend_kopts'] = fuel_bootstrap_config['extend_kopts'] \
+ ' intel_iommu=on'
override = True
# Override fuel bootstrap yaml if needed
if override:
with open("/etc/fuel-bootstrap-cli/fuel_bootstrap_cli.yaml", "w") as f:
yaml.dump(fuel_bootstrap_config, f)
extra_packages = "\'mlnx-ofed-kernel-dkms\'"
extra_packages = ['mlnx-ofed-fuel', 'python-libxml2', 'lsof']
packages = ''.join(['--package %s ' % p for p in extra_packages])
extra_dir = "/var/www/nailgun/plugins/%s/bootstrap/sync" % plugin
cmd = "fuel-bootstrap build --debug --package {0} --extra-dir {1} \
--label 'bootstrap_with_ofed_{2}' \
cmd = "fuel-bootstrap build --debug {0} --extra-dir {1} \
--label 'bootstrap_with_ofed{3}_{2}' \
--output-dir /tmp/ \
--script {1}/opt/mellanox_init.sh \
--activate".format(extra_packages, extra_dir, current_time)
--script {1}/opt/mellanox_init{3}.sh \
--activate".format(packages, extra_dir, current_time, link_type)
os.system(cmd)