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