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