Skip to content

Commit

Permalink
Merge pull request #1852 from hj-johannes-lee/PR-2024-006
Browse files Browse the repository at this point in the history
 qat, initcontainer: add enablement of auto_reset
  • Loading branch information
hj-johannes-lee authored Oct 2, 2024
2 parents 4410cd3 + 51b7745 commit e2a82e8
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 4 deletions.
3 changes: 2 additions & 1 deletion build/docker/intel-qat-initcontainer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@ LABEL summary='Intel® QAT initcontainer for Kubernetes'
LABEL description='Intel QAT initcontainer initializes devices'
COPY --from=builder /install_root /
COPY demo/qat-init.sh /usr/local/bin/
COPY demo/qat-autoreset.sh /usr/local/bin/
WORKDIR /qat-init
ENTRYPOINT ["/usr/local/bin/qat-init.sh"]
ENTRYPOINT ["bash", "-c", "/usr/local/bin/qat-init.sh && /usr/local/bin/qat-autoreset.sh"]
4 changes: 3 additions & 1 deletion build/docker/templates/intel-qat-initcontainer.Dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ COPY --from=builder /install_root /

COPY demo/qat-init.sh /usr/local/bin/

COPY demo/qat-autoreset.sh /usr/local/bin/

WORKDIR /qat-init

ENTRYPOINT ["/usr/local/bin/qat-init.sh"]
ENTRYPOINT ["bash", "-c", "/usr/local/bin/qat-init.sh && /usr/local/bin/qat-autoreset.sh"]
1 change: 1 addition & 0 deletions cmd/qat_plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ In addition to the default configuration, you can add device-specific configurat
| Device | Possible Configuration | How To Customize | Options | Notes |
|:-------|:-----------------------|:-----------------|:--------|:------|
| 4xxx, 401xx, 402xx, 420xx | [cfg_services](https://github.com/torvalds/linux/blob/v6.6-rc5/Documentation/ABI/testing/sysfs-driver-qat) reports the configured services (crypto services or compression services) of the QAT device. | `ServicesEnabled=<value>` | compress:`dc`, crypto:`sym;asym`, <br>crypto+compress:`asym;dc`,<br>crypto+compress:`sym;dc` | 4xxx/401xx/402xx: Linux 6.0+ kernel. 420xx: Linux 6.8+ kernel. |
| 4xxx, 401xx, 402xx, 420xx | [auto_reset](https://github.com/torvalds/linux/blob/a38297e3fb012ddfa7ce0321a7e5a8daeb1872b6/Documentation/ABI/testing/sysfs-driver-qat#L145) reports the setting of the QAT device's automatic error recovery functionality. | `AutoresetEnabled=<value>` | `on`, `off`, | Linux 6.8+ kernel. |

To create a provisioning `configMap`, run the following command before deploying initcontainer:

Expand Down
45 changes: 45 additions & 0 deletions demo/qat-autoreset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
NODE_NAME="${NODE_NAME:-}"
ENABLED_QAT_PF_PCIIDS=${ENABLED_QAT_PF_PCIIDS:-37c8 4940 4942 4944 4946}
DEVS=$(for pf in $ENABLED_QAT_PF_PCIIDS; do lspci -n | grep -e "$pf" | grep -o -e "^\\S*"; done)

AUTORESET_ENABLED="NONE"
AUTORESET_ENABLED_FOUND="FALSE"
AUTORESET_OPTIONS_LIST="on off"

check_config() {
[ -f "conf/qat.conf" ] && AUTORESET_ENABLED=$(grep "^AutoresetEnabled=" conf/qat.conf | cut -d= -f 2 | grep '\S')
[ -f "conf/qat-$NODE_NAME.conf" ] && AUTORESET_ENABLED=$(grep "^AutoresetEnabled=" conf/qat-"$NODE_NAME".conf | cut -d= -f 2 | grep '\S')

if [ "$AUTORESET_ENABLED" != "NONE" ]; then
AUTORESET_ENABLED_FOUND="FALSE"
for OPTION in $AUTORESET_OPTIONS_LIST
do
if [ "$OPTION" = "$AUTORESET_ENABLED" ]; then
AUTORESET_ENABLED_FOUND="TRUE"
break
fi
done
fi
}

enable_auto_reset() {
if [ "$AUTORESET_ENABLED_FOUND" = "TRUE" ]; then
for dev in $DEVS; do
devpath="/sys/bus/pci/devices/0000:$dev"
autoreset_path="$devpath/qat/auto_reset"
if ! test -w "$autoreset_path"; then
echo "error: $autoreset_path is not found or not writable. Check if QAT driver module is loaded. Skipping..."
exit 1
fi
if [ "$(cat "$autoreset_path")" = "$AUTORESET_ENABLED" ]; then
echo "$devpath's auto reset is already $AUTORESET_ENABLED"
else
echo "$AUTORESET_ENABLED" > "$autoreset_path" && echo "$devpath's auto reset has been set $AUTORESET_ENABLED"
fi
done
fi
}

check_config
enable_auto_reset
4 changes: 2 additions & 2 deletions demo/qat-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ SERVICES_ENABLED="NONE"
SERVICES_ENABLED_FOUND="FALSE"

check_config() {
[ -f "conf/qat.conf" ] && SERVICES_ENABLED=$(cut -d= -f 2 conf/qat.conf | grep '\S')
[ -f "conf/qat-$NODE_NAME.conf" ] && SERVICES_ENABLED=$(cut -d= -f 2 conf/qat-$NODE_NAME.conf | grep '\S')
[ -f "conf/qat.conf" ] && SERVICES_ENABLED=$(grep "^ServicesEnabled=" conf/qat.conf | cut -d= -f 2 | grep '\S')
[ -f "conf/qat-$NODE_NAME.conf" ] && SERVICES_ENABLED=$(grep "^ServicesEnabled=" conf/qat-"$NODE_NAME".conf | cut -d= -f 2 | grep '\S')

if [ "$SERVICES_ENABLED" != "NONE" ]; then
SERVICES_ENABLED_FOUND="FALSE"
Expand Down

0 comments on commit e2a82e8

Please sign in to comment.