Skip to content

Commit 6fd980a

Browse files
jrfastabdavem330
authored andcommitted
net: samples: pktgen mode samples/tests for qdisc layer
This adds samples for pktgen to use with new mode to inject pkts into the qdisc layer. This also doubles as nice test cases to test any patches against qdisc layer. Signed-off-by: John Fastabend <john.r.fastabend@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0967f24 commit 6fd980a

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
#
3+
# Benchmark script:
4+
# - developed for benchmarking egress qdisc path, derived (more
5+
# like cut'n'pasted) from ingress benchmark script.
6+
#
7+
# Script for injecting packets into egress qdisc path of the stack
8+
# with pktgen "xmit_mode queue_xmit".
9+
#
10+
basedir=`dirname $0`
11+
source ${basedir}/functions.sh
12+
root_check_run_with_sudo "$@"
13+
14+
# Parameter parsing via include
15+
source ${basedir}/parameters.sh
16+
[ -z "$DEST_IP" ] && DEST_IP="198.18.0.42"
17+
[ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"
18+
19+
# Burst greater than 1 are invalid for queue_xmit mode
20+
if [[ -n "$BURST" ]]; then
21+
err 1 "Bursting not supported for this mode"
22+
fi
23+
24+
# Base Config
25+
DELAY="0" # Zero means max speed
26+
COUNT="10000000" # Zero means indefinitely
27+
28+
# General cleanup everything since last run
29+
pg_ctrl "reset"
30+
31+
# Threads are specified with parameter -t value in $THREADS
32+
for ((thread = 0; thread < $THREADS; thread++)); do
33+
# The device name is extended with @name, using thread number to
34+
# make then unique, but any name will do.
35+
dev=${DEV}@${thread}
36+
37+
# Add remove all other devices and add_device $dev to thread
38+
pg_thread $thread "rem_device_all"
39+
pg_thread $thread "add_device" $dev
40+
41+
# Base config of dev
42+
pg_set $dev "flag QUEUE_MAP_CPU"
43+
pg_set $dev "count $COUNT"
44+
pg_set $dev "pkt_size $PKT_SIZE"
45+
pg_set $dev "delay $DELAY"
46+
pg_set $dev "flag NO_TIMESTAMP"
47+
48+
# Destination
49+
pg_set $dev "dst_mac $DST_MAC"
50+
pg_set $dev "dst $DEST_IP"
51+
52+
# Inject packet into TX qdisc egress path of stack
53+
pg_set $dev "xmit_mode queue_xmit"
54+
done
55+
56+
# start_run
57+
echo "Running... ctrl^C to stop" >&2
58+
pg_ctrl "start"
59+
echo "Done" >&2
60+
61+
# Print results
62+
for ((thread = 0; thread < $THREADS; thread++)); do
63+
dev=${DEV}@${thread}
64+
echo "Device: $dev"
65+
cat /proc/net/pktgen/$dev | grep -A2 "Result:"
66+
done

0 commit comments

Comments
 (0)