aboutsummaryrefslogtreecommitdiffstats
path: root/kud/deployment_infra/playbooks/install_iavf_drivers.sh
diff options
context:
space:
mode:
authorAkhila Kishore <akhila.kishore@intel.com>2019-11-11 22:57:39 -0800
committerAkhila Kishore <akhila.kishore@intel.com>2019-11-13 15:17:57 -0800
commitf18b84fb5cb2bbb7e95e346fc74e84368ffcc78e (patch)
treef2c740611eb7301b821d9300cddd9193283b3fa8 /kud/deployment_infra/playbooks/install_iavf_drivers.sh
parentb0f94ada2751713ea8d62c235d0bc1cc2877034a (diff)
Updating sriov playbook to meet requirements of updated device
Previous sriov playbook supported X710 SRIOV NIC. Updating the scripts to support new device XL710. Other changes include syntactical corrections to "WHEN" condition in ansible. Co-authored-by: hle2 <huifeng.le@intel.com> Signed-off-by: Akhila Kishore <akhila.kishore@intel.com> Issue-ID: MULTICLOUD-929 Change-Id: I697a49a64472ad2d755753e58f8fd4e7857b0456
Diffstat (limited to 'kud/deployment_infra/playbooks/install_iavf_drivers.sh')
-rwxr-xr-xkud/deployment_infra/playbooks/install_iavf_drivers.sh47
1 files changed, 42 insertions, 5 deletions
diff --git a/kud/deployment_infra/playbooks/install_iavf_drivers.sh b/kud/deployment_infra/playbooks/install_iavf_drivers.sh
index d44483de..7a54e9f2 100755
--- a/kud/deployment_infra/playbooks/install_iavf_drivers.sh
+++ b/kud/deployment_infra/playbooks/install_iavf_drivers.sh
@@ -3,6 +3,10 @@
# Based on:
# https://gerrit.akraino.org/r/#/c/icn/+/1359/1/deploy/kud-plugin-addons/device-plugins/sriov/driver/install_iavf_drivers.sh
+nic_models=(XL710 X722)
+nic_drivers=(i40e)
+device_checkers=(is_not_used is_driver_match is_model_match)
+
function install_iavf_driver {
local ifname=$1
@@ -27,22 +31,55 @@ function install_iavf_driver {
echo '8' > /sys/class/net/$ifname/device/sriov_numvfs
}
-function is_used {
+function is_not_used {
local ifname=$1
route_info=`ip route show | grep $ifname`
if [ -z "$route_info" ]; then
- return 0
- else
return 1
+ else
+ return 0
+ fi
+}
+
+function is_driver_match {
+ local ifname=$1
+ driver=`cat /sys/class/net/$ifname/device/uevent | grep DRIVER | cut -f2 -d "="`
+ if [ ! -z "$driver" ]; then
+ for nic_driver in ${nic_drivers[@]}; do
+ if [ "$driver" = "$nic_driver" ]; then
+ return 1
+ fi
+ done
+ fi
+ return 0
+}
+
+function is_model_match {
+ local ifname=$1
+ pci_addr=`cat /sys/class/net/$ifname/device/uevent | grep PCI_SLOT_NAME | cut -f2 -d "=" | cut -f2,3 -d ":"`
+ if [ ! -z "$pci_addr" ]; then
+ for nic_model in ${nic_models[@]}; do
+ model_match=$(lspci | grep $pci_addr | grep $nic_model)
+ if [ ! -z "$model_match" ]; then
+ return 1
+ fi
+ done
fi
+ return 0
}
function get_sriov_ifname {
for net_device in /sys/class/net/*/ ; do
if [ -e $net_device/device/sriov_numvfs ] ; then
ifname=$(basename $net_device)
- is_used $ifname
- if [ "$?" = "0" ]; then
+ for device_checker in ${device_checkers[@]}; do
+ eval $device_checker $ifname
+ if [ "$?" = "0" ]; then
+ ifname=""
+ break
+ fi
+ done
+ if [ ! -z "$ifname" ]; then
echo $ifname
return
fi