Linux 4.14.129
[linux-stable.git] / samples / pktgen / pktgen_bench_xmit_mode_netif_receive.sh
blob2839f7d315cf6c2f8aa2f1524b4467c360501dba
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Benchmark script:
5 # - developed for benchmarking ingress qdisc path
7 # Script for injecting packets into RX path of the stack with pktgen
8 # "xmit_mode netif_receive". With an invalid dst_mac this will only
9 # measure the ingress code path as packets gets dropped in ip_rcv().
11 # This script don't really need any hardware. It benchmarks software
12 # RX path just after NIC driver level. With bursting is also
13 # "removes" the SKB alloc/free overhead.
15 # Setup scenarios for measuring ingress qdisc (with invalid dst_mac):
16 # ------------------------------------------------------------------
17 # (1) no ingress (uses static_key_false(&ingress_needed))
19 # (2) ingress on other dev (change ingress_needed and calls
20 # handle_ing() but exit early)
22 # config: tc qdisc add dev $SOMEDEV handle ffff: ingress
24 # (3) ingress on this dev, handle_ing() -> tc_classify()
26 # config: tc qdisc add dev $DEV handle ffff: ingress
28 # (4) ingress on this dev + drop at u32 classifier/action.
30 basedir=`dirname $0`
31 source ${basedir}/functions.sh
32 root_check_run_with_sudo "$@"
34 # Parameter parsing via include
35 source ${basedir}/parameters.sh
36 # Using invalid DST_MAC will cause the packets to get dropped in
37 # ip_rcv() which is part of the test
38 if [ -z "$DEST_IP" ]; then
39 [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
41 [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"
42 [ -z "$BURST" ] && BURST=1024
43 [ -z "$COUNT" ] && COUNT="10000000" # Zero means indefinitely
45 # Base Config
46 DELAY="0" # Zero means max speed
48 # General cleanup everything since last run
49 pg_ctrl "reset"
51 # Threads are specified with parameter -t value in $THREADS
52 for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
53 # The device name is extended with @name, using thread number to
54 # make then unique, but any name will do.
55 dev=${DEV}@${thread}
57 # Add remove all other devices and add_device $dev to thread
58 pg_thread $thread "rem_device_all"
59 pg_thread $thread "add_device" $dev
61 # Base config of dev
62 pg_set $dev "flag QUEUE_MAP_CPU"
63 pg_set $dev "count $COUNT"
64 pg_set $dev "pkt_size $PKT_SIZE"
65 pg_set $dev "delay $DELAY"
66 pg_set $dev "flag NO_TIMESTAMP"
68 # Destination
69 pg_set $dev "dst_mac $DST_MAC"
70 pg_set $dev "dst$IP6 $DEST_IP"
72 # Inject packet into RX path of stack
73 pg_set $dev "xmit_mode netif_receive"
75 # Burst allow us to avoid measuring SKB alloc/free overhead
76 pg_set $dev "burst $BURST"
77 done
79 # start_run
80 echo "Running... ctrl^C to stop" >&2
81 pg_ctrl "start"
82 echo "Done" >&2
84 # Print results
85 for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
86 dev=${DEV}@${thread}
87 echo "Device: $dev"
88 cat /proc/net/pktgen/$dev | grep -A2 "Result:"
89 done