3 ### This may be a temporary file. Once DPDK is working stable in the nested
4 ### VM, and if and when ### we decide we want to do all testing with DPDK,
5 ### the steps executed here may become default configuration for the image.
7 ### For now, to give us the flexibility to work with and without DPDK, keep
8 ### this as a separate script.
10 DPDK_START_FILE="start-testpmd.sh"
11 DPDK_STOP_FILE="stop-testpmd.sh"
13 cat - > ${DPDK_START_FILE} <<"_EOF"
16 TARGET_DRIVER="igb_uio"
17 PATH_TO_IGB_UIO_MODULE="/usr/local/kmod/igb_uio.ko"
19 TESTPMD_LOG=/tmp/testpmd.log
20 TESTPMD_PID=/tmp/testpmd.pid
22 if [ -f ${TESTPMD_PID} ]
24 echo Testpmd is already running. Please stop running instance first.
25 echo Delete PID file ${TESTPMD_PID} if you are sure this is a stale PID file.
29 # Load igb_uio module if this is the driver we want to use
30 if [ "${TARGET_DRIVER}" = "igb_uio" ]
32 insmod ${PATH_TO_IGB_UIO_MODULE}
36 echo "vm.nr_hugepages = ${NUM_HUGEPAGES}" > /etc/sysctl.conf
37 echo "vm.swappiness = 0" >> /etc/sysctl.conf
38 echo "kernel.randomize_va_space = 0" >> /etc/sysctl.conf
41 grep -q hugetlbfs /etc/fstab || echo "hugetlbfs /mnt/huge hugetlbfs mode=1770,gid=2021 0 0" >> /etc/fstab
45 echo 1af4 1000 > /sys/bus/pci/drivers/${TARGET_DRIVER}/new_id
47 for dev in $(find /sys/bus/pci/drivers/virtio-pci -type l -name '*:*:*.*' | sed -e 's/.*\///')
49 class=$(cat /sys/bus/pci/drivers/virtio-pci/${dev}/class)
50 if [ "$class" = "0x020000" ]; then
51 echo Unbinding $dev from virtio-pci
52 echo $dev > /sys/bus/pci/drivers/virtio-pci/unbind
53 echo Binding $dev to ${TARGET_DRIVER}
54 echo $dev > /sys/bus/pci/drivers/${TARGET_DRIVER}/bind
58 # RCU and IRQ affinity
59 for i in $(ls /proc/irq/ | grep [0-9])
61 echo 1 > /proc/irq/$i/smp_affinity
63 echo 1 | sudo tee /sys/bus/workqueue/devices/writeback/cpumask
65 # There is a bug causing packet loss when VM is initialized. This workaround is
66 # supposed to re-initialize CPUs.
67 for i in $(ls -d /sys/devices/system/cpu/cpu[1-9]/online); do
73 # Start testpmd in the background. This looks a bit convoluted; we need to redirect stdin
74 # (and keep stdin active) or else testpmd will quit.
75 tail -f /dev/null | nohup testpmd $@ > ${TESTPMD_LOG} 2>&1 &
76 echo $! > ${TESTPMD_PID}
79 cat - > ${DPDK_STOP_FILE} <<"_EOF"
82 TESTPMD_LOG=/tmp/testpmd.log
83 TESTPMD_PID=/tmp/testpmd.pid
85 if [ ! -f ${TESTPMD_PID} ]
87 echo Testpmd is not running.
91 kill $(cat ${TESTPMD_PID})
97 chmod 755 ${DPDK_START_FILE}
98 chmod 755 ${DPDK_STOP_FILE}