aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorJuha-Matti Tilli <juha-matti.tilli@iki.fi>2017-12-23 11:58:32 +0200
committerMaxim Uvarov <maxim.uvarov@linaro.org>2018-01-24 16:36:26 +0300
commit91b127d61530bcf0e8c5399b3d4117ef2389ca12 (patch)
tree41bc7c8983ee4c0d0493226ce189b0f11e876342 /example
parentb122176ee59494dd957f0f5ff41d4b55a1477e13 (diff)
linux-generic: pktio: add null pktio support
Sometimes, you may wish to run an application by using a dummy interface that never receives any packets and that discards transmitted packets. This is possible with non-looping pcap pktio with no input and output pcaps. So, the pktio would be just "pcap:". However, you cannot have two pktios named "pcap:" because there is code to check if the pktio is already opened. Also, the pcap pktio requires that ODP is compiled with the pcap library, which it may not be. Also, pcap is always single-queue and therefore not suitable for modern multi-queue applications. Also, recently a patch was provided to ODP to allow interruptible sleep when receiving packets. This, however, does not work with mixed pcap and socket/netmap pktio types. To fix these issues, a new "null" pktio is introduced. It is used by specifying the interface name to be "null:0", "null:1", or similar. All packets sent to the null pktio are discarded and no packets are received. The null pktio fully supports the interruptible sleep infrastructure, meaning applications can have 0% idle CPU load when one interface is a null interface and another interface is socket or netmap. Signed-off-by: Juha-Matti Tilli <juha-matti.tilli@iki.fi> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'example')
-rw-r--r--example/generator/Makefile.am5
-rwxr-xr-xexample/generator/generator_run.sh17
-rwxr-xr-xexample/l2fwd_simple/l2fwd_simple_run.sh13
3 files changed, 35 insertions, 0 deletions
diff --git a/example/generator/Makefile.am b/example/generator/Makefile.am
index 7deeef406..63f4ae608 100644
--- a/example/generator/Makefile.am
+++ b/example/generator/Makefile.am
@@ -3,3 +3,8 @@ include $(top_srcdir)/example/Makefile.inc
bin_PROGRAMS = odp_generator
odp_generator_SOURCES = odp_generator.c
+
+if test_example
+TESTS = generator_run.sh
+endif
+EXTRA_DIST = generator_run.sh
diff --git a/example/generator/generator_run.sh b/example/generator/generator_run.sh
new file mode 100755
index 000000000..2d741a8d1
--- /dev/null
+++ b/example/generator/generator_run.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# Copyright (c) 2018, Linaro Limited
+# All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+./odp_generator${EXEEXT} -w 1 -n 1 -I null:0 -m u
+STATUS=$?
+
+if [ "$STATUS" -ne 0 ]; then
+ echo "Error: status was: $STATUS, expected 0"
+ exit 1
+fi
+
+exit 0
diff --git a/example/l2fwd_simple/l2fwd_simple_run.sh b/example/l2fwd_simple/l2fwd_simple_run.sh
index 089d9f97d..d09bd3cfe 100755
--- a/example/l2fwd_simple/l2fwd_simple_run.sh
+++ b/example/l2fwd_simple/l2fwd_simple_run.sh
@@ -29,4 +29,17 @@ fi
rm -f pcapout.pcap
+./odp_l2fwd_simple${EXEEXT} null:0 null:1 \
+ 02:00:00:00:00:01 02:00:00:00:00:02 &
+
+sleep 1
+kill -s SIGINT $!
+wait $!
+STATUS=$?
+
+if [ "$STATUS" -ne 255 ]; then
+ echo "Error: status was: $STATUS, expected 255"
+ exit 1
+fi
+
exit 0