#!/bin/bash

# source /ucloud/exports.ini

# BF 1st Generation -->MT416842.
# BF 2nd Generation -->MT4282.But you will see mst devices's name is 'mt41686_pciconf0' on system.
Card_Info=$(lspci -nn -d 15b3::0604 )
if [[ $Card_Info =~ "MT416842" ]];then
    NetDev_1="/dev/mst/mt41682_pciconf0"
elif [[ $Card_Info =~ "MT42822" ]];then
    NetDev_1="/dev/mst/mt41686_pciconf0"
elif [[ $Card_Info =~ "MT43244" ]];then
    NetDev_1="/dev/mst/mt41692_pciconf0"
fi

_install(){
    return 0
}

_check() {
    _check="PASS"

    if [[ $BFFLAG = 1 ]];then
        mst restart
        if mlxconfig -d "$NetDev_1" query|grep -q "SEPERATED_HOST(0)";then
            _check="FAIL"
            PRINT_ERR "NIC is Pass-through mode, Please check! 网卡处于直通模式，请检查！"
        fi
    fi
}

