-
Notifications
You must be signed in to change notification settings - Fork 216
add vfio based devices to DSA #2194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: dpdk-vfio | ||
| spec: | ||
| restartPolicy: Never | ||
| containers: | ||
| - name: dpdk-vfio | ||
| image: intel/dsa-dpdk-dmadevtest:devel | ||
| command: | ||
| - dpdk-test | ||
| args: | ||
| - -a | ||
| - $(VFIO_BDF0) | ||
| - dmadev_autotest | ||
| securityContext: | ||
| capabilities: | ||
| add: ["IPC_LOCK"] | ||
| drop: ["ALL"] | ||
| volumeMounts: | ||
| - mountPath: /mnt/hugepage | ||
| name: hugepage | ||
| resources: | ||
| requests: | ||
| hugepages-2Mi: 64Mi | ||
| memory: 128Mi | ||
| dsa.intel.com/vfio: 1 | ||
| limits: | ||
| hugepages-2Mi: 64Mi | ||
| memory: 128Mi | ||
| dsa.intel.com/vfio: 1 | ||
| volumes: | ||
| - name: hugepage | ||
| emptyDir: | ||
| medium: HugePages |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,7 +3,9 @@ | |||||
| set -euo pipefail | ||||||
|
|
||||||
| DEV="${DEVICE_TYPE:-dsa}" | ||||||
| DSA_DRIVER=${DSA_DRIVER:-idxd} | ||||||
| NODE_NAME="${NODE_NAME:-}" | ||||||
| DSA_PCI_IDS=${DSA_PCI_IDS:-0b25 11fb 1212} | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This cannot be set via the operator. But QAT's device id listing is similar so it can be left as a future improvement idea.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact, with QAT this is configurable (based on what user sets as the kernelvfdrivers).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kernel drivers are configurable: https://github.com/intel/intel-device-plugins-for-kubernetes/blob/main/pkg/apis/deviceplugin/v1/qatdeviceplugin_types.go#L55
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is (only) done through the operator: intel-device-plugins-for-kubernetes/pkg/controllers/qat/controller.go Lines 224 to 225 in 839fe47
|
||||||
| OPT="" | ||||||
| [ "$DEV" != "dsa" ] && OPT="-v" | ||||||
|
|
||||||
|
|
@@ -14,6 +16,40 @@ function cmd() { | |||||
| "${@}" | ||||||
| } | ||||||
|
|
||||||
| function bind_driver() { | ||||||
| NEW_DRIVER=$1 | ||||||
| DSA_PFS=$2 | ||||||
|
|
||||||
| DEVS="" | ||||||
| for DEV in $(realpath /sys/bus/pci/devices/*); do | ||||||
| for PF in $DSA_PFS; do | ||||||
| if grep -q "$PF" "$DEV"/device; then | ||||||
| DEVS="$DEV $DEVS" | ||||||
| fi | ||||||
| done | ||||||
| done | ||||||
|
|
||||||
| for D in $DEVS; do | ||||||
| BSF=$(basename "$D") | ||||||
| if [ -e "$D/driver" ]; then | ||||||
| P=$(realpath -L "$D/driver") | ||||||
| DRIVER=$(basename "$P") | ||||||
| else | ||||||
| DRIVER="" | ||||||
| fi | ||||||
|
|
||||||
| if [ "$DRIVER" != "$NEW_DRIVER" ]; then | ||||||
| if [ -n "$DRIVER" ]; then | ||||||
| echo -n "$BSF" >/sys/bus/pci/drivers/"$DRIVER"/unbind | ||||||
| fi | ||||||
| echo -n "$NEW_DRIVER" >/sys/bus/pci/devices/"$BSF"/driver_override | ||||||
| echo -n "$BSF" >/sys/bus/pci/drivers/"$NEW_DRIVER"/bind | ||||||
| fi | ||||||
| done | ||||||
| } | ||||||
|
|
||||||
| [[ "$DEV" == "dsa" && -e /sys/bus/pci/drivers/"$DSA_DRIVER" ]] && bind_driver "$DSA_DRIVER" "$DSA_PCI_IDS" | ||||||
|
|
||||||
| for i in $(accel-config list | jq -r '.[].dev' | grep ${OPT} "dsa"); do | ||||||
|
|
||||||
| cmd accel-config disable-device "$i" | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| - op: add | ||
| path: /spec/template/spec/containers/0/volumeMounts/- | ||
| value: | ||
| name: devfs-vfio | ||
| mountPath: /dev/vfio | ||
| - op: add | ||
| path: /spec/template/spec/volumes/- | ||
| value: | ||
| name: devfs-vfio | ||
| hostPath: | ||
| path: /dev/vfio |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| - op: add | ||
| path: /spec/template/spec/containers/0/args | ||
| value: | ||
| - "-driver=vfio-pci" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| apiVersion: apps/v1 | ||
| kind: DaemonSet | ||
| metadata: | ||
| name: intel-dsa-plugin | ||
| spec: | ||
| template: | ||
| spec: | ||
| initContainers: | ||
| - name: intel-idxd-config-initcontainer | ||
| env: | ||
| - name: NODE_NAME | ||
| valueFrom: | ||
| fieldRef: | ||
| fieldPath: spec.nodeName | ||
| - name: DSA_DRIVER | ||
| value: vfio-pci | ||
| image: intel/intel-idxd-config-initcontainer:devel | ||
| securityContext: | ||
| seLinuxOptions: | ||
| type: "container_device_plugin_init_t" | ||
| readOnlyRootFilesystem: true | ||
| privileged: true | ||
| volumeMounts: | ||
| - mountPath: /sys/bus/dsa | ||
| name: sys-bus-dsa | ||
| - mountPath: /sys/devices | ||
| name: sys-devices | ||
| - mountPath: /idxd-init/scratch | ||
| name: scratch | ||
| volumes: | ||
| - name: sys-bus-dsa | ||
| hostPath: | ||
| path: /sys/bus/dsa | ||
| - name: sys-devices | ||
| hostPath: | ||
| path: /sys/devices | ||
| - name: scratch | ||
| emptyDir: {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| resources: | ||
| - ../../base | ||
| apiVersion: kustomize.config.k8s.io/v1beta1 | ||
| kind: Kustomization | ||
| patches: | ||
| - path: dsa_initcontainer.yaml | ||
| - path: driver_args.yaml | ||
| target: | ||
| kind: DaemonSet | ||
| - path: devfs_path.yaml | ||
| target: | ||
| kind: DaemonSet |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,10 @@ type DsaDevicePluginSpec struct { | |
| // ProvisioningConfig is a ConfigMap used to pass the DSA devices and workqueues configuration into idxd-config initcontainer. | ||
| ProvisioningConfig string `json:"provisioningConfig,omitempty"` | ||
|
|
||
| // Driver name used for the DSA devices. | ||
| // +kubebuilder:validation:Enum=idxd;vfio-pci | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could also have |
||
| Driver string `json:"driver,omitempty"` | ||
|
|
||
| // Specialized nodes (e.g., with accelerators) can be Tainted to make sure unwanted pods are not scheduled on them. Tolerations can be set for the plugin pod to neutralize the Taint. | ||
| Tolerations []v1.Toleration `json:"tolerations,omitempty"` | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: as sharedDevNum is not supported with vfio-pci mode, plugin should warn/error if it's set. Maybe the same could be added to the validation webhook also.