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
39 grep -q hugetlbfs /etc/fstab || echo "hugetlbfs /mnt/huge hugetlbfs mode=1770,gid=2021 0 0" >> /etc/fstab
43 echo 1af4 1000 > /sys/bus/pci/drivers/${TARGET_DRIVER}/new_id
45 for dev in $(find /sys/bus/pci/drivers/virtio-pci -type l -name '*:*:*.*' | sed -e 's/.*\///')
47 echo Unbinding $dev from virtio-pci
48 echo $dev > /sys/bus/pci/drivers/virtio-pci/unbind
49 echo Binding $dev to ${TARGET_DRIVER}
50 echo $dev > /sys/bus/pci/drivers/${TARGET_DRIVER}/bind
53 # Start testpmd in the background. This looks a bit convoluted; we need to redirect stdin
54 # (and keep stdin active) or else testpmd will quit.
55 tail -f /dev/null | nohup testpmd $@ > ${TESTPMD_LOG} 2>&1 &
56 echo $! > ${TESTPMD_PID}
59 cat - > ${DPDK_STOP_FILE} <<"_EOF"
62 TESTPMD_LOG=/tmp/testpmd.log
63 TESTPMD_PID=/tmp/testpmd.pid
65 if [ ! -f ${TESTPMD_PID} ]
67 echo Testpmd is not running.
71 kill $(cat ${TESTPMD_PID})
77 chmod 755 ${DPDK_START_FILE}
78 chmod 755 ${DPDK_STOP_FILE}