22# This script is based on qatlib's qat_init.sh
33NODE_NAME=" ${NODE_NAME:- } "
44ENABLED_QAT_PF_PCIIDS=${ENABLED_QAT_PF_PCIIDS:- 37c8 4940 4942 4944 4946}
5- DEVS=$( for pf in $ENABLED_QAT_PF_PCIIDS ; do lspci -n | grep -e " $pf " | grep -o -e " ^\\ S*" ; done)
65SERVICES_LIST=" sym asym sym;asym dc sym;dc asym;dc"
76QAT_4XXX_DEVICE_PCI_ID=" 0x4940"
87QAT_401XX_DEVICE_PCI_ID=" 0x4942"
@@ -11,6 +10,15 @@ QAT_420XX_DEVICE_PCI_ID="0x4946"
1110SERVICES_ENABLED=" NONE"
1211SERVICES_ENABLED_FOUND=" FALSE"
1312
13+ DEVS=" "
14+ for DEV in $( realpath /sys/bus/pci/devices/* ) ; do
15+ for PF in $ENABLED_QAT_PF_PCIIDS ; do
16+ if grep -q " $PF " " $DEV " /device; then
17+ DEVS=" $DEVS $DEV "
18+ fi
19+ done
20+ done
21+
1422check_config () {
1523 [ -f " conf/qat.conf" ] && SERVICES_ENABLED=$( grep " ^ServicesEnabled=" conf/qat.conf | cut -d= -f 2 | grep ' \S' )
1624 [ -f " conf/qat-$NODE_NAME .conf" ] && SERVICES_ENABLED=$( grep " ^ServicesEnabled=" conf/qat-" $NODE_NAME " .conf | cut -d= -f 2 | grep ' \S' )
@@ -29,8 +37,7 @@ check_config() {
2937
3038sysfs_config () {
3139 if [ " $SERVICES_ENABLED_FOUND " = " TRUE" ]; then
32- for dev in $DEVS ; do
33- DEVPATH=" /sys/bus/pci/devices/0000:$dev "
40+ for DEVPATH in $DEVS ; do
3441 PCI_DEV=$( cat " $DEVPATH " /device 2> /dev/null)
3542 if [ " $PCI_DEV " != " $QAT_4XXX_DEVICE_PCI_ID " ] && [ " $PCI_DEV " != " $QAT_401XX_DEVICE_PCI_ID " ] && [ " $PCI_DEV " != " $QAT_402XX_DEVICE_PCI_ID " ] && [ " $PCI_DEV " != " $QAT_420XX_DEVICE_PCI_ID " ]; then
3643 continue
@@ -45,14 +52,13 @@ sysfs_config() {
4552 echo " $SERVICES_ENABLED " > " $DEVPATH " /qat/cfg_services
4653 CURRENT_SERVICES=$( cat " $DEVPATH " /qat/cfg_services)
4754 fi
48- echo " Device $dev configured with services: $CURRENT_SERVICES "
55+ echo " Device $DEVPATH configured with services: $CURRENT_SERVICES "
4956 done
5057 fi
5158}
5259
5360enable_sriov () {
54- for dev in $DEVS ; do
55- DEVPATH=" /sys/bus/pci/devices/0000:$dev "
61+ for DEVPATH in $DEVS ; do
5662 NUMVFS=" $DEVPATH /sriov_numvfs"
5763 if ! test -w " $NUMVFS " ; then
5864 echo " error: $NUMVFS is not found or not writable. Check if QAT driver module is loaded"
0 commit comments