Skip to content

Commit 10a26b8

Browse files
authored
Merge pull request #1234 from hj-johannes-lee/qat-cfgServices
qat: add configuration of cfgServices to qat initcontainer
2 parents 3c11640 + a6037ea commit 10a26b8

File tree

17 files changed

+223
-18
lines changed

17 files changed

+223
-18
lines changed

build/docker/intel-qat-initcontainer.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,5 @@ LABEL summary='Intel® QAT initcontainer for Kubernetes'
6262
LABEL description='Intel QAT initcontainer initializes devices'
6363
COPY --from=builder /install_root /
6464
COPY demo/qat-init.sh /usr/local/bin/
65+
WORKDIR /qat-init
6566
ENTRYPOINT [ "/bin/bash", "/usr/local/bin/qat-init.sh"]

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ COPY --from=builder /install_root /
2121

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

24+
WORKDIR /qat-init
25+
2426
ENTRYPOINT [ "/bin/bash", "/usr/local/bin/qat-init.sh"]

build/docker/toybox-config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Automatically generated make config: don't edit
33
# ToyBox version: KCONFIG_VERSION
4-
# Tue Oct 11 13:47:43 2022
4+
# Thu Nov 17 14:23:21 2022
55
#
66
# CONFIG_TOYBOX_ON_ANDROID is not set
77
CONFIG_TOYBOX_FORK=y
@@ -23,7 +23,7 @@ CONFIG_CP=y
2323
# CONFIG_MV is not set
2424
# CONFIG_INSTALL is not set
2525
# CONFIG_CPIO is not set
26-
# CONFIG_CUT is not set
26+
CONFIG_CUT=y
2727
# CONFIG_DATE is not set
2828
# CONFIG_DF is not set
2929
# CONFIG_DIRNAME is not set

cmd/qat_plugin/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,34 @@ $ kubectl apply -k https://github.com/intel/intel-device-plugins-for-kubernetes/
120120
> socket creation and kubelet registration. Furthermore, the deployments `securityContext` must
121121
> be configured with appropriate `runAsUser/runAsGroup`.
122122
123+
#### Automatic Provisioning
124+
125+
There's a sample [qat initcontainer](https://github.com/intel/intel-device-plugins-for-kubernetes/blob/main/build/docker/intel-qat-initcontainer.Dockerfile). Regardless of device types, the script running inside the initcontainer enables QAT SR-IOV VFs.
126+
127+
To deploy, run as follows:
128+
129+
```bash
130+
$ kubectl apply -k deployments/qat_plugin/overlays/qat_initcontainer/
131+
```
132+
133+
In addition to the default configuration, you can add device-specific configurations via ConfigMap.
134+
135+
| Device | Possible Configuration | How To Customize | Options | Notes |
136+
|:-------|:-----------------------|:-----------------|:--------|:------|
137+
| 4xxx, 401xx | [cfg_services](https://github.com/torvalds/linux/blob/42e66b1cc3a070671001f8a1e933a80818a192bf/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` | Linux 6.0+ kernel is required. |
138+
139+
To create a provisioning config after customizing, run as follows:
140+
141+
```bash
142+
$ kubectl create configmap --namespace=inteldeviceplugins-system qat-config --from-file=deployments/qat_plugin/overlays/qat_initcontainer/qat.conf
143+
```
144+
> **Note**: When deploying the overlay qat_initcontainer, such a manual creation is not necessary since ConfigMap is generated automatically. Just set the values in the config file and deploy the overlay.
145+
146+
When using the operator for deploying the plugin with provisioning config, use `provisioningConfig` field for the name of the ConfigMap, then the config is passed to initcontainer through the volume mount.
147+
148+
There's also a possibility for a node specific congfiguration through passing a nodename via `NODE_NAME` into initcontainer's environment and passing a node specific profile (`qat-$NODE_NAME.conf`) via ConfigMap volume mount.
149+
150+
123151
#### Verify Plugin Registration
124152

125153
Verification of the plugin deployment and detection of QAT hardware can be confirmed by

demo/qat-init.sh

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,55 @@
1-
#!/bin/sh -eu
1+
#!/bin/sh
2+
# This script is based on qatlib's qat_init.sh
3+
NODE_NAME="${NODE_NAME:-}"
24
ENABLED_QAT_PF_PCIIDS=${ENABLED_QAT_PF_PCIIDS:-37c8 4940 4942}
35
DEVS=$(for pf in $ENABLED_QAT_PF_PCIIDS; do lspci -n | grep -e "$pf" | grep -o -e "^\\S*"; done)
6+
SERVICES_LIST="sym;asym dc"
7+
QAT_4XXX_DEVICE_PCI_ID="0x4940"
8+
QAT_401XX_DEVICE_PCI_ID="0x4942"
9+
SERVICES_ENABLED="NONE"
10+
SERVICES_ENABLED_FOUND="FALSE"
411

5-
for dev in $DEVS; do
12+
check_config() {
13+
[ -f "conf/qat.conf" ] && SERVICES_ENABLED=$(cut -d= -f 2 conf/qat.conf | grep '\S')
14+
[ -f "conf/qat-$NODE_NAME.conf" ] && SERVICES_ENABLED=$(cut -d= -f 2 conf/qat-$NODE_NAME.conf | grep '\S')
15+
16+
if [ "$SERVICES_ENABLED" != "NONE" ]; then
17+
SERVICES_ENABLED_FOUND="FALSE"
18+
for SERVICE in $SERVICES_LIST
19+
do
20+
if [ "$SERVICE" = "$SERVICES_ENABLED" ]; then
21+
SERVICES_ENABLED_FOUND="TRUE"
22+
break
23+
fi
24+
done
25+
fi
26+
}
27+
28+
sysfs_config() {
29+
if [ "$SERVICES_ENABLED_FOUND" = "TRUE" ]; then
30+
for dev in $DEVS; do
31+
DEVPATH="/sys/bus/pci/devices/0000:$dev"
32+
PCI_DEV=$(cat "$DEVPATH"/device 2> /dev/null)
33+
if [ "$PCI_DEV" != "$QAT_4XXX_DEVICE_PCI_ID" ] && [ "$PCI_DEV" != "$QAT_401XX_DEVICE_PCI_ID" ]; then
34+
continue
35+
fi
36+
37+
CURRENT_SERVICES=$(cat "$DEVPATH"/qat/cfg_services)
38+
if [ "$CURRENT_SERVICES" != "$SERVICES_ENABLED" ]; then
39+
CURRENT_STATE=$(cat "$DEVPATH"/qat/state)
40+
if [ "$CURRENT_STATE" = "up" ]; then
41+
echo down > "$DEVPATH"/qat/state
42+
fi
43+
echo "$SERVICES_ENABLED" > "$DEVPATH"/qat/cfg_services
44+
CURRENT_SERVICES=$(cat "$DEVPATH"/qat/cfg_services)
45+
fi
46+
echo "Device $dev configured with services: $CURRENT_SERVICES"
47+
done
48+
fi
49+
}
50+
51+
enable_sriov() {
52+
for dev in $DEVS; do
653
DEVPATH="/sys/bus/pci/devices/0000:$dev"
754
NUMVFS="$DEVPATH/sriov_numvfs"
855
if ! test -w "$NUMVFS"; then
@@ -14,4 +61,9 @@ for dev in $DEVS; do
1461
else
1562
tee "$NUMVFS" < "$DEVPATH/sriov_totalvfs"
1663
fi
17-
done
64+
done
65+
}
66+
67+
check_config
68+
sysfs_config
69+
enable_sriov

deployments/operator/crd/bases/deviceplugin.intel.com_qatdeviceplugins.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ spec:
102102
- balanced
103103
- packed
104104
type: string
105+
provisioningConfig:
106+
description: ProvisioningConfig is a ConfigMap used to pass the configuration
107+
of QAT devices into qat initcontainer.
108+
type: string
105109
type: object
106110
status:
107111
description: 'QatDevicePluginStatus defines the observed state of QatDevicePlugin.

deployments/qat_plugin/base/intel-qat-plugin.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ spec:
1616
automountServiceAccountToken: false
1717
containers:
1818
- name: intel-qat-plugin
19+
env:
20+
- name: NODE_NAME
21+
valueFrom:
22+
fieldRef:
23+
fieldPath: spec.nodeName
1924
image: intel/intel-qat-plugin:devel
2025
securityContext:
2126
seLinuxOptions:

deployments/qat_plugin/overlays/e2e/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ commonAnnotations:
33
container.apparmor.security.beta.kubernetes.io/intel-qat-plugin: unconfined
44

55
resources:
6-
- ../sriov_numvfs
6+
- ../qat_initcontainer
77

88
patches:
99
- path: add-args.yaml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
bases:
2+
- ../../base
3+
patchesStrategicMerge:
4+
- qat_initcontainer.yaml
5+
configMapGenerator:
6+
- name: qat-config
7+
files:
8+
- qat.conf
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ServicesEnabled=sym;asym

0 commit comments

Comments
 (0)