2018-04-20 14:46:27 +01:00
|
|
|
# OVS_DPDK_PRE_CHECK()
|
|
|
|
#
|
|
|
|
# Check prerequisites for DPDK tests. Following settings are checked:
|
|
|
|
# - Hugepages
|
|
|
|
#
|
|
|
|
m4_define([OVS_DPDK_PRE_CHECK],
|
|
|
|
[dnl Check Hugepages
|
|
|
|
AT_CHECK([cat /proc/meminfo], [], [stdout])
|
2022-09-12 21:38:46 +02:00
|
|
|
AT_SKIP_IF([grep -E 'HugePages_Free: *0' stdout], [], [stdout])
|
2018-09-14 10:11:57 -04:00
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
# OVS_DPDK_PRE_PHY_SKIP()
|
|
|
|
#
|
|
|
|
# Skip any phy related tests if the PHY variable is not set.
|
|
|
|
# This is done by checking for a bound driver.
|
|
|
|
#
|
|
|
|
m4_define([OVS_DPDK_PRE_PHY_SKIP],
|
|
|
|
[dnl Perform the precheck
|
|
|
|
OVS_DPDK_PRE_CHECK()
|
|
|
|
|
2018-04-20 14:46:27 +01:00
|
|
|
dnl Check if VFIO or UIO driver is loaded
|
2018-09-14 10:11:57 -04:00
|
|
|
AT_SKIP_IF([ ! (lsmod | grep -E "igb_uio|vfio") ], [], [stdout])
|
2018-04-20 14:46:27 +01:00
|
|
|
|
|
|
|
dnl Find PCI address candidate, skip if there is no DPDK-compatible NIC
|
|
|
|
AT_CHECK([$DPDK_DIR/usertools/dpdk-devbind.py -s | head -n +4 | tail -1], [], [stdout])
|
|
|
|
AT_CHECK([cat stdout | cut -d" " -s -f1 > PCI_ADDR])
|
2018-09-14 10:11:57 -04:00
|
|
|
AT_SKIP_IF([ ! test -s PCI_ADDR ])
|
|
|
|
|
2018-04-20 14:46:27 +01:00
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
# OVS_DPDK_START()
|
|
|
|
#
|
2022-06-24 11:13:24 +01:00
|
|
|
# Start ovsdb-server. Set dpdk-init to initialize DPDK. Start ovs-vswitchd.
|
2018-04-20 14:46:27 +01:00
|
|
|
#
|
|
|
|
m4_define([OVS_DPDK_START],
|
2022-06-24 11:13:24 +01:00
|
|
|
[dnl start ovs dpdk
|
|
|
|
OVS_DPDK_START_OVSDB()
|
|
|
|
dnl Enable DPDK functionality
|
|
|
|
AT_CHECK([ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true])
|
2023-05-12 15:41:41 +02:00
|
|
|
OVS_DPDK_START_VSWITCHD($1)
|
2022-06-24 11:13:24 +01:00
|
|
|
])
|
|
|
|
|
|
|
|
# OVS_DPDK_START_OVSDB()
|
|
|
|
#
|
|
|
|
# Create an empty database and start ovsdb-server.
|
|
|
|
#
|
|
|
|
m4_define([OVS_DPDK_START_OVSDB],
|
2018-04-20 14:46:27 +01:00
|
|
|
[dnl Create database.
|
|
|
|
AT_CHECK([touch .conf.db.~lock~])
|
|
|
|
AT_CHECK([ovsdb-tool create conf.db $abs_top_srcdir/vswitchd/vswitch.ovsschema])
|
|
|
|
|
|
|
|
dnl Start ovsdb-server.
|
|
|
|
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock], [0], [stdout], [stderr])
|
|
|
|
on_exit "kill `cat ovsdb-server.pid`"
|
|
|
|
AT_CHECK([[sed < stderr '
|
|
|
|
/vlog|INFO|opened log file/d
|
|
|
|
/ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
|
|
|
|
AT_CAPTURE_FILE([ovsdb-server.log])
|
|
|
|
|
|
|
|
dnl Initialize database.
|
|
|
|
AT_CHECK([ovs-vsctl --no-wait init])
|
2022-06-24 11:13:24 +01:00
|
|
|
])
|
2018-04-20 14:46:27 +01:00
|
|
|
|
2022-06-24 11:13:24 +01:00
|
|
|
# OVS_DPDK_START_VSWITCHD()
|
|
|
|
#
|
|
|
|
# Add special configuration for dpdk-init. Start ovs-vswitchd.
|
|
|
|
#
|
|
|
|
m4_define([OVS_DPDK_START_VSWITCHD],
|
|
|
|
[dnl Change DPDK drivers log levels so that tests only catch errors
|
2023-05-12 15:41:41 +02:00
|
|
|
AT_CHECK([ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-extra="--log-level=pmd.*:error $1"])
|
2022-01-03 15:15:49 +01:00
|
|
|
|
2018-04-20 14:46:27 +01:00
|
|
|
dnl Start ovs-vswitchd.
|
|
|
|
AT_CHECK([ovs-vswitchd --detach --no-chdir --pidfile --log-file -vvconn -vofproto_dpif -vunixctl], [0], [stdout], [stderr])
|
|
|
|
AT_CAPTURE_FILE([ovs-vswitchd.log])
|
|
|
|
on_exit "kill_ovs_vswitchd `cat ovs-vswitchd.pid`"
|
|
|
|
])
|
2023-11-20 16:56:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
# OVS_DPDK_CHECK_TESTPMD()
|
|
|
|
#
|
|
|
|
# Check dpdk-testpmd availability.
|
|
|
|
#
|
|
|
|
m4_define([OVS_DPDK_CHECK_TESTPMD],
|
|
|
|
[AT_SKIP_IF([! which dpdk-testpmd >/dev/null 2>/dev/null])
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
# OVS_DPDK_START_TESTPMD()
|
|
|
|
#
|
|
|
|
# Start dpdk-testpmd in background.
|
|
|
|
#
|
|
|
|
m4_define([OVS_DPDK_START_TESTPMD],
|
|
|
|
[AT_CHECK([lscpu], [], [stdout])
|
|
|
|
AT_CHECK([cat stdout | grep "NUMA node(s)" | awk '{c=1; while (c++<$(3)) {printf "512,"}; print "512"}' > NUMA_NODE])
|
2023-11-20 16:56:41 +01:00
|
|
|
eal_options="$DPDK_EAL_OPTIONS --in-memory --socket-mem="$(cat NUMA_NODE)" --single-file-segments --no-pci"
|
2023-11-20 16:56:39 +01:00
|
|
|
options="$1"
|
|
|
|
test "$options" != "${options%% -- *}" || options="$options -- "
|
|
|
|
eal_options="$eal_options ${options%% -- *}"
|
|
|
|
testpmd_options="-a --stats-period 2 ${options#* -- }"
|
|
|
|
echo "dpdk-testpmd $eal_options -- $testpmd_options" >testpmd.cmd
|
|
|
|
dpdk-testpmd $eal_options -- $testpmd_options >testpmd.log 2>&1 & \
|
|
|
|
echo $! > testpmd.pid
|
|
|
|
on_exit "kill -9 `cat testpmd.pid`"
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
# OVS_DPDK_STOP_TESTPMD()
|
|
|
|
#
|
|
|
|
# Stop background dpdk-testpmd.
|
|
|
|
#
|
|
|
|
m4_define([OVS_DPDK_STOP_TESTPMD],
|
|
|
|
[AT_CHECK([kill `cat testpmd.pid`])
|
|
|
|
OVS_WAIT([kill -0 `cat testpmd.pid`], [kill -9 `cat testpmd.pid`])
|
|
|
|
])
|