intel-device-plugins-for-ku.../demo/dlb-init.sh
Mikko Ylinen e02c480ab7 images: use buildkit again
The Toybox images had two issues:

1. Distroless does not support /bin -> /usr/bin so we needed to
create it manually to get /bin/bash for Toybox. However, with this
Openshift image validation complains that we are touching the "base"
image.

2. We could not use buildkit since it fails with /bin symlink
copied over /bin directory from Distroless.

The simple fix is just to move away from all /bin/sh and /bin/bash
and use "/usr/bin/env bash" to resolve the path instead. This allows
to keep /bin untouched.

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2023-12-08 08:01:22 +02:00

52 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -u
enable_and_configure_vfs() {
devpath=$1
sriov_numvfs_path="$devpath/sriov_numvfs"
if ! test -w "$sriov_numvfs_path"; then
echo "$sriov_numvfs_path is not found or not writable. In case there is no configured VF yet, check if dlb driver module is loaded"
exit 0
fi
if [ "$(cat "$sriov_numvfs_path")" -ne 0 ]; then
echo "$devpath already configured"
exit 0
fi
# enable sriov
echo -n 1 > "$sriov_numvfs_path"
# configure vf
# unbind vf
vf_pciid=$(basename "$(realpath "$devpath/virtfn0")")
dlb_pci_driver_path=/sys/bus/pci/drivers/dlb2
echo -n "$vf_pciid" > $dlb_pci_driver_path/unbind
# assign resources to vf
vf_resources_path="$devpath/vf0_resources"
echo -n 2048 > "$vf_resources_path/num_atomic_inflights"
echo -n 2048 > "$vf_resources_path/num_dir_credits"
echo -n 8 > "$vf_resources_path/num_dir_ports"
echo -n 2048 > "$vf_resources_path/num_hist_list_entries"
echo -n 8192 > "$vf_resources_path/num_ldb_credits"
echo -n 4 > "$vf_resources_path/num_ldb_ports"
echo -n 32 > "$vf_resources_path/num_ldb_queues"
echo -n 32 > "$vf_resources_path/num_sched_domains"
echo -n 2 > "$vf_resources_path/num_sn0_slots"
echo -n 2 > "$vf_resources_path/num_sn1_slots"
# bind vf back to dlb2 driver
echo -n "$vf_pciid" > $dlb_pci_driver_path/bind
echo "$devpath configured"
# TODO: Due to unknown e2e-dlb (Simics) limitations, it is not possible to configure per VF resources based on values
# reported in /sys/bus/pci/devices/<dev_name>/total_resources/<resource_name>. Therefore, only one VF with
# values known to work is enabled. This will be improved in the future to make the scrip more meaningful for real-world
# deployments (see #1145).
}
# use first dlb device to configure a vf
DEVPATH=$(realpath /sys/bus/pci/drivers/dlb2/????:??:??\.0 | head -1)
enable_and_configure_vfs "$DEVPATH"