Signed-off-by: Ilya Maximets <i.maxim...@samsung.com>
---
 tests/automake.mk  |   1 +
 tests/pmd.at       | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/testsuite.at |   1 +
 3 files changed, 181 insertions(+)
 create mode 100644 tests/pmd.at

diff --git a/tests/automake.mk b/tests/automake.mk
index 7af7f69..777f6db 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -48,6 +48,7 @@ TESTSUITE_AT = \
        tests/json.at \
        tests/jsonrpc.at \
        tests/jsonrpc-py.at \
+       tests/pmd.at \
        tests/tunnel.at \
        tests/tunnel-push-pop.at \
        tests/tunnel-push-pop-ipv6.at \
diff --git a/tests/pmd.at b/tests/pmd.at
new file mode 100644
index 0000000..73cd52d
--- /dev/null
+++ b/tests/pmd.at
@@ -0,0 +1,179 @@
+AT_BANNER([PMD])
+
+dnl CHECK_CPU_DISCOVERED([n_cpu])
+dnl
+dnl Waits until CPUs discovered and checks if number of discovered CPUs
+dnl is greater or equal to 'n_cpu'. Without parameters checks that at
+dnl least one CPU discovered.
+m4_define([CHECK_CPU_DISCOVERED], [
+       PATTERN="Discovered [[0-9]]* NUMA nodes and [[0-9]]* CPU cores"
+       OVS_WAIT_UNTIL([grep "$PATTERN" ovs-vswitchd.log])
+       N_CPU=$(grep "$PATTERN" ovs-vswitchd.log | sed -e 's/.* \([[0-9]]*\) 
CPU cores/\1/')
+       if [[ -z "$1" ]]
+               then AT_CHECK([test "$N_CPU" -gt "0"])
+               else AT_SKIP_IF([test "$N_CPU" -lt "$1"])
+       fi
+])
+
+dnl CHECK_PMD_THREADS_CREATED([n_threads], [numa_id], [+line])
+dnl
+dnl Whaits for creation of 'n_threads' or at least 1 thread if $1 not
+dnl passed. Checking starts from line number 'line' in ovs-vswithd.log .
+m4_define([CHECK_PMD_THREADS_CREATED], [
+       PATTERN="Created [[0-9]]* pmd threads on numa node $2"
+       line_st=$3
+       if [[ -z "$line_st" ]]
+               then
+                       line_st="+0"
+       fi
+       OVS_WAIT_UNTIL([tail -n $line_st ovs-vswitchd.log | grep "$PATTERN"])
+       N_THREADS=$(tail -n $line_st ovs-vswitchd.log | grep "$PATTERN" | tail 
-1 | sed -e 's/.* \([[0-9]]*\) pmd .*/\1/')
+       if [[ -z "$1" ]]
+               then AT_CHECK([test "$N_THREADS" -gt 0])
+               else AT_CHECK([test "$N_THREADS" -eq "$1"])
+       fi
+])
+
+m4_define([SED_NUMA_CORE_PATTERN], ["s/\(numa_id \)[[0-9]]*\( core_id 
\)[[0-9]]*:/\1<cleared>\2<cleared>:/"])
+
+AT_SETUP([PMD - creating a thread/add-port])
+OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy-pmd])
+
+CHECK_CPU_DISCOVERED()
+CHECK_PMD_THREADS_CREATED()
+
+AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], 
[0], [dnl
+pmd thread numa_id <cleared> core_id <cleared>:
+       port: p0        queue-id: 0
+])
+
+AT_CHECK([ovs-appctl dpif/show | sed 
's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
+dummy@ovs-dummy: hit:0 missed:0
+       br0:
+               br0 65534/100: (dummy)
+               p0 1/1: (dummy-pmd: configured_rx_queues=1, 
configured_tx_queues=<cleared>, requested_rx_queues=1, 
requested_tx_queues=<cleared>)
+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+AT_SETUP([PMD - multiqueue support])
+OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy-pmd])
+
+CHECK_CPU_DISCOVERED()
+CHECK_PMD_THREADS_CREATED()
+
+AT_CHECK([ovs-vsctl set interface p0 options:n_rxq=8])
+
+AT_CHECK([ovs-appctl dpif/show | sed 
's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
+dummy@ovs-dummy: hit:0 missed:0
+       br0:
+               br0 65534/100: (dummy)
+               p0 1/1: (dummy-pmd: configured_rx_queues=8, 
configured_tx_queues=<cleared>, requested_rx_queues=8, 
requested_tx_queues=<cleared>)
+])
+
+AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], 
[0], [dnl
+pmd thread numa_id <cleared> core_id <cleared>:
+       port: p0        queue-id: 0 1 2 3 4 5 6 7
+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+
+AT_SETUP([PMD - pmd-cpu-mask/distribution of rx queues])
+OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy-pmd 
options:n_rxq=8])
+
+CHECK_CPU_DISCOVERED(2)
+CHECK_PMD_THREADS_CREATED()
+
+AT_CHECK([ovs-appctl dpif/show | sed 
's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
+dummy@ovs-dummy: hit:0 missed:0
+       br0:
+               br0 65534/100: (dummy)
+               p0 1/1: (dummy-pmd: configured_rx_queues=8, 
configured_tx_queues=<cleared>, requested_rx_queues=8, 
requested_tx_queues=<cleared>)
+])
+
+AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], 
[0], [dnl
+pmd thread numa_id <cleared> core_id <cleared>:
+       port: p0        queue-id: 0 1 2 3 4 5 6 7
+])
+
+TMP=$(cat ovs-vswitchd.log | wc -l)
+AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=3])
+CHECK_PMD_THREADS_CREATED([2], [], [+$TMP])
+
+AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], 
[0], [dnl
+pmd thread numa_id <cleared> core_id <cleared>:
+       port: p0        queue-id: 0 2 4 6
+pmd thread numa_id <cleared> core_id <cleared>:
+       port: p0        queue-id: 1 3 5 7
+])
+
+TMP=$(cat ovs-vswitchd.log | wc -l)
+AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=1])
+CHECK_PMD_THREADS_CREATED([1], [], [+$TMP])
+
+AT_CHECK([ovs-appctl dpif-netdev/pmd-rxq-show | sed SED_NUMA_CORE_PATTERN], 
[0], [dnl
+pmd thread numa_id <cleared> core_id <cleared>:
+       port: p0        queue-id: 0 1 2 3 4 5 6 7
+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+
+AT_SETUP([PMD - stats])
+OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 ofport_request=7 
type=dummy-pmd options:n_rxq=4])
+
+CHECK_CPU_DISCOVERED()
+CHECK_PMD_THREADS_CREATED()
+
+AT_CHECK([ovs-appctl vlog/set dpif_netdev:dbg])
+AT_CHECK([ovs-ofctl add-flow br0 action=normal])
+
+sleep 1
+
+AT_CHECK([ovs-appctl dpif/show | sed 
's/\(tx_queues=\)[[0-9]]*/\1<cleared>/g'], [0], [dnl
+dummy@ovs-dummy: hit:0 missed:0
+       br0:
+               br0 65534/100: (dummy)
+               p0 7/1: (dummy-pmd: configured_rx_queues=4, 
configured_tx_queues=<cleared>, requested_rx_queues=4, 
requested_tx_queues=<cleared>)
+])
+
+AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | sed SED_NUMA_CORE_PATTERN | 
sed '/cycles/d' | grep pmd -A 4], [0], [dnl
+pmd thread numa_id <cleared> core_id <cleared>:
+       emc hits:0
+       megaflow hits:0
+       miss:0
+       lost:0
+])
+
+ovs-appctl time/stop
+ovs-appctl time/warp 100
+(
+for i in `seq 0 19`;
+    do
+    
pkt="in_port(7),eth(src=50:54:00:00:00:77,dst=50:54:00:00:01:78),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)"
+    AT_CHECK([ovs-appctl netdev-dummy/receive p0 $pkt])
+    done
+)
+ovs-appctl time/warp 100
+
+AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
+skb_priority(0),skb_mark(0),recirc_id(0),dp_hash(0),in_port(1),eth(src=50:54:00:00:00:77,dst=50:54:00:00:01:78),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)
+])
+AT_CHECK([cat ovs-vswitchd.log | filter_flow_install | strip_xout], [0], [dnl
+recirc_id=0,ip,in_port=1,vlan_tci=0x0000/0x1fff,dl_src=50:54:00:00:00:77,dl_dst=50:54:00:00:01:78,nw_frag=no,
 actions: <del>
+])
+
+AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | sed SED_NUMA_CORE_PATTERN | 
sed '/cycles/d' | grep pmd -A 4], [0], [dnl
+pmd thread numa_id <cleared> core_id <cleared>:
+       emc hits:19
+       megaflow hits:0
+       miss:1
+       lost:0
+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
diff --git a/tests/testsuite.at b/tests/testsuite.at
index c2f8e61..6b3fb25 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -56,6 +56,7 @@ m4_include([tests/reconnect.at])
 m4_include([tests/ovs-vswitchd.at])
 m4_include([tests/ofproto.at])
 m4_include([tests/dpif-netdev.at])
+m4_include([tests/pmd.at])
 m4_include([tests/dpctl.at])
 m4_include([tests/ofproto-dpif.at])
 m4_include([tests/bridge.at])
-- 
2.5.0

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to