intel-device-plugins-for-ku.../demo/qat-init.sh
Hyeongju Johannes Lee b82d508150 qat: fix initcontainer to skip when sriov is already configured
Signed-off-by: Hyeongju Johannes Lee <hyeongju.lee@intel.com>
2022-10-19 20:15:34 +03:00

18 lines
554 B
Bash
Executable File

#!/bin/sh -eu
ENABLED_QAT_PF_PCIIDS=${ENABLED_QAT_PF_PCIIDS:-37c8 4940 4942}
DEVS=$(for pf in $ENABLED_QAT_PF_PCIIDS; do lspci -n | grep -e "$pf" | grep -o -e "^\\S*"; done)
for dev in $DEVS; do
DEVPATH="/sys/bus/pci/devices/0000:$dev"
NUMVFS="$DEVPATH/sriov_numvfs"
if ! test -w "$NUMVFS"; then
echo "error: $NUMVFS is not found or not writable. Check if QAT driver module is loaded"
exit 1
fi
if [ "$(cat "$NUMVFS")" -ne 0 ]; then
echo "$DEVPATH already configured"
else
tee "$NUMVFS" < "$DEVPATH/sriov_totalvfs"
fi
done