Skip to content

Commit e2a82e8

Browse files
Merge pull request #1852 from hj-johannes-lee/PR-2024-006
qat, initcontainer: add enablement of auto_reset
2 parents 4410cd3 + 51b7745 commit e2a82e8

File tree

5 files changed

+53
-4
lines changed

5 files changed

+53
-4
lines changed

build/docker/intel-qat-initcontainer.Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,6 @@ LABEL summary='Intel® QAT initcontainer for Kubernetes'
6464
LABEL description='Intel QAT initcontainer initializes devices'
6565
COPY --from=builder /install_root /
6666
COPY demo/qat-init.sh /usr/local/bin/
67+
COPY demo/qat-autoreset.sh /usr/local/bin/
6768
WORKDIR /qat-init
68-
ENTRYPOINT ["/usr/local/bin/qat-init.sh"]
69+
ENTRYPOINT ["bash", "-c", "/usr/local/bin/qat-init.sh && /usr/local/bin/qat-autoreset.sh"]

build/docker/templates/intel-qat-initcontainer.Dockerfile.in

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ COPY --from=builder /install_root /
2222

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

25+
COPY demo/qat-autoreset.sh /usr/local/bin/
26+
2527
WORKDIR /qat-init
2628

27-
ENTRYPOINT ["/usr/local/bin/qat-init.sh"]
29+
ENTRYPOINT ["bash", "-c", "/usr/local/bin/qat-init.sh && /usr/local/bin/qat-autoreset.sh"]

cmd/qat_plugin/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ In addition to the default configuration, you can add device-specific configurat
131131
| Device | Possible Configuration | How To Customize | Options | Notes |
132132
|:-------|:-----------------------|:-----------------|:--------|:------|
133133
| 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. |
134+
| 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. |
134135

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

demo/qat-autoreset.sh

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
NODE_NAME="${NODE_NAME:-}"
3+
ENABLED_QAT_PF_PCIIDS=${ENABLED_QAT_PF_PCIIDS:-37c8 4940 4942 4944 4946}
4+
DEVS=$(for pf in $ENABLED_QAT_PF_PCIIDS; do lspci -n | grep -e "$pf" | grep -o -e "^\\S*"; done)
5+
6+
AUTORESET_ENABLED="NONE"
7+
AUTORESET_ENABLED_FOUND="FALSE"
8+
AUTORESET_OPTIONS_LIST="on off"
9+
10+
check_config() {
11+
[ -f "conf/qat.conf" ] && AUTORESET_ENABLED=$(grep "^AutoresetEnabled=" conf/qat.conf | cut -d= -f 2 | grep '\S')
12+
[ -f "conf/qat-$NODE_NAME.conf" ] && AUTORESET_ENABLED=$(grep "^AutoresetEnabled=" conf/qat-"$NODE_NAME".conf | cut -d= -f 2 | grep '\S')
13+
14+
if [ "$AUTORESET_ENABLED" != "NONE" ]; then
15+
AUTORESET_ENABLED_FOUND="FALSE"
16+
for OPTION in $AUTORESET_OPTIONS_LIST
17+
do
18+
if [ "$OPTION" = "$AUTORESET_ENABLED" ]; then
19+
AUTORESET_ENABLED_FOUND="TRUE"
20+
break
21+
fi
22+
done
23+
fi
24+
}
25+
26+
enable_auto_reset() {
27+
if [ "$AUTORESET_ENABLED_FOUND" = "TRUE" ]; then
28+
for dev in $DEVS; do
29+
devpath="/sys/bus/pci/devices/0000:$dev"
30+
autoreset_path="$devpath/qat/auto_reset"
31+
if ! test -w "$autoreset_path"; then
32+
echo "error: $autoreset_path is not found or not writable. Check if QAT driver module is loaded. Skipping..."
33+
exit 1
34+
fi
35+
if [ "$(cat "$autoreset_path")" = "$AUTORESET_ENABLED" ]; then
36+
echo "$devpath's auto reset is already $AUTORESET_ENABLED"
37+
else
38+
echo "$AUTORESET_ENABLED" > "$autoreset_path" && echo "$devpath's auto reset has been set $AUTORESET_ENABLED"
39+
fi
40+
done
41+
fi
42+
}
43+
44+
check_config
45+
enable_auto_reset

demo/qat-init.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ SERVICES_ENABLED="NONE"
1212
SERVICES_ENABLED_FOUND="FALSE"
1313

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

1818
if [ "$SERVICES_ENABLED" != "NONE" ]; then
1919
SERVICES_ENABLED_FOUND="FALSE"

0 commit comments

Comments
 (0)