test: Use lspci to discover default kernel drivers

Instead of searching /sys for devices and checking which
driver happens to be loaded, use lspci. The lspci tool is
a bit smarter - it knows which driver is loaded now but
also which driver is the default driver the kernel wants
to load for that type of device. It's that default that
we need.

Change-Id: I1dc01ab6eac233e85f42316567bde2f4ed2203c6
Signed-off-by: Liang Yan <liang.z.yan@intel.com>
This commit is contained in:
Liang Yan 2016-11-01 22:36:41 +08:00 committed by Daniel Verkamp
parent dca887b7d8
commit e3580da167

View File

@ -40,7 +40,7 @@ function detect_mellanox_nics()
# for nvmf target loopback test, suppose we only have one type of card. # for nvmf target loopback test, suppose we only have one type of card.
for nvmf_nic_bdf in $nvmf_nic_bdfs for nvmf_nic_bdf in $nvmf_nic_bdfs
do do
result=`find /sys -name $nvmf_nic_bdf | grep driver | awk -F / '{ print $6 }'` result=`lspci -vvv -s $nvmf_nic_bdf | grep 'Kernel modules' | awk -F ' ' '{print $3}'`
if [ "$result" == "mlx5_core" ]; then if [ "$result" == "mlx5_core" ]; then
mlx_core_driver="mlx5_core" mlx_core_driver="mlx5_core"
mlx_ib_driver="mlx5_ib" mlx_ib_driver="mlx5_ib"