blob: 1b6204125d2d79bb49ffa343457157cbf347316e [file] [log] [blame]
Jesper Dangaard Brouer05a14d52015-05-21 12:18:29 +02001#!/bin/bash
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01002# SPDX-License-Identifier: GPL-2.0
Jesper Dangaard Brouer05a14d52015-05-21 12:18:29 +02003#
4# Benchmark script:
5# - developed for benchmarking ingress qdisc path
6#
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().
10#
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.
14#
15# Setup scenarios for measuring ingress qdisc (with invalid dst_mac):
16# ------------------------------------------------------------------
17# (1) no ingress (uses static_key_false(&ingress_needed))
18#
19# (2) ingress on other dev (change ingress_needed and calls
20# handle_ing() but exit early)
21#
22# config: tc qdisc add dev $SOMEDEV handle ffff: ingress
23#
24# (3) ingress on this dev, handle_ing() -> tc_classify()
25#
26# config: tc qdisc add dev $DEV handle ffff: ingress
27#
28# (4) ingress on this dev + drop at u32 classifier/action.
29#
30basedir=`dirname $0`
31source ${basedir}/functions.sh
32root_check_run_with_sudo "$@"
33
34# Parameter parsing via include
35source ${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
Martin KaFai Lau0f06a672016-07-20 15:48:43 -070038if [ -z "$DEST_IP" ]; then
39 [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1"
40fi
Jesper Dangaard Brouer05a14d52015-05-21 12:18:29 +020041[ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"
42[ -z "$BURST" ] && BURST=1024
Tariq Toukan69137ea2017-06-15 19:07:21 +030043[ -z "$COUNT" ] && COUNT="10000000" # Zero means indefinitely
Daniel T. Lee40f843e2019-10-05 17:25:09 +090044if [ -n "$DEST_IP" ]; then
45 validate_addr${IP6} $DEST_IP
46 read -r DST_MIN DST_MAX <<< $(parse_addr${IP6} $DEST_IP)
47fi
Daniel T. Lee6e32a742019-06-29 22:33:58 +090048if [ -n "$DST_PORT" ]; then
Daniel T. Lee723d2902019-10-05 17:25:06 +090049 read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)
50 validate_ports $UDP_DST_MIN $UDP_DST_MAX
Daniel T. Lee6e32a742019-06-29 22:33:58 +090051fi
Jesper Dangaard Brouer05a14d52015-05-21 12:18:29 +020052
53# Base Config
54DELAY="0" # Zero means max speed
Jesper Dangaard Brouer05a14d52015-05-21 12:18:29 +020055
56# General cleanup everything since last run
57pg_ctrl "reset"
58
59# Threads are specified with parameter -t value in $THREADS
Tariq Toukane0e16672017-06-15 19:07:22 +030060for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
Jesper Dangaard Brouer05a14d52015-05-21 12:18:29 +020061 # The device name is extended with @name, using thread number to
62 # make then unique, but any name will do.
63 dev=${DEV}@${thread}
64
65 # Add remove all other devices and add_device $dev to thread
66 pg_thread $thread "rem_device_all"
67 pg_thread $thread "add_device" $dev
68
69 # Base config of dev
70 pg_set $dev "flag QUEUE_MAP_CPU"
71 pg_set $dev "count $COUNT"
72 pg_set $dev "pkt_size $PKT_SIZE"
73 pg_set $dev "delay $DELAY"
74 pg_set $dev "flag NO_TIMESTAMP"
75
76 # Destination
77 pg_set $dev "dst_mac $DST_MAC"
Daniel T. Lee40f843e2019-10-05 17:25:09 +090078 pg_set $dev "dst${IP6}_min $DST_MIN"
79 pg_set $dev "dst${IP6}_max $DST_MAX"
Jesper Dangaard Brouer05a14d52015-05-21 12:18:29 +020080
Daniel T. Lee6e32a742019-06-29 22:33:58 +090081 if [ -n "$DST_PORT" ]; then
82 # Single destination port or random port range
83 pg_set $dev "flag UDPDST_RND"
Daniel T. Lee723d2902019-10-05 17:25:06 +090084 pg_set $dev "udp_dst_min $UDP_DST_MIN"
85 pg_set $dev "udp_dst_max $UDP_DST_MAX"
Daniel T. Lee6e32a742019-06-29 22:33:58 +090086 fi
87
Jesper Dangaard Brouer05a14d52015-05-21 12:18:29 +020088 # Inject packet into RX path of stack
89 pg_set $dev "xmit_mode netif_receive"
90
91 # Burst allow us to avoid measuring SKB alloc/free overhead
92 pg_set $dev "burst $BURST"
93done
94
95# start_run
96echo "Running... ctrl^C to stop" >&2
97pg_ctrl "start"
98echo "Done" >&2
99
100# Print results
Tariq Toukane0e16672017-06-15 19:07:22 +0300101for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
Jesper Dangaard Brouer05a14d52015-05-21 12:18:29 +0200102 dev=${DEV}@${thread}
103 echo "Device: $dev"
104 cat /proc/net/pktgen/$dev | grep -A2 "Result:"
105done