diff options
Diffstat (limited to 'kud/deployment_infra/playbooks/install_iavf_drivers.sh')
-rwxr-xr-x | kud/deployment_infra/playbooks/install_iavf_drivers.sh | 47 |
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 |